From 3381fae281ba7caaa9aaf04effe0ca2ab985ef4f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Aug 2004 18:42:17 +0600 Subject: [PATCH 01/41] Change information text in pipe and shared memory libmysql/errmsg.c: Changed texts of shared memory and pipe sql-common/client.c: remove information about host from pipe and change assigment of host_info in shared_memory --- libmysql/errmsg.c | 12 ++++++------ sql-common/client.c | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 2b941470fc3..6d78569887e 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -39,7 +39,7 @@ const char *client_errors[]= "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; you can't run this command now", - "Verbindung ueber Named Pipe; Host: %-.100s", + "Verbindung ueber Named Pipe: %-.32s", "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", @@ -61,7 +61,7 @@ const char *client_errors[]= "Invalid parameter number", "Can't send long data for non-string/non-binary data types (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)", - "Shared memory (%lu)", + "Shared memory: %-.100s", "Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)", @@ -98,7 +98,7 @@ const char *client_errors[]= "Erro na negociao de acesso ao servidor", "Conexo perdida com servidor MySQL durante 'query'", "Comandos fora de sincronismo; voc no pode executar este comando agora", - "%-.100s via 'named pipe'", + "Named pipe: %-.32s", "No pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "No pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "No pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", @@ -120,7 +120,7 @@ const char *client_errors[]= "Invalid parameter number", "Can't send long data for non-string/non-binary data types (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)", - "Shared memory (%lu)", + "Shared memory: %-.100s", "Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)", @@ -155,7 +155,7 @@ const char *client_errors[]= "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; you can't run this command now", - "%-.100s via named pipe", + "Named pipe: %-.32s", "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", @@ -177,7 +177,7 @@ const char *client_errors[]= "Invalid parameter number", "Can't send long data for non-string/non-binary data types (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)", - "Shared memory (%lu)", + "Shared memory: %-.100s", "Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)", diff --git a/sql-common/client.c b/sql-common/client.c index 738904657cc..289944d35a0 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1613,7 +1613,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, sock=0; unix_socket = 0; host=mysql->options.shared_memory_base_name; - host_info=(char*) ER(CR_SHARED_MEMORY_CONNECTION); + sprintf(host_info=buff, ER(CR_SHARED_MEMORY_CONNECTION), host); } } #endif /* HAVE_SMEM */ @@ -1677,8 +1677,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, else { net->vio=vio_new_win32pipe(hPipe); - sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host, - unix_socket); + sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); } } #endif From afac3c31278d491e8e1329129b38df4ab2e9371e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Sep 2004 22:06:30 -0700 Subject: [PATCH 02/41] select.result, select.test: Added a test case for bug #5333. null_key.result, key_primary.result: Made covering index usable for const tables. sql_select.cc: Made covering index usable for const tables: downported the corresponding code from 4.1. Simultaneously fixed bug #5333 reported for 4.1. The bug was due to the fact that field index in join structures was always set to 0 for const tables. sql/sql_select.cc: Made covering index usable for const tables: downported the corresponding code from 4.1. Simultaneously fixed bug #5333 reported for 4.1. The bug was due to the fact that field index in join structures was always set to 0 for const tables. mysql-test/t/select.test: Added a test case for bug #5333. mysql-test/r/key_primary.result: Made covering index usable for const tables. mysql-test/r/null_key.result: Made covering index usable for const tables. mysql-test/r/select.result: Added a test case for bug #5333. --- mysql-test/r/key_primary.result | 2 +- mysql-test/r/null_key.result | 2 +- mysql-test/r/select.result | 16 ++++++++++++++++ mysql-test/t/select.test | 21 +++++++++++++++++++++ sql/sql_select.cc | 11 ++++++++++- 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/key_primary.result b/mysql-test/r/key_primary.result index 87289f1cf54..3216ead667b 100644 --- a/mysql-test/r/key_primary.result +++ b/mysql-test/r/key_primary.result @@ -13,7 +13,7 @@ t1 AB% describe select * from t1 where t1="ABC"; table type possible_keys key key_len ref rows Extra -t1 const PRIMARY PRIMARY 3 const 1 +t1 const PRIMARY PRIMARY 3 const 1 Using index describe select * from t1 where t1="ABCD"; Comment Impossible WHERE noticed after reading const tables diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 009a3e06eb2..41b0ae26617 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -12,7 +12,7 @@ table type possible_keys key key_len ref rows Extra t1 ref a,b a 9 const,const 1 Using where; Using index explain select * from t1 where a=2 and b = 2; table type possible_keys key key_len ref rows Extra -t1 const a,b a 9 const,const 1 +t1 const a,b a 9 const,const 1 Using index explain select * from t1 where a<=>b limit 2; table type possible_keys key key_len ref rows Extra t1 index NULL a 9 NULL 12 Using where; Using index diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 206fa507615..ce5ea94a08e 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2327,3 +2327,19 @@ select * from t2,t3 where t2.s = t3.s; s s two two drop table t1, t2, t3; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) TYPE=MyISAM; +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +table type possible_keys key key_len ref rows Extra +t1 const PRIMARY PRIMARY 4 const 1 Using index +EXPLAIN SELECT i FROM t1 WHERE i=1; +table type possible_keys key key_len ref rows Extra +t1 const PRIMARY PRIMARY 4 const 1 Using index +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 7cb157f194e..dae44159683 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1874,3 +1874,24 @@ select * from t3 where s = 'one'; select * from t1,t2 where t1.s = t2.s; select * from t2,t3 where t2.s = t3.s; drop table t1, t2, t3; + +# +# Covering index is mentioned in EXPLAIN output for const tables (bug #5333) +# + +CREATE TABLE t1 ( + i int(11) NOT NULL default '0', + c char(10) NOT NULL default '', + PRIMARY KEY (i), + UNIQUE KEY c (c) +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); + +EXPLAIN SELECT i FROM t1 WHERE i=1; + +EXPLAIN SELECT i FROM t1 WHERE i=1; + +DROP TABLE t1; \ No newline at end of file diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 882f345a1ca..d2b9f9d4588 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4901,6 +4901,15 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) } else { + if (!table->key_read && + (table->used_keys & ((key_map) 1 << tab->ref.key)) && + !table->no_keyread && + (int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY) + { + table->key_read=1; + table->file->extra(HA_EXTRA_KEYREAD); + tab->index= tab->ref.key; + } if ((error=join_read_const(tab))) { tab->info="unique row not found"; @@ -7617,7 +7626,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, sprintf(buff3,"%.0f",join->best_positions[i].records_read); item_list.push_back(new Item_string(buff3,strlen(buff3))); my_bool key_read=table->key_read; - if (tab->type == JT_NEXT && + if ((tab->type == JT_NEXT || tab->type == JT_CONST) && ((table->used_keys & ((key_map) 1 << tab->index)))) key_read=1; From 462ee7c4175436938785c06c77394247b83d0d87 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Sep 2004 19:26:11 +0500 Subject: [PATCH 03/41] A fix (bug #2631: mlockall called after dropping root permissions). --- sql/mysqld.cc | 124 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 37 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 670e6a5a63e..06599cf0ea7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -414,6 +414,7 @@ char mysql_real_data_home[FN_REFLEN], max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file; char *language_ptr= language; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; +struct passwd *user_info; #ifndef EMBEDDED_LIBRARY bool mysql_embedded=0; #else @@ -1028,27 +1029,26 @@ static void set_ports() } } -/* Change to run as another user if started with --user */ -static void set_user(const char *user) +static struct passwd *check_user(const char *user) { -#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - struct passwd *ent; +#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) + struct passwd *user_info; uid_t user_id= geteuid(); - - // don't bother if we aren't superuser + + // Don't bother if we aren't superuser if (user_id) { if (user) { - /* Don't give a warning, if real user is same as given with --user */ - struct passwd *user_info= getpwnam(user); + // Don't give a warning, if real user is same as given with --user + user_info= getpwnam(user); if ((!user_info || user_id != user_info->pw_uid) && - global_system_variables.log_warnings) - fprintf(stderr, - "Warning: One can only use the --user switch if running as root\n"); + global_system_variables.log_warnings) + fprintf(stderr, + "Warning: One can only use the --user switch if running as root\n"); } - return; + return NULL; } if (!user) { @@ -1057,38 +1057,52 @@ static void set_user(const char *user) fprintf(stderr,"Fatal error: Please read \"Security\" section of the manual to find out how to run mysqld as root!\n"); unireg_abort(1); } - return; + return NULL; } if (!strcmp(user,"root")) - return; // Avoid problem with dynamic libraries - - uid_t uid; - if (!(ent = getpwnam(user))) + return NULL; // Avoid problem with dynamic libraries + if (!(user_info= getpwnam(user))) { - // allow a numeric uid to be used + // Allow a numeric uid to be used const char *pos; - for (pos=user; isdigit(*pos); pos++) ; - if (*pos) // Not numeric id - { - fprintf(stderr,"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); - unireg_abort(1); - } - uid=atoi(user); // Use numberic uid + for (pos= user; isdigit(*pos); pos++); + if (*pos) // Not numeric id + goto err; + if (!(user_info= getpwuid(atoi(user)))) + goto err; + else + return user_info; } else { -#ifdef HAVE_INITGROUPS - initgroups((char*) user,ent->pw_gid); -#endif - if (setgid(ent->pw_gid) == -1) - { - sql_perror("setgid"); - unireg_abort(1); - } - uid=ent->pw_uid; + return user_info; } - if (setuid(uid) == -1) +err: + fprintf(stderr, + "Fatal error: Can't change to run as user '%s'. Please check that the user exists!\n", + user); + unireg_abort(1); + return NULL; +#else + return NULL; +#endif +} + + +static void set_user(const char *user, struct passwd *user_info) +{ +#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) + DBUG_ASSERT(user_info); +#ifdef HAVE_INITGROUPS + initgroups((char*) user, user_info->pw_gid); +#endif + if (setgid(user_info->pw_gid) == -1) + { + sql_perror("setgid"); + unireg_abort(1); + } + if (setuid(user_info->pw_uid) == -1) { sql_perror("setuid"); unireg_abort(1); @@ -1096,6 +1110,24 @@ static void set_user(const char *user) #endif } +static void set_effective_user(struct passwd *user_info) +{ +#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) + DBUG_ASSERT(user_info); + if (setegid(user_info->pw_gid) == -1) + { + sql_perror("setegid"); + unireg_abort(1); + } + if (seteuid(user_info->pw_uid) == -1) + { + sql_perror("seteuid"); + unireg_abort(1); + } +#endif +} + + /* Change root user if started with --chroot */ static void set_root(const char *path) @@ -1171,7 +1203,18 @@ static void server_init(void) unireg_abort(1); } } - set_user(mysqld_user); // Works also with mysqld_user==NULL + + if ((user_info= check_user(mysqld_user))) + { +#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) + if (locked_in_memory && !getuid()) + set_effective_user(user_info); + else + set_user(mysqld_user, user_info); +#else + set_user(mysqld_user, user_info); +#endif + } #ifdef __NT__ /* create named pipe */ @@ -2466,8 +2509,13 @@ You should consider changing lower_case_table_names to 1 or 2", } ha_key_cache(); #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) - if (locked_in_memory && !geteuid()) + if (locked_in_memory && !getuid()) { + if (seteuid(0) == -1) + { // this should never happen + sql_perror("seteuid"); + unireg_abort(1); + } if (mlockall(MCL_CURRENT)) { if (global_system_variables.log_warnings) @@ -2475,6 +2523,8 @@ You should consider changing lower_case_table_names to 1 or 2", } else locked_in_memory=1; + if (user_info) + set_user(mysqld_user, user_info); } #else locked_in_memory=0; From 4b4af1c1839cd6451d0cf03efa3ceca1a491d2a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Sep 2004 19:38:16 +0500 Subject: [PATCH 04/41] A fix (Bug #5291: float -> string, truncation, sometimes without warning). --- mysql-test/r/type_float.result | 2 ++ sql/field.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 843bdc2bdc5..75f0298797a 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -137,6 +137,8 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (c20 char); insert into t1 values (5000.0); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 drop table t1; create table t1 (f float(54)); ERROR 42000: Incorrect column specifier for column 'f' diff --git a/sql/field.cc b/sql/field.cc index 5356fbc773a..8a1c5ec5271 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4297,7 +4297,7 @@ if (field_length < 32 && fabs(nr) < log_10[field_length]-1) like inserting 500.0 in char(1) */ DBUG_ASSERT(field_length < 5 || length <= field_length+1); - return store((const char *)buff, min(length, field_length), charset()); + return store((const char *) buff, length, charset()); } From df8a43b8b2f51901fc35cd5dbd047e09941eeae3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Sep 2004 20:17:09 +0200 Subject: [PATCH 05/41] sql_print_error cleanup --- sql/ha_myisam.cc | 20 ++++++++--------- sql/handler.cc | 2 +- sql/opt_range.cc | 6 +++--- sql/slave.cc | 2 +- sql/sql_acl.cc | 56 +++++++++++++++++++++--------------------------- sql/sql_base.cc | 8 +++---- sql/sql_parse.cc | 12 +++++------ sql/sql_table.cc | 4 ++-- sql/sql_udf.cc | 3 +-- 9 files changed, 53 insertions(+), 60 deletions(-) diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 3d2d25b3e7d..95a294764d3 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -509,16 +509,16 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) (uint) (T_RETRY_WITHOUT_QUICK | T_QUICK))) { param.testflag&= ~T_RETRY_WITHOUT_QUICK; - sql_print_error("Note: Retrying repair of: '%s' without quick", - table->path); + sql_print_information("Retrying repair of: '%s' without quick", + table->path); continue; } param.testflag&= ~T_QUICK; if ((param.testflag & T_REP_BY_SORT)) { param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP; - sql_print_error("Note: Retrying repair of: '%s' with keycache", - table->path); + sql_print_information("Retrying repair of: '%s' with keycache", + table->path); continue; } break; @@ -527,10 +527,10 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) !(check_opt->flags & T_VERY_SILENT)) { char llbuff[22],llbuff2[22]; - sql_print_error("Note: Found %s of %s rows when repairing '%s'", - llstr(file->state->records, llbuff), - llstr(start_records, llbuff2), - table->path); + sql_print_information("Found %s of %s rows when repairing '%s'", + llstr(file->state->records, llbuff), + llstr(start_records, llbuff2), + table->path); } return error; } @@ -1034,7 +1034,7 @@ bool ha_myisam::check_and_repair(THD *thd) // Don't use quick if deleted rows if (!file->state->del && (myisam_recover_options & HA_RECOVER_QUICK)) check_opt.flags|=T_QUICK; - sql_print_error("Warning: Checking table: '%s'",table->path); + sql_print_warning("Checking table: '%s'",table->path); old_query= thd->query; old_query_length= thd->query_length; @@ -1045,7 +1045,7 @@ bool ha_myisam::check_and_repair(THD *thd) if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt)) { - sql_print_error("Warning: Recovering table: '%s'",table->path); + sql_print_warning("Recovering table: '%s'",table->path); check_opt.flags= ((myisam_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) | (marked_crashed ? 0 : T_QUICK) | diff --git a/sql/handler.cc b/sql/handler.cc index 15f30b25eb8..b7634b3cf33 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -558,7 +558,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) query_cache.invalidate(thd->transaction.changed_tables); #endif /*HAVE_QUERY_CACHE*/ if (error && trans == &thd->transaction.all && mysql_bin_log.is_open()) - sql_print_error("Error: Got error during commit; Binlog is not up to date!"); + sql_print_error("Got error during commit; Binlog is not up to date!"); thd->variables.tx_isolation=thd->session_tx_isolation; if (operation_done) { diff --git a/sql/opt_range.cc b/sql/opt_range.cc index f11ed31950a..27e8e9c11e7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2193,7 +2193,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) uint e_count=0; if (this == root && use_count != 1) { - sql_print_error("Note: Use_count: Wrong count %lu for root",use_count); + sql_print_information("Use_count: Wrong count %lu for root",use_count); return; } if (this->type != SEL_ARG::KEY_RANGE) @@ -2206,7 +2206,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) ulong count=count_key_part_usage(root,pos->next_key_part); if (count > pos->next_key_part->use_count) { - sql_print_error("Note: Use_count: Wrong count for key at %lx, %lu should be %lu", + sql_print_information("Use_count: Wrong count for key at %lx, %lu should be %lu", pos,pos->next_key_part->use_count,count); return; } @@ -2214,7 +2214,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) } } if (e_count != elements) - sql_print_error("Warning: Wrong use count: %u (should be %u) for tree at %lx", + sql_print_warning("Wrong use count: %u (should be %u) for tree at %lx", e_count, elements, (gptr) this); } diff --git a/sql/slave.cc b/sql/slave.cc index cb37a798037..96b484a3965 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1202,7 +1202,7 @@ slaves can't replicate a 5.0 or newer master."; else { mi->clock_diff_with_master= 0; /* The "most sensible" value */ - sql_print_error("Warning: \"SELECT UNIX_TIMESTAMP()\" failed on master, \ + sql_print_warning("\"SELECT UNIX_TIMESTAMP()\" failed on master, \ do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS"); } if (master_res) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 9c6853187f6..fc68e26c21d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -203,7 +203,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) host.sort= get_sort(2,host.host.hostname,host.db); if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) { - sql_print_error("Warning: 'host' entry '%s|%s' " + sql_print_warning("'host' entry '%s|%s' " "ignored in --skip-name-resolve mode.", host.host.hostname, host.db, host.host.hostname); continue; @@ -271,8 +271,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) user.user= get_field(&mem, table->field[1]); if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) { - sql_print_error("Warning: 'user' entry '%s@%s' " - "ignored in --skip-name-resolve mode.", + sql_print_warning("'user' entry '%s@%s' " + "ignored in --skip-name-resolve mode.", user.user, user.host.hostname, user.host.hostname); continue; } @@ -284,16 +284,16 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) { switch (password_len) { case 45: /* 4.1: to be removed */ - sql_print_error("Found 4.1 style password for user '%s@%s'. " - "Ignoring user. " - "You should change password for this user.", - user.user ? user.user : "", - user.host.hostname ? user.host.hostname : ""); + sql_print_warning("Found 4.1 style password for user '%s@%s'. " + "Ignoring user. " + "You should change password for this user.", + user.user ? user.user : "", + user.host.hostname ? user.host.hostname : ""); break; default: - sql_print_error("Found invalid password for user: '%s@%s'; " - "Ignoring user", user.user ? user.user : "", - user.host.hostname ? user.host.hostname : ""); + sql_print_warning("Found invalid password for user: '%s@%s'; " + "Ignoring user", user.user ? user.user : "", + user.host.hostname ? user.host.hostname : ""); break; } } @@ -368,15 +368,15 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) db.db=get_field(&mem, table->field[1]); if (!db.db) { - sql_print_error("Found an entry in the 'db' table with empty database name; Skipped"); + sql_print_warning("Found an entry in the 'db' table with empty database name; Skipped"); continue; } db.user=get_field(&mem, table->field[2]); if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) { - sql_print_error("Warning: 'db' entry '%s %s@%s' " - "ignored in --skip-name-resolve mode.", - db.db, db.user, db.host.hostname, db.host.hostname); + sql_print_warning("'db' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", + db.db, db.user, db.host.hostname, db.host.hostname); continue; } db.access=get_access(table,3); @@ -733,9 +733,9 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, else { if (global_system_variables.log_warnings) - sql_print_error("X509 ciphers mismatch: should be '%s' but is '%s'", - acl_user->ssl_cipher, - SSL_get_cipher(ssl)); + sql_print_information("X509 ciphers mismatch: should be '%s' but is '%s'", + acl_user->ssl_cipher, + SSL_get_cipher(ssl)); break; } } @@ -757,8 +757,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (strcmp(acl_user->x509_issuer, ptr)) { if (global_system_variables.log_warnings) - sql_print_error("X509 issuer mismatch: should be '%s' " - "but is '%s'", acl_user->x509_issuer, ptr); + sql_print_information("X509 issuer mismatch: should be '%s' " + "but is '%s'", acl_user->x509_issuer, ptr); free(ptr); break; } @@ -775,7 +775,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (strcmp(acl_user->x509_subject,ptr)) { if (global_system_variables.log_warnings) - sql_print_error("X509 subject mismatch: '%s' vs '%s'", + sql_print_information("X509 subject mismatch: '%s' vs '%s'", acl_user->x509_subject, ptr); } else @@ -2610,10 +2610,10 @@ my_bool grant_init(THD *org_thd) { if (hostname_requires_resolving(mem_check->host)) { - sql_print_error("Warning: 'tables_priv' entry '%s %s@%s' " - "ignored in --skip-name-resolve mode.", - mem_check->tname, mem_check->user, - mem_check->host, mem_check->host); + sql_print_warning("'tables_priv' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", + mem_check->tname, mem_check->user, + mem_check->host, mem_check->host); continue; } } @@ -3680,12 +3680,6 @@ int mysql_revoke_all(THD *thd, List &list) rw_unlock(&LOCK_grant); close_thread_tables(thd); - /* XXX this should not be necessary. The error message is already printed - by replace_xxx_table. my_error() should be use above instead of - sql_print_error(), and print ER_NONEXISTING_GRANT - as other grant - commands do */ - /* when this code is deleted, the error slot (error 1268) can be reused, - as this error code was not present in any MySQL release */ if (result) my_error(ER_REVOKE_GRANTS, MYF(0)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ac5008717e6..30f97cf20a9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1384,7 +1384,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, /* Give right error message */ thd->clear_error(); my_error(ER_NOT_KEYFILE, MYF(0), name, my_errno); - sql_print_error("Error: Couldn't repair table: %s.%s",db,name); + sql_print_error("Couldn't repair table: %s.%s",db,name); if (entry->file) closefrm(entry); error=1; @@ -1424,7 +1424,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, DBA on top of warning the client (which will automatically be done because of MYF(MY_WME) in my_malloc() above). */ - sql_print_error("Error: when opening HEAP table, could not allocate \ + sql_print_error("When opening HEAP table, could not allocate \ memory to write 'DELETE FROM `%s`.`%s`' to the binary log",db,name); if (entry->file) closefrm(entry); @@ -1820,8 +1820,8 @@ bool rm_temporary_table(enum db_type base, char *path) if (file && file->delete_table(path)) { error=1; - sql_print_error("Warning: Could not remove tmp table: '%s', error: %d", - path, my_errno); + sql_print_warning("Could not remove tmp table: '%s', error: %d", + path, my_errno); } delete file; DBUG_RETURN(error); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 79a011b9501..a90a58ddfe0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1022,12 +1022,12 @@ pthread_handler_decl(handle_one_connection,arg) if (net->error && net->vio != 0 && net->report_error) { if (!thd->killed && thd->variables.log_warnings > 1) - sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - thd->user ? thd->user : "unauthenticated", - thd->host_or_ip, - (net->last_errno ? ER(net->last_errno) : - ER(ER_UNKNOWN_ERROR))); + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + thd->user ? thd->user : "unauthenticated", + thd->host_or_ip, + (net->last_errno ? ER(net->last_errno) : + ER(ER_UNKNOWN_ERROR))); send_error(thd,net->last_errno,NullS); statistic_increment(aborted_threads,&LOCK_status); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 58e3bc1d9ac..a1760261f94 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3250,8 +3250,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, my_free((char*) table, MYF(0)); } else - sql_print_error("Warning: Could not open BDB table %s.%s after rename\n", - new_db,table_name); + sql_print_warning("Could not open BDB table %s.%s after rename\n", + new_db,table_name); (void) berkeley_flush_logs(); } #endif diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 561f79f9de1..0bb8ac8a28b 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -184,8 +184,7 @@ void udf_init() if (!(dl = dlopen(tmp->dl, RTLD_NOW))) { /* Print warning to log */ - sql_print_error(ER(ER_CANT_OPEN_LIBRARY), - tmp->dl,errno,dlerror()); + sql_print_error(ER(ER_CANT_OPEN_LIBRARY), tmp->dl,errno,dlerror()); /* Keep the udf in the hash so that we can remove it later */ continue; } From e9a404525242a1e9745f479a53d4b793b844b58b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 5 Sep 2004 11:27:31 +0200 Subject: [PATCH 06/41] union.test: drop table added BitKeeper/etc/ignore: Added support-files/my-innodb-heavy-4G.cnf to the ignore list mysql-test/r/union.result: drop table added mysql-test/t/union.test: drop table added --- .bzrignore | 1 + mysql-test/r/union.result | 1 + mysql-test/t/union.test | 1 + 3 files changed, 3 insertions(+) diff --git a/.bzrignore b/.bzrignore index 8583b7ef437..1d14c09a602 100644 --- a/.bzrignore +++ b/.bzrignore @@ -545,3 +545,4 @@ vio/test-sslserver vio/viotest-ssl scripts/make_win_binary_distribution EXCEPTIONS-CLIENT +support-files/my-innodb-heavy-4G.cnf diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 4b9555c334b..45866cdf495 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -420,6 +420,7 @@ a (SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; Wrong usage/placement of 'SQL_CALC_FOUND_ROWS' create temporary table t1 select a from t1 union select a from t2; +drop table t1; create table t1 select a from t1 union select a from t2; INSERT TABLE 't1' isn't allowed in FROM table list select a from t1 union select a from t2 order by t2.a; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index c978aef9ce0..2bcd50b11de 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -224,6 +224,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; (SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; create temporary table t1 select a from t1 union select a from t2; +drop table t1; --error 1093 create table t1 select a from t1 union select a from t2; --error 1054 From ac8f443a6c159925a75c64e11d8c38ef175f393b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 10:33:12 +0200 Subject: [PATCH 07/41] Added debug printout's to ha_ndbcluster sql/ha_ndbcluster.cc: Added debug function for printing key_range. Corrected number of arguments to DBUG_PRINT, too many %s --- sql/ha_ndbcluster.cc | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 815aed13ce3..74a1d2abb5b 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1111,12 +1111,12 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, const char* bounds[]= {"LE", "LT", "GE", "GT", "EQ"}; DBUG_ASSERT(bound >= 0 && bound <= 4); - DBUG_PRINT("info", ("Set Bound%s on %s %s %s %s", + DBUG_PRINT("info", ("Set Bound%s on %s %s %s", bounds[bound], field->field_name, key_nullable ? "NULLABLE" : "", key_null ? "NULL":"")); - DBUG_PRINT("info", ("Total length %ds", tot_len)); + DBUG_PRINT("info", ("Total length %d", tot_len)); DBUG_DUMP("key", (char*) key_ptr, key_store_len); @@ -1143,6 +1143,42 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, DBUG_RETURN(0); } +const char* key_flag_strs[] = +{ "HA_READ_KEY_EXACT", + "HA_READ_KEY_OR_NEXT", + "HA_READ_KEY_OR_PREV", + "HA_READ_AFTER_KEY", + "HA_READ_BEFORE_KEY", + "HA_READ_PREFIX", + "HA_READ_PREFIX_LAST", + "HA_READ_PREFIX_LAST_OR_PREV", + "HA_READ_MBR_CONTAIN", + "HA_READ_MBR_INTERSECT", + "HA_READ_MBR_WITHIN", + "HA_READ_MBR_DISJOINT", + "HA_READ_MBR_EQUAL" +}; + +const int no_of_key_flags = sizeof(key_flag_strs)/sizeof(char*); + +void print_key(const key_range* key, const char* info) +{ + if (key) + { + const char* str= key->flag < no_of_key_flags ? + key_flag_strs[key->flag] : "Unknown flag"; + + DBUG_LOCK_FILE; + fprintf(DBUG_FILE,"%s: %s, length=%d, key=", info, str, key->length); + uint i; + for (i=0; ilength-1; i++) + fprintf(DBUG_FILE,"%0d ", key->key[i]); + fprintf(DBUG_FILE, "\n"); + DBUG_UNLOCK_FILE; + } + return; +} + /* Start ordered index scan in NDB @@ -1160,6 +1196,9 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, DBUG_ENTER("ordered_index_scan"); DBUG_PRINT("enter", ("index: %u, sorted: %d", active_index, sorted)); DBUG_PRINT("enter", ("Starting new ordered scan on %s", m_tabname)); + + DBUG_EXECUTE("enter", print_key(start_key, "start_key");); + DBUG_EXECUTE("enter", print_key(end_key, "end_key");); index_name= get_index_name(active_index); if (!(op= trans->getNdbIndexScanOperation((NDBINDEX *) From bdf4d6940d53f90c42ff5f183e189818d883ed2d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 13:01:29 +0300 Subject: [PATCH 08/41] srv0start.c: Fix bug #5414 in 4.1: srv_max_n_threads was always set to only 1000, regardless of the buffer pool size; undelr very high concurrent loads this could cause an assertion failure in sync0arr.c line 384 when we ran out of wait slots for threads; also innodb_thread_concurrency did not work, because the wait queue also there overflowed at 1000 concurrent threads; also remove redundant code trx0undo.c: Add a missing newline to fprints innobase/trx/trx0undo.c: Add a missing newline to fprints innobase/srv/srv0start.c: Fix bug in 4.1: srv_max_n_threads was always set to only 1000, regardless of the buffer pool size; undelr very high concurrent loads this could cause an assertion failure in sync0arr.c line 384 when we ran out of wait slots for threads; also innodb_thread_concurrency did not work, because the wait queue also there overflowed at 1000 concurrent threads; also remove redundant code --- innobase/srv/srv0start.c | 40 +++++++++++++--------------------------- innobase/trx/trx0undo.c | 2 +- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 4a0335086f0..8e48034e09c 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1055,34 +1055,15 @@ innobase_start_or_create_for_mysql(void) srv_file_flush_method_str); return(DB_ERROR); } - - /* Set the maximum number of threads which can wait for a semaphore - inside InnoDB */ -#if defined(__WIN__) || defined(__NETWARE__) -/* Create less event semaphores because Win 98/ME had difficulty creating -40000 event semaphores. -Comment from Novell, Inc.: also, these just take a lot of memory on -NetWare. */ - srv_max_n_threads = 1000; -#else - if (srv_pool_size >= 8 * 1024) { - /* Here we still have srv_pool_size counted - in kilobytes, srv_boot converts the value to - pages; if buffer pool is less than 8 MB, - assume fewer threads. */ - srv_max_n_threads = 10000; - } else { - srv_max_n_threads = 1000; /* saves several MB of memory, - especially in 64-bit - computers */ - } -#endif /* Note that the call srv_boot() also changes the values of srv_pool_size etc. to the units used by InnoDB internally */ /* Set the maximum number of threads which can wait for a semaphore - inside InnoDB */ + inside InnoDB: this is the 'sync wait array' size, as well as the + maximum number of threads that can wait in the 'srv_conc array' for + their time to enter InnoDB. */ + #if defined(__WIN__) || defined(__NETWARE__) /* Create less event semaphores because Win 98/ME had difficulty creating @@ -1091,11 +1072,16 @@ Comment from Novell, Inc.: also, these just take a lot of memory on NetWare. */ srv_max_n_threads = 1000; #else - if (srv_pool_size >= 8 * 1024 * 1024) { + if (srv_pool_size >= 1000 * 1024) { /* Here we still have srv_pool_size counted - in bytes, srv_boot converts the value to - pages; if buffer pool is less than 8 MB, + in kilobytes (in 4.0 this was in bytes) + srv_boot() converts the value to + pages; if buffer pool is less than 1000 MB, assume fewer threads. */ + srv_max_n_threads = 50000; + + } else if (srv_pool_size >= 8 * 1024) { + srv_max_n_threads = 10000; } else { srv_max_n_threads = 1000; /* saves several MB of memory, @@ -1103,7 +1089,7 @@ NetWare. */ computers */ } #endif - err = srv_boot(); + err = srv_boot(); /* This changes srv_pool_size to units of a page */ if (err != DB_SUCCESS) { diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index 79566fe01c3..c1edc223cbc 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -404,7 +404,7 @@ trx_undo_seg_create( ut_print_timestamp(stderr); fprintf(stderr, "InnoDB: Warning: cannot find a free slot for an undo log. Do you have too\n" -"InnoDB: many active transactions running concurrently?"); +"InnoDB: many active transactions running concurrently?\n"); return(NULL); } From 9d8d16ccf7584b4c40b0bfab9eee6662f6e39c56 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 15:03:43 +0500 Subject: [PATCH 09/41] Bug #5397: Crash with varchar binary and LIKE --- mysql-test/r/ctype_utf8.result | 5 +++++ mysql-test/t/ctype_utf8.test | 7 +++++++ strings/ctype-mb.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index f3be539251a..c7d015da9dc 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -639,3 +639,8 @@ select * from t1 where str='str'; str str drop table t1; +CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8; +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +a +DROP TABLE t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 2c531d4e5d2..f5bd9ede673 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -492,3 +492,10 @@ INSERT INTO t1 VALUES ('str2'); select * from t1 where str='str'; drop table t1; +# +# Bug #5397: Crash with varchar binary and LIKE +# +CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8; +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +DROP TABLE t1; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 2548a68ab19..25ee85d62b4 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -565,7 +565,7 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, if (str++ == str_end) return (-1); } { - int tmp=my_wildcmp_mb(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_mb_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); if (tmp <= 0) return (tmp); } From 71ba3e55b788e8c701b7292051f04e6fce55f26f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 16:48:11 +0500 Subject: [PATCH 10/41] A fix (bug #2205 USE database doesn't work after DROP database + CREATE database) (Jani's CS 1.1675 04/01/05 21:45:14 was adapted an aplied). client/mysql.cc: A fix (bug #2205 USE database doesn't work after DROP database + CREATE database). --- client/mysql.cc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 154695aa9e5..1858699e8da 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2200,8 +2200,9 @@ static int com_source(String *buffer, char *line) static int com_use(String *buffer __attribute__((unused)), char *line) { - char *tmp; - char buff[256]; + char *tmp, buff[FN_REFLEN + 1]; + MYSQL_RES *res; + MYSQL_ROW row; while (isspace(*line)) line++; @@ -2214,6 +2215,30 @@ com_use(String *buffer __attribute__((unused)), char *line) put_info("USE must be followed by a database name",INFO_ERROR); return 0; } + /* + We need to recheck the current database, because it may change + under our feet, for example if DROP DATABASE or RENAME DATABASE + (latter one not yet available by the time the comment was written) + */ + current_db= 0; // Let's reset current_db, assume it's gone + /* + We don't care about in case of an error below because current_db + was just set to 0. + */ + if (!mysql_query(&mysql, "SELECT DATABASE()") && + (res= mysql_use_result(&mysql))) + { + row= mysql_fetch_row(res); + if (row[0] && + (!current_db || cmp_database(current_db, row[0]))) + { + my_free(current_db, MYF(MY_ALLOW_ZERO_PTR)); + current_db= my_strdup(row[0], MYF(MY_WME)); + } + (void) mysql_fetch_row(res); // Read eof + mysql_free_result(res); + } + if (!current_db || cmp_database(current_db,tmp)) { if (one_database) From 4011f819e21f3bc586cb5d9a8b3ad8e2781fa298 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 09:23:51 -0500 Subject: [PATCH 11/41] client.c: sqlstat uninitialized in mysql_init(). sql-common/client.c: sqlstat uninitialized in mysql_init(). --- sql-common/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sql-common/client.c b/sql-common/client.c index 04d4bc06102..d4352af9802 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1401,6 +1401,7 @@ mysql_init(MYSQL *mysql) bzero((char*) (mysql),sizeof(*(mysql))); mysql->options.connect_timeout= CONNECT_TIMEOUT; mysql->last_used_con= mysql->next_slave= mysql->master = mysql; + strmov(mysql->net.sqlstate, not_error_sqlstate); /* By default, we are a replication pivot. The caller must reset it after we return if this is not the case. From 7e7dfcccd64472c9d46b319e997181d0354b668c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 20:04:22 +0500 Subject: [PATCH 12/41] Bug #5324 Bug in UCA collations with LIKE comparisons and INDEX --- include/m_ctype.h | 7 +++ mysql-test/r/ctype_uca.result | 39 ++++++++++++++++ mysql-test/t/ctype_uca.test | 37 +++++++++++++++ strings/ctype-mb.c | 86 +++++++++++++++++++++++++++++++++++ strings/ctype-uca.c | 7 +-- 5 files changed, 173 insertions(+), 3 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index 65b11f4c06a..16490af7fc3 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -312,6 +312,13 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, char *min_str, char *max_str, uint *min_length, uint *max_length); +my_bool my_like_range_mb(CHARSET_INFO *cs, + const char *ptr, uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_length, uint *max_length); + my_bool my_like_range_ucs2(CHARSET_INFO *cs, const char *ptr, uint ptr_length, pbool escape, pbool w_one, pbool w_many, diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 94fe15fed26..da4b5bfb663 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -1872,3 +1872,42 @@ Z,z,Ź,ź,Ż,ż,Ž,ž ǁ ǂ ǃ +drop table t1; +SET NAMES utf8; +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_general_ci, INDEX (c)); +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE ucs2_unicode_ci, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 COLLATE ucs2_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 +COLLATE ucs2_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_unicode_ci, INDEX (c)); +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) COLLATE utf8_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 187d21f9ab7..d9181b19992 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -180,3 +180,40 @@ select group_concat(c1 order by c1) from t1 group by c1 collate utf8_slovak_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish2_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; +drop table t1; + +# +# Bug#5324 +# +SET NAMES utf8; +#test1 +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_general_ci, INDEX (c)); +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +#Check one row +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci; +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +#Check two rows +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci ORDER BY c; +DROP TABLE t1; +#test2 +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE ucs2_unicode_ci, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +#Check one row +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 COLLATE ucs2_unicode_ci; +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 +COLLATE ucs2_unicode_ci ORDER BY c; +DROP TABLE t1; +#test 3 +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_unicode_ci, INDEX (c)); +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +#Check one row row +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) COLLATE utf8_unicode_ci; +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +#Check two rows +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_unicode_ci ORDER BY c; +DROP TABLE t1; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 25ee85d62b4..3bfc66029ce 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -458,6 +458,92 @@ static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), } } +/* +** Calculate min_str and max_str that ranges a LIKE string. +** Arguments: +** ptr Pointer to LIKE string. +** ptr_length Length of LIKE string. +** escape Escape character in LIKE. (Normally '\'). +** All escape characters should be removed from min_str and max_str +** res_length Length of min_str and max_str. +** min_str Smallest case sensitive string that ranges LIKE. +** Should be space padded to res_length. +** max_str Largest case sensitive string that ranges LIKE. +** Normally padded with the biggest character sort value. +** +** The function should return 0 if ok and 1 if the LIKE string can't be +** optimized ! +*/ + +my_bool my_like_range_mb(CHARSET_INFO *cs, + const char *ptr,uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str,char *max_str, + uint *min_length,uint *max_length) +{ + const char *end=ptr+ptr_length; + char *min_org=min_str; + char *min_end=min_str+res_length; + char *max_end=max_str+res_length; + + for (; ptr != end && min_str != min_end ; ptr++) + { + if (*ptr == escape && ptr+1 != end) + { + ptr++; /* Skip escape */ + *min_str++= *max_str++ = *ptr; + continue; + } + if (*ptr == w_one || *ptr == w_many) /* '_' and '%' in SQL */ + { + char buf[10]; + uint buflen; + + /* Write min key */ + *min_length= (uint) (min_str - min_org); + *max_length=res_length; + do + { + *min_str++= (char) cs->min_sort_char; + } while (min_str != min_end); + + /* + Write max key: create a buffer with multibyte + representation of the max_sort_char character, + and copy it into max_str in a loop. + */ + buflen= cs->cset->wc_mb(cs, cs->max_sort_char, buf, buf + sizeof(buf)); + DBUG_ASSERT(buflen > 0); + do + { + if ((max_str + buflen) <= max_end) + { + /* Enough space for max characer */ + memcpy(max_str, buf, buflen); + max_str+= buflen; + } + else + { + /* + There is no space for whole multibyte + character, then add trailing spaces. + */ + + *max_str++= ' '; + } + } while (max_str != max_end); + return 0; + } + *min_str++= *max_str++ = *ptr; + } + *min_length= *max_length = (uint) (min_str - min_org); + + while (min_str != min_end) + *min_str++ = *max_str++ = ' '; /* Because if key compression */ + return 0; +} + static int my_wildcmp_mb_bin(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index cecc3be5045..edb84dbf225 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6876,7 +6876,8 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) int mblen; if (((mblen= scanner->cs->cset->mb_wc(scanner->cs, &wc, - scanner->sbeg, scanner->send)) < 0)) + scanner->sbeg, + scanner->send)) <= 0)) return -1; scanner->page= wc >> 8; @@ -7918,7 +7919,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = my_strnncoll_ucs2_uca, my_strnncollsp_ucs2_uca, my_strnxfrm_ucs2_uca, - my_like_range_simple, + my_like_range_ucs2, my_wildcmp_uca, NULL, my_instr_mb, @@ -8369,7 +8370,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, - my_like_range_simple, + my_like_range_mb, my_wildcmp_uca, NULL, my_instr_mb, From 982a78829af9bc579fc884e641f5ec10cb1f478e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 22:20:40 +0200 Subject: [PATCH 13/41] bug#5389 merge.test fails on qnx - uninitalized variable in myrg_open() myisammrg/myrg_open.c: backport from 4.1 mysql-test/r/union.result: after merge fix mysql-test/t/union.test: after merge fix sql/log.cc: backward compatibility: inhibit severity labels in error log --- myisammrg/myrg_open.c | 28 ++++++++++++++-------------- mysql-test/r/union.result | 1 - mysql-test/t/union.test | 1 - sql/log.cc | 20 +++++++++++++------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 4c6ffb98ad5..a59ccb7d966 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -34,14 +34,17 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { int save_errno,errpos=0; uint files=0,i,dir_length,length,key_parts; - ulonglong file_offset; + ulonglong file_offset=0; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MYRG_INFO *m_info=0; File fd; IO_CACHE file; MI_INFO *isam=0; + uint found_merge_insert_method= 0; DBUG_ENTER("myrg_open"); + LINT_INIT(key_parts); + bzero((char*) &file,sizeof(file)); if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), O_RDONLY | O_SHARE,MYF(0))) < 0) @@ -69,10 +72,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) continue; /* Skip empty lines */ if (buff[0] == '#') { - if( !strncmp(buff+1,"INSERT_METHOD=",14)) + if (!strncmp(buff+1,"INSERT_METHOD=",14)) { /* Lookup insert method */ int tmp=find_type(buff+15,&merge_insert_method,2); - m_info->merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); + found_merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } continue; /* Skip comments */ } @@ -84,8 +87,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) VOID(cleanup_dirname(buff,name_buff)); } if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) - goto err; - if (!m_info) + goto err; + if (!m_info) /* First file */ { key_parts=isam->s->base.key_parts; if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) + @@ -97,15 +100,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { m_info->open_tables=(MYRG_TABLE *) (m_info+1); m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files); + m_info->tables= files; + files= 0; } - else - { - m_info->open_tables=0; - m_info->rec_per_key_part=0; - } - m_info->tables=files; m_info->reclength=isam->s->base.reclength; - file_offset=files=0; errpos=3; } m_info->open_tables[files].table= isam; @@ -122,14 +120,16 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) m_info->del+= isam->state->del; m_info->data_file_length+= isam->state->data_file_length; for (i=0; i < key_parts; i++) - m_info->rec_per_key_part[i]+=isam->s->state.rec_per_key_part[i] / m_info->tables; + m_info->rec_per_key_part[i]+= (isam->s->state.rec_per_key_part[i] / + m_info->tables); } if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), - MYF(MY_WME|MY_ZEROFILL)))) + MYF(MY_WME | MY_ZEROFILL)))) goto err; /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); + m_info->merge_insert_method= found_merge_insert_method; if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) { diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 79c589774d8..0db18b090bc 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -424,7 +424,6 @@ create table t1 select a from t1 union select a from t2; INSERT TABLE 't1' isn't allowed in FROM table list select a from t1 union select a from t2 order by t2.a; Unknown column 't2.a' in 'ORDER BY' -drop table t1; drop table t1,t2; select length(version()) > 1 as `*` UNION select 2; * diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index e55cb3ea272..eb2d8dd6efa 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -229,7 +229,6 @@ drop table t1; create table t1 select a from t1 union select a from t2; --error 1054 select a from t1 union select a from t2 order by t2.a; -drop table t1; # Drop temporary table drop table t1,t2; # diff --git a/sql/log.cc b/sql/log.cc index 55ef2e72960..151d613f637 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1221,7 +1221,7 @@ bool MYSQL_LOG::write(Log_event* event_info) if (e.write(file)) goto err; } -#if MYSQL_VERSION_ID < 40100 +#if MYSQL_VERSION_ID < 40100 if (thd->variables.convert_set) { Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0); @@ -1761,15 +1761,21 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) skr=time(NULL); localtime_r(&skr, &tm_tmp); start=&tm_tmp; +#if MYSQL_VERSION_ID > 40100 fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", - start->tm_year % 100, - start->tm_mon+1, - start->tm_mday, - start->tm_hour, - start->tm_min, - start->tm_sec, +#else + fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d %s\n", +#endif + start->tm_year % 100, + start->tm_mon+1, + start->tm_mday, + start->tm_hour, + start->tm_min, + start->tm_sec, +#if MYSQL_VERSION_ID > 40100 (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "WARNING" : "INFORMATION"), +#endif buffer); fflush(stderr); From e663f91ad7a7315c339713f390bf1fc5fec381ad Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 22:30:16 +0200 Subject: [PATCH 14/41] Dependency fix. We observed that doing any change to class THD in sql_class.h resulted in mysqld going crazy (parsing errors, query cache errors in query_cache.test). This is because sql_yacc.cc depends on several .h files but those were not listed in the dependencies of sql_yacc.o. The present patch does fix the issue; but my auto*-expert colleagues may have a better one. sql/Makefile.am: sql_yacc.c includes mysql_priv.h, slave.h etc, so sql_yacc.o does depend on these .h files; so they need to be listed in the dependencies. --- sql/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/Makefile.am b/sql/Makefile.am index 0a664a120a5..0fc81a48c63 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -108,7 +108,7 @@ gen_lex_hash.o: gen_lex_hash.cc lex.h sql_yacc.cc: sql_yacc.yy sql_yacc.h: sql_yacc.yy -sql_yacc.o: sql_yacc.cc sql_yacc.h +sql_yacc.o: sql_yacc.cc sql_yacc.h $(noinst_HEADERS) @echo "Note: The following compile may take a long time." @echo "If it fails, re-run configure with --with-low-memory" $(CXXCOMPILE) $(LM_CFLAGS) -c $< From ea971987fcc8479fdd3fbf185efedd8ed7ccbfd6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 22:47:26 +0200 Subject: [PATCH 15/41] Replacing class Disable_binlog by macros. Patch already approved by Monty. sql/log.cc: removing unneeded class Disable_binlog sql/sql_class.h: removing unneeded class Disable_binlog sql/sql_table.cc: As discussed, class Disable_binlog is removed and replaced by macros. --- sql/log.cc | 16 ---------------- sql/sql_class.h | 21 --------------------- sql/sql_table.cc | 47 ++++++++++++++++++++++++++++------------------- 3 files changed, 28 insertions(+), 56 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 55ef2e72960..a864943edf8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1682,22 +1682,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg) } -Disable_binlog::Disable_binlog(THD *thd_arg) : - thd(thd_arg), - save_options(thd_arg->options), save_master_access(thd_arg->master_access) -{ - thd_arg->options&= ~OPTION_BIN_LOG; - thd_arg->master_access|= SUPER_ACL; // unneeded in 4.1 -}; - - -Disable_binlog::~Disable_binlog() -{ - thd->options= save_options; - thd->master_access= save_master_access; -} - - /* Check if a string is a valid number diff --git a/sql/sql_class.h b/sql/sql_class.h index 30947041b7d..d362a90b7df 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -638,27 +638,6 @@ public: #define SYSTEM_THREAD_SLAVE_IO 2 #define SYSTEM_THREAD_SLAVE_SQL 4 -/* - Disables binary logging for one thread, and resets it back to what it was - before being disabled. - Some functions (like the internal mysql_create_table() when it's called by - mysql_alter_table()) must NOT write to the binlog (binlogging is done at the - at a later stage of the command already, and must be, for locking reasons); - so we internally disable it temporarily by creating the Disable_binlog - object and reset the state by destroying the object (don't forget that! or - write code so that the object gets automatically destroyed when leaving a - block, see example in sql_table.cc). -*/ -class Disable_binlog { -private: - THD *thd; - ulong save_options; - ulong save_master_access; -public: - Disable_binlog(THD *thd_arg); - ~Disable_binlog(); -}; - /* Used to hold information about file and file structure in exchainge via non-DB file (...INTO OUTFILE..., ...LOAD DATA...) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 96eebd98ac3..c712167bfc1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -30,6 +30,16 @@ #include #endif +#include "sql_acl.h" // for SUPER_ACL +# define tmp_disable_binlog(A) \ + ulong save_options= (A)->options, save_master_access= (A)->master_access; \ + (A)->options&= ~OPTION_BIN_LOG; \ + (A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */ + +#define reenable_binlog(A) \ + (A)->options= save_options; \ + (A)->master_access= save_master_access; + extern HASH open_cache; static const char *primary_key_name="PRIMARY"; @@ -840,9 +850,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, MYSQL_LOCK **lock) { TABLE tmp_table; // Used during 'create_field()' - TABLE *table; + TABLE *table= 0; tmp_table.table_name=0; - Disable_binlog disable_binlog(thd); DBUG_ENTER("create_table_from_items"); /* Add selected items to field list */ @@ -872,23 +881,25 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, extra_fields->push_back(cr_field); } /* create and lock table */ - /* QQ: This should be done atomic ! */ - /* We don't log the statement, it will be logged later */ - if (mysql_create_table(thd,db,name,create_info,*extra_fields, - *keys,0)) - DBUG_RETURN(0); + /* QQ: create and open should be done atomic ! */ /* + We don't log the statement, it will be logged later. If this is a HEAP table, the automatic DELETE FROM which is written to the binlog when a HEAP table is opened for the first time since startup, must not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we don't want to delete from it) 2) it would be written before the CREATE - TABLE, which is a wrong order. So we keep binary logging disabled. + TABLE, which is a wrong order. So we keep binary logging disabled when we + open_table(). */ - if (!(table=open_table(thd,db,name,name,(bool*) 0))) + tmp_disable_binlog(thd); + if (!mysql_create_table(thd,db,name,create_info,*extra_fields,*keys,0)) { - quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); - DBUG_RETURN(0); + if (!(table=open_table(thd,db,name,name,(bool*) 0))) + quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); } + reenable_binlog(thd); + if (!table) + DBUG_RETURN(0); table->reginfo.lock_type=TL_WRITE; if (!((*lock)=mysql_lock_tables(thd,&table,1))) { @@ -1925,14 +1936,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, else create_info->data_file_name=create_info->index_file_name=0; { - /* - We don't log the statement, it will be logged later. Using a block so - that disable_binlog is deleted when we leave it in either way. - */ - Disable_binlog disable_binlog(thd); - if ((error=mysql_create_table(thd, new_db, tmp_name, - create_info, - create_list,key_list,1))) + /* We don't log the statement, it will be logged later. */ + tmp_disable_binlog(thd); + int error= mysql_create_table(thd, new_db, tmp_name, + create_info,create_list,key_list,1); + reenable_binlog(thd); + if (error) DBUG_RETURN(error); } if (table->tmp_table) From 21642fb5d733df8c2b699eea55b0151439e0eca6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 22:48:42 +0200 Subject: [PATCH 16/41] Bug #5413 mysqlcheck segfaults when user has to few permissions --- client/mysqlcheck.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1c5638f3c52..8764611adf4 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -413,18 +413,18 @@ static int process_all_tables_in_db(char *database) LINT_INIT(res); if (use_db(database)) return 1; - if (!(mysql_query(sock, "SHOW TABLES") || - (res = mysql_store_result(sock)))) + if (mysql_query(sock, "SHOW TABLES") || + !((res= mysql_store_result(sock)))) return 1; if (opt_all_in_1) { - /* + /* We need table list in form `a`, `b`, `c` that's why we need 4 more chars added to to each table name space is for more readable output in logs and in case of error */ - + char *tables, *end; uint tot_length = 0; From 6f46f997b19537e7805dcc618dea16f1bd05ce23 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 23:20:33 +0200 Subject: [PATCH 17/41] Fix of previous push. sql/sql_table.cc: stupid me. error already exists in the function. Using a local 'int error' resulted in global 'error' not being inited, which probably made next steps (those testing global error) go wrong! --- sql/sql_table.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c712167bfc1..e2e186abb0d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1938,8 +1938,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { /* We don't log the statement, it will be logged later. */ tmp_disable_binlog(thd); - int error= mysql_create_table(thd, new_db, tmp_name, - create_info,create_list,key_list,1); + error= mysql_create_table(thd, new_db, tmp_name, + create_info,create_list,key_list,1); reenable_binlog(thd); if (error) DBUG_RETURN(error); From 2b464cae9b25da31b5152e115ac0a477f98566c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 11:40:27 +0300 Subject: [PATCH 18/41] Fixed Bug#3645, "PROCEDURE ANALYSE() recommends illegal FLOAT columns". --- sql/sql_analyse.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 3847849d6a7..0723c274a17 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -810,6 +810,13 @@ void field_real::get_opt_type(String *answer, if (min_arg >= 0) answer->append(" UNSIGNED"); } + else if (item->decimals == NOT_FIXED_DEC) + { + if (min_arg >= -FLT_MAX && max_arg <= FLT_MAX) + answer->append("FLOAT", 5); + else + answer->append("DOUBLE", 6); + } else { if (min_arg >= -FLT_MAX && max_arg <= FLT_MAX) From 00080aa7c3d4e1216fad3de30723c2a018200855 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 11:15:23 +0200 Subject: [PATCH 19/41] A new test for the fix for BUG#4500 ("SET CHARACTER SET replicates incorrectly"). As I cannot be 100% sure that there won't be issues with some of our exotic platforms (who knows if the charset of will play fair?), I'll send an email to the build guys. Well, this holds if bk does not crash on binary chars of this cset. --- mysql-test/r/rpl_set_charset.result | 51 +++++++++++++++++++++++++++++ mysql-test/t/rpl_set_charset.test | 40 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 mysql-test/r/rpl_set_charset.result create mode 100644 mysql-test/t/rpl_set_charset.test diff --git a/mysql-test/r/rpl_set_charset.result b/mysql-test/r/rpl_set_charset.result new file mode 100644 index 00000000000..b2bfa3678a9 --- /dev/null +++ b/mysql-test/r/rpl_set_charset.result @@ -0,0 +1,51 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +drop database if exists mysqltest1; +create database mysqltest1 /*!40100 character set latin2 */; +use mysqltest1; +drop table if exists t1; +create table t1 (a varchar(255) character set latin2, b varchar(4)); +SET CHARACTER SET cp1250_latin2; +INSERT INTO t1 VALUES ('','80'); +INSERT INTO t1 VALUES ('','90'); +INSERT INTO t1 VALUES ('','A0'); +INSERT INTO t1 VALUES ('','B0'); +INSERT INTO t1 VALUES ('','C0'); +INSERT INTO t1 VALUES ('','D0'); +INSERT INTO t1 VALUES ('','E0'); +INSERT INTO t1 VALUES ('','F0'); +select "--- on master ---"; +--- on master --- +--- on master --- +select hex(a),b from t1 order by b; +hex(a) b +A9A6ABAEAC 80 +B9B6BBBEBC 90 +A3A1AAAF A0 +B3B1BAA5B5BF B0 +C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0 +D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0 +E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0 +F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0 +show binlog events from 1979; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 1979 Query 1 1979 use `mysqltest1`; SET CHARACTER SET DEFAULT +use mysqltest1; +select "--- on slave ---"; +--- on slave --- +--- on slave --- +select hex(a),b from t1 order by b; +hex(a) b +A9A6ABAEAC 80 +B9B6BBBEBC 90 +A3A1AAAF A0 +B3B1BAA5B5BF B0 +C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0 +D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0 +E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0 +F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0 +drop table t1; diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test new file mode 100644 index 00000000000..6aa864b1008 --- /dev/null +++ b/mysql-test/t/rpl_set_charset.test @@ -0,0 +1,40 @@ +source include/master-slave.inc; +--disable_warnings +drop database if exists mysqltest1; +# 4.1 bases its conversion on the db's charset, +# while 4.0 uses the part of "SET CHARACTER SET" after "_". +# So for 4.1 we add a clause to CREATE DATABASE. +create database mysqltest1 /*!40100 character set latin2 */; +use mysqltest1; +drop table if exists t1; +--enable_warnings +create table t1 (a varchar(255) character set latin2, b varchar(4)); +SET CHARACTER SET cp1250_latin2; +INSERT INTO t1 VALUES ('','80'); +INSERT INTO t1 VALUES ('','90'); +INSERT INTO t1 VALUES ('','A0'); +INSERT INTO t1 VALUES ('','B0'); +INSERT INTO t1 VALUES ('','C0'); +INSERT INTO t1 VALUES ('','D0'); +INSERT INTO t1 VALUES ('','E0'); +INSERT INTO t1 VALUES ('','F0'); +select "--- on master ---"; +select hex(a),b from t1 order by b; +# It's complicated to verify that the charset is reset to default in +# the binlog after each query, except by checking the binlog. When you +# merge this into 4.1/5.0, the 1979 will have to be changed; all you have +# to do is read the var/log/master-bin.0*01 with mysqlbinlog, verify +# that a SET CHARACTER SET DEFAULT is just after the last INSERT, and +# replace 1979 by its position (the "# at" line above the SET). +show binlog events from 1979; +save_master_pos; +connection slave; +sync_with_master; +use mysqltest1; +select "--- on slave ---"; +select hex(a),b from t1 order by b; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; From ee511e55e7598767924d73e9fe08a480e1c2c72d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 14:24:47 +0500 Subject: [PATCH 20/41] A fix (Bug #5432: Is this a leak in mysql console client?) --- client/mysql.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 1858699e8da..3cc8b41af66 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2220,7 +2220,9 @@ com_use(String *buffer __attribute__((unused)), char *line) under our feet, for example if DROP DATABASE or RENAME DATABASE (latter one not yet available by the time the comment was written) */ - current_db= 0; // Let's reset current_db, assume it's gone + /* Let's reset current_db, assume it's gone */ + my_free(current_db, MYF(MY_ALLOW_ZERO_PTR)); + current_db= 0; /* We don't care about in case of an error below because current_db was just set to 0. @@ -2229,10 +2231,8 @@ com_use(String *buffer __attribute__((unused)), char *line) (res= mysql_use_result(&mysql))) { row= mysql_fetch_row(res); - if (row[0] && - (!current_db || cmp_database(current_db, row[0]))) + if (row[0]) { - my_free(current_db, MYF(MY_ALLOW_ZERO_PTR)); current_db= my_strdup(row[0], MYF(MY_WME)); } (void) mysql_fetch_row(res); // Read eof From a1d960418c1b1309a27e222f2249b730e39711a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 14:30:53 +0500 Subject: [PATCH 21/41] Fix for the bug #5371 (Prepared query converting float to string blows the stack) We just don't expect BIG buffer to be sent for just a double libmysql/libmysql.c: We shouldn't fall if the buffer_length is bigger than 330 --- libmysql/libmysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 7d71998f37d..b4871f6bb9d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3490,7 +3490,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, if (field->decimals >= 31) #undef NOT_FIXED_DEC { - sprintf(buff, "%-*.*g", (int) param->buffer_length, width, value); + sprintf(buff, "%-*.*g", (int) min(330, param->buffer_length), width, value); end= strcend(buff, ' '); *end= 0; } From af46c9c3b63b6a6cc4753588dc1e793b48802a14 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 12:23:06 +0200 Subject: [PATCH 22/41] Only include debug print routines in debug mode --- sql/ha_ndbcluster.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 74a1d2abb5b..3cbede189b1 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1143,6 +1143,8 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, DBUG_RETURN(0); } +#ifndef DBUG_OFF + const char* key_flag_strs[] = { "HA_READ_KEY_EXACT", "HA_READ_KEY_OR_NEXT", @@ -1178,7 +1180,7 @@ void print_key(const key_range* key, const char* info) } return; } - +#endif /* Start ordered index scan in NDB From 95f42e1da29deb3fb2843c5066ea8692e7bdca08 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 15:42:19 +0500 Subject: [PATCH 23/41] Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions --- mysql-test/r/cast.result | 23 +++++++++++++++++++++++ mysql-test/t/cast.test | 13 +++++++++++++ sql/item_func.h | 2 ++ sql/item_timefunc.cc | 18 ++++++++++++++++++ sql/item_timefunc.h | 5 +++++ 5 files changed, 61 insertions(+) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 6564a3e392b..ccf75f68e88 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -155,3 +155,26 @@ NULL select cast(NULL as BINARY); cast(NULL as BINARY) NULL +CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); +INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); +SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ; +a CAST(a AS CHAR) +aac aac +aab aab +aaa aaa +SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; +a CAST(a AS CHAR(3)) +aac aac +aab aab +aaa aaa +SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; +a CAST(a AS UNSIGNED) +aaa 3 +aab 2 +aac 1 +SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a; +a CAST(a AS CHAR(2)) +aaa aa +aab aa +aac aa +DROP TABLE t1; diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index e2deb792d47..e5681dedbac 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -95,3 +95,16 @@ select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"; select cast("1:2:3" as TIME) = "1:02:03"; select cast(NULL as DATE); select cast(NULL as BINARY); + +# +# Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions +# +CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); +INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); +# these two should be in enum order +SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ; +SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; +# these two should be in alphabetic order +SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; +SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a; +DROP TABLE t1; diff --git a/sql/item_func.h b/sql/item_func.h index d45f7244e55..836ed27ee46 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -214,6 +214,7 @@ class Item_func_signed :public Item_int_func { public: Item_func_signed(Item *a) :Item_int_func(a) {} + const char *func_name() const { return "cast_as_signed"; } double val() { double tmp= args[0]->val(); @@ -236,6 +237,7 @@ class Item_func_unsigned :public Item_func_signed { public: Item_func_unsigned(Item *a) :Item_func_signed(a) {} + const char *func_name() const { return "cast_as_unsigned"; } void fix_length_and_dec() { max_length=args[0]->max_length; unsigned_flag=1; } void print(String *str); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 5d9a6dd9490..8f09fe82c1b 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2059,6 +2059,24 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const } +bool Item_char_typecast::eq(const Item *item, bool binary_cmp) const +{ + if (this == item) + return 1; + if (item->type() != FUNC_ITEM || + func_name() != ((Item_func*)item)->func_name()) + return 0; + + Item_char_typecast *cast= (Item_char_typecast*)item; + if (cast_length != cast->cast_length || + cast_cs != cast->cast_cs) + return 0; + + if (!args[0]->eq(cast->args[0], binary_cmp)) + return 0; + return 1; +} + void Item_typecast::print(String *str) { str->append("cast(", 5); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 2254fc830c9..df0b05d6d42 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -683,6 +683,8 @@ class Item_char_typecast :public Item_typecast public: Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg) :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {} + bool eq(const Item *item, bool binary_cmp) const; + const char *func_name() const { return "cast_as_char"; } const char* cast_type() const { return "char"; }; String *val_str(String *a); void fix_length_and_dec(); @@ -694,6 +696,7 @@ class Item_date_typecast :public Item_typecast_maybe_null { public: Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {} + const char *func_name() const { return "cast_as_date"; } String *val_str(String *str); bool get_date(TIME *ltime, uint fuzzy_date); const char *cast_type() const { return "date"; } @@ -709,6 +712,7 @@ class Item_time_typecast :public Item_typecast_maybe_null { public: Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {} + const char *func_name() const { return "cast_as_time"; } String *val_str(String *str); bool get_time(TIME *ltime); const char *cast_type() const { return "time"; } @@ -724,6 +728,7 @@ class Item_datetime_typecast :public Item_typecast_maybe_null { public: Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {} + const char *func_name() const { return "cast_as_datetime"; } String *val_str(String *str); const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } From 235c5035b5d894c40a9f0d8cd23d17541eb8cd6a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 12:45:19 +0200 Subject: [PATCH 24/41] Fix for INSERT with multiple values and start/end_bulk_insert mysql-test/r/ndb_insert.result: Add tests for duplicate keys in combination with start/end_bulk_insert mysql-test/t/ndb_insert.test: Add tests for duplicate keys in combination with start/end_bulk_insert sql/ha_ndbcluster.cc: Set my_errno if error occurs in end_bulk_insert --- mysql-test/r/ndb_insert.result | 12 ++++++++++++ mysql-test/t/ndb_insert.test | 29 +++++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index 93f46c85499..87f27518ea3 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -416,4 +416,16 @@ INSERT INTO t1 VALUES SELECT COUNT(*) FROM t1; COUNT(*) 2000 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Duplicate entry '10' for key 1 +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Duplicate entry '10' for key 1 +commit; +insert into t1 select * from t1 where b < 10 order by pk1; +ERROR 23000: Duplicate entry '9' for key 1 DROP TABLE t1; diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index c55a925dca2..a448e413f1d 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -429,5 +429,34 @@ INSERT INTO t1 VALUES SELECT COUNT(*) FROM t1; +# +# Insert duplicate rows +# +--error 1062 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + + + +begin; + +# +# Insert duplicate rows, inside transaction +# +--error 1062 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +commit; + +# +# Insert duplicate rows using "insert .. select" + +# +--error 1062 +insert into t1 select * from t1 where b < 10 order by pk1; + DROP TABLE t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 3cbede189b1..10ac9fbf84f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2401,7 +2401,7 @@ int ha_ndbcluster::end_bulk_insert() rows_inserted, bulk_insert_rows)); bulk_insert_not_flushed= false; if (trans->execute(NoCommit) != 0) - error= ndb_err(trans); + my_errno= error= ndb_err(trans); } rows_inserted= 0; From 411ef7d7b664873087d8a569009e6e683f73b470 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 16:33:39 +0500 Subject: [PATCH 25/41] Small fixes to patch for #5371 libmysql/libmysql.c: Code trimmed --- libmysql/libmysql.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index b4871f6bb9d..5b3db5a1a47 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3487,10 +3487,11 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, char *end; /* TODO: move this to a header shared between client and server. */ #define NOT_FIXED_DEC 31 - if (field->decimals >= 31) + if (field->decimals >= NOT_FIXED_DEC) #undef NOT_FIXED_DEC { - sprintf(buff, "%-*.*g", (int) min(330, param->buffer_length), width, value); + sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1, param->buffer_length), + width, value); end= strcend(buff, ' '); *end= 0; } From e205392de7a201c2d912116f01067b3047f91811 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 13:36:27 +0200 Subject: [PATCH 26/41] cleanup --- mysql-test/r/rpl_set_charset.result | 1 + mysql-test/t/rpl_set_charset.test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/r/rpl_set_charset.result b/mysql-test/r/rpl_set_charset.result index b2bfa3678a9..7297d80865b 100644 --- a/mysql-test/r/rpl_set_charset.result +++ b/mysql-test/r/rpl_set_charset.result @@ -49,3 +49,4 @@ D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0 E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0 F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0 drop table t1; +drop database mysqltest1; diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test index 6aa864b1008..dcfc11bf25e 100644 --- a/mysql-test/t/rpl_set_charset.test +++ b/mysql-test/t/rpl_set_charset.test @@ -38,3 +38,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; +connection master; +drop database mysqltest1; From 6b1444d7ba70a286f3fc543ab5bc8927106f5638 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 13:48:38 +0200 Subject: [PATCH 27/41] better fix for bug#5001 --- scripts/mysqld_safe.sh | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 8ad2ee1df4d..b9e7ce21f79 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -322,36 +322,26 @@ do # but should work for the rest of the servers. # The only thing is ps x => redhat 5 gives warnings when using ps -x. # kill -9 is used or the process won't react on the kill. - if test -n "$mysql_tcp_port" - then - numofproces=`ps xa | grep -v "grep" | grep $ledir/$MYSQLD| grep -c "port=$mysql_tcp_port"` - else - numofproces=`ps xa | grep -v "grep" | grep -c $ledir/$MYSQLD` - fi + numofproces=`ps xa | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"` echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log I=1 while test "$I" -le "$numofproces" do - if test -n "$mysql_tcp_port" - then - PROC=`ps xa | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "port=$mysql_tcp_port" | sed -n '$p'` - else - PROC=`ps xa | grep "$ledir/$MYSQLD\>" | grep -v "grep" | sed -n '$p'` - fi + PROC=`ps xa | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "pid-file=$pid_file" | sed -n '$p'` - for T in $PROC - do - break - done - # echo "TEST $I - $T **" - if kill -9 $T - then - echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log - else - break - fi - I=`expr $I + 1` + for T in $PROC + do + break + done + # echo "TEST $I - $T **" + if kill -9 $T + then + echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log + else + break + fi + I=`expr $I + 1` done fi echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log @@ -359,3 +349,4 @@ done echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log echo "" | tee -a $err_log + From 3a476a6e91bcd8f219393b7ec670c4833f534ea3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 14:20:48 +0200 Subject: [PATCH 28/41] clean up at end of test (thanks serg) mysql-test/r/rpl_set_charset.result: result update mysql-test/t/rpl_set_charset.test: clean up on slave too. --- mysql-test/r/rpl_set_charset.result | 1 - mysql-test/t/rpl_set_charset.test | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_set_charset.result b/mysql-test/r/rpl_set_charset.result index 7297d80865b..9c7ea73c741 100644 --- a/mysql-test/r/rpl_set_charset.result +++ b/mysql-test/r/rpl_set_charset.result @@ -48,5 +48,4 @@ C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0 D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0 E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0 F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0 -drop table t1; drop database mysqltest1; diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test index dcfc11bf25e..bd68ce17bbc 100644 --- a/mysql-test/t/rpl_set_charset.test +++ b/mysql-test/t/rpl_set_charset.test @@ -34,9 +34,7 @@ use mysqltest1; select "--- on slave ---"; select hex(a),b from t1 order by b; connection master; -drop table t1; +drop database mysqltest1; save_master_pos; connection slave; sync_with_master; -connection master; -drop database mysqltest1; From 32db5b4c5eb4dddf6401f3a926645a1972fa5369 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 14:57:54 +0200 Subject: [PATCH 29/41] when we update thd->db in replication, it's safer to update thd->db_length too. This does not fix any known bug, but is still a good idea. sql/log_event.cc: when we update thd->db in replication, it's safer to update thd->db_length too. sql/slave.cc: when we update thd->db in replication, it's safer to update thd->db_length too. sql/sql_db.cc: comment --- sql/log_event.cc | 14 ++++++++++---- sql/slave.cc | 13 +++++++++---- sql/sql_db.cc | 9 +++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 5526795c9d1..f707eabebd5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1806,7 +1806,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) { int expected_error, actual_error= 0; init_sql_alloc(&thd->mem_root, thd->variables.query_alloc_block_size,0); - thd->db= (char*) rewrite_db(db); + thd->db= (char*) rewrite_db(db); // thd->db_length is set later if needed /* InnoDB internally stores the master log position it has processed so far; @@ -1836,6 +1836,11 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) { thd->set_time((time_t)when); thd->current_tablenr = 0; + /* + We cannot use db_len from event to fill thd->db_length, because + rewrite_db() may have changed db. + */ + thd->db_length= thd->db ? strlen(thd->db) : 0; thd->query_length= q_len; thd->query= (char *) query; VOID(pthread_mutex_lock(&LOCK_thread_count)); @@ -1930,7 +1935,7 @@ end: VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->db= 0; // prevent db from being freed thd->query= 0; // just to be sure - thd->query_length= 0; + thd->query_length= thd->db_length =0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); close_thread_tables(thd); free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); @@ -1968,7 +1973,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, { char *load_data_query= 0; init_sql_alloc(&thd->mem_root, thd->variables.query_alloc_block_size, 0); - thd->db= (char*) rewrite_db(db); + thd->db= (char*) rewrite_db(db); // thd->db_length is set later if needed DBUG_ASSERT(thd->query == 0); clear_all_errors(thd, rli); @@ -2001,6 +2006,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, { thd->set_time((time_t)when); thd->current_tablenr = 0; + thd->db_length= thd->db ? strlen(thd->db) : 0; VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_id = query_id++; VOID(pthread_mutex_unlock(&LOCK_thread_count)); @@ -2117,7 +2123,7 @@ Slave: load data infile on table '%s' at log position %s in log \ VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->db= 0; thd->query= 0; - thd->query_length= 0; + thd->query_length= thd->db_length= 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); close_thread_tables(thd); if (load_data_query) diff --git a/sql/slave.cc b/sql/slave.cc index 4416a2544ef..18e0ec5929f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1124,6 +1124,7 @@ slaves can't replicate a 5.0 or newer master."; Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it from the dump. Honours replication inclusion/exclusion rules. + db must be non-zero (guarded by assertion). RETURN VALUES 0 success @@ -1134,8 +1135,8 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, const char* table_name, bool overwrite) { ulong packet_len = my_net_read(net); // read create table statement - char *query; - char* save_db; + char *query, *save_db; + uint32 save_db_length; Vio* save_vio; HA_CHECK_OPT check_opt; TABLE_LIST tables; @@ -1193,9 +1194,13 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, thd->proc_info = "Creating table from master dump"; // save old db in case we are creating in a different database save_db = thd->db; + save_db_length= thd->db_length; thd->db = (char*)db; + DBUG_ASSERT(thd->db); + thd->db_length= strlen(thd->db); mysql_parse(thd, thd->query, packet_len); // run create table thd->db = save_db; // leave things the way the were before + thd->db_length= save_db_length; thd->options = save_options; if (thd->query_error) @@ -2689,7 +2694,7 @@ err: IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff)); VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query = thd->db = 0; // extra safety - thd->query_length = 0; + thd->query_length= thd->db_length= 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); if (mysql) { @@ -2838,7 +2843,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ err: VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query = thd->db = 0; // extra safety - thd->query_length = 0; + thd->query_length= thd->db_length= 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); thd->proc_info = "Waiting for slave mutex on exit"; pthread_mutex_lock(&rli->run_lock); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 3d877403813..c8874701aa1 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -385,6 +385,15 @@ err: } +/* + Changes the current database. + + NOTES + Do as little as possible in this function, as it is not called for the + replication slave SQL thread (for that thread, setting of thd->db is done + in ::exec_event() methods of log_event.cc). +*/ + bool mysql_change_db(THD *thd,const char *name) { int length, db_length; From 49d90b09f558b30adf1578dfcaf7d094e51609bd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 16:56:31 +0200 Subject: [PATCH 30/41] after merge fixes --- mysql-test/r/rpl_set_charset.result | 7 ++----- mysql-test/t/rpl_set_charset.test | 7 ------- sql/sql_table.cc | 5 ++--- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/rpl_set_charset.result b/mysql-test/r/rpl_set_charset.result index 7297d80865b..fd9c99d35d8 100644 --- a/mysql-test/r/rpl_set_charset.result +++ b/mysql-test/r/rpl_set_charset.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; drop database if exists mysqltest1; create database mysqltest1 /*!40100 character set latin2 */; use mysqltest1; @@ -31,9 +31,6 @@ C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0 D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0 E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0 F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0 -show binlog events from 1979; -Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 1979 Query 1 1979 use `mysqltest1`; SET CHARACTER SET DEFAULT use mysqltest1; select "--- on slave ---"; --- on slave --- diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test index dcfc11bf25e..1c0bd62fa55 100644 --- a/mysql-test/t/rpl_set_charset.test +++ b/mysql-test/t/rpl_set_charset.test @@ -20,13 +20,6 @@ INSERT INTO t1 VALUES (' INSERT INTO t1 VALUES ('','F0'); select "--- on master ---"; select hex(a),b from t1 order by b; -# It's complicated to verify that the charset is reset to default in -# the binlog after each query, except by checking the binlog. When you -# merge this into 4.1/5.0, the 1979 will have to be changed; all you have -# to do is read the var/log/master-bin.0*01 with mysqlbinlog, verify -# that a SET CHARACTER SET DEFAULT is just after the last INSERT, and -# replace 1979 by its position (the "# at" line above the SET). -show binlog events from 1979; save_master_pos; connection slave; sync_with_master; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 129d63ff529..7f9898df76e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -35,8 +35,7 @@ #define reenable_binlog(A) (A)->options= save_options; -//extern HASH open_cache; // leftover from the merge. to be deleted -static const char *primary_key_name="PRIMARY"; +const char *primary_key_name="PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); @@ -1398,7 +1397,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, open_table(). */ tmp_disable_binlog(thd); - if (mysql_create_table(thd,db,name,create_info,*extra_fields, + if (!mysql_create_table(thd,db,name,create_info,*extra_fields, *keys,0,select_field_count)) { if (!(table=open_table(thd,db,name,name,(bool*) 0))) From 95036003c6bf0e0c685789f118a225f70b164a17 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 10:03:46 -0700 Subject: [PATCH 31/41] select.test: Added newline at the end of file. mysql-test/t/select.test: Added newline at the end of file. --- mysql-test/t/select.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index dae44159683..03490360b35 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1894,4 +1894,4 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; EXPLAIN SELECT i FROM t1 WHERE i=1; -DROP TABLE t1; \ No newline at end of file +DROP TABLE t1; From 3f70b62cebfbaa0e93ea5f378167d9d3e7b02a91 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 22:10:15 +0200 Subject: [PATCH 32/41] after merge --- client/mysql.cc | 2 +- mysql-test/r/select.result | 10 +++++----- mysql-test/t/select.test | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 36a2fecd661..142e396d424 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2626,7 +2626,7 @@ com_use(String *buffer __attribute__((unused)), char *line) mysql_free_result(res); } - if (!current_db || cmp_database(current_db,tmp)) + if (!current_db || cmp_database(charset_info, current_db,tmp)) { if (one_database) skip_updates= 1; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 09bcfbb0e7f..f0618c0f153 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2353,14 +2353,14 @@ i int(11) NOT NULL default '0', c char(10) NOT NULL default '', PRIMARY KEY (i), UNIQUE KEY c (c) -) TYPE=MyISAM; +) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,'a'); INSERT INTO t1 VALUES (2,'b'); INSERT INTO t1 VALUES (3,'c'); EXPLAIN SELECT i FROM t1 WHERE i=1; -table type possible_keys key key_len ref rows Extra -t1 const PRIMARY PRIMARY 4 const 1 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index EXPLAIN SELECT i FROM t1 WHERE i=1; -table type possible_keys key key_len ref rows Extra -t1 const PRIMARY PRIMARY 4 const 1 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 8228371142a..4490f97765b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1890,7 +1890,7 @@ CREATE TABLE t1 ( c char(10) NOT NULL default '', PRIMARY KEY (i), UNIQUE KEY c (c) -) TYPE=MyISAM; +) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,'a'); INSERT INTO t1 VALUES (2,'b'); From 3be674036fa9adc961a3100ea69dd7c7fa6675e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2004 19:46:09 -0700 Subject: [PATCH 33/41] func_group.test, func_group.result: Added test case for bug #5406. opt_sum.cc: Fixed bug #5406. sql/opt_sum.cc: Fixed bug #5406. mysql-test/r/func_group.result: Added test case for bug #5406. mysql-test/t/func_group.test: Added test case for bug #5406. --- mysql-test/r/func_group.result | 9 +++++++++ mysql-test/t/func_group.test | 16 ++++++++++++++++ sql/opt_sum.cc | 18 ++++++++---------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 06259ff4931..011a47874c2 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -684,3 +684,12 @@ max(a) 2 deallocate prepare stmt1; drop table t1; +CREATE TABLE t1 (a int primary key); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT MAX(a) FROM t1 WHERE a > 5; +MAX(a) +NULL +SELECT MIN(a) FROM t1 WHERE a < 0; +MIN(a) +NULL +DROP TABLE t1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 74f4c1bad44..7f48f2b92bd 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -418,3 +418,19 @@ execute stmt1; execute stmt1; deallocate prepare stmt1; drop table t1; + +# +# Bug #5406 min/max optimization for empty set +# + +CREATE TABLE t1 (a int primary key); +INSERT INTO t1 VALUES (1),(2),(3),(4); + +SELECT MAX(a) FROM t1 WHERE a > 5; +SELECT MIN(a) FROM t1 WHERE a < 0; + +DROP TABLE t1; + + + + diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index f4c39462d0c..538f5c6097d 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -186,16 +186,15 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!ref.key_length) error= table->file->index_first(table->record[0]); else - { error= table->file->index_read(table->record[0],key_buff, ref.key_length, range_fl & NEAR_MIN ? HA_READ_AFTER_KEY : HA_READ_KEY_OR_NEXT); - if (!error && reckey_in_range(0, &ref, item_field->field, - conds, range_fl, prefix_len)) - error= HA_ERR_KEY_NOT_FOUND; - } + if ((!error || error == HA_ERR_KEY_NOT_FOUND) && + reckey_in_range(0, &ref, item_field->field, + conds, range_fl, prefix_len)) + error= HA_ERR_KEY_NOT_FOUND; if (table->key_read) { table->key_read= 0; @@ -260,16 +259,15 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!ref.key_length) error= table->file->index_last(table->record[0]); else - { error= table->file->index_read(table->record[0], key_buff, ref.key_length, range_fl & NEAR_MAX ? HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV); - if (!error && reckey_in_range(1, &ref, item_field->field, - conds, range_fl, prefix_len)) - error= HA_ERR_KEY_NOT_FOUND; - } + if ((!error || error == HA_ERR_KEY_NOT_FOUND) && + reckey_in_range(1, &ref, item_field->field, + conds, range_fl, prefix_len)) + error= HA_ERR_KEY_NOT_FOUND; if (table->key_read) { table->key_read=0; From e5af92b0d21b9a0cbc55531dd2580709d503befd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 12:33:05 +0400 Subject: [PATCH 34/41] A fix and test case for bug#5399 "Wrong statement executed by MySQL server" (use my_charset_bin for stmt id hash). sql/sql_class.cc: Fix for bug#5399 "Wrong statement executed by MySQL server": we hash stmt ids bytewise, need to use binary collation for it. tests/client_test.c: Test case for bug#5399 "Wrong statement executed by MySQL server": create number of statements returning different results, execute them one by one. --- sql/sql_class.cc | 2 +- tests/client_test.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b103ee29095..2d6c778fab4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1502,7 +1502,7 @@ Statement_map::Statement_map() : START_STMT_HASH_SIZE = 16, START_NAME_HASH_SIZE = 16 }; - hash_init(&st_hash, default_charset_info, START_STMT_HASH_SIZE, 0, 0, + hash_init(&st_hash, &my_charset_bin, START_STMT_HASH_SIZE, 0, 0, get_statement_id_as_hash_key, delete_statement_as_hash_key, MYF(0)); hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0, diff --git a/tests/client_test.c b/tests/client_test.c index b124fba3f59..0f9d1dba4a7 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -10163,6 +10163,52 @@ static void test_bug4231() myquery(rc); } + +static void test_bug5399() +{ + /* + Ascii 97 is 'a', which gets mapped to Ascii 65 'A' unless internal + statement id hash in the server uses binary collation. + */ +#define NUM_OF_USED_STMT 97 + MYSQL_STMT *stmt[NUM_OF_USED_STMT]; + MYSQL_BIND bind[1]; + char buff[500]; + int rc, i; + int32 no; + + myheader("test_bug5399"); + + bzero(bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= &no; + + for (i= 0; i < NUM_OF_USED_STMT; ++i) + { + stmt[i]= mysql_stmt_init(mysql); + sprintf(buff, "select %d", i); + rc= mysql_stmt_prepare(stmt[i], buff, strlen(buff)); + check_execute(stmt[i], rc); + mysql_stmt_bind_result(stmt[i], bind); + } + printf("%d statements prepared.\n", NUM_OF_USED_STMT); + + for (i= 0; i < NUM_OF_USED_STMT; ++i) + { + rc= mysql_stmt_execute(stmt[i]); + check_execute(stmt[i], rc); + rc= mysql_stmt_store_result(stmt[i]); + check_execute(stmt[i], rc); + rc= mysql_stmt_fetch(stmt[i]); + assert(rc == 0); + assert((int32) i == no); + } + + for (i= 0; i < NUM_OF_USED_STMT; ++i) + mysql_stmt_close(stmt[i]); +#undef NUM_OF_USED_STMT +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -10463,6 +10509,8 @@ int main(int argc, char **argv) test_bug5126(); /* support for mediumint type in libmysql */ test_bug4231(); /* proper handling of all-zero times and dates in the server */ + test_bug5399(); /* check that statement id uniquely identifies + statement */ /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. From 9b1a33435a4b12e6b30b7098efccfbfe319edb4f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 17:38:57 +0500 Subject: [PATCH 35/41] After merge fix. sql/mysqld.cc: mlockall() call hided behind !defined(EMBEDDED_LIBRARY). --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d978069a823..c59f1ddcad6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2654,7 +2654,7 @@ server."); /* We must set dflt_key_cache in case we are using ISAM tables */ dflt_key_cache= sql_key_cache; -#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) +#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY) if (locked_in_memory && !getuid()) { if (seteuid(0) == -1) From 9b6ca7f3a516267422f4048d48ad1ce78a773c27 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 13:28:11 -0500 Subject: [PATCH 36/41] mysql.cc: Print sqlstate value in batch mode, not just in interactive mode. client/mysql.cc: Print sqlstate value in batch mode, not just in interactive mode. --- client/mysql.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 142e396d424..e940fdcc406 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2947,7 +2947,12 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) (void) fflush(file); fprintf(file,"ERROR"); if (error) - (void) fprintf(file," %d",error); + { + if (sqlstate) + (void) fprintf(file," %d (%s)",error, sqlstate); + else + (void) fprintf(file," %d",error); + } if (status.query_start_line && line_numbers) { (void) fprintf(file," at line %lu",status.query_start_line); From 4233d901f4d6a5b29f2ee944f96c6d3734531c81 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 22:43:37 +0400 Subject: [PATCH 37/41] Fix for bug#5400 "GROUP_CONCAT returns everything twice": Don't evaluate the value of GROUP_CONCAT several times for the same 'group', reuse the value instead. mysql-test/r/group_by.result: Testcase for bug#5400 mysql-test/t/group_by.test: Testcase for bug#5400 --- mysql-test/r/group_by.result | 9 +++++++++ mysql-test/t/group_by.test | 9 +++++++++ sql/item_sum.cc | 2 ++ 3 files changed, 20 insertions(+) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 9af7304c167..022b8eff7e8 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -629,3 +629,12 @@ explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort DROP TABLE t1; +create table t1 ( col1 int, col2 int ); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +select group_concat( distinct col1 ) as alias from t1 +group by col2 having alias like '%'; +alias +1,2 +1,2 +1 +drop table t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index d6d1922c10f..59983594c32 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -456,3 +456,12 @@ INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5); SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; DROP TABLE t1; + +# Test for BUG#5400: GROUP_CONCAT returns everything twice. +create table t1 ( col1 int, col2 int ); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +select group_concat( distinct col1 ) as alias from t1 + group by col2 having alias like '%'; + +drop table t1; + diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 79c1be57625..290e10bd59a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2121,6 +2121,8 @@ String* Item_func_group_concat::val_str(String* str) DBUG_ASSERT(fixed == 1); if (null_value) return 0; + if (result.length()) + return &result; if (tree_mode) { tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, From b9826e10635e222ca758692c6788a5a449e10926 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 21:54:01 +0300 Subject: [PATCH 38/41] test case of bug#5220 --- mysql-test/r/subselect_innodb.result | 8 ++++++++ mysql-test/t/subselect_innodb.test | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index bbbc607b6f8..e8f6426f51b 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -106,3 +106,11 @@ a b 2 12 4 105 drop table t1, t2; +CREATE TABLE `t1` ( `unit` varchar(50) NOT NULL default '', `ingredient` varchar(50) NOT NULL default '') ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE `t2` ( `ingredient` varchar(50) NOT NULL default '', `unit` varchar(50) NOT NULL default '', PRIMARY KEY (ingredient, unit)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES ('xx','yy'); +INSERT INTO `t2` VALUES ('yy','xx'); +SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient FROM t2 N WHERE N.unit = R.unit); +unit ingredient +xx yy +drop table t1, t2; diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 8c13171d221..5f4badb3624 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -111,3 +111,17 @@ create table t2 (a int) engine=innodb; insert into t2 values (1),(2),(3),(4); select a, sum(b) as b from t1 group by a having b > (select max(a) from t2); drop table t1, t2; + +# +# bug #5220 test suite +# +CREATE TABLE `t1` ( `unit` varchar(50) NOT NULL default '', `ingredient` varchar(50) NOT NULL default '') ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `t2` ( `ingredient` varchar(50) NOT NULL default '', `unit` varchar(50) NOT NULL default '', PRIMARY KEY (ingredient, unit)) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +INSERT INTO `t1` VALUES ('xx','yy'); +INSERT INTO `t2` VALUES ('yy','xx'); + +SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient FROM t2 N WHERE N.unit = R.unit); + +drop table t1, t2; From d7a230677c90831d1f21426a56fd2d0a9106f31e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 23:07:11 +0400 Subject: [PATCH 39/41] A fix and test case for Bug#5194 "Bulk Insert Failures with Prepared Statements": - fix a couple of net->buff overruns in libmysql, - check in the server that statement parameter count is less than 65535 (maximum value supported by prepared statements protocol). libmysql/libmysql.c: Bug#5194 "Bulk Insert Failures with Prepared Statements": - clean up my_realloc_str() - ensure that net buffer has space when storing null bits and parameter typecodes. sql/net_serv.cc: - set net->last_errno if packet is too big, even on client (Why was it ifdefed before?) sql/sql_prepare.cc: Bug#5194 "Bulk Insert Failures with Prepared Statements": - if placeholder count is bigger than 65535, give error. We have only 2 bytes reserved for transferring placeholder count in 4.1 protocol. - can't add a proper error code and message in 4.1 because of possible merge difficulties." tests/client_test.c: A test case for Bug#5194 "Bulk Insert Failures with Prepared Statements". --- libmysql/libmysql.c | 26 +++++-- sql/net_serv.cc | 2 - sql/sql_prepare.cc | 10 ++- tests/client_test.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 211 insertions(+), 10 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 5b3db5a1a47..f9a6202b761 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1703,16 +1703,18 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); /**************** Misc utility functions ****************************/ /* - Reallocate the NET package to be at least of 'length' bytes + Reallocate the NET package to have at least length bytes available. SYNPOSIS - my_realloc_str() - net The NET structure to modify - length Ensure that net->buff is at least this big + my_realloc_str() + net The NET structure to modify. + length Ensure that net->buff has space for at least + this number of bytes. RETURN VALUES - 0 ok - 1 Error + 0 Success. + 1 Error, i.e. out of memory or requested packet size is bigger + than max_allowed_packet. The error code is stored in net->last_errno. */ static my_bool my_realloc_str(NET *net, ulong length) @@ -2365,7 +2367,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) */ if ((my_realloc_str(net, *param->length))) { - set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); + set_stmt_error(stmt, net->last_errno, unknown_sqlstate); DBUG_RETURN(1); } (*param->store_param_func)(net, param); @@ -2427,6 +2429,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) net_clear(net); /* Sets net->write_pos */ /* Reserve place for null-marker bytes */ null_count= (stmt->param_count+7) /8; + if (my_realloc_str(net, null_count + 1)) + { + set_stmt_error(stmt, net->last_errno, unknown_sqlstate); + DBUG_RETURN(1); + } bzero((char*) net->write_pos, null_count); net->write_pos+= null_count; param_end= stmt->params + stmt->param_count; @@ -2435,6 +2442,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) *(net->write_pos)++= (uchar) stmt->send_types_to_server; if (stmt->send_types_to_server) { + if (my_realloc_str(net, 2 * stmt->param_count)) + { + set_stmt_error(stmt, net->last_errno, unknown_sqlstate); + DBUG_RETURN(1); + } /* Store types of parameters in first in first package that is sent to the server. diff --git a/sql/net_serv.cc b/sql/net_serv.cc index c2da47b480e..457b2052a45 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -193,9 +193,7 @@ my_bool net_realloc(NET *net, ulong length) { net->error= 1; net->report_error= 1; -#ifdef MYSQL_SERVER net->last_errno= ER_OUT_OF_RESOURCES; -#endif DBUG_RETURN(1); } net->buff=net->write_pos=buff; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1b6c7dbc9bc..aa3301d540f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1475,8 +1475,16 @@ error: static bool init_param_array(Prepared_statement *stmt) { LEX *lex= stmt->lex; + THD *thd= stmt->thd; if ((stmt->param_count= lex->param_list.elements)) { + if (stmt->param_count > (uint) UINT_MAX16) + { + /* Error code to be defined in 5.0 */ + send_error(thd, ER_UNKNOWN_ERROR, + "Prepared statement contains too many placeholders."); + return 1; + } Item_param **to; List_iterator param_iterator(lex->param_list); /* Use thd->mem_root as it points at statement mem_root */ @@ -1485,7 +1493,7 @@ static bool init_param_array(Prepared_statement *stmt) sizeof(Item_param*) * stmt->param_count); if (!stmt->param_array) { - send_error(stmt->thd, ER_OUT_OF_RESOURCES); + send_error(thd, ER_OUT_OF_RESOURCES); return 1; } for (to= stmt->param_array; diff --git a/tests/client_test.c b/tests/client_test.c index 0f9d1dba4a7..7e1aae1c997 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -10209,6 +10209,188 @@ static void test_bug5399() #undef NUM_OF_USED_STMT } + +static void test_bug5194() +{ + MYSQL_STMT *stmt; + MYSQL_BIND *bind; + char *query; + char *param_str; + int param_str_length; + const char *stmt_text; + int rc; + float float_array[250] = + { + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25 + }; + float *fa_ptr= float_array; + /* Number of columns per row */ + const int COLUMN_COUNT= sizeof(float_array)/sizeof(*float_array); + /* Number of rows per bulk insert to start with */ + const int MIN_ROWS_PER_INSERT= 260; + /* Max number of rows per bulk insert to end with */ + const int MAX_ROWS_PER_INSERT= 300; + const int MAX_PARAM_COUNT= COLUMN_COUNT*MAX_ROWS_PER_INSERT; + const char *query_template= "insert into t1 values %s"; + const int CHARS_PER_PARAM= 5; /* space needed to place ", ?" in the query */ + const int uint16_max= 65535; + int nrows, i; + + myheader("test_bug5194"); + + stmt_text= "drop table if exists t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + + stmt_text= "create table if not exists t1" + "(c1 float, c2 float, c3 float, c4 float, c5 float, c6 float, " + "c7 float, c8 float, c9 float, c10 float, c11 float, c12 float, " + "c13 float, c14 float, c15 float, c16 float, c17 float, c18 float, " + "c19 float, c20 float, c21 float, c22 float, c23 float, c24 float, " + "c25 float, c26 float, c27 float, c28 float, c29 float, c30 float, " + "c31 float, c32 float, c33 float, c34 float, c35 float, c36 float, " + "c37 float, c38 float, c39 float, c40 float, c41 float, c42 float, " + "c43 float, c44 float, c45 float, c46 float, c47 float, c48 float, " + "c49 float, c50 float, c51 float, c52 float, c53 float, c54 float, " + "c55 float, c56 float, c57 float, c58 float, c59 float, c60 float, " + "c61 float, c62 float, c63 float, c64 float, c65 float, c66 float, " + "c67 float, c68 float, c69 float, c70 float, c71 float, c72 float, " + "c73 float, c74 float, c75 float, c76 float, c77 float, c78 float, " + "c79 float, c80 float, c81 float, c82 float, c83 float, c84 float, " + "c85 float, c86 float, c87 float, c88 float, c89 float, c90 float, " + "c91 float, c92 float, c93 float, c94 float, c95 float, c96 float, " + "c97 float, c98 float, c99 float, c100 float, c101 float, c102 float, " + "c103 float, c104 float, c105 float, c106 float, c107 float, c108 float, " + "c109 float, c110 float, c111 float, c112 float, c113 float, c114 float, " + "c115 float, c116 float, c117 float, c118 float, c119 float, c120 float, " + "c121 float, c122 float, c123 float, c124 float, c125 float, c126 float, " + "c127 float, c128 float, c129 float, c130 float, c131 float, c132 float, " + "c133 float, c134 float, c135 float, c136 float, c137 float, c138 float, " + "c139 float, c140 float, c141 float, c142 float, c143 float, c144 float, " + "c145 float, c146 float, c147 float, c148 float, c149 float, c150 float, " + "c151 float, c152 float, c153 float, c154 float, c155 float, c156 float, " + "c157 float, c158 float, c159 float, c160 float, c161 float, c162 float, " + "c163 float, c164 float, c165 float, c166 float, c167 float, c168 float, " + "c169 float, c170 float, c171 float, c172 float, c173 float, c174 float, " + "c175 float, c176 float, c177 float, c178 float, c179 float, c180 float, " + "c181 float, c182 float, c183 float, c184 float, c185 float, c186 float, " + "c187 float, c188 float, c189 float, c190 float, c191 float, c192 float, " + "c193 float, c194 float, c195 float, c196 float, c197 float, c198 float, " + "c199 float, c200 float, c201 float, c202 float, c203 float, c204 float, " + "c205 float, c206 float, c207 float, c208 float, c209 float, c210 float, " + "c211 float, c212 float, c213 float, c214 float, c215 float, c216 float, " + "c217 float, c218 float, c219 float, c220 float, c221 float, c222 float, " + "c223 float, c224 float, c225 float, c226 float, c227 float, c228 float, " + "c229 float, c230 float, c231 float, c232 float, c233 float, c234 float, " + "c235 float, c236 float, c237 float, c238 float, c239 float, c240 float, " + "c241 float, c242 float, c243 float, c244 float, c245 float, c246 float, " + "c247 float, c248 float, c249 float, c250 float)"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + bind= (MYSQL_BIND*) malloc(MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); + query= (char*) malloc(strlen(query_template) + + MAX_PARAM_COUNT * CHARS_PER_PARAM + 1); + param_str= (char*) malloc(COLUMN_COUNT * CHARS_PER_PARAM); + + if (bind == 0 || query == 0 || param_str == 0) + { + fprintf(stderr, "Can't allocate enough memory for query structs\n"); + return; + } + + stmt= mysql_stmt_init(mysql); + + /* setup a template for one row of parameters */ + sprintf(param_str, "("); + for (i= 1; i < COLUMN_COUNT; ++i) + strcat(param_str, "?, "); + strcat(param_str, "?)"); + param_str_length= strlen(param_str); + + /* setup bind array */ + bzero(bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); + for (i= 0; i < MAX_PARAM_COUNT; ++i) + { + bind[i].buffer_type= MYSQL_TYPE_FLOAT; + bind[i].buffer= fa_ptr; + if (++fa_ptr == float_array + COLUMN_COUNT) + fa_ptr= float_array; + } + + /* + Test each number of rows per bulk insert, so that we can see where + MySQL fails. + */ + for (nrows= MIN_ROWS_PER_INSERT; nrows <= MAX_ROWS_PER_INSERT; ++nrows) + { + char *query_ptr; + /* Create statement text for current number of rows */ + sprintf(query, query_template, param_str); + query_ptr= query + strlen(query); + for (i= 1; i < nrows; ++i) + { + memcpy(query_ptr, ", ", 2); + query_ptr+= 2; + memcpy(query_ptr, param_str, param_str_length); + query_ptr+= param_str_length; + } + *query_ptr= '\0'; + + rc= mysql_stmt_prepare(stmt, query, query_ptr - query); + if (rc && nrows * COLUMN_COUNT > uint16_max) + { + printf("Failed to prepare a statement with %d placeholders " + "(as expected).\n", nrows * COLUMN_COUNT); + break; + } + else + check_execute(stmt, rc); + + printf("Insert: query length= %d, row count= %d, param count= %lu\n", + strlen(query), nrows, mysql_stmt_param_count(stmt)); + + /* bind the parameter array and execute the query */ + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + } + + mysql_stmt_close(stmt); + free(bind); + free(query); + free(param_str); + stmt_text= "drop table t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -10511,6 +10693,7 @@ int main(int argc, char **argv) dates in the server */ test_bug5399(); /* check that statement id uniquely identifies statement */ + test_bug5194(); /* bulk inserts in prepared mode */ /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. From b1c77d977bdc710448f3f05f3dad1220871ddb9d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 22:05:49 +0200 Subject: [PATCH 40/41] log.cc: Changed label on INFORMATION log items to NOTE sql/log.cc: Changed label on INFORMATION log items to NOTE --- sql/log.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log.cc b/sql/log.cc index 1a3807cbfe6..79934451b09 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1994,7 +1994,7 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) start->tm_min, start->tm_sec, (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? - "WARNING" : "INFORMATION"), + "WARNING" : "NOTE"), buffer); fflush(stderr); From 50f9e2f58126f97d215cccbecd60c7c325922ec0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2004 20:13:27 -0500 Subject: [PATCH 41/41] client_test.c: fix typos noticed while poking around in test program. tests/client_test.c: fix typos noticed while poking around in test program. --- tests/client_test.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/client_test.c b/tests/client_test.c index 7e1aae1c997..8a98c5b6584 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -223,7 +223,7 @@ static void client_disconnect() if (mysql) { - fprintf(stdout, "\n droping the test database '%s' ...", current_db); + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); mysql_query(mysql, query); @@ -797,21 +797,21 @@ static void test_tran_bdb() rc= mysql_commit(mysql); myquery(rc); - /* now insert the second row, and rollback the transaction */ + /* now insert the second row, and roll back the transaction */ rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(20, 'mysql')"); myquery(rc); rc= mysql_rollback(mysql); myquery(rc); - /* delete first row, and rollback it */ + /* delete first row, and roll it back */ rc= mysql_query(mysql, "DELETE FROM my_demo_transaction WHERE col1= 10"); myquery(rc); rc= mysql_rollback(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); @@ -822,7 +822,7 @@ static void test_tran_bdb() my_process_result_set(result); mysql_free_result(result); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); @@ -870,21 +870,21 @@ static void test_tran_innodb() rc= mysql_commit(mysql); myquery(rc); - /* now insert the second row, and rollback the transaction */ + /* now insert the second row, and roll back the transaction */ rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(20, 'mysql')"); myquery(rc); rc= mysql_rollback(mysql); myquery(rc); - /* delete first row, and rollback it */ + /* delete first row, and roll it back */ rc= mysql_query(mysql, "DELETE FROM my_demo_transaction WHERE col1= 10"); myquery(rc); rc= mysql_rollback(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); @@ -895,7 +895,7 @@ static void test_tran_innodb() my_process_result_set(result); mysql_free_result(result); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); @@ -1158,7 +1158,7 @@ static void test_prepare() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare")); stmt= mysql_simple_prepare(mysql, "SELECT * FROM my_prepare"); @@ -1304,7 +1304,7 @@ static void test_double_compare() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM test_double_compare"); myquery(rc); @@ -1740,7 +1740,7 @@ static void test_select() rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 'venu')"); myquery(rc); - /* now insert the second row, and rollback the transaction */ + /* now insert the second row, and roll back the transaction */ rc= mysql_query(mysql, "INSERT INTO test_select VALUES(20, 'mysql')"); myquery(rc); @@ -2259,7 +2259,7 @@ static void test_simple_update() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM test_update"); myquery(rc); @@ -2738,7 +2738,7 @@ static void test_simple_delete() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM test_simple_delete"); myquery(rc); @@ -2837,7 +2837,7 @@ static void test_update() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM test_update"); myquery(rc); @@ -2883,7 +2883,7 @@ static void test_prepare_noparam() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM my_prepare"); myquery(rc); @@ -3953,7 +3953,7 @@ static void test_insert() rc= mysql_commit(mysql); myquery(rc); - /* test the results now, only one row should exists */ + /* test the results now, only one row should exist */ rc= mysql_query(mysql, "SELECT * FROM test_prep_insert"); myquery(rc); @@ -4906,7 +4906,7 @@ DROP TABLE IF EXISTS test_multi_tab"; /* First test that we get an error for multi statements - (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) + (Because default connection is not opened with CLIENT_MULTI_STATEMENTS) */ rc= mysql_query(mysql, query); /* syntax error */ myquery_r(rc); @@ -4920,7 +4920,7 @@ DROP TABLE IF EXISTS test_multi_tab"; exit(1); } - /* Create connection that supprot multi statements */ + /* Create connection that supports multi statements */ if (!(mysql_real_connect(mysql_local, opt_host, opt_user, opt_password, current_db, opt_port, opt_unix_socket, CLIENT_MULTI_STATEMENTS)))