From 7c16fd2c0f9eb167b841b94241d8083ec1d6c984 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Wed, 17 Oct 2007 20:40:23 +0200 Subject: [PATCH 001/128] Bug #30878: Crashing when alter an auto_increment non partitioned table to partitioned Problem: Crashed because usage of an uninitialised mutex when auto_incrementing a partitioned temporary table Fix: Only locking (using the mutex) if not temporary table. --- mysql-test/r/partition.result | 12 ++++++++++++ mysql-test/t/partition.test | 18 ++++++++++++++++++ sql/ha_partition.cc | 20 +++++++++++++++----- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index f90f3b07d70..753a2e31632 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,16 @@ drop table if exists t1; +create table t1 (id int auto_increment, s1 int, primary key (id)); +insert into t1 values (null,1); +insert into t1 values (null,6); +select * from t1; +id s1 +1 1 +2 6 +alter table t1 partition by range (id) ( +partition p0 values less than (3), +partition p1 values less than maxvalue +); +drop table t1; create table t1 (a int) partition by key(a) partitions 0.2+e1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index f391237a4db..929d3ecce9e 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,24 @@ drop table if exists t1; --enable_warnings +# +# Bug 30878: crashing when alter an auto_increment non partitioned +# table to partitioned + +create table t1 (id int auto_increment, s1 int, primary key (id)); + +insert into t1 values (null,1); +insert into t1 values (null,6); + +select * from t1; + +alter table t1 partition by range (id) ( + partition p0 values less than (3), + partition p1 values less than maxvalue +); + +drop table t1; + # # Bug 15890: Strange number of partitions accepted # diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 1150cf41417..81d75c58d05 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2678,7 +2678,8 @@ int ha_partition::write_row(uchar * buf) uint32 part_id; int error; longlong func_value; - bool autoincrement_lock= false; + bool autoincrement_lock= FALSE; + my_bitmap_map *old_map; #ifdef NOT_NEEDED uchar *rec0= m_rec0; #endif @@ -2705,8 +2706,17 @@ int ha_partition::write_row(uchar * buf) use autoincrement_lock variable to avoid unnecessary locks. Probably not an ideal solution. */ - autoincrement_lock= true; - pthread_mutex_lock(&table_share->mutex); + if (table_share->tmp_table == NO_TMP_TABLE) + { + /* + Bug#30878 crash when alter table from non partitioned table + to partitioned. + Checking if tmp table then there is no need to lock, + and the table_share->mutex may not be initialised. + */ + autoincrement_lock= TRUE; + pthread_mutex_lock(&table_share->mutex); + } error= update_auto_increment(); /* @@ -2715,10 +2725,10 @@ int ha_partition::write_row(uchar * buf) the correct partition. We must check and fail if neccessary. */ if (error) - DBUG_RETURN(error); + goto exit; } - my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); + old_map= dbug_tmp_use_all_columns(table, table->read_set); #ifdef NOT_NEEDED if (likely(buf == rec0)) #endif From c60397ef1988ed1286a4d99dc2b9f9216c5dd98b Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Fri, 19 Oct 2007 19:57:08 +0400 Subject: [PATCH 002/128] Patch for BUG#31111: --read-only crashes MySQL (events fail to load). There actually were several problems here: - WRITE-lock is required to load events from the mysql.event table, but in the read-only mode an ordinary user can not acquire it; - Security_context::master_access attribute was not properly initialized in Security_context::init(), which led to differences in behavior with and without debug configure options. - if the server failed to load events from mysql.event, it forgot to close the mysql.event table, that led to the coredump, described in the bug report. The patch is to fix all these problems: - Use the super-user to acquire WRITE-lock on the mysql.even table; - The WRITE-lock is acquired by the event scheduler in two cases: - on initial loading of events from the database; - when an event has been executed, so its attributes should be updated. Other cases when WRITE-lock is needed for the mysql.event table happen under the user account. So, nothing should be changed there for the read-only mode. The user is able to create/update/drop an event only if he is a super-user. - Initialize Security_context::master_access; - Close the mysql.event table in case something went wrong. --- mysql-test/r/events_bugs.result | 103 ++++++++++++++- mysql-test/t/events_bugs.test | 224 ++++++++++++++++++++++++++++++-- sql/event_data_objects.cc | 16 ++- sql/event_db_repository.cc | 9 ++ sql/event_scheduler.cc | 7 + sql/events.cc | 16 ++- sql/sql_class.cc | 1 + 7 files changed, 360 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 3c9e6384c64..b6b77101874 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -610,7 +610,6 @@ id ev_nm ev_cnt 6 ev_sched_1823 6 DROP TABLE event_log; SET GLOBAL event_scheduler = OFF; -DROP DATABASE events_test; SET GLOBAL event_scheduler= ON; CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' DO BEGIN @@ -618,3 +617,105 @@ SELECT 1; END;| SET GLOBAL event_scheduler= OFF; DROP EVENT bug28641; + +##################################################################### +# +# BUG#31111: --read-only crashes MySQL (events fail to load). +# +##################################################################### + +DROP USER mysqltest_u1@localhost; +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; + +GRANT EVENT ON *.* TO mysqltest_u1@localhost; + +SET GLOBAL READ_ONLY = 1; + +# +# Connection: u1_con (mysqltest_u1@localhost/events_test). +# + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +ALTER EVENT e1 COMMENT 'comment'; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +DROP EVENT e1; +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement + +# +# Connection: root_con (root@localhost/events_test). +# + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +ALTER EVENT e1 COMMENT 'comment'; + +DROP EVENT e1; + +SET GLOBAL READ_ONLY = 0; + +# +# Connection: u1_con (mysqltest_u1@localhost/test). +# + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; + +SELECT +event_name, +last_executed IS NULL, +definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; +event_name last_executed IS NULL definer +e1 1 mysqltest_u1@localhost +e2 1 mysqltest_u1@localhost + +# +# Connection: root_con (root@localhost/events_test). +# + +SET GLOBAL READ_ONLY = 1; + +SET GLOBAL EVENT_SCHEDULER = ON; + +# Waiting for the event scheduler to execute and drop event e1... + +# Waiting for the event scheduler to execute and update event e2... + +SET GLOBAL EVENT_SCHEDULER = OFF; + +SELECT +event_name, +last_executed IS NULL, +definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; +event_name last_executed IS NULL definer +e2 0 mysqltest_u1@localhost + +DROP EVENT e1; +ERROR HY000: Unknown event 'e1' + +# Cleanup. + +DROP EVENT e2; + +SET GLOBAL READ_ONLY = 0; + +# +# Connection: default +# + +DROP USER mysqltest_u1@localhost; + +##################################################################### +# +# End of BUG#31111. +# +##################################################################### + +DROP DATABASE events_test; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 36052fdb9af..ebd86f3a3d2 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -712,18 +712,6 @@ DROP TABLE event_log; #DROP DATABASE ev_db_1; SET GLOBAL event_scheduler = OFF; -# -# End of tests -# - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -DROP DATABASE events_test; - - # # Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. # @@ -737,3 +725,215 @@ CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' DELIMITER ;| SET GLOBAL event_scheduler= OFF; DROP EVENT bug28641; + +########################################################################### + +--echo +--echo ##################################################################### +--echo # +--echo # BUG#31111: --read-only crashes MySQL (events fail to load). +--echo # +--echo ##################################################################### +--echo + +--error 0,ER_CANNOT_USER +DROP USER mysqltest_u1@localhost; + +--disable_warnings +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +--enable_warnings + +--echo + +# Check that an ordinary user can not create/update/drop events in the +# read-only mode. + +GRANT EVENT ON *.* TO mysqltest_u1@localhost; + +--echo + +SET GLOBAL READ_ONLY = 1; + +--echo + +--echo # +--echo # Connection: u1_con (mysqltest_u1@localhost/events_test). +--echo # + +--connect(u1_con,localhost,mysqltest_u1,,events_test) + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +DROP EVENT e1; + +--echo + +# Check that the super user still can create/update/drop events. + +--echo # +--echo # Connection: root_con (root@localhost/events_test). +--echo # + +--connect(root_con,localhost,root,,events_test) + +--echo + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +DROP EVENT e1; + +--echo + +# +# Switch to read-write mode; create test events under the user mysqltest_u1; +# switch back to read-only mode. +# + +SET GLOBAL READ_ONLY = 0; + +--echo + +--echo # +--echo # Connection: u1_con (mysqltest_u1@localhost/test). +--echo # + +--connection u1_con + +--echo + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; + +--echo + +SELECT + event_name, + last_executed IS NULL, + definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; + +--echo + +--echo # +--echo # Connection: root_con (root@localhost/events_test). +--echo # + +--connection root_con + +--echo + +SET GLOBAL READ_ONLY = 1; + +# Check that the event scheduler is able to update event. + +--echo + +SET GLOBAL EVENT_SCHEDULER = ON; + +--echo + +--echo # Waiting for the event scheduler to execute and drop event e1... + +let $wait_timeout = 2; +let $wait_condition = + SELECT COUNT(*) = 0 + FROM INFORMATION_SCHEMA.EVENTS + WHERE event_schema = 'events_test' AND event_name = 'e1'; +--source include/wait_condition.inc + +--echo + +--echo # Waiting for the event scheduler to execute and update event e2... + +let $wait_condition = + SELECT last_executed IS NOT NULL + FROM INFORMATION_SCHEMA.EVENTS + WHERE event_schema = 'events_test' AND event_name = 'e2'; +--source include/wait_condition.inc + +--echo + +SET GLOBAL EVENT_SCHEDULER = OFF; + +--echo + +SELECT + event_name, + last_executed IS NULL, + definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; + +--echo + +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT e1; + +--echo +--echo # Cleanup. +--echo + +DROP EVENT e2; + +--echo + +SET GLOBAL READ_ONLY = 0; + +--echo + +--echo # +--echo # Connection: default +--echo # + +--disconnect u1_con +--disconnect root_con +--connection default + +--echo + +DROP USER mysqltest_u1@localhost; + +--echo +--echo ##################################################################### +--echo # +--echo # End of BUG#31111. +--echo # +--echo ##################################################################### +--echo + + +########################################################################### +# +# End of tests +# +# !!! KEEP this section AT THE END of this file !!! +# +########################################################################### + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +DROP DATABASE events_test; + +# THIS MUST BE THE LAST LINE in this file. diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 787b04c12c6..adac2b596c1 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -2017,6 +2017,7 @@ end_no_lex_start: ret= 1; else { + ulong saved_master_access; /* Peculiar initialization order is a crutch to avoid races in SHOW PROCESSLIST which reads thd->{query/query_length} without a mutex. @@ -2024,8 +2025,19 @@ end_no_lex_start: thd->query_length= 0; thd->query= sp_sql.c_ptr_safe(); thd->query_length= sp_sql.length(); - if (Events::drop_event(thd, dbname, name, FALSE)) - ret= 1; + + /* + NOTE: even if we run in read-only mode, we should be able to lock + the mysql.event table for writing. In order to achieve this, we + should call mysql_lock_tables() under the super-user. + */ + + saved_master_access= thd->security_ctx->master_access; + thd->security_ctx->master_access |= SUPER_ACL; + + ret= Events::drop_event(thd, dbname, name, FALSE); + + thd->security_ctx->master_access= saved_master_access; } } #ifndef NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 705bd8b2704..4451e763ff7 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -525,6 +525,10 @@ Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *tables, - whether this open mode would work under LOCK TABLES, or inside a stored function or trigger. + Note that if the table can't be locked successfully this operation will + close it. Therefore it provides guarantee that it either opens and locks + table or fails without leaving any tables open. + @param[in] thd Thread context @param[in] lock_type How to lock the table @param[out] table We will store the open table here @@ -544,7 +548,10 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type, tables.init_one_table("mysql", "event", lock_type); if (simple_open_n_lock_tables(thd, &tables)) + { + close_thread_tables(thd, FALSE, FALSE); DBUG_RETURN(TRUE); + } *table= tables.table; tables.table->use_all_columns(); @@ -995,6 +1002,8 @@ update_timing_fields_for_event(THD *thd, if (thd->current_stmt_binlog_row_based) thd->clear_current_stmt_binlog_row_based(); + DBUG_ASSERT(thd->security_ctx->master_access & SUPER_ACL); + if (open_event_table(thd, TL_WRITE, &table)) goto end; diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index b03b51f1134..d3a031fd8f8 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -399,6 +399,13 @@ Event_scheduler::start() new_thd->system_thread= SYSTEM_THREAD_EVENT_SCHEDULER; new_thd->command= COM_DAEMON; + /* + We should run the event scheduler thread under the super-user privileges. + In particular, this is needed to be able to lock the mysql.event table + for writing when the server is running in the read-only mode. + */ + new_thd->security_ctx->master_access |= SUPER_ACL; + scheduler_param_value= (struct scheduler_param *)my_malloc(sizeof(struct scheduler_param), MYF(0)); scheduler_param_value->thd= new_thd; diff --git a/sql/events.cc b/sql/events.cc index 5246bccc388..1bfbc5d6645 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1124,11 +1124,25 @@ Events::load_events_from_db(THD *thd) READ_RECORD read_record_info; bool ret= TRUE; uint count= 0; + ulong saved_master_access; DBUG_ENTER("Events::load_events_from_db"); DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd)); - if (db_repository->open_event_table(thd, TL_WRITE, &table)) + /* + NOTE: even if we run in read-only mode, we should be able to lock the + mysql.event table for writing. In order to achieve this, we should call + mysql_lock_tables() under the super user. + */ + + saved_master_access= thd->security_ctx->master_access; + thd->security_ctx->master_access |= SUPER_ACL; + + ret= db_repository->open_event_table(thd, TL_WRITE, &table); + + thd->security_ctx->master_access= saved_master_access; + + if (ret) { sql_print_error("Event Scheduler: Failed to open table mysql.event"); DBUG_RETURN(TRUE); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ffbf0649961..d3ebfd94aa7 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2404,6 +2404,7 @@ void Security_context::init() host= user= priv_user= ip= 0; host_or_ip= "connecting host"; priv_host[0]= '\0'; + master_access= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS db_access= NO_ACCESS; #endif From 7c00f8a3b474ef278004d29dcd8811f0c8f76d50 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Sat, 20 Oct 2007 01:20:38 +0400 Subject: [PATCH 003/128] Rename: query_error -> is_slave_error. Add comments. --- sql/ha_ndbcluster_binlog.cc | 4 +-- sql/handler.cc | 6 ++--- sql/log.cc | 4 +-- sql/log_event.cc | 54 ++++++++++++++++++++----------------- sql/log_event_old.cc | 12 ++++----- sql/mysqld.cc | 2 +- sql/protocol.cc | 4 +-- sql/slave.cc | 6 ++--- sql/sp_head.cc | 6 ++--- sql/sql_class.cc | 2 +- sql/sql_class.h | 11 ++++++-- sql/sql_connect.cc | 2 +- 12 files changed, 63 insertions(+), 50 deletions(-) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 5d5c8a26447..c22d5ac53f5 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -259,7 +259,7 @@ static void run_query(THD *thd, char *buf, char *end, DBUG_PRINT("query", ("%s", thd->query)); mysql_parse(thd, thd->query, thd->query_length, &found_semicolon); - if (no_print_error && thd->query_error) + if (no_print_error && thd->is_slave_error) { int i; Thd_ndb *thd_ndb= get_thd_ndb(thd); @@ -271,7 +271,7 @@ static void run_query(THD *thd, char *buf, char *end, sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d", buf, thd->net.last_error, thd->net.last_errno, thd_ndb->m_error_code, - thd->net.report_error, thd->query_error); + thd->net.report_error, thd->is_slave_error); } thd->options= save_thd_options; diff --git a/sql/handler.cc b/sql/handler.cc index 75c3a64bc27..706da76c000 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1447,7 +1447,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, (We should in the future either rewrite handler::print_error() or make a nice method of this. */ - bool query_error= thd->query_error; + bool is_slave_error= thd->is_slave_error; sp_rcontext *spcont= thd->spcont; SELECT_LEX *current_select= thd->lex->current_select; char buff[sizeof(thd->net.last_error)]; @@ -1455,7 +1455,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, int last_errno= thd->net.last_errno; strmake(buff, thd->net.last_error, sizeof(buff)-1); - thd->query_error= 0; + thd->is_slave_error= 0; thd->spcont= NULL; thd->lex->current_select= 0; thd->net.last_error[0]= 0; @@ -1475,7 +1475,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, strmake(new_error, thd->net.last_error, sizeof(buff)-1); /* restore thd */ - thd->query_error= query_error; + thd->is_slave_error= is_slave_error; thd->spcont= spcont; thd->lex->current_select= current_select; thd->net.last_errno= last_errno; diff --git a/sql/log.cc b/sql/log.cc index e923418b23a..02986bef493 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2891,8 +2891,8 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, *decrease_log_space-= file_size; ha_binlog_index_purge_file(current_thd, log_info.log_file_name); - if (current_thd->query_error) { - DBUG_PRINT("info",("query error: %d", current_thd->query_error)); + if (current_thd->is_slave_error) { + DBUG_PRINT("info",("slave error: %d", current_thd->is_slave_error)); if (my_errno == EMFILE) { DBUG_PRINT("info",("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno)); ret = LOG_INFO_EMFILE; diff --git a/sql/log_event.cc b/sql/log_event.cc index a435894382b..a6d07e72033 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -148,7 +148,7 @@ static void pretty_print_str(IO_CACHE* cache, char* str, int len) static void clear_all_errors(THD *thd, Relay_log_info *rli) { - thd->query_error = 0; + thd->is_slave_error = 0; thd->clear_error(); rli->clear_error(); } @@ -2106,7 +2106,7 @@ and was aborted. There is a chance that your master is inconsistent at this \ point. If you are sure that your master is ok, run this query manually on the \ slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; \ START SLAVE; . Query: '%s'", expected_error, thd->query); - thd->query_error= 1; + thd->is_slave_error= 1; } goto end; } @@ -2138,7 +2138,7 @@ Default database: '%s'. Query: '%s'", actual_error ? thd->net.last_error: "no error", actual_error, print_slave_db_safe(db), query_arg); - thd->query_error= 1; + thd->is_slave_error= 1; } /* If we get the same error code as expected, or they should be ignored. @@ -2153,14 +2153,14 @@ Default database: '%s'. Query: '%s'", /* Other cases: mostly we expected no error and get one. */ - else if (thd->query_error || thd->is_fatal_error) + else if (thd->is_slave_error || thd->is_fatal_error) { rli->report(ERROR_LEVEL, actual_error, "Error '%s' on query. Default database: '%s'. Query: '%s'", (actual_error ? thd->net.last_error : "unexpected success or fatal error"), print_slave_db_safe(thd->db), query_arg); - thd->query_error= 1; + thd->is_slave_error= 1; } /* @@ -2171,7 +2171,7 @@ Default database: '%s'. Query: '%s'", sql_print_error("Slave: did not get the expected number of affected \ rows running query from master - expected %d, got %d (this numbers \ should have matched modulo 4294967296).", 0, ...); - thd->query_error = 1; + thd->is_slave_error = 1; } We may also want an option to tell the slave to ignore "affected" mismatch. This mismatch could be implemented with a new ER_ code, and @@ -2215,7 +2215,7 @@ end: thd->first_successful_insert_id_in_prev_stmt= 0; thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0; free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); - return thd->query_error; + return thd->is_slave_error; } int Query_log_event::do_update_pos(Relay_log_info *rli) @@ -3255,7 +3255,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli, thd->set_db(new_db.str, new_db.length); DBUG_ASSERT(thd->query == 0); thd->query_length= 0; // Should not be needed - thd->query_error= 0; + thd->is_slave_error= 0; clear_all_errors(thd, const_cast(rli)); /* see Query_log_event::do_apply_event() and BUG#13360 */ @@ -3429,7 +3429,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli, List tmp_list; if (mysql_load(thd, &ex, &tables, field_list, tmp_list, tmp_list, handle_dup, ignore, net != 0)) - thd->query_error= 1; + thd->is_slave_error= 1; if (thd->cuted_fields) { /* log_pos is the position of the LOAD event in the master log */ @@ -3468,9 +3468,9 @@ error: close_thread_tables(thd); DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error", - thd->query_error= 0; thd->is_fatal_error= 1;); + thd->is_slave_error= 0; thd->is_fatal_error= 1;); - if (thd->query_error) + if (thd->is_slave_error) { /* this err/sql_errno code is copy-paste from net_send_error() */ const char *err; @@ -5655,7 +5655,7 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, m_width(tbl_arg ? tbl_arg->s->fields : 1), m_rows_buf(0), m_rows_cur(0), m_rows_end(0), m_flags(0) #ifdef HAVE_REPLICATION - ,m_key(NULL), m_curr_row(NULL), m_curr_row_end(NULL) + , m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL) #endif { /* @@ -5703,7 +5703,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, #endif m_table_id(0), m_rows_buf(0), m_rows_cur(0), m_rows_end(0) #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - ,m_key(NULL), m_curr_row(NULL), m_curr_row_end(NULL) + , m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL) #endif { DBUG_ENTER("Rows_log_event::Rows_log_event(const char*,...)"); @@ -5951,7 +5951,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) { if (!need_reopen) { - if (thd->query_error || thd->is_fatal_error) + if (thd->is_slave_error || thd->is_fatal_error) { /* Error reporting borrowed from Query_log_event with many excessive @@ -5995,7 +5995,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) uint tables_count= rli->tables_to_lock_count; if ((error= open_tables(thd, &tables, &tables_count, 0))) { - if (thd->query_error || thd->is_fatal_error) + if (thd->is_slave_error || thd->is_fatal_error) { /* Error reporting borrowed from Query_log_event with many excessive @@ -6006,7 +6006,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) "Error '%s' on reopening tables", (actual_error ? thd->net.last_error : "unexpected success or fatal error")); - thd->query_error= 1; + thd->is_slave_error= 1; } const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(error); @@ -6029,7 +6029,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) { mysql_unlock_tables(thd, thd->lock); thd->lock= 0; - thd->query_error= 1; + thd->is_slave_error= 1; const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(ERR_BAD_TABLE_DEF); } @@ -6159,7 +6159,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) "Error in %s event: row application failed. %s", get_type_str(), thd->net.last_error ? thd->net.last_error : ""); - thd->query_error= 1; + thd->is_slave_error= 1; break; } @@ -6221,7 +6221,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) */ thd->reset_current_stmt_binlog_row_based(); const_cast(rli)->cleanup_context(thd, error); - thd->query_error= 1; + thd->is_slave_error= 1; DBUG_RETURN(error); } @@ -6519,9 +6519,15 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, m_dblen(m_dbnam ? tbl->s->db.length : 0), m_tblnam(tbl->s->table_name.str), m_tbllen(tbl->s->table_name.length), - m_colcnt(tbl->s->fields), m_field_metadata(0), - m_field_metadata_size(0), m_memory(NULL), m_meta_memory(NULL), m_data_size(0), - m_table_id(tid), m_null_bits(0), m_flags(flags) + m_colcnt(tbl->s->fields), + m_memory(NULL), + m_table_id(tid), + m_flags(flags), + m_data_size(0), + m_field_metadata(0), + m_field_metadata_size(0), + m_null_bits(0), + m_meta_memory(NULL) { DBUG_ASSERT(m_table_id != ~0UL); /* @@ -6798,7 +6804,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) TABLE_LIST *tmp_table_list= table_list; if ((error= open_tables(thd, &tmp_table_list, &count, 0))) { - if (thd->query_error || thd->is_fatal_error) + if (thd->is_slave_error || thd->is_fatal_error) { /* Error reporting borrowed from Query_log_event with many excessive @@ -6810,7 +6816,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) (actual_error ? thd->net.last_error : "unexpected success or fatal error"), table_list->db, table_list->table_name); - thd->query_error= 1; + thd->is_slave_error= 1; } goto err; } diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 949179386ea..c6b691ec010 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -68,7 +68,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli { if (!need_reopen) { - if (thd->query_error || thd->is_fatal_error) + if (thd->is_slave_error || thd->is_fatal_error) { /* Error reporting borrowed from Query_log_event with many excessive @@ -112,7 +112,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli uint tables_count= rli->tables_to_lock_count; if ((error= open_tables(thd, &tables, &tables_count, 0))) { - if (thd->query_error || thd->is_fatal_error) + if (thd->is_slave_error || thd->is_fatal_error) { /* Error reporting borrowed from Query_log_event with many excessive @@ -123,7 +123,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli "Error '%s' on reopening tables", (actual_error ? thd->net.last_error : "unexpected success or fatal error")); - thd->query_error= 1; + thd->is_slave_error= 1; } const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(error); @@ -146,7 +146,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli { mysql_unlock_tables(thd, thd->lock); thd->lock= 0; - thd->query_error= 1; + thd->is_slave_error= 1; const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(Rows_log_event::ERR_BAD_TABLE_DEF); } @@ -255,7 +255,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli "Error in %s event: row application failed. %s", ev->get_type_str(), thd->net.last_error ? thd->net.last_error : ""); - thd->query_error= 1; + thd->is_slave_error= 1; break; } @@ -300,7 +300,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli */ thd->reset_current_stmt_binlog_row_based(); const_cast(rli)->cleanup_context(thd, error); - thd->query_error= 1; + thd->is_slave_error= 1; DBUG_RETURN(error); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a355c560996..cc964e417bf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2593,7 +2593,7 @@ int my_message_sql(uint error, const char *str, myf MyFlags) DBUG_RETURN(0); } - thd->query_error= 1; // needed to catch query errors during replication + thd->is_slave_error= 1; // needed to catch query errors during replication if (!thd->no_warnings_for_error) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); diff --git a/sql/protocol.cc b/sql/protocol.cc index 9d473912ba3..31d23ec94dd 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -84,7 +84,7 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) DBUG_VOID_RETURN; } - thd->query_error= 1; // needed to catch query errors during replication + thd->is_slave_error= 1; // needed to catch query errors during replication if (!err) { if (sql_errno) @@ -162,7 +162,7 @@ net_printf_error(THD *thd, uint errcode, ...) DBUG_VOID_RETURN; } - thd->query_error= 1; // needed to catch query errors during replication + thd->is_slave_error= 1; // needed to catch query errors during replication #ifndef EMBEDDED_LIBRARY query_cache_abort(net); // Safety #endif diff --git a/sql/slave.cc b/sql/slave.cc index fcbd4eb841b..494e13d8c9f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -980,7 +980,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, DBUG_RETURN(1); } thd->query= query; - thd->query_error = 0; + thd->is_slave_error = 0; thd->net.no_send_ok = 1; bzero((char*) &tables,sizeof(tables)); @@ -1009,7 +1009,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, thd->db_length= save_db_length; thd->options = save_options; - if (thd->query_error) + if (thd->is_slave_error) goto err; // mysql_parse took care of the error send thd->proc_info = "Opening master dump table"; @@ -2501,7 +2501,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, if (sys_init_slave.value_length) { execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave); - if (thd->query_error) + if (thd->is_slave_error) { sql_print_error("\ Slave SQL thread aborted. Can't execute init_slave query"); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 093544cdd0a..f7ab9bac3b1 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1108,7 +1108,7 @@ sp_head::execute(THD *thd) if ((ctx= thd->spcont)) ctx->clear_handler(); - thd->query_error= 0; + thd->is_slave_error= 0; old_arena= thd->stmt_arena; /* @@ -1275,8 +1275,8 @@ sp_head::execute(THD *thd) state= EXECUTED; done: - DBUG_PRINT("info", ("err_status: %d killed: %d query_error: %d report_error: %d", - err_status, thd->killed, thd->query_error, + DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d", + err_status, thd->killed, thd->is_slave_error, thd->net.report_error)); if (thd->killed) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ffbf0649961..8c02fdb8289 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -395,7 +395,7 @@ THD::THD() count_cuted_fields= CHECK_FIELD_IGNORE; killed= NOT_KILLED; col_access=0; - query_error= thread_specific_used= FALSE; + is_slave_error= thread_specific_used= FALSE; hash_clear(&handler_tables_hash); tmp_table=0; used_tables=0; diff --git a/sql/sql_class.h b/sql/sql_class.h index 97a63ed9448..5aec68e1c61 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1466,7 +1466,14 @@ public: /* for IS NULL => = last_insert_id() fix in remove_eq_conds() */ bool substitute_null_with_insert_id; bool in_lock_tables; - bool query_error, bootstrap, cleanup_done; + /** + True if a slave error. Causes the slave to stop. Not the same + as the statement execution error (net.report_error), since + a statement may be expected to return an error, e.g. because + it returned an error on master, and this is OK on the slave. + */ + bool is_slave_error; + bool bootstrap, cleanup_done; /** is set if some thread specific value(s) used in a statement. */ bool thread_specific_used; @@ -1695,7 +1702,7 @@ public: net.last_error[0]= 0; net.last_errno= 0; net.report_error= 0; - query_error= 0; + is_slave_error= 0; DBUG_VOID_RETURN; } inline bool vio_ok() const { return net.vio != 0; } diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 094bef9324e..afd97c27a55 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1030,7 +1030,7 @@ static void prepare_new_connection_state(THD* thd) if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL)) { execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); - if (thd->query_error) + if (thd->net.report_error) { thd->killed= THD::KILL_CONNECTION; sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), From 9a6f67314380ee56a1c7af02554de544bd796fc4 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Sat, 20 Oct 2007 21:48:15 +0400 Subject: [PATCH 004/128] Fix for BUG#31148: bool close_thread_table(THD*, TABLE**): Assertion `table->key_read == 0' failed. The problem was that key_read on a table in a sub-select was not properly reset. That happens because the code responsible for that is copy&pasted all around the server. In some place, it was obviously forgotten to be pasted. The fix is to reset key_read properly. --- mysql-test/r/key.result | 15 +++++++++++++++ mysql-test/t/key.test | 23 +++++++++++++++++++++++ sql/sql_select.cc | 9 ++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index a2bed75a709..6c115435fb6 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -530,3 +530,18 @@ ORDER BY c.b, c.d a b c d e f g h i j a b c d 2 2 1 2004-11-30 12:00:00 1 0 0 0 0 0 2 3388000 -553000 NULL DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT); +INSERT INTO t1 VALUES (), (), (); +SELECT 1 AS c1 +FROM t1 +ORDER BY ( +SELECT 1 AS c2 +FROM t1 +GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ASC +LIMIT 1); +c1 +1 +1 +1 +DROP TABLE t1; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index f1eb8e68b49..cd6c480407d 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -501,3 +501,26 @@ ORDER BY c.b, c.d ; DROP TABLE t1, t2; + +# +# Bug #31148: bool close_thread_table(THD*, TABLE**): Assertion +# `table->key_read == 0' failed. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT); + +INSERT INTO t1 VALUES (), (), (); + +SELECT 1 AS c1 +FROM t1 +ORDER BY ( + SELECT 1 AS c2 + FROM t1 + GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ASC + LIMIT 1); + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index eb2731205ec..d041b2edcfa 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6651,7 +6651,14 @@ void JOIN::cleanup(bool full) for (tab= join_tab, end= tab+tables; tab != end; tab++) { if (tab->table) - tab->table->file->ha_index_or_rnd_end(); + { + if (tab->table->key_read) + { + tab->table->key_read= 0; + tab->table->file->extra(HA_EXTRA_NO_KEYREAD); + } + tab->table->file->ha_index_or_rnd_end(); + } } } } From 01f62e0d06d42b15035451c148cc5744b17ca94e Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 22 Oct 2007 23:02:05 +0400 Subject: [PATCH 005/128] WL#4104: Deprecate the Instance Manager. A deprecation warning added. --- server-tools/instance-manager/mysqlmanager.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index 6d6ebbee57d..276d1ca3b49 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -79,6 +79,9 @@ int main(int argc, char *argv[]) { int return_value; + puts("\n" + "WARNING: This program is deprecated and will be removed in 6.0.\n"); + /* Initialize. */ MY_INIT(argv[0]); From 5adc332c632e1af62294820ed84e94409894c142 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Tue, 23 Oct 2007 16:16:59 +0500 Subject: [PATCH 006/128] Fixed bug #31663: if the FIELDS TERMINATED BY string in the SELECT INTO OUTFILE clause starts with a special character (one of n, t, r, b, 0, Z or N) and ENCLOSED BY is empty, every occurrence of this character within a field value is duplicated. Duplication has been avoided. New warning message has been added: "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY". --- mysql-test/r/outfile_loaddata.result | 85 ++++++++++++++++++++++++++ mysql-test/t/outfile_loaddata.test | 89 ++++++++++++++++++++++++++++ sql/share/errmsg.txt | 2 + sql/sql_class.cc | 44 +++++++++++--- sql/sql_class.h | 7 +++ 5 files changed, 218 insertions(+), 9 deletions(-) create mode 100644 mysql-test/r/outfile_loaddata.result create mode 100644 mysql-test/t/outfile_loaddata.test diff --git a/mysql-test/r/outfile_loaddata.result b/mysql-test/r/outfile_loaddata.result new file mode 100644 index 00000000000..1bcaf308b7c --- /dev/null +++ b/mysql-test/r/outfile_loaddata.result @@ -0,0 +1,85 @@ +DROP TABLE IF EXISTS t1, t2; +# +# Bug#31663 FIELDS TERMINATED BY special character +# +CREATE TABLE t1 (i1 int, i2 int, c1 VARCHAR(256), c2 VARCHAR(256)); +INSERT INTO t1 VALUES (101, 202, '-r-', '=raker='); +# FIELDS TERMINATED BY 'raker', warning: +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' FIELDS TERMINATED BY 'raker' FROM t1; +Warnings: +Warning 1475 First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY +SELECT LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt'); +LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt') +101raker202raker-r-raker=raker= + +CREATE TABLE t2 SELECT * FROM t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 FIELDS TERMINATED BY 'raker'; +Warnings: +Warning 1262 Row 1 was truncated; it contained more data than there were input columns +SELECT * FROM t2; +i1 i2 c1 c2 +101 202 -r- =raker= +101 202 -r- = +DROP TABLE t2; +# Only numeric fields, FIELDS TERMINATED BY 'r', no warnings: +SELECT i1, i2 INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' FIELDS TERMINATED BY 'r' FROM t1; +SELECT LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt'); +LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt') +101r202 + +CREATE TABLE t2 SELECT i1, i2 FROM t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 FIELDS TERMINATED BY 'r'; +SELECT i1, i2 FROM t2; +i1 i2 +101 202 +101 202 +DROP TABLE t2; +# FIELDS TERMINATED BY '0', warning: +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' FIELDS TERMINATED BY '0' FROM t1; +Warnings: +Warning 1475 First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY +SELECT LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt'); +LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt') +10102020-r-0=raker= + +CREATE TABLE t2 SELECT * FROM t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 FIELDS TERMINATED BY '0'; +Warnings: +Warning 1262 Row 1 was truncated; it contained more data than there were input columns +SELECT * FROM t2; +i1 i2 c1 c2 +101 202 -r- =raker= +1 1 2 2 +DROP TABLE t2; +# FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0', warning: +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0' FROM t1; +Warnings: +Warning 1475 First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY +SELECT LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt'); +LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt') +10102020"-r-"0"=raker=" + +CREATE TABLE t2 SELECT * FROM t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0'; +Warnings: +Warning 1262 Row 1 was truncated; it contained more data than there were input columns +SELECT * FROM t2; +i1 i2 c1 c2 +101 202 -r- =raker= +1 1 2 2 +DROP TABLE t2; +# Only string fields, FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0', no warnings: +SELECT c1, c2 INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0' FROM t1; +SELECT LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt'); +LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug31663.txt') +"-r-"0"=raker=" + +CREATE TABLE t2 SELECT c1, c2 FROM t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0'; +SELECT c1, c2 FROM t2; +c1 c2 +-r- =raker= +-r- =raker= +DROP TABLE t2; +DROP TABLE t1; +# End of 5.0 tests. diff --git a/mysql-test/t/outfile_loaddata.test b/mysql-test/t/outfile_loaddata.test new file mode 100644 index 00000000000..2f6ac998b3d --- /dev/null +++ b/mysql-test/t/outfile_loaddata.test @@ -0,0 +1,89 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +--echo # +--echo # Bug#31663 FIELDS TERMINATED BY special character +--echo # + +CREATE TABLE t1 (i1 int, i2 int, c1 VARCHAR(256), c2 VARCHAR(256)); +INSERT INTO t1 VALUES (101, 202, '-r-', '=raker='); + +--let $fields=* +--let $clauses=FIELDS TERMINATED BY 'raker' +--echo # $clauses, warning: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') +--eval CREATE TABLE t2 SELECT $fields FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses +--eval SELECT $fields FROM t2 +--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt +DROP TABLE t2; + +--let $fields=i1, i2 +--let $clauses=FIELDS TERMINATED BY 'r' +--echo # Only numeric fields, $clauses, no warnings: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') +--eval CREATE TABLE t2 SELECT $fields FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses +--eval SELECT $fields FROM t2 +--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt +DROP TABLE t2; + +--let $fields=* +--let $clauses=FIELDS TERMINATED BY '0' +--echo # $clauses, warning: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') +--eval CREATE TABLE t2 SELECT $fields FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses +--eval SELECT $fields FROM t2 +--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt +DROP TABLE t2; + +--let $fields=* +--let $clauses=FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0' +--echo # $clauses, warning: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') +--eval CREATE TABLE t2 SELECT $fields FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses +--eval SELECT $fields FROM t2 +--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt +DROP TABLE t2; + +--let $fields=c1, c2 +--let $clauses=FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0' +--echo # Only string fields, $clauses, no warnings: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') +--eval CREATE TABLE t2 SELECT $fields FROM t1 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses +--eval SELECT $fields FROM t2 +--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt +DROP TABLE t2; + +DROP TABLE t1; + +--echo # End of 5.0 tests. diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 709cd1fc0a9..9e6cf462113 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5639,3 +5639,5 @@ ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT eng "Too high level of nesting for select" ER_NAME_BECOMES_EMPTY eng "Name '%-.64s' has become ''" +ER_AMBIGUOUS_FIELD_TERM + eng "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b67f63778dc..1836989f2fa 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1194,6 +1194,7 @@ int select_export::prepare(List &list, SELECT_LEX_UNIT *u) { bool blob_flag=0; + bool string_results= FALSE, non_string_results= FALSE; unit= u; if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) strmake(path,exchange->file_name,FN_REFLEN-1); @@ -1211,13 +1212,18 @@ select_export::prepare(List &list, SELECT_LEX_UNIT *u) blob_flag=1; break; } + if (item->result_type() == STRING_RESULT) + string_results= TRUE; + else + non_string_results= TRUE; } } field_term_length=exchange->field_term->length(); + field_term_char= field_term_length ? (*exchange->field_term)[0] : INT_MAX; if (!exchange->line_term->length()) exchange->line_term=exchange->field_term; // Use this if it exists field_sep_char= (exchange->enclosed->length() ? (*exchange->enclosed)[0] : - field_term_length ? (*exchange->field_term)[0] : INT_MAX); + field_term_char); escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1); is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char)); is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char)); @@ -1229,12 +1235,25 @@ select_export::prepare(List &list, SELECT_LEX_UNIT *u) exchange->opt_enclosed=1; // A little quicker loop fixed_row_size= (!field_term_length && !exchange->enclosed->length() && !blob_flag); + if ((is_ambiguous_field_sep && exchange->enclosed->is_empty() && + (string_results || is_unsafe_field_sep)) || + (exchange->opt_enclosed && non_string_results && + field_term_length && strchr(NUMERIC_CHARS, field_term_char))) + { + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_AMBIGUOUS_FIELD_TERM, ER(ER_AMBIGUOUS_FIELD_TERM)); + is_ambiguous_field_term= TRUE; + } + else + is_ambiguous_field_term= FALSE; + return 0; } #define NEED_ESCAPING(x) ((int) (uchar) (x) == escape_char || \ - (int) (uchar) (x) == field_sep_char || \ + (enclosed ? (int) (uchar) (x) == field_sep_char \ + : (int) (uchar) (x) == field_term_char) || \ (int) (uchar) (x) == line_sep_char || \ !(x)) @@ -1263,8 +1282,10 @@ bool select_export::send_data(List &items) while ((item=li++)) { Item_result result_type=item->result_type(); + bool enclosed = (exchange->enclosed->length() && + (!exchange->opt_enclosed || result_type == STRING_RESULT)); res=item->str_result(&tmp); - if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) + if (res && enclosed) { if (my_b_write(&cache,(byte*) exchange->enclosed->ptr(), exchange->enclosed->length())) @@ -1355,11 +1376,16 @@ bool select_export::send_data(List &items) DBUG_ASSERT before the loop makes that sure. */ - if (NEED_ESCAPING(*pos) || - (check_second_byte && - my_mbcharlen(character_set_client, (uchar) *pos) == 2 && - pos + 1 < end && - NEED_ESCAPING(pos[1]))) + if ((NEED_ESCAPING(*pos) || + (check_second_byte && + my_mbcharlen(character_set_client, (uchar) *pos) == 2 && + pos + 1 < end && + NEED_ESCAPING(pos[1]))) && + /* + Don't escape field_term_char by doubling - doubling is only + valid for ENCLOSED BY characters: + */ + (enclosed || !is_ambiguous_field_term || *pos != field_term_char)) { char tmp_buff[2]; tmp_buff[0]= ((int) *pos == field_sep_char && @@ -1398,7 +1424,7 @@ bool select_export::send_data(List &items) goto err; } } - if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) + if (res && enclosed) { if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(), exchange->enclosed->length())) diff --git a/sql/sql_class.h b/sql/sql_class.h index e6d65f3133a..62b1008e59c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1992,12 +1992,19 @@ public: class select_export :public select_to_file { uint field_term_length; int field_sep_char,escape_char,line_sep_char; + int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT /* The is_ambiguous_field_sep field is true if a value of the field_sep_char field is one of the 'n', 't', 'r' etc characters (see the READ_INFO::unescape method and the ESCAPE_CHARS constant value). */ bool is_ambiguous_field_sep; + /* + The is_ambiguous_field_term is true if field_sep_char contains the first + char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can + contain this character. + */ + bool is_ambiguous_field_term; /* The is_unsafe_field_sep field is true if a value of the field_sep_char field is one of the '0'..'9', '+', '-', '.' and 'e' characters From dac55f09f0f1ed0e86ce04317fe8c52a1d4bb2bd Mon Sep 17 00:00:00 2001 From: "davi@moksha.local/moksha.com.br" <> Date: Tue, 23 Oct 2007 09:05:39 -0300 Subject: [PATCH 007/128] Bug#31669 Buffer overflow in mysql_change_user() The problem is that when copying the supplied username and database, no bounds checking is performed on the fixed-length buffer. A sufficiently large (> 512) user string can easily cause stack corruption. Since this API can be used from PHP and other programs, this is a serious problem. The solution is to increase the buffer size to the accepted size in similar functions and perform bounds checking when copying the username and database. --- libmysql/libmysql.c | 7 +-- tests/mysql_client_test.c | 94 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c7bdfc4c42c..5c015bd6b0f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -706,7 +706,8 @@ int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd) my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db) { - char buff[512],*end=buff; + char buff[USERNAME_LENGTH+SCRAMBLED_PASSWORD_CHAR_LENGTH+NAME_LEN+2]; + char *end= buff; int rc; DBUG_ENTER("mysql_change_user"); @@ -716,7 +717,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, passwd=""; /* Store user into the buffer */ - end=strmov(end,user)+1; + end= strmake(end, user, USERNAME_LENGTH) + 1; /* write scrambled password according to server capabilities */ if (passwd[0]) @@ -736,7 +737,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, else *end++= '\0'; /* empty password */ /* Add database if needed */ - end= strmov(end, db ? db : "") + 1; + end= strmake(end, db ? db : "", NAME_LEN) + 1; /* Write authentication package */ simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (end-buff),1); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 9962a108e45..59f0150aa7a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15857,6 +15857,99 @@ static void test_bug29306() DBUG_VOID_RETURN; } + +/** + Bug#31669 Buffer overflow in mysql_change_user() +*/ + +#define LARGE_BUFFER_SIZE 2048 + +static void test_bug31669() +{ + int rc; + static char buff[LARGE_BUFFER_SIZE+1]; +#ifndef EMBEDDED_LIBRARY + static char user[USERNAME_LENGTH+1]; + static char db[NAME_LEN+1]; + static char query[LARGE_BUFFER_SIZE*2]; +#endif + + DBUG_ENTER("test_bug31669"); + myheader("test_bug31669"); + + rc= mysql_change_user(mysql, NULL, NULL, NULL); + DIE_UNLESS(rc); + + rc= mysql_change_user(mysql, "", "", ""); + DIE_UNLESS(rc); + + memset(buff, 'a', sizeof(buff)); + + rc= mysql_change_user(mysql, buff, buff, buff); + DIE_UNLESS(rc); + + rc = mysql_change_user(mysql, opt_user, opt_password, current_db); + DIE_UNLESS(!rc); + +#ifndef EMBEDDED_LIBRARY + memset(db, 'a', sizeof(db)); + db[NAME_LEN]= 0; + strxmov(query, "CREATE DATABASE IF NOT EXISTS ", db, NullS); + rc= mysql_query(mysql, query); + myquery(rc); + + memset(user, 'b', sizeof(user)); + user[USERNAME_LENGTH]= 0; + memset(buff, 'c', sizeof(buff)); + buff[LARGE_BUFFER_SIZE]= 0; + strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'%' IDENTIFIED BY " + "'", buff, "' WITH GRANT OPTION", NullS); + rc= mysql_query(mysql, query); + myquery(rc); + + rc= mysql_query(mysql, "FLUSH PRIVILEGES"); + myquery(rc); + + rc= mysql_change_user(mysql, user, buff, db); + DIE_UNLESS(!rc); + + user[USERNAME_LENGTH-1]= 'a'; + rc= mysql_change_user(mysql, user, buff, db); + DIE_UNLESS(rc); + + user[USERNAME_LENGTH-1]= 'b'; + buff[LARGE_BUFFER_SIZE-1]= 'd'; + rc= mysql_change_user(mysql, user, buff, db); + DIE_UNLESS(rc); + + buff[LARGE_BUFFER_SIZE-1]= 'c'; + db[NAME_LEN-1]= 'e'; + rc= mysql_change_user(mysql, user, buff, db); + DIE_UNLESS(rc); + + db[NAME_LEN-1]= 'a'; + rc= mysql_change_user(mysql, user, buff, db); + DIE_UNLESS(!rc); + + rc= mysql_change_user(mysql, user + 1, buff + 1, db + 1); + DIE_UNLESS(rc); + + rc = mysql_change_user(mysql, opt_user, opt_password, current_db); + DIE_UNLESS(!rc); + + strxmov(query, "DROP DATABASE ", db, NullS); + rc= mysql_query(mysql, query); + myquery(rc); + + strxmov(query, "DELETE FROM mysql.user WHERE User='", user, "'", NullS); + rc= mysql_query(mysql, query); + myquery(rc); + DIE_UNLESS(mysql_affected_rows(mysql) == 1); +#endif + + DBUG_VOID_RETURN; +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -16149,6 +16242,7 @@ static struct my_tests_st my_tests[]= { { "test_bug27592", test_bug27592 }, { "test_bug29948", test_bug29948 }, { "test_bug29306", test_bug29306 }, + { "test_bug31669", test_bug31669 }, { 0, 0 } }; From b2264ff81040fa021671181d8098778964458033 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Tue, 23 Oct 2007 18:03:51 +0400 Subject: [PATCH 008/128] Patch for BUG#30736: Row Size Too Large Error Creating a Table and Inserting Data. The problem was that under some circumstances Field class was not properly initialized before calling create_length_to_internal_length() function, which led to assert failure. The fix is to do the proper initialization. The user-visible problem was that under some circumstances CREATE TABLE ... SELECT statement crashed the server or led to wrong error message (wrong results). --- mysql-test/r/select.result | 35 +++++++++++++++++++++++++++ mysql-test/t/select.test | 48 ++++++++++++++++++++++++++++++++++++++ sql/sql_table.cc | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index ed120a1bbb8..76022053702 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4096,4 +4096,39 @@ SELECT `x` FROM v3; x 1 DROP VIEW v1, v2, v3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 5c30a17e08e..6deb951c4e8 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3484,4 +3484,52 @@ DROP VIEW v1, v2, v3; --enable_ps_protocol +########################################################################### + +--echo +--echo # +--echo # Bug#30736: Row Size Too Large Error Creating a Table and +--echo # Inserting Data. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +--echo + +CREATE TABLE t1( + c1 DECIMAL(10, 2), + c2 FLOAT); + +--echo + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +--echo + +CREATE TABLE t2( + c3 DECIMAL(10, 2)) + SELECT + c1 * c2 AS c3 + FROM t1; + +--echo + +SELECT * FROM t1; + +--echo + +SELECT * FROM t2; + +--echo + +DROP TABLE t1; +DROP TABLE t2; + +--echo + +########################################################################### + --echo End of 5.0 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6cbe98fe862..b5628ab011b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -955,8 +955,8 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->length= dup_field->char_length; sql_field->pack_length= dup_field->pack_length; sql_field->key_length= dup_field->key_length; - sql_field->create_length_to_internal_length(); sql_field->decimals= dup_field->decimals; + sql_field->create_length_to_internal_length(); sql_field->unireg_check= dup_field->unireg_check; /* We're making one field from two, the result field will have From 28e5063d933b130990f1c028b891870de4088ade Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Tue, 23 Oct 2007 19:24:59 +0400 Subject: [PATCH 009/128] BUG#31450: Query causes error 1048 - Let Item::save_in_field() call set_field_to_null_with_conversions() for decimal type, like this is done for the other item result types. --- mysql-test/r/type_decimal.result | 11 +++++++++++ mysql-test/t/type_decimal.test | 19 +++++++++++++++++++ sql/item.cc | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 72f827f11ed..594da466644 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -805,3 +805,14 @@ SELECT 1 % .12345678912345678912345678912345678912345678912345678912345678912345 SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; MOD() 0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 +create table t1 ( +ua_id decimal(22,0) not null, +ua_invited_by_id decimal(22,0) default NULL, +primary key(ua_id) +); +insert into t1 values (123, NULL), (456, NULL); +this must not produce error 1048: +select * from t1 where ua_invited_by_id not in (select ua_id from t1); +ua_id ua_invited_by_id +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index c154b2685dd..38eb1ebb984 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -416,3 +416,22 @@ DROP TABLE t1; SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; + + +# +# BUG#31450 "Query causes error 1048" +# +create table t1 ( + ua_id decimal(22,0) not null, + ua_invited_by_id decimal(22,0) default NULL, + primary key(ua_id) +); +insert into t1 values (123, NULL), (456, NULL); + +--echo this must not produce error 1048: +select * from t1 where ua_invited_by_id not in (select ua_id from t1); + +drop table t1; + +--echo End of 5.0 tests + diff --git a/sql/item.cc b/sql/item.cc index 83cbf261b8a..739fe7967e2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4548,7 +4548,7 @@ int Item::save_in_field(Field *field, bool no_conversions) my_decimal decimal_value; my_decimal *value= val_decimal(&decimal_value); if (null_value) - return set_field_to_null(field); + return set_field_to_null_with_conversions(field, no_conversions); field->set_notnull(); error=field->store_decimal(value); } From 7ca65155ad07834d136190a4d55a512e86df1fd5 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Tue, 23 Oct 2007 21:32:30 +0400 Subject: [PATCH 010/128] Post-merge fixes --- mysql-test/r/type_decimal.result | 1 + mysql-test/t/type_decimal.test | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 8dd4f6aaaf4..b550536d0db 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -811,6 +811,7 @@ insert into t1 values (-0.123456,0.123456); select group_concat(f1),group_concat(f2) from t1; group_concat(f1) group_concat(f2) -0.123456 0.123456 +drop table t1; create table t1 ( ua_id decimal(22,0) not null, ua_invited_by_id decimal(22,0) default NULL, diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 4d61350a613..12d4398dd57 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -425,5 +425,20 @@ insert into t1 values (-0.123456,0.123456); select group_concat(f1),group_concat(f2) from t1; drop table t1; +# +# BUG#31450 "Query causes error 1048" +# +create table t1 ( + ua_id decimal(22,0) not null, + ua_invited_by_id decimal(22,0) default NULL, + primary key(ua_id) +); +insert into t1 values (123, NULL), (456, NULL); + +--echo this must not produce error 1048: +select * from t1 where ua_invited_by_id not in (select ua_id from t1); + +drop table t1; + --echo End of 5.0 tests From f733ea5a06862d32725a2153a01d137eed54ee77 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Tue, 23 Oct 2007 22:04:09 +0200 Subject: [PATCH 011/128] Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. Accessing partitioned table with an apostrophe in partition options like DATA DIRECTORY, INDEX DIRECTORY or COMMENT causes server crash. Partition options were saved in .frm file without escaping. When accessing such table it is not possible to properly restore partition information. Crashed because there was no check for partition info parser failure. Fixed by escaping quoted text in the partition info when writing it to the frm-file and added a check that it was able to parse the partition info before using it NOTE: If the comment is written by an earlier version of the server, the corrupted frm-file is not fixed, but left corrupted, you have to manually drop the table and recreate it. --- mysql-test/r/partition.result | 16 ++++++++++++++++ mysql-test/t/partition.test | 26 ++++++++++++++++++++++++++ sql/sql_partition.cc | 21 +++++++++++++++++---- sql/table.cc | 3 ++- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 5d985d053fc..2057b18de3d 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,20 @@ drop table if exists t1; +CREATE TABLE t1 ( +d DATE NOT NULL +) +PARTITION BY RANGE( YEAR(d) ) ( +PARTITION p0 VALUES LESS THAN (1960), +PARTITION p1 VALUES LESS THAN (1970), +PARTITION p2 VALUES LESS THAN (1980), +PARTITION p3 VALUES LESS THAN (1990) +); +ALTER TABLE t1 ADD PARTITION ( +PARTITION `p5` VALUES LESS THAN (2010) +COMMENT 'APSTART \' APEND' +); +SELECT * FROM t1 LIMIT 1; +d +DROP TABLE t1; create table t1 (a int) partition by key(a) partitions 0.2+e1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 42db23dadef..53454b132e9 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,32 @@ drop table if exists t1; --enable_warnings +# +# Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. +# +# To verify the fix for crashing (on unix-type OS) +# uncomment the exec and error rows! + +CREATE TABLE t1 ( + d DATE NOT NULL +) +PARTITION BY RANGE( YEAR(d) ) ( + PARTITION p0 VALUES LESS THAN (1960), + PARTITION p1 VALUES LESS THAN (1970), + PARTITION p2 VALUES LESS THAN (1980), + PARTITION p3 VALUES LESS THAN (1990) +); + +ALTER TABLE t1 ADD PARTITION ( +PARTITION `p5` VALUES LESS THAN (2010) +COMMENT 'APSTART \' APEND' +); +#--exec sed 's/APSTART \\/APSTART /' var/master-data/test/t1.frm > tmpt1.frm && mv tmpt1.frm var/master-data/test/t1.frm +#--error 1064 +SELECT * FROM t1 LIMIT 1; + +DROP TABLE t1; + # # Bug 15890: Strange number of partitions accepted # diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 8a8a03cb4e4..3ad2cbfb284 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1849,6 +1849,20 @@ static int add_uint(File fptr, ulonglong number) return add_string(fptr, buff); } +/* + Must escape strings in partitioned tables frm-files, + parsing it later with mysql_unpack_partition will fail otherwise. +*/ +static int add_quoted_string(File fptr, const char *quotestr) +{ + String orgstr(quotestr, system_charset_info); + String escapedstr; + int err= add_string(fptr, "'"); + err+= append_escaped(&escapedstr, &orgstr); + err+= add_string(fptr, escapedstr.c_ptr()); + return err + add_string(fptr, "'"); +} + static int add_keyword_string(File fptr, const char *keyword, bool should_use_quotes, const char *keystr) @@ -1859,10 +1873,9 @@ static int add_keyword_string(File fptr, const char *keyword, err+= add_equal(fptr); err+= add_space(fptr); if (should_use_quotes) - err+= add_string(fptr, "'"); - err+= add_string(fptr, keystr); - if (should_use_quotes) - err+= add_string(fptr, "'"); + err+= add_quoted_string(fptr, keystr); + else + err+= add_string(fptr, keystr); return err + add_space(fptr); } diff --git a/sql/table.cc b/sql/table.cc index ccddbf8134b..7cf5eeaaad6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1782,7 +1782,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, outparam, is_create_table, share->default_part_db_type, &work_part_info_used); - outparam->part_info->is_auto_partitioned= share->auto_partitioned; + if (!tmp) + outparam->part_info->is_auto_partitioned= share->auto_partitioned; DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned)); /* we should perform the fix_partition_func in either local or caller's arena depending on work_part_info_used value From 54cea40003b09f8c339b89d186a65f78e641f941 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Wed, 24 Oct 2007 11:15:08 +0300 Subject: [PATCH 012/128] Bug #30715: Assertion failed: item_field->field->real_maybe_null(), file .\opt_sum.cc, line The optimizer pre-calculates the MIN/MAX values for queries like SELECT MIN(kp_k) WHERE kp_1 = const AND ... AND kp_k-1 = const when there is a key over kp_1...kp_k In doing so it was not checking correctly nullability and there was a superfluous assert(). Fixed by making sure that the field can be null before checking and taking out the wrong assert(). . Introduced a correct check for nullability The MIN(field) can return NULL when all the row values in the group are NULL-able or if there were no rows. Fixed the assertion to reflect the case when there are no rows. --- mysql-test/r/func_group.result | 5 +++++ mysql-test/t/func_group.test | 9 +++++++++ sql/opt_sum.cc | 10 +++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 3a2cb26910a..e7f27ebb07e 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1387,4 +1387,9 @@ SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); 1 1 DROP TABLE t1; +CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b)); +SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; +MIN(b) +NULL +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 8c020eb3dc8..7e115707625 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -873,5 +873,14 @@ SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); DROP TABLE t1; +# +# Bug #30715: Assertion failed: item_field->field->real_maybe_null(), file +# .\opt_sum.cc, line +# + +CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b)); +SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; +DROP TABLE t1; + ### --echo End of 5.0 tests diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index b9de54dbf5c..3fc62d05ae5 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -249,20 +249,20 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) Check if case 1 from above holds. If it does, we should read the skipped tuple. */ - if (ref.key_buff[prefix_len] == 1 && - /* + if (item_field->field->real_maybe_null() && + ref.key_buff[prefix_len] == 1 && + /* Last keypart (i.e. the argument to MIN) is set to NULL by find_key_for_maxmin only if all other keyparts are bound to constants in a conjunction of equalities. Hence, we can detect this by checking only if the last keypart is NULL. - */ + */ (error == HA_ERR_KEY_NOT_FOUND || key_cmp_if_same(table, ref.key_buff, ref.key, prefix_len))) { - DBUG_ASSERT(item_field->field->real_maybe_null()); error= table->file->index_read(table->record[0], ref.key_buff, - ref.key_length, + ref.key_length, HA_READ_KEY_EXACT); } } From 5d1ccce58ac10b2abff245734cd8e3f5ed2e9f67 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Wed, 24 Oct 2007 16:09:30 +0500 Subject: [PATCH 013/128] BUG#31159 - fulltext search on ucs2 column crashes server ucs2 doesn't provide required by fulltext ctype array. Crash happens because fulltext attempts to use unitialized ctype array. Fixed by converting ucs2 fields to compatible utf8 analogue. --- include/my_sys.h | 2 ++ mysql-test/r/ctype_ucs.result | 6 ++++++ mysql-test/t/ctype_ucs.test | 8 +++++++ mysys/charset.c | 40 +++++++++++++++++++++++++++++++++++ sql/item_func.cc | 33 ++++++++++++++++++++++++++++- 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/include/my_sys.h b/include/my_sys.h index 759531fa649..4a0586b9f2d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -784,6 +784,8 @@ extern CHARSET_INFO *get_charset(uint cs_number, myf flags); extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, uint cs_flags, myf my_flags); +extern CHARSET_INFO *get_compatible_charset_with_ctype(CHARSET_INFO + *original_cs); extern void free_charsets(void); extern char *get_charsets_dir(char *buf); extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index bf827209795..fef13b19ae8 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -803,4 +803,10 @@ quote(name) ???????? ???????????????? drop table bug20536; +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci); +INSERT INTO t1 VALUES('abcd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE); +a +abcd +DROP TABLE t1; End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 10559d33eb3..57f741597e0 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -535,4 +535,12 @@ select quote(name) from bug20536; drop table bug20536; +# +# BUG#31159 - fulltext search on ucs2 column crashes server +# +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci); +INSERT INTO t1 VALUES('abcd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE); +DROP TABLE t1; + --echo End of 4.1 tests diff --git a/mysys/charset.c b/mysys/charset.c index 6f2d4d3c347..f0ac61ceed5 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -673,3 +673,43 @@ CHARSET_INFO *fs_character_set() return fs_cset_cache; } #endif + + +/** + @brief Find compatible character set with ctype. + + @param[in] original_cs Original character set + + @note + 128 my_charset_ucs2_general_uca ->192 my_charset_utf8_general_uca_ci + 129 my_charset_ucs2_icelandic_uca_ci ->193 my_charset_utf8_icelandic_uca_ci + 130 my_charset_ucs2_latvian_uca_ci ->194 my_charset_utf8_latvian_uca_ci + 131 my_charset_ucs2_romanian_uca_ci ->195 my_charset_utf8_romanian_uca_ci + 132 my_charset_ucs2_slovenian_uca_ci ->196 my_charset_utf8_slovenian_uca_ci + 133 my_charset_ucs2_polish_uca_ci ->197 my_charset_utf8_polish_uca_ci + 134 my_charset_ucs2_estonian_uca_ci ->198 my_charset_utf8_estonian_uca_ci + 135 my_charset_ucs2_spanish_uca_ci ->199 my_charset_utf8_spanish_uca_ci + 136 my_charset_ucs2_swedish_uca_ci ->200 my_charset_utf8_swedish_uca_ci + 137 my_charset_ucs2_turkish_uca_ci ->201 my_charset_utf8_turkish_uca_ci + 138 my_charset_ucs2_czech_uca_ci ->202 my_charset_utf8_czech_uca_ci + 139 my_charset_ucs2_danish_uca_ci ->203 my_charset_utf8_danish_uca_ci + 140 my_charset_ucs2_lithuanian_uca_ci->204 my_charset_utf8_lithuanian_uca_ci + 141 my_charset_ucs2_slovak_uca_ci ->205 my_charset_utf8_slovak_uca_ci + 142 my_charset_ucs2_spanish2_uca_ci ->206 my_charset_utf8_spanish2_uca_ci + 143 my_charset_ucs2_roman_uca_ci ->207 my_charset_utf8_roman_uca_ci + 144 my_charset_ucs2_persian_uca_ci ->208 my_charset_utf8_persian_uca_ci + + @return Compatible character set or NULL. +*/ + +CHARSET_INFO *get_compatible_charset_with_ctype(CHARSET_INFO *original_cs) +{ + CHARSET_INFO *compatible_cs= 0; + DBUG_ENTER("get_compatible_charset_with_ctype"); + if (!strcmp(original_cs->csname, "ucs2") && + (compatible_cs= get_charset(original_cs->number + 64, MYF(0))) && + (!compatible_cs->ctype || + strcmp(original_cs->name + 4, compatible_cs->name + 4))) + compatible_cs= 0; + DBUG_RETURN(compatible_cs); +} diff --git a/sql/item_func.cc b/sql/item_func.cc index f71297515d6..6bfb920d7c8 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3135,13 +3135,44 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); return 1; } - table=((Item_field *)item)->field->table; + /* + With prepared statements Item_func_match::fix_fields is called twice. + When it is called first time we have original item tree here and add + conversion layer for character sets that do not have ctype array a few + lines below. When it is called second time, we already have conversion + layer in item tree. + */ + table= (item->type() == Item::FIELD_ITEM) ? + ((Item_field *)item)->field->table : + ((Item_field *)((Item_func_conv *)item)->key_item())->field->table; if (!(table->file->table_flags() & HA_CAN_FULLTEXT)) { my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0)); return 1; } table->fulltext_searched=1; + /* A workaround for ucs2 character set */ + if (!args[1]->collation.collation->ctype) + { + CHARSET_INFO *compatible_cs= + get_compatible_charset_with_ctype(args[1]->collation.collation); + bool rc= 1; + if (compatible_cs) + { + Item_string *conv_item= new Item_string("", 0, compatible_cs, + DERIVATION_EXPLICIT); + item= args[0]; + args[0]= conv_item; + rc= agg_item_charsets(cmp_collation, func_name(), args, arg_count, + MY_COLL_ALLOW_SUPERSET_CONV | + MY_COLL_ALLOW_COERCIBLE_CONV | + MY_COLL_DISALLOW_NONE); + args[0]= item; + } + else + my_error(ER_WRONG_ARGUMENTS, MYF(0), "MATCH"); + return rc; + } return agg_arg_collations_for_comparison(cmp_collation, args+1, arg_count-1); } From 2bc41b7e1e07b5c28e498175518c72afa8f43b25 Mon Sep 17 00:00:00 2001 From: "malff@lambda.hsd1.co.comcast.net." <> Date: Wed, 24 Oct 2007 19:01:08 -0600 Subject: [PATCH 014/128] Bug#30854 (Tables name show as binary in slave err msg on vm-win2003-64-b) The root cause of this defect is that a call to my_error() is using a 'LEX_STRING' parameter instead of a 'char*' This patch fixes the failing calls to my_error(), as well as similar calls found during investigation. This is a compiling bug (see the instrumentation in the bug report), no test cases provided. --- sql/sql_base.cc | 2 +- sql/sql_table.cc | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c4e90165ced..6307564c14f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7393,7 +7393,7 @@ open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias, else { /* only VIEWs are supported now */ - my_error(ER_FRM_UNKNOWN_TYPE, MYF(0), share->path, parser->type()->str); + my_error(ER_FRM_UNKNOWN_TYPE, MYF(0), share->path.str, parser->type()->str); goto err; } DBUG_RETURN(0); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 462b944e635..64d739aae7e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5200,7 +5200,8 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, if (error == HA_ERR_WRONG_COMMAND) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->s->table_name); + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), + table->s->table_name.str); error= 0; } else if (error) table->file->print_error(error, MYF(0)); @@ -5392,7 +5393,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, { if (def->change && ! def->field) { - my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->s->table_name); + my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->s->table_name.str); goto err; } /* @@ -5427,7 +5428,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (!find) { - my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after, table->s->table_name); + my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after, table->s->table_name.str); goto err; } find_it.after(def); // Put element after this @@ -5437,7 +5438,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (alter_info->alter_list.elements) { my_error(ER_BAD_FIELD_ERROR, MYF(0), - alter_info->alter_list.head()->name, table->s->table_name); + alter_info->alter_list.head()->name, table->s->table_name.str); goto err; } if (!new_create_list.elements) From e36846deca5f07003a17fd12ba98284d19eb52d8 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Thu, 25 Oct 2007 10:32:52 +0500 Subject: [PATCH 015/128] Fixed bug #27695: View should not be allowed to have empty or all space column names. The parser has been modified to check VIEW column names with the check_column_name function and to report an error on empty and all space column names (same as for TABLE column names). --- mysql-test/r/select.result | 26 ++++++++++++-------------- mysql-test/t/select.test | 33 ++++++++++++++++++++------------- sql/sql_yacc.yy | 6 ++++++ 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index ed120a1bbb8..52f2e84bf4e 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4077,23 +4077,21 @@ x 1 Warnings: Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' CREATE VIEW v1 AS SELECT 1 AS ` `; -Warnings: -Warning 1474 Name ' ' has become '' -SELECT `` FROM v1; - -1 -CREATE VIEW v2 AS SELECT 1 AS ` `; -Warnings: -Warning 1474 Name ' ' has become '' -SELECT `` FROM v2; - -1 -CREATE VIEW v3 AS SELECT 1 AS ` x`; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; Warnings: Warning 1466 Leading spaces are removed from name ' x' -SELECT `x` FROM v3; +SELECT `x` FROM v1; x 1 -DROP VIEW v1, v2, v3; +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 5c30a17e08e..a6ed3c854b4 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3466,22 +3466,29 @@ DROP TABLE t1; # --disable_ps_protocol - SELECT 1 AS ` `; SELECT 1 AS ` `; SELECT 1 AS ` x`; - -CREATE VIEW v1 AS SELECT 1 AS ` `; -SELECT `` FROM v1; - -CREATE VIEW v2 AS SELECT 1 AS ` `; -SELECT `` FROM v2; - -CREATE VIEW v3 AS SELECT 1 AS ` x`; -SELECT `x` FROM v3; - -DROP VIEW v1, v2, v3; - --enable_ps_protocol +--error 1166 +CREATE VIEW v1 AS SELECT 1 AS ``; + +--error 1166 +CREATE VIEW v1 AS SELECT 1 AS ` `; + +--error 1166 +CREATE VIEW v1 AS SELECT 1 AS ` `; + +--error 1166 +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); + +CREATE VIEW v1 AS SELECT 1 AS ` x`; +SELECT `x` FROM v1; + +--error 1166 +ALTER VIEW v1 AS SELECT 1 AS ` `; + +DROP VIEW v1; + --echo End of 5.0 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 368ce5673e2..3401bf739b3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4305,6 +4305,12 @@ select_item: MYSQL_YYABORT; if ($4.str) { + if (Lex->sql_command == SQLCOM_CREATE_VIEW && + check_column_name($4.str)) + { + my_error(ER_WRONG_COLUMN_NAME, MYF(0), $4.str); + MYSQL_YYABORT; + } $2->is_autogenerated_name= FALSE; $2->set_name($4.str, $4.length, system_charset_info); } From 99f4b74311c8e08446fb2db77e5ccc43d6d9af1d Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Thu, 25 Oct 2007 14:02:27 +0400 Subject: [PATCH 016/128] Fix for bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it This is a 5.0 version of the patch, it will be null-merged to 5.1 Problem: 'log' and 'log_slow_queries' were "fixed" variables, i.e. they showed up in SHOW VARIABLES, but could not be used in expressions like "select @@log". Also, using them in the SET statement produced an incorrect "unknown system variable" error. Solution: Make 'log' and 'log_slow_queries' read-only dynamic variables to make them available for use in expressions, and produce a correct error about the variable being read-only when used in the SET statement. --- mysql-test/r/variables.result | 16 ++++++++++++++++ mysql-test/t/variables.test | 14 ++++++++++++++ sql/mysql_priv.h | 4 ++-- sql/mysqld.cc | 4 ++-- sql/set_var.cc | 8 ++++++-- sql/set_var.h | 22 ++++++++++++++++++++++ 6 files changed, 62 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 3d76f8e4a90..217be9400e6 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -791,6 +791,22 @@ ERROR HY000: Variable 'hostname' is a read only variable show variables like 'hostname'; Variable_name Value hostname # +SHOW VARIABLES LIKE 'log'; +Variable_name Value +log ON +SELECT @@log; +@@log +1 +SET GLOBAL log=0; +ERROR HY000: Variable 'log' is a read only variable +SHOW VARIABLES LIKE 'log_slow_queries'; +Variable_name Value +log_slow_queries ON +SELECT @@log_slow_queries; +@@log_slow_queries +1 +SET GLOBAL log_slow_queries=0; +ERROR HY000: Variable 'log_slow_queries' is a read only variable End of 5.0 tests set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 0ad85a32568..13f897e7596 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -674,6 +674,20 @@ set @@hostname= "anothername"; --replace_column 2 # show variables like 'hostname'; +# +# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it +# + +SHOW VARIABLES LIKE 'log'; +SELECT @@log; +--error 1238 +SET GLOBAL log=0; + +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@log_slow_queries; +--error 1238 +SET GLOBAL log_slow_queries=0; + --echo End of 5.0 tests # This is at the very after the versioned tests, since it involves doing diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5bec94857f7..8364456a9ee 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1306,8 +1306,8 @@ extern bool opt_endinfo, using_udf_functions; extern my_bool locked_in_memory; extern bool opt_using_transactions, mysqld_embedded; extern bool using_update_log, opt_large_files, server_id_supplied; -extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log; -extern my_bool opt_log_queries_not_using_indexes; +extern bool opt_update_log, opt_bin_log, opt_error_log; +extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes; extern bool opt_disable_networking, opt_skip_show_db; extern my_bool opt_character_set_client_handshake; extern bool volatile abort_loop, shutdown_in_progress, grant_option; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08c2b60fa79..63cdf2b3640 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -339,8 +339,8 @@ static my_bool opt_sync_bdb_logs; /* Global variables */ -bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; -my_bool opt_log_queries_not_using_indexes= 0; +bool opt_update_log, opt_bin_log; +my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes= 0; bool opt_error_log= IF_WIN(1,0); bool opt_disable_networking=0, opt_skip_show_db=0; my_bool opt_character_set_client_handshake= 1; diff --git a/sql/set_var.cc b/sql/set_var.cc index fbfe174434d..80106b900fc 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -201,6 +201,7 @@ sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold", param_age_threshold)); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); +sys_var_bool_const_ptr sys_log("log", &opt_log); sys_var_trust_routine_creators sys_trust_routine_creators("log_bin_trust_routine_creators", &trust_function_creators); @@ -213,6 +214,7 @@ sys_var_bool_ptr sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings); sys_var_thd_ulong sys_long_query_time("long_query_time", &SV::long_query_time); +sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log); sys_var_thd_bool sys_low_priority_updates("low_priority_updates", &SV::low_priority_updates, fix_low_priority_updates); @@ -665,9 +667,11 @@ sys_var *sys_variables[]= &sys_lc_time_names, &sys_license, &sys_local_infile, + &sys_log, &sys_log_binlog, &sys_log_off, &sys_log_queries_not_using_indexes, + &sys_log_slow, &sys_log_update, &sys_log_warnings, &sys_long_query_time, @@ -946,7 +950,7 @@ struct show_var_st init_vars[]= { #ifdef HAVE_MLOCKALL {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL}, #endif - {"log", (char*) &opt_log, SHOW_BOOL}, + {sys_log.name, (char*) &sys_log, SHOW_SYS}, {"log_bin", (char*) &opt_bin_log, SHOW_BOOL}, {sys_trust_function_creators.name,(char*) &sys_trust_function_creators, SHOW_SYS}, {"log_error", (char*) log_error_file, SHOW_CHAR}, @@ -955,7 +959,7 @@ struct show_var_st init_vars[]= { #ifdef HAVE_REPLICATION {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL}, #endif - {"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL}, + {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS}, {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS}, {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS}, {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS}, diff --git a/sql/set_var.h b/sql/set_var.h index 6000e155db9..7b3f864f44c 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -160,6 +160,28 @@ public: }; +class sys_var_bool_const_ptr : public sys_var +{ +public: + my_bool *value; + sys_var_bool_const_ptr(const char *name_arg, my_bool *value_arg) + :sys_var(name_arg),value(value_arg) + {} + bool check(THD *thd, set_var *var) + { + return 1; + } + bool update(THD *thd, set_var *var) + { + return 1; + } + SHOW_TYPE show_type() { return SHOW_MY_BOOL; } + byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { return (byte*) value; } + bool check_update_type(Item_result type) { return 0; } + bool is_readonly() const { return 1; } +}; + class sys_var_str :public sys_var { public: From 1f268043f6c99d1ca10e9e513c2673b4f03b85f4 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Thu, 25 Oct 2007 14:03:24 +0400 Subject: [PATCH 017/128] Fix for bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it This is a 5.1 version of the patch. Problem: 'log' and 'log_slow_queries' were "fixed" variables, i.e. they showed up in SHOW VARIABLES, but could not be used in expressions like "select @@log". Also, using them in the SET statement produced an incorrect "unknown system variable" error. Solution: Since as of MySQL 5.1.12 one can enable or disable the general query log or the slow query log at runtime by changing values of general_log/slow_query_log, make 'log' and 'log_slow_queries" to be synonyms for 'general_log' and 'slow_query_log' respectively. This makes expressions using the '@@var' syntax backward compatible with 5.0 and SHOW VARIABLES output to be consistent with the SET statement. --- mysql-test/r/log_state.result | 63 +++++++++++++++++++++++++++++++++++ mysql-test/t/log_state.test | 36 ++++++++++++++++++++ sql/set_var.cc | 8 +++-- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index 3a3ef584ce3..b0ec0d25935 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -175,3 +175,66 @@ SET GLOBAL slow_query_log = ON; SET GLOBAL READ_ONLY = OFF; SET GLOBAL general_log = @old_general_log_state; SET GLOBAL slow_query_log = @old_slow_log_state; +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; +SHOW VARIABLES LIKE 'general_log'; +Variable_name Value +general_log ON +SHOW VARIABLES LIKE 'log'; +Variable_name Value +log ON +SELECT @@general_log, @@log; +@@general_log @@log +1 1 +SET GLOBAL log = 0; +SHOW VARIABLES LIKE 'general_log'; +Variable_name Value +general_log OFF +SHOW VARIABLES LIKE 'log'; +Variable_name Value +log OFF +SELECT @@general_log, @@log; +@@general_log @@log +0 0 +SET GLOBAL general_log = 1; +SHOW VARIABLES LIKE 'general_log'; +Variable_name Value +general_log ON +SHOW VARIABLES LIKE 'log'; +Variable_name Value +log ON +SELECT @@general_log, @@log; +@@general_log @@log +1 1 +SHOW VARIABLES LIKE 'slow_query_log'; +Variable_name Value +slow_query_log OFF +SHOW VARIABLES LIKE 'log_slow_queries'; +Variable_name Value +log_slow_queries OFF +SELECT @@slow_query_log, @@log_slow_queries; +@@slow_query_log @@log_slow_queries +0 0 +SET GLOBAL log_slow_queries = 0; +SHOW VARIABLES LIKE 'slow_query_log'; +Variable_name Value +slow_query_log OFF +SHOW VARIABLES LIKE 'log_slow_queries'; +Variable_name Value +log_slow_queries OFF +SELECT @@slow_query_log, @@log_slow_queries; +@@slow_query_log @@log_slow_queries +0 0 +SET GLOBAL slow_query_log = 1; +SHOW VARIABLES LIKE 'slow_query_log'; +Variable_name Value +slow_query_log ON +SHOW VARIABLES LIKE 'log_slow_queries'; +Variable_name Value +log_slow_queries ON +SELECT @@slow_query_log, @@log_slow_queries; +@@slow_query_log @@log_slow_queries +1 1 +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; +End of 5.1 tests diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index c67da261ef1..f7795e49b37 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -179,6 +179,42 @@ SET GLOBAL READ_ONLY = OFF; SET GLOBAL general_log = @old_general_log_state; SET GLOBAL slow_query_log = @old_slow_log_state; +# +# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it +# + +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; + +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; +SET GLOBAL log = 0; +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; +SET GLOBAL general_log = 1; +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; + +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; +SET GLOBAL log_slow_queries = 0; +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; +SET GLOBAL slow_query_log = 1; +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; + +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; + +--echo End of 5.1 tests + --enable_ps_protocol # diff --git a/sql/set_var.cc b/sql/set_var.cc index 697de9cda97..f8e1e86e9f7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -641,8 +641,14 @@ static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE)); /* Global variables which enable|disable logging */ static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log, QUERY_LOG_GENERAL); +/* Synonym of "general_log" for consistency with SHOW VARIABLES output */ +static sys_var_log_state sys_var_log(&vars, "log", &opt_log, + QUERY_LOG_GENERAL); static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log, QUERY_LOG_SLOW); +/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */ +static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries", + &opt_slow_log, QUERY_LOG_SLOW); sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path, sys_update_general_log_path, sys_default_general_log_path, @@ -678,10 +684,8 @@ static SHOW_VAR fixed_vars[]= { #ifdef HAVE_MLOCKALL {"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL}, #endif - {"log", (char*) &opt_log, SHOW_MY_BOOL}, {"log_bin", (char*) &opt_bin_log, SHOW_BOOL}, {"log_error", (char*) log_error_file, SHOW_CHAR}, - {"log_slow_queries", (char*) &opt_slow_log, SHOW_MY_BOOL}, {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL}, {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT}, {"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR}, From f9fc31f9675c518a265be9009226bbab6701700c Mon Sep 17 00:00:00 2001 From: "antony@pcg5ppc.xiphis.org" <> Date: Thu, 25 Oct 2007 17:23:12 -0700 Subject: [PATCH 018/128] protect bug31473 from regressing into 5.0 --- mysql-test/r/csv.result | 42 +++++++++++++++++++++++++++++++++++++++++ mysql-test/t/csv.test | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 3900597d2a6..dca4e349c8a 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5029,4 +5029,46 @@ F7 FE þ LATIN SMALL LETTER THORN FF ÿ LATIN SMALL LETTER Y WITH DIAERESIS drop table t1; +create table t1(a datetime) engine=csv; +insert into t1 values(); +select * from t1; +a +0000-00-00 00:00:00 +drop table t1; +create table t1(a set('foo','bar')) engine=csv; +insert into t1 values(); +select * from t1; +a + +drop table t1; +create table t1(a varchar(32)) engine=csv; +insert into t1 values(); +select * from t1; +a + +drop table t1; +create table t1(a int) engine=csv; +insert into t1 values(); +select * from t1; +a +0 +drop table t1; +create table t1(a blob) engine=csv; +insert into t1 values(); +select * from t1; +a + +drop table t1; +create table t1(a bit(1)) engine=csv; +insert into t1 values(); +select BIN(a) from t1; +BIN(a) +0 +drop table t1; +create table t1(a enum('foo','bar') default 'foo') engine=csv; +insert into t1 values(); +select * from t1; +a +foo +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index b724b4ce47c..db5cb92c3e6 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1427,4 +1427,37 @@ insert into t1 values (0xFF,'LATIN SMALL LETTER Y WITH DIAERESIS'); select hex(c), c, name from t1 order by 1; drop table t1; +# +# Bug #31473: does not work with NULL value in datetime field +# This bug is a 5.1 but is here to prevent 5.0 regression. +# +create table t1(a datetime) engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1(a set('foo','bar')) engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1(a varchar(32)) engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1(a int) engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1(a blob) engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1(a bit(1)) engine=csv; +insert into t1 values(); +select BIN(a) from t1; +drop table t1; +create table t1(a enum('foo','bar') default 'foo') engine=csv; +insert into t1 values(); +select * from t1; +drop table t1; + --echo End of 5.0 tests From ada0b493285392baa63650294be59cbcf9748f00 Mon Sep 17 00:00:00 2001 From: "antony@pcg5ppc.xiphis.org" <> Date: Thu, 25 Oct 2007 21:19:28 -0700 Subject: [PATCH 019/128] Bug#30296 "Dynamic plugins fail to load on FreeBSD" ELF executables need to be linked using the -export-dynamic option to ld(1) for symbols defined in the executable to become visible to dlsym(). Also, do not build plugins on an all-static build. --- config/ac-macros/plugins.m4 | 11 +++++++++++ configure.in | 13 ++++++++++++- sql/sql_yacc.yy | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4 index 48754563992..8dfb698709f 100644 --- a/config/ac-macros/plugins.m4 +++ b/config/ac-macros/plugins.m4 @@ -360,6 +360,17 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[ AC_MSG_ERROR([cannot disable mandatory plugin]) fi [mysql_plugin_]$2=yes + ],[ + case "$with_mysqld_ldflags " in + *"-all-static "*) + # No need to build shared plugins when mysqld is linked with + # -all-static as it won't be able to load them. + if test "X[$mysql_plugin_]$2" != Xyes -a \ + "X[$with_plugin_]$2" != Xyes; then + [with_plugin_]$2=no + fi + ;; + esac ]) if test "X[$with_plugin_]$2" = Xno; then AC_MSG_RESULT([no]) diff --git a/configure.in b/configure.in index 0fe2f1b5510..0c5fe692edf 100644 --- a/configure.in +++ b/configure.in @@ -1745,7 +1745,18 @@ then LDFLAGS="$LDFLAGS -rdynamic" AC_MSG_RESULT("-rdynamic") else - AC_MSG_RESULT("none") + case "$SYSTEM_TYPE$with_mysqld_ldflags " in + *freebsd*"-all-static "*|*dragonfly*"-all-static "*) + AC_MSG_RESULT("none") + ;; + *freebsd*|*dragonfly*) + MYSQLD_EXTRA_LDFLAGS="$MYSQLD_EXTRA_LDFLAGS -export-dynamic" + AC_MSG_RESULT("-export-dynamic") + ;; + *) + AC_MSG_RESULT("none") + ;; + esac fi dnl Checks for typedefs, structures, and compiler characteristics. diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 30e62c5d7b5..16fda2886f8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6492,7 +6492,7 @@ bool_pri: { $$= (*$2)(0)->create($1,$3); } | bool_pri comp_op all_or_any '(' subselect ')' %prec EQ { $$= all_any_subquery_creator($1, $2, $3, $5); } - | predicate ; + | predicate ; predicate: From 66047f1c163cc8e9caa08db5c79c3c8e24bf1274 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Fri, 26 Oct 2007 09:01:29 +0200 Subject: [PATCH 020/128] Bug#31662: 'null' is shown as type of fields for view with bad definer, breaks mysqldump SHOW FIELDS FROM a view with no valid definer was possible (since fix for Bug#26817), but gave NULL as a field-type. This led to mysqldump-ing of such views being successful, but loading such a dump with the client failing. Patch allows SHOW FIELDS to give data-type of field in underlying table. --- mysql-test/r/information_schema_db.result | 6 +++--- sql/sql_base.cc | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index dd1f0295277..ef63ef719a4 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -130,7 +130,7 @@ Warnings: Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them show fields from testdb_1.v7; Field Type Null Key Default Extra -f1 null YES NULL +f1 char(4) YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered create table t3 (f1 char(4), f2 char(4)); @@ -150,7 +150,7 @@ View Create View v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` show fields from testdb_1.v7; Field Type Null Key Default Extra -f1 null YES NULL +f1 char(4) YES NULL Warnings: Note 1449 There is no 'no_such_user'@'no_such_host' registered show create view testdb_1.v7; @@ -178,7 +178,7 @@ show create view v4; ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show fields from v4; Field Type Null Key Default Extra -f1 null YES NULL +f1 char(4) YES NULL f2 char(4) YES NULL show fields from v2; Field Type Null Key Default Extra diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2f8bb35683b..7679c9436e9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3958,7 +3958,9 @@ find_field_in_tables(THD *thd, Item_ident *item, { Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length, item->name, db, table_name, ref, - check_privileges, + (thd->lex->sql_command == + SQLCOM_SHOW_FIELDS) + ? false : check_privileges, allow_rowid, &(item->cached_field_index), register_tree_change, From 8cc5fe116f85763a25634c67040d093b175aaca1 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Fri, 26 Oct 2007 15:29:06 +0200 Subject: [PATCH 021/128] Bug#4692 - DISABLE/ENABLE KEYS waste a space Disabling and enabling indexes on a non-empty table grows the index file. Disabling indexes just sets a flag per non-unique index and does not free the index blocks of the affected indexes. Re-enabling indexes creates new indexes with new blocks. The old blocks remain unused in the index file. Fixed by dropping and re-creating all indexes if non-empty disabled indexes exist when enabling indexes. Dropping all indexes resets the internal end-of-file marker to the end of the index file header. It also clears the root block pointers of every index and clears the deleted blocks chains. This way all blocks are declared as free. --- myisam/mi_check.c | 222 +++++++++++++++++++++------- mysql-test/r/bdb_notembedded.result | 35 ----- mysql-test/r/myisam.result | 25 ++++ mysql-test/t/bdb_notembedded.test | 38 ----- mysql-test/t/myisam.test | 26 ++++ 5 files changed, 216 insertions(+), 130 deletions(-) delete mode 100644 mysql-test/r/bdb_notembedded.result delete mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/myisam/mi_check.c b/myisam/mi_check.c index ed0a84e737d..c225e2bdb5c 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1375,6 +1375,139 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } /* chk_data_link */ +/** + @brief Drop all indexes + + @param[in] param check parameters + @param[in] info MI_INFO handle + @param[in] force if to force drop all indexes + + @return status + @retval 0 OK + @retval != 0 Error + + @note + Once allocated, index blocks remain part of the key file forever. + When indexes are disabled, no block is freed. When enabling indexes, + no block is freed either. The new indexes are create from new + blocks. (Bug #4692) + + Before recreating formerly disabled indexes, the unused blocks + must be freed. There are two options to do this: + - Follow the tree of disabled indexes, add all blocks to the + deleted blocks chain. Would require a lot of random I/O. + - Drop all blocks by clearing all index root pointers and all + delete chain pointers and resetting key_file_length to the end + of the index file header. This requires to recreate all indexes, + even those that may still be intact. + The second method is probably faster in most cases. + + When disabling indexes, MySQL disables either all indexes or all + non-unique indexes. When MySQL [re-]enables disabled indexes + (T_CREATE_MISSING_KEYS), then we either have "lost" blocks in the + index file, or there are no non-unique indexes. In the latter case, + mi_repair*() would not be called as there would be no disabled + indexes. + + If there would be more unique indexes than disabled (non-unique) + indexes, we could do the first method. But this is not implemented + yet. By now we drop and recreate all indexes when repair is called. + + However, there is an exception. Sometimes MySQL disables non-unique + indexes when the table is empty (e.g. when copying a table in + mysql_alter_table()). When enabling the non-unique indexes, they + are still empty. So there is no index block that can be lost. This + optimization is implemented in this function. + + Note that in normal repair (T_CREATE_MISSING_KEYS not set) we + recreate all enabled indexes unconditonally. We do not change the + key_map. Otherwise we invert the key map temporarily (outside of + this function) and recreate the then "seemingly" enabled indexes. + When we cannot use the optimization, and drop all indexes, we + pretend that all indexes were disabled. By the inversion, we will + then recrate all indexes. +*/ + +static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force) +{ + MYISAM_SHARE *share= info->s; + MI_STATE_INFO *state= &share->state; + uint i; + int error; + DBUG_ENTER("mi_drop_all_indexes"); + + /* + If any of the disabled indexes has a key block assigned, we must + drop and recreate all indexes to avoid losing index blocks. + + If we want to recreate disabled indexes only _and_ all of these + indexes are empty, we don't need to recreate the existing indexes. + */ + if (!force && (param->testflag & T_CREATE_MISSING_KEYS)) + { + DBUG_PRINT("repair", ("creating missing indexes")); + for (i= 0; i < share->base.keys; i++) + { + DBUG_PRINT("repair", ("index #: %u key_root: 0x%lx active: %d", + i, (long) state->key_root[i], + mi_is_key_active(state->key_map, i))); + if ((state->key_root[i] != HA_OFFSET_ERROR) && + !mi_is_key_active(state->key_map, i)) + { + /* + This index has at least one key block and it is disabled. + We would lose its block(s) if would just recreate it. + So we need to drop and recreate all indexes. + */ + DBUG_PRINT("repair", ("nonempty and disabled: recreate all")); + break; + } + } + if (i >= share->base.keys) + { + /* + All of the disabled indexes are empty. We can just recreate them. + Flush dirty blocks of this index file from key cache and remove + all blocks of this index file from key cache. + */ + DBUG_PRINT("repair", ("all disabled are empty: create missing")); + error= flush_key_blocks(share->key_cache, share->kfile, + FLUSH_FORCE_WRITE); + goto end; + } + /* + We do now drop all indexes and declare them disabled. With the + T_CREATE_MISSING_KEYS flag, mi_repair*() will recreate all + disabled indexes and enable them. + */ + mi_clear_all_keys_active(state->key_map); + DBUG_PRINT("repair", ("declared all indexes disabled")); + } + + /* Remove all key blocks of this index file from key cache. */ + if ((error= flush_key_blocks(share->key_cache, share->kfile, + FLUSH_IGNORE_CHANGED))) + goto end; + + /* Clear index root block pointers. */ + for (i= 0; i < share->base.keys; i++) + state->key_root[i]= HA_OFFSET_ERROR; + + /* Clear the delete chains. */ + for (i= 0; i < state->header.max_block_size; i++) + state->key_del[i]= HA_OFFSET_ERROR; + + /* Reset index file length to end of index file header. */ + info->state->key_file_length= share->base.keystart; + + DBUG_PRINT("repair", ("dropped all indexes")); + /* error= 0; set by last (error= flush_key_bocks()). */ + + end: + DBUG_RETURN(error); +} + + /* Recover old table by reading each record and writing all keys */ /* Save new datafile-name in temp_filename */ @@ -1382,7 +1515,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, my_string name, int rep_quick) { int error,got_error; - uint i; ha_rows start_records,new_header_length; my_off_t del; File new_file; @@ -1486,25 +1618,10 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - /* - Clear all keys. Note that all key blocks allocated until now remain - "dead" parts of the key file. (Bug #4692) - */ - for (i=0 ; i < info->s->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - - /* Drop the delete chain. */ - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - - /* - If requested, activate (enable) all keys in key_map. In this case, - all indexes will be (re-)built. - */ + /* This function always recreates all enabled indexes. */ if (param->testflag & T_CREATE_MISSING_KEYS) mi_set_all_keys_active(share->state.key_map, share->base.keys); - - info->state->key_file_length=share->base.keystart; + mi_drop_all_indexes(param, info, TRUE); lock_memory(param); /* Everything is alloced */ @@ -2105,7 +2222,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ulong *rec_per_key_part; char llbuff[22]; SORT_INFO sort_info; - ulonglong key_map=share->state.key_map; + ulonglong key_map; DBUG_ENTER("mi_repair_by_sort"); start_records=info->state->records; @@ -2179,25 +2296,14 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - if (!(param->testflag & T_CREATE_MISSING_KEYS)) + + /* Optionally drop indexes and optionally modify the key_map. */ + mi_drop_all_indexes(param, info, FALSE); + key_map= share->state.key_map; + if (param->testflag & T_CREATE_MISSING_KEYS) { - /* - Flush key cache for this file if we are calling this outside - myisamchk - */ - flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); - /* Clear the pointers to the given rows */ - for (i=0 ; i < share->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - info->state->key_file_length=share->base.keystart; - } - else - { - if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) - goto err; - key_map= ~key_map; /* Create the missing keys */ + /* Invert the copied key_map to recreate all disabled indexes. */ + key_map= ~key_map; } sort_info.info=info; @@ -2240,6 +2346,10 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, sort_param.read_cache=param->read_cache; sort_param.keyinfo=share->keyinfo+sort_param.key; sort_param.seg=sort_param.keyinfo->seg; + /* + Skip this index if it is marked disabled in the copied + (and possibly inverted) key_map. + */ if (! mi_is_key_active(key_map, sort_param.key)) { /* Remember old statistics for key */ @@ -2247,6 +2357,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, (char*) (share->state.rec_per_key_part + (uint) (rec_per_key_part - param->rec_per_key_part)), sort_param.keyinfo->keysegs*sizeof(*rec_per_key_part)); + DBUG_PRINT("repair", ("skipping seemingly disabled index #: %u", + sort_param.key)); continue; } @@ -2302,8 +2414,11 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, if (param->testflag & T_STATISTICS) update_key_parts(sort_param.keyinfo, rec_per_key_part, sort_param.unique, param->stats_method == MI_STATS_METHOD_IGNORE_NULLS? - sort_param.notnull: NULL,(ulonglong) info->state->records); + sort_param.notnull: NULL, + (ulonglong) info->state->records); + /* Enable this index in the permanent (not the copied) key_map. */ mi_set_key_active(share->state.key_map, sort_param.key); + DBUG_PRINT("repair", ("set enabled index #: %u", sort_param.key)); if (sort_param.fix_datafile) { @@ -2504,7 +2619,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, IO_CACHE new_data_cache; /* For non-quick repair. */ IO_CACHE_SHARE io_share; SORT_INFO sort_info; - ulonglong key_map=share->state.key_map; + ulonglong key_map; pthread_attr_t thr_attr; DBUG_ENTER("mi_repair_parallel"); @@ -2608,25 +2723,14 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - if (!(param->testflag & T_CREATE_MISSING_KEYS)) + + /* Optionally drop indexes and optionally modify the key_map. */ + mi_drop_all_indexes(param, info, FALSE); + key_map= share->state.key_map; + if (param->testflag & T_CREATE_MISSING_KEYS) { - /* - Flush key cache for this file if we are calling this outside - myisamchk - */ - flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); - /* Clear the pointers to the given rows */ - for (i=0 ; i < share->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - info->state->key_file_length=share->base.keystart; - } - else - { - if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) - goto err; - key_map= ~key_map; /* Create the missing keys */ + /* Invert the copied key_map to recreate all disabled indexes. */ + key_map= ~key_map; } sort_info.info=info; @@ -2682,6 +2786,10 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, sort_param[i].key=key; sort_param[i].keyinfo=share->keyinfo+key; sort_param[i].seg=sort_param[i].keyinfo->seg; + /* + Skip this index if it is marked disabled in the copied + (and possibly inverted) key_map. + */ if (! mi_is_key_active(key_map, key)) { /* Remember old statistics for key */ diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result deleted file mode 100644 index 14cb5fad915..00000000000 --- a/mysql-test/r/bdb_notembedded.result +++ /dev/null @@ -1,35 +0,0 @@ -set autocommit=1; -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; insert into bug16206 values(2) -drop table bug16206; -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb -f n Query 1 n use `test`; insert into bug16206 values(0) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; BEGIN -f n Query 1 n use `test`; insert into bug16206 values(2) -f n Query 1 n use `test`; COMMIT -f n Query 1 n use `test`; insert into bug16206 values(3) -drop table bug16206; -set autocommit=0; -End of 5.0 tests diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 7fc29cd13ca..176d0e97012 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1806,4 +1806,29 @@ SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; a 1 DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 0 # # # 1024 # # # # # # # +INSERT INTO t1 VALUES (1,1); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index d5f403616c8..ad223dc2664 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1161,4 +1161,30 @@ ALTER TABLE t1 ENABLE KEYS; SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; DROP TABLE t1; +# +# Bug#4692 - DISABLE/ENABLE KEYS waste a space +# +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +INSERT INTO t1 VALUES (1,1); +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +#--exec ls -log var/master-data/test/t1.MYI +#--exec myisamchk -dvv var/master-data/test/t1.MYI +#--exec myisamchk -iev var/master-data/test/t1.MYI +DROP TABLE t1; + --echo End of 5.0 tests From 5eb3b270d3dd38e2cc6894d622849eb3a12856db Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Fri, 26 Oct 2007 21:26:06 +0500 Subject: [PATCH 022/128] Fixed bug #31036: Using order by with archive table crashes server. 1. Memory overrun have been fixed. 2. Server failure on assertion has been fixed. --- mysql-test/r/archive.result | 4 ++++ mysql-test/t/archive.test | 22 ++++++++++++++++++++++ storage/archive/azio.c | 10 +++++----- storage/archive/ha_archive.cc | 4 ++-- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 36b013703d8..803c102f6cf 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12682,3 +12682,7 @@ check table t1 extended; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +CREATE TABLE t1(a VARCHAR(510)) ENGINE = ARCHIVE; +INSERT INTO t1(a) VALUES (''); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 23c591856a7..a8567ab9fd0 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1559,3 +1559,25 @@ insert into t1 set a=''; insert into t1 set a='a'; check table t1 extended; drop table t1; + +# +# BUG#31036 - Using order by with archive table crashes server +# + +CREATE TABLE t1(a VARCHAR(510)) ENGINE = ARCHIVE; + +let $bug31036=41; +--disable_query_log +while($bug31036) +{ + INSERT INTO t1(a) VALUES (REPEAT('a', 510)); + dec $bug31036; +} +--enable_query_log +INSERT INTO t1(a) VALUES (''); + +--disable_result_log +SELECT * FROM t1 ORDER BY a; +--enable_result_log + +DROP TABLE t1; diff --git a/storage/archive/azio.c b/storage/archive/azio.c index f6b1a6e733f..b5c3dd465af 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -681,8 +681,8 @@ my_off_t azseek (s, offset, whence) /* There was a zmemzero here if inbuf was null -Brian */ while (offset > 0) { - uInt size = AZ_BUFSIZE_WRITE; - if (offset < AZ_BUFSIZE_WRITE) size = (uInt)offset; + uInt size = AZ_BUFSIZE_READ; + if (offset < AZ_BUFSIZE_READ) size = (uInt)offset; size = azwrite(s, s->inbuf, size); if (size == 0) return -1L; @@ -725,11 +725,11 @@ my_off_t azseek (s, offset, whence) } while (offset > 0) { int error; - unsigned int size = AZ_BUFSIZE_READ; - if (offset < AZ_BUFSIZE_READ) size = (int)offset; + unsigned int size = AZ_BUFSIZE_WRITE; + if (offset < AZ_BUFSIZE_WRITE) size = (int)offset; size = azread(s, s->outbuf, size, &error); - if (error <= 0) return -1L; + if (error < 0) return -1L; offset -= size; } return s->out; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 6696eac2fbb..3015ae78761 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1241,8 +1241,8 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos) DBUG_ENTER("ha_archive::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); current_position= (my_off_t)my_get_ptr(pos, ref_length); - (void)azseek(&archive, current_position, SEEK_SET); - + if (azseek(&archive, current_position, SEEK_SET) < 0) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); DBUG_RETURN(get_row(&archive, buf)); } From 6fbac59c5c2d88d2b9ad1a2747a42a1631b80a90 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Sat, 27 Oct 2007 01:40:48 +0500 Subject: [PATCH 023/128] Many files: Error message numbers. --- mysql-test/r/binlog_unsafe.result | 4 +-- mysql-test/r/events_bugs.result | 16 +++++----- mysql-test/r/events_trans.result | 2 +- mysql-test/r/sp_gis.result | 4 +-- mysql-test/r/xml.result | 18 +++++------ mysql-test/suite/ndb/r/ndb_dd_basic.result | 6 ++-- mysql-test/suite/ndb/r/ndb_dd_ddl.result | 2 +- mysql-test/suite/ndb/r/ndb_gis.result | 4 +-- mysql-test/suite/ndb/r/ndb_row_format.result | 2 +- mysql-test/suite/ndb/r/ndb_single_user.result | 10 +++--- mysql-test/suite/rpl/r/rpl_incident.result | 4 +-- .../suite/rpl/r/rpl_loaddata_fatal.result | 4 +-- mysql-test/suite/rpl/r/rpl_udf.result | 8 ++--- .../suite/rpl_ndb/r/rpl_ndb_extraCol.result | 32 +++++++++---------- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/mysql-test/r/binlog_unsafe.result b/mysql-test/r/binlog_unsafe.result index 281bb475944..47284ed8bc3 100644 --- a/mysql-test/r/binlog_unsafe.result +++ b/mysql-test/r/binlog_unsafe.result @@ -5,9 +5,9 @@ CREATE TABLE t3 (b INT AUTO_INCREMENT PRIMARY KEY); CREATE VIEW v1(a,b) AS SELECT a,b FROM t2,t3; INSERT INTO t1 SELECT UUID(); Warnings: -Warning 1591 Statement is not safe to log in statement format. +Warning 1592 Statement is not safe to log in statement format. SHOW WARNINGS; Level Warning -Code 1591 +Code 1592 Message Statement is not safe to log in statement format. DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 3c9e6384c64..1cbc37cb5b5 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -31,7 +31,7 @@ create event e_55 on schedule at 10000101000000 do drop table t; ERROR HY000: Incorrect AT value: '10000101000000' create event e_55 on schedule at 20000101000000 do drop table t; Warnings: -Note 1587 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. show events; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t; @@ -457,22 +457,22 @@ CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO SELECT 1; Warnings: -Note 1587 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' DISABLE DO SELECT 1; Warnings: -Note 1587 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO SELECT 1; Warnings: -Note 1587 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE DO SELECT 1; Warnings: -Note 1587 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci @@ -482,19 +482,19 @@ The following should succeed giving a warning. ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE; Warnings: -Note 1543 Event execution time is in the past. Event has been disabled +Note 1544 Event execution time is in the past. Event has been disabled CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DO SELECT 1; Warnings: -Note 1543 Event execution time is in the past. Event has been disabled +Note 1544 Event execution time is in the past. Event has been disabled CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00' ON COMPLETION PRESERVE DO SELECT 1; Warnings: -Note 1543 Event execution time is in the past. Event has been disabled +Note 1544 Event execution time is in the past. Event has been disabled The following should succeed without warnings. ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'; ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' diff --git a/mysql-test/r/events_trans.result b/mysql-test/r/events_trans.result index 984e22a2c1a..16ec64b4c50 100644 --- a/mysql-test/r/events_trans.result +++ b/mysql-test/r/events_trans.result @@ -63,7 +63,7 @@ begin work; insert into t1 (a) values ("OK: create event if not exists"); create event if not exists e1 on schedule every 2 day do select 2; Warnings: -Note 1536 Event 'e1' already exists +Note 1537 Event 'e1' already exists rollback work; select * from t1; a diff --git a/mysql-test/r/sp_gis.result b/mysql-test/r/sp_gis.result index b0960dec647..7a76507754f 100644 --- a/mysql-test/r/sp_gis.result +++ b/mysql-test/r/sp_gis.result @@ -7,11 +7,11 @@ return 1; create function x() returns int return 2; Warnings: -Note 1584 This function 'x' has the same name as a native function +Note 1585 This function 'x' has the same name as a native function create function y() returns int return 3; Warnings: -Note 1584 This function 'y' has the same name as a native function +Note 1585 This function 'y' has the same name as a native function select a(); a() 1 diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 552f4896698..d98173dbe15 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -647,32 +647,32 @@ select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT' select extractValue('a<','/a'); extractValue('a<','/a') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)' select extractValue('aaaa' wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 8: END-OF-INPUT unexpected ('>' wanted)' select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 12: '' unexpected (END-OF-INPUT wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 12: '' unexpected (END-OF-INPUT wanted)' select extractValue('a','/a'); extractValue('a','/a') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)' select extractValue('1','position()'); ERROR HY000: XPATH syntax error: '' select extractValue('1','last()'); @@ -723,17 +723,17 @@ select extractValue('<01>10:39:15<02>140','//* extractValue('<01>10:39:15<02>140','//*') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)' select extractValue('<.>test','//*'); extractValue('<.>test','//*') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' select extractValue('<->test','//*'); extractValue('<->test','//*') NULL Warnings: -Warning 1524 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' select extractValue('<:>test','//*'); extractValue('<:>test','//*') test diff --git a/mysql-test/suite/ndb/r/ndb_dd_basic.result b/mysql-test/suite/ndb/r/ndb_dd_basic.result index 0ff28f889b7..f04905b8d13 100644 --- a/mysql-test/suite/ndb/r/ndb_dd_basic.result +++ b/mysql-test/suite/ndb/r/ndb_dd_basic.result @@ -8,20 +8,20 @@ INITIAL_SIZE 16M UNDO_BUFFER_SIZE = 1M ENGINE=MYISAM; Warnings: -Error 1477 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1478 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' ALTER LOGFILE GROUP lg1 ADD UNDOFILE 'undofile02.dat' INITIAL_SIZE = 4M ENGINE=XYZ; Warnings: Warning 1286 Unknown table engine 'XYZ' -Error 1477 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1478 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M; Warnings: -Error 1477 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +Error 1478 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' set storage_engine=ndb; CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' diff --git a/mysql-test/suite/ndb/r/ndb_dd_ddl.result b/mysql-test/suite/ndb/r/ndb_dd_ddl.result index 569769cfaef..d8d9e8631d5 100644 --- a/mysql-test/suite/ndb/r/ndb_dd_ddl.result +++ b/mysql-test/suite/ndb/r/ndb_dd_ddl.result @@ -16,7 +16,7 @@ ERROR HY000: Failed to create LOGFILE GROUP SHOW WARNINGS; Level Code Message Error 1296 Got error 1514 'Currently there is a limit of one logfile group' from NDB -Error 1527 Failed to create LOGFILE GROUP +Error 1528 Failed to create LOGFILE GROUP CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' INITIAL_SIZE 1M diff --git a/mysql-test/suite/ndb/r/ndb_gis.result b/mysql-test/suite/ndb/r/ndb_gis.result index b401dee8054..6c44c6fb822 100644 --- a/mysql-test/suite/ndb/r/ndb_gis.result +++ b/mysql-test/suite/ndb/r/ndb_gis.result @@ -463,7 +463,7 @@ drop table t1; End of 4.1 tests CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); Warnings: -Error 1477 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +Error 1478 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); @@ -1013,7 +1013,7 @@ drop table t1; End of 4.1 tests CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); Warnings: -Error 1477 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +Error 1478 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); diff --git a/mysql-test/suite/ndb/r/ndb_row_format.result b/mysql-test/suite/ndb/r/ndb_row_format.result index ea495e7e9c5..eea0692dd92 100644 --- a/mysql-test/suite/ndb/r/ndb_row_format.result +++ b/mysql-test/suite/ndb/r/ndb_row_format.result @@ -8,7 +8,7 @@ ENGINE=NDB; ERROR HY000: Can't create table 'test.t1' (errno: 138) SHOW WARNINGS; Level Code Message -Error 1477 Table storage engine 'ndbcluster' does not support the create option 'Row format FIXED incompatible with variable sized attribute' +Error 1478 Table storage engine 'ndbcluster' does not support the create option 'Row format FIXED incompatible with variable sized attribute' Error 1005 Can't create table 'test.t1' (errno: 138) CREATE TABLE t1 ( a INT KEY, diff --git a/mysql-test/suite/ndb/r/ndb_single_user.result b/mysql-test/suite/ndb/r/ndb_single_user.result index 552629ae532..0a4f7cd0b5f 100644 --- a/mysql-test/suite/ndb/r/ndb_single_user.result +++ b/mysql-test/suite/ndb/r/ndb_single_user.result @@ -11,7 +11,7 @@ ERROR HY000: Failed to create LOGFILE GROUP show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1527 Failed to create LOGFILE GROUP +Error 1528 Failed to create LOGFILE GROUP create table t1 (a int key, b int unique, c int) engine ndb; CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' @@ -27,14 +27,14 @@ ERROR HY000: Failed to create TABLESPACE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1527 Failed to create TABLESPACE +Error 1528 Failed to create TABLESPACE DROP LOGFILE GROUP lg1 ENGINE =NDB; ERROR HY000: Failed to drop LOGFILE GROUP show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1528 Failed to drop LOGFILE GROUP +Error 1529 Failed to drop LOGFILE GROUP CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 @@ -47,7 +47,7 @@ ERROR HY000: Failed to alter: DROP DATAFILE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1532 Failed to alter: DROP DATAFILE +Error 1533 Failed to alter: DROP DATAFILE ALTER TABLESPACE ts1 DROP DATAFILE 'datafile.dat' ENGINE NDB; @@ -57,7 +57,7 @@ ERROR HY000: Failed to drop TABLESPACE show warnings; Level Code Message Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB -Error 1528 Failed to drop TABLESPACE +Error 1529 Failed to drop TABLESPACE DROP TABLESPACE ts1 ENGINE NDB; DROP LOGFILE GROUP lg1 diff --git a/mysql-test/suite/rpl/r/rpl_incident.result b/mysql-test/suite/rpl/r/rpl_incident.result index 568078cc276..c3baabbdbc3 100644 --- a/mysql-test/suite/rpl/r/rpl_incident.result +++ b/mysql-test/suite/rpl/r/rpl_incident.result @@ -44,7 +44,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1589 +Last_Errno 1590 Last_Error The incident LOST_EVENTS occured on the master. Message: Skip_Counter 0 Exec_Master_Log_Pos # @@ -62,7 +62,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1589 +Last_SQL_Errno 1590 Last_SQL_Error The incident LOST_EVENTS occured on the master. Message: SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result index d30110f85e9..a4d67754bd6 100644 --- a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result +++ b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result @@ -65,7 +65,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1592 +Last_Errno 1593 Last_Error Fatal error: Not enough memory Skip_Counter 0 Exec_Master_Log_Pos 325 @@ -83,7 +83,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1592 +Last_SQL_Errno 1593 Last_SQL_Error Fatal error: Not enough memory SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result index fcd2f4743ba..79a82b5fbc7 100644 --- a/mysql-test/suite/rpl/r/rpl_udf.result +++ b/mysql-test/suite/rpl/r/rpl_udf.result @@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); Warnings: -Warning 1591 Statement is not safe to log in statement format. +Warning 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); Warnings: -Warning 1591 Statement is not safe to log in statement format. +Warning 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); Warnings: -Warning 1591 Statement is not safe to log in statement format. +Warning 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); Warnings: -Warning 1591 Statement is not safe to log in statement format. +Warning 1592 Statement is not safe to log in statement format. affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result index 41e888827b1..54056ac613b 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. STOP SLAVE; RESET SLAVE; @@ -139,7 +139,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -157,7 +157,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -201,7 +201,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -219,7 +219,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -263,7 +263,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -281,7 +281,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -324,7 +324,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -342,7 +342,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -436,7 +436,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -454,7 +454,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -497,7 +497,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -515,7 +515,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -823,7 +823,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -841,7 +841,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; From 3cc449465c8caf3dd91d9d2b7db8832f984e45cc Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Sun, 28 Oct 2007 02:33:18 +0500 Subject: [PATCH 024/128] ha_archive.cc: Post-merge fix. --- storage/archive/ha_archive.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 3015ae78761..84298e785d1 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1241,7 +1241,7 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos) DBUG_ENTER("ha_archive::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); current_position= (my_off_t)my_get_ptr(pos, ref_length); - if (azseek(&archive, current_position, SEEK_SET) < 0) + if (azseek(&archive, current_position, SEEK_SET) == (my_off_t)(-1L)) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); DBUG_RETURN(get_row(&archive, buf)); } From 5ebb07a8c09384b772cc341df6d0c78e8957de64 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Sun, 28 Oct 2007 02:09:24 +0400 Subject: [PATCH 025/128] rpl_row_tabledefs_2myisam.result, sp.result, rpl_row_colSize.result: Error message numbers. --- mysql-test/r/sp.result | 8 +-- mysql-test/suite/rpl/r/rpl_row_colSize.result | 52 +++++++++---------- .../rpl/r/rpl_row_tabledefs_2myisam.result | 12 ++--- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 412f6b94fa2..68aa278585f 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5670,7 +5670,7 @@ drop function if exists pi; create function pi() returns varchar(50) return "pie, my favorite desert."; Warnings: -Note 1584 This function 'pi' has the same name as a native function +Note 1585 This function 'pi' has the same name as a native function SET @save_sql_mode=@@sql_mode; SET SQL_MODE='IGNORE_SPACE'; select pi(), pi (); @@ -5719,15 +5719,15 @@ use test; create function `database`() returns varchar(50) return "Stored function database"; Warnings: -Note 1584 This function 'database' has the same name as a native function +Note 1585 This function 'database' has the same name as a native function create function `current_user`() returns varchar(50) return "Stored function current_user"; Warnings: -Note 1584 This function 'current_user' has the same name as a native function +Note 1585 This function 'current_user' has the same name as a native function create function md5(x varchar(50)) returns varchar(50) return "Stored function md5"; Warnings: -Note 1584 This function 'md5' has the same name as a native function +Note 1585 This function 'md5' has the same name as a native function SET SQL_MODE='IGNORE_SPACE'; select database(), database (); database() database () diff --git a/mysql-test/suite/rpl/r/rpl_row_colSize.result b/mysql-test/suite/rpl/r/rpl_row_colSize.result index 9358e36cac6..6d002a722f1 100644 --- a/mysql-test/suite/rpl/r/rpl_row_colSize.result +++ b/mysql-test/suite/rpl/r/rpl_row_colSize.result @@ -37,7 +37,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 10, test.t1 on slave has size 3. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -55,7 +55,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 10, test.t1 on slave has size 3. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -91,7 +91,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 12, test.t1 on slave has size 12. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -109,7 +109,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 12, test.t1 on slave has size 12. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -145,7 +145,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 10, test.t1 on slave has size 3. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -163,7 +163,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 10, test.t1 on slave has size 3. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -200,7 +200,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 5, test.t1 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -218,7 +218,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 5, test.t1 has type 4 SELECT COUNT(*) FROM t1; COUNT(*) @@ -255,7 +255,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 8, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -273,7 +273,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 8, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -309,7 +309,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 2. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -327,7 +327,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 2. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -364,7 +364,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -382,7 +382,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -419,7 +419,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 20, test.t1 on slave has size 11. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -437,7 +437,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 20, test.t1 on slave has size 11. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -505,7 +505,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -523,7 +523,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -560,7 +560,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2000, test.t1 on slave has size 100. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -578,7 +578,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2000, test.t1 on slave has size 100. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -614,7 +614,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 200, test.t1 on slave has size 10. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -632,7 +632,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 200, test.t1 on slave has size 10. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -668,7 +668,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2000, test.t1 on slave has size 1000. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -686,7 +686,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 2000, test.t1 on slave has size 1000. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) @@ -723,7 +723,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 4, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -741,7 +741,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 size mismatch - master has size 4, test.t1 on slave has size 1. Master's column size should be <= the slave's column size. SELECT COUNT(*) FROM t1; COUNT(*) diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result index 566537ab745..06dc90f18aa 100644 --- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result +++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result @@ -214,7 +214,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -232,7 +232,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -300,7 +300,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -318,7 +318,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; From bf2bb354302fbabc2661c9d9efa14de5e51d0530 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Sun, 28 Oct 2007 11:30:36 +0400 Subject: [PATCH 026/128] Many files: Error message numbers. --- .../suite/rpl/r/rpl_extraCol_innodb.result | 32 +++++++++---------- .../suite/rpl/r/rpl_extraCol_myisam.result | 32 +++++++++---------- .../rpl/r/rpl_row_tabledefs_3innodb.result | 12 +++---- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result b/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result index fe5a5b28682..007cd5a252c 100644 --- a/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. STOP SLAVE; RESET SLAVE; @@ -139,7 +139,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -157,7 +157,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -201,7 +201,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -219,7 +219,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -263,7 +263,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -281,7 +281,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -324,7 +324,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -342,7 +342,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -436,7 +436,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -454,7 +454,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -497,7 +497,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -515,7 +515,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -822,7 +822,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -840,7 +840,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result b/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result index e70a2efaf29..873fc5cddbc 100644 --- a/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result +++ b/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result @@ -72,7 +72,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. Skip_Counter 0 Exec_Master_Log_Pos # @@ -90,7 +90,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size. STOP SLAVE; RESET SLAVE; @@ -139,7 +139,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -157,7 +157,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -201,7 +201,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -219,7 +219,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -263,7 +263,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 Skip_Counter 0 Exec_Master_Log_Pos # @@ -281,7 +281,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -324,7 +324,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 Skip_Counter 0 Exec_Master_Log_Pos # @@ -342,7 +342,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3; *** Drop t6 *** @@ -436,7 +436,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 Skip_Counter 0 Exec_Master_Log_Pos # @@ -454,7 +454,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -497,7 +497,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 Skip_Counter 0 Exec_Master_Log_Pos # @@ -515,7 +515,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -822,7 +822,7 @@ Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 Skip_Counter 0 Exec_Master_Log_Pos # @@ -840,7 +840,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result index 83df75b81e9..3911fe89b7f 100644 --- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result +++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result @@ -214,7 +214,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -232,7 +232,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -257,7 +257,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -275,7 +275,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 1 type mismatch - received type 3, test.t5 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -300,7 +300,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 Skip_Counter 0 Exec_Master_Log_Pos # @@ -318,7 +318,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 3, test.t6 has type 4 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; From 76bf63ba4ba05f79abbdb3ba74de068324088851 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Mon, 29 Oct 2007 11:52:44 +0300 Subject: [PATCH 027/128] Fixed compile warnings introduced by the patch for bug #29131. --- sql/mysqld.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 90bba4cd8ab..4c459d34a55 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6544,7 +6544,8 @@ static void mysql_init_variables(void) /* Things reset to zero */ opt_skip_slave_start= opt_reckless_slave = 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; - opt_log= opt_update_log= opt_slow_log= 0; + opt_log= opt_slow_log= 0; + opt_update_log= 0; opt_bin_log= 0; opt_disable_networking= opt_skip_show_db=0; opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0; From 7f945b2ad1fc8f6dcdb64a46313a164362cf6475 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Mon, 29 Oct 2007 14:45:35 +0400 Subject: [PATCH 028/128] backported test case from 5.1 --- mysql-test/r/information_schema.result | 32 ++++++++++++++++++++++++++ mysql-test/t/information_schema.test | 20 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 0c6a1855072..80f85aee429 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1385,6 +1385,38 @@ f6 bigint(20) NO 10 f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; +select * from information_schema.columns where table_schema = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME +select * from information_schema.schemata where schema_name = NULL; +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH +select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT +select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT +select * from information_schema.tables where table_schema = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from information_schema.tables where table_catalog = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from information_schema.tables where table_name = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER +select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE +select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE End of 5.0 tests. show fields from information_schema.table_names; ERROR 42S02: Unknown table 'table_names' in information_schema diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 04ffd30ec62..3d3310e389e 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1088,6 +1088,26 @@ select column_default from information_schema.columns where table_name= 't1'; show columns from t1; drop table t1; +# +# Bug#31633 Information schema = NULL queries crash the server +# +select * from information_schema.columns where table_schema = NULL; +select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; +select * from information_schema.schemata where schema_name = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; +select * from information_schema.tables where table_schema = NULL; +select * from information_schema.tables where table_catalog = NULL; +select * from information_schema.tables where table_name = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; + --echo End of 5.0 tests. # From b943d8cf3c46f1246089a00b1878d8143eb400d5 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Mon, 29 Oct 2007 14:53:10 +0400 Subject: [PATCH 029/128] Bug#30897 GROUP_CONCAT returns extra comma on empty fields The fix is a copy of Martin Friebe's suggestion. added testing for no_appended which will be false if anything, including the empty string is in result --- mysql-test/r/func_gconcat.result | 9 +++++++++ mysql-test/t/func_gconcat.test | 9 +++++++++ sql/item_sum.cc | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 73f756bc1d2..df61954b22a 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -861,4 +861,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1; group_concat(distinct a, c order by a desc, c desc) 31,11,10,01,00 drop table t1; +create table t1 (f1 char(20)); +insert into t1 values (''),(''); +select group_concat(distinct f1) from t1; +group_concat(distinct f1) + +select group_concat(f1) from t1; +group_concat(f1) +, +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index c415ca6c6eb..df8199a5bc7 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -590,4 +590,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1; drop table t1; +# +# Bug#30897 GROUP_CONCAT returns extra comma on empty fields +# +create table t1 (f1 char(20)); +insert into t1 values (''),(''); +select group_concat(distinct f1) from t1; +select group_concat(f1) from t1; +drop table t1; + --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 30cbe872101..ad8ebd0791c 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3406,7 +3406,7 @@ String* Item_func_group_concat::val_str(String* str) DBUG_ASSERT(fixed == 1); if (null_value) return 0; - if (!result.length() && tree) + if (no_appended && tree) /* Tree is used for sorting as in ORDER BY */ tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, left_root_right); From 6b92ec4acbf78892bc4880913a762db0189ce20f Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Mon, 29 Oct 2007 15:39:56 +0400 Subject: [PATCH 030/128] Bug#30889: filesort and order by with float/numeric crashes server There are two problems with ROUND(X, D) on an exact numeric (DECIMAL, NUMERIC type) field of a table: 1) The implementation of the ROUND function would change the number of decimal places regardless of the value decided upon in fix_length_and_dec. When the number of decimal places is not constant, this would cause an inconsistent state where the number of digits was less than the number of decimal places, which crashes filesort. Fixed by not allowing the ROUND operation to add any more decimal places than was decided in fix_length_and_dec. 2) fix_length_and_dec would allow the number of decimals to be greater than the maximium configured value for constant values of D. This led to the same crash as in (1). Fixed by not allowing the above in fix_length_and_dec. --- mysql-test/r/type_decimal.result | 67 ++++++++++++++++++++++++++++++++ mysql-test/t/type_decimal.test | 39 ++++++++++++++++++- sql/item_func.cc | 3 +- sql/item_func.h | 31 +++++++++++++++ 4 files changed, 138 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index b550536d0db..a438755ce6b 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -822,4 +822,71 @@ this must not produce error 1048: select * from t1 where ua_invited_by_id not in (select ua_id from t1); ua_id ua_invited_by_id drop table t1; +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +CREATE TABLE t1( a NUMERIC, b INT ); +INSERT INTO t1 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t1 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, b ) AS c FROM t1 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, 100 ) AS c FROM t1 ORDER BY c; +c +123456.000000000000000000000000000000 +123456.000000000000000000000000000000 +CREATE TABLE t2( a NUMERIC, b INT ); +INSERT INTO t2 VALUES (123456, 100); +SELECT TRUNCATE( a, b ) AS c FROM t2 ORDER BY c; +c +123456 +SELECT ROUND( a, b ) AS c FROM t2 ORDER BY c; +c +123456 +CREATE TABLE t3( a DECIMAL, b INT ); +INSERT INTO t3 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t3 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, b ) AS c FROM t3 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, 100 ) AS c FROM t3 ORDER BY c; +c +123456.000000000000000000000000000000 +123456.000000000000000000000000000000 +CREATE TABLE t4( a DECIMAL, b INT ); +INSERT INTO t4 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t4 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, b ) AS c FROM t4 ORDER BY c; +c +123456 +123456 +SELECT ROUND( a, 100 ) AS c FROM t4 ORDER BY c; +c +123456.000000000000000000000000000000 +123456.000000000000000000000000000000 +delete from t1; +INSERT INTO t1 VALUES (1234567890, 20), (999.99, 5); +Warnings: +Note 1265 Data truncated for column 'a' at row 2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(10,0) default NULL, + `b` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select round(a,b) as c from t1 order by c; +c +1000 +1234567890 +DROP TABLE t1, t2, t3, t4; End of 5.0 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 12d4398dd57..807d1e6b01e 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -440,5 +440,42 @@ select * from t1 where ua_invited_by_id not in (select ua_id from t1); drop table t1; ---echo End of 5.0 tests +# +# Bug #30889: filesort and order by with float/numeric crashes server +# +--disable_warnings +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +--enable_warnings +CREATE TABLE t1( a NUMERIC, b INT ); +INSERT INTO t1 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t1 ORDER BY c; +SELECT ROUND( a, b ) AS c FROM t1 ORDER BY c; +SELECT ROUND( a, 100 ) AS c FROM t1 ORDER BY c; +CREATE TABLE t2( a NUMERIC, b INT ); +INSERT INTO t2 VALUES (123456, 100); +SELECT TRUNCATE( a, b ) AS c FROM t2 ORDER BY c; +SELECT ROUND( a, b ) AS c FROM t2 ORDER BY c; + +CREATE TABLE t3( a DECIMAL, b INT ); +INSERT INTO t3 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t3 ORDER BY c; +SELECT ROUND( a, b ) AS c FROM t3 ORDER BY c; +SELECT ROUND( a, 100 ) AS c FROM t3 ORDER BY c; + +CREATE TABLE t4( a DECIMAL, b INT ); +INSERT INTO t4 VALUES (123456, 40), (123456, 40); +SELECT TRUNCATE( a, b ) AS c FROM t4 ORDER BY c; +SELECT ROUND( a, b ) AS c FROM t4 ORDER BY c; +SELECT ROUND( a, 100 ) AS c FROM t4 ORDER BY c; + +delete from t1; +INSERT INTO t1 VALUES (1234567890, 20), (999.99, 5); +show create table t1; + +select round(a,b) as c from t1 order by c; + +DROP TABLE t1, t2, t3, t4; + +--echo End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 22b0044242c..2ee9973c785 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2003,6 +2003,7 @@ void Item_func_round::fix_length_and_dec() case DECIMAL_RESULT: { hybrid_type= DECIMAL_RESULT; + decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set); int decimals_delta= args[0]->decimals - decimals_to_set; int precision= args[0]->decimal_precision(); int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1; @@ -2109,7 +2110,7 @@ my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value) longlong dec= args[1]->val_int(); if (dec > 0 || (dec < 0 && args[1]->unsigned_flag)) { - dec= min((ulonglong) dec, DECIMAL_MAX_SCALE); + dec= min((ulonglong) dec, decimals); decimals= (uint8) dec; // to get correct output } else if (dec < INT_MIN) diff --git a/sql/item_func.h b/sql/item_func.h index 43221a18a5b..a31294c0395 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -236,9 +236,40 @@ public: my_decimal *val_decimal(my_decimal *); String *val_str(String*str); + /** + @brief Performs the operation that this functions implements when the + result type is INT. + + @return The result of the operation. + */ virtual longlong int_op()= 0; + + /** + @brief Performs the operation that this functions implements when the + result type is REAL. + + @return The result of the operation. + */ virtual double real_op()= 0; + + /** + @brief Performs the operation that this functions implements when the + result type is DECIMAL. + + @param A pointer where the DECIMAL value will be allocated. + @return + - 0 If the result is NULL + - The same pointer it was given, with the area initialized to the + result of the operation. + */ virtual my_decimal *decimal_op(my_decimal *)= 0; + + /** + @brief Performs the operation that this functions implements when the + result type is a string type. + + @return The result of the operation. + */ virtual String *str_op(String *)= 0; bool is_null() { update_null_value(); return null_value; } }; From 69ed192e7277556f4e2ca487967322be7fe7edf7 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Mon, 29 Oct 2007 15:49:56 +0400 Subject: [PATCH 031/128] after merge fix --- mysql-test/r/type_decimal.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 4e9dcf41256..e37a398d22e 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -881,8 +881,8 @@ Note 1265 Data truncated for column 'a' at row 2 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` decimal(10,0) default NULL, - `b` int(11) default NULL + `a` decimal(10,0) DEFAULT NULL, + `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select round(a,b) as c from t1 order by c; c From ee25b4f56f417c09f11cda1ddd0347cec8b76c9f Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 29 Oct 2007 15:42:49 +0300 Subject: [PATCH 032/128] Fix for BUG#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table. The problem was that ROW_FORMAT clause in ALTER TABLE did not trigger table reconstruction. The fix is to rebuild a table if ROW_FORMAT is specified. --- mysql-test/include/mix1.inc | 49 ++++++++++++++++++++++++++++++++ mysql-test/r/innodb_mysql.result | 34 ++++++++++++++++++++++ sql/sql_table.cc | 1 + 3 files changed, 84 insertions(+) diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index aee5613ff35..df9d79157af 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1019,6 +1019,55 @@ SELECT * FROM t1 ORDER BY b DESC, a ASC; DROP TABLE t1; +########################################################################### + +--echo +--echo # +--echo # Bug#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table. +--echo # + +--echo +--echo # - prepare; +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo + +CREATE TABLE t1(c INT) + ENGINE = InnoDB + ROW_FORMAT = COMPACT; + +--echo +--echo # - initial check; +--echo + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; + +--echo +--echo # - change ROW_FORMAT and check; +--echo + +ALTER TABLE t1 ROW_FORMAT = REDUNDANT; + +--echo + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; + +--echo +--echo # - that's it, cleanup. +--echo + +DROP TABLE t1; + +########################################################################### + --echo End of 5.0 tests # Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 3a6758b38f4..2a0f9a930b8 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1286,6 +1286,40 @@ a b 2 2 3 2 1 1 +DROP TABLE t1; + +# +# Bug#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table. +# + +# - prepare; + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c INT) +ENGINE = InnoDB +ROW_FORMAT = COMPACT; + +# - initial check; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +table_schema table_name row_format +test t1 Compact + +# - change ROW_FORMAT and check; + +ALTER TABLE t1 ROW_FORMAT = REDUNDANT; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +table_schema table_name row_format +test t1 Redundant + +# - that's it, cleanup. + DROP TABLE t1; End of 5.0 tests CREATE TABLE `t2` ( diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 64d739aae7e..2bd89d4a0ae 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4985,6 +4985,7 @@ compare_tables(TABLE *table, create_info->used_fields & HA_CREATE_USED_ENGINE || create_info->used_fields & HA_CREATE_USED_CHARSET || create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET || + create_info->used_fields & HA_CREATE_USED_ROW_FORMAT || (alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) || order_num || !table->s->mysql_version || From e93574e9d16efc747a88875325469e2b029e5eb8 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Tue, 30 Oct 2007 12:35:03 +0400 Subject: [PATCH 033/128] Bug #31758 inet_ntoa, oct crashes server with null+filesort Item_func_inet_ntoa and Item_func_conv inherit 'maybe_null' flag from an argument, which is wrong. Both can be NULL with notnull arguments, so that's fixed. --- mysql-test/r/func_str.result | 18 +++++++++++++++--- mysql-test/t/func_str.test | 13 +++++++++++++ sql/item_strfunc.h | 3 ++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index af6a4d20cff..3a429765c98 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -711,9 +711,9 @@ Warning 1265 Data truncated for column 'format(130,10)' at row 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `bin(130)` char(64) NOT NULL default '', - `oct(130)` char(64) NOT NULL default '', - `conv(130,16,10)` char(64) NOT NULL default '', + `bin(130)` char(64) default NULL, + `oct(130)` char(64) default NULL, + `conv(130,16,10)` char(64) default NULL, `hex(130)` char(6) NOT NULL default '', `char(130)` char(1) NOT NULL default '', `format(130,10)` char(4) NOT NULL default '', @@ -1075,5 +1075,17 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found Warnings: Note 1003 select decode(test.t1.f1,'zxcv') AS `enc` from test.t1 +drop table t1; +create table t1 (a bigint not null)engine=myisam; +insert into t1 set a = 1024*1024*1024*4; +delete from t1 order by (inet_ntoa(a)) desc limit 10; +drop table t1; +create table t1 (a char(36) not null)engine=myisam; +insert ignore into t1 set a = ' '; +insert ignore into t1 set a = ' '; +select * from t1 order by (oct(a)); +a + + drop table t1; End of 4.1 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 5897674d1d4..f2991cc3b1d 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -721,4 +721,17 @@ explain extended select encode(f1,'zxcv') as 'enc' from t1; explain extended select decode(f1,'zxcv') as 'enc' from t1; drop table t1; +# +# Bug #31758 inet_ntoa, oct, crashes server with null + filesort +# +create table t1 (a bigint not null)engine=myisam; +insert into t1 set a = 1024*1024*1024*4; +delete from t1 order by (inet_ntoa(a)) desc limit 10; +drop table t1; +create table t1 (a char(36) not null)engine=myisam; +insert ignore into t1 set a = ' '; +insert ignore into t1 set a = ' '; +select * from t1 order by (oct(a)); +drop table t1; + --echo End of 4.1 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 4bd8574ff04..b438ac81763 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -531,6 +531,7 @@ public: { collation.set(default_charset()); decimals=0; max_length=64; + maybe_null= 1; } }; @@ -623,7 +624,7 @@ public: } String* val_str(String* str); const char *func_name() const { return "inet_ntoa"; } - void fix_length_and_dec() { decimals = 0; max_length=3*8+7; } + void fix_length_and_dec() { decimals = 0; max_length=3*8+7; maybe_null=1;} }; class Item_func_quote :public Item_str_func From cbd3dfbbcb85ffd4c3aecbf238857e9dc0a95be8 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Tue, 30 Oct 2007 14:46:43 +0400 Subject: [PATCH 034/128] BUG#11392 - fulltext search bug Fulltext boolean mode phrase search may crash server on platforms where size of pointer is not equal to size of unsigned integer (in other words some 64-bit platforms). The problem was integer overflow. Affects 4.1 only. --- myisam/ft_boolean_search.c | 3 ++- mysql-test/r/fulltext.result | 6 ++++++ mysql-test/t/fulltext.test | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f1ff8f6d886..fad25abcc6c 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -446,7 +446,8 @@ static int _ftb_strstr(const byte *s0, const byte *e0, { if (cs->coll->instr(cs, p0, e0 - p0, s1, e1 - s1, m, 2) != 2) return(0); - if ((!s_after || p0 + m[1].beg == s0 || !true_word_char(cs, p0[m[1].beg-1])) && + if ((!s_after || p0 + m[1].beg == s0 || + !true_word_char(cs, p0[(int) m[1].beg - 1])) && (!e_before || p0 + m[1].end == e0 || !true_word_char(cs, p0[m[1].end]))) return(1); p0+= m[1].beg; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 3700ace4b19..af41adf3a24 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -454,3 +454,9 @@ ALTER TABLE t1 DISABLE KEYS; SELECT * FROM t1 WHERE MATCH(a) AGAINST('test'); ERROR HY000: Can't find FULLTEXT index matching the column list DROP TABLE t1; +CREATE TABLE t1(a TEXT); +INSERT INTO t1 VALUES(' aaaaa aaaa'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE); +a + aaaaa aaaa +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 1a9a6b578dc..661e93d8d87 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -379,4 +379,12 @@ ALTER TABLE t1 DISABLE KEYS; SELECT * FROM t1 WHERE MATCH(a) AGAINST('test'); DROP TABLE t1; +# +# BUG#11392 - fulltext search bug +# +CREATE TABLE t1(a TEXT); +INSERT INTO t1 VALUES(' aaaaa aaaa'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE); +DROP TABLE t1; + # End of 4.1 tests From 250f5769bf37d5de5c02b25e08567e7814a37f6d Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 30 Oct 2007 12:03:44 +0100 Subject: [PATCH 035/128] Post-merge fix --- mysql-test/t/variables.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index f474d166fae..9fa14ba3907 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -161,7 +161,7 @@ select * from information_schema.session_variables where variable_name like 'net set net_buffer_length=1; show variables like 'net_buffer_length'; select * from information_schema.session_variables where variable_name like 'net_buffer_length'; ---warning 1292 +#warning 1292 set net_buffer_length=2000000000; show variables like 'net_buffer_length'; select * from information_schema.session_variables where variable_name like 'net_buffer_length'; From 47c381fbb42cd8129fff8b99c70d44d6070532c1 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Tue, 30 Oct 2007 15:25:39 +0300 Subject: [PATCH 036/128] Make sure rpl.rpl_innodb_mixed_dml passes even if rpl_mixed.dat is read-only. This is important for a development environment where not all source files are checked out. --- mysql-test/suite/rpl/include/rpl_mixed_dml.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/include/rpl_mixed_dml.inc b/mysql-test/suite/rpl/include/rpl_mixed_dml.inc index 96dfdbed541..a3ff022c43c 100644 --- a/mysql-test/suite/rpl/include/rpl_mixed_dml.inc +++ b/mysql-test/suite/rpl/include/rpl_mixed_dml.inc @@ -53,7 +53,7 @@ DELETE FROM t2 WHERE a = 2; --echo ******************** LOAD DATA INFILE ******************** --exec cp ./suite/rpl/data/rpl_mixed.dat $MYSQLTEST_VARDIR/tmp/ LOAD DATA INFILE '../tmp/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ; ---exec rm $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat +--remove_file $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat SELECT * FROM t1; --source suite/rpl/include/rpl_mixed_check_select.inc --source suite/rpl/include/rpl_mixed_clear_tables.inc From 01fe24cd68bfd00183745df215c98175bf898afe Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 30 Oct 2007 14:27:21 +0200 Subject: [PATCH 037/128] Bug #31884: Assertion + crash in subquery in the SELECT clause. Item_in_subselect's only externally callable method is val_bool(). However the nullability in the wrapper class (Item_in_optimizer) is established by calling the "forbidden" method val_int(). Fixed to use the correct method (val_bool() ) to establish nullability of Item_in_subselect in Item_in_optimizer. --- mysql-test/r/subselect.result | 11 +++++++++++ mysql-test/t/subselect.test | 15 +++++++++++++++ sql/item_subselect.h | 1 + 3 files changed, 27 insertions(+) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index be99bdb1afc..bfacfc86eef 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4139,4 +4139,15 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1; (SELECT SUM(t1.a) FROM t2 WHERE a=1) 3 DROP TABLE t1,t2; +CREATE TABLE t1 (a1 INT, a2 INT); +CREATE TABLE t2 (b1 INT, b2 INT); +INSERT INTO t1 VALUES (100, 200); +INSERT INTO t1 VALUES (101, 201); +INSERT INTO t2 VALUES (101, 201); +INSERT INTO t2 VALUES (103, 203); +SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; +((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL +0 +0 +DROP TABLE t1, t2; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index d076ca6bd33..b5279331a5f 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2987,4 +2987,19 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1; SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1; DROP TABLE t1,t2; +# +# Bug #31884: Assertion + crash in subquery in the SELECT clause. +# + +CREATE TABLE t1 (a1 INT, a2 INT); +CREATE TABLE t2 (b1 INT, b2 INT); + +INSERT INTO t1 VALUES (100, 200); +INSERT INTO t1 VALUES (101, 201); +INSERT INTO t2 VALUES (101, 201); +INSERT INTO t2 VALUES (103, 203); + +SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; +DROP TABLE t1, t2; + --echo End of 5.0 tests. diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 118609671b8..51dcd3ca175 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -306,6 +306,7 @@ public: double val_real(); String *val_str(String*); my_decimal *val_decimal(my_decimal *); + void update_null_value () { (void) val_bool(); } bool val_bool(); void top_level_item() { abort_on_null=1; } inline bool is_top_level_item() { return abort_on_null; } From 5a09edd203ea125b846af82935b7d7e5da430435 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Tue, 30 Oct 2007 15:39:50 +0300 Subject: [PATCH 038/128] Fix failing init_connect.test (5.1-runtime). --- sql/sql_connect.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index afd97c27a55..c4367b2a8fb 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1030,7 +1030,17 @@ static void prepare_new_connection_state(THD* thd) if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL)) { execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); - if (thd->net.report_error) + /* + execute_init_command calls net_send_error. + If there was an error during execution of the init statements, + the error at this moment is present in thd->net.last_error and also + thd->is_slave_error and thd->net.report_error are set. + net_send_error sends the contents of thd->net.last_error and + clears thd->net.report_error. It doesn't, however, clean + thd->is_slave_error or thd->net.last_error. Here we make use of this + fact. + */ + if (thd->is_slave_error) { thd->killed= THD::KILL_CONNECTION; sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), From e4b353c40c551e4ac0832dd0106219e7e0b716ba Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Tue, 30 Oct 2007 20:08:16 +0300 Subject: [PATCH 039/128] Use an inline getter method (thd->is_error()) to query if there is an error in THD. In future the error may be stored elsewhere (not in net.report_error) and it's important to start using an opaque getter to simplify merges. --- sql/filesort.cc | 4 ++-- sql/ha_ndbcluster_binlog.cc | 2 +- sql/item_func.cc | 4 ++-- sql/item_subselect.cc | 2 +- sql/set_var.cc | 2 +- sql/sp.cc | 2 +- sql/sp_head.cc | 6 +++--- sql/sql_base.cc | 10 +++++----- sql/sql_class.cc | 4 ++-- sql/sql_class.h | 16 +++++++++++++++- sql/sql_connect.cc | 6 +++--- sql/sql_delete.cc | 8 ++++---- sql/sql_insert.cc | 12 ++++++------ sql/sql_parse.cc | 22 +++++++++++----------- sql/sql_prepare.cc | 2 +- sql/sql_select.cc | 30 +++++++++++++++--------------- sql/sql_union.cc | 2 +- sql/sql_update.cc | 6 +++--- sql/sql_view.cc | 6 +++--- sql/sql_yacc.yy | 4 ++-- 20 files changed, 82 insertions(+), 68 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index c074f90e780..2e6f0ecaf05 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -555,7 +555,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, else file->unlock_row(); /* It does not make sense to read more keys in case of a fatal error */ - if (thd->net.report_error) + if (thd->is_error()) break; } if (quick_select) @@ -573,7 +573,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, file->ha_rnd_end(); } - if (thd->net.report_error) + if (thd->is_error()) DBUG_RETURN(HA_POS_ERROR); /* Signal we should use orignal column read and write maps */ diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index c22d5ac53f5..fc35a7a930e 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -271,7 +271,7 @@ static void run_query(THD *thd, char *buf, char *end, sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d", buf, thd->net.last_error, thd->net.last_errno, thd_ndb->m_error_code, - thd->net.report_error, thd->is_slave_error); + (int) thd->is_error(), thd->is_slave_error); } thd->options= save_thd_options; diff --git a/sql/item_func.cc b/sql/item_func.cc index 64574a9ad74..2d4d61de61b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -187,7 +187,7 @@ Item_func::fix_fields(THD *thd, Item **ref) } } fix_length_and_dec(); - if (thd->net.report_error) // An error inside fix_length_and_dec occured + if (thd->is_error()) // An error inside fix_length_and_dec occured return TRUE; fixed= 1; return FALSE; @@ -4073,7 +4073,7 @@ my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val) NOTES For now it always return OK. All problem with value evaluating - will be caught by thd->net.report_error check in sql_set_variables(). + will be caught by thd->is_error() check in sql_set_variables(). RETURN FALSE OK. diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 843c6ced263..8eb7421f854 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -248,7 +248,7 @@ bool Item_subselect::exec() { int res; - if (thd->net.report_error) + if (thd->is_error()) /* Do not execute subselect in case of a fatal error */ return 1; diff --git a/sql/set_var.cc b/sql/set_var.cc index 138c71fa559..11874b1020c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3051,7 +3051,7 @@ int sql_set_variables(THD *thd, List *var_list) if ((error= var->check(thd))) goto err; } - if (!(error= test(thd->net.report_error))) + if (!(error= test(thd->is_error()))) { it.rewind(); while ((var= it++)) diff --git a/sql/sp.cc b/sql/sp.cc index 1b5d8ca87b8..b4f0ec7729b 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1866,7 +1866,7 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, an error with it's return value without calling my_error(), we set the generic "mysql.proc table corrupt" error here. */ - if (!thd->net.report_error) + if (! thd->is_error()) { /* SP allows full NAME_LEN chars thus he have to allocate enough diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f7ab9bac3b1..6e8749aa745 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -370,7 +370,7 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) thd->abort_on_warning= save_abort_on_warning; thd->transaction.stmt.modified_non_trans_table= save_stmt_modified_non_trans_table; - if (thd->net.report_error) + if (thd->is_error()) { /* Return error status if something went wrong. */ err_status= TRUE; @@ -1277,7 +1277,7 @@ sp_head::execute(THD *thd) done: DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d", err_status, thd->killed, thd->is_slave_error, - thd->net.report_error)); + thd->is_error())); if (thd->killed) err_status= TRUE; @@ -2673,7 +2673,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, cleanup_items() is called in sp_head::execute() */ - DBUG_RETURN(res || thd->net.report_error); + DBUG_RETURN(res || thd->is_error()); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 10e6716cadf..223485f1e42 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6260,7 +6260,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, thd->lex->allow_sum_func= save_allow_sum_func; thd->mark_used_columns= save_mark_used_columns; DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); - DBUG_RETURN(test(thd->net.report_error)); + DBUG_RETURN(test(thd->is_error())); } @@ -6804,7 +6804,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, select_lex->conds_processed_with_permanent_arena= 1; } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; - DBUG_RETURN(test(thd->net.report_error)); + DBUG_RETURN(test(thd->is_error())); err_no_arena: select_lex->is_item_list_lookup= save_is_item_list_lookup; @@ -6886,7 +6886,7 @@ fill_record(THD * thd, List &fields, List &values, goto err; } } - DBUG_RETURN(thd->net.report_error); + DBUG_RETURN(thd->is_error()); err: if (table) table->auto_increment_field_not_null= FALSE; @@ -6971,7 +6971,7 @@ fill_record(THD *thd, Field **ptr, List &values, bool ignore_errors) table= (*ptr)->table; table->auto_increment_field_not_null= FALSE; } - while ((field = *ptr++) && !thd->net.report_error) + while ((field = *ptr++) && ! thd->is_error()) { value=v++; table= field->table; @@ -6980,7 +6980,7 @@ fill_record(THD *thd, Field **ptr, List &values, bool ignore_errors) if (value->save_in_field(field, 0) < 0) goto err; } - DBUG_RETURN(thd->net.report_error); + DBUG_RETURN(thd->is_error()); err: if (table) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d77e531ec13..707c8e83007 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1368,7 +1368,7 @@ bool select_send::send_data(List &items) thd->sent_row_count++; if (!thd->vio_ok()) DBUG_RETURN(0); - if (!thd->net.report_error) + if (! thd->is_error()) DBUG_RETURN(protocol->write()); protocol->remove_last_row(); DBUG_RETURN(1); @@ -1389,7 +1389,7 @@ bool select_send::send_eof() mysql_unlock_tables(thd, thd->lock); thd->lock=0; } - if (!thd->net.report_error) + if (! thd->is_error()) { ::send_eof(thd); status= 0; diff --git a/sql/sql_class.h b/sql/sql_class.h index a7f196cd825..a3e71e183f3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1468,7 +1468,7 @@ public: bool in_lock_tables; /** True if a slave error. Causes the slave to stop. Not the same - as the statement execution error (net.report_error), since + as the statement execution error (is_error()), since a statement may be expected to return an error, e.g. because it returned an error on master, and this is OK on the slave. */ @@ -1716,6 +1716,20 @@ public: net.report_error= 1; DBUG_PRINT("error",("Fatal error set")); } + /** + TRUE if there is an error in the error stack. + + Please use this method instead of direct access to + net.report_error. + + If TRUE, the current (sub)-statement should be aborted. + The main difference between this member and is_fatal_error + is that a fatal error can not be handled by a stored + procedure continue handler, whereas a normal error can. + + To raise this flag, use my_error(). + */ + inline bool is_error() const { return net.report_error; } inline CHARSET_INFO *charset() { return variables.character_set_client; } void update_charset(); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index afd97c27a55..006cca4ee90 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -975,12 +975,12 @@ void end_connection(THD *thd) decrease_user_connections(thd->user_connect); if (thd->killed || - net->error && net->vio != 0 && net->report_error) + net->error && net->vio != 0 && thd->is_error()) { statistic_increment(aborted_threads,&LOCK_status); } - if (net->error && net->vio != 0 && net->report_error) + if (net->error && net->vio != 0 && thd->is_error()) { if (!thd->killed && thd->variables.log_warnings > 1) { @@ -1030,7 +1030,7 @@ static void prepare_new_connection_state(THD* thd) if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL)) { execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); - if (thd->net.report_error) + if (thd->is_error()) { thd->killed= THD::KILL_CONNECTION; sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4c57fad8d87..219dc90429b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -252,10 +252,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, table->mark_columns_needed_for_delete(); while (!(error=info.read_record(&info)) && !thd->killed && - !thd->net.report_error) + ! thd->is_error()) { - // thd->net.report_error is tested to disallow delete row on error - if (!(select && select->skip_record())&& !thd->net.report_error ) + // thd->is_error() is tested to disallow delete row on error + if (!(select && select->skip_record())&& ! thd->is_error() ) { if (table->triggers && @@ -389,7 +389,7 @@ cleanup: send_ok(thd, (ha_rows) thd->row_count_func); DBUG_PRINT("info",("%ld records deleted",(long) deleted)); } - DBUG_RETURN(error >= 0 || thd->net.report_error); + DBUG_RETURN(error >= 0 || thd->is_error()); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e868afede51..077141c4d7a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -738,7 +738,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, table->triggers, TRG_EVENT_INSERT)) { - if (values_list.elements != 1 && !thd->net.report_error) + if (values_list.elements != 1 && ! thd->is_error()) { info.records++; continue; @@ -769,7 +769,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, table->triggers, TRG_EVENT_INSERT)) { - if (values_list.elements != 1 && ! thd->net.report_error) + if (values_list.elements != 1 && ! thd->is_error()) { info.records++; continue; @@ -1909,7 +1909,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) thd->proc_info="got old table"; if (di->thd.killed) { - if (di->thd.net.report_error) + if (di->thd.is_error()) { /* Copy the error message. Note that we don't treat fatal @@ -1940,7 +1940,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) pthread_mutex_unlock(&di->mutex); if (table_list->table) { - DBUG_ASSERT(thd->net.report_error == 0); + DBUG_ASSERT(! thd->is_error()); thd->di= di; } /* Unlock the delayed insert object after its last access. */ @@ -1949,7 +1949,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) end_create: pthread_mutex_unlock(&LOCK_delayed_create); - DBUG_RETURN(thd->net.report_error); + DBUG_RETURN(thd->is_error()); } @@ -3015,7 +3015,7 @@ bool select_insert::send_data(List &values) thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields store_values(values); thd->count_cuted_fields= CHECK_FIELD_IGNORE; - if (thd->net.report_error) + if (thd->is_error()) DBUG_RETURN(1); if (table_list) // Not CREATE ... SELECT { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e6d953bcbe1..ac042960388 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -436,7 +436,7 @@ pthread_handler_t handle_bootstrap(void *arg) if (thd->is_fatal_error) break; - if (thd->net.report_error) + if (thd->is_error()) { /* The query failed, send error to log and abort bootstrap */ net_send_error(thd); @@ -990,7 +990,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, mysql_parse(thd, thd->query, thd->query_length, & found_semicolon); - while (!thd->killed && found_semicolon && !thd->net.report_error) + while (!thd->killed && found_semicolon && ! thd->is_error()) { char *next_packet= (char*) found_semicolon; net->no_send_error= 0; @@ -1355,9 +1355,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->transaction.xid_state.xid.null(); /* report error issued during command execution */ - if (thd->killed_errno() && !thd->net.report_error) + if (thd->killed_errno() && ! thd->is_error()) thd->send_kill_message(); - if (thd->net.report_error) + if (thd->is_error()) net_send_error(thd); log_slow_statement(thd); @@ -3930,7 +3930,7 @@ create_sp_error: thd->row_count_func)); else { - DBUG_ASSERT(thd->net.report_error == 1 || thd->killed); + DBUG_ASSERT(thd->is_error() || thd->killed); goto error; // Substatement should already have sent error } } @@ -4523,7 +4523,7 @@ finish: */ start_waiting_global_read_lock(thd); } - DBUG_RETURN(res || thd->net.report_error); + DBUG_RETURN(res || thd->is_error()); } @@ -5467,7 +5467,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, else #endif { - if (! thd->net.report_error) + if (! thd->is_error()) { /* Binlog logs a string starting from thd->query and having length @@ -5491,7 +5491,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, } else { - DBUG_ASSERT(thd->net.report_error); + DBUG_ASSERT(thd->is_error()); DBUG_PRINT("info",("Command aborted. Fatal_error: %d", thd->is_fatal_error)); @@ -6311,7 +6311,7 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List *using_fields, RETURN 0 ok - !=0 error. thd->killed or thd->net.report_error is set + !=0 error. thd->killed or thd->is_error() is set */ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, @@ -7274,10 +7274,10 @@ bool parse_sql(THD *thd, bool mysql_parse_status= MYSQLparse(thd) != 0; - /* Check that if MYSQLparse() failed, thd->net.report_error is set. */ + /* Check that if MYSQLparse() failed, thd->is_error() is set. */ DBUG_ASSERT(!mysql_parse_status || - mysql_parse_status && thd->net.report_error); + mysql_parse_status && thd->is_error()); /* Reset Lex_input_stream. */ diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index a6cdcf14881..b1b1502f015 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2864,7 +2864,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) lex_start(thd); error= parse_sql(thd, &lip, NULL) || - thd->net.report_error || + thd->is_error() || init_param_array(this); lex->set_trg_event_type_for_tables(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fd0ce630a01..ef1151d82f3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -263,8 +263,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, result, unit, select_lex); } DBUG_PRINT("info",("res: %d report_error: %d", res, - thd->net.report_error)); - res|= thd->net.report_error; + thd->is_error())); + res|= thd->is_error(); if (unlikely(res)) result->abort(); @@ -491,7 +491,7 @@ JOIN::prepare(Item ***rref_pointer_array, (having->fix_fields(thd, &having) || having->check_cols(1))); select_lex->having_fix_field= 0; - if (having_fix_rc || thd->net.report_error) + if (having_fix_rc || thd->is_error()) DBUG_RETURN(-1); /* purecov: inspected */ thd->lex->allow_sum_func= save_allow_sum_func; } @@ -817,7 +817,7 @@ JOIN::optimize() } conds= optimize_cond(this, conds, join_list, &cond_value); - if (thd->net.report_error) + if (thd->is_error()) { error= 1; DBUG_PRINT("error",("Error from optimize_cond")); @@ -826,7 +826,7 @@ JOIN::optimize() { having= optimize_cond(this, having, join_list, &having_value); - if (thd->net.report_error) + if (thd->is_error()) { error= 1; DBUG_PRINT("error",("Error from optimize_cond")); @@ -1031,7 +1031,7 @@ JOIN::optimize() { ORDER *org_order= order; order=remove_const(this, order,conds,1, &simple_order); - if (thd->net.report_error) + if (thd->is_error()) { error= 1; DBUG_PRINT("error",("Error from remove_const")); @@ -1162,7 +1162,7 @@ JOIN::optimize() group_list= remove_const(this, (old_group_list= group_list), conds, rollup.state == ROLLUP::STATE_NONE, &simple_group); - if (thd->net.report_error) + if (thd->is_error()) { error= 1; DBUG_PRINT("error",("Error from remove_const")); @@ -1185,7 +1185,7 @@ JOIN::optimize() { group_list= procedure->group= remove_const(this, procedure->group, conds, 1, &simple_group); - if (thd->net.report_error) + if (thd->is_error()) { error= 1; DBUG_PRINT("error",("Error from remove_const")); @@ -2098,10 +2098,10 @@ JOIN::exec() } } } - /* XXX: When can we have here thd->net.report_error not zero? */ - if (thd->net.report_error) + /* XXX: When can we have here thd->is_error() not zero? */ + if (thd->is_error()) { - error= thd->net.report_error; + error= thd->is_error(); DBUG_VOID_RETURN; } curr_join->having= curr_join->tmp_having; @@ -2307,7 +2307,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, join->having_history= (join->having?join->having:join->tmp_having); } - if (thd->net.report_error) + if (thd->is_error()) goto err; join->exec(); @@ -2333,7 +2333,7 @@ err: { thd->proc_info="end"; err|= select_lex->cleanup(); - DBUG_RETURN(err || thd->net.report_error); + DBUG_RETURN(err || thd->is_error()); } DBUG_RETURN(join->error); } @@ -10717,7 +10717,7 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) DBUG_PRINT("error",("Error: do_select() failed")); } #endif - DBUG_RETURN(join->thd->net.report_error ? -1 : rc); + DBUG_RETURN(join->thd->is_error() ? -1 : rc); } @@ -16050,7 +16050,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) first->options | thd->options | SELECT_DESCRIBE, result, unit, first); } - DBUG_RETURN(res || thd->net.report_error); + DBUG_RETURN(res || thd->is_error()); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5da4b97cc5d..a48cff82715 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -58,7 +58,7 @@ bool select_union::send_data(List &values) return 0; } fill_record(thd, table->field, values, 1); - if (thd->net.report_error) + if (thd->is_error()) return 1; if ((error= table->file->ha_write_row(table->record[0]))) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4071bb86c90..036d7e06d0e 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -844,7 +844,7 @@ int mysql_update(THD *thd, } thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ thd->abort_on_warning= 0; - DBUG_RETURN((error >= 0 || thd->net.report_error) ? 1 : 0); + DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0); err: delete select; @@ -1193,8 +1193,8 @@ bool mysql_multi_update(THD *thd, OPTION_SETUP_TABLES_DONE, result, unit, select_lex); DBUG_PRINT("info",("res: %d report_error: %d", res, - thd->net.report_error)); - res|= thd->net.report_error; + (int) thd->is_error())); + res|= thd->is_error(); if (unlikely(res)) { /* If we had a another error reported earlier then this will be ignored */ diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6e27af63e8a..f7223cafb5e 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -607,7 +607,7 @@ err: thd->proc_info= "end"; lex->link_first_table_back(view, link_to_local); unit->cleanup(); - DBUG_RETURN(res || thd->net.report_error); + DBUG_RETURN(res || thd->is_error()); } @@ -823,7 +823,7 @@ loop_out: view_parameters + revision_number_position, 1, &file_parser_dummy_hook)) { - error= thd->net.report_error? -1 : 0; + error= thd->is_error() ? -1 : 0; goto err; } } @@ -886,7 +886,7 @@ loop_out: if (sql_create_definition_file(&dir, &file, view_file_type, (uchar*)view, view_parameters, num_view_backups)) { - error= thd->net.report_error? -1 : 1; + error= thd->is_error() ? -1 : 1; goto err; } DBUG_RETURN(0); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 109e8f5434f..b893014aacb 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9804,7 +9804,7 @@ NUM_literal: | DECIMAL_NUM { $$= new Item_decimal($1.str, $1.length, YYTHD->charset()); - if (YYTHD->net.report_error) + if (YYTHD->is_error()) { MYSQL_YYABORT; } @@ -9812,7 +9812,7 @@ NUM_literal: | FLOAT_NUM { $$ = new Item_float($1.str, $1.length); - if (YYTHD->net.report_error) + if (YYTHD->is_error()) { MYSQL_YYABORT; } From 230604f33c12b760694473af51ffae59fd4c9536 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Tue, 30 Oct 2007 22:35:14 +0300 Subject: [PATCH 040/128] In ha_delete_table, use a standard mechanism to intercept the error message and convert it to a warning instead of direct manipulation with the thread error stack. Fix a bug in handler::print_erorr when a garbled message was printed for HA_ERR_NO_SUCH_TABLE. This is a pre-requisite patch for the fix for Bug#12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem --- sql/handler.cc | 72 +++++++++++++++++++++++++++++++----------------- sql/log.cc | 3 +- sql/mysqld.cc | 2 +- sql/sql_base.cc | 3 +- sql/sql_class.cc | 4 +-- sql/sql_class.h | 3 +- sql/sql_error.cc | 2 +- 7 files changed, 56 insertions(+), 33 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 3ba52ca1c71..22374d57e99 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1414,6 +1414,36 @@ static const char *check_lowercase_names(handler *file, const char *path, } +/** + An interceptor to hijack the text of the error message without + setting an error in the thread. We need the text to present it + in the form of a warning to the user. +*/ + +struct Ha_delete_table_error_handler: public Internal_error_handler +{ +public: + virtual bool handle_error(uint sql_errno, + const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd); + char buff[MYSQL_ERRMSG_SIZE]; +}; + + +bool +Ha_delete_table_error_handler:: +handle_error(uint sql_errno, + const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd) +{ + /* Grab the error message */ + strmake(buff, message, sizeof(buff)-1); + return TRUE; +} + + /** @brief This should return ENOENT if the file doesn't exists. The .frm file will be deleted only if we return 0 or ENOENT @@ -1442,23 +1472,11 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, { /* Because file->print_error() use my_error() to generate the error message - we must store the error state in thd, reset it and restore it to - be able to get hold of the error message. - (We should in the future either rewrite handler::print_error() or make - a nice method of this. + we use an internal error handler to intercept it and store the text + in a temporary buffer. Later the message will be presented to user + as a warning. */ - bool is_slave_error= thd->is_slave_error; - sp_rcontext *spcont= thd->spcont; - SELECT_LEX *current_select= thd->lex->current_select; - char buff[sizeof(thd->net.last_error)]; - char new_error[sizeof(thd->net.last_error)]; - int last_errno= thd->net.last_errno; - - strmake(buff, thd->net.last_error, sizeof(buff)-1); - thd->is_slave_error= 0; - thd->spcont= NULL; - thd->lex->current_select= 0; - thd->net.last_error[0]= 0; + Ha_delete_table_error_handler ha_delete_table_error_handler; /* Fill up strucutures that print_error may need */ dummy_share.path.str= (char*) path; @@ -1471,16 +1489,18 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, file->table_share= &dummy_share; file->table= &dummy_table; - file->print_error(error, 0); - strmake(new_error, thd->net.last_error, sizeof(buff)-1); - /* restore thd */ - thd->is_slave_error= is_slave_error; - thd->spcont= spcont; - thd->lex->current_select= current_select; - thd->net.last_errno= last_errno; - strmake(thd->net.last_error, buff, sizeof(buff)-1); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, new_error); + thd->push_internal_handler(&ha_delete_table_error_handler); + file->print_error(error, 0); + + thd->pop_internal_handler(); + + /* + XXX: should we convert *all* errors to warnings here? + What if the error is fatal? + */ + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, + ha_delete_table_error_handler.buff); } delete file; DBUG_RETURN(error); @@ -2203,7 +2223,7 @@ void handler::print_error(int error, myf errflag) case HA_ERR_NO_SUCH_TABLE: my_error(ER_NO_SUCH_TABLE, MYF(0), table_share->db.str, table_share->table_name.str); - break; + DBUG_VOID_RETURN; case HA_ERR_RBR_LOGGING_FAILED: textno= ER_BINLOG_ROW_LOGGING_FAILED; break; diff --git a/sql/log.cc b/sql/log.cc index 02986bef493..688ed03d5d1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -72,13 +72,14 @@ public: virtual ~Silence_log_table_errors() {} - virtual bool handle_error(uint sql_errno, + virtual bool handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level, THD *thd); }; bool Silence_log_table_errors::handle_error(uint /* sql_errno */, + const char * /* message */, MYSQL_ERROR::enum_warning_level /* level */, THD * /* thd */) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index cc964e417bf..c76bd8bd712 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2583,7 +2583,7 @@ int my_message_sql(uint error, const char *str, myf MyFlags) TODO: There are two exceptions mechanism (THD and sp_rcontext), this could be improved by having a common stack of handlers. */ - if (thd->handle_error(error, + if (thd->handle_error(error, str, MYSQL_ERROR::WARN_LEVEL_ERROR)) DBUG_RETURN(0); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 223485f1e42..2584390d756 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -44,7 +44,7 @@ public: virtual ~Prelock_error_handler() {} - virtual bool handle_error(uint sql_errno, + virtual bool handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level, THD *thd); @@ -58,6 +58,7 @@ private: bool Prelock_error_handler::handle_error(uint sql_errno, + const char * /* message */, MYSQL_ERROR::enum_warning_level /* level */, THD * /* thd */) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 707c8e83007..b5a29783044 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -498,12 +498,12 @@ void THD::push_internal_handler(Internal_error_handler *handler) } -bool THD::handle_error(uint sql_errno, +bool THD::handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level) { if (m_internal_handler) { - return m_internal_handler->handle_error(sql_errno, level, this); + return m_internal_handler->handle_error(sql_errno, message, level, this); } return FALSE; // 'FALSE', as per coding style diff --git a/sql/sql_class.h b/sql/sql_class.h index a3e71e183f3..db847c814a0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -969,6 +969,7 @@ public: @return true if the error is handled */ virtual bool handle_error(uint sql_errno, + const char *message, MYSQL_ERROR::enum_warning_level level, THD *thd) = 0; }; @@ -1923,7 +1924,7 @@ public: @param level the error level @return true if the error is handled */ - virtual bool handle_error(uint sql_errno, + virtual bool handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level); /** diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 8bdb2e59ed5..89cff73d153 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -137,7 +137,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, level= MYSQL_ERROR::WARN_LEVEL_ERROR; } - if (thd->handle_error(code, level)) + if (thd->handle_error(code, msg, level)) DBUG_RETURN(NULL); if (thd->spcont && From 756a86f06d9a8722657e6ea3d7386da538990c84 Mon Sep 17 00:00:00 2001 From: "davi@endora.local" <> Date: Tue, 30 Oct 2007 20:51:04 -0200 Subject: [PATCH 041/128] Bug#30904 SET PASSWORD statement is non-transactional The SET PASSWORD statement is non-transactional (no explicit transaction boundaries) in nature and hence is forbidden inside stored functions and triggers, but it weren't being effectively forbidden. The implemented fix is to issue a implicit commit with every SET PASSWORD statement, effectively prohibiting these statements in stored functions and triggers. --- mysql-test/r/sp-error.result | 10 ++++++++++ mysql-test/t/sp-error.test | 19 +++++++++++++++++++ sql/sql_lex.h | 2 +- sql/sql_parse.cc | 4 ++++ sql/sql_yacc.yy | 8 ++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 1b14d75cd9c..300fa42f3ad 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1523,3 +1523,13 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SELECT ..inexistent(); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.inexistent()' at line 1 USE test; +create function f1() returns int +begin +set @test = 1, password = password('foo'); +return 1; +end| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger +create trigger t1 +before insert on t2 for each row set password = password('foo'); +delimiter ;| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index a956a246770..9f20d02480c 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2222,6 +2222,25 @@ SELECT .inexistent(); SELECT ..inexistent(); USE test; +# +# Bug#30904 SET PASSWORD statement is non-transactional +# + +delimiter |; + +--error ER_SP_CANT_SET_AUTOCOMMIT +create function f1() returns int +begin + set @test = 1, password = password('foo'); + return 1; +end| + +--error ER_SP_CANT_SET_AUTOCOMMIT +create trigger t1 + before insert on t2 for each row set password = password('foo'); + +delimiter ;| + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a26c4fd1ca0..507d64daf89 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1616,7 +1616,7 @@ typedef struct st_lex : public Query_tables_list uint8 create_view_algorithm; uint8 create_view_check; bool drop_if_exists, drop_temporary, local_file, one_shot_set; - + bool autocommit; bool verbose, no_write_to_binlog; bool tx_chain, tx_release; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ac042960388..85457fea41b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3053,6 +3053,10 @@ end_with_restore_list: case SQLCOM_SET_OPTION: { List *lex_var_list= &lex->var_list; + + if (lex->autocommit && end_active_trans(thd)) + goto error; + if ((check_table_access(thd, SELECT_ACL, all_tables, 0) || open_and_lock_tables(thd, all_tables))) goto error; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b893014aacb..69cd7060778 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -10516,6 +10516,7 @@ set: lex->option_type=OPT_SESSION; lex->var_list.empty(); lex->one_shot_set= 0; + lex->autocommit= 0; } option_value_list {} @@ -10558,6 +10559,7 @@ option_type_value: lex->option_type=OPT_SESSION; lex->var_list.empty(); lex->one_shot_set= 0; + lex->autocommit= 0; lex->sphead->m_tmp_query= lip->get_tok_start(); } } @@ -10799,10 +10801,16 @@ option_value: user->host=null_lex_str; user->user.str=thd->security_ctx->priv_user; thd->lex->var_list.push_back(new set_var_password(user, $3)); + thd->lex->autocommit= TRUE; + if (lex->sphead) + lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } | PASSWORD FOR_SYM user equal text_or_password { Lex->var_list.push_back(new set_var_password($3,$5)); + Lex->autocommit= TRUE; + if (Lex->sphead) + Lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } ; From 4852cc7fc412f7bfcc7b1504ef9e015b2c6bf391 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Wed, 31 Oct 2007 09:53:58 +0300 Subject: [PATCH 042/128] Fix result files after patch for BUG#31035. --- mysql-test/r/group_min_max.result | 4 ++-- mysql-test/r/index_merge_myisam.result | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 02b1459afd0..f62fd662a5d 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2251,7 +2251,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +2 SUBQUERY t1 range NULL a 5 NULL 8 EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra @@ -2268,7 +2268,7 @@ AND t1_outer1.b = t1_outer2.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer -2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +2 SUBQUERY t1 range NULL a 5 NULL 8 EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 9d7d06f7f1b..ebeba53fdfa 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -286,7 +286,7 @@ NULL UNION RESULT ALL NULL NULL NULL NULL NULL explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 -2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where; Using index +2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where create table t3 like t0; insert into t3 select * from t0; alter table t3 add key9 int not null, add index i9(key9); From 62d2ee935e5038b805a368c5eb2f0a30adce1c29 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Wed, 31 Oct 2007 12:04:19 +0300 Subject: [PATCH 043/128] Fix for a BUG#31649: events.test fails: NULL "state" field of SHOW PROCESSLIST. The problem was a race condition: if the Event Scheduler was not quick enough, the following scenario happens: - The Event Scheduler picks up the created event; - The event is executed; - event_scheduler_thread->proc_info is set to NULL; - The client issues SELECT FROM I_S. The fix is to wait for the Event Scheduler to reach 'Waiting for next activation' state. --- mysql-test/t/events.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test index d1ca5f1b609..a4c7eaebc30 100644 --- a/mysql-test/t/events.test +++ b/mysql-test/t/events.test @@ -454,7 +454,8 @@ create event закачка on schedule every 10 hour do select get_lock("test_l --echo "Should have only 2 processes: the scheduler and the locked event" let $wait_condition= select count(*) = 2 from information_schema.processlist where ( (state like 'User lock%' AND info like 'select get_lock%') - OR (command='Daemon' AND user='event_scheduler')); + OR (command='Daemon' AND user='event_scheduler' AND + state = 'Waiting for next activation')); --source include/wait_condition.inc select /*2*/ user, host, db, command, state, info From 8549a8ea8fd2f1f7a64772bac35db839c9ed6618 Mon Sep 17 00:00:00 2001 From: "thek@adventure.(none)" <> Date: Wed, 31 Oct 2007 12:25:18 +0100 Subject: [PATCH 044/128] Bug#31347 Increase in memory usage after many DROP USER statements Dropping users causes huge increase in memory usage because field values were allocated on the server memory root for temporary usage but never deallocated. This patch changes the target memory root to be that of the thread handler instead since this root is cleared between each statement. --- sql/sql_acl.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6bc6cce5e72..d03aacd7f07 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -311,7 +311,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) continue; } - const char *password= get_field(&mem, table->field[2]); + const char *password= get_field(thd->mem_root, table->field[2]); uint password_len= password ? strlen(password) : 0; set_user_salt(&user, password, password_len); if (user.salt_len == 0 && password_len != 0) @@ -364,7 +364,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) /* Starting from 4.0.2 we have more fields */ if (table->s->fields >= 31) { - char *ssl_type=get_field(&mem, table->field[next_field++]); + char *ssl_type=get_field(thd->mem_root, table->field[next_field++]); if (!ssl_type) user.ssl_type=SSL_TYPE_NONE; else if (!strcmp(ssl_type, "ANY")) @@ -378,11 +378,11 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) user.x509_issuer= get_field(&mem, table->field[next_field++]); user.x509_subject= get_field(&mem, table->field[next_field++]); - char *ptr = get_field(&mem, table->field[next_field++]); + char *ptr = get_field(thd->mem_root, table->field[next_field++]); user.user_resource.questions=ptr ? atoi(ptr) : 0; - ptr = get_field(&mem, table->field[next_field++]); + ptr = get_field(thd->mem_root, table->field[next_field++]); user.user_resource.updates=ptr ? atoi(ptr) : 0; - ptr = get_field(&mem, table->field[next_field++]); + ptr = get_field(thd->mem_root, table->field[next_field++]); user.user_resource.conn_per_hour= ptr ? atoi(ptr) : 0; if (user.user_resource.questions || user.user_resource.updates || user.user_resource.conn_per_hour) @@ -391,7 +391,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) if (table->s->fields >= 36) { /* Starting from 5.0.3 we have max_user_connections field */ - ptr= get_field(&mem, table->field[next_field++]); + ptr= get_field(thd->mem_root, table->field[next_field++]); user.user_resource.user_conn= ptr ? atoi(ptr) : 0; } else @@ -4865,6 +4865,7 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, byte user_key[MAX_KEY_LENGTH]; uint key_prefix_length; DBUG_ENTER("handle_grant_table"); + THD *thd= current_thd; if (! table_no) // mysql.user table { @@ -4932,17 +4933,18 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, DBUG_PRINT("info",("scan error: %d", error)); continue; } - if (! (host= get_field(&mem, host_field))) + if (! (host= get_field(thd->mem_root, host_field))) host= ""; - if (! (user= get_field(&mem, user_field))) + if (! (user= get_field(thd->mem_root, user_field))) user= ""; #ifdef EXTRA_DEBUG DBUG_PRINT("loop",("scan fields: '%s'@'%s' '%s' '%s' '%s'", user, host, - get_field(&mem, table->field[1]) /*db*/, - get_field(&mem, table->field[3]) /*table*/, - get_field(&mem, table->field[4]) /*column*/)); + get_field(thd->mem_root, table->field[1]) /*db*/, + get_field(thd->mem_root, table->field[3]) /*table*/, + get_field(thd->mem_root, + table->field[4]) /*column*/)); #endif if (strcmp(user_str, user) || my_strcasecmp(system_charset_info, host_str, host)) From edbf4120f6da3bd39fd3464f27b8a53bee525d10 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Wed, 31 Oct 2007 16:01:29 +0400 Subject: [PATCH 045/128] Bug #31893 Partitions: crash if subpartitions and engine change. The new default database engine for altered table was reassigned to the old one. That's wrong thing by itself, and (as the engine for a subpartition gets that new value) leads to DBUG_ASSERTION in mysql_unpack_partition() --- mysql-test/r/partition.result | 14 ++++++++++++++ mysql-test/t/partition.test | 11 +++++++++++ sql/sql_partition.cc | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 4e4bd0bbc0a..e39e84fdd69 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1291,4 +1291,18 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */ drop table t1, t2; +create table t1 (int_column int, char_column char(5)) +PARTITION BY RANGE (int_column) subpartition by key (char_column) +(PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); +Warnings: +Warning 1286 Unknown table engine 'InnoDB' +alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) +(PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `int_column` int(11) DEFAULT NULL, + `char_column` char(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) SUBPARTITION BY KEY (char_column) (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 2906b4640cd..82a8759e910 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1528,4 +1528,15 @@ PARTITION BY RANGE (b) ( show create table t1; drop table t1, t2; +# +# Bug #31893 Partitions: crash if subpartitions and engine change +# +create table t1 (int_column int, char_column char(5)) + PARTITION BY RANGE (int_column) subpartition by key (char_column) + (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); +alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) + (PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); +show create table t1; +drop table t1; + --echo End of 5.1 tests diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 0cc2cac2a1a..e5466599429 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5031,7 +5031,10 @@ the generated partition syntax in a correct manner. *partition_changed= TRUE; } if (create_info->db_type == partition_hton) - part_info->default_engine_type= table->part_info->default_engine_type; + { + if (!part_info->default_engine_type) + part_info->default_engine_type= table->part_info->default_engine_type; + } else part_info->default_engine_type= create_info->db_type; if (check_native_partitioned(create_info, &is_native_partitioned, From 96f8d086f8dc002fdbbde589e0abaf045d53a07d Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Wed, 31 Oct 2007 17:16:53 +0300 Subject: [PATCH 046/128] Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT. No functionality added or changed. This is a pre-requisite for the fix for Bug#12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem Address post-review comments. --- include/sql_common.h | 6 +- libmysql/libmysql.c | 152 +++++++++++++++++++------------------------ libmysqld/lib_sql.cc | 22 +++---- sql-common/client.c | 148 +++++++++++++++++++---------------------- 4 files changed, 144 insertions(+), 184 deletions(-) diff --git a/include/sql_common.h b/include/sql_common.h index 80504140fae..56e7305130f 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -36,8 +36,10 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const unsigned char *arg, ulong arg_length, my_bool skip_check, MYSQL_STMT *stmt); unsigned long cli_safe_read(MYSQL *mysql); -void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, - const char *sqlstate); +void net_clear_error(NET *net); +void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net); +void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate, + const char *err); void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate); #ifdef __cplusplus } diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e2e42fe4a2d..76928ec798c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -686,9 +686,7 @@ int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd) if (my_net_write(net, (uchar*) buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) { - net->last_errno= CR_SERVER_LOST; - strmov(net->sqlstate, unknown_sqlstate); - strmov(net->last_error,ER(net->last_errno)); + set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate); return 1; } /* Read what server thinks about out new auth message report */ @@ -860,8 +858,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) /* copy filename into local memory and allocate read buffer */ if (!(buf=my_malloc(packet_length, MYF(0)))) { - strmov(net->sqlstate, unknown_sqlstate); - strmov(net->last_error, ER(net->last_errno=CR_OUT_OF_MEMORY)); + set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); DBUG_RETURN(1); } @@ -887,9 +884,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) { DBUG_PRINT("error", ("Lost connection to MySQL server during LOAD DATA of local file")); - strmov(net->sqlstate, unknown_sqlstate); - net->last_errno=CR_SERVER_LOST; - strmov(net->last_error,ER(net->last_errno)); + set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate); goto err; } } @@ -897,9 +892,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) /* Send empty packet to mark end of file */ if (my_net_write(net, (const uchar*) "", 0) || net_flush(net)) { - strmov(net->sqlstate, unknown_sqlstate); - net->last_errno=CR_SERVER_LOST; - sprintf(net->last_error,ER(net->last_errno),errno); + set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate); goto err; } @@ -1400,9 +1393,7 @@ const char *cli_read_statistics(MYSQL *mysql) mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ if (!mysql->net.read_pos[0]) { - strmov(mysql->net.sqlstate, unknown_sqlstate); - mysql->net.last_errno=CR_WRONG_HOST_INFO; - strmov(mysql->net.last_error, ER(mysql->net.last_errno)); + set_mysql_error(mysql, CR_WRONG_HOST_INFO, unknown_sqlstate); return mysql->net.last_error; } return (char*) mysql->net.read_pos; @@ -1848,24 +1839,17 @@ static my_bool my_realloc_str(NET *net, ulong length) if (buf_length + length > net->max_packet) { res= net_realloc(net, buf_length + length); + if (res) + { + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error, ER(net->last_errno)); + } net->write_pos= net->buff+ buf_length; } DBUG_RETURN(res); } -/* Clear possible error statee of struct NET */ - -static void net_clear_error(NET *net) -{ - if (net->last_errno) - { - net->last_errno= 0; - net->last_error[0]= '\0'; - strmov(net->sqlstate, not_error_sqlstate); - } -} - static void stmt_clear_error(MYSQL_STMT *stmt) { if (stmt->last_errno) @@ -1876,18 +1860,21 @@ static void stmt_clear_error(MYSQL_STMT *stmt) } } -/* +/** Set statement error code, sqlstate, and error message from given errcode and sqlstate. */ -static void set_stmt_error(MYSQL_STMT * stmt, int errcode, - const char *sqlstate) +void set_stmt_error(MYSQL_STMT * stmt, int errcode, + const char *sqlstate, const char *err) { DBUG_ENTER("set_stmt_error"); DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode))); DBUG_ASSERT(stmt != 0); + if (err == 0) + err= ER(errcode); + stmt->last_errno= errcode; strmov(stmt->last_error, ER(errcode)); strmov(stmt->sqlstate, sqlstate); @@ -1896,21 +1883,24 @@ static void set_stmt_error(MYSQL_STMT * stmt, int errcode, } -/* - Set statement error code, sqlstate, and error message. +/** + Set statement error code, sqlstate, and error message from NET. + + @param stmt a statement handle. Copy the error here. + @param net mysql->net. Source of the error. */ -void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, - const char *sqlstate) +void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net) { DBUG_ENTER("set_stmt_errmsg"); - DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err)); + DBUG_PRINT("enter", ("error: %d/%s '%s'", net->last_errno, net->sqlstate, + net->last_error)); DBUG_ASSERT(stmt != 0); - stmt->last_errno= errcode; - if (err && err[0]) - strmov(stmt->last_error, err); - strmov(stmt->sqlstate, sqlstate); + stmt->last_errno= net->last_errno; + if (net->last_error && net->last_error[0]) + strmov(stmt->last_error, net->last_error); + strmov(stmt->sqlstate, net->sqlstate); DBUG_VOID_RETURN; } @@ -2085,7 +2075,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) if (!mysql) { /* mysql can be reset in mysql_close called from mysql_reconnect */ - set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -2123,23 +2113,20 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) stmt->state= MYSQL_STMT_INIT_DONE; if (stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt)) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } } if (stmt_command(mysql, COM_STMT_PREPARE, (const uchar*) query, length, stmt)) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } if ((*mysql->methods->read_prepare_result)(mysql, stmt)) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } @@ -2154,7 +2141,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) (stmt->param_count + stmt->field_count)))) { - set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); + set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL); DBUG_RETURN(1); } stmt->bind= stmt->params + stmt->param_count; @@ -2284,7 +2271,7 @@ mysql_stmt_result_metadata(MYSQL_STMT *stmt) if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result), MYF(MY_WME | MY_ZEROFILL)))) { - set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); + set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL); DBUG_RETURN(0); } @@ -2517,7 +2504,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) */ if ((my_realloc_str(net, *param->length))) { - set_stmt_error(stmt, net->last_errno, unknown_sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } (*param->store_param_func)(net, param); @@ -2554,7 +2541,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) stmt->insert_id= mysql->insert_id; if (res) { - set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -2577,13 +2564,13 @@ int cli_stmt_execute(MYSQL_STMT *stmt) if (!stmt->bind_param_done) { - set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate); + set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate, NULL); DBUG_RETURN(1); } if (mysql->status != MYSQL_STATUS_READY || mysql->server_status & SERVER_MORE_RESULTS_EXISTS) { - set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -2592,7 +2579,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt) null_count= (stmt->param_count+7) /8; if (my_realloc_str(net, null_count + 1)) { - set_stmt_error(stmt, net->last_errno, unknown_sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } bzero((char*) net->write_pos, null_count); @@ -2605,7 +2592,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt) { if (my_realloc_str(net, 2 * stmt->param_count)) { - set_stmt_error(stmt, net->last_errno, unknown_sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } /* @@ -2628,7 +2615,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt) /* TODO: Look into avoding the following memdup */ if (!(param_data= my_memdup(net->buff, length, MYF(0)))) { - set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); + set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL); DBUG_RETURN(1); } result= execute(stmt, param_data, length); @@ -2692,20 +2679,19 @@ static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row) */ if (!mysql) { - set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); return 1; } if (mysql->status != MYSQL_STATUS_GET_RESULT) { set_stmt_error(stmt, stmt->unbuffered_fetch_cancelled ? CR_FETCH_CANCELED : CR_COMMANDS_OUT_OF_SYNC, - unknown_sqlstate); + unknown_sqlstate, NULL); goto error; } if ((*mysql->methods->unbuffered_fetch)(mysql, (char**) row)) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); /* If there was an error, there are no more pending rows: reset statement status to not hang up in following @@ -2766,7 +2752,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) buff, sizeof(buff), (uchar*) 0, 0, 1, NULL)) { - set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); + set_stmt_errmsg(stmt, net); return 1; } if ((*mysql->methods->read_rows_from_cursor)(stmt)) @@ -2797,7 +2783,7 @@ static int stmt_read_row_no_result_set(MYSQL_STMT *stmt __attribute__((unused)), unsigned char **row __attribute__((unused))) { - set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate); + set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate, NULL); return 1; } @@ -2847,7 +2833,7 @@ my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, } return FALSE; err_not_implemented: - set_stmt_error(stmt, CR_NOT_IMPLEMENTED, unknown_sqlstate); + set_stmt_error(stmt, CR_NOT_IMPLEMENTED, unknown_sqlstate, NULL); return TRUE; } @@ -3232,7 +3218,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *my_bind) { if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE) { - set_stmt_error(stmt, CR_NO_PREPARE_STMT, unknown_sqlstate); + set_stmt_error(stmt, CR_NO_PREPARE_STMT, unknown_sqlstate, NULL); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -3397,7 +3383,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, */ if (param_number >= stmt->param_count) { - set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate); + set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -3433,8 +3419,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, buff, sizeof(buff), (uchar*) data, length, 1, NULL)) { - set_stmt_errmsg(stmt, mysql->net.last_error, - mysql->net.last_errno, mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } } @@ -3903,7 +3888,8 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, if (field->flags & ZEROFILL_FLAG && length < field->length && field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1) { - bmove_upp((char*) buff + field->length, buff + length, length); + bmove_upp((uchar*) buff + field->length, (uchar*) buff + length, + length); bfill((char*) buff, field->length - length, '0'); length= field->length; } @@ -4502,7 +4488,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *my_bind) { int errorcode= (int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE ? CR_NO_PREPARE_STMT : CR_NO_STMT_METADATA; - set_stmt_error(stmt, errorcode, unknown_sqlstate); + set_stmt_error(stmt, errorcode, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -4682,12 +4668,12 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *my_bind, if ((int) stmt->state < (int) MYSQL_STMT_FETCH_DONE) { - set_stmt_error(stmt, CR_NO_DATA, unknown_sqlstate); + set_stmt_error(stmt, CR_NO_DATA, unknown_sqlstate, NULL); return 1; } if (column >= stmt->field_count) { - set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate); + set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -4733,7 +4719,7 @@ int cli_read_binary_rows(MYSQL_STMT *stmt) if (!mysql) { - set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -4748,7 +4734,7 @@ int cli_read_binary_rows(MYSQL_STMT *stmt) if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc, sizeof(MYSQL_ROWS) + pkt_len - 1))) { - set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); + set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL); goto err; } cur->data= (MYSQL_ROW) (cur+1); @@ -4769,7 +4755,7 @@ int cli_read_binary_rows(MYSQL_STMT *stmt) DBUG_RETURN(0); } } - set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); + set_stmt_errmsg(stmt, net); err: DBUG_RETURN(1); @@ -4836,7 +4822,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if ((int) stmt->state < (int) MYSQL_STMT_EXECUTE_DONE) { - set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -4856,13 +4842,13 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, NULL)) { - set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } } else if (mysql->status != MYSQL_STATUS_GET_RESULT) { - set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate, NULL); DBUG_RETURN(1); } @@ -5043,8 +5029,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags) if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff, sizeof(buff), 0, 0, 0, NULL)) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); stmt->state= MYSQL_STMT_INIT_DONE; return 1; } @@ -5117,8 +5102,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) int4store(buff, stmt->stmt_id); if ((rc= stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt))) { - set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, - mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); } } } @@ -5139,7 +5123,7 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) if (!stmt->mysql) { /* mysql can be reset in mysql_close called from mysql_reconnect */ - set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); DBUG_RETURN(1); } /* Reset the client and server sides of the prepared statement */ @@ -5243,15 +5227,11 @@ int STDCALL mysql_next_result(MYSQL *mysql) if (mysql->status != MYSQL_STATUS_READY) { - strmov(mysql->net.sqlstate, unknown_sqlstate); - strmov(mysql->net.last_error, - ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); DBUG_RETURN(1); } - mysql->net.last_error[0]= 0; - mysql->net.last_errno= 0; - strmov(mysql->net.sqlstate, not_error_sqlstate); + net_clear_error(&mysql->net); mysql->affected_rows= ~(my_ulonglong) 0; if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 4e525f8447f..13847c324e1 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -81,8 +81,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, /* Check that we are calling the client functions in right order */ if (mysql->status != MYSQL_STATUS_READY) { - strmov(net->last_error, - ER(net->last_errno=CR_COMMANDS_OUT_OF_SYNC)); + set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); return 1; } @@ -90,7 +89,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, thd->clear_error(); mysql->affected_rows= ~(my_ulonglong) 0; mysql->field_count= 0; - net->last_errno= 0; + net_clear_error(net); thd->current_stmt= stmt; thd->store_globals(); // Fix if more than one connect @@ -245,8 +244,7 @@ static my_bool emb_read_query_result(MYSQL *mysql) mysql->fields= res->embedded_info->fields_list; mysql->affected_rows= res->embedded_info->affected_rows; mysql->insert_id= res->embedded_info->insert_id; - mysql->net.last_errno= 0; - mysql->net.last_error[0]= 0; + net_clear_error(&mysql->net); mysql->info= 0; if (res->embedded_info->info[0]) @@ -288,7 +286,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) if (res) { NET *net= &stmt->mysql->net; - set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -299,14 +297,12 @@ int emb_read_binary_rows(MYSQL_STMT *stmt) MYSQL_DATA *data; if (!(data= emb_read_rows(stmt->mysql, 0, 0))) { - set_stmt_errmsg(stmt, stmt->mysql->net.last_error, - stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate); + set_stmt_errmsg(stmt, &stmt->mysql->net); return 1; } stmt->result= *data; my_free((char *) data, MYF(0)); - set_stmt_errmsg(stmt, stmt->mysql->net.last_error, - stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate); + set_stmt_errmsg(stmt, &stmt->mysql->net); return 0; } @@ -320,16 +316,14 @@ int emb_read_rows_from_cursor(MYSQL_STMT *stmt) if (res->embedded_info->last_errno) { embedded_get_error(mysql, res); - set_stmt_errmsg(stmt, mysql->net.last_error, - mysql->net.last_errno, mysql->net.sqlstate); + set_stmt_errmsg(stmt, &mysql->net); return 1; } thd->cur_data= res; mysql->warning_count= res->embedded_info->warning_count; mysql->server_status= res->embedded_info->server_status; - mysql->net.last_errno= 0; - mysql->net.last_error[0]= 0; + net_clear_error(&mysql->net); return emb_read_binary_rows(stmt); } diff --git a/sql-common/client.c b/sql-common/client.c index baf154dcc43..a6e02376a40 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -312,42 +312,34 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, break; if (GetLastError() != ERROR_PIPE_BUSY) { - net->last_errno=CR_NAMEDPIPEOPEN_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), host, unix_socket, - (ulong) GetLastError()); + set_mysql_extended_error(mysql, CR_NAMEDPIPEOPEN_ERROR, + unknown_sqlstate, ER(CR_NAMEDPIPEOPEN_ERROR), + host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } /* wait for for an other instance */ if (! WaitNamedPipe(pipe_name, connect_timeout*1000) ) { - net->last_errno=CR_NAMEDPIPEWAIT_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), host, unix_socket, - (ulong) GetLastError()); + set_mysql_extended_error(mysql, CR_NAMEDPIPEWAIT_ERROR, unknown_sqlstate, + ER(CR_NAMEDPIPEWAIT_ERROR), + host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } } if (hPipe == INVALID_HANDLE_VALUE) { - net->last_errno=CR_NAMEDPIPEOPEN_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), host, unix_socket, - (ulong) GetLastError()); + set_mysql_extended_error(mysql, CR_NAMEDPIPEOPEN_ERROR, unknown_sqlstate, + ER(CR_NAMEDPIPEOPEN_ERROR), host, unix_socket, + (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } dwMode = PIPE_READMODE_BYTE | PIPE_WAIT; if ( !SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL) ) { CloseHandle( hPipe ); - net->last_errno=CR_NAMEDPIPESETSTATE_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno),host, unix_socket, - (ulong) GetLastError()); + set_mysql_extended_error(mysql, CR_NAMEDPIPESETSTATE_ERROR, + unknown_sqlstate, ER(CR_NAMEDPIPESETSTATE_ERROR), + host, unix_socket, (ulong) GetLastError()); return INVALID_HANDLE_VALUE; } *arg_host=host ; *arg_unix_socket=unix_socket; /* connect arg */ @@ -566,14 +558,12 @@ err: CloseHandle(handle_connect_file_map); if (error_allow) { - net->last_errno=error_allow; - strmov(net->sqlstate, unknown_sqlstate); if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR) - my_snprintf(net->last_error,sizeof(net->last_error)-1, - ER(net->last_errno),suffix_pos,error_code); + set_mysql_extended_error(mysql, error_allow, unknown_sqlstate, + ER(error_allow), suffix_pos, error_code); else - my_snprintf(net->last_error,sizeof(net->last_error)-1, - ER(net->last_errno),error_code); + set_mysql_extended_error(mysql, error_allow, unknown_sqlstate, + ER(error_allow), error_code); return(INVALID_HANDLE_VALUE); } return(handle_map); @@ -683,10 +673,8 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, DBUG_RETURN(1); } - net->last_error[0]=0; - net->last_errno= 0; - strmov(net->sqlstate, not_error_sqlstate); - mysql->net.report_error=0; + net_clear_error(net); + net->report_error=0; mysql->info=0; mysql->affected_rows= ~(my_ulonglong) 0; /* @@ -703,8 +691,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, socket_errno)); if (net->last_errno == ER_NET_PACKET_TOO_LARGE) { - net->last_errno=CR_NET_PACKET_TOO_LARGE; - strmov(net->last_error,ER(net->last_errno)); + set_mysql_error(mysql, CR_NET_PACKET_TOO_LARGE, unknown_sqlstate); goto end; } end_server(mysql); @@ -713,8 +700,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, if (net_write_command(net,(uchar) command, header, header_length, arg, arg_length)) { - net->last_errno=CR_SERVER_GONE_ERROR; - strmov(net->last_error,ER(net->last_errno)); + set_mysql_error(mysql, CR_SERVER_GONE_ERROR, unknown_sqlstate); goto end; } } @@ -760,6 +746,19 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate) DBUG_VOID_RETURN; } +/** + Clear possible error state of struct NET + + @param net clear the state of the argument +*/ + +void net_clear_error(NET *net) +{ + net->last_errno= 0; + net->last_error[0]= '\0'; + strmov(net->sqlstate, not_error_sqlstate); +} + static void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate, @@ -846,9 +845,8 @@ static int check_license(MYSQL *mysql) { if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) { - net->last_errno= CR_WRONG_LICENSE; - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), required_license); + set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, + ER(CR_WRONG_LICENSE), required_license); } return 1; } @@ -864,9 +862,8 @@ static int check_license(MYSQL *mysql) (!row || !row[0] || strncmp(row[0], required_license, sizeof(required_license)))) { - net->last_errno= CR_WRONG_LICENSE; - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), required_license); + set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, + ER(CR_WRONG_LICENSE), required_license); } mysql_free_result(res); return net->last_errno; @@ -1761,24 +1758,22 @@ int mysql_init_character_set(MYSQL *mysql) } charsets_dir= save; } - + if (!mysql->charset) { - net->last_errno=CR_CANT_READ_CHARSET; - strmov(net->sqlstate, unknown_sqlstate); if (mysql->options.charset_dir) - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - mysql->options.charset_dir); + set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate, + ER(CR_CANT_READ_CHARSET), + mysql->options.charset_name, + mysql->options.charset_dir); else { char cs_dir_name[FN_REFLEN]; get_charsets_dir(cs_dir_name); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - cs_dir_name); + set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate, + ER(CR_CANT_READ_CHARSET), + mysql->options.charset_name, + cs_dir_name); } return 1; } @@ -1910,10 +1905,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, DBUG_PRINT("info",("Using UNIX sock '%s'",unix_socket)); if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) { - net->last_errno=CR_SOCKET_CREATE_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error,sizeof(net->last_error)-1, - ER(net->last_errno),socket_errno); + set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR, + unknown_sqlstate, + ER(CR_SOCKET_CREATE_ERROR), + socket_errno); goto error; } net->vio= vio_new(sock, VIO_TYPE_SOCKET, @@ -1926,10 +1921,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { DBUG_PRINT("error",("Got error %d on connect to local server", socket_errno)); - net->last_errno=CR_CONNECTION_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error,sizeof(net->last_error)-1, - ER(net->last_errno),unix_socket,socket_errno); + set_mysql_extended_error(mysql, CR_CONNECTION_ERROR, + unknown_sqlstate, + ER(CR_CONNECTION_ERROR), + unix_socket, socket_errno); goto error; } mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; @@ -1986,10 +1981,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, #endif if (sock == SOCKET_ERROR) { - net->last_errno=CR_IPSOCK_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error,sizeof(net->last_error)-1, - ER(net->last_errno),socket_errno); + set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate, + ER(CR_IPSOCK_ERROR), socket_errno); goto error; } net->vio= vio_new(sock, VIO_TYPE_TCPIP, VIO_BUFFERED_READ); @@ -2014,10 +2007,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!hp) { my_gethostbyname_r_free(); - net->last_errno=CR_UNKNOWN_HOST; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(CR_UNKNOWN_HOST), host, tmp_errno); + set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate, + ER(CR_UNKNOWN_HOST), host, tmp_errno); goto error; } memcpy(&sock_addr.sin_addr, hp->h_addr, @@ -2030,10 +2021,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno, host)); - net->last_errno= CR_CONN_HOST_ERROR; - strmov(net->sqlstate, unknown_sqlstate); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(CR_CONN_HOST_ERROR), host, socket_errno); + set_mysql_extended_error(mysql, CR_CONN_HOST_ERROR, unknown_sqlstate, + ER(CR_CONN_HOST_ERROR), host, socket_errno); goto error; } } @@ -2097,11 +2086,9 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, PROTOCOL_VERSION, mysql->protocol_version)); if (mysql->protocol_version != PROTOCOL_VERSION) { - strmov(net->sqlstate, unknown_sqlstate); - net->last_errno= CR_VERSION_ERROR; - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(CR_VERSION_ERROR), mysql->protocol_version, - PROTOCOL_VERSION); + set_mysql_extended_error(mysql, CR_VERSION_ERROR, unknown_sqlstate, + ER(CR_VERSION_ERROR), mysql->protocol_version, + PROTOCOL_VERSION); goto error; } end=strend((char*) net->read_pos+1); @@ -2625,7 +2612,7 @@ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)), for (; element; element= element->next) { MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; - set_stmt_errmsg(stmt, buff, CR_STMT_CLOSED, unknown_sqlstate); + set_stmt_error(stmt, CR_STMT_CLOSED, unknown_sqlstate, buff); stmt->mysql= 0; /* No need to call list_delete for statement here */ } @@ -3142,11 +3129,8 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name) { char cs_dir_name[FN_REFLEN]; get_charsets_dir(cs_dir_name); - mysql->net.last_errno= CR_CANT_READ_CHARSET; - strmov(mysql->net.sqlstate, unknown_sqlstate); - my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error) - 1, - ER(mysql->net.last_errno), cs_name, cs_dir_name); - + set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate, + ER(CR_CANT_READ_CHARSET), cs_name, cs_dir_name); } charsets_dir= save_csdir; return mysql->net.last_errno; From 3154b2bee4dc99b3313081effe2ac9c4c4a487f9 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Wed, 31 Oct 2007 18:33:13 +0300 Subject: [PATCH 047/128] Cleanup: rename select_send::status to select_send::is_result_set_started. Add select_send::cleanup. Fix a compilation warning. Issues spotted while working on the fix for Bug#12713. --- sql-common/client.c | 1 - sql/sql_class.cc | 30 ++++++++++++++++++++++-------- sql/sql_class.h | 10 ++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index a6e02376a40..e92a9bd0cdc 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1714,7 +1714,6 @@ static MYSQL_METHODS client_methods= C_MODE_START int mysql_init_character_set(MYSQL *mysql) { - NET *net= &mysql->net; const char *default_collation_name; /* Set character set */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b5a29783044..a904023cbff 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1305,23 +1305,26 @@ bool select_send::send_fields(List &list, uint flags) { bool res; if (!(res= thd->protocol->send_fields(&list, flags))) - status= 1; + is_result_set_started= 1; return res; } void select_send::abort() { DBUG_ENTER("select_send::abort"); - if (status && thd->spcont && + if (is_result_set_started && thd->spcont && thd->spcont->find_handler(thd, thd->net.last_errno, MYSQL_ERROR::WARN_LEVEL_ERROR)) { /* - Executing stored procedure without a handler. - Here we should actually send an error to the client, - but as an error will break a multiple result set, the only thing we - can do for now is to nicely end the current data set and remembering - the error so that the calling routine will abort + We're executing a stored procedure, have an open result + set, an SQL exception conditiona and a handler for it. + In this situation we must abort the current statement, + silence the error and start executing the continue/exit + handler. + Before aborting the statement, let's end the open result set, as + otherwise the client will hang due to the violation of the + client/server protocol. */ thd->net.report_error= 0; send_eof(); @@ -1331,6 +1334,17 @@ void select_send::abort() } +/** + Cleanup an instance of this class for re-use + at next execution of a prepared statement/ + stored procedure statement. +*/ + +void select_send::cleanup() +{ + is_result_set_started= FALSE; +} + /* Send data to client. Returns 0 if ok */ bool select_send::send_data(List &items) @@ -1392,7 +1406,7 @@ bool select_send::send_eof() if (! thd->is_error()) { ::send_eof(thd); - status= 0; + is_result_set_started= 0; return 0; } else diff --git a/sql/sql_class.h b/sql/sql_class.h index db847c814a0..632c440266f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2051,14 +2051,20 @@ public: class select_send :public select_result { - int status; + /** + True if we have sent result set metadata to the client. + In this case the client always expects us to end the result + set with an eof or error packet + */ + bool is_result_set_started; public: - select_send() :status(0) {} + select_send() :is_result_set_started(FALSE) {} bool send_fields(List &list, uint flags); bool send_data(List &items); bool send_eof(); virtual bool check_simple_select() const { return FALSE; } void abort(); + virtual void cleanup(); }; From 8620673f932f62c8c9fbf74b8551ccd4c4a2b8ac Mon Sep 17 00:00:00 2001 From: "davi@endora.local/endora" <> Date: Wed, 31 Oct 2007 13:54:53 -0200 Subject: [PATCH 048/128] Post merge fix for bug 31669. --- tests/mysql_client_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 808d6fe30de..0cb9ff49128 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -17112,8 +17112,8 @@ static void test_bug31669() int rc; static char buff[LARGE_BUFFER_SIZE+1]; #ifndef EMBEDDED_LIBRARY - static char user[USERNAME_LENGTH+1]; - static char db[NAME_LEN+1]; + static char user[USERNAME_CHAR_LENGTH+1]; + static char db[NAME_CHAR_LEN+1]; static char query[LARGE_BUFFER_SIZE*2]; #endif @@ -17136,13 +17136,13 @@ static void test_bug31669() #ifndef EMBEDDED_LIBRARY memset(db, 'a', sizeof(db)); - db[NAME_LEN]= 0; + db[NAME_CHAR_LEN]= 0; strxmov(query, "CREATE DATABASE IF NOT EXISTS ", db, NullS); rc= mysql_query(mysql, query); myquery(rc); memset(user, 'b', sizeof(user)); - user[USERNAME_LENGTH]= 0; + user[USERNAME_CHAR_LENGTH]= 0; memset(buff, 'c', sizeof(buff)); buff[LARGE_BUFFER_SIZE]= 0; strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'%' IDENTIFIED BY " @@ -17156,21 +17156,21 @@ static void test_bug31669() rc= mysql_change_user(mysql, user, buff, db); DIE_UNLESS(!rc); - user[USERNAME_LENGTH-1]= 'a'; + user[USERNAME_CHAR_LENGTH-1]= 'a'; rc= mysql_change_user(mysql, user, buff, db); DIE_UNLESS(rc); - user[USERNAME_LENGTH-1]= 'b'; + user[USERNAME_CHAR_LENGTH-1]= 'b'; buff[LARGE_BUFFER_SIZE-1]= 'd'; rc= mysql_change_user(mysql, user, buff, db); DIE_UNLESS(rc); buff[LARGE_BUFFER_SIZE-1]= 'c'; - db[NAME_LEN-1]= 'e'; + db[NAME_CHAR_LEN-1]= 'e'; rc= mysql_change_user(mysql, user, buff, db); DIE_UNLESS(rc); - db[NAME_LEN-1]= 'a'; + db[NAME_CHAR_LEN-1]= 'a'; rc= mysql_change_user(mysql, user, buff, db); DIE_UNLESS(!rc); From c26aef8fc6a026808fc41f78c55440bfe7c5a008 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Wed, 31 Oct 2007 23:48:41 +0300 Subject: [PATCH 049/128] Try to fix a Windows compilation warning. --- sql-common/client.c | 125 +++++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index e92a9bd0cdc..5ece9c39d6c 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -272,6 +272,76 @@ static int wait_for_data(my_socket fd, uint timeout) } #endif /* defined(__WIN__) || defined(__NETWARE__) */ +/** + Set the internal error message to mysql handler + + @param mysql connection handle (client side) + @param errcode CR_ error code, passed to ER macro to get + error text + @parma sqlstate SQL standard sqlstate +*/ + +void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate) +{ + NET *net; + DBUG_ENTER("set_mysql_error"); + DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode))); + DBUG_ASSERT(mysql != 0); + + net= &mysql->net; + net->last_errno= errcode; + strmov(net->last_error, ER(errcode)); + strmov(net->sqlstate, sqlstate); + + DBUG_VOID_RETURN; +} + +/** + Clear possible error state of struct NET + + @param net clear the state of the argument +*/ + +void net_clear_error(NET *net) +{ + net->last_errno= 0; + net->last_error[0]= '\0'; + strmov(net->sqlstate, not_error_sqlstate); +} + +/** + Set an error message on the client. + + @param mysql connection handle + @param errcode CR_* errcode, for client errors + @param sqlstate SQL standard sql state, unknown_sqlstate for the + majority of client errors. + @param format error message template, in sprintf format + @param ... variable number of arguments +*/ + +static void set_mysql_extended_error(MYSQL *mysql, int errcode, + const char *sqlstate, + const char *format, ...) +{ + NET *net; + va_list args; + DBUG_ENTER("set_mysql_extended_error"); + DBUG_PRINT("enter", ("error :%d '%s'", errcode, format)); + DBUG_ASSERT(mysql != 0); + + net= &mysql->net; + net->last_errno= errcode; + va_start(args, format); + my_vsnprintf(net->last_error, sizeof(net->last_error)-1, + format, args); + va_end(args); + strmov(net->sqlstate, sqlstate); + + DBUG_VOID_RETURN; +} + + /* Create a named pipe connection @@ -727,61 +797,6 @@ void free_old_query(MYSQL *mysql) DBUG_VOID_RETURN; } -/* - Set the internal error message to mysql handler -*/ - -void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate) -{ - NET *net; - DBUG_ENTER("set_mysql_error"); - DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode))); - DBUG_ASSERT(mysql != 0); - - net= &mysql->net; - net->last_errno= errcode; - strmov(net->last_error, ER(errcode)); - strmov(net->sqlstate, sqlstate); - - DBUG_VOID_RETURN; -} - -/** - Clear possible error state of struct NET - - @param net clear the state of the argument -*/ - -void net_clear_error(NET *net) -{ - net->last_errno= 0; - net->last_error[0]= '\0'; - strmov(net->sqlstate, not_error_sqlstate); -} - - -static void set_mysql_extended_error(MYSQL *mysql, int errcode, - const char *sqlstate, - const char *format, ...) -{ - NET *net; - va_list args; - DBUG_ENTER("set_mysql_extended_error"); - DBUG_PRINT("enter", ("error :%d '%s'", errcode, format)); - DBUG_ASSERT(mysql != 0); - - net= &mysql->net; - net->last_errno= errcode; - va_start(args, format); - my_vsnprintf(net->last_error, sizeof(net->last_error)-1, - format, args); - va_end(args); - strmov(net->sqlstate, sqlstate); - - DBUG_VOID_RETURN; -} - - /* Flush result set sent from server */ From c0bb7f8682cd11ad9fc9915781c8447ac2818094 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 00:10:58 +0300 Subject: [PATCH 050/128] Remove net_printf_error(). Do not talk to network directly in check_user()/check_connection()/check_for_max_user_connections(). This is a pre-requisite patch for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem" Implement review comments. --- sql/mysql_priv.h | 1 - sql/mysqld.cc | 6 +- sql/protocol.cc | 120 +---------------------------- sql/protocol.h | 1 - sql/sql_connect.cc | 183 +++++++++++++++++++++++++-------------------- sql/sql_parse.cc | 5 -- 6 files changed, 108 insertions(+), 208 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3b88fe0fca8..3484b8096e3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -920,7 +920,6 @@ bool init_new_connection_handler_thread(); void reset_mqh(LEX_USER *lu, bool get_them); bool check_mqh(THD *thd, uint check_command); void time_out_user_resource_limits(THD *thd, USER_CONN *uc); -int check_for_max_user_connections(THD *thd, USER_CONN *uc); void decrease_user_connections(USER_CONN *uc); void thd_init_client_charset(THD *thd, uint cs_number); bool setup_connection_thread_globals(THD *thd); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c76bd8bd712..4cf6e05751f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4302,6 +4302,7 @@ void create_thread_to_handle_connection(THD *thd) } else { + char error_message_buff[MYSQL_ERRMSG_SIZE]; /* Create new thread to handle connection */ int error; thread_created++; @@ -4320,7 +4321,10 @@ void create_thread_to_handle_connection(THD *thd) thd->killed= THD::KILL_CONNECTION; // Safety (void) pthread_mutex_unlock(&LOCK_thread_count); statistic_increment(aborted_connects,&LOCK_status); - net_printf_error(thd, ER_CANT_CREATE_THREAD, error); + /* Can't use my_error() since store_globals has not been called. */ + my_snprintf(error_message_buff, sizeof(error_message_buff), + ER(ER_CANT_CREATE_THREAD), error); + net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff); (void) pthread_mutex_lock(&LOCK_thread_count); close_connection(thd,0,0); delete thd; diff --git a/sql/protocol.cc b/sql/protocol.cc index 51d408de9de..bf8faec006a 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -58,7 +58,7 @@ bool Protocol_binary::net_store_data(const uchar *from, size_t length) Design note: - net_printf_error and net_send_error are low-level functions + net_send_error is a low-level functions that shall be used only when a new connection is being established or at server startup. For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's @@ -120,124 +120,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) DBUG_VOID_RETURN; } -/* - Write error package and flush to client - It's a little too low level, but I don't want to use another buffer for - this - - Design note: - - net_printf_error and net_send_error are low-level functions - that shall be used only when a new connection is being - established or at server startup. - For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's - critical that every error that can be intercepted is issued in one - place only, my_message_sql. -*/ - -void -net_printf_error(THD *thd, uint errcode, ...) -{ - va_list args; - uint length,offset; - const char *format; -#ifndef EMBEDDED_LIBRARY - const char *text_pos; - int head_length= NET_HEADER_SIZE; -#else - char text_pos[1024]; -#endif - NET *net= &thd->net; - - DBUG_ENTER("net_printf_error"); - DBUG_PRINT("enter",("message: %u",errcode)); - - DBUG_ASSERT(!thd->spcont); - - if (net && net->no_send_error) - { - thd->clear_error(); - thd->is_fatal_error= 0; // Error message is given - DBUG_PRINT("info", ("sending error messages prohibited")); - DBUG_VOID_RETURN; - } - - thd->is_slave_error= 1; // needed to catch query errors during replication -#ifndef EMBEDDED_LIBRARY - query_cache_abort(net); // Safety -#endif - va_start(args,errcode); - /* - The following is needed to make net_printf_error() work with 0 argument - for errorcode and use the argument after that as the format string. This - is useful for rare errors that are not worth the hassle to put in - errmsg.sys, but at the same time, the message is not fixed text - */ - if (errcode) - format= ER(errcode); - else - { - format=va_arg(args,char*); - errcode= ER_UNKNOWN_ERROR; - } - offset= (net->return_errno ? - ((thd->client_capabilities & CLIENT_PROTOCOL_41) ? - 2+SQLSTATE_LENGTH+1 : 2) : 0); -#ifndef EMBEDDED_LIBRARY - text_pos=(char*) net->buff + head_length + offset + 1; - length= (uint) ((char*)net->buff_end - text_pos); -#else - length=sizeof(text_pos)-1; -#endif - length=my_vsnprintf(my_const_cast(char*) (text_pos), - min(length, sizeof(net->last_error)), - format,args); - va_end(args); - - /* Replication slave relies on net->last_* to see if there was error */ - net->last_errno= errcode; - strmake(net->last_error, text_pos, sizeof(net->last_error)-1); - -#ifndef EMBEDDED_LIBRARY - if (net->vio == 0) - { - if (thd->bootstrap) - { - /* - In bootstrap it's ok to print on stderr - This may also happen when we get an error from a slave thread - */ - fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos); - thd->fatal_error(); - } - DBUG_VOID_RETURN; - } - - int3store(net->buff,length+1+offset); - net->buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); - net->buff[head_length]=(uchar) 255; // Error package - if (offset) - { - uchar *pos= net->buff+head_length+1; - int2store(pos, errcode); - if (thd->client_capabilities & CLIENT_PROTOCOL_41) - { - pos[2]= '#'; /* To make the protocol backward compatible */ - memcpy(pos+3, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH); - } - } - VOID(net_real_write(net, net->buff, length+head_length+1+offset)); -#else - net->last_errno= errcode; - strmake(net->last_error, text_pos, length); - strmake(net->sqlstate, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH); -#endif - if (thd->killed != THD::KILL_CONNECTION) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, errcode, - text_pos ? text_pos : ER(errcode)); - thd->is_fatal_error=0; // Error message is given - DBUG_VOID_RETURN; -} /* Return ok to the client. diff --git a/sql/protocol.h b/sql/protocol.h index 46a2b6d36b6..53584326f03 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -172,7 +172,6 @@ public: }; void send_warning(THD *thd, uint sql_errno, const char *err=0); -void net_printf_error(THD *thd, uint sql_errno, ...); void net_send_error(THD *thd, uint sql_errno=0, const char *err=0); void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 8a817e5993a..9b5f1a9b0e5 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -87,7 +87,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, my_malloc(sizeof(struct user_conn) + temp_len+1, MYF(MY_WME))))) { - net_send_error(thd, 0, NullS); // Out of memory + /* MY_WME ensures an error is set in THD. */ return_val= 1; goto end; } @@ -100,8 +100,8 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->reset_utime= thd->thr_create_utime; if (my_hash_insert(&hash_user_connections, (uchar*) uc)) { + /* The only possible error is out of memory, MY_WME sets an error. */ my_free((char*) uc,0); - net_send_error(thd, 0, NullS); // Out of memory return_val= 1; goto end; } @@ -132,6 +132,7 @@ end: 1 error */ +static int check_for_max_user_connections(THD *thd, USER_CONN *uc) { int error=0; @@ -141,7 +142,7 @@ int check_for_max_user_connections(THD *thd, USER_CONN *uc) if (max_user_connections && !uc->user_resources.user_conn && max_user_connections < (uint) uc->connections) { - net_printf_error(thd, ER_TOO_MANY_USER_CONNECTIONS, uc->user); + my_error(ER_TOO_MANY_USER_CONNECTIONS, MYF(0), uc->user); error=1; goto end; } @@ -149,24 +150,24 @@ int check_for_max_user_connections(THD *thd, USER_CONN *uc) if (uc->user_resources.user_conn && uc->user_resources.user_conn < uc->connections) { - net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, - "max_user_connections", - (long) uc->user_resources.user_conn); + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, + "max_user_connections", + (long) uc->user_resources.user_conn); error= 1; goto end; } if (uc->user_resources.conn_per_hour && uc->user_resources.conn_per_hour <= uc->conn_per_hour) { - net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, - "max_connections_per_hour", - (long) uc->user_resources.conn_per_hour); + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, + "max_connections_per_hour", + (long) uc->user_resources.conn_per_hour); error=1; goto end; } uc->conn_per_hour++; - end: +end: if (error) uc->connections--; // no need for decrease_user_connections() here (void) pthread_mutex_unlock(&LOCK_user_conn); @@ -258,8 +259,8 @@ bool check_mqh(THD *thd, uint check_command) if (uc->user_resources.questions && uc->questions++ >= uc->user_resources.questions) { - net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions", - (long) uc->user_resources.questions); + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_questions", + (long) uc->user_resources.questions); error=1; goto end; } @@ -270,8 +271,8 @@ bool check_mqh(THD *thd, uint check_command) (sql_command_flags[check_command] & CF_CHANGES_DATA) && uc->updates++ >= uc->user_resources.updates) { - net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates", - (long) uc->user_resources.updates); + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_updates", + (long) uc->user_resources.updates); error=1; goto end; } @@ -284,33 +285,33 @@ end: #endif /* NO_EMBEDDED_ACCESS_CHECKS */ -/* - Check if user exist and password supplied is correct. +/** + Check if user exist and password supplied is correct. - SYNOPSIS - check_user() - thd thread handle, thd->security_ctx->{host,user,ip} are used - command originator of the check: now check_user is called - during connect and change user procedures; used for - logging. - passwd scrambled password received from client - passwd_len length of scrambled password - db database name to connect to, may be NULL - check_count dont know exactly + @param thd thread handle, thd->security_ctx->{host,user,ip} are used + @param command originator of the check: now check_user is called + during connect and change user procedures; used for + logging. + @param passwd scrambled password received from client + @param passwd_len length of scrambled password + @param db database name to connect to, may be NULL + @param check_count TRUE if establishing a new connection. In this case + check that we have not exceeded the global + max_connections limist - Note, that host, user and passwd may point to communication buffer. - Current implementation does not depend on that, but future changes - should be done with this in mind; 'thd' is INOUT, all other params - are 'IN'. + @note Host, user and passwd may point to communication buffer. + Current implementation does not depend on that, but future changes + should be done with this in mind; 'thd' is INOUT, all other params + are 'IN'. - RETURN VALUE - 0 OK; thd->security_ctx->user/master_access/priv_user/db_access and - thd->db are updated; OK is sent to client; - -1 access denied or handshake error; error is sent to client; - >0 error, not sent to client + @retval 0 OK; thd->security_ctx->user/master_access/priv_user/db_access and + thd->db are updated; OK is sent to the client. + @retval 1 error, e.g. access denied or handshake error, not sent to + the client. A message is pushed into the error stack. */ -int check_user(THD *thd, enum enum_server_command command, +int +check_user(THD *thd, enum enum_server_command command, const char *passwd, uint passwd_len, const char *db, bool check_count) { @@ -328,11 +329,7 @@ int check_user(THD *thd, enum enum_server_command command, */ thd->reset_db(NULL, 0); if (mysql_change_db(thd, &db_str, FALSE)) - { - /* Send the error to the client */ - net_send_error(thd); - DBUG_RETURN(-1); - } + DBUG_RETURN(1); } send_ok(thd); DBUG_RETURN(0); @@ -349,14 +346,17 @@ int check_user(THD *thd, enum enum_server_command command, */ if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323) { - net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE); + my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0)); general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE)); - DBUG_RETURN(-1); + DBUG_RETURN(1); } if (passwd_len != 0 && passwd_len != SCRAMBLE_LENGTH && passwd_len != SCRAMBLE_LENGTH_323) - DBUG_RETURN(ER_HANDSHAKE_ERROR); + { + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + DBUG_RETURN(1); + } /* Clear thd->db as it points to something, that will be freed when @@ -380,20 +380,21 @@ int check_user(THD *thd, enum enum_server_command command, NET *net= &thd->net; if (opt_secure_auth_local) { - net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE, - thd->main_security_ctx.user, - thd->main_security_ctx.host_or_ip); + my_error(ER_SERVER_IS_IN_SECURE_AUTH_MODE, MYF(0), + thd->main_security_ctx.user, + thd->main_security_ctx.host_or_ip); general_log_print(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE), thd->main_security_ctx.user, thd->main_security_ctx.host_or_ip); - DBUG_RETURN(-1); + DBUG_RETURN(1); } /* We have to read very specific packet size */ if (send_old_password_request(thd) || my_net_read(net) != SCRAMBLE_LENGTH_323 + 1) { inc_host_errors(&thd->remote.sin_addr); - DBUG_RETURN(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + DBUG_RETURN(1); } /* Final attempt to check the user based on reply */ /* So as passwd is short, errcode is always >= 0 */ @@ -427,8 +428,8 @@ int check_user(THD *thd, enum enum_server_command command, VOID(pthread_mutex_unlock(&LOCK_thread_count)); if (!count_ok) { // too many connections - net_send_error(thd, ER_CON_COUNT_ERROR); - DBUG_RETURN(-1); + my_error(ER_CON_COUNT_ERROR, MYF(0)); + DBUG_RETURN(1); } } @@ -462,24 +463,29 @@ int check_user(THD *thd, enum enum_server_command command, (opt_old_style_user_limits ? thd->main_security_ctx.host_or_ip : thd->main_security_ctx.priv_host), &ur)) - DBUG_RETURN(-1); + { + /* The error is set by get_or_create_user_conn(). */ + DBUG_RETURN(1); + } if (thd->user_connect && (thd->user_connect->user_resources.conn_per_hour || thd->user_connect->user_resources.user_conn || max_user_connections) && check_for_max_user_connections(thd, thd->user_connect)) - DBUG_RETURN(-1); + { + /* The error is set in check_for_max_user_connections(). */ + DBUG_RETURN(1); + } /* Change database if necessary */ if (db && db[0]) { if (mysql_change_db(thd, &db_str, FALSE)) { - /* Send error to the client */ - net_send_error(thd); + /* mysql_change_db() has pushed the error message. */ if (thd->user_connect) decrease_user_connections(thd->user_connect); - DBUG_RETURN(-1); + DBUG_RETURN(1); } } send_ok(thd); @@ -490,19 +496,19 @@ int check_user(THD *thd, enum enum_server_command command, } else if (res == 2) // client gave short hash, server has long hash { - net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE); + my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0)); general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE)); - DBUG_RETURN(-1); + DBUG_RETURN(1); } - net_printf_error(thd, ER_ACCESS_DENIED_ERROR, - thd->main_security_ctx.user, - thd->main_security_ctx.host_or_ip, - passwd_len ? ER(ER_YES) : ER(ER_NO)); + my_error(ER_ACCESS_DENIED_ERROR, MYF(0), + thd->main_security_ctx.user, + thd->main_security_ctx.host_or_ip, + passwd_len ? ER(ER_YES) : ER(ER_NO)); general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR), thd->main_security_ctx.user, thd->main_security_ctx.host_or_ip, passwd_len ? ER(ER_YES) : ER(ER_NO)); - DBUG_RETURN(-1); + DBUG_RETURN(1); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ } @@ -666,9 +672,12 @@ static int check_connection(THD *thd) char ip[30]; if (vio_peer_addr(net->vio, ip, &thd->peer_port)) - return (ER_BAD_HOST_ERROR); - if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(0)))) - return (ER_OUT_OF_RESOURCES); + { + my_error(ER_BAD_HOST_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; + } + if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME)))) + return 1; /* The error is set by my_strdup(). */ thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip; vio_in_addr(net->vio,&thd->remote.sin_addr); if (!(specialflag & SPECIAL_NO_RESOLVE)) @@ -685,7 +694,10 @@ static int check_connection(THD *thd) thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host; } if (connect_errors > max_connect_errors) - return(ER_HOST_IS_BLOCKED); + { + my_error(ER_HOST_IS_BLOCKED, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; + } } DBUG_PRINT("info",("Host: %s ip: %s", (thd->main_security_ctx.host ? @@ -693,7 +705,11 @@ static int check_connection(THD *thd) (thd->main_security_ctx.ip ? thd->main_security_ctx.ip : "unknown ip"))); if (acl_check_host(thd->main_security_ctx.host, thd->main_security_ctx.ip)) - return(ER_HOST_NOT_PRIVILEGED); + { + my_error(ER_HOST_NOT_PRIVILEGED, MYF(0), + thd->main_security_ctx.host_or_ip); + return 1; + } } else /* Hostname given means that the connection was on a socket */ { @@ -753,7 +769,9 @@ static int check_connection(THD *thd) pkt_len < MIN_HANDSHAKE_SIZE) { inc_host_errors(&thd->remote.sin_addr); - return(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), + thd->main_security_ctx.host_or_ip); + return 1; } } #ifdef _CUSTOMCONFIG_ @@ -762,7 +780,7 @@ static int check_connection(THD *thd) if (connect_errors) reset_host_errors(&thd->remote.sin_addr); if (thd->packet.alloc(thd->variables.net_buffer_length)) - return(ER_OUT_OF_RESOURCES); + return 1; /* The error is set by alloc(). */ thd->client_capabilities=uint2korr(net->read_pos); if (thd->client_capabilities & CLIENT_PROTOCOL_41) @@ -790,14 +808,16 @@ static int check_connection(THD *thd) if (!ssl_acceptor_fd) { inc_host_errors(&thd->remote.sin_addr); - return(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; } DBUG_PRINT("info", ("IO layer change in progress...")); if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout)) { DBUG_PRINT("error", ("Failed to accept new SSL connection")); inc_host_errors(&thd->remote.sin_addr); - return(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; } DBUG_PRINT("info", ("Reading user information over SSL layer")); if ((pkt_len= my_net_read(net)) == packet_error || @@ -806,7 +826,8 @@ static int check_connection(THD *thd) DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)", pkt_len)); inc_host_errors(&thd->remote.sin_addr); - return(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; } } #endif /* HAVE_OPENSSL */ @@ -814,7 +835,8 @@ static int check_connection(THD *thd) if (end >= (char*) net->read_pos+ pkt_len +2) { inc_host_errors(&thd->remote.sin_addr); - return(ER_HANDSHAKE_ERROR); + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; } if (thd->client_capabilities & CLIENT_INTERACTIVE) @@ -851,7 +873,8 @@ static int check_connection(THD *thd) if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len) { inc_host_errors(&thd->remote.sin_addr); - return ER_HANDSHAKE_ERROR; + my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); + return 1; } /* Since 4.1 all database names are stored in utf8 */ @@ -879,8 +902,8 @@ static int check_connection(THD *thd) if (thd->main_security_ctx.user) x_free(thd->main_security_ctx.user); - if (!(thd->main_security_ctx.user= my_strdup(user, MYF(0)))) - return (ER_OUT_OF_RESOURCES); + if (!(thd->main_security_ctx.user= my_strdup(user, MYF(MY_WME)))) + return 1; /* The error is set by my_strdup(). */ return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE); } @@ -929,7 +952,6 @@ bool setup_connection_thread_globals(THD *thd) bool login_connection(THD *thd) { - int error; NET *net= &thd->net; Security_context *sctx= thd->security_ctx; DBUG_ENTER("login_connection"); @@ -942,10 +964,9 @@ bool login_connection(THD *thd) my_net_set_read_timeout(net, connect_timeout); my_net_set_write_timeout(net, connect_timeout); - if ((error=check_connection(thd))) + if (check_connection(thd)) { // Wrong permissions - if (error > 0) - net_printf_error(thd, error, sctx->host_or_ip); + net_send_error(thd); #ifdef __NT__ if (vio_type(net->vio) == VIO_TYPE_NAMEDPIPE) my_sleep(1000); /* must wait after eof() */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ac042960388..803d29d83d6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -915,11 +915,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (res) { - /* authentication failure, we shall restore old user */ - if (res > 0) - my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); - else - thd->clear_error(); // Error already sent to client x_free(thd->security_ctx->user); *thd->security_ctx= save_security_ctx; thd->user_connect= save_user_connect; From 26326ed0b7a630fd2990d560b009895fa1ea818f Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 00:31:57 +0300 Subject: [PATCH 051/128] A fix for Bug#32007 select udf_function() doesn't return an error if error during udf initialization. The bug is spotted while working on Bug 12713. If a user-defined function was used in a SELECT statement, and an error would occur during UDF initialization, this error would not terminate execution of the SELECT, but rather would be converted to a warning. The fix is to use a stack buffer to store the message from udf_init instead of private my_error() buffer. --- mysql-test/r/udf.result | 12 ++++++------ mysql-test/t/udf.test | 12 ++++++------ sql/item_func.cc | 5 +++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index da27a71c1a1..cb5afcf5f17 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -11,7 +11,7 @@ RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "UDF_EXAMPLE_LIB"; select myfunc_double(); -ERROR HY000: myfunc_double must have at least one argument +ERROR HY000: Can't initialize function 'myfunc_double'; myfunc_double must have at least one argument select myfunc_double(1); myfunc_double(1) 49.00 @@ -24,26 +24,26 @@ select myfunc_int(); myfunc_int() 0 select lookup(); -ERROR HY000: Wrong arguments to lookup; Use the source +ERROR HY000: Can't initialize function 'lookup'; Wrong arguments to lookup; Use the source select lookup("127.0.0.1"); lookup("127.0.0.1") 127.0.0.1 select lookup(127,0,0,1); -ERROR HY000: Wrong arguments to lookup; Use the source +ERROR HY000: Can't initialize function 'lookup'; Wrong arguments to lookup; Use the source select lookup("localhost"); lookup("localhost") 127.0.0.1 select reverse_lookup(); -ERROR HY000: Wrong number of arguments to reverse_lookup; Use the source +ERROR HY000: Can't initialize function 'reverse_lookup'; Wrong number of arguments to reverse_lookup; Use the source select reverse_lookup("127.0.0.1"); select reverse_lookup(127,0,0,1); select reverse_lookup("localhost"); reverse_lookup("localhost") NULL select avgcost(); -ERROR HY000: wrong number of arguments: AVGCOST() requires two arguments +ERROR HY000: Can't initialize function 'avgcost'; wrong number of arguments: AVGCOST() requires two arguments select avgcost(100,23.76); -ERROR HY000: wrong argument type: AVGCOST() requires an INT and a REAL +ERROR HY000: Can't initialize function 'avgcost'; wrong argument type: AVGCOST() requires an INT and a REAL create table t1(sum int, price float(24)); insert into t1 values(100, 50.00), (100, 100.00); select avgcost(sum, price) from t1; diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 663dc08d72e..32cfca57546 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -35,20 +35,20 @@ eval CREATE FUNCTION reverse_lookup eval CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; ---error 0 +--error ER_CANT_INITIALIZE_UDF select myfunc_double(); select myfunc_double(1); select myfunc_double(78654); --error 1305 select myfunc_nonexist(); select myfunc_int(); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(); select lookup("127.0.0.1"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(127,0,0,1); select lookup("localhost"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select reverse_lookup(); # These two functions should return "localhost", but it's @@ -59,9 +59,9 @@ select reverse_lookup(127,0,0,1); --enable_result_log select reverse_lookup("localhost"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select avgcost(); ---error 0 +--error ER_CANT_INITIALIZE_UDF select avgcost(100,23.76); create table t1(sum int, price float(24)); insert into t1 values(100, 50.00), (100, 100.00); diff --git a/sql/item_func.cc b/sql/item_func.cc index 2d4d61de61b..ec0ecc89394 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2897,6 +2897,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, if (u_d->func_init) { + char init_msg_buff[MYSQL_ERRMSG_SIZE]; char *to=num_buffer; for (uint i=0; i < arg_count; i++) { @@ -2949,10 +2950,10 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, } thd->net.last_error[0]=0; Udf_func_init init= u_d->func_init; - if ((error=(uchar) init(&initid, &f_args, thd->net.last_error))) + if ((error=(uchar) init(&initid, &f_args, init_msg_buff))) { my_error(ER_CANT_INITIALIZE_UDF, MYF(0), - u_d->name.str, thd->net.last_error); + u_d->name.str, init_msg_buff); free_udf(u_d); DBUG_RETURN(TRUE); } From 8423c7ef227cf34f9f274659778abfdc8f869ef0 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 00:55:25 +0300 Subject: [PATCH 052/128] Another attempt to fix the Windows compilation failre. --- sql-common/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index 5ece9c39d6c..0ca7ef16c0d 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -349,7 +349,7 @@ static void set_mysql_extended_error(MYSQL *mysql, int errcode, #ifdef __WIN__ -HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, +HANDLE create_named_pipe(MYSQL *mysql, uint connect_timeout, char **arg_host, char **arg_unix_socket) { HANDLE hPipe=INVALID_HANDLE_VALUE; @@ -1950,8 +1950,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, (! have_tcpip && (unix_socket || !host && is_NT())))) { sock=0; - if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout, - (char**) &host, (char**) &unix_socket)) == + if ((hPipe= create_named_pipe(mysql, mysql->options.connect_timeout, + (char**) &host, (char**) &unix_socket)) == INVALID_HANDLE_VALUE) { DBUG_PRINT("error", From f8c2f9d195a9aa0fd0ba53f1ed0fec6589e19749 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Thu, 1 Nov 2007 16:27:01 +0400 Subject: [PATCH 053/128] BUG#31950 - repair table hangs while processing multicolumn utf8 fulltext index Having a table with broken multibyte characters may cause fulltext parser dead-loop. Since normally it is not possible to insert broken multibyte sequence into a table, this problem may arise only if table is damaged. Affected statements are: - CHECK/REPAIR against damaged table with fulltext index; - boolean mode phrase search against damaged table with or without fulltext inex; - boolean mode searches without index; - nlq searches. No test case for this fix. Affects 5.0 only. --- myisam/ft_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c index 6d68542e4e2..1d3a19dd8c6 100644 --- a/myisam/ft_parser.c +++ b/myisam/ft_parser.c @@ -188,7 +188,7 @@ byte ft_simple_get_word(CHARSET_INFO *cs, byte **start, const byte *end, do { - for (;; doc+= mbl) + for (;; doc+= (mbl ? mbl : 1)) { if (doc >= end) DBUG_RETURN(0); if (true_word_char(cs, *doc)) break; From 447eff2d98af4bd229f71e109ae568d4155c30cf Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 1 Nov 2007 14:42:14 +0200 Subject: [PATCH 054/128] Bug #31866: MySQL Server crashes on SHOW CREATE TRIGGER statement SHOW CREATE TRIGGER was not checking for detected errors opening/reading the trigger file. Fixed to return the already generated error. --- mysql-test/r/trigger.result | 6 ++++++ mysql-test/t/trigger.test | 12 ++++++++++++ sql/sql_show.cc | 3 +++ 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 189722bfe9b..47ffc90e3cd 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1978,3 +1978,9 @@ a 1 drop table table_25411_a; drop table table_25411_b; +DROP TRIGGER IF EXISTS trg; +Warnings: +Note 1360 Trigger does not exist +SHOW CREATE TRIGGER trg; +ERROR HY000: Trigger does not exist +End of 5.1 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 9f4634e1e17..1c98a0f8d29 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2246,3 +2246,15 @@ select * from table_25411_a; drop table table_25411_a; drop table table_25411_b; +# +# Bug #31866: MySQL Server crashes on SHOW CREATE TRIGGER statement +# + +--disable-warnings +DROP TRIGGER IF EXISTS trg; +--enable-warnings + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER trg; + +--echo End of 5.1 tests. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 049c050c288..1969472dff4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6862,6 +6862,9 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name) { TABLE_LIST *lst= get_trigger_table(thd, trg_name); + if (!lst) + return TRUE; + /* Open the table by name in order to load Table_triggers_list object. From f60b89096771e0d4eb05c2532540e7d57d04b826 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 17:00:24 +0300 Subject: [PATCH 055/128] Fix a compilation warning. --- sql/sql_connect.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 9b5f1a9b0e5..90df233896a 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -953,7 +953,6 @@ bool setup_connection_thread_globals(THD *thd) bool login_connection(THD *thd) { NET *net= &thd->net; - Security_context *sctx= thd->security_ctx; DBUG_ENTER("login_connection"); DBUG_PRINT("info", ("login_connection called by thread %lu", thd->thread_id)); From 382f62b10b63894faa739cc61d18e3d5a268713a Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Thu, 1 Nov 2007 15:03:09 +0100 Subject: [PATCH 056/128] Bug#31909 - New gis.test creates warnings files Comment sign of -- at line begin in test files lead to warnings from mysqltest. Changed -- to #. --- mysql-test/include/gis_keys.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc index 295e0c48234..c75311f062a 100644 --- a/mysql-test/include/gis_keys.inc +++ b/mysql-test/include/gis_keys.inc @@ -13,20 +13,20 @@ CREATE TABLE t2 (p POINT, INDEX(p)); INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); --- no index, returns 1 as expected +# no index, returns 1 as expected SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); --- with index, returns 1 as expected --- EXPLAIN shows that the index is not used though --- due to the "most rows covered anyway, so a scan is more effective" rule +# with index, returns 1 as expected +# EXPLAIN shows that the index is not used though +# due to the "most rows covered anyway, so a scan is more effective" rule EXPLAIN SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); --- adding another row to the table so that --- the "most rows covered" rule doesn't kick in anymore --- now EXPLAIN shows the index used on the table --- and we're getting the wrong result again +# adding another row to the table so that +# the "most rows covered" rule doesn't kick in anymore +# now EXPLAIN shows the index used on the table +# and we're getting the wrong result again INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); EXPLAIN From 1b165ef41f8ef2283264ff1ef6c5e719fea60e4e Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Thu, 1 Nov 2007 15:04:23 +0100 Subject: [PATCH 057/128] Post-merge fix --- mysql-test/t/variables.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 63bc3c5e273..b661d0e8ae7 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -139,7 +139,7 @@ show global variables like 'net_%'; show session variables like 'net_%'; set net_buffer_length=1; show variables like 'net_buffer_length'; ---warning 1292 +#warning 1292 set net_buffer_length=2000000000; show variables like 'net_buffer_length'; From 6bd9f5c1cb1875b1a0b962a29c408f299222479e Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 17:08:02 +0300 Subject: [PATCH 058/128] Use thd->is_error() instead of direct access to thd->net.report_error in evaluate_join_record(). A minor cleanup required for the fix for Bug#12713. --- sql/sql_select.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ef1151d82f3..338b5f0cc3f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -122,7 +122,7 @@ static int do_select(JOIN *join,List *fields,TABLE *tmp_table, static enum_nested_loop_state evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, - int error, my_bool *report_error); + int error); static enum_nested_loop_state evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab); static enum_nested_loop_state @@ -10871,7 +10871,6 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) int error; enum_nested_loop_state rc; - my_bool *report_error= &(join->thd->net.report_error); READ_RECORD *info= &join_tab->read_record; if (join->resume_nested_loop) @@ -10903,13 +10902,13 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) join->thd->row_count= 0; error= (*join_tab->read_first_record)(join_tab); - rc= evaluate_join_record(join, join_tab, error, report_error); + rc= evaluate_join_record(join, join_tab, error); } while (rc == NESTED_LOOP_OK) { error= info->read_record(info); - rc= evaluate_join_record(join, join_tab, error, report_error); + rc= evaluate_join_record(join, join_tab, error); } if (rc == NESTED_LOOP_NO_MORE_ROWS && @@ -10933,13 +10932,13 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) static enum_nested_loop_state evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, - int error, my_bool *report_error) + int error) { bool not_used_in_distinct=join_tab->not_used_in_distinct; ha_rows found_records=join->found_records; COND *select_cond= join_tab->select_cond; - if (error > 0 || (*report_error)) // Fatal error + if (error > 0 || (join->thd->is_error())) // Fatal error return NESTED_LOOP_ERROR; if (error < 0) return NESTED_LOOP_NO_MORE_ROWS; From 7e119ec0d19f72a0f37823ee678409de85f5c676 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 18:06:46 +0300 Subject: [PATCH 059/128] Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS error in mysql_create_frm instead of direct access to my_error() members. This is a pre-requisite for the patch for Bug#12713. --- sql/unireg.cc | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/sql/unireg.cc b/sql/unireg.cc index f9e8e54439a..f2238d69973 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -47,6 +47,35 @@ static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type, uint reclength, ulong data_offset, handler *handler); +/** + An interceptor to hijack ER_TOO_MANY_FIELDS error from + pack_screens and retry again without UNIREG screens. + + XXX: what is a UNIREG screen? +*/ + +struct Pack_header_error_handler: public Internal_error_handler +{ + virtual bool handle_error(uint sql_errno, + const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd); + bool is_handled; + Pack_header_error_handler() :is_handled(FALSE) {} +}; + + +bool +Pack_header_error_handler:: +handle_error(uint sql_errno, + const char * /* message */, + MYSQL_ERROR::enum_warning_level /* level */, + THD * /* thd */) +{ + is_handled= (sql_errno == ER_TOO_MANY_FIELDS); + return is_handled; +} + /* Create a frm (table definition) file @@ -86,6 +115,8 @@ bool mysql_create_frm(THD *thd, const char *file_name, #ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info= thd->work_part_info; #endif + Pack_header_error_handler pack_header_error_handler; + int error; DBUG_ENTER("mysql_create_frm"); DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension @@ -99,17 +130,22 @@ bool mysql_create_frm(THD *thd, const char *file_name, create_info->null_bits++; data_offset= (create_info->null_bits + 7) / 8; - if (pack_header(forminfo, ha_legacy_type(create_info->db_type), - create_fields,info_length, - screens, create_info->table_options, - data_offset, db_file)) + thd->push_internal_handler(&pack_header_error_handler); + + error= pack_header(forminfo, ha_legacy_type(create_info->db_type), + create_fields,info_length, + screens, create_info->table_options, + data_offset, db_file); + + thd->pop_internal_handler(); + + if (error) { my_free(screen_buff, MYF(0)); - if (thd->net.last_errno != ER_TOO_MANY_FIELDS) + if (! pack_header_error_handler.is_handled) DBUG_RETURN(1); // Try again without UNIREG screens (to get more columns) - thd->net.last_error[0]=0; if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1))) DBUG_RETURN(1); if (pack_header(forminfo, ha_legacy_type(create_info->db_type), From 8f90f66d434d27d840fd258e0fa9270c5dd1f2fe Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Thu, 1 Nov 2007 18:33:51 +0300 Subject: [PATCH 060/128] Cleanup execute_ddl_log_recovery() to not generate an error if there is nothing to recover. Discovered while working on Bug#12713 --- sql/sql_table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6edb8494b03..328b5e71a44 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -434,7 +434,7 @@ static uint read_ddl_log_header() create_ddl_log_file_name(file_name); if ((global_ddl_log.file_id= my_open(file_name, - O_RDWR | O_BINARY, MYF(MY_WME))) >= 0) + O_RDWR | O_BINARY, MYF(0))) >= 0) { if (read_ddl_log_file_entry(0UL)) { From 92a5605d439feb4d044bb2c27fb06a7d4f5cc197 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 1 Nov 2007 18:36:24 +0200 Subject: [PATCH 061/128] Bug #31794: no syntax error on SELECT id FROM t HAVING count(*)>2 The HAVING clause is subject to the same rules as the SELECT list about using aggregated and non-aggregated columns. But this was not enforced when processing implicit grouping from using aggregate functions. Fixed by performing the same checks for HAVING as for SELECT. --- mysql-test/r/func_group.result | 15 +++++++++++++++ mysql-test/t/func_group.test | 19 +++++++++++++++++++ sql/sql_select.cc | 12 ++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index e7f27ebb07e..1e130877088 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1392,4 +1392,19 @@ SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; MIN(b) NULL DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SET SQL_MODE=ONLY_FULL_GROUP_BY; +SELECT a FROM t1 HAVING COUNT(*)>2; +ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause +SELECT COUNT(*), a FROM t1; +ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause +SET SQL_MODE=DEFAULT; +SELECT a FROM t1 HAVING COUNT(*)>2; +a +1 +SELECT COUNT(*), a FROM t1; +COUNT(*) a +4 1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 7e115707625..25cb13a2f75 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -882,5 +882,24 @@ CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b)); SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; DROP TABLE t1; +# +# Bug #31794: no syntax error on SELECT id FROM t HAVING count(*)>2; +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); + +SET SQL_MODE=ONLY_FULL_GROUP_BY; +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT a FROM t1 HAVING COUNT(*)>2; +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT COUNT(*), a FROM t1; + +SET SQL_MODE=DEFAULT; +SELECT a FROM t1 HAVING COUNT(*)>2; +SELECT COUNT(*), a FROM t1; + +DROP TABLE t1; + ### --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7af39071561..e7d778de991 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -565,11 +565,12 @@ JOIN::prepare(Item ***rref_pointer_array, /* - Check if one one uses a not constant column with group functions - and no GROUP BY. + Check if there are references to un-aggregated columns when computing + aggregate functions with implicit grouping (there is no GROUP BY). TODO: Add check of calculation of GROUP functions and fields: SELECT COUNT(*)+table.col1 from table1; */ + if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) { if (!group_list) { @@ -583,6 +584,13 @@ JOIN::prepare(Item ***rref_pointer_array, else if (!(flag & 2) && !item->const_during_execution()) flag|=2; } + if (having) + { + if (having->with_sum_func) + flag |= 1; + else if (!having->const_during_execution()) + flag |= 2; + } if (flag == 3) { my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, From 968af721502f47b061e716f955716293e9f2597e Mon Sep 17 00:00:00 2001 From: "davi@endora.local" <> Date: Thu, 1 Nov 2007 17:29:20 -0200 Subject: [PATCH 062/128] Bug#31850 Test crashes in "embedded" server The mysql_change_user command fails to properly update the database pointer when no database is selected, leading to "use after free" errors. The same happens on the user privilege pointer in the thread security context. The solution is to properly reset and update the database name. Also update the user_priv pointer so that it doesn't point to freed memory. --- sql/sql_connect.cc | 23 +++++++++-------------- sql/sql_parse.cc | 5 +++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 8a817e5993a..adf0b9e01ed 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -316,17 +316,20 @@ int check_user(THD *thd, enum enum_server_command command, { DBUG_ENTER("check_user"); LEX_STRING db_str= { (char *) db, db ? strlen(db) : 0 }; - + + /* + Clear thd->db as it points to something, that will be freed when + connection is closed. We don't want to accidentally free a wrong + pointer if connect failed. Also in case of 'CHANGE USER' failure, + current database will be switched to 'no database selected'. + */ + thd->reset_db(NULL, 0); + #ifdef NO_EMBEDDED_ACCESS_CHECKS thd->main_security_ctx.master_access= GLOBAL_ACLS; // Full rights /* Change database if necessary */ if (db && db[0]) { - /* - thd->db is saved in caller and needs to be freed by caller if this - function returns 0 - */ - thd->reset_db(NULL, 0); if (mysql_change_db(thd, &db_str, FALSE)) { /* Send the error to the client */ @@ -358,14 +361,6 @@ int check_user(THD *thd, enum enum_server_command command, passwd_len != SCRAMBLE_LENGTH_323) DBUG_RETURN(ER_HANDSHAKE_ERROR); - /* - Clear thd->db as it points to something, that will be freed when - connection is closed. We don't want to accidentally free a wrong pointer - if connect failed. Also in case of 'CHANGE USER' failure, current - database will be switched to 'no database selected'. - */ - thd->reset_db(NULL, 0); - USER_RESOURCES ur; int res= acl_getroot(thd, &ur, passwd, passwd_len); #ifndef EMBEDDED_LIBRARY diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 85457fea41b..b2f2e74999b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -911,6 +911,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Clear variables that are allocated */ thd->user_connect= 0; + thd->security_ctx->priv_user= thd->security_ctx->user; res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, FALSE); if (res) @@ -933,8 +934,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (save_user_connect) decrease_user_connections(save_user_connect); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ - x_free((uchar*) save_db); - x_free((uchar*) save_security_ctx.user); + x_free(save_db); + x_free(save_security_ctx.user); if (cs_number) { From bcfe0fa67eb32df9ab3df117c9ff11f1d271da5b Mon Sep 17 00:00:00 2001 From: "antony@pcg5ppc.xiphis.org" <> Date: Thu, 1 Nov 2007 12:30:03 -0700 Subject: [PATCH 063/128] Bug#30671 "ALTER SERVER can cause server to crash" While retrieving values, it would erronously set the socket value to NULL and attempt to use it in strcmp(). Ensure it is correctly set to "" so that strcmp may not crash. --- mysql-test/r/federated_server.result | 10 +++++++++- mysql-test/t/federated_server.test | 14 +++++++++++++- sql/sql_servers.cc | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/federated_server.result b/mysql-test/r/federated_server.result index 0905aabb075..32717b4f0e3 100644 --- a/mysql-test/r/federated_server.result +++ b/mysql-test/r/federated_server.result @@ -253,6 +253,14 @@ drop user guest_usage@localhost; drop user guest_select@localhost; drop table federated.t1; drop server 's1'; +create server 's1' foreign data wrapper 'mysql' options (port 3306); +alter server 's1' options +(host 'localhost', database '', user '', +password '', socket '', owner '', port 3306); +alter server 's1' options +(host 'localhost', database 'database1', user '', +password '', socket '', owner '', port 3306); +drop server 's1'; # End of 5.1 tests use test; create procedure p1 () @@ -262,7 +270,7 @@ DECLARE e INT DEFAULT 0; DECLARE i INT; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1; SET i = sleep(5); -WHILE v < 20000 do +WHILE v < 10000 do CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test'); diff --git a/mysql-test/t/federated_server.test b/mysql-test/t/federated_server.test index 87b67720104..444285ac045 100644 --- a/mysql-test/t/federated_server.test +++ b/mysql-test/t/federated_server.test @@ -2,7 +2,7 @@ # if federated can utilise the servers table # should work with embedded server after mysqltest is fixed -- source include/not_embedded.inc --- source include/federated.inc; +-- source include/federated.inc -- source include/big_test.inc connection slave; @@ -282,6 +282,18 @@ drop user guest_select@localhost; drop table federated.t1; drop server 's1'; +# +# Bug#30671 - ALTER SERVER causes the server to crash +# +create server 's1' foreign data wrapper 'mysql' options (port 3306); +alter server 's1' options + (host 'localhost', database '', user '', + password '', socket '', owner '', port 3306); +# The next statement would crash unpatched server +alter server 's1' options + (host 'localhost', database 'database1', user '', + password '', socket '', owner '', port 3306); +drop server 's1'; --echo # End of 5.1 tests diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index a780c561ffe..543884fdfa6 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -289,7 +289,7 @@ get_server_from_table_to_cache(TABLE *table) { /* alloc a server struct */ char *ptr; - char *blank= (char*)""; + char * const blank= (char*)""; FOREIGN_SERVER *server= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER)); DBUG_ENTER("get_server_from_table_to_cache"); @@ -312,7 +312,7 @@ get_server_from_table_to_cache(TABLE *table) server->port= server->sport ? atoi(server->sport) : 0; ptr= get_field(&mem, table->field[6]); - server->socket= ptr && strlen(ptr) ? ptr : NULL; + server->socket= ptr && strlen(ptr) ? ptr : blank; ptr= get_field(&mem, table->field[7]); server->scheme= ptr ? ptr : blank; ptr= get_field(&mem, table->field[8]); From cc007acb785d12cb6f5f176320ad9d099937fd9c Mon Sep 17 00:00:00 2001 From: "davi@endora.local" <> Date: Thu, 1 Nov 2007 18:52:56 -0200 Subject: [PATCH 064/128] Bug#30882 Dropping a temporary table inside a stored function may cause a server crash If a stored function that contains a drop temporary table statement is invoked by a create temporary table of the same name may cause a server crash. The problem is that when dropping a table no check is done to ensure that table is not being used by some outer query (or outer statement), potentially leaving the outer query with a reference to a stale (freed) table. The solution is when dropping a temporary table, always check if the table is being used by some outer statement as a temporary table can be dropped inside stored procedures. The check is performed by looking at the TABLE::query_id value for temporary tables. To simplify this check and to solve a bug related to handling of temporary tables in prelocked mode, this patch changes the way in which this member is used to track the fact that table is used/unused. Now we ensure that TABLE::query_id is zero for unused temporary tables (which means that all temporary tables which were used by a statement should be marked as free for reuse after it's execution has been completed). --- mysql-test/include/handler.inc | 32 +++++++ mysql-test/r/handler_innodb.result | 62 +++++++++++++ mysql-test/r/handler_myisam.result | 62 +++++++++++++ mysql-test/r/sp-error.result | 52 ++++++++++- mysql-test/t/sp-error.test | 74 ++++++++++++++- sql/event_db_repository.cc | 2 +- sql/mysql_priv.h | 4 +- sql/slave.cc | 2 +- sql/sp_head.cc | 2 +- sql/sql_base.cc | 141 ++++++++++++++++++----------- sql/sql_handler.cc | 14 +++ sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 15 ++- sql/sql_table.cc | 28 ++++-- sql/table.h | 22 ++++- 15 files changed, 431 insertions(+), 83 deletions(-) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 71647112126..79e21382d4c 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -566,3 +566,35 @@ reap; connection default; drop table t2; disconnect flush; + +# +# Bug#30882 Dropping a temporary table inside a stored function may cause a server crash +# +# Test HANDLER statements in conjunction with temporary tables. While the temporary table +# is open by a HANDLER, no other statement can access it. +# + +--disable_warnings +drop table if exists t1; +--enable_warnings +create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), + (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +select a,b from t1; +handler t1 open as a1; +handler a1 read a first; +handler a1 read a next; +handler a1 read a next; +--error ER_CANT_REOPEN_TABLE +select a,b from t1; +handler a1 read a prev; +handler a1 read a prev; +handler a1 read a=(6) where b="g"; +handler a1 close; +select a,b from t1; +handler t1 open as a2; +handler a2 read a first; +handler a2 read a last; +handler a2 read a prev; +handler a2 close; +drop table t1; diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index e9e5c7dbdd5..d9a1a0aa12b 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -575,3 +575,65 @@ ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; handler t2 close; drop table t2; +drop table if exists t1; +create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +handler t1 open as a1; +handler a1 read a first; +a b +0 a +handler a1 read a next; +a b +1 b +handler a1 read a next; +a b +2 c +select a,b from t1; +ERROR HY000: Can't reopen table: 'a1' +handler a1 read a prev; +a b +1 b +handler a1 read a prev; +a b +0 a +handler a1 read a=(6) where b="g"; +a b +6 g +handler a1 close; +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +handler t1 open as a2; +handler a2 read a first; +a b +0 a +handler a2 read a last; +a b +9 j +handler a2 read a prev; +a b +8 i +handler a2 close; +drop table t1; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index 715e5ab03d6..b42fdc864fe 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -575,3 +575,65 @@ ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; handler t2 close; drop table t2; +drop table if exists t1; +create temporary table t1 (a int, b char(1), key a(a), key b(a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +handler t1 open as a1; +handler a1 read a first; +a b +0 a +handler a1 read a next; +a b +1 b +handler a1 read a next; +a b +2 c +select a,b from t1; +ERROR HY000: Can't reopen table: 'a1' +handler a1 read a prev; +a b +1 b +handler a1 read a prev; +a b +0 a +handler a1 read a=(6) where b="g"; +a b +6 g +handler a1 close; +select a,b from t1; +a b +0 a +1 b +2 c +3 d +4 e +5 f +6 g +7 h +8 i +9 j +handler t1 open as a2; +handler a2 read a first; +a b +0 a +handler a2 read a last; +a b +9 j +handler a2 read a prev; +a b +8 i +handler a2 close; +drop table t1; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 300fa42f3ad..b81f8ea64c9 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1428,7 +1428,6 @@ create function bug20701() returns varchar(25) binary return "test"; ERROR 42000: This version of MySQL doesn't yet support 'return value collation' create function bug20701() returns varchar(25) return "test"; drop function bug20701; -End of 5.1 tests create procedure proc_26503_error_1() begin retry: @@ -1530,6 +1529,53 @@ return 1; end| ERROR HY000: Not allowed to set autocommit from a stored function or trigger create trigger t1 -before insert on t2 for each row set password = password('foo'); -delimiter ;| +before insert on t2 for each row set password = password('foo');| ERROR HY000: Not allowed to set autocommit from a stored function or trigger +drop function if exists f1; +drop function if exists f2; +drop table if exists t1, t2; +create function f1() returns int +begin +drop temporary table t1; +return 1; +end| +create temporary table t1 as select f1(); +ERROR HY000: Can't reopen table: 't1' +create function f2() returns int +begin +create temporary table t2 as select f1(); +return 1; +end| +create temporary table t1 as select f2(); +ERROR HY000: Can't reopen table: 't1' +drop function f1; +drop function f2; +create function f1() returns int +begin +drop temporary table t2,t1; +return 1; +end| +create function f2() returns int +begin +create temporary table t2 as select f1(); +return 1; +end| +create temporary table t1 as select f2(); +ERROR HY000: Can't reopen table: 't2' +drop function f1; +drop function f2; +create temporary table t2(a int); +select * from t2; +a +create function f2() returns int +begin +drop temporary table t2; +return 1; +end| +select f2(); +f2() +1 +drop function f2; +drop table t2; +ERROR 42S02: Unknown table 't2' +End of 5.1 tests diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 9f20d02480c..606c2a673bc 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2078,10 +2078,6 @@ create function bug20701() returns varchar(25) binary return "test"; create function bug20701() returns varchar(25) return "test"; drop function bug20701; - ---echo End of 5.1 tests - - # # Bug#26503 (Illegal SQL exception handler code causes the server to crash) # @@ -2237,10 +2233,78 @@ end| --error ER_SP_CANT_SET_AUTOCOMMIT create trigger t1 - before insert on t2 for each row set password = password('foo'); + before insert on t2 for each row set password = password('foo');| delimiter ;| +# +# Bug#30882 Dropping a temporary table inside a stored function may cause a server crash +# + +--disable_warnings +drop function if exists f1; +drop function if exists f2; +drop table if exists t1, t2; +--enable_warnings + +delimiter |; +create function f1() returns int +begin + drop temporary table t1; + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f1(); + +delimiter |; +create function f2() returns int +begin + create temporary table t2 as select f1(); + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f2(); + +drop function f1; +drop function f2; + +delimiter |; +create function f1() returns int +begin + drop temporary table t2,t1; + return 1; +end| +create function f2() returns int +begin + create temporary table t2 as select f1(); + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f2(); + +drop function f1; +drop function f2; + +create temporary table t2(a int); +select * from t2; +delimiter |; +create function f2() returns int +begin + drop temporary table t2; + return 1; +end| +delimiter ;| +select f2(); + +drop function f2; +--error ER_BAD_TABLE_ERROR +drop table t2; + +--echo End of 5.1 tests + # # BUG#NNNN: New bug synopsis # diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 4451e763ff7..9a33b33d8c9 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -549,7 +549,7 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type, if (simple_open_n_lock_tables(thd, &tables)) { - close_thread_tables(thd, FALSE, FALSE); + close_thread_tables(thd); DBUG_RETURN(TRUE); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3484b8096e3..12838317646 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -679,7 +679,7 @@ extern my_decimal decimal_zero; void free_items(Item *item); void cleanup_items(Item *item); class THD; -void close_thread_tables(THD *thd, bool locked=0, bool skip_derived=0); +void close_thread_tables(THD *thd); bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables); bool check_single_table_access(THD *thd, ulong privilege, TABLE_LIST *tables, bool no_errors); @@ -1419,7 +1419,7 @@ TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, bool check_alias); TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name); TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list); -bool close_temporary_table(THD *thd, TABLE_LIST *table_list); +int drop_temporary_table(THD *thd, TABLE_LIST *table_list); void close_temporary_table(THD *thd, TABLE *table, bool free_share, bool delete_table); void close_temporary(TABLE *table, bool free_share, bool delete_table); diff --git a/sql/slave.cc b/sql/slave.cc index 494e13d8c9f..7abcf50fa75 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2353,7 +2353,7 @@ err: change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE); DBUG_ASSERT(thd->net.buff != 0); net_end(&thd->net); // destructor will not free it, because net.vio is 0 - close_thread_tables(thd, 0); + close_thread_tables(thd); pthread_mutex_lock(&LOCK_thread_count); THD_CHECK_SENTRY(thd); delete thd; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 6e8749aa745..c0ea73a6c00 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1872,7 +1872,7 @@ sp_head::execute_procedure(THD *thd, List *args) we'll leave it here. */ if (!thd->in_sub_stmt) - close_thread_tables(thd, 0, 0); + close_thread_tables(thd); DBUG_PRINT("info",(" %.*s: eval args done", (int) m_name.length, m_name.str)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2584390d756..ddc5f88f577 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1055,6 +1055,29 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, } +/** + Mark all temporary tables which were used by the current statement or + substatement as free for reuse, but only if the query_id can be cleared. + + @param thd thread context + + @remark For temp tables associated with a open SQL HANDLER the query_id + is not reset until the HANDLER is closed. +*/ + +static void mark_temp_tables_as_free_for_reuse(THD *thd) +{ + for (TABLE *table= thd->temporary_tables ; table ; table= table->next) + { + if ((table->query_id == thd->query_id) && ! table->open_by_handler) + { + table->query_id= 0; + table->file->ha_reset(); + } + } +} + + /* Mark all tables in the list which were used by current substatement as free for reuse. @@ -1091,6 +1114,42 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table) } +/** + Auxiliary function to close all tables in the open_tables list. + + @param thd Thread context. + + @remark It should not ordinarily be called directly. +*/ + +static void close_open_tables(THD *thd) +{ + bool found_old_table= 0; + + safe_mutex_assert_not_owner(&LOCK_open); + + VOID(pthread_mutex_lock(&LOCK_open)); + + DBUG_PRINT("info", ("thd->open_tables: 0x%lx", (long) thd->open_tables)); + + while (thd->open_tables) + found_old_table|= close_thread_table(thd, &thd->open_tables); + thd->some_tables_deleted= 0; + + /* Free tables to hold down open files */ + while (open_cache.records > table_cache_size && unused_tables) + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ + check_unused(); + if (found_old_table) + { + /* Tell threads waiting for refresh that something has happened */ + broadcast_refresh(); + } + + VOID(pthread_mutex_unlock(&LOCK_open)); +} + + /* Close all tables used by the current substatement, or all tables used by this thread if we are on the upper level. @@ -1098,26 +1157,19 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table) SYNOPSIS close_thread_tables() thd Thread handler - lock_in_use Set to 1 (0 = default) if caller has a lock on - LOCK_open - skip_derived Set to 1 (0 = default) if we should not free derived - tables. - stopper When closing tables from thd->open_tables(->next)*, - don't close/remove tables starting from stopper. IMPLEMENTATION Unlocks tables and frees derived tables. Put all normal tables used by thread in free list. - When in prelocked mode it will only close/mark as free for reuse - tables opened by this substatement, it will also check if we are - closing tables after execution of complete query (i.e. we are on - upper level) and will leave prelocked mode if needed. + It will only close/mark as free for reuse tables opened by this + substatement, it will also check if we are closing tables after + execution of complete query (i.e. we are on upper level) and will + leave prelocked mode if needed. */ -void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) +void close_thread_tables(THD *thd) { - bool found_old_table; prelocked_mode_type prelocked_mode= thd->prelocked_mode; DBUG_ENTER("close_thread_tables"); @@ -1132,7 +1184,7 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) derived tables with (sub-)statement instead of thread and destroy them at the end of its execution. */ - if (thd->derived_tables && !skip_derived) + if (thd->derived_tables) { TABLE *table, *next; /* @@ -1147,13 +1199,10 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) thd->derived_tables= 0; } - if (prelocked_mode) - { - /* - Mark all temporary tables used by this substatement as free for reuse. - */ - mark_used_tables_as_free_for_reuse(thd, thd->temporary_tables); - } + /* + Mark all temporary tables used by this statement as free for reuse. + */ + mark_temp_tables_as_free_for_reuse(thd); if (thd->locked_tables || prelocked_mode) { @@ -1217,28 +1266,8 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) if (!thd->active_transaction()) thd->transaction.xid_state.xid.null(); - if (!lock_in_use) - VOID(pthread_mutex_lock(&LOCK_open)); - - DBUG_PRINT("info", ("thd->open_tables: 0x%lx", (long) thd->open_tables)); - - found_old_table= 0; - while (thd->open_tables) - found_old_table|= close_thread_table(thd, &thd->open_tables); - thd->some_tables_deleted=0; - - /* Free tables to hold down open files */ - while (open_cache.records > table_cache_size && unused_tables) - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ - check_unused(); - if (found_old_table) - { - /* Tell threads waiting for refresh that something has happened */ - broadcast_refresh(); - } - if (!lock_in_use) - VOID(pthread_mutex_unlock(&LOCK_open)); - /* VOID(pthread_sigmask(SIG_SETMASK,&thd->signals,NULL)); */ + if (thd->open_tables) + close_open_tables(thd); if (prelocked_mode == PRELOCKED) { @@ -1675,6 +1704,7 @@ TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list) Try to locate the table in the list of thd->temporary_tables. If the table is found: + - if the table is being used by some outer statement, fail. - if the table is in thd->locked_tables, unlock it and remove it from the list of locked tables. Currently only transactional temporary tables are present in the locked_tables list. @@ -1689,24 +1719,34 @@ TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list) thd->temporary_tables list, it's impossible to tell here whether we're dealing with an internal or a user temporary table. - @retval TRUE the table was not found in the list of temporary tables - of this thread - @retval FALSE the table was found and dropped successfully. + @retval 0 the table was found and dropped successfully. + @retval 1 the table was not found in the list of temporary tables + of this thread + @retval -1 the table is in use by a outer query */ -bool close_temporary_table(THD *thd, TABLE_LIST *table_list) +int drop_temporary_table(THD *thd, TABLE_LIST *table_list) { TABLE *table; + DBUG_ENTER("drop_temporary_table"); if (!(table= find_temporary_table(thd, table_list))) - return 1; + DBUG_RETURN(1); + + /* Table might be in use by some outer statement. */ + if (table->query_id && table->query_id != thd->query_id) + { + my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias); + DBUG_RETURN(-1); + } + /* If LOCK TABLES list is not empty and contains this table, unlock the table and remove the table from this list. */ mysql_lock_remove(thd, thd->locked_tables, table, FALSE); close_temporary_table(thd, table, 1, 1); - return 0; + DBUG_RETURN(0); } /* @@ -2285,8 +2325,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, is always represented by only one TABLE object in THD, and it can not be cloned. Emit an error for an unsupported behaviour. */ - if (table->query_id == thd->query_id || - thd->prelocked_mode && table->query_id) + if (table->query_id) { DBUG_PRINT("error", ("query_id: %lu server_id: %u pseudo_thread_id: %lu", @@ -2296,7 +2335,6 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, DBUG_RETURN(0); } table->query_id= thd->query_id; - table->clear_query_id= 1; thd->thread_specific_used= TRUE; DBUG_PRINT("info",("Using temporary table")); goto reset; @@ -4306,7 +4344,6 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables) sp_remove_not_own_routines(thd->lex); for (TABLE_LIST *tmp= *tables; tmp; tmp= tmp->next_global) tmp->table= 0; - mark_used_tables_as_free_for_reuse(thd, thd->temporary_tables); close_thread_tables(thd); } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index ed7e30c1fef..19a99f9d12b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -151,6 +151,14 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables) } VOID(pthread_mutex_unlock(&LOCK_open)); } + else if (tables->table) + { + /* Must be a temporary table */ + TABLE *table= tables->table; + table->file->ha_index_or_rnd_end(); + table->query_id= thd->query_id; + table->open_by_handler= 0; + } } /* @@ -282,6 +290,12 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) goto err; } + /* + If it's a temp table, don't reset table->query_id as the table is + being used by this handler. Otherwise, no meaning at all. + */ + tables->table->open_by_handler= 1; + if (! reopen) send_ok(thd); DBUG_PRINT("exit",("OK")); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 077141c4d7a..d3010e4309b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3399,7 +3399,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, it preparable for open. But let us do close_temporary_table() here just in case. */ - close_temporary_table(thd, create_table); + drop_temporary_table(thd, create_table); } } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ea6a25d9866..7d04f564cf3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -992,9 +992,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Multiple queries exits, execute them individually */ - if (thd->lock || thd->open_tables || thd->derived_tables || - thd->prelocked_mode) - close_thread_tables(thd); + close_thread_tables(thd); ulong length= (ulong)(packet_end - next_packet); log_slow_statement(thd); @@ -1331,12 +1329,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } - if (thd->lock || thd->open_tables || thd->derived_tables || - thd->prelocked_mode) - { - thd->proc_info="closing tables"; - close_thread_tables(thd); /* Free tables */ - } + + thd->proc_info= "closing tables"; + /* Free tables */ + close_thread_tables(thd); + /* assume handlers auto-commit (if some doesn't - transaction handling in MySQL should be redesigned to support it; it's a big change, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6edb8494b03..e10e89be478 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1503,7 +1503,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, char path[FN_REFLEN], *alias; uint path_length; String wrong_tables; - int error; + int error= 0; int non_temp_tables_count= 0; bool some_tables_deleted=0, tmp_table_deleted=0, foreign_key_error=0; String built_query; @@ -1563,10 +1563,27 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, enum legacy_db_type frm_db_type; mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL, 1); - if (!close_temporary_table(thd, table)) - { - tmp_table_deleted=1; - continue; // removed temporary table + + error= drop_temporary_table(thd, table); + + switch (error) { + case 0: + // removed temporary table + tmp_table_deleted= 1; + continue; + case -1: + // table already in use + /* + XXX: This branch should never be taken outside of SF, trigger or + prelocked mode. + + DBUG_ASSERT(thd->in_sub_stmt); + */ + error= 1; + goto err_with_placeholders; + default: + // temporary table not found + error= 0; } /* @@ -1593,7 +1610,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, built_query.append("`,"); } - error=0; table_type= table->db_type; if (!drop_temporary) { diff --git a/sql/table.h b/sql/table.h index 6554b6ed578..2bbd71b70c6 100644 --- a/sql/table.h +++ b/sql/table.h @@ -499,6 +499,24 @@ struct st_table { my_bitmap_map *bitmap_init_value; MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */ MY_BITMAP *read_set, *write_set; /* Active column sets */ + /* + The ID of the query that opened and is using this table. Has different + meanings depending on the table type. + + Temporary tables: + + table->query_id is set to thd->query_id for the duration of a statement + and is reset to 0 once it is closed by the same statement. A non-zero + table->query_id means that a statement is using the table even if it's + not the current statement (table is in use by some outer statement). + + Non-temporary tables: + + Under pre-locked or LOCK TABLES mode: query_id is set to thd->query_id + for the duration of a statement and is reset to 0 once it is closed by + the same statement. A non-zero query_id is used to control which tables + in the list of pre-opened and locked tables are actually being used. + */ query_id_t query_id; /* @@ -593,8 +611,8 @@ struct st_table { my_bool locked_by_name; my_bool fulltext_searched; my_bool no_cache; - /* To signal that we should reset query_id for tables and cols */ - my_bool clear_query_id; + /* To signal that the table is associated with a HANDLER statement */ + my_bool open_by_handler; /* To indicate that a non-null value of the auto_increment field was provided by the user or retrieved from the current record. From 2ce9194411a665f8d6f65e52a808609a900cff80 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Fri, 2 Nov 2007 02:36:12 +0300 Subject: [PATCH 065/128] A fix for Bug#32030 "DELETE does not return an error and deletes rows if error evaluating WHERE" DELETE with a subquery in WHERE clause would sometimes ignore subquery evaluation error and proceed with deletion. The fix is to check for an error after evaluation of the WHERE clause in DELETE. Addressed review comments. --- mysql-test/r/group_min_max.result | 3 +-- mysql-test/r/ps.result | 20 +++++++++++++++++++ mysql-test/t/group_min_max.test | 1 + mysql-test/t/ps.test | 33 +++++++++++++++++++++++++++++++ sql/sql_delete.cc | 11 +++++++++-- 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index f62fd662a5d..270f248ea9c 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2299,8 +2299,7 @@ Handler_read_next 0 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1) > 10000; -Warnings: -Error 1242 Subquery returns more than 1 row +ERROR 21000: Subquery returns more than 1 row SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index edac68a88d6..db9f0613d7f 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -2680,4 +2680,24 @@ t1 CREATE TABLE `t1` ( KEY `c` (`c`(10)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +create table t1 (a int, b int); +create table t2 like t1; +insert into t1 (a, b) values (1,1), (1,2), (1,3), (1,4), (1,5), +(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +insert into t2 select a, max(b) from t1 group by a; +prepare stmt from "delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000"; +delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000; +ERROR 21000: Subquery returns more than 1 row +execute stmt; +ERROR 21000: Subquery returns more than 1 row +execute stmt; +ERROR 21000: Subquery returns more than 1 row +deallocate prepare stmt; +drop table t1, t2; End of 5.1 tests. diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index cf25b4c61be..9d1e065797d 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -890,6 +890,7 @@ FLUSH STATUS; DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; SHOW STATUS LIKE 'handler_read__e%'; FLUSH STATUS; +--error ER_SUBQUERY_NO_1_ROW DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1) > 10000; SHOW STATUS LIKE 'handler_read__e%'; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index dea86bdd2fa..c528fddaf93 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -2778,4 +2778,37 @@ execute stmt; show create table t1; drop table t1; +# +# Bug #32030 DELETE does not return an error and deletes rows if error +# evaluating WHERE +# +# Test that there is an error for prepared delete just like for the normal +# one. +# + +drop table if exists t1, t2; +create table t1 (a int, b int); +create table t2 like t1; + +insert into t1 (a, b) values (1,1), (1,2), (1,3), (1,4), (1,5), + (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); + +insert into t2 select a, max(b) from t1 group by a; + +prepare stmt from "delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000"; + +--error ER_SUBQUERY_NO_1_ROW +delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; + +deallocate prepare stmt; +drop table t1, t2; + + + --echo End of 5.1 tests. diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 219dc90429b..f183cb3142f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -35,6 +35,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, READ_RECORD info; bool using_limit=limit != HA_POS_ERROR; bool transactional_table, safe_update, const_cond; + bool const_cond_result; ha_rows deleted= 0; uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; @@ -86,6 +87,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, select_lex->no_error= thd->lex->ignore; + const_cond_result= const_cond && (!conds || conds->val_int()); + if (thd->is_error()) + { + /* Error evaluating val_int(). */ + DBUG_RETURN(TRUE); + } /* Test if the user wants to delete all rows and deletion doesn't have any side-effects (because of triggers), so we can use optimized @@ -105,7 +112,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, - We should not be binlogging this statement row-based, and - there should be no delete triggers associated with the table. */ - if (!using_limit && const_cond && (!conds || conds->val_int()) && + if (!using_limit && const_cond_result && !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && (thd->lex->sql_command == SQLCOM_TRUNCATE || (!thd->current_stmt_binlog_row_based && @@ -300,7 +307,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, else table->file->unlock_row(); // Row failed selection, release lock on it } - if (thd->killed && !error) + if (thd->killed || thd->is_error()) error= 1; // Aborted if (will_batch && (loc_error= table->file->end_bulk_delete())) { From b0e9fa31afb8c110bb1dcef0f1f46d20279ba6b6 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Fri, 2 Nov 2007 12:24:45 +0400 Subject: [PATCH 066/128] Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names db name should be quoted. this code does communication with the server. it's always ok to quote names in this case. --- client/mysqldump.c | 4 +++- mysql-test/r/mysqldump.result | 19 +++++++++++++++++++ mysql-test/t/mysqldump.test | 12 ++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index d504d177490..f5362b272cd 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1040,8 +1040,10 @@ static int fetch_db_collation(const char *db_name, char query[QUERY_LENGTH]; MYSQL_RES *db_cl_res; MYSQL_ROW db_cl_row; + char quoted_database_buf[NAME_LEN*2+3]; + char *qdatabase= quote_name(db_name, quoted_database_buf, 1); - my_snprintf(query, sizeof (query), "use %s", db_name); + my_snprintf(query, sizeof (query), "use %s", qdatabase); if (mysql_query_with_error_report(mysql, NULL, query)) return 1; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index c0856314ba5..d07aed5317a 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -4212,5 +4212,24 @@ TRUNCATE mysql.event; SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation # +# Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names +# +create database `test-database`; +use `test-database`; +create table test (a int); +DROP TABLE IF EXISTS `test`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `test` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +SET character_set_client = @saved_cs_client; +LOCK TABLES `test` WRITE; +/*!40000 ALTER TABLE `test` DISABLE KEYS */; +/*!40000 ALTER TABLE `test` ENABLE KEYS */; +UNLOCK TABLES; +drop database `test-database`; +use test; +# # End of 5.1 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 158e8a769bd..0e4e9989ffa 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1788,6 +1788,18 @@ TRUNCATE mysql.event; --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql SHOW EVENTS; + +--echo # +--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names +--echo # +create database `test-database`; +use `test-database`; +create table test (a int); +--exec $MYSQL_DUMP --compact --opt --quote-names test-database +drop database `test-database`; +use test; + + --echo # --echo # End of 5.1 tests --echo # From 4198c2bcf5f28a088bc9610fb2d2fbe9f9548309 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Fri, 2 Nov 2007 12:39:14 +0400 Subject: [PATCH 067/128] Bug#31630 debug assert with explain extended select ... from i_s added 'in_rows' column value for 'describe extended' for the case when 'describe' handles I_S table --- mysql-test/r/information_schema.result | 5 +++++ mysql-test/t/information_schema.test | 5 +++++ sql/sql_select.cc | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 7693fe628ef..18ffb4a37ea 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1604,4 +1604,9 @@ select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION +explain extended select 1 from information_schema.TABLES; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE TABLES ALL NULL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases +Warnings: +Note 1003 select 1 AS `1` from `information_schema`.`TABLES` End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 1987d9d5773..5ac7ffa42ad 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1232,4 +1232,9 @@ select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; +# +# Bug#31630 debug assert with explain extended select ... from i_s +# +explain extended select 1 from information_schema.TABLES; + --echo End of 5.1 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 140daf8b55d..596f8d8a294 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15819,6 +15819,10 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, /* Add "rows" field to item_list. */ if (table_list->schema_table) { + /* in_rows */ + if (join->thd->lex->describe & DESCRIBE_EXTENDED) + item_list.push_back(item_null); + /* rows */ item_list.push_back(item_null); } else From 3afce4aa2ca1bd0dcf694e23163d05ff8a9d96ce Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Fri, 2 Nov 2007 09:58:29 +0100 Subject: [PATCH 068/128] Bug#32048 - innodb_mysql.test produces warnings files Typo --#echo at line begin in test files lead to warnings from mysqltest. Changed to --echo #. --- mysql-test/include/mix1.inc | 2 +- mysql-test/r/innodb_mysql.result | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index c8d3ba79e39..211bd0b4908 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1163,7 +1163,7 @@ CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) ENGINE = $engine_type; INSERT INTO t1 VALUES (1,2); ---#echo 1. test for locking: +--echo # 1. test for locking: BEGIN; --enable_info diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 44d874ef018..2332056ec39 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1426,6 +1426,7 @@ SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) ENGINE = InnoDB; INSERT INTO t1 VALUES (1,2); +# 1. test for locking: BEGIN; UPDATE t1 SET b = 12 WHERE a = 1; affected rows: 1 From 8d4b8423f71d0fe64e4ed293470698c4ac6f60dc Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Fri, 2 Nov 2007 10:11:26 +0100 Subject: [PATCH 069/128] Bug#31030 - rpl000015.test fails if $MYSQL_TCP_PORT != 3306 Preliminarily disabled test case --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 9bfe9567d83..80b28e11da6 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,3 +10,4 @@ # ############################################################################## +rpl000015 : Bug#31030 - rpl000015.test fails if $MYSQL_TCP_PORT != 3306 From 9cd5f49c538dc266b41479d9e0bc63a47f4d766c Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Fri, 2 Nov 2007 13:40:34 +0300 Subject: [PATCH 070/128] Fix for: bug #26215: mysql command line client should not strip comments from SQL statements and bug #11230: Keeping comments when storing stored procedures With the introduction of multiline comments support in the command line client (mysql) in MySQL 4.1, it became impossible to preserve client-side comments within single SQL statements or stored routines. This feature was useful for monitoring tools and maintenance. The patch adds a new option to the command line client ('--enable-comments', '-c') which allows to preserve SQL comments and send them to the server for single SQL statements, and to keep comments in the code for stored procedures / functions / triggers. The patch is a modification of the contributed patch from bug #11230 with the following changes: - code style changes to conform to the coding guidelines - changed is_prefix() to my_strnncoll() to detect the DELIMITER command, since the first one is case-sensitive and not charset-aware - renamed t/comments-51.* to t/mysql_comments.* - removed tests for comments in triggers since 5.0 does not have SHOW CREATE TRIGGER (those tests will be added back in 5.1). The test cases are only for bug #11230. No automated test case for bug #26215 is possible due to the test suite deficiencies (though the cases from the bug report were tested manually). --- client/mysql.cc | 168 ++++++++++++++++++++------- mysql-test/r/mysql_comments.result | 50 ++++++++ mysql-test/t/mysql_comments.sql | 177 +++++++++++++++++++++++++++++ mysql-test/t/mysql_comments.test | 37 ++++++ 4 files changed, 389 insertions(+), 43 deletions(-) create mode 100644 mysql-test/r/mysql_comments.result create mode 100644 mysql-test/t/mysql_comments.sql create mode 100644 mysql-test/t/mysql_comments.test diff --git a/client/mysql.cc b/client/mysql.cc index 8e1b6c2a9b4..2c6d0df2274 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -140,6 +140,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, default_pager_set= 0, opt_sigint_ignore= 0, show_warnings= 0; static volatile int executing_query= 0, interrupted_query= 0; +static my_bool preserve_comments= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; @@ -754,6 +755,10 @@ static struct my_option my_long_options[] = {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.", (gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"comments", 'c', "Preserve comments. Send comments to the server." + " Comments are discarded by default, enable with --enable-comments", + (gptr*) &preserve_comments, (gptr*) &preserve_comments, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1131,10 +1136,6 @@ static int read_and_execute(bool interactive) status.exit_status=0; break; } - if (!in_string && (line[0] == '#' || - (line[0] == '-' && line[1] == '-') || - line[0] == 0)) - continue; // Skip comment lines /* Check if line is a mysql command line @@ -1260,15 +1261,21 @@ static bool add_line(String &buffer,char *line,char *in_string, for (pos=out=line ; (inchar= (uchar) *pos) ; pos++) { - if (my_isspace(charset_info,inchar) && out == line && - buffer.is_empty()) - continue; + if (!preserve_comments) + { + // Skip spaces at the beggining of a statement + if (my_isspace(charset_info,inchar) && (out == line) && + buffer.is_empty()) + continue; + } + #ifdef USE_MB + // Accept multi-byte characters as-is int length; if (use_mb(charset_info) && (length= my_ismbchar(charset_info, pos, end_of_line))) { - if (!*ml_comment) + if (!*ml_comment || preserve_comments) { while (length--) *out++ = *pos++; @@ -1294,8 +1301,13 @@ static bool add_line(String &buffer,char *line,char *in_string, } if ((com=find_command(NullS,(char) inchar))) { - const String tmp(line,(uint) (out-line), charset_info); - buffer.append(tmp); + // Flush previously accepted characters + if (out != line) + { + buffer.append(line, (uint) (out-line)); + out= line; + } + if ((*com->func)(&buffer,pos-1) > 0) DBUG_RETURN(1); // Quit if (com->takes_params) @@ -1323,7 +1335,6 @@ static bool add_line(String &buffer,char *line,char *in_string, pos+= delimiter_length - 1; // Point at last delim char } } - out=line; } else { @@ -1336,46 +1347,106 @@ static bool add_line(String &buffer,char *line,char *in_string, } } else if (!*ml_comment && !*in_string && - (*pos == *delimiter && is_prefix(pos + 1, delimiter + 1) || - buffer.length() == 0 && (out - line) >= 9 && - !my_strcasecmp(charset_info, line, "delimiter"))) - { - uint old_delimiter_length= delimiter_length; + (out - line) >= 9 && + !my_strnncoll(charset_info, (uchar*) pos, 9, + (const uchar*) "delimiter", 9) && + my_isspace(charset_info, pos[9])) + { + // Flush previously accepted characters if (out != line) - buffer.append(line, (uint) (out - line)); // Add this line + { + buffer.append(line, (uint32) (out - line)); + out= line; + } + + // Flush possible comments in the buffer + if (!buffer.is_empty()) + { + if (com_go(&buffer, 0) > 0) // < 0 is not fatal + DBUG_RETURN(1); + buffer.length(0); + } + + /* + Delimiter wants the get rest of the given line as argument to + allow one to change ';' to ';;' and back + */ + buffer.append(pos); + if (com_delimiter(&buffer, pos) > 0) + DBUG_RETURN(1); + + buffer.length(0); + break; + } + else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter)) + { + // Found a statement. Continue parsing after the delimiter + pos+= delimiter_length; + + if (preserve_comments) + { + while (my_isspace(charset_info, *pos)) + *out++= *pos++; + } + // Flush previously accepted characters + if (out != line) + { + buffer.append(line, (uint32) (out-line)); + out= line; + } + + if (preserve_comments && ((*pos == '#') || + ((*pos == '-') && + (pos[1] == '-') && + my_isspace(charset_info, pos[2])))) + { + // Add trailing single line comments to this statement + buffer.append(pos); + pos+= strlen(pos); + } + + pos--; + if ((com= find_command(buffer.c_ptr(), 0))) { - if (com->func == com_delimiter) - { - /* - Delimiter wants the get rest of the given line as argument to - allow one to change ';' to ';;' and back - */ - char *end= strend(pos); - buffer.append(pos, (uint) (end - pos)); - /* Ensure pos will point at \0 after the pos+= below */ - pos= end - old_delimiter_length + 1; - } - if ((*com->func)(&buffer, buffer.c_ptr()) > 0) - DBUG_RETURN(1); // Quit + + if ((*com->func)(&buffer, buffer.c_ptr()) > 0) + DBUG_RETURN(1); // Quit } else { - if (com_go(&buffer, 0) > 0) // < 0 is not fatal - DBUG_RETURN(1); + if (com_go(&buffer, 0) > 0) // < 0 is not fatal + DBUG_RETURN(1); } buffer.length(0); - out= line; - pos+= old_delimiter_length - 1; } else if (!*ml_comment && (!*in_string && (inchar == '#' || inchar == '-' && pos[1] == '-' && my_isspace(charset_info,pos[2])))) - break; // comment to end of line + { + // Flush previously accepted characters + if (out != line) + { + buffer.append(line, (uint32) (out - line)); + out= line; + } + + // comment to end of line + if (preserve_comments) + buffer.append(pos); + + break; + } else if (!*in_string && inchar == '/' && *(pos+1) == '*' && *(pos+2) != '!') { - pos++; + if (preserve_comments) + { + *out++= *pos++; // copy '/' + *out++= *pos; // copy '*' + } + else + pos++; *ml_comment= 1; if (out != line) { @@ -1385,8 +1456,21 @@ static bool add_line(String &buffer,char *line,char *in_string, } else if (*ml_comment && !ss_comment && inchar == '*' && *(pos + 1) == '/') { - pos++; + if (preserve_comments) + { + *out++= *pos++; // copy '*' + *out++= *pos; // copy '/' + } + else + pos++; *ml_comment= 0; + if (out != line) + { + buffer.append(line, (uint32) (out - line)); + out= line; + } + // Consumed a 2 chars or more, and will add 1 at most, + // so using the 'line' buffer to edit data in place is ok. need_space= 1; } else @@ -1401,14 +1485,12 @@ static bool add_line(String &buffer,char *line,char *in_string, else if (!*ml_comment && !*in_string && (inchar == '\'' || inchar == '"' || inchar == '`')) *in_string= (char) inchar; - if (!*ml_comment) + if (!*ml_comment || preserve_comments) { if (need_space && !my_isspace(charset_info, (char)inchar)) - { *out++= ' '; - need_space= 0; - } - *out++= (char) inchar; + need_space= 0; + *out++= (char) inchar; } } } @@ -1418,7 +1500,7 @@ static bool add_line(String &buffer,char *line,char *in_string, uint length=(uint) (out-line); if (buffer.length() + length >= buffer.alloced_length()) buffer.realloc(buffer.length()+length+IO_SIZE); - if (!(*ml_comment) && buffer.append(line,length)) + if ((!*ml_comment || preserve_comments) && buffer.append(line, length)) DBUG_RETURN(1); } DBUG_RETURN(0); diff --git a/mysql-test/r/mysql_comments.result b/mysql-test/r/mysql_comments.result new file mode 100644 index 00000000000..366ceeb5bbf --- /dev/null +++ b/mysql-test/r/mysql_comments.result @@ -0,0 +1,50 @@ +drop table if exists t1; +drop function if exists foofct; +drop procedure if exists empty; +drop procedure if exists foosp; +drop procedure if exists nicesp; +drop trigger if exists t1_empty; +drop trigger if exists t1_bi; +"Pass 1 : --disable-comments" +1 +1 +2 +2 +foofct("call 1") +call 1 +Function sql_mode Create Function +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n\n\n\nx +foofct("call 2") +call 2 +Function sql_mode Create Function +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n \n \n \n\n \n\n \n return x;\nend +Procedure sql_mode Create Procedure +empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend +id data +foo 42 +Procedure sql_mode Create Procedure +foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n\n\n\n\n \n\n \n values ("foo", 42) +Procedure sql_mode Create Procedure +nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n \n declare b int;\n declare c float;\n\n \n \n\n \nend +"Pass 2 : --enable-comments" +1 +1 +2 +2 +foofct("call 1") +call 1 +Function sql_mode Create Function +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n-- comment 1a\n# comment 1b\n/* comment 1c */\nx # after body, on same line +foofct("call 2") +call 2 +Function sql_mode Create Function +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n -- comment 1a\n # comment 1b\n /*\n comment 1c\n */\n\n -- empty line below\n\n -- empty line above\n return x;\nend +Procedure sql_mode Create Procedure +empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend +id data +foo 42 +Procedure sql_mode Create Procedure +foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n## These comments are part of the procedure body, and should be kept.\n# Comment 2a\n-- Comment 2b\n/* Comment 2c */\n -- empty line below\n\n -- empty line above\n values ("foo", 42) # comment 3, still part of the body +Procedure sql_mode Create Procedure +nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\nend +End of 5.0 tests diff --git a/mysql-test/t/mysql_comments.sql b/mysql-test/t/mysql_comments.sql new file mode 100644 index 00000000000..60b223a240f --- /dev/null +++ b/mysql-test/t/mysql_comments.sql @@ -0,0 +1,177 @@ +##============================================================================ +## Notes +##============================================================================ + +# Test case for Bug#11230 + +# The point of this test is to make sure that '#', '-- ' and '/* ... */' +# comments, as well as empty lines, are sent from the client to the server. +# This is to ensure better error reporting, and to keep comments in the code +# for stored procedures / functions / triggers (Bug#11230). +# As a result, be careful when editing comments in this script, they do +# matter. +# +# Also, note that this is a script for **mysql**, not mysqltest. +# This is critical, as the mysqltest client interprets comments differently. + +##============================================================================ +## Setup +##============================================================================ + +## See mysql_comments.test for initial cleanup + +# Test tables +# +# t1 is reused throughout the file, and dropped at the end. +# +drop table if exists t1; +create table t1 ( + id char(16) not null default '', + data int not null +); + +##============================================================================ +## Comments outside statements +##============================================================================ + +# Ignored 1a +-- Ignored 1b +/* + Ignored 1c +*/ + +select 1; + +##============================================================================ +## Comments inside statements +##============================================================================ + +select # comment 1a +# comment 2a +-- comment 2b +/* + comment 2c +*/ +2 +; # not strictly inside, but on same line +# ignored + +##============================================================================ +## Comments inside functions +##============================================================================ + +drop function if exists foofct ; + +create function foofct (x char(20)) +returns char(20) +/* not inside the body yet */ +return +-- comment 1a +# comment 1b +/* comment 1c */ +x; # after body, on same line + +select foofct("call 1"); + +show create function foofct; +drop function foofct; + +delimiter | + +create function foofct(x char(20)) +returns char(20) +begin + -- comment 1a + # comment 1b + /* + comment 1c + */ + + -- empty line below + + -- empty line above + return x; +end| + +delimiter ; + +select foofct("call 2"); + +show create function foofct; +drop function foofct; + +##============================================================================ +## Comments inside stored procedures +##============================================================================ + +# Empty statement +drop procedure if exists empty; +create procedure empty() +begin +end; + +call empty(); +show create procedure empty; +drop procedure empty; + +drop procedure if exists foosp; + +## These comments are before the create, and will be lost +# Comment 1a +-- Comment 1b +/* + Comment 1c + */ +create procedure foosp() +/* Comment not quiet in the body yet */ + insert into test.t1 +## These comments are part of the procedure body, and should be kept. +# Comment 2a +-- Comment 2b +/* Comment 2c */ + -- empty line below + + -- empty line above + values ("foo", 42); # comment 3, still part of the body +## After the ';', therefore not part of the body +# comment 4a +-- Comment 4b +/* + Comment 4c + */ + +call foosp(); +select * from t1; +delete from t1; +show create procedure foosp; +drop procedure foosp; + +drop procedure if exists nicesp; + +delimiter | + +create procedure nicesp(a int) +begin + -- declare some variables here + declare b int; + declare c float; + + -- do more stuff here + -- commented nicely and so on + + -- famous last words ... +end| + +delimiter ; + +show create procedure nicesp; +drop procedure nicesp; + +# Triggers can be tested only in 5.1, since 5.0 does not have +# SHOW CREATE TRIGGER + +##============================================================================ +## Cleanup +##============================================================================ + +drop table t1; diff --git a/mysql-test/t/mysql_comments.test b/mysql-test/t/mysql_comments.test new file mode 100644 index 00000000000..1f997aeb1ab --- /dev/null +++ b/mysql-test/t/mysql_comments.test @@ -0,0 +1,37 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc +###################### mysql_comments.test ############################# +# # +# Testing of comments handling by the command line client (mysql) # +# # +# Creation: # +# 2007-10-29 akopytov Implemented this test as a part of fixes for # +# bug #26215 and bug #11230 # +# # +######################################################################## + +# +# Bug #11230: Keeping comments when storing stored procedures +# + +# See the content of mysql_comments.sql +# Set the test database to a known state before running the tests. +--disable_warnings +drop table if exists t1; +drop function if exists foofct; +drop procedure if exists empty; +drop procedure if exists foosp; +drop procedure if exists nicesp; +drop trigger if exists t1_empty; +drop trigger if exists t1_bi; +--enable_warnings + +# Test without comments +--echo "Pass 1 : --disable-comments" +--exec $MYSQL --disable-comments test 2>&1 < "./t/mysql_comments.sql" + +# Test with comments +--echo "Pass 2 : --enable-comments" +--exec $MYSQL --enable-comments test 2>&1 < "./t/mysql_comments.sql" + +--echo End of 5.0 tests From b9550052455de9ffa43f44c920d5b8e30979f70a Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.(none)" <> Date: Fri, 2 Nov 2007 14:47:18 +0300 Subject: [PATCH 071/128] Cleanup the test case for Bug#32030 "DELETE does not return an error and deletes rows if error evaluating WHERE" --- mysql-test/r/ps.result | 3 --- mysql-test/t/ps.test | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index db9f0613d7f..9d0906ad5e7 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -2681,9 +2681,6 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; drop table if exists t1, t2; -Warnings: -Note 1051 Unknown table 't1' -Note 1051 Unknown table 't2' create table t1 (a int, b int); create table t2 like t1; insert into t1 (a, b) values (1,1), (1,2), (1,3), (1,4), (1,5), diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index c528fddaf93..fd7caeb195e 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -2785,8 +2785,9 @@ drop table t1; # Test that there is an error for prepared delete just like for the normal # one. # - +--disable_warnings drop table if exists t1, t2; +--enable_warnings create table t1 (a int, b int); create table t2 like t1; From 794274ab10c1ac08e3596d6551f26f545dc8cbc6 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Fri, 2 Nov 2007 16:40:08 +0300 Subject: [PATCH 072/128] 5.1-specific changes for bug #26215 after merging the patch from 5.0: - Added trigger tests back. - Fixed test cases to match the extended output format of SHOW CREATE ... - Replaced 'gptr' with 'uchar *'. --- client/mysql.cc | 2 +- mysql-test/r/mysql_comments.result | 52 ++++++++++++++++++------------ mysql-test/t/mysql_comments.sql | 45 ++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 699fd3ea19d..3a89dec2557 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -776,7 +776,7 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"comments", 'c', "Preserve comments. Send comments to the server." " Comments are discarded by default, enable with --enable-comments", - (gptr*) &preserve_comments, (gptr*) &preserve_comments, + (uchar**) &preserve_comments, (uchar**) &preserve_comments, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/mysql-test/r/mysql_comments.result b/mysql-test/r/mysql_comments.result index 366ceeb5bbf..7f1c0b50c5e 100644 --- a/mysql-test/r/mysql_comments.result +++ b/mysql-test/r/mysql_comments.result @@ -12,20 +12,26 @@ drop trigger if exists t1_bi; 2 foofct("call 1") call 1 -Function sql_mode Create Function -foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n\n\n\nx +Function sql_mode Create Function character_set_client collation_connection Database Collation +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n\n\n\nx latin1 latin1_swedish_ci latin1_swedish_ci foofct("call 2") call 2 -Function sql_mode Create Function -foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n \n \n \n\n \n\n \n return x;\nend -Procedure sql_mode Create Procedure -empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend +Function sql_mode Create Function character_set_client collation_connection Database Collation +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n \n \n \n\n \n\n \n return x;\nend latin1 latin1_swedish_ci latin1_swedish_ci +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend latin1 latin1_swedish_ci latin1_swedish_ci id data foo 42 -Procedure sql_mode Create Procedure -foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n\n\n\n\n \n\n \n values ("foo", 42) -Procedure sql_mode Create Procedure -nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n \n declare b int;\n declare c float;\n\n \n \n\n \nend +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n\n\n\n\n \n\n \n values ("foo", 42) latin1 latin1_swedish_ci latin1_swedish_ci +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n \n declare b int;\n declare c float;\n\n \n \n\n \nend latin1 latin1_swedish_ci latin1_swedish_ci +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation +t1_empty CREATE DEFINER=`root`@`localhost` trigger t1_empty after delete on t1\nfor each row\nbegin\nend latin1 latin1_swedish_ci latin1_swedish_ci +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation +t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n\n\n\n \n declare b int;\n declare c float;\n\n \n \n\n \n set NEW.data := 12;\nend latin1 latin1_swedish_ci latin1_swedish_ci +id data +trig 12 "Pass 2 : --enable-comments" 1 1 @@ -33,18 +39,24 @@ nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n \n 2 foofct("call 1") call 1 -Function sql_mode Create Function -foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n-- comment 1a\n# comment 1b\n/* comment 1c */\nx # after body, on same line +Function sql_mode Create Function character_set_client collation_connection Database Collation +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n-- comment 1a\n# comment 1b\n/* comment 1c */\nx # after body, on same line latin1 latin1_swedish_ci latin1_swedish_ci foofct("call 2") call 2 -Function sql_mode Create Function -foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n -- comment 1a\n # comment 1b\n /*\n comment 1c\n */\n\n -- empty line below\n\n -- empty line above\n return x;\nend -Procedure sql_mode Create Procedure -empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend +Function sql_mode Create Function character_set_client collation_connection Database Collation +foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n -- comment 1a\n # comment 1b\n /*\n comment 1c\n */\n\n -- empty line below\n\n -- empty line above\n return x;\nend latin1 latin1_swedish_ci latin1_swedish_ci +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend latin1 latin1_swedish_ci latin1_swedish_ci id data foo 42 -Procedure sql_mode Create Procedure -foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n## These comments are part of the procedure body, and should be kept.\n# Comment 2a\n-- Comment 2b\n/* Comment 2c */\n -- empty line below\n\n -- empty line above\n values ("foo", 42) # comment 3, still part of the body -Procedure sql_mode Create Procedure -nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\nend +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n## These comments are part of the procedure body, and should be kept.\n# Comment 2a\n-- Comment 2b\n/* Comment 2c */\n -- empty line below\n\n -- empty line above\n values ("foo", 42) # comment 3, still part of the body latin1 latin1_swedish_ci latin1_swedish_ci +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\nend latin1 latin1_swedish_ci latin1_swedish_ci +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation +t1_empty CREATE DEFINER=`root`@`localhost` trigger t1_empty after delete on t1\nfor each row\nbegin\nend latin1 latin1_swedish_ci latin1_swedish_ci +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation +t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n# comment 1a\n-- comment 1b\n/*\n comment 1c\n*/\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\n set NEW.data := 12;\nend latin1 latin1_swedish_ci latin1_swedish_ci +id data +trig 12 End of 5.0 tests diff --git a/mysql-test/t/mysql_comments.sql b/mysql-test/t/mysql_comments.sql index 60b223a240f..2497c35e465 100644 --- a/mysql-test/t/mysql_comments.sql +++ b/mysql-test/t/mysql_comments.sql @@ -167,8 +167,49 @@ delimiter ; show create procedure nicesp; drop procedure nicesp; -# Triggers can be tested only in 5.1, since 5.0 does not have -# SHOW CREATE TRIGGER +##============================================================================ +## Comments inside triggers +##============================================================================ + +drop trigger if exists t1_empty; + +create trigger t1_empty after delete on t1 +for each row +begin +end; + +show create trigger t1_empty; + +drop trigger if exists t1_bi; + +delimiter | + +create trigger t1_bi before insert on t1 +for each row +begin +# comment 1a +-- comment 1b +/* + comment 1c +*/ + -- declare some variables here + declare b int; + declare c float; + + -- do more stuff here + -- commented nicely and so on + + -- famous last words ... + set NEW.data := 12; +end| + +delimiter ; + +show create trigger t1_bi; + +# also make sure the trigger still works +insert into t1(id) value ("trig"); +select * from t1; ##============================================================================ ## Cleanup From 626e12624e15a2fd2e7c61eb8bbcf3e6497bc57d Mon Sep 17 00:00:00 2001 From: "antony@pcg5ppc.xiphis.org" <> Date: Fri, 2 Nov 2007 14:25:48 -0700 Subject: [PATCH 073/128] fix for 2.4.6 bug should be properly enclosed to not break other versions. --- sql/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 299f4ae4285..77abc4e6fa5 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -90,12 +90,14 @@ TARGET_LINK_LIBRARIES(mysqld SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX}) +IF(cmake_version EQUAL 20406) # Work around for 2.4.6 bug, OUTPUT_NAME will not set the right .PDB # file name. Note that COMPILE_FLAGS set some temporary pdb during build, # LINK_FLAGS sets the real one. SET_TARGET_PROPERTIES(mysqld PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/mysqld${MYSQLD_EXE_SUFFIX}.pdb" LINK_FLAGS "/PDB:${CMAKE_CFG_INTDIR}/mysqld${MYSQLD_EXE_SUFFIX}.pdb") +ENDIF(cmake_version EQUAL 20406) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("mysqld" "asInvoker") From c0138b94f0074f7632e0b3d619e6300900497a7a Mon Sep 17 00:00:00 2001 From: "mats@kindahl-laptop.dnsalias.net" <> Date: Sat, 3 Nov 2007 01:33:48 +0100 Subject: [PATCH 074/128] BUG#31611 (Security risk with BINLOG statement): Adding check that the user executing a BINLOG statement has SUPER privileges and aborting execution of the statement with an error otherwise. --- mysql-test/r/mysqlbinlog.result | 22 ++++++++++++++++++++++ mysql-test/t/mysqlbinlog.test | 27 +++++++++++++++++++++++++++ sql/sql_binlog.cc | 6 ++++++ 3 files changed, 55 insertions(+) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index f10ae4b4df5..287fbd7e7f3 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -328,4 +328,26 @@ drop table t1; drop table t1; End of 5.0 tests flush logs; +BUG#31611: Security risk with BINLOG statement +SET BINLOG_FORMAT=ROW; +CREATE DATABASE mysqltest1; +CREATE USER untrusted@localhost; +GRANT SELECT ON mysqltest1.* TO untrusted@localhost; +SHOW GRANTS FOR untrusted@localhost; +Grants for untrusted@localhost +GRANT USAGE ON *.* TO 'untrusted'@'localhost' +GRANT SELECT ON `mysqltest1`.* TO 'untrusted'@'localhost' +USE mysqltest1; +CREATE TABLE t1 (a INT, b CHAR(64)); +flush logs; +INSERT INTO t1 VALUES (1,USER()); +flush logs; +mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql +mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql +INSERT INTO t1 VALUES (1,USER()); +ERROR 42000: INSERT command denied to user 'untrusted'@'localhost' for table 't1' +SELECT * FROM t1; +a b +1 root@localhost +DROP DATABASE mysqltest1; End of 5.1 tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 25bd9a402ae..8635bbfab87 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -250,4 +250,31 @@ flush logs; --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000016 >/dev/null 2>/dev/null --exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000016 >/dev/null 2>/dev/null +--echo BUG#31611: Security risk with BINLOG statement + +SET BINLOG_FORMAT=ROW; +CREATE DATABASE mysqltest1; +CREATE USER untrusted@localhost; +GRANT SELECT ON mysqltest1.* TO untrusted@localhost; + +SHOW GRANTS FOR untrusted@localhost; +USE mysqltest1; +CREATE TABLE t1 (a INT, b CHAR(64)); +flush logs; +INSERT INTO t1 VALUES (1,USER()); +flush logs; +echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql; +exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql; +connect (unsecure,localhost,untrusted,,mysqltest1); +echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql; +error 1; +exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql; +connection unsecure; +error ER_TABLEACCESS_DENIED_ERROR; +INSERT INTO t1 VALUES (1,USER()); + +SELECT * FROM t1; +connection default; +DROP DATABASE mysqltest1; + --echo End of 5.1 tests diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 87224b8eea0..95eea9f20fa 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -37,6 +37,12 @@ void mysql_client_binlog_statement(THD* thd) thd->lex->comment.length : 2048), thd->lex->comment.str)); + if (check_global_access(thd, SUPER_ACL)) + { + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER"); + DBUG_VOID_RETURN; + } + /* Temporarily turn off send_ok, since different events handle this differently From 241cd5f969e04c0b9e294f7c2d7c3c7e708d86b8 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Mon, 5 Nov 2007 10:57:52 +0100 Subject: [PATCH 075/128] Bug#4692 - DISABLE/ENABLE KEYS waste a space Fixed absurd compiler warnings of a Suse 10.1 system. --- storage/myisam/mi_check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index feb639d48f9..7cd35295cb0 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2225,6 +2225,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, SORT_INFO sort_info; ulonglong key_map; DBUG_ENTER("mi_repair_by_sort"); + LINT_INIT(key_map); start_records=info->state->records; got_error=1; @@ -2649,6 +2650,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ulonglong key_map; pthread_attr_t thr_attr; DBUG_ENTER("mi_repair_parallel"); + LINT_INIT(key_map); start_records=info->state->records; got_error=1; From 910003b54493e65861f1a4f1e96997b1f93a9f00 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Mon, 5 Nov 2007 13:30:31 +0300 Subject: [PATCH 076/128] Fixed code that parses the DELIMITER command to correctly calculate the length of the remaining input string. This is to fix mysqldump test failure in PB introduced by the patch for bug #26215. --- client/mysql.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2c6d0df2274..a8d88bec274 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1347,10 +1347,9 @@ static bool add_line(String &buffer,char *line,char *in_string, } } else if (!*ml_comment && !*in_string && - (out - line) >= 9 && - !my_strnncoll(charset_info, (uchar*) pos, 9, - (const uchar*) "delimiter", 9) && - my_isspace(charset_info, pos[9])) + strlen(pos) >= 10 && + !my_strnncoll(charset_info, (uchar*) pos, 10, + (const uchar*) "delimiter ", 10)) { // Flush previously accepted characters if (out != line) From 8f6a0a4c3cb8da473ca755e2da58e1e9ce02c029 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 5 Nov 2007 13:19:56 +0200 Subject: [PATCH 077/128] Bug #31974: Wrong EXPLAIN output The fix for bug 31148 is not correct. It does not have a relation to the problem described in this bug. And removing the fix will not make the bug to re-appear. Fixed the bug #31974 by removing the fix for bug 31148 and adding a test case. --- mysql-test/r/key.result | 14 ++++++++++++++ mysql-test/t/key.test | 17 +++++++++++++++++ sql/sql_select.cc | 7 ------- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 6c115435fb6..3db5e926d30 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -545,3 +545,17 @@ c1 1 1 DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) +VALUES +(1,1), (1,2), (1,3), (1,4), (1,5), +(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +SELECT 1 as RES FROM t1 AS t1_outer WHERE +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +RES +DROP TABLE t1; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index cd6c480407d..31d5ac5201b 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -524,3 +524,20 @@ ORDER BY ( LIMIT 1); DROP TABLE t1; + + +# +# Bug #31974: Wrong EXPLAIN output +# + +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) + VALUES + (1,1), (1,2), (1,3), (1,4), (1,5), + (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +SELECT 1 as RES FROM t1 AS t1_outer WHERE + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 338b5f0cc3f..862948e48a4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6651,14 +6651,7 @@ void JOIN::cleanup(bool full) for (tab= join_tab, end= tab+tables; tab != end; tab++) { if (tab->table) - { - if (tab->table->key_read) - { - tab->table->key_read= 0; - tab->table->file->extra(HA_EXTRA_NO_KEYREAD); - } tab->table->file->ha_index_or_rnd_end(); - } } } } From 31787d3d56880b8df5a4e432ff08f5dcf41830c6 Mon Sep 17 00:00:00 2001 From: "mats@kindahl-laptop.dnsalias.net" <> Date: Mon, 5 Nov 2007 14:24:20 +0100 Subject: [PATCH 078/128] BUG#31611 (Security risk with BINLOG statement): Incremental patch to remove redundant, but benign, my_error() call. --- sql/sql_binlog.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 95eea9f20fa..ee78c244fe4 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -38,10 +38,7 @@ void mysql_client_binlog_statement(THD* thd) thd->lex->comment.str)); if (check_global_access(thd, SUPER_ACL)) - { - my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER"); DBUG_VOID_RETURN; - } /* Temporarily turn off send_ok, since different events handle this From aac68041eff685f94d8a88bfb86d2d45e6116504 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Mon, 5 Nov 2007 14:37:00 +0100 Subject: [PATCH 079/128] Bug#32107 - ctype_uca.test produces warnings files Comment sign of -- at line begin in test files lead to warnings from mysqltest. Changed -- to #. --- mysql-test/t/ctype_uca.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 17632e7c8fc..695a21adbf5 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -530,7 +530,7 @@ create table t1 ( a varchar(255), key a(a) ) character set utf8 collate utf8_czech_ci; --- In Czech 'ch' is a single letter between 'h' and 'i' +# In Czech 'ch' is a single letter between 'h' and 'i' insert into t1 values ('b'),('c'),('d'),('e'),('f'),('g'),('h'),('ch'),('i'),('j'); select * from t1 where a like 'c%'; From 2481d2c1e30b07640c2c45af56e08a89acd79b96 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Mon, 5 Nov 2007 14:44:38 +0100 Subject: [PATCH 080/128] Bug#32108 - subselect.test produces warnings files Comment sign of -- at line begin in test files lead to warnings from mysqltest. Changed -- to #. --- mysql-test/t/subselect.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index d076ca6bd33..86d2aec870c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2970,7 +2970,7 @@ DROP TABLE t1,t2; CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1, 2), (1,3), (1,4), (2,1), (2,2); --- returns no rows, when it should +# returns no rows, when it should SELECT a1.a, COUNT(*) FROM t1 a1 WHERE a1.a = 1 AND EXISTS( SELECT a2.a FROM t1 a2 WHERE a2.a = a1.a) GROUP BY a1.a; From 18ab121a3c695ed296e97da3fbe43ca4caa29be9 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 5 Nov 2007 18:23:55 +0400 Subject: [PATCH 081/128] merging --- mysql-test/r/func_str.result | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index d6879a8e756..d0809eca65b 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -722,9 +722,9 @@ Warning 1265 Data truncated for column 'format(130,10)' at row 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `bin(130)` varchar(64) NOT NULL default '', - `oct(130)` varchar(64) NOT NULL default '', - `conv(130,16,10)` varchar(64) NOT NULL default '', + `bin(130)` varchar(64) default NULL, + `oct(130)` varchar(64) default NULL, + `conv(130,16,10)` varchar(64) default NULL, `hex(130)` varchar(6) NOT NULL default '', `char(130)` varbinary(4) NOT NULL default '', `format(130,10)` varchar(4) NOT NULL default '', From 0cccdaba06251a70be3280e5cb777ab823a8260c Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 5 Nov 2007 18:43:13 +0400 Subject: [PATCH 082/128] merging --- mysql-test/r/func_str.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 237c5eced39..6f6edd5112b 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -723,7 +723,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `bin(130)` varchar(64) DEFAULT NULL, - `oct(130)` varchar(64) EFAULT NULL, + `oct(130)` varchar(64) DEFAULT NULL, `conv(130,16,10)` varchar(64) DEFAULT NULL, `hex(130)` varchar(6) NOT NULL DEFAULT '', `char(130)` varbinary(4) NOT NULL DEFAULT '', From 3eaf82a17504158aa29b1f39360f365428943de4 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Mon, 5 Nov 2007 16:25:40 +0100 Subject: [PATCH 083/128] Bug#31210 - INSERT DELAYED crashes server when used on partitioned table Trying INSERT DELAYED on a partitioned table, that has not been used right before, crashes the server. When a table is used for select or update, it is kept open for some time. This period I mean with "right before". Information about partitioning of a table is stored in form of a string in the .frm file. Parsing of this string requires a correctly set up lexical analyzer (lex). The partitioning code uses a new temporary instance of a lex. But it does still refer to the previously active lex. The delayd insert thread does not initialize its lex though... Added initialization for thd->lex before open table in the delayed thread and at all other places where it is necessary to call lex_start() if all tables would be partitioned and need to parse the .frm file. --- mysql-test/r/partition_hash.result | 4 ++++ mysql-test/t/partition_hash.test | 8 ++++++++ sql/event_scheduler.cc | 1 + sql/events.cc | 1 + sql/ha_ndbcluster_binlog.cc | 1 + sql/slave.cc | 1 + sql/sql_acl.cc | 2 ++ sql/sql_base.cc | 3 +++ sql/sql_connect.cc | 1 + sql/sql_insert.cc | 7 ++++++- sql/sql_lex.cc | 3 ++- sql/sql_lex.h | 1 + sql/sql_plugin.cc | 1 + sql/sql_servers.cc | 1 + sql/sql_udf.cc | 1 + sql/table.cc | 3 +++ sql/tztime.cc | 1 + 17 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result index 9a82a36d902..3ebbd020db4 100644 --- a/mysql-test/r/partition_hash.result +++ b/mysql-test/r/partition_hash.result @@ -183,3 +183,7 @@ c1 c2 c3 182 abc 2002-11-09 184 abc 2002-11-22 drop table t1; +CREATE TABLE t1 (c1 INT) ENGINE=MyISAM PARTITION BY HASH(c1) PARTITIONS 1; +INSERT DELAYED INTO t1 VALUES (1); +ERROR HY000: Table storage engine for 't1' doesn't have this option +DROP TABLE t1; diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test index 98add060a76..16c3e2b3b9b 100644 --- a/mysql-test/t/partition_hash.test +++ b/mysql-test/t/partition_hash.test @@ -144,3 +144,11 @@ select * from t1 where c3 between '2002-01-01' and '2002-12-31'; drop table t1; +# +# Bug#31210 - INSERT DELAYED crashes server when used on partitioned table +# +CREATE TABLE t1 (c1 INT) ENGINE=MyISAM PARTITION BY HASH(c1) PARTITIONS 1; +--error ER_ILLEGAL_HA +INSERT DELAYED INTO t1 VALUES (1); +DROP TABLE t1; + diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index b03b51f1134..52c7d291da7 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -127,6 +127,7 @@ post_init_event_thread(THD *thd) thd->cleanup(); return TRUE; } + lex_start(thd); pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); diff --git a/sql/events.cc b/sql/events.cc index 5246bccc388..84301d811f0 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -884,6 +884,7 @@ Events::init(my_bool opt_noacl) */ thd->thread_stack= (char*) &thd; thd->store_globals(); + lex_start(thd); /* We will need Event_db_repository anyway, even if the scheduler is diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 5d5c8a26447..5f67c6f73ea 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -3621,6 +3621,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) pthread_exit(0); DBUG_RETURN(NULL); } + lex_start(thd); thd->init_for_queries(); thd->command= COM_DAEMON; diff --git a/sql/slave.cc b/sql/slave.cc index fcbd4eb841b..a89d5262cbf 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1510,6 +1510,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) delete thd; DBUG_RETURN(-1); } + lex_start(thd); if (thd_type == SLAVE_THD_SQL) thd->proc_info= "Waiting for the next event in relay log"; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7e017d7d028..495b7e06c8a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -277,6 +277,7 @@ my_bool acl_init(bool dont_read_acl_tables) DBUG_RETURN(1); /* purecov: inspected */ thd->thread_stack= (char*) &thd; thd->store_globals(); + lex_start(thd); /* It is safe to call acl_reload() since acl_* arrays and hashes which will be freed there are global static objects and thus are initialized @@ -3493,6 +3494,7 @@ my_bool grant_init() DBUG_RETURN(1); /* purecov: deadcode */ thd->thread_stack= (char*) &thd; thd->store_globals(); + lex_start(thd); return_val= grant_reload(thd); delete thd; /* Remember that we don't have a THD */ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 337fde53dac..119da29c316 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2248,6 +2248,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, HASH_SEARCH_STATE state; DBUG_ENTER("open_table"); + /* Parsing of partitioning information from .frm needs thd->lex set up. */ + DBUG_ASSERT(thd->lex->is_lex_started); + /* find a unused table in the open table cache */ if (refresh) *refresh=0; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6bb0f62d843..225a54448ac 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1087,6 +1087,7 @@ pthread_handler_t handle_one_connection(void *arg) { NET *net= &thd->net; + lex_start(thd); if (login_connection(thd)) goto end_thread; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ebbf4cafb19..fb4a563c4d6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2264,7 +2264,12 @@ pthread_handler_t handle_delayed_insert(void *arg) goto err; } - /* open table */ + /* + Open table requires an initialized lex in case the table is + partitioned. The .frm file contains a partial SQL string which is + parsed using a lex, that depends on initialized thd->lex. + */ + lex_start(thd); if (!(di->table=open_ltable(thd, &di->table_list, TL_WRITE_DELAYED, 0))) { thd->fatal_error(); // Abort waiting inserts diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0a5f83af400..26c9790923a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -362,6 +362,7 @@ void lex_start(THD *thd) lex->server_options.owner= 0; lex->server_options.port= -1; + lex->is_lex_started= TRUE; DBUG_VOID_RETURN; } @@ -2138,7 +2139,7 @@ void Query_tables_list::destroy_query_tables_list() st_lex::st_lex() :result(0), yacc_yyss(0), yacc_yyvs(0), - sql_command(SQLCOM_END), option_type(OPT_DEFAULT) + sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0) { my_init_dynamic_array2(&plugins, sizeof(plugin_ref), diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 08104769704..d0822fed3c2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1703,6 +1703,7 @@ typedef struct st_lex : public Query_tables_list st_alter_tablespace *alter_tablespace_info; bool escape_used; + bool is_lex_started; /* If lex_start() did run. For debugging. */ st_lex(); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2af528f6699..c8d9116f196 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1329,6 +1329,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) } new_thd->thread_stack= (char*) &tables; new_thd->store_globals(); + lex_start(new_thd); new_thd->db= my_strdup("mysql", MYF(0)); new_thd->db_length= 5; bzero((uchar*)&tables, sizeof(tables)); diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index a780c561ffe..d1d7801538c 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -140,6 +140,7 @@ bool servers_init(bool dont_read_servers_table) DBUG_RETURN(TRUE); thd->thread_stack= (char*) &thd; thd->store_globals(); + lex_start(thd); /* It is safe to call servers_reload() since servers_* arrays and hashes which will be freed there are global static objects and thus are initialized diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 19582af38f4..112280a10b2 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -135,6 +135,7 @@ void udf_init() initialized = 1; new_thd->thread_stack= (char*) &new_thd; new_thd->store_globals(); + lex_start(new_thd); new_thd->set_db(db, sizeof(db)-1); bzero((uchar*) &tables,sizeof(tables)); diff --git a/sql/table.cc b/sql/table.cc index ccddbf8134b..26008f0aa19 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1608,6 +1608,9 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str, share->table_name.str, (long) outparam)); + /* Parsing of partitioning information from .frm needs thd->lex set up. */ + DBUG_ASSERT(thd->lex->is_lex_started); + error= 1; bzero((char*) outparam, sizeof(*outparam)); outparam->in_use= thd; diff --git a/sql/tztime.cc b/sql/tztime.cc index 9eb38e97827..920f8e87d13 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1575,6 +1575,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) DBUG_RETURN(1); thd->thread_stack= (char*) &thd; thd->store_globals(); + lex_start(thd); /* Init all memory structures that require explicit destruction */ if (hash_init(&tz_names, &my_charset_latin1, 20, From 36e0b66638127a95545945fa612d83d844e9d9e5 Mon Sep 17 00:00:00 2001 From: "malff@lambda.hsd1.co.comcast.net." <> Date: Mon, 5 Nov 2007 16:52:04 -0700 Subject: [PATCH 084/128] fixed coding style --- sql/sql_yacc.yy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 69cd7060778..b337f82dec3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9784,9 +9784,10 @@ literal: MYSQL_YYABORT; } } - | DATE_SYM text_literal { $$ = $2; } - | TIME_SYM text_literal { $$ = $2; } - | TIMESTAMP text_literal { $$ = $2; }; + | DATE_SYM text_literal { $$ = $2; } + | TIME_SYM text_literal { $$ = $2; } + | TIMESTAMP text_literal { $$ = $2; } + ; NUM_literal: NUM From 30b409bd6fc66c5c2cfde023810c837a72fb2b50 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 6 Nov 2007 13:41:32 +0100 Subject: [PATCH 085/128] Bug#4692 - DISABLE/ENABLE KEYS waste a space Disabling and enabling indexes on a non-empty table grows the index file. Disabling indexes just sets a flag per non-unique index and does not free the index blocks of the affected indexes. Re-enabling indexes creates new indexes with new blocks. The old blocks remain unused in the index file. Fixed by dropping and re-creating all indexes if non-empty disabled indexes exist when enabling indexes. Dropping all indexes resets the internal end-of-file marker to the end of the index file header. It also clears the root block pointers of every index and clears the deleted blocks chains. This way all blocks are declared as free. --- myisam/mi_check.c | 224 +++++++++++++++++++++++++++---------- mysql-test/r/myisam.result | 25 +++++ mysql-test/t/myisam.test | 26 +++++ 3 files changed, 218 insertions(+), 57 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index ed0a84e737d..ba308f75d24 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1375,6 +1375,139 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } /* chk_data_link */ +/** + @brief Drop all indexes + + @param[in] param check parameters + @param[in] info MI_INFO handle + @param[in] force if to force drop all indexes + + @return status + @retval 0 OK + @retval != 0 Error + + @note + Once allocated, index blocks remain part of the key file forever. + When indexes are disabled, no block is freed. When enabling indexes, + no block is freed either. The new indexes are create from new + blocks. (Bug #4692) + + Before recreating formerly disabled indexes, the unused blocks + must be freed. There are two options to do this: + - Follow the tree of disabled indexes, add all blocks to the + deleted blocks chain. Would require a lot of random I/O. + - Drop all blocks by clearing all index root pointers and all + delete chain pointers and resetting key_file_length to the end + of the index file header. This requires to recreate all indexes, + even those that may still be intact. + The second method is probably faster in most cases. + + When disabling indexes, MySQL disables either all indexes or all + non-unique indexes. When MySQL [re-]enables disabled indexes + (T_CREATE_MISSING_KEYS), then we either have "lost" blocks in the + index file, or there are no non-unique indexes. In the latter case, + mi_repair*() would not be called as there would be no disabled + indexes. + + If there would be more unique indexes than disabled (non-unique) + indexes, we could do the first method. But this is not implemented + yet. By now we drop and recreate all indexes when repair is called. + + However, there is an exception. Sometimes MySQL disables non-unique + indexes when the table is empty (e.g. when copying a table in + mysql_alter_table()). When enabling the non-unique indexes, they + are still empty. So there is no index block that can be lost. This + optimization is implemented in this function. + + Note that in normal repair (T_CREATE_MISSING_KEYS not set) we + recreate all enabled indexes unconditonally. We do not change the + key_map. Otherwise we invert the key map temporarily (outside of + this function) and recreate the then "seemingly" enabled indexes. + When we cannot use the optimization, and drop all indexes, we + pretend that all indexes were disabled. By the inversion, we will + then recrate all indexes. +*/ + +static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force) +{ + MYISAM_SHARE *share= info->s; + MI_STATE_INFO *state= &share->state; + uint i; + int error; + DBUG_ENTER("mi_drop_all_indexes"); + + /* + If any of the disabled indexes has a key block assigned, we must + drop and recreate all indexes to avoid losing index blocks. + + If we want to recreate disabled indexes only _and_ all of these + indexes are empty, we don't need to recreate the existing indexes. + */ + if (!force && (param->testflag & T_CREATE_MISSING_KEYS)) + { + DBUG_PRINT("repair", ("creating missing indexes")); + for (i= 0; i < share->base.keys; i++) + { + DBUG_PRINT("repair", ("index #: %u key_root: 0x%lx active: %d", + i, (long) state->key_root[i], + mi_is_key_active(state->key_map, i))); + if ((state->key_root[i] != HA_OFFSET_ERROR) && + !mi_is_key_active(state->key_map, i)) + { + /* + This index has at least one key block and it is disabled. + We would lose its block(s) if would just recreate it. + So we need to drop and recreate all indexes. + */ + DBUG_PRINT("repair", ("nonempty and disabled: recreate all")); + break; + } + } + if (i >= share->base.keys) + { + /* + All of the disabled indexes are empty. We can just recreate them. + Flush dirty blocks of this index file from key cache and remove + all blocks of this index file from key cache. + */ + DBUG_PRINT("repair", ("all disabled are empty: create missing")); + error= flush_key_blocks(share->key_cache, share->kfile, + FLUSH_FORCE_WRITE); + goto end; + } + /* + We do now drop all indexes and declare them disabled. With the + T_CREATE_MISSING_KEYS flag, mi_repair*() will recreate all + disabled indexes and enable them. + */ + mi_clear_all_keys_active(state->key_map); + DBUG_PRINT("repair", ("declared all indexes disabled")); + } + + /* Remove all key blocks of this index file from key cache. */ + if ((error= flush_key_blocks(share->key_cache, share->kfile, + FLUSH_IGNORE_CHANGED))) + goto end; + + /* Clear index root block pointers. */ + for (i= 0; i < share->base.keys; i++) + state->key_root[i]= HA_OFFSET_ERROR; + + /* Clear the delete chains. */ + for (i= 0; i < state->header.max_block_size; i++) + state->key_del[i]= HA_OFFSET_ERROR; + + /* Reset index file length to end of index file header. */ + info->state->key_file_length= share->base.keystart; + + DBUG_PRINT("repair", ("dropped all indexes")); + /* error= 0; set by last (error= flush_key_bocks()). */ + + end: + DBUG_RETURN(error); +} + + /* Recover old table by reading each record and writing all keys */ /* Save new datafile-name in temp_filename */ @@ -1382,7 +1515,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, my_string name, int rep_quick) { int error,got_error; - uint i; ha_rows start_records,new_header_length; my_off_t del; File new_file; @@ -1486,25 +1618,10 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - /* - Clear all keys. Note that all key blocks allocated until now remain - "dead" parts of the key file. (Bug #4692) - */ - for (i=0 ; i < info->s->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - - /* Drop the delete chain. */ - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - - /* - If requested, activate (enable) all keys in key_map. In this case, - all indexes will be (re-)built. - */ + /* This function always recreates all enabled indexes. */ if (param->testflag & T_CREATE_MISSING_KEYS) mi_set_all_keys_active(share->state.key_map, share->base.keys); - - info->state->key_file_length=share->base.keystart; + mi_drop_all_indexes(param, info, TRUE); lock_memory(param); /* Everything is alloced */ @@ -2105,8 +2222,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ulong *rec_per_key_part; char llbuff[22]; SORT_INFO sort_info; - ulonglong key_map=share->state.key_map; + ulonglong key_map; DBUG_ENTER("mi_repair_by_sort"); + LINT_INIT(key_map); start_records=info->state->records; got_error=1; @@ -2179,25 +2297,14 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - if (!(param->testflag & T_CREATE_MISSING_KEYS)) + + /* Optionally drop indexes and optionally modify the key_map. */ + mi_drop_all_indexes(param, info, FALSE); + key_map= share->state.key_map; + if (param->testflag & T_CREATE_MISSING_KEYS) { - /* - Flush key cache for this file if we are calling this outside - myisamchk - */ - flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); - /* Clear the pointers to the given rows */ - for (i=0 ; i < share->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - info->state->key_file_length=share->base.keystart; - } - else - { - if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) - goto err; - key_map= ~key_map; /* Create the missing keys */ + /* Invert the copied key_map to recreate all disabled indexes. */ + key_map= ~key_map; } sort_info.info=info; @@ -2240,6 +2347,10 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, sort_param.read_cache=param->read_cache; sort_param.keyinfo=share->keyinfo+sort_param.key; sort_param.seg=sort_param.keyinfo->seg; + /* + Skip this index if it is marked disabled in the copied + (and possibly inverted) key_map. + */ if (! mi_is_key_active(key_map, sort_param.key)) { /* Remember old statistics for key */ @@ -2247,6 +2358,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, (char*) (share->state.rec_per_key_part + (uint) (rec_per_key_part - param->rec_per_key_part)), sort_param.keyinfo->keysegs*sizeof(*rec_per_key_part)); + DBUG_PRINT("repair", ("skipping seemingly disabled index #: %u", + sort_param.key)); continue; } @@ -2302,8 +2415,11 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, if (param->testflag & T_STATISTICS) update_key_parts(sort_param.keyinfo, rec_per_key_part, sort_param.unique, param->stats_method == MI_STATS_METHOD_IGNORE_NULLS? - sort_param.notnull: NULL,(ulonglong) info->state->records); + sort_param.notnull: NULL, + (ulonglong) info->state->records); + /* Enable this index in the permanent (not the copied) key_map. */ mi_set_key_active(share->state.key_map, sort_param.key); + DBUG_PRINT("repair", ("set enabled index #: %u", sort_param.key)); if (sort_param.fix_datafile) { @@ -2504,9 +2620,10 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, IO_CACHE new_data_cache; /* For non-quick repair. */ IO_CACHE_SHARE io_share; SORT_INFO sort_info; - ulonglong key_map=share->state.key_map; + ulonglong key_map; pthread_attr_t thr_attr; DBUG_ENTER("mi_repair_parallel"); + LINT_INIT(key_map); start_records=info->state->records; got_error=1; @@ -2608,25 +2725,14 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - if (!(param->testflag & T_CREATE_MISSING_KEYS)) + + /* Optionally drop indexes and optionally modify the key_map. */ + mi_drop_all_indexes(param, info, FALSE); + key_map= share->state.key_map; + if (param->testflag & T_CREATE_MISSING_KEYS) { - /* - Flush key cache for this file if we are calling this outside - myisamchk - */ - flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); - /* Clear the pointers to the given rows */ - for (i=0 ; i < share->base.keys ; i++) - share->state.key_root[i]= HA_OFFSET_ERROR; - for (i=0 ; i < share->state.header.max_block_size ; i++) - share->state.key_del[i]= HA_OFFSET_ERROR; - info->state->key_file_length=share->base.keystart; - } - else - { - if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) - goto err; - key_map= ~key_map; /* Create the missing keys */ + /* Invert the copied key_map to recreate all disabled indexes. */ + key_map= ~key_map; } sort_info.info=info; @@ -2682,6 +2788,10 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, sort_param[i].key=key; sort_param[i].keyinfo=share->keyinfo+key; sort_param[i].seg=sort_param[i].keyinfo->seg; + /* + Skip this index if it is marked disabled in the copied + (and possibly inverted) key_map. + */ if (! mi_is_key_active(key_map, key)) { /* Remember old statistics for key */ diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 7fc29cd13ca..176d0e97012 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1806,4 +1806,29 @@ SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; a 1 DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 0 # # # 1024 # # # # # # # +INSERT INTO t1 VALUES (1,1); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index d5f403616c8..ad223dc2664 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1161,4 +1161,30 @@ ALTER TABLE t1 ENABLE KEYS; SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; DROP TABLE t1; +# +# Bug#4692 - DISABLE/ENABLE KEYS waste a space +# +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +INSERT INTO t1 VALUES (1,1); +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +#--exec ls -log var/master-data/test/t1.MYI +#--exec myisamchk -dvv var/master-data/test/t1.MYI +#--exec myisamchk -iev var/master-data/test/t1.MYI +DROP TABLE t1; + --echo End of 5.0 tests From a34c1d5a36da650ec5e7c2a674c5c1d82b750673 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Tue, 6 Nov 2007 16:53:02 +0400 Subject: [PATCH 086/128] fix for pushbuild 'powermacg5' failure --- mysql-test/r/information_schema.result | 6 +++--- mysql-test/t/information_schema.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 18ffb4a37ea..007bd112ccc 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1604,9 +1604,9 @@ select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -explain extended select 1 from information_schema.TABLES; +explain extended select 1 from information_schema.tables; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE TABLES ALL NULL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases +1 SIMPLE tables ALL NULL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases Warnings: -Note 1003 select 1 AS `1` from `information_schema`.`TABLES` +Note 1003 select 1 AS `1` from `information_schema`.`tables` End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 5ac7ffa42ad..e9b025692e2 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1235,6 +1235,6 @@ select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; # # Bug#31630 debug assert with explain extended select ... from i_s # -explain extended select 1 from information_schema.TABLES; +explain extended select 1 from information_schema.tables; --echo End of 5.1 tests. From b028dad9ce805042401c484c24c65516c0972588 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 6 Nov 2007 15:29:55 +0200 Subject: [PATCH 087/128] Bug #31974: additional commit (test case updates) loose index scan enabled for subqueries --- mysql-test/r/group_min_max.result | 4 ++-- mysql-test/r/index_merge_myisam.result | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 270f248ea9c..a3744b36e87 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2251,7 +2251,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -2 SUBQUERY t1 range NULL a 5 NULL 8 +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra @@ -2268,7 +2268,7 @@ AND t1_outer1.b = t1_outer2.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer -2 SUBQUERY t1 range NULL a 5 NULL 8 +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index ebeba53fdfa..9d7d06f7f1b 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -286,7 +286,7 @@ NULL UNION RESULT ALL NULL NULL NULL NULL NULL explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 -2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where +2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where; Using index create table t3 like t0; insert into t3 select * from t0; alter table t3 add key9 int not null, add index i9(key9); From e85cc0000aa47896780854a584f979f4bc2389df Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 6 Nov 2007 14:47:15 +0100 Subject: [PATCH 088/128] Bug#4692 - DISABLE/ENABLE KEYS waste a space Post-merge fix. Moved test into 5.0 section. --- mysql-test/r/myisam.result | 50 ++++++++++++++++++------------------- mysql-test/t/myisam.test | 51 +++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e3ff66afeab..3125660643c 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1794,6 +1794,31 @@ SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; a 1 DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 0 # # # 1024 # # # # # # # +INSERT INTO t1 VALUES (1,1); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 DISABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +ALTER TABLE t1 ENABLE KEYS; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # +DROP TABLE t1; End of 5.0 tests create table t1 (a int not null, key `a` (a) key_block_size=1024); show create table t1; @@ -1987,28 +2012,3 @@ Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; End of 5.1 tests -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 0 # # # 1024 # # # # # # # -INSERT INTO t1 VALUES (1,1); -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # -ALTER TABLE t1 DISABLE KEYS; -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # -ALTER TABLE t1 ENABLE KEYS; -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # -ALTER TABLE t1 DISABLE KEYS; -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # -ALTER TABLE t1 ENABLE KEYS; -SHOW TABLE STATUS LIKE 't1'; -Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # # -DROP TABLE t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 0c5a2e621d1..6f24d84f4c0 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1146,6 +1146,32 @@ ALTER TABLE t1 ENABLE KEYS; SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1; DROP TABLE t1; +# +# Bug#4692 - DISABLE/ENABLE KEYS waste a space +# +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +INSERT INTO t1 VALUES (1,1); +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 DISABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +ALTER TABLE t1 ENABLE KEYS; +--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # +SHOW TABLE STATUS LIKE 't1'; +#--exec ls -log var/master-data/test/t1.MYI +#--exec myisamchk -dvv var/master-data/test/t1.MYI +#--exec myisamchk -iev var/master-data/test/t1.MYI +DROP TABLE t1; + --echo End of 5.0 tests @@ -1256,29 +1282,4 @@ CHECK TABLE t1; DROP TABLE t1; --echo End of 5.1 tests -# -# Bug#4692 - DISABLE/ENABLE KEYS waste a space -# -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM; ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -INSERT INTO t1 VALUES (1,1); ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -ALTER TABLE t1 DISABLE KEYS; ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -ALTER TABLE t1 ENABLE KEYS; ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -ALTER TABLE t1 DISABLE KEYS; ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -ALTER TABLE t1 ENABLE KEYS; ---replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # -SHOW TABLE STATUS LIKE 't1'; -#--exec ls -log var/master-data/test/t1.MYI -#--exec myisamchk -dvv var/master-data/test/t1.MYI -#--exec myisamchk -iev var/master-data/test/t1.MYI -DROP TABLE t1; From d06e2f922354bb1f98f5fe434ea5445c99af215d Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Tue, 6 Nov 2007 18:09:33 +0400 Subject: [PATCH 089/128] BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE RENAME TABLE against a table with DATA/INDEX DIRECTORY overwrites the file to which the symlink points. This is security issue, because it is possible to create a table with some name in some non-system database and set DATA/INDEX DIRECTORY to mysql system database. Renaming this table to one of mysql system tables (e.g. user, host) would overwrite the system table. Return an error when the file to which the symlink points exist. --- mysql-test/r/symlink.result | 6 ++++++ mysql-test/t/symlink.test | 12 ++++++++++++ mysys/my_symlink2.c | 11 ++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index d07a8613883..e2b26cb508c 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -84,3 +84,9 @@ t1 CREATE TABLE `t1` ( `b` int(11) default NULL ) TYPE=MyISAM drop table t1; +CREATE TABLE t1(a INT) +DATA DIRECTORY='TEST_DIR/var/master-data/mysql' +INDEX DIRECTORY='TEST_DIR/var/master-data/mysql'; +RENAME TABLE t1 TO user; +Can't create/write to file 'TEST_DIR/var/master-data/mysql/user.MYI' (Errcode: 17) +DROP TABLE t1; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 7a42a60054e..9750e6fdfdd 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -112,3 +112,15 @@ eval alter table t1 index directory="$MYSQL_TEST_DIR/var/log"; enable_query_log; show create table t1; drop table t1; + +# +# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE +# +--replace_result $MYSQL_TEST_DIR TEST_DIR +eval CREATE TABLE t1(a INT) +DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/mysql' +INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data/mysql'; +--replace_result $MYSQL_TEST_DIR TEST_DIR +--error 1 +RENAME TABLE t1 TO user; +DROP TABLE t1; diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c index 913f632fbb4..4d58699412a 100644 --- a/mysys/my_symlink2.c +++ b/mysys/my_symlink2.c @@ -120,6 +120,7 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) int was_symlink= (!my_disable_symlinks && !my_readlink(link_name, from, MYF(0))); int result=0; + int name_is_different; DBUG_ENTER("my_rename_with_symlink"); if (!was_symlink) @@ -128,6 +129,14 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) /* Change filename that symlink pointed to */ strmov(tmp_name, to); fn_same(tmp_name,link_name,1); /* Copy dir */ + name_is_different= strcmp(link_name, tmp_name); + if (name_is_different && !access(tmp_name, F_OK)) + { + my_errno= EEXIST; + if (MyFlags & MY_WME) + my_error(EE_CANTCREATEFILE, MYF(0), tmp_name, EEXIST); + DBUG_RETURN(1); + } /* Create new symlink */ if (my_symlink(tmp_name, to, MyFlags)) @@ -139,7 +148,7 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) the same basename and different directories. */ - if (strcmp(link_name, tmp_name) && my_rename(link_name, tmp_name, MyFlags)) + if (name_is_different && my_rename(link_name, tmp_name, MyFlags)) { int save_errno=my_errno; my_delete(to, MyFlags); /* Remove created symlink */ From 9f6febf93367b419a6e5de861574ea8ef6a8472e Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Tue, 6 Nov 2007 21:57:51 +0300 Subject: [PATCH 090/128] Better comments --- sql/opt_range.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/opt_range.h b/sql/opt_range.h index dd219129167..4f5cce28bf2 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -24,9 +24,14 @@ #endif typedef struct st_key_part { - uint16 key,part, store_length, length; + uint16 key,part; + /* See KEY_PART_INFO for meaning of the next two: */ + uint16 store_length, length; uint8 null_bit; - /* Keypart flags (0 if partition pruning is used) */ + /* + Keypart flags (0 when this structure is used by partition pruning code + for fake partitioning index description) + */ uint8 flag; Field *field; Field::imagetype image_type; From 9de5a2424fff878e6f0074bc6b214f065b4c494e Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Wed, 7 Nov 2007 09:30:41 +0100 Subject: [PATCH 091/128] Bug#22351 - handler::index_next_same() call to key_cmp_if_same() uses the wrong buffer handler::index_next_same() did not take into account that the internally called function key_cmp_if_same() uses the fixed buffer table->record[0] for key comparison instead of the buffer provided by the caller of handler::index_next_same(). Added code to temporarily redirect table->record[0] and the fields used for the key to the record buffer provided by the caller of handler::index_next_same(). The test case is in partition.test already. --- sql/handler.cc | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/sql/handler.cc b/sql/handler.cc index 75c3a64bc27..7891661cefc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2522,15 +2522,56 @@ int ha_enable_transaction(THD *thd, bool on) int handler::index_next_same(uchar *buf, const uchar *key, uint keylen) { int error; + DBUG_ENTER("index_next_same"); if (!(error=index_next(buf))) { + my_ptrdiff_t ptrdiff= buf - table->record[0]; + uchar *save_record_0; + KEY *key_info; + KEY_PART_INFO *key_part; + KEY_PART_INFO *key_part_end; + LINT_INIT(save_record_0); + LINT_INIT(key_info); + LINT_INIT(key_part); + LINT_INIT(key_part_end); + + /* + key_cmp_if_same() compares table->record[0] against 'key'. + In parts it uses table->record[0] directly, in parts it uses + field objects with their local pointers into table->record[0]. + If 'buf' is distinct from table->record[0], we need to move + all record references. This is table->record[0] itself and + the field pointers of the fields used in this key. + */ + if (ptrdiff) + { + save_record_0= table->record[0]; + table->record[0]= buf; + key_info= table->key_info + active_index; + key_part= key_info->key_part; + key_part_end= key_part + key_info->key_parts; + for (; key_part < key_part_end; key_part++) + { + DBUG_ASSERT(key_part->field); + key_part->field->move_field_offset(ptrdiff); + } + } + if (key_cmp_if_same(table, key, active_index, keylen)) { table->status=STATUS_NOT_FOUND; error=HA_ERR_END_OF_FILE; } + + /* Move back if necessary. */ + if (ptrdiff) + { + table->record[0]= save_record_0; + for (key_part= key_info->key_part; key_part < key_part_end; key_part++) + key_part->field->move_field_offset(-ptrdiff); + } } - return error; + DBUG_RETURN(error); } From 4aa04022245ca0ec4186683ea2c8ef7399db7055 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Wed, 7 Nov 2007 14:00:45 +0300 Subject: [PATCH 092/128] Fix for bug #30666: Incorrect order when using range conditions on 2 tables or more The problem was that the optimizer used the join buffer in cases when the result set is ordered by filesort. This resulted in the ORDER BY clause being ignored, and the records being returned in the order determined by the order of matching records in the last table in join. Fixed by relaxing the condition in make_join_readinfo() to take filesort-ordered result sets into account, not only index-ordered ones. --- mysql-test/r/select.result | 39 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/select.test | 36 +++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 7 +++---- 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index ed120a1bbb8..649fe262679 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4096,4 +4096,43 @@ SELECT `x` FROM v3; x 1 DROP VIEW v1, v2, v3; +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 5c30a17e08e..7fe866e6495 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3484,4 +3484,40 @@ DROP VIEW v1, v2, v3; --enable_ps_protocol +# +# Bug #30666: Incorrect order when using range conditions on 2 tables or more +# + +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, + c22 INT DEFAULT NULL, + KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, + c32 INT DEFAULT NULL, + c33 INT NOT NULL, + c34 INT UNSIGNED DEFAULT 0, + KEY (c33, c34, c32)); + +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), + (2, 2, 0, 0), + (3, 3, 1, 0), + (4, 4, 0, 0), + (5, 5, 1, 0); + +# Show that ORDER BY produces the correct results order +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND + t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND + t3.c33 = 1 AND t2.c22 in (1, 3) + ORDER BY c32; + +# Show that ORDER BY DESC produces the correct results order +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND + t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND + t3.c33 = 1 AND t2.c22 in (1, 3) + ORDER BY c32 DESC; + +DROP TABLE t1, t2, t3; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3529de1c28a..24d1639edf1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6071,10 +6071,9 @@ make_join_readinfo(JOIN *join, ulonglong options) ordered. If there is a temp table the ordering is done as a last operation and doesn't prevent join cache usage. */ - if (!ordered_set && !join->need_tmp && - ((table == join->sort_by_table && - (!join->order || join->skip_sort_order)) || - (join->sort_by_table == (TABLE *) 1 && i != join->const_tables))) + if (!ordered_set && !join->need_tmp && + (table == join->sort_by_table || + (join->sort_by_table == (TABLE *) 1 && i != join->const_tables))) ordered_set= 1; switch (tab->type) { From 3ebb915d718c0e8432aea529578e846bf2dd9ceb Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Wed, 7 Nov 2007 15:08:50 +0300 Subject: [PATCH 093/128] Fix for bug #25421: MySQL threads don't respond to the kill command Calculating the estimated number of records for a range scan may take a significant time, and it was impossible for a user to interrupt that process by killing the connection or the query. Fixed by checking the thread's 'killed' status in check_quick_keys() and interrupting the calculation process if it is set to a non-zero value. --- sql/opt_range.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 99c28be36b0..c1c2ea17715 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7352,6 +7352,9 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree, tmp_max_flag= max_key_flag | key_tree->max_flag; } + if (unlikely(param->thd->killed != 0)) + return HA_POS_ERROR; + keynr=param->real_keynr[idx]; param->range_count++; if (!tmp_min_flag && ! tmp_max_flag && From f1a3c36403fb0a566a6d9da1c6b9fb74e4c8681a Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Wed, 7 Nov 2007 18:45:04 +0300 Subject: [PATCH 094/128] Fix for bug #32103: optimizer crash when join on int and mediumint with variable in where clause. Problem: the new_item() method of Item_uint used an incorrect constructor. "new Item_uint(name, max_length)" calls Item_uint::Item_uint(const char *str_arg, uint length) which assumes the first argument to be the string representation of the value, not the item's name. This could result in either a server crash or incorrect results depending on usage scenarios. Fixed by using the correct constructor in new_item(): Item_uint::Item_uint(const char *str_arg, longlong i, uint length). --- mysql-test/r/select.result | 8 ++++++++ mysql-test/t/select.test | 21 +++++++++++++++++++++ sql/item.h | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 6dc971a953c..53ab13fe084 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2835,4 +2835,12 @@ FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF 8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; End of 4.1 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 0dc179e9b4b..b41deed65d2 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2353,4 +2353,25 @@ insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), select hex(a), hex(b) from t1; drop table t1; +# +# Bug #32103: optimizer crash when join on int and mediumint with variable in +# where clause +# + +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); + +# We need any variable that: +# 1. has integer type, +# 2. can be used with the "@@name" syntax +# 3. available in every server build +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); + +# We only need to ensure 1 row is returned to validate the results +--replace_column 1 X 2 X +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); + +DROP TABLE t1, t2; + --echo End of 4.1 tests diff --git a/sql/item.h b/sql/item.h index f2136c4997a..7a073b7165c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -690,7 +690,7 @@ public: double val() { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); } String *val_str(String*); - Item *new_item() { return new Item_uint(name,max_length); } + Item *new_item() { return new Item_uint(name, value, max_length); } int save_in_field(Field *field, bool no_conversions); void print(String *str); Item_num *neg (); From 5a5ed2a5095c98ae56c766b5a8fbc7ca2fe28e7c Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Thu, 8 Nov 2007 06:08:44 +0100 Subject: [PATCH 095/128] Bug#31990: MINUTE() and SECOND() return bogus results when used on a DATE HOUR(), MINUTE(), ... returned spurious results when used on a DATE-cast. This happened because DATE-cast object did not overload get_time() method in superclass Item. The default method was inappropriate here and misinterpreted the data. Patch adds missing method; get_time() on DATE-casts now returns SQL-NULL on NULL input, 0 otherwise. This coincides with the way DATE-columns behave. --- mysql-test/r/cast.result | 24 ++++++++++++++++++++++++ mysql-test/t/cast.test | 22 ++++++++++++++++++++++ sql/item_timefunc.cc | 7 +++++++ sql/item_timefunc.h | 1 + 4 files changed, 54 insertions(+) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 524ff48d69e..88601eceb0a 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -414,4 +414,28 @@ NULL NULL 20070719 drop table t1; +CREATE TABLE t1 (f1 DATE); +INSERT INTO t1 VALUES ('2007-07-19'), (NULL); +SELECT HOUR(f1), +MINUTE(f1), +SECOND(f1) FROM t1; +HOUR(f1) MINUTE(f1) SECOND(f1) +0 0 0 +NULL NULL NULL +SELECT HOUR(CAST('2007-07-19' AS DATE)), +MINUTE(CAST('2007-07-19' AS DATE)), +SECOND(CAST('2007-07-19' AS DATE)); +HOUR(CAST('2007-07-19' AS DATE)) MINUTE(CAST('2007-07-19' AS DATE)) SECOND(CAST('2007-07-19' AS DATE)) +0 0 0 +SELECT HOUR(CAST(NULL AS DATE)), +MINUTE(CAST(NULL AS DATE)), +SECOND(CAST(NULL AS DATE)); +HOUR(CAST(NULL AS DATE)) MINUTE(CAST(NULL AS DATE)) SECOND(CAST(NULL AS DATE)) +NULL NULL NULL +SELECT HOUR(NULL), +MINUTE(NULL), +SECOND(NULL); +HOUR(NULL) MINUTE(NULL) SECOND(NULL) +NULL NULL NULL +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 316b79efe4d..df475b49746 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -246,4 +246,26 @@ INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL), SELECT cast(date(d1) as signed) FROM t1; drop table t1; +# +# Bug #31990: MINUTE() and SECOND() return bogus results when used on a DATE +# + +# Show that HH:MM:SS of a DATE are 0, and that it's the same for columns +# and typecasts (NULL in, NULL out). +CREATE TABLE t1 (f1 DATE); +INSERT INTO t1 VALUES ('2007-07-19'), (NULL); +SELECT HOUR(f1), + MINUTE(f1), + SECOND(f1) FROM t1; +SELECT HOUR(CAST('2007-07-19' AS DATE)), + MINUTE(CAST('2007-07-19' AS DATE)), + SECOND(CAST('2007-07-19' AS DATE)); +SELECT HOUR(CAST(NULL AS DATE)), + MINUTE(CAST(NULL AS DATE)), + SECOND(CAST(NULL AS DATE)); +SELECT HOUR(NULL), + MINUTE(NULL), + SECOND(NULL); +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c1fa9dce038..7ed5e375f5b 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2645,6 +2645,13 @@ bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date) } +bool Item_date_typecast::get_time(MYSQL_TIME *ltime) +{ + bzero((char *)ltime, sizeof(MYSQL_TIME)); + return args[0]->null_value; +} + + String *Item_date_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index a5ecbc57e8d..b647e93b700 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -779,6 +779,7 @@ public: const char *func_name() const { return "cast_as_date"; } String *val_str(String *str); bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); + bool get_time(MYSQL_TIME *ltime); const char *cast_type() const { return "date"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } Field *tmp_table_field(TABLE *t_arg) From e703c6a78c97eddf6a8fbf20bebe89d1ae504f93 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Fri, 9 Nov 2007 13:29:43 +0300 Subject: [PATCH 096/128] Fix for bug #32020: loading udfs while --skip-grant-tables is enabled causes out of memory errors The code in mysql_create_function() and mysql_drop_function() assumed that the only reason for UDFs being uninitialized at that point is an out-of-memory error during initialization. However, another possible reason for that is the --skip-grant-tables option in which case UDF initialization is skipped and UDFs are unavailable. The solution is to check whether mysqld is running with --skip-grant-tables and issue a proper error in such a case. --- mysql-test/r/skip_grants.result | 5 +++++ mysql-test/t/skip_grants.test | 12 ++++++++++++ sql/sql_udf.cc | 12 ++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result index 3052bae8e97..1ef35b051d6 100644 --- a/mysql-test/r/skip_grants.result +++ b/mysql-test/r/skip_grants.result @@ -70,3 +70,8 @@ count(*) select count(*) from information_schema.USER_PRIVILEGES; count(*) 0 +CREATE FUNCTION a RETURNS STRING SONAME ''; +ERROR HY000: Can't initialize function 'a'; UDFs are unavailable with the --skip-grant-tables option +DROP FUNCTION a; +ERROR 42000: FUNCTION test.a does not exist +End of 5.0 tests diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test index 75694672a17..02a381063ee 100644 --- a/mysql-test/t/skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -116,3 +116,15 @@ select count(*) from information_schema.COLUMN_PRIVILEGES; select count(*) from information_schema.SCHEMA_PRIVILEGES; select count(*) from information_schema.TABLE_PRIVILEGES; select count(*) from information_schema.USER_PRIVILEGES; + +# +# Bug #32020: loading udfs while --skip-grant-tables is enabled causes out of +# memory errors +# + +--error ER_CANT_INITIALIZE_UDF +CREATE FUNCTION a RETURNS STRING SONAME ''; +--error ER_SP_DOES_NOT_EXIST +DROP FUNCTION a; + +--echo End of 5.0 tests diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 077660f0bb9..e53dce1be13 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -410,7 +410,12 @@ int mysql_create_function(THD *thd,udf_func *udf) if (!initialized) { - my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); + if (opt_noacl) + my_error(ER_CANT_INITIALIZE_UDF, MYF(0), + udf->name.str, + "UDFs are unavailable with the --skip-grant-tables option"); + else + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); DBUG_RETURN(1); } @@ -514,7 +519,10 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) DBUG_ENTER("mysql_drop_function"); if (!initialized) { - my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); + if (opt_noacl) + my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str); + else + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); DBUG_RETURN(1); } rw_wrlock(&THR_LOCK_udf); From 8c19367881b6ded5e08649d5a3d50f3e2a48ab0d Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Fri, 9 Nov 2007 19:12:12 +0300 Subject: [PATCH 097/128] Fix for bug #32202: ORDER BY not working with GROUP BY The bug is a regression introduced by the fix for bug30596. The problem was that in cases when groups in GROUP BY correspond to only one row, and there is ORDER BY, the GROUP BY was removed and the ORDER BY rewritten to ORDER BY without checking if the columns in GROUP BY and ORDER BY are compatible. This led to incorrect ordering of the result set as it was sorted using the GROUP BY columns. Additionaly, the code discarded ASC/DESC modifiers from ORDER BY even if its columns were compatible with the GROUP BY ones. This patch fixes the regression by checking if ORDER BY columns form a prefix of the GROUP BY ones, and rewriting ORDER BY only in that case, preserving the ASC/DESC modifiers. That check is sufficient, since the GROUP BY columns contain a unique index. --- mysql-test/r/group_by.result | 65 ++++++++++++++++++++++++++++++++++++ mysql-test/t/group_by.test | 35 +++++++++++++++++++ sql/sql_select.cc | 15 +++++++-- 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 053c2901509..1693fa646eb 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1113,3 +1113,68 @@ c b 3 1 3 2 DROP TABLE t1; +CREATE TABLE t1( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +c2 INT NOT NULL, +UNIQUE KEY (c2,c1)); +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); +SELECT * FROM t1 ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2 ,c1, id ORDER BY c2, c1; +id c1 c2 +2 4 1 +1 5 1 +5 1 3 +4 2 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +5 1 3 +4 2 3 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +4 2 3 +5 1 3 +1 5 1 +2 4 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2, c1; +id c1 c2 +1 5 1 +4 2 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +4 2 3 +1 5 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +4 2 3 +1 5 1 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index b7c28cada46..b150db6dafe 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -815,3 +815,38 @@ EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; SELECT c,b FROM t1 GROUP BY c,b; DROP TABLE t1; + +# +# Bug #32202: ORDER BY not working with GROUP BY +# + +CREATE TABLE t1( + id INT AUTO_INCREMENT PRIMARY KEY, + c1 INT NOT NULL, + c2 INT NOT NULL, + UNIQUE KEY (c2,c1)); + +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); + +# Show that the test cases from the bug report pass +SELECT * FROM t1 ORDER BY c1; +SELECT * FROM t1 GROUP BY id ORDER BY c1; + +# Show that DESC is handled correctly +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; + +# Show that results are correctly ordered when ORDER BY fields +# are a subset of GROUP BY ones +SELECT * FROM t1 GROUP BY c2 ,c1, id ORDER BY c2, c1; +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1; +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1 DESC; + +# Show that results are correctly ordered when GROUP BY fields +# are a subset of ORDER BY ones +SELECT * FROM t1 GROUP BY c2 ORDER BY c2, c1; +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1; +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC; + +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3529de1c28a..3c840027ab5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1057,10 +1057,19 @@ JOIN::optimize() We have found that grouping can be removed since groups correspond to only one row anyway, but we still have to guarantee correct result order. The line below effectively rewrites the query from GROUP BY - to ORDER BY . One exception is if skip_sort_order is - set (see above), then we can simply skip GROUP BY. + to ORDER BY . There are two exceptions: + - if skip_sort_order is set (see above), then we can simply skip + GROUP BY; + - we can only rewrite ORDER BY if the ORDER BY fields are 'compatible' + with the GROUP BY ones, i.e. either one is a prefix of another. + We only check if the ORDER BY is a prefix of GROUP BY. In this case + test_if_subpart() copies the ASC/DESC attributes from the original + ORDER BY fields. + If GROUP BY is a prefix of ORDER BY, then it is safe to leave + 'order' as is. */ - order= skip_sort_order ? 0 : group_list; + if (!order || test_if_subpart(group_list, order)) + order= skip_sort_order ? 0 : group_list; group_list= 0; group= 0; } From 6776cc19a0271b3d63d0069aec2ae4155488b426 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Fri, 9 Nov 2007 23:22:00 +0100 Subject: [PATCH 098/128] Bug#32091: Security breach via directory changes Problem: the table's INDEX and DATA DIR was taken directly from the table's first partition. This allowed rename attack similar to bug#32111 when ALTER TABLE REMOVE PARTITIONING Solution: Silently ignore the INDEX/DATA DIR for the table. (Like some other storage engines do). Partitioned tables do not support DATA/INDEX DIR on the table level, only on its partitions. --- mysql-test/r/partition_mgm.result | 81 +++++++++++++++++++++ mysql-test/t/partition_mgm.test | 113 +++++++++++++++++++++++++++++- sql/ha_partition.cc | 1 + 3 files changed, 193 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 04ac603fea7..7d2c159bb15 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -1,4 +1,85 @@ DROP TABLE IF EXISTS t1; +# Creating two non colliding tables mysqltest2.t1 and test.t1 +# test.t1 have partitions in mysqltest2-directory! +# user root: +GRANT USAGE ON test.* TO mysqltest_1@localhost; +CREATE DATABASE mysqltest2; +USE mysqltest2; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +# user mysqltest_1: +USE test; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', +PARTITION p2 VALUES IN (2) +); +# without the patch for bug#32091 this would create +# files mysqltest2/t1.MYD + .MYI and possible overwrite +# the mysqltest2.t1 table (depending on bug#32111) +ALTER TABLE t1 REMOVE PARTITIONING; +INSERT INTO t1 VALUES (1); +SELECT * FROM t1; +a +1 +# user root: +USE mysqltest2; +FLUSH TABLES; +# if the patch works, this should be different +# and before the patch they were the same! +SELECT * FROM t1; +a +0 +USE test; +SELECT * FROM t1; +a +1 +DROP TABLE t1; +DROP DATABASE mysqltest2; +# test that symlinks can not overwrite files when CREATE TABLE +# user root: +CREATE DATABASE mysqltest2; +USE mysqltest2; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + ); +# user mysqltest_1: +USE test; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + ); +ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/master-data/mysqltest2/t1#P#p0.MYI' (Errcode: 17) +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + ); +ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/master-data/test/t1#P#p1.MYI' (Errcode: 17) +# user root (cleanup): +DROP DATABASE mysqltest2; +USE test; +REVOKE USAGE ON *.* FROM mysqltest_1@localhost; create table t1 (a int) partition by range (a) subpartition by key (a) diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index a06f8d1aee5..a405e15ec16 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -1,7 +1,116 @@ -- source include/have_partition.inc ---disable_warnings +-- disable_warnings DROP TABLE IF EXISTS t1; ---enable_warnings +-- enable_warnings + +# +# Bug 32091: Security breach via directory changes +# +# The below test shows that a pre-existing table mysqltest2.t1 cannot be +# replaced by a user with no rights in 'mysqltest2'. The altered table +# test.t1 will be altered (remove partitioning) into the test directory +# and having its partitions removed from the mysqltest2 directory. +# (the partitions data files are named #P#.MYD +# and will not collide with a non partitioned table's data files.) +# NOTE: the privileges on files and directories are the same for all +# database users in mysqld, though mysqld enforces privileges on +# the database and table levels which in turn maps to directories and +# files, but not the other way around (any db-user can use any +# directory or file that the mysqld-process can use, via DATA/INDEX DIR) +# this is the security flaw that was used in bug#32091 and bug#32111 +-- echo # Creating two non colliding tables mysqltest2.t1 and test.t1 +-- echo # test.t1 have partitions in mysqltest2-directory! +-- echo # user root: + GRANT USAGE ON test.* TO mysqltest_1@localhost; + CREATE DATABASE mysqltest2; + USE mysqltest2; + CREATE TABLE t1 (a INT); + INSERT INTO t1 VALUES (0); +connect(con1,localhost,mysqltest_1,,); +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', + PARTITION p2 VALUES IN (2) + ); + -- echo # without the patch for bug#32091 this would create + -- echo # files mysqltest2/t1.MYD + .MYI and possible overwrite + -- echo # the mysqltest2.t1 table (depending on bug#32111) + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + ALTER TABLE t1 REMOVE PARTITIONING; + INSERT INTO t1 VALUES (1); + SELECT * FROM t1; +connection default; +-- echo # user root: + USE mysqltest2; + FLUSH TABLES; + -- echo # if the patch works, this should be different + -- echo # and before the patch they were the same! + SELECT * FROM t1; + USE test; + SELECT * FROM t1; + DROP TABLE t1; + DROP DATABASE mysqltest2; +# The below test shows that a pre-existing partition can not be +# destroyed by a new partition from another table. +# (Remember that a table or partition that uses the DATA/INDEX DIR +# is symlinked and thus has +# 1. the real file in the DATA/INDEX DIR and +# 2. a symlink in its default database directory pointing to +# the real file. +# So it is using/blocking 2 files in (in 2 different directories +-- echo # test that symlinks can not overwrite files when CREATE TABLE +-- echo # user root: + CREATE DATABASE mysqltest2; + USE mysqltest2; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + ); +connection con1; +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + ); + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + ); +connection default; +-- echo # user root (cleanup): + DROP DATABASE mysqltest2; + USE test; + REVOKE USAGE ON *.* FROM mysqltest_1@localhost; + disconnect con1; # # Bug 21143: mysqld hang when error in number of subparts in diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 363c0a273bc..b53a5e3da97 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1599,6 +1599,7 @@ error: void ha_partition::update_create_info(HA_CREATE_INFO *create_info) { m_file[0]->update_create_info(create_info); + create_info->data_file_name= create_info->index_file_name = NULL; return; } From 43c1daf630a28b64048fb20fae5b3052c09aa3a3 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Sat, 10 Nov 2007 13:09:18 +0100 Subject: [PATCH 099/128] Bug#29368: Modified error messages Problem: there was no standard syntax error when creating partitions with syntax error in the partitioning clause. Solution: added "Syntax error: " to the error message --- mysql-test/r/partition.result | 4 ++-- mysql-test/r/partition_error.result | 15 ++++++++++++--- mysql-test/t/partition_error.test | 13 +++++++++++++ sql/share/errmsg.txt | 6 +++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 4e4bd0bbc0a..3c41e9a0d49 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -709,7 +709,7 @@ partition by range (a) alter table t1 add partition (partition p1 values in (2)); ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition alter table t1 add partition (partition p1); -ERROR HY000: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition drop table t1; create table t1 (a int) partition by list (a) @@ -717,7 +717,7 @@ partition by list (a) alter table t1 add partition (partition p1 values less than (2)); ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition alter table t1 add partition (partition p1); -ERROR HY000: LIST PARTITIONING requires definition of VALUES IN for each partition +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition drop table t1; create table t1 (a int) partition by hash (a) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 7952c8df609..46532cb32ab 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,4 +1,13 @@ drop table if exists t1; +CREATE TABLE t1 ( +a int +) +PARTITION BY RANGE (a) +( +PARTITION p0 VALUES LESS THAN (1), +PARTITION p1 VALU ES LESS THAN (2) +); +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition partition by list (a) partitions 3 (partition x1 values in (1,2,9,4) tablespace ts1, @@ -351,7 +360,7 @@ partition by range (a) partitions 2 (partition x1 values less than (4), partition x2); -ERROR HY000: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition CREATE TABLE t1 ( a int not null, b int not null, @@ -531,7 +540,7 @@ partition by list (a) partitions 2 (partition x1 values in (4), partition x2); -ERROR HY000: LIST PARTITIONING requires definition of VALUES IN for each partition +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition CREATE TABLE t1 ( a int not null, b int not null, @@ -551,7 +560,7 @@ partition by list (a) partitions 2 (partition x1 values in (4,6), partition x2); -ERROR HY000: LIST PARTITIONING requires definition of VALUES IN for each partition +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition CREATE TABLE t1 ( a int not null, b int not null, diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 5fc2097cc52..c9b95fc1664 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -8,6 +8,19 @@ drop table if exists t1; --enable_warnings +# +# Bug 29368: +# Incorrect error, 1467, for syntax error when creating partition +--error ER_PARTITION_REQUIRES_VALUES_ERROR +CREATE TABLE t1 ( + a int +) +PARTITION BY RANGE (a) +( + PARTITION p0 VALUES LESS THAN (1), + PARTITION p1 VALU ES LESS THAN (2) +); + # # Partition by key stand-alone error # diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 8fad09eb221..257cea7c27b 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5667,9 +5667,9 @@ ER_ILLEGAL_HA_CREATE_OPTION eng "Table storage engine '%-.64s' does not support the create option '%.64s'" ger "Speicher-Engine '%-.64s' der Tabelle unterstützt die Option '%.64s' nicht" ER_PARTITION_REQUIRES_VALUES_ERROR - eng "%-.64s PARTITIONING requires definition of VALUES %-.64s for each partition" - ger "%-.64s-PARTITIONierung erfordert Definition von VALUES %-.64s für jede Partition" - swe "%-.64s PARTITIONering kräver definition av VALUES %-.64s för varje partition" + eng "Syntax error: %-.64s PARTITIONING requires definition of VALUES %-.64s for each partition" + ger "Fehler in der SQL-Syntax: %-.64s-PARTITIONierung erfordert Definition von VALUES %-.64s für jede Partition" + swe "Syntaxfel: %-.64s PARTITIONering kräver definition av VALUES %-.64s för varje partition" ER_PARTITION_WRONG_VALUES_ERROR eng "Only %-.64s PARTITIONING can use VALUES %-.64s in partition definition" ger "Nur %-.64s-PARTITIONierung kann VALUES %-.64s in der Partitionsdefinition verwenden" From dd7452c280687e96d970e9364a56ea62ffb91782 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Sat, 10 Nov 2007 13:33:42 +0100 Subject: [PATCH 100/128] Bug#31800: Date comparison fails with timezone and slashes for greater than comparison BETWEEN was more lenient with regard to what it accepted as a DATE/DATETIME in comparisons than greater-than and less-than were. ChangeSet makes < > comparisons similarly robust with regard to trailing garbage (" GMT-1") and "missing" leading zeros. Now all three comparators behave similarly in that they throw a warning for "junk" at the end of the data, but then proceed anyway if possible. Before < > fell back on a string- (rather than date-) comparison when a warning-condition was raised in the string-to-date conversion. Now the fallback only happens on actual errors, while warning- conditions still result in a warning being to delivered to the client. --- mysql-test/r/select.result | 160 +++++++++++++++++++++++++++++++++++-- mysql-test/t/select.test | 78 ++++++++++++++++-- sql-common/my_time.c | 32 ++++---- sql/item_cmpfunc.cc | 61 ++++++++------ 4 files changed, 278 insertions(+), 53 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 52f2e84bf4e..36faba94404 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3233,40 +3233,40 @@ drop table t1, t2 ,t3; create table t1(f1 int, f2 date); insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), (4,'2005-10-01'),(5,'2005-12-30'); -select * from t1 where f2 >= 0; +select * from t1 where f2 >= 0 order by f2; f1 f2 1 2005-01-01 2 2005-09-01 3 2005-09-30 4 2005-10-01 5 2005-12-30 -select * from t1 where f2 >= '0000-00-00'; +select * from t1 where f2 >= '0000-00-00' order by f2; f1 f2 1 2005-01-01 2 2005-09-01 3 2005-09-30 4 2005-10-01 5 2005-12-30 -select * from t1 where f2 >= '2005-09-31'; +select * from t1 where f2 >= '2005-09-31' order by f2; f1 f2 4 2005-10-01 5 2005-12-30 -select * from t1 where f2 >= '2005-09-3a'; +select * from t1 where f2 >= '2005-09-3a' order by f2; f1 f2 +3 2005-09-30 4 2005-10-01 5 2005-12-30 Warnings: Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 -select * from t1 where f2 <= '2005-09-31'; +select * from t1 where f2 <= '2005-09-31' order by f2; f1 f2 1 2005-01-01 2 2005-09-01 3 2005-09-30 -select * from t1 where f2 <= '2005-09-3a'; +select * from t1 where f2 <= '2005-09-3a' order by f2; f1 f2 1 2005-01-01 2 2005-09-01 -3 2005-09-30 Warnings: Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 drop table t1; @@ -4094,4 +4094,150 @@ x ALTER VIEW v1 AS SELECT 1 AS ` `; ERROR 42000: Incorrect column name ' ' DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34'; +str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34' +1 +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +1 +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +1 +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +0 +Warnings: +Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1 +Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1 +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '' +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +0 +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +0 +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +str_to_date('1','%Y-%m-%d') = '1' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +str_to_date('1','%Y-%m-%d') = '1' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '1' +select str_to_date('','%Y-%m-%d') = ''; +str_to_date('','%Y-%m-%d') = '' +0 +Warnings: +Warning 1292 Truncated incorrect date value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +0 +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index a6ed3c854b4..f9d11d2d9a9 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2742,14 +2742,14 @@ create table t1(f1 int, f2 date); insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), (4,'2005-10-01'),(5,'2005-12-30'); # should return all records -select * from t1 where f2 >= 0; -select * from t1 where f2 >= '0000-00-00'; +select * from t1 where f2 >= 0 order by f2; +select * from t1 where f2 >= '0000-00-00' order by f2; # should return 4,5 -select * from t1 where f2 >= '2005-09-31'; -select * from t1 where f2 >= '2005-09-3a'; +select * from t1 where f2 >= '2005-09-31' order by f2; +select * from t1 where f2 >= '2005-09-3a' order by f2; # should return 1,2,3 -select * from t1 where f2 <= '2005-09-31'; -select * from t1 where f2 <= '2005-09-3a'; +select * from t1 where f2 <= '2005-09-31' order by f2; +select * from t1 where f2 <= '2005-09-3a' order by f2; drop table t1; # @@ -3491,4 +3491,70 @@ ALTER VIEW v1 AS SELECT 1 AS ` `; DROP VIEW v1; +# +# Bug#31800: Date comparison fails with timezone and slashes for greater +# than comparison +# + +# On DATETIME-like literals with trailing garbage, BETWEEN fudged in a +# DATETIME comparator, while greater/less-than used bin-string comparisons. +# Should correctly be compared as DATE or DATETIME, but throw a warning: + +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; + +# We have all we need -- and trailing garbage: +# (leaving out a leading zero in first example to prove it's a +# value-comparison, not a string-comparison!) +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +# no time at all: +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +# partial time: +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +# fail, different second part: +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +# correct syntax, no trailing nonsense -- this one must throw no warning: +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +# no warning, but failure (different hour parts): +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +# succeed: +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +# succeed, but warn for "trailing garbage" (":34"): +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +# invalid date (Feb 30) succeeds +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34'; +# 0-day for both, just works in default SQL mode. +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +# 0-day, succeed +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +set SQL_MODE=TRADITIONAL; +# 0-day throws warning in traditional mode, and fails +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +# different code-path: get_datetime_value() with 0-day +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; + +select str_to_date('1','%Y-%m-%d') = '1'; +select str_to_date('1','%Y-%m-%d') = '1'; +select str_to_date('','%Y-%m-%d') = ''; + +# these three should work! +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; + --echo End of 5.0 tests diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 3c08db6bf97..453c7b73008 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -54,24 +54,24 @@ uint calc_days_in_year(uint year) 366 : 365); } -/* - Check datetime value for validity according to flags. +/** + @brief Check datetime value for validity according to flags. - SYNOPSIS - check_date() - ltime Date to check. - not_zero_date ltime is not the zero date - flags flags to check - was_cut set to 2 if value was truncated. - NOTE: This is not touched if value was not truncated - NOTES - Here we assume that year and month is ok ! + @param[in] ltime Date to check. + @param[in] not_zero_date ltime is not the zero date + @param[in] flags flags to check + (see str_to_datetime() flags in my_time.h) + @param[out] was_cut set to 2 if value was invalid according to flags. + (Feb 29 in non-leap etc.) This remains unchanged + if value is not invalid. + + @details Here we assume that year and month is ok! If month is 0 we allow any date. (This only happens if we allow zero date parts in str_to_datetime()) Disallow dates with zero year and non-zero month and/or day. - RETURN - 0 ok + @return + 0 OK 1 error */ @@ -117,9 +117,9 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, TIME_NO_ZERO_IN_DATE Don't allow partial dates TIME_NO_ZERO_DATE Don't allow 0000-00-00 date TIME_INVALID_DATES Allow 2000-02-31 - was_cut 0 Value ok + was_cut 0 Value OK 1 If value was cut during conversion - 2 Date part was within ranges but date was wrong + 2 check_date(date,flags) considers date invalid DESCRIPTION At least the following formats are recogniced (based on number of digits) @@ -1087,7 +1087,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to) flags - flags to use in validating date, as in str_to_datetime() was_cut 0 Value ok 1 If value was cut during conversion - 2 Date part was within ranges but date was wrong + 2 check_date(date,flags) considers date invalid DESCRIPTION Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS, diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a9ad5ad675d..e67ad30f9c5 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -552,26 +552,26 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) } -/* - Convert date provided in a string to the int representation. +/** + @brief Convert date provided in a string to the int representation. - SYNOPSIS - get_date_from_str() - thd Thread handle - str a string to convert - warn_type type of the timestamp for issuing the warning - warn_name field name for issuing the warning - error_arg [out] TRUE if string isn't a DATETIME or clipping occur + @param[in] thd thread handle + @param[in] str a string to convert + @param[in] warn_type type of the timestamp for issuing the warning + @param[in] warn_name field name for issuing the warning + @param[out] error_arg could not extract a DATE or DATETIME - DESCRIPTION - Convert date provided in the string str to the int representation. - if the string contains wrong date or doesn't contain it at all - then the warning is issued and TRUE returned in the error_arg argument. - The warn_type and the warn_name arguments are used as the name and the - type of the field when issuing the warning. + @details Convert date provided in the string str to the int + representation. If the string contains wrong date or doesn't + contain it at all then a warning is issued. The warn_type and + the warn_name arguments are used as the name and the type of the + field when issuing the warning. If any input was discarded + (trailing or non-timestampy characters), was_cut will be non-zero. + was_type will return the type str_to_datetime() could correctly + extract. - RETURN - converted value. + @return + converted value. 0 on error and on zero-dates -- check 'failure' */ static ulonglong @@ -582,26 +582,33 @@ get_date_from_str(THD *thd, String *str, timestamp_type warn_type, int error; MYSQL_TIME l_time; enum_mysql_timestamp_type ret; - *error_arg= TRUE; ret= str_to_datetime(str->ptr(), str->length(), &l_time, (TIME_FUZZY_DATE | MODE_INVALID_DATES | (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE))), &error); - if ((ret == MYSQL_TIMESTAMP_DATETIME || ret == MYSQL_TIMESTAMP_DATE)) + + if (ret == MYSQL_TIMESTAMP_DATETIME || ret == MYSQL_TIMESTAMP_DATE) { - value= TIME_to_ulonglong_datetime(&l_time); + /* + Do not return yet, we may still want to throw a "trailing garbage" + warning. + */ *error_arg= FALSE; + value= TIME_to_ulonglong_datetime(&l_time); + } + else + { + *error_arg= TRUE; + error= 1; /* force warning */ } - if (error || *error_arg) - { + if (error > 0) make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, str->ptr(), str->length(), warn_type, warn_name); - *error_arg= TRUE; - } + return value; } @@ -902,6 +909,12 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, timestamp_type t_type= f_type == MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME; value= get_date_from_str(thd, str, t_type, warn_item->name, &error); + /* + If str did not contain a valid date according to the current + SQL_MODE, get_date_from_str() has already thrown a warning, + and we don't want to throw NULL on invalid date (see 5.2.6 + "SQL modes" in the manual), so we're done here. + */ } /* Do not cache GET_USER_VAR() function as its const_item() may return TRUE From 10df30f091931ae83abf936905807d604d08dcc4 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Sat, 10 Nov 2007 14:36:25 +0100 Subject: [PATCH 101/128] Bug#31210 - INSERT DELAYED crashes server when used on partitioned table Post-merge fix A new need for lex initialization arose. --- sql/ha_ndbcluster.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 436710e3dee..bf2b19bfc9c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -9073,6 +9073,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) thd->thread_stack= (char*)&thd; /* remember where our stack is */ if (thd->store_globals()) goto ndb_util_thread_fail; + lex_start(thd); thd->init_for_queries(); thd->version=refresh_version; thd->main_security_ctx.host_or_ip= ""; From 47a03ea32169e56526b31423334a56c8b6095621 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Sat, 10 Nov 2007 14:56:21 +0100 Subject: [PATCH 102/128] Bug#32091: Security breach via directory changes small fix of test case (when running make test after merge, it did not substitute MYSQLTEST_VARDIR in the error) --- mysql-test/r/partition_mgm.result | 4 ++-- mysql-test/t/partition_mgm.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 7d2c159bb15..e59a2e881dd 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -65,7 +65,7 @@ PARTITION p1 VALUES IN (1) DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' ); -ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/master-data/mysqltest2/t1#P#p0.MYI' (Errcode: 17) +Got one of the listed errors CREATE TABLE t1 (a INT) PARTITION BY LIST (a) ( PARTITION p0 VALUES IN (0) @@ -75,7 +75,7 @@ PARTITION p1 VALUES IN (1) DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' ); -ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/master-data/test/t1#P#p1.MYI' (Errcode: 17) +Got one of the listed errors # user root (cleanup): DROP DATABASE mysqltest2; USE test; diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index a405e15ec16..0127f61eb4b 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -84,7 +84,7 @@ connection con1; -- echo # user mysqltest_1: USE test; -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - -- error 1 + -- error 1,1 eval CREATE TABLE t1 (a INT) PARTITION BY LIST (a) ( PARTITION p0 VALUES IN (0) @@ -95,7 +95,7 @@ connection con1; INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' ); -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - -- error 1 + -- error 1,1 eval CREATE TABLE t1 (a INT) PARTITION BY LIST (a) ( PARTITION p0 VALUES IN (0) From 8a5e621ff2c902762f60ee09eb30a58d2585950c Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Sat, 10 Nov 2007 18:29:13 +0100 Subject: [PATCH 103/128] Bug#31700: thd->examined_row_count not incremented for 'const' type queries UNIQUE (eq-ref) lookups result in table being considered as a "constant" table. Queries that consist of only constant tables are processed in do_select() in a special way that doesn't invoke evaluate_join_record(), and therefore doesn't increase the counters join->examined_rows and join->thd->row_count. The patch increases these counters in this special case. NOTICE: This behavior seems to contradict what the documentation says in Sect. 5.11.4: "Queries handled by the query cache are not added to the slow query log, nor are queries that would not benefit from the presence of an index because the table has zero rows or one row." No test case in 5.0 as issue shows only in slow query log, and other counters can give subtly different values (with regard to counting in create_sort_index(), synthetic rows in ROLLUP, etc.). --- sql/sql_class.h | 23 +++++++++++++++++++---- sql/sql_select.cc | 9 +++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 62b1008e59c..93a9d4d6da2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1368,9 +1368,20 @@ public: ulonglong limit_found_rows; ulonglong options; /* Bitmap of states */ - longlong row_count_func; /* For the ROW_COUNT() function */ - ha_rows cuted_fields, - sent_row_count, examined_row_count; + longlong row_count_func; /* For the ROW_COUNT() function */ + ha_rows cuted_fields; + + /* + number of rows we actually sent to the client, including "synthetic" + rows in ROLLUP etc. + */ + ha_rows sent_row_count; + + /* + number of rows we read, sent or not, including in create_sort_index() + */ + ha_rows examined_row_count; + /* The set of those tables whose fields are referenced in all subqueries of the query. @@ -1403,7 +1414,11 @@ public: /* Statement id is thread-wide. This counter is used to generate ids */ ulong statement_id_counter; ulong rand_saved_seed1, rand_saved_seed2; - ulong row_count; // Row counter, mainly for errors and warnings + /* + Row counter, mainly for errors and warnings. Not increased in + create_sort_index(); may differ from examined_row_count. + */ + ulong row_count; long dbug_thread_id; pthread_t real_id; uint tmp_table, global_read_lock; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7af39071561..d6aae35205c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10339,6 +10339,15 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) error= (*end_select)(join,join_tab,0); if (error == NESTED_LOOP_OK || error == NESTED_LOOP_QUERY_LIMIT) error= (*end_select)(join,join_tab,1); + + /* + If we don't go through evaluate_join_record(), do the counting + here. join->send_records is increased on success in end_send(), + so we don't touch it here. + */ + join->examined_rows++; + join->thd->row_count++; + DBUG_ASSERT(join->examined_rows <= 1); } else if (join->send_row_on_empty_set()) { From 0aabb89ee11a7492a0788470be9a6ba018152c9f Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Sat, 10 Nov 2007 23:44:48 +0400 Subject: [PATCH 104/128] Fixed bug #28076: inconsistent binary/varbinary comparison. After adding an index the IN (SELECT ...) clause returned a wrong result: the VARBINARY value was illegally padded with zero bytes to the length of the BINARY column for the index search. (, ...) IN (SELECT , ... ) clauses are affected too. --- mysql-test/r/subselect.result | 49 +++++++++++++++++++++++++++++++++++ mysql-test/t/subselect.test | 42 ++++++++++++++++++++++++++++++ sql/item.cc | 16 +++++++++--- sql/item.h | 14 +++++++--- sql/item_cmpfunc.cc | 2 +- sql/item_subselect.cc | 13 +++++++++- sql/sp_rcontext.cc | 6 ++--- sql/sp_rcontext.h | 2 +- sql/sql_class.cc | 2 +- 9 files changed, 132 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index bfacfc86eef..1c450269809 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4150,4 +4150,53 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; 0 0 DROP TABLE t1, t2; +CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); +INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); +SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); +s1 s2 +SELECT s1, s2 FROM t1 WHERE (s2, 10) IN (SELECT s1, 10 FROM t1); +s1 s2 +CREATE INDEX I1 ON t1 (s1); +CREATE INDEX I2 ON t1 (s2); +SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); +s1 s2 +SELECT s1, s2 FROM t1 WHERE (s2, 10) IN (SELECT s1, 10 FROM t1); +s1 s2 +TRUNCATE t1; +INSERT INTO t1 VALUES (0x41,0x41); +SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1); +s1 s2 +DROP TABLE t1; +CREATE TABLE t1 (a1 VARBINARY(2) NOT NULL DEFAULT '0', PRIMARY KEY (a1)); +CREATE TABLE t2 (a2 BINARY(2) default '0', INDEX (a2)); +CREATE TABLE t3 (a3 BINARY(2) default '0'); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2),(3); +INSERT INTO t3 VALUES (1),(2),(3); +SELECT LEFT(t2.a2, 1) FROM t2,t3 WHERE t3.a3=t2.a2; +LEFT(t2.a2, 1) +1 +2 +3 +SELECT t1.a1, t1.a1 in (SELECT t2.a2 FROM t2,t3 WHERE t3.a3=t2.a2) FROM t1; +a1 t1.a1 in (SELECT t2.a2 FROM t2,t3 WHERE t3.a3=t2.a2) +1 0 +2 0 +3 0 +4 0 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a1 BINARY(3) PRIMARY KEY, b1 VARBINARY(3)); +CREATE TABLE t2 (a2 VARBINARY(3) PRIMARY KEY); +CREATE TABLE t3 (a3 VARBINARY(3) PRIMARY KEY); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10), (20), (30); +SELECT LEFT(t1.a1,1) FROM t1,t3 WHERE t1.b1=t3.a3; +LEFT(t1.a1,1) +1 +2 +3 +SELECT a2 FROM t2 WHERE t2.a2 IN (SELECT t1.a1 FROM t1,t3 WHERE t1.b1=t3.a3); +a2 +DROP TABLE t1, t2, t3; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index b5279331a5f..5a1870e49c6 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3002,4 +3002,46 @@ INSERT INTO t2 VALUES (103, 203); SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1; DROP TABLE t1, t2; +# +# Bug #28076: inconsistent binary/varbinary comparison +# + +CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5)); +INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43); + +SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); +SELECT s1, s2 FROM t1 WHERE (s2, 10) IN (SELECT s1, 10 FROM t1); + +CREATE INDEX I1 ON t1 (s1); +CREATE INDEX I2 ON t1 (s2); + +SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1); +SELECT s1, s2 FROM t1 WHERE (s2, 10) IN (SELECT s1, 10 FROM t1); + +TRUNCATE t1; +INSERT INTO t1 VALUES (0x41,0x41); +SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1); + +DROP TABLE t1; + +CREATE TABLE t1 (a1 VARBINARY(2) NOT NULL DEFAULT '0', PRIMARY KEY (a1)); +CREATE TABLE t2 (a2 BINARY(2) default '0', INDEX (a2)); +CREATE TABLE t3 (a3 BINARY(2) default '0'); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2),(3); +INSERT INTO t3 VALUES (1),(2),(3); +SELECT LEFT(t2.a2, 1) FROM t2,t3 WHERE t3.a3=t2.a2; +SELECT t1.a1, t1.a1 in (SELECT t2.a2 FROM t2,t3 WHERE t3.a3=t2.a2) FROM t1; +DROP TABLE t1,t2,t3; + +CREATE TABLE t1 (a1 BINARY(3) PRIMARY KEY, b1 VARBINARY(3)); +CREATE TABLE t2 (a2 VARBINARY(3) PRIMARY KEY); +CREATE TABLE t3 (a3 VARBINARY(3) PRIMARY KEY); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10), (20), (30); +SELECT LEFT(t1.a1,1) FROM t1,t3 WHERE t1.b1=t3.a3; +SELECT a2 FROM t2 WHERE t2.a2 IN (SELECT t1.a1 FROM t1,t3 WHERE t1.b1=t3.a3); +DROP TABLE t1, t2, t3; + --echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index dc3b1fc6b79..af3b1566632 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6259,9 +6259,9 @@ bool field_is_equal_to_item(Field *field,Item *item) return result == field->val_real(); } -Item_cache* Item_cache::get_cache(Item_result type) +Item_cache* Item_cache::get_cache(const Item *item) { - switch (type) { + switch (item->result_type()) { case INT_RESULT: return new Item_cache_int(); case REAL_RESULT: @@ -6269,7 +6269,7 @@ Item_cache* Item_cache::get_cache(Item_result type) case DECIMAL_RESULT: return new Item_cache_decimal(); case STRING_RESULT: - return new Item_cache_str(); + return new Item_cache_str(item); case ROW_RESULT: return new Item_cache_row(); default: @@ -6447,6 +6447,14 @@ my_decimal *Item_cache_str::val_decimal(my_decimal *decimal_val) } +int Item_cache_str::save_in_field(Field *field, bool no_conversions) +{ + int res= Item_cache::save_in_field(field, no_conversions); + return (is_varbinary && field->type() == MYSQL_TYPE_STRING && + value->length() < field->field_length) ? 1 : res; +} + + bool Item_cache_row::allocate(uint num) { item_count= num; @@ -6465,7 +6473,7 @@ bool Item_cache_row::setup(Item * item) { Item *el= item->element_index(i); Item_cache *tmp; - if (!(tmp= values[i]= Item_cache::get_cache(el->result_type()))) + if (!(tmp= values[i]= Item_cache::get_cache(el))) return 1; tmp->setup(el); } diff --git a/sql/item.h b/sql/item.h index 2f504badec0..a1135c2c725 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2469,7 +2469,7 @@ public: }; virtual void store(Item *)= 0; enum Type type() const { return CACHE_ITEM; } - static Item_cache* get_cache(Item_result type); + static Item_cache* get_cache(const Item *item); table_map used_tables() const { return used_table_map; } virtual void keep_array() {} // to prevent drop fixed flag (no need parent cleanup call) @@ -2531,9 +2531,16 @@ class Item_cache_str: public Item_cache { char buffer[STRING_BUFFER_USUAL_SIZE]; String *value, value_buff; + bool is_varbinary; + public: - Item_cache_str(): Item_cache(), value(0) { } - + Item_cache_str(const Item *item) : + Item_cache(), value(0), + is_varbinary(item->type() == FIELD_ITEM && + ((const Item_field *) item)->field->type() == + MYSQL_TYPE_VARCHAR && + !((const Item_field *) item)->field->has_charset()) + {} void store(Item *item); double val_real(); longlong val_int(); @@ -2541,6 +2548,7 @@ public: my_decimal *val_decimal(my_decimal *); enum Item_result result_type() const { return STRING_RESULT; } CHARSET_INFO *charset() const { return value->charset(); }; + int save_in_field(Field *field, bool no_conversions); }; class Item_cache_row: public Item_cache diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a9ad5ad675d..345b84e8868 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1373,7 +1373,7 @@ longlong Item_func_truth::val_int() bool Item_in_optimizer::fix_left(THD *thd, Item **ref) { if (!args[0]->fixed && args[0]->fix_fields(thd, args) || - !cache && !(cache= Item_cache::get_cache(args[0]->result_type()))) + !cache && !(cache= Item_cache::get_cache(args[0]))) return 1; cache->setup(args[0]); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0020dd35c61..57c3b391507 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1717,7 +1717,7 @@ void subselect_engine::set_row(List &item_list, Item_cache **row) item->decimals= sel_item->decimals; item->unsigned_flag= sel_item->unsigned_flag; maybe_null= sel_item->maybe_null; - if (!(row[i]= Item_cache::get_cache(res_type))) + if (!(row[i]= Item_cache::get_cache(sel_item))) return; row[i]->setup(sel_item); } @@ -2178,6 +2178,7 @@ int subselect_indexsubquery_engine::exec() ((Item_in_subselect *) item)->value= 0; empty_result_set= TRUE; null_keypart= 0; + table->status= 0; if (check_null) { @@ -2190,6 +2191,16 @@ int subselect_indexsubquery_engine::exec() if (copy_ref_key()) DBUG_RETURN(1); + if (table->status) + { + /* + We know that there will be no rows even if we scan. + Can be set in copy_ref_key. + */ + ((Item_in_subselect *) item)->value= 0; + DBUG_RETURN(0); + } + if (null_keypart) DBUG_RETURN(scan_table()); diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index ac7c46c9fe5..54e016f6099 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -503,14 +503,14 @@ sp_cursor::fetch(THD *thd, List *vars) */ Item_cache * -sp_rcontext::create_case_expr_holder(THD *thd, Item_result result_type) +sp_rcontext::create_case_expr_holder(THD *thd, const Item *item) { Item_cache *holder; Query_arena current_arena; thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); - holder= Item_cache::get_cache(result_type); + holder= Item_cache::get_cache(item); thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); @@ -559,7 +559,7 @@ sp_rcontext::set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr case_expr_item->result_type()) { m_case_expr_holders[case_expr_id]= - create_case_expr_holder(thd, case_expr_item->result_type()); + create_case_expr_holder(thd, case_expr_item); } m_case_expr_holders[case_expr_id]->store(case_expr_item); diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 0104b71a648..43102cfeeb2 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -261,7 +261,7 @@ private: bool init_var_table(THD *thd); bool init_var_items(); - Item_cache *create_case_expr_holder(THD *thd, Item_result result_type); + Item_cache *create_case_expr_holder(THD *thd, const Item *item); int set_variable(THD *thd, Field *field, Item **value); }; // class sp_rcontext : public Sql_alloc diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0bef946928b..ef199b6f883 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1553,7 +1553,7 @@ bool select_max_min_finder_subselect::send_data(List &items) { if (!cache) { - cache= Item_cache::get_cache(val_item->result_type()); + cache= Item_cache::get_cache(val_item); switch (val_item->result_type()) { case REAL_RESULT: From f9c771b037cf10fec7e29121f9363e8469772719 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Sat, 10 Nov 2007 21:29:39 +0100 Subject: [PATCH 105/128] Bug#32091: Security breach via directory changes Changed test case from GRANT to CREATE USER --- mysql-test/r/partition_mgm.result | 5 +++-- mysql-test/t/partition_mgm.test | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index e59a2e881dd..04358fa0f9f 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -1,8 +1,9 @@ DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest2; # Creating two non colliding tables mysqltest2.t1 and test.t1 # test.t1 have partitions in mysqltest2-directory! # user root: -GRANT USAGE ON test.* TO mysqltest_1@localhost; +CREATE USER mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT); @@ -79,7 +80,7 @@ Got one of the listed errors # user root (cleanup): DROP DATABASE mysqltest2; USE test; -REVOKE USAGE ON *.* FROM mysqltest_1@localhost; +DROP USER mysqltest_1@localhost; create table t1 (a int) partition by range (a) subpartition by key (a) diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 0127f61eb4b..1532ea64ab2 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -1,6 +1,7 @@ -- source include/have_partition.inc -- disable_warnings DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest2; -- enable_warnings # @@ -21,7 +22,7 @@ DROP TABLE IF EXISTS t1; -- echo # Creating two non colliding tables mysqltest2.t1 and test.t1 -- echo # test.t1 have partitions in mysqltest2-directory! -- echo # user root: - GRANT USAGE ON test.* TO mysqltest_1@localhost; + CREATE USER mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT); @@ -109,7 +110,7 @@ connection default; -- echo # user root (cleanup): DROP DATABASE mysqltest2; USE test; - REVOKE USAGE ON *.* FROM mysqltest_1@localhost; + DROP USER mysqltest_1@localhost; disconnect con1; # From 7908e3b6c280ab5e001c0572f3ece52f2591a477 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Sat, 10 Nov 2007 21:51:47 +0100 Subject: [PATCH 106/128] Bug#31700: thd->examined_row_count not incremented for 'const' type queries add 5.1-specific test showing that 'const' access increments 'examined' counter in slow query log. --- mysql-test/r/log_tables.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/log_tables.test | 31 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 261e3292f4d..6004c3d082b 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -820,3 +820,31 @@ Execute select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 0 Query set global general_log = off deallocate prepare long_query; set global general_log = @old_general_log_state; +SET @old_slow_log_state = @@global.slow_query_log; +SET SESSION long_query_time = 0; +SET GLOBAL slow_query_log = ON; +FLUSH LOGS; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (f1 SERIAL,f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2)); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,2,2); +INSERT INTO t1 VALUES (3,3,3); +INSERT INTO t1 VALUES (4,4,4); +SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4; +Bug#31700 - SCAN f1 f2 f3 +Bug#31700 - SCAN 4 4 4 +SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3; +Bug#31700 - KEY f1 f2 f3 +Bug#31700 - KEY 3 3 3 +SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2; +Bug#31700 - PK f1 f2 f3 +Bug#31700 - PK 2 2 2 +SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time; +start_time rows_examined rows_sent sql_text +TIMESTAMP 4 1 SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4 +TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3 +TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2 +DROP TABLE t1; +TRUNCATE TABLE mysql.slow_log; +SET GLOBAL slow_query_log = @old_slow_log_state; +SET SESSION long_query_time =@old_long_query_time; diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 12098b4543b..39bf8029a7c 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -924,3 +924,34 @@ set global general_log = off; select command_type, argument from mysql.general_log; deallocate prepare long_query; set global general_log = @old_general_log_state; + +# +# Bug #31700: thd->examined_row_count not incremented for 'const' type queries +# +SET @old_slow_log_state = @@global.slow_query_log; + +SET SESSION long_query_time = 0; +SET GLOBAL slow_query_log = ON; +FLUSH LOGS; +TRUNCATE TABLE mysql.slow_log; + +# Let there be three columns, unique, non-unique, and non-indexed: +CREATE TABLE t1 (f1 SERIAL,f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2)); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,2,2); +INSERT INTO t1 VALUES (3,3,3); +INSERT INTO t1 VALUES (4,4,4); + +SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4; +SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3; +SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2; + +--replace_column 1 TIMESTAMP +SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time; + +DROP TABLE t1; + +TRUNCATE TABLE mysql.slow_log; + +SET GLOBAL slow_query_log = @old_slow_log_state; +SET SESSION long_query_time =@old_long_query_time; From e2cc172d35253e6ea4d7773bccddd5cca88e9c17 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Sun, 11 Nov 2007 20:38:28 +0100 Subject: [PATCH 107/128] Bug#31210 - INSERT DELAYED crashes server when used on partitioned table Post-pushbuild fix Pushbuild detected a new need for lex initialization in embedded server. Fixed test for INSERT DELAYED in partitions_hash.test so that it works with embedded server. --- libmysqld/lib_sql.cc | 1 + mysql-test/r/partition_hash.result | 1 - mysql-test/t/partition_hash.test | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 4e525f8447f..d929024483c 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -94,6 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, thd->current_stmt= stmt; thd->store_globals(); // Fix if more than one connect + lex_start(thd); /* We have to call free_old_query before we start to fill mysql->fields for new query. In the case of embedded server we collect field data diff --git a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result index 3ebbd020db4..72f036be099 100644 --- a/mysql-test/r/partition_hash.result +++ b/mysql-test/r/partition_hash.result @@ -185,5 +185,4 @@ c1 c2 c3 drop table t1; CREATE TABLE t1 (c1 INT) ENGINE=MyISAM PARTITION BY HASH(c1) PARTITIONS 1; INSERT DELAYED INTO t1 VALUES (1); -ERROR HY000: Table storage engine for 't1' doesn't have this option DROP TABLE t1; diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test index 16c3e2b3b9b..52caaa8c8e9 100644 --- a/mysql-test/t/partition_hash.test +++ b/mysql-test/t/partition_hash.test @@ -148,7 +148,9 @@ drop table t1; # Bug#31210 - INSERT DELAYED crashes server when used on partitioned table # CREATE TABLE t1 (c1 INT) ENGINE=MyISAM PARTITION BY HASH(c1) PARTITIONS 1; ---error ER_ILLEGAL_HA +# The test succeeds in an embedded server because normal insert is done. +# The test fails in a normal server with "engine doesn't have this option". +--error 0, ER_ILLEGAL_HA INSERT DELAYED INTO t1 VALUES (1); DROP TABLE t1; From e7e18ac405a3090b4a9689e9ff48ae866526121a Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Sun, 11 Nov 2007 22:30:01 +0100 Subject: [PATCH 108/128] Bug#30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. Post-pushbuild fix Pushbuild genereted valgrind warnings. Changed function to safer variant. --- sql/sql_partition.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ac098d57c24..ad9eec1906a 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1866,7 +1866,7 @@ static int add_quoted_string(File fptr, const char *quotestr) String escapedstr; int err= add_string(fptr, "'"); err+= append_escaped(&escapedstr, &orgstr); - err+= add_string(fptr, escapedstr.c_ptr()); + err+= add_string(fptr, escapedstr.c_ptr_safe()); return err + add_string(fptr, "'"); } From 91e2f91897af45189a1611a47ac248a331b8db5f Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 12 Nov 2007 13:00:22 +0400 Subject: [PATCH 109/128] Bug #31305 myisam tables crash when they are near capacity. When we insert a record into MYISAM table which is almost 'full', we first write record data in the free space inside a file, and then check if we have enough space after the end of the file. So if we don't have the space, table will left corrupted. Similar error also happens when we updata MYISAM tables. Fixed by modifying write_dynamic_record and update_dynamic_record functions to check for free space before writing parts of a record --- .bzrignore | 2 + myisam/mi_dynrec.c | 68 +++++++++++++++++++++++++++++++++ mysql-test/r/almost_full.result | 29 ++++++++++++++ mysql-test/t/almost_full.test | 41 ++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 mysql-test/r/almost_full.result create mode 100644 mysql-test/t/almost_full.test diff --git a/.bzrignore b/.bzrignore index 0c666cc3ae0..27ad9519e18 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1068,3 +1068,5 @@ include/check_abi include/mysql_h.ic mysql-test/r/blackhole.log mysql-test/lib/init_db.sql +libmysql_r/client_settings.h +libmysqld/ha_blackhole.cc diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 260f461685e..ad76296a66e 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -145,6 +145,29 @@ static int write_dynamic_record(MI_INFO *info, const byte *record, DBUG_ENTER("write_dynamic_record"); flag=0; + + /* + Check if we have enough room for the new record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MI_MAX_DYN_BLOCK_HEADER while it can be + less in the most of the cases. + */ + + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < + reclength + MI_MAX_DYN_BLOCK_HEADER)) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER < + reclength + MI_MAX_DYN_BLOCK_HEADER) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + DBUG_RETURN(1); + } + } + do { if (_mi_find_writepos(info,reclength,&filepos,&length)) @@ -577,6 +600,51 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, DBUG_ENTER("update_dynamic_record"); flag=block_info.second_read=0; + /* + Check if we have enough room for the record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MI_MAX_DYN_BLOCK_HEADER while it can be + less in the most of the cases. + */ + + /* + compare with just the reclength as we're going + to get some space from the old replaced record + */ + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < reclength)) + { + /* + let's read the old record's block to find out the length of the + old record + */ + if ((error=_mi_get_block_info(&block_info,info->dfile,filepos)) + & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | BLOCK_FATAL_ERROR)) + { + DBUG_PRINT("error",("Got wrong block info")); + if (!(error & BLOCK_FATAL_ERROR)) + my_errno=HA_ERR_WRONG_IN_RECORD; + goto err; + } + + /* + if new record isn't longer, we can go on safely + */ + if (block_info.rec_len < reclength) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER < + reclength - block_info.rec_len + MI_MAX_DYN_BLOCK_HEADER) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + goto err; + } + } + block_info.second_read=0; + } + while (reclength > 0) { if (filepos != info->s->state.dellink) diff --git a/mysql-test/r/almost_full.result b/mysql-test/r/almost_full.result new file mode 100644 index 00000000000..eb28f12fa51 --- /dev/null +++ b/mysql-test/r/almost_full.result @@ -0,0 +1,29 @@ +drop table if exists t1; +set global myisam_data_pointer_size=2; +CREATE TABLE t1 (a int auto_increment primary key not null, b longtext) ENGINE=MyISAM; +DELETE FROM t1 WHERE a=1 or a=5; +INSERT INTO t1 SET b=repeat('a',600); +ERROR HY000: The table 't1' is full +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check warning Datafile is almost full, 65448 of 65534 used +test.t1 check status OK +UPDATE t1 SET b=repeat('a', 800) where a=10; +ERROR HY000: The table 't1' is full +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check warning Datafile is almost full, 65448 of 65534 used +test.t1 check status OK +INSERT INTO t1 SET b=repeat('a',400); +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check warning Datafile is almost full, 65448 of 65534 used +test.t1 check status OK +DELETE FROM t1 WHERE a=2 or a=6; +UPDATE t1 SET b=repeat('a', 600) where a=11; +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check warning Datafile is almost full, 65448 of 65534 used +test.t1 check status OK +drop table t1; +set global myisam_data_pointer_size=default; diff --git a/mysql-test/t/almost_full.test b/mysql-test/t/almost_full.test new file mode 100644 index 00000000000..5c67ab3c088 --- /dev/null +++ b/mysql-test/t/almost_full.test @@ -0,0 +1,41 @@ +# +# Some special cases with empty tables +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +set global myisam_data_pointer_size=2; +CREATE TABLE t1 (a int auto_increment primary key not null, b longtext) ENGINE=MyISAM; + +--disable_query_log +let $1= 303; +while ($1) +{ + INSERT INTO t1 SET b=repeat('a',200); + dec $1; +} +--enable_query_log + +DELETE FROM t1 WHERE a=1 or a=5; + +--error 1114 +INSERT INTO t1 SET b=repeat('a',600); +CHECK TABLE t1 EXTENDED; + +--error 1114 +UPDATE t1 SET b=repeat('a', 800) where a=10; +CHECK TABLE t1 EXTENDED; + +INSERT INTO t1 SET b=repeat('a',400); +CHECK TABLE t1 EXTENDED; + +DELETE FROM t1 WHERE a=2 or a=6; +UPDATE t1 SET b=repeat('a', 600) where a=11; +CHECK TABLE t1 EXTENDED; +drop table t1; + +set global myisam_data_pointer_size=default; + +# End of 4.1 tests From 2b3947a6a5db159fe252f980aaf9de917c4d278f Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 12 Nov 2007 14:26:09 +0400 Subject: [PATCH 110/128] 'no innodb engine' test failure fixed --- mysql-test/r/partition.result | 14 -------------- mysql-test/r/partition_innodb.result | 12 ++++++++++++ mysql-test/t/partition.test | 11 ----------- mysql-test/t/partition_innodb.test | 11 +++++++++++ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index e39e84fdd69..4e4bd0bbc0a 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1291,18 +1291,4 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */ drop table t1, t2; -create table t1 (int_column int, char_column char(5)) -PARTITION BY RANGE (int_column) subpartition by key (char_column) -(PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); -Warnings: -Warning 1286 Unknown table engine 'InnoDB' -alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) -(PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `int_column` int(11) DEFAULT NULL, - `char_column` char(5) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) SUBPARTITION BY KEY (char_column) (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ -drop table t1; End of 5.1 tests diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 5b755b6bfd5..e007c8f3e96 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -136,3 +136,15 @@ SELECT COUNT(*) FROM t1; COUNT(*) 2 DROP TABLE t1; +create table t1 (int_column int, char_column char(5)) +PARTITION BY RANGE (int_column) subpartition by key (char_column) +(PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); +alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) +(PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `int_column` int(11) DEFAULT NULL, + `char_column` char(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) SUBPARTITION BY KEY (char_column) (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ +drop table t1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 82a8759e910..2906b4640cd 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1528,15 +1528,4 @@ PARTITION BY RANGE (b) ( show create table t1; drop table t1, t2; -# -# Bug #31893 Partitions: crash if subpartitions and engine change -# -create table t1 (int_column int, char_column char(5)) - PARTITION BY RANGE (int_column) subpartition by key (char_column) - (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); -alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) - (PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); -show create table t1; -drop table t1; - --echo End of 5.1 tests diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 4a50332b3df..0f20b34c7dc 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -142,3 +142,14 @@ PARTITION BY KEY(a) PARTITIONS 10; INSERT INTO t1 VALUES(1),(2); SELECT COUNT(*) FROM t1; DROP TABLE t1; + +# +# Bug #31893 Partitions: crash if subpartitions and engine change +# +create table t1 (int_column int, char_column char(5)) + PARTITION BY RANGE (int_column) subpartition by key (char_column) + (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); +alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) + (PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); +show create table t1; +drop table t1; From e4e8cb3a900257e13faede7453391aa962de1650 Mon Sep 17 00:00:00 2001 From: "mats@kindahl-laptop.dnsalias.net" <> Date: Mon, 12 Nov 2007 11:29:55 +0100 Subject: [PATCH 111/128] BUG#31611 (Security risk with BINLOG statement): Adding missing drop of user created for test case. --- mysql-test/r/mysqlbinlog.result | 1 + mysql-test/t/mysqlbinlog.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 287fbd7e7f3..1deb9401aa1 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -350,4 +350,5 @@ SELECT * FROM t1; a b 1 root@localhost DROP DATABASE mysqltest1; +DROP USER untrusted@localhost; End of 5.1 tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 8635bbfab87..edaf07a64db 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -276,5 +276,6 @@ INSERT INTO t1 VALUES (1,USER()); SELECT * FROM t1; connection default; DROP DATABASE mysqltest1; +DROP USER untrusted@localhost; --echo End of 5.1 tests From 40a78cd3900d72e76edf0e7d9b83b26f1a55811c Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Mon, 12 Nov 2007 15:15:16 +0400 Subject: [PATCH 112/128] After merge fix. --- mysql-test/r/symlink.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index cc54233107a..81798b2dc20 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -94,7 +94,7 @@ CREATE TABLE t1(a INT) DATA DIRECTORY='TEST_DIR/var/master-data/mysql' INDEX DIRECTORY='TEST_DIR/var/master-data/mysql'; RENAME TABLE t1 TO user; -Can't create/write to file 'TEST_DIR/var/master-data/mysql/user.MYI' (Errcode: 17) +ERROR HY000: Can't create/write to file 'TEST_DIR/var/master-data/mysql/user.MYI' (Errcode: 17) DROP TABLE t1; show create table t1; Table Create Table From b05471de734b2695dd545608116716d39eadd91d Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Mon, 12 Nov 2007 13:07:54 +0100 Subject: [PATCH 113/128] Bug#31210 - INSERT DELAYED crashes server when used on partitioned table Post-pushbuild fix Pushbuild detected yet another need for lex initialization in embedded server. --- libmysqld/lib_sql.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index d929024483c..2481956023c 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -587,6 +587,7 @@ void *create_embedded_thd(int client_flag) fprintf(stderr,"store_globals failed.\n"); goto err; } + lex_start(thd); /* TODO - add init_connect command execution */ From 9c05d109aa5d29947315f3e465ef31f0f83c3dc0 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Mon, 12 Nov 2007 13:23:45 +0100 Subject: [PATCH 114/128] Bug#32091: Security breach via directory changes Merge fix partition_mgm did not require have_symlink. Moved the test case to partition_symlink, which require have_symlink, and should work on both *nix and Windows --- mysql-test/r/partition_mgm.result | 82 ------------------ mysql-test/r/partition_symlink.result | 83 ++++++++++++++++++ mysql-test/t/partition_mgm.test | 114 +----------------------- mysql-test/t/partition_symlink.test | 119 ++++++++++++++++++++++++++ 4 files changed, 204 insertions(+), 194 deletions(-) create mode 100644 mysql-test/r/partition_symlink.result create mode 100644 mysql-test/t/partition_symlink.test diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 04358fa0f9f..04ac603fea7 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -1,86 +1,4 @@ DROP TABLE IF EXISTS t1; -DROP DATABASE IF EXISTS mysqltest2; -# Creating two non colliding tables mysqltest2.t1 and test.t1 -# test.t1 have partitions in mysqltest2-directory! -# user root: -CREATE USER mysqltest_1@localhost; -CREATE DATABASE mysqltest2; -USE mysqltest2; -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (0); -# user mysqltest_1: -USE test; -CREATE TABLE t1 (a INT) -PARTITION BY LIST (a) ( -PARTITION p0 VALUES IN (0) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', -PARTITION p1 VALUES IN (1) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', -PARTITION p2 VALUES IN (2) -); -# without the patch for bug#32091 this would create -# files mysqltest2/t1.MYD + .MYI and possible overwrite -# the mysqltest2.t1 table (depending on bug#32111) -ALTER TABLE t1 REMOVE PARTITIONING; -INSERT INTO t1 VALUES (1); -SELECT * FROM t1; -a -1 -# user root: -USE mysqltest2; -FLUSH TABLES; -# if the patch works, this should be different -# and before the patch they were the same! -SELECT * FROM t1; -a -0 -USE test; -SELECT * FROM t1; -a -1 -DROP TABLE t1; -DROP DATABASE mysqltest2; -# test that symlinks can not overwrite files when CREATE TABLE -# user root: -CREATE DATABASE mysqltest2; -USE mysqltest2; -CREATE TABLE t1 (a INT) -PARTITION BY LIST (a) ( -PARTITION p0 VALUES IN (0) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', -PARTITION p1 VALUES IN (1) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - ); -# user mysqltest_1: -USE test; -CREATE TABLE t1 (a INT) -PARTITION BY LIST (a) ( -PARTITION p0 VALUES IN (0) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', -PARTITION p1 VALUES IN (1) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - ); -Got one of the listed errors -CREATE TABLE t1 (a INT) -PARTITION BY LIST (a) ( -PARTITION p0 VALUES IN (0) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', -PARTITION p1 VALUES IN (1) -DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' - ); -Got one of the listed errors -# user root (cleanup): -DROP DATABASE mysqltest2; -USE test; -DROP USER mysqltest_1@localhost; create table t1 (a int) partition by range (a) subpartition by key (a) diff --git a/mysql-test/r/partition_symlink.result b/mysql-test/r/partition_symlink.result new file mode 100644 index 00000000000..20e841d2e0e --- /dev/null +++ b/mysql-test/r/partition_symlink.result @@ -0,0 +1,83 @@ +DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest2; +# Creating two non colliding tables mysqltest2.t1 and test.t1 +# test.t1 have partitions in mysqltest2-directory! +# user root: +CREATE USER mysqltest_1@localhost; +CREATE DATABASE mysqltest2; +USE mysqltest2; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +# user mysqltest_1: +USE test; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', +PARTITION p2 VALUES IN (2) +); +# without the patch for bug#32091 this would create +# files mysqltest2/t1.MYD + .MYI and possible overwrite +# the mysqltest2.t1 table (depending on bug#32111) +ALTER TABLE t1 REMOVE PARTITIONING; +INSERT INTO t1 VALUES (1); +SELECT * FROM t1; +a +1 +# user root: +USE mysqltest2; +FLUSH TABLES; +# if the patch works, this should be different +# and before the patch they were the same! +SELECT * FROM t1; +a +0 +USE test; +SELECT * FROM t1; +a +1 +DROP TABLE t1; +DROP DATABASE mysqltest2; +# test that symlinks can not overwrite files when CREATE TABLE +# user root: +CREATE DATABASE mysqltest2; +USE mysqltest2; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + ); +# user mysqltest_1: +USE test; +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + ); +Got one of the listed errors +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) ( +PARTITION p0 VALUES IN (0) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/test', +PARTITION p1 VALUES IN (1) +DATA DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY 'MYSQLTEST_VARDIR/master-data/mysqltest2' + ); +Got one of the listed errors +# user root (cleanup): +DROP DATABASE mysqltest2; +USE test; +DROP USER mysqltest_1@localhost; diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 1532ea64ab2..a06f8d1aee5 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -1,117 +1,7 @@ -- source include/have_partition.inc --- disable_warnings +--disable_warnings DROP TABLE IF EXISTS t1; -DROP DATABASE IF EXISTS mysqltest2; --- enable_warnings - -# -# Bug 32091: Security breach via directory changes -# -# The below test shows that a pre-existing table mysqltest2.t1 cannot be -# replaced by a user with no rights in 'mysqltest2'. The altered table -# test.t1 will be altered (remove partitioning) into the test directory -# and having its partitions removed from the mysqltest2 directory. -# (the partitions data files are named #P#.MYD -# and will not collide with a non partitioned table's data files.) -# NOTE: the privileges on files and directories are the same for all -# database users in mysqld, though mysqld enforces privileges on -# the database and table levels which in turn maps to directories and -# files, but not the other way around (any db-user can use any -# directory or file that the mysqld-process can use, via DATA/INDEX DIR) -# this is the security flaw that was used in bug#32091 and bug#32111 --- echo # Creating two non colliding tables mysqltest2.t1 and test.t1 --- echo # test.t1 have partitions in mysqltest2-directory! --- echo # user root: - CREATE USER mysqltest_1@localhost; - CREATE DATABASE mysqltest2; - USE mysqltest2; - CREATE TABLE t1 (a INT); - INSERT INTO t1 VALUES (0); -connect(con1,localhost,mysqltest_1,,); --- echo # user mysqltest_1: - USE test; - -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - eval CREATE TABLE t1 (a INT) - PARTITION BY LIST (a) ( - PARTITION p0 VALUES IN (0) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', - PARTITION p1 VALUES IN (1) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', - PARTITION p2 VALUES IN (2) - ); - -- echo # without the patch for bug#32091 this would create - -- echo # files mysqltest2/t1.MYD + .MYI and possible overwrite - -- echo # the mysqltest2.t1 table (depending on bug#32111) - -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - ALTER TABLE t1 REMOVE PARTITIONING; - INSERT INTO t1 VALUES (1); - SELECT * FROM t1; -connection default; --- echo # user root: - USE mysqltest2; - FLUSH TABLES; - -- echo # if the patch works, this should be different - -- echo # and before the patch they were the same! - SELECT * FROM t1; - USE test; - SELECT * FROM t1; - DROP TABLE t1; - DROP DATABASE mysqltest2; -# The below test shows that a pre-existing partition can not be -# destroyed by a new partition from another table. -# (Remember that a table or partition that uses the DATA/INDEX DIR -# is symlinked and thus has -# 1. the real file in the DATA/INDEX DIR and -# 2. a symlink in its default database directory pointing to -# the real file. -# So it is using/blocking 2 files in (in 2 different directories --- echo # test that symlinks can not overwrite files when CREATE TABLE --- echo # user root: - CREATE DATABASE mysqltest2; - USE mysqltest2; - -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - eval CREATE TABLE t1 (a INT) - PARTITION BY LIST (a) ( - PARTITION p0 VALUES IN (0) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', - PARTITION p1 VALUES IN (1) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - ); -connection con1; --- echo # user mysqltest_1: - USE test; - -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - -- error 1,1 - eval CREATE TABLE t1 (a INT) - PARTITION BY LIST (a) ( - PARTITION p0 VALUES IN (0) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', - PARTITION p1 VALUES IN (1) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - ); - -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR - -- error 1,1 - eval CREATE TABLE t1 (a INT) - PARTITION BY LIST (a) ( - PARTITION p0 VALUES IN (0) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', - PARTITION p1 VALUES IN (1) - DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' - INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' - ); -connection default; --- echo # user root (cleanup): - DROP DATABASE mysqltest2; - USE test; - DROP USER mysqltest_1@localhost; - disconnect con1; +--enable_warnings # # Bug 21143: mysqld hang when error in number of subparts in diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test new file mode 100644 index 00000000000..6f823c4a30a --- /dev/null +++ b/mysql-test/t/partition_symlink.test @@ -0,0 +1,119 @@ +# Test that must have symlink. eg. using DATA/INDEX DIR +# (DATA/INDEX DIR requires symlinks) +-- source include/have_partition.inc +-- source include/have_symlink.inc +-- disable_warnings +DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest2; +-- enable_warnings + +# +# Bug 32091: Security breach via directory changes +# +# The below test shows that a pre-existing table mysqltest2.t1 cannot be +# replaced by a user with no rights in 'mysqltest2'. The altered table +# test.t1 will be altered (remove partitioning) into the test directory +# and having its partitions removed from the mysqltest2 directory. +# (the partitions data files are named #P#.MYD +# and will not collide with a non partitioned table's data files.) +# NOTE: the privileges on files and directories are the same for all +# database users in mysqld, though mysqld enforces privileges on +# the database and table levels which in turn maps to directories and +# files, but not the other way around (any db-user can use any +# directory or file that the mysqld-process can use, via DATA/INDEX DIR) +# this is the security flaw that was used in bug#32091 and bug#32111 +-- echo # Creating two non colliding tables mysqltest2.t1 and test.t1 +-- echo # test.t1 have partitions in mysqltest2-directory! +-- echo # user root: + CREATE USER mysqltest_1@localhost; + CREATE DATABASE mysqltest2; + USE mysqltest2; + CREATE TABLE t1 (a INT); + INSERT INTO t1 VALUES (0); +connect(con1,localhost,mysqltest_1,,); +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', + PARTITION p2 VALUES IN (2) + ); + -- echo # without the patch for bug#32091 this would create + -- echo # files mysqltest2/t1.MYD + .MYI and possible overwrite + -- echo # the mysqltest2.t1 table (depending on bug#32111) + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + ALTER TABLE t1 REMOVE PARTITIONING; + INSERT INTO t1 VALUES (1); + SELECT * FROM t1; +connection default; +-- echo # user root: + USE mysqltest2; + FLUSH TABLES; + -- echo # if the patch works, this should be different + -- echo # and before the patch they were the same! + SELECT * FROM t1; + USE test; + SELECT * FROM t1; + DROP TABLE t1; + DROP DATABASE mysqltest2; +# The below test shows that a pre-existing partition can not be +# destroyed by a new partition from another table. +# (Remember that a table or partition that uses the DATA/INDEX DIR +# is symlinked and thus has +# 1. the real file in the DATA/INDEX DIR and +# 2. a symlink in its default database directory pointing to +# the real file. +# So it is using/blocking 2 files in (in 2 different directories +-- echo # test that symlinks can not overwrite files when CREATE TABLE +-- echo # user root: + CREATE DATABASE mysqltest2; + USE mysqltest2; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + ); +connection con1; +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1,1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + ); + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1,1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/test' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/test', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/master-data/mysqltest2' + ); +connection default; +-- echo # user root (cleanup): + DROP DATABASE mysqltest2; + USE test; + DROP USER mysqltest_1@localhost; + disconnect con1; + + From 43578c9097b4bf76495c0765ab9f9a5e84a2f89e Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Mon, 12 Nov 2007 14:51:14 +0100 Subject: [PATCH 115/128] Bug#31705 Partitions: crash if varchar length > 65530 Buffer overflow due to wrong key length in partitioning Changed to the correct key_length function. --- mysql-test/r/partition_datatype.result | 282 +++++++++++++++++++++++++ mysql-test/t/partition_datatype.test | 213 +++++++++++++++++++ sql/opt_range.cc | 10 +- 3 files changed, 499 insertions(+), 6 deletions(-) create mode 100644 mysql-test/r/partition_datatype.result create mode 100644 mysql-test/t/partition_datatype.test diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result new file mode 100644 index 00000000000..c6506178b03 --- /dev/null +++ b/mysql-test/r/partition_datatype.result @@ -0,0 +1,282 @@ +drop table if exists t1; +create table t1 (a tinyint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a smallint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a mediumint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a int not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a bigint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a float not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +a +drop table t1; +create table t1 (a double not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +a +2.1 +drop table t1; +create table t1 (a decimal not null) partition by key (a); +insert into t1 values (2.1); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +select * from t1 where a = 2.1; +a +drop table t1; +create table t1 (a date not null) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +a +2001-01-01 +drop table t1; +create table t1 (a datetime not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +a +2001-01-01 01:02:03 +drop table t1; +create table t1 (a timestamp not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +a +2001-01-01 01:02:03 +drop table t1; +create table t1 (a time not null) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +a +01:02:03 +drop table t1; +create table t1 (a year not null) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +a +2001 +drop table t1; +create table t1 (a varchar(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(300) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(300) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a char(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a char(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a enum('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +a +y +drop table t1; +create table t1 (a set('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +a +y +drop table t1; +create table t1 (a tinyint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a smallint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a mediumint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a int) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a bigint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +a +2 +drop table t1; +create table t1 (a float) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +a +drop table t1; +create table t1 (a double) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +a +2.1 +drop table t1; +create table t1 (a decimal) partition by key (a); +insert into t1 values (2.1); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +select * from t1 where a = 2.1; +a +drop table t1; +create table t1 (a date) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +a +2001-01-01 +drop table t1; +create table t1 (a datetime) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +a +2001-01-01 01:02:03 +drop table t1; +create table t1 (a timestamp null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +a +2001-01-01 01:02:03 +drop table t1; +create table t1 (a time) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +a +01:02:03 +drop table t1; +create table t1 (a year) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +a +2001 +drop table t1; +create table t1 (a varchar(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(300) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a varchar(300) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a char(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a char(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +a +abc +drop table t1; +create table t1 (a enum('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +a +y +drop table t1; +create table t1 (a set('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +a +y +drop table t1; +create table t1 (a varchar(65531)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +a +select * from t1 where a like 'aaa%'; +a +aaaa +drop table t1; +create table t1 (a varchar(65532)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +a +select * from t1 where a like 'aaa%'; +a +aaaa +drop table t1; +create table t1 (a varchar(65533) not null) partition by key (a); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +a +drop table t1; +create table t1 (a varchar(65533)) partition by key (a); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs +create table t1 (a varchar(65534) not null) partition by key (a); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs +create table t1 (a varchar(65535)) partition by key (a); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test new file mode 100644 index 00000000000..61d3cb42c7b --- /dev/null +++ b/mysql-test/t/partition_datatype.test @@ -0,0 +1,213 @@ +# +# Simple test for the partition storage engine +# with most datatypes and null / not null +# as partition by key +# Created to verify the fix for Bug#31705 +# Partitions: crash if varchar length > 65530 +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# FIXME: disabled this test because of valgrind error +#create table t1 (a bit not null) partition by key (a); +#insert into t1 values (b'1'); +#select * from t1 where a = b'1'; +#drop table t1; +create table t1 (a tinyint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a smallint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a mediumint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a int not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a bigint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a float not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a double not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a decimal not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a date not null) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +drop table t1; +create table t1 (a datetime not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a timestamp not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a time not null) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +drop table t1; +create table t1 (a year not null) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +drop table t1; +create table t1 (a varchar(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a enum('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a set('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +# FIXME: disabled this test because of valgrind error +#create table t1 (a bit) partition by key (a); +#insert into t1 values (b'1'); +#select * from t1 where a = b'1'; +#drop table t1; +create table t1 (a tinyint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a smallint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a mediumint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a int) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a bigint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a float) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a double) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a decimal) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a date) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +drop table t1; +create table t1 (a datetime) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a timestamp null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a time) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +drop table t1; +create table t1 (a year) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +drop table t1; +create table t1 (a varchar(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a enum('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a set('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a varchar(65531)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +select * from t1 where a like 'aaa%'; +drop table t1; +create table t1 (a varchar(65532)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +select * from t1 where a like 'aaa%'; +drop table t1; +create table t1 (a varchar(65533) not null) partition by key (a); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaa%'; +drop table t1; +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65533)) partition by key (a); +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65534) not null) partition by key (a); +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65535)) partition by key (a); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 99c28be36b0..b89e8b3dcbb 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3344,18 +3344,16 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar) { key_part->key= 0; key_part->part= part; - key_part->length= (uint16) (*field)->pack_length_in_rec(); - /* - psergey-todo: check yet again if this is correct for tricky field types, - e.g. see "Fix a fatal error in decimal key handling" in open_binary_frm() - */ - key_part->store_length= (uint16) (*field)->pack_length(); + key_part->store_length= key_part->length= (uint16) (*field)->key_length(); if ((*field)->real_maybe_null()) key_part->store_length+= HA_KEY_NULL_LENGTH; if ((*field)->type() == MYSQL_TYPE_BLOB || (*field)->real_type() == MYSQL_TYPE_VARCHAR) key_part->store_length+= HA_KEY_BLOB_LENGTH; + DBUG_PRINT("info", ("part %u length %u store_length %u", part, + key_part->length, key_part->store_length)); + key_part->field= (*field); key_part->image_type = Field::itRAW; /* From 8085bed591b56ed4c0aaad81dec2bf43e622de56 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 12 Nov 2007 21:11:31 +0400 Subject: [PATCH 116/128] Bug #32067 Partitions: crash with timestamp column. Partition handler fails updating tables with partitioning based on timestamp field, as it calculates the timestamp field AFTER it calculates the number of partition of a record. Fixed by adding timestamp_field->set_time() call and disabling such consequent calls --- mysql-test/r/partition.result | 5 +++++ mysql-test/t/partition.test | 21 +++++++++++++++++++++ sql/ha_partition.cc | 28 ++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 4e4bd0bbc0a..b3a498ff0ab 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1291,4 +1291,9 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */ drop table t1, t2; +create table t1 +(s1 timestamp on update current_timestamp, s2 int) +partition by key(s1) partitions 3; +insert into t1 values (null,null); +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 2906b4640cd..524862af135 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1528,4 +1528,25 @@ PARTITION BY RANGE (b) ( show create table t1; drop table t1, t2; +# +# Bug #32067 Partitions: crash with timestamp column +# this bug occurs randomly on some UPDATE statement +# with the '1032: Can't find record in 't1'' error + +create table t1 + (s1 timestamp on update current_timestamp, s2 int) + partition by key(s1) partitions 3; + +insert into t1 values (null,null); +--disable_query_log +let $cnt= 1000; +while ($cnt) +{ + update t1 set s2 = 1; + update t1 set s2 = 2; + dec $cnt; +} +--enable_query_log + +drop table t1; --echo End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 8afaab71160..a7638f5a357 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2783,16 +2783,28 @@ exit: int ha_partition::update_row(const uchar *old_data, uchar *new_data) { uint32 new_part_id, old_part_id; - int error; + int error= 0; longlong func_value; + timestamp_auto_set_type orig_timestamp_type= table->timestamp_field_type; DBUG_ENTER("ha_partition::update_row"); + /* + We need to set timestamp field once before we calculate + the partition. Then we disable timestamp calculations + inside m_file[*]->update_row() methods + */ + if (orig_timestamp_type & TIMESTAMP_AUTO_SET_ON_UPDATE) + { + table->timestamp_field->set_time(); + table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; + } + if ((error= get_parts_for_update(old_data, new_data, table->record[0], m_part_info, &old_part_id, &new_part_id, &func_value))) { m_part_info->err_value= func_value; - DBUG_RETURN(error); + goto exit; } /* @@ -2804,23 +2816,27 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) if (new_part_id == old_part_id) { DBUG_PRINT("info", ("Update in partition %d", new_part_id)); - DBUG_RETURN(m_file[new_part_id]->update_row(old_data, new_data)); + error= m_file[new_part_id]->update_row(old_data, new_data); + goto exit; } else { DBUG_PRINT("info", ("Update from partition %d to partition %d", old_part_id, new_part_id)); if ((error= m_file[new_part_id]->write_row(new_data))) - DBUG_RETURN(error); + goto exit; if ((error= m_file[old_part_id]->delete_row(old_data))) { #ifdef IN_THE_FUTURE (void) m_file[new_part_id]->delete_last_inserted_row(new_data); #endif - DBUG_RETURN(error); + goto exit; } } - DBUG_RETURN(0); + +exit: + table->timestamp_field_type= orig_timestamp_type; + DBUG_RETURN(error); } From ed8f506d29dfdd6547db798dbc468e2ab205d045 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Mon, 12 Nov 2007 21:52:30 +0400 Subject: [PATCH 117/128] symlink.test, symlink.result: Use proper variable for test. --- mysql-test/r/symlink.result | 6 +++--- mysql-test/t/symlink.test | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 81798b2dc20..32dc72b8219 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -91,10 +91,10 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE t1(a INT) -DATA DIRECTORY='TEST_DIR/var/master-data/mysql' -INDEX DIRECTORY='TEST_DIR/var/master-data/mysql'; +DATA DIRECTORY='TEST_DIR/master-data/mysql' +INDEX DIRECTORY='TEST_DIR/master-data/mysql'; RENAME TABLE t1 TO user; -ERROR HY000: Can't create/write to file 'TEST_DIR/var/master-data/mysql/user.MYI' (Errcode: 17) +ERROR HY000: Can't create/write to file 'TEST_DIR/master-data/mysql/user.MYI' (Errcode: 17) DROP TABLE t1; show create table t1; Table Create Table diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index fb35bd3c130..40127a697ac 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -121,11 +121,11 @@ drop table t1; # # BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE # ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR TEST_DIR eval CREATE TABLE t1(a INT) -DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/mysql' -INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data/mysql'; ---replace_result $MYSQL_TEST_DIR TEST_DIR +DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql' +INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql'; +--replace_result $MYSQLTEST_VARDIR TEST_DIR --error 1 RENAME TABLE t1 TO user; DROP TABLE t1; From bc08ff042174ca69c7a5a44a062d42b451781e51 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Tue, 13 Nov 2007 09:41:59 +0400 Subject: [PATCH 118/128] test fixed --- mysql-test/r/partition_innodb.result | 7 ++++--- mysql-test/t/partition_innodb.test | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index e007c8f3e96..f80e0001ea8 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -137,14 +137,15 @@ COUNT(*) 2 DROP TABLE t1; create table t1 (int_column int, char_column char(5)) -PARTITION BY RANGE (int_column) subpartition by key (char_column) +PARTITION BY RANGE (int_column) subpartition by key (char_column) subpartitions 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); -alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) +alter table t1 PARTITION BY RANGE (int_column) +subpartition by key (char_column) subpartitions 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `int_column` int(11) DEFAULT NULL, `char_column` char(5) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) SUBPARTITION BY KEY (char_column) (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (int_column) SUBPARTITION BY KEY (char_column) SUBPARTITIONS 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */ drop table t1; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 0f20b34c7dc..6b73d0b2c5e 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -147,9 +147,10 @@ DROP TABLE t1; # Bug #31893 Partitions: crash if subpartitions and engine change # create table t1 (int_column int, char_column char(5)) - PARTITION BY RANGE (int_column) subpartition by key (char_column) + PARTITION BY RANGE (int_column) subpartition by key (char_column) subpartitions 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); -alter table t1 PARTITION BY RANGE (int_column) subpartition by key (char_column) +alter table t1 PARTITION BY RANGE (int_column) + subpartition by key (char_column) subpartitions 2 (PARTITION p1 VALUES LESS THAN (5) ENGINE = myisam); show create table t1; drop table t1; From edce8a63e222c2ee65b9f3a64641ca0044957fc3 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 13 Nov 2007 10:25:22 +0100 Subject: [PATCH 119/128] Bug#32078 - Excessive warnings: One can only use the --user switch if running as root Every start of a server in the test suite raised that warning. The cause was an unconditionla add of the --user option to the server command line. Only the "root" user (effective user id == 0) must use that option. Added check for effective user id == 0 before adding --user. Thanks to Magnus Svensson for the patch. --- mysql-test/mysql-test-run.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c3312dce3ac..f6ea5550007 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3754,7 +3754,9 @@ sub mysqld_arguments ($$$$) { # When mysqld is run by a root user(euid is 0), it will fail # to start unless we specify what user to run as. If not running # as root it will be ignored, see BUG#30630 - if (!(grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt))) { + my $euid= $>; + if (!$glob_win32 and $euid == 0 and + grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) { mtr_add_arg($args, "%s--user=root"); } From 3384d3e96c459cc2789c912261541f2b4eb13818 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 13 Nov 2007 11:39:52 +0200 Subject: [PATCH 120/128] Bug #31562: HAVING and lower case The columns in HAVING can reference the GROUP BY and SELECT columns. There can be "table" prefixes when referencing these columns. And these "table" prefixes in HAVING use the table alias if available. This means that table aliases are subject to the same storage rules as table names and are dependent on lower_case_table_names in the same way as the table names are. Fixed by : 1. Treating table aliases as table names and make them lowercase when printing out the SQL statement for view persistence. 2. Using case insensitive comparison for table aliases when requested by lower_case_table_names --- mysql-test/r/lowercase_view.result | 21 +++++++++++++++++++-- mysql-test/t/lowercase_view.test | 23 +++++++++++++++++++++++ sql/item.cc | 2 +- sql/sql_base.cc | 3 ++- sql/sql_select.cc | 15 ++++++++++++++- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result index f09725dafcb..a89b79263c5 100644 --- a/mysql-test/r/lowercase_view.result +++ b/mysql-test/r/lowercase_view.result @@ -119,7 +119,7 @@ create table t1Aa (col1 int); create view v1Aa as select col1 from t1Aa as AaA; show create view v1AA; View Create View -v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA` +v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa` drop view v1AA; select Aaa.col1 from t1Aa as AaA; col1 @@ -128,6 +128,23 @@ drop view v1AA; create view v1Aa as select AaA.col1 from t1Aa as AaA; show create view v1AA; View Create View -v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA` +v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `aaa` drop view v1AA; drop table t1Aa; +CREATE TABLE t1 (a int, b int); +select X.a from t1 AS X group by X.b having (X.a = 1); +a +select X.a from t1 AS X group by X.b having (x.a = 1); +a +select X.a from t1 AS X group by X.b having (x.b = 1); +a +CREATE OR REPLACE VIEW v1 AS +select X.a from t1 AS X group by X.b having (X.a = 1); +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `x`.`a` AS `a` from `t1` `x` group by `x`.`b` having (`x`.`a` = 1) +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +End of 5.0 tests. diff --git a/mysql-test/t/lowercase_view.test b/mysql-test/t/lowercase_view.test index e9cc26bec18..d6612b3e6b9 100644 --- a/mysql-test/t/lowercase_view.test +++ b/mysql-test/t/lowercase_view.test @@ -138,3 +138,26 @@ create view v1Aa as select AaA.col1 from t1Aa as AaA; show create view v1AA; drop view v1AA; drop table t1Aa; + + +# +# Bug #31562: HAVING and lower case +# + +CREATE TABLE t1 (a int, b int); + +select X.a from t1 AS X group by X.b having (X.a = 1); +select X.a from t1 AS X group by X.b having (x.a = 1); +select X.a from t1 AS X group by X.b having (x.b = 1); + +CREATE OR REPLACE VIEW v1 AS +select X.a from t1 AS X group by X.b having (X.a = 1); + +SHOW CREATE VIEW v1; + +SELECT * FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + +--echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index dc3b1fc6b79..538f23980d6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3307,7 +3307,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) if (cur_field->table_name && table_name) { /* If field_name is qualified by a table name. */ - if (strcmp(cur_field->table_name, table_name)) + if (my_strcasecmp(table_alias_charset, cur_field->table_name, table_name)) /* Same field names, different tables. */ return NULL; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b206e4a6e03..fd921be1ecf 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4164,7 +4164,8 @@ find_item_in_list(Item *find, List &items, uint *counter, if (item_field->field_name && item_field->table_name && !my_strcasecmp(system_charset_info, item_field->field_name, field_name) && - !strcmp(item_field->table_name, table_name) && + !my_strcasecmp(table_alias_charset, item_field->table_name, + table_name) && (!db_name || (item_field->db_name && !strcmp(item_field->db_name, db_name)))) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e7d778de991..1fe84c13a49 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15612,8 +15612,21 @@ void TABLE_LIST::print(THD *thd, String *str) } if (my_strcasecmp(table_alias_charset, cmp_name, alias)) { + char t_alias_buff[MAX_ALIAS_NAME]; + const char *t_alias= alias; + str->append(' '); - append_identifier(thd, str, alias, strlen(alias)); + if (lower_case_table_names== 1) + { + if (alias && alias[0]) + { + strmov(t_alias_buff, alias); + my_casedn_str(files_charset_info, t_alias_buff); + t_alias= t_alias_buff; + } + } + + append_identifier(thd, str, t_alias, strlen(t_alias)); } if (use_index) From 6223deb694946e5a2c3e46eaf4f2ce5624b5e78a Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 13 Nov 2007 11:12:53 +0100 Subject: [PATCH 121/128] Bug#32091: Security breach via directory changes Post pushbuild fix Disabled test on windows due to bug#30459 (DATA/INDEX DIR for partitions not working on windows) Patch from Mattias Jonsson. --- mysql-test/r/partition_mgm.result | 10 ---------- mysql-test/t/partition_mgm.test | 19 ++++++++++--------- mysql-test/t/partition_symlink.test | 2 ++ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 04ac603fea7..9ef220028b3 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -17,12 +17,6 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (YEAR(f_date)) PARTITIONS 2 */ -hello/master-data/test/t1#P#p0.MYD -hello/master-data/test/t1#P#p0.MYI -hello/master-data/test/t1#P#p1.MYD -hello/master-data/test/t1#P#p1.MYI -hello/master-data/test/t1.frm -hello/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; Table Create Table @@ -30,10 +24,6 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (YEAR(f_date)) PARTITIONS 1 */ -hello/master-data/test/t1#P#p0.MYD -hello/master-data/test/t1#P#p0.MYI -hello/master-data/test/t1.frm -hello/master-data/test/t1.par drop table t1; create table t1 (a int) partition by list (a) diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index a06f8d1aee5..68da4a5b390 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -22,17 +22,18 @@ drop table t1; CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) PARTITION BY HASH(YEAR(f_date)) PARTITIONS 2; SHOW CREATE TABLE t1; - ---replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* ---replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p0.MYD +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p0.MYI +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p1.MYD +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p1.MYI +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1.frm +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; ---replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* ---replace_result $MYSQLTEST_VARDIR "hello" ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p0.MYD +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1#P#p0.MYI +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1.frm +-- file_exists $MYSQLTEST_VARDIR/master-data/test/t1.par drop table t1; # # Bug 20767: REORGANIZE partition crashes diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test index 6f823c4a30a..ab779ec2b68 100644 --- a/mysql-test/t/partition_symlink.test +++ b/mysql-test/t/partition_symlink.test @@ -2,6 +2,8 @@ # (DATA/INDEX DIR requires symlinks) -- source include/have_partition.inc -- source include/have_symlink.inc +# remove the not_windows line after fixing bug#30459 +-- source include/not_windows.inc -- disable_warnings DROP TABLE IF EXISTS t1; DROP DATABASE IF EXISTS mysqltest2; From 4fa7ee92e6ed958d55b52abdd541842746b3a369 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 13 Nov 2007 13:24:48 +0000 Subject: [PATCH 122/128] Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. The fact that a timestamp field will be set to NO on UPDATE wasn't shown by the SHOW COMMAND and reported to a client through connectors. This led to problems in the ODBC connector and might lead to a user confusion. A new filed flag called ON_UPDATE_NOW_FLAG is added. Constructors of the Field_timestamp set it when a field should be set to NOW on UPDATE. The get_schema_column_record function now reports whether a timestamp field will be set to NOW on UPDATE. --- client/mysql.cc | 1 + include/mysql_com.h | 1 + mysql-test/r/grant.result | 2 +- mysql-test/r/information_schema.result | 6 ++++-- mysql-test/r/log_tables.result | 4 ++-- mysql-test/r/metadata.result | 2 +- mysql-test/r/ps_2myisam.result | 2 +- mysql-test/r/ps_3innodb.result | 2 +- mysql-test/r/ps_4heap.result | 2 +- mysql-test/r/ps_5merge.result | 4 ++-- mysql-test/r/show_check.result | 4 ++-- mysql-test/r/type_ranges.result | 4 ++-- mysql-test/r/type_timestamp.result | 8 ++++---- mysql-test/t/information_schema.test | 3 ++- sql/field.cc | 4 ++++ sql/sql_show.cc | 9 ++++++--- tests/mysql_client_test.c | 2 +- 17 files changed, 36 insertions(+), 24 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 1dd33593b83..9bc9e90965a 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2366,6 +2366,7 @@ static char *fieldflags2str(uint f) { ff2s_check_flag(GROUP); ff2s_check_flag(UNIQUE); ff2s_check_flag(BINCMP); + ff2s_check_flag(ON_UPDATE_NOW); #undef ff2s_check_flag if (f) sprintf(s, " unknows=0x%04x", f); diff --git a/include/mysql_com.h b/include/mysql_com.h index f76486b9ec2..4ae7f66060f 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -94,6 +94,7 @@ enum enum_server_command #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ #define SET_FLAG 2048 /* field is a set */ #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ +#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */ #define NUM_FLAG 32768 /* Field is num (for clients) */ #define PART_KEY_FLAG 16384 /* Intern; Part of some key */ #define GROUP_FLAG 32768 /* Intern: Group field */ diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 4e25ada43a0..4d402d7d0e9 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -529,7 +529,7 @@ Db char(64) NO PRI User char(16) NO PRI Table_name char(64) NO PRI Grantor char(77) NO MUL -Timestamp timestamp NO CURRENT_TIMESTAMP +Timestamp timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') NO Column_priv set('Select','Insert','Update','References') NO use test; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 7693fe628ef..21ef478326d 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1141,11 +1141,13 @@ DROP FUNCTION func2; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and -(column_type = 'varchar(7)' or column_type = 'varchar(20)') +(column_type = 'varchar(7)' or column_type = 'varchar(20)' + or column_type = 'varchar(27)') group by column_type order by num; column_type group_concat(table_schema, '.', table_name) num +varchar(27) information_schema.COLUMNS 1 varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2 -varchar(20) information_schema.COLUMNS,information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 6 +varchar(20) information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 5 create table t1(f1 char(1) not null, f2 char(9) not null) default character set utf8; select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 261e3292f4d..f2b992667c7 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -50,7 +50,7 @@ general_log CREATE TABLE `general_log` ( ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log' show fields from mysql.general_log; Field Type Null Key Default Extra -event_time timestamp NO CURRENT_TIMESTAMP +event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP user_host mediumtext NO NULL thread_id int(11) NO NULL server_id int(11) NO NULL @@ -73,7 +73,7 @@ slow_log CREATE TABLE `slow_log` ( ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' show fields from mysql.slow_log; Field Type Null Key Default Extra -start_time timestamp NO CURRENT_TIMESTAMP +start_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP user_host mediumtext NO NULL query_time time NO NULL lock_time time NO NULL diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 4a776b6a253..76c6ae7d034 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -21,7 +21,7 @@ def test t1 t1 g g 5 4 0 Y 32768 3 63 def test t1 t1 h h 246 7 0 Y 0 4 63 def test t1 t1 i i 13 4 0 Y 32864 0 63 def test t1 t1 j j 10 10 0 Y 128 0 63 -def test t1 t1 k k 7 19 0 N 1249 0 63 +def test t1 t1 k k 7 19 0 N 9441 0 63 def test t1 t1 l l 12 19 0 Y 128 0 63 def test t1 t1 m m 254 1 0 Y 256 0 8 def test t1 t1 n n 254 3 0 Y 2048 0 8 diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 6f0bad71f23..eb8ef7a85c3 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -63,7 +63,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 85a109b0630..15650efa41d 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -63,7 +63,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 980b89ad504..486f770220e 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -64,7 +64,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index e95f8766a24..0229b0ece08 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -106,7 +106,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 @@ -3128,7 +3128,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 04a5253e6a8..ff32d2a1512 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -979,7 +979,7 @@ def COLUMNS CHARACTER_SET_NAME CHARACTER_SET_NAME 253 192 0 Y 0 0 33 def COLUMNS COLLATION_NAME COLLATION_NAME 253 192 0 Y 0 0 33 def COLUMNS COLUMN_TYPE COLUMN_TYPE 252 589815 7 N 17 0 33 def COLUMNS COLUMN_KEY COLUMN_KEY 253 9 3 N 1 0 33 -def COLUMNS EXTRA EXTRA 253 60 0 N 1 0 33 +def COLUMNS EXTRA EXTRA 253 81 0 N 1 0 33 def COLUMNS PRIVILEGES PRIVILEGES 253 240 31 N 1 0 33 def COLUMNS COLUMN_COMMENT COLUMN_COMMENT 253 765 0 N 1 0 33 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT @@ -998,7 +998,7 @@ def COLUMNS COLUMN_TYPE Type 252 589815 7 N 17 0 33 def COLUMNS IS_NULLABLE Null 253 9 2 N 1 0 33 def COLUMNS COLUMN_KEY Key 253 9 3 N 1 0 33 def COLUMNS COLUMN_DEFAULT Default 252 589815 0 Y 16 0 33 -def COLUMNS EXTRA Extra 253 60 0 N 1 0 33 +def COLUMNS EXTRA Extra 253 81 0 N 1 0 33 Field Type Null Key Default Extra c int(11) NO PRI NULL ---------------------------------------------------------------- diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 149f0d2dca5..6e08067d8a4 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -57,7 +57,7 @@ ushort smallint(5) unsigned zerofill NULL NO MUL 00000 # umedium mediumint(8) unsigned NULL NO MUL 0 # ulong int(11) unsigned NULL NO MUL 0 # ulonglong bigint(13) unsigned NULL NO MUL 0 # -time_stamp timestamp NULL NO CURRENT_TIMESTAMP # +time_stamp timestamp NULL NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP # date_field date NULL YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # @@ -225,7 +225,7 @@ ushort smallint(5) unsigned zerofill NULL NO 00000 # umedium mediumint(8) unsigned NULL NO MUL 0 # ulong int(11) unsigned NULL NO MUL 0 # ulonglong bigint(13) unsigned NULL NO MUL 0 # -time_stamp timestamp NULL NO CURRENT_TIMESTAMP # +time_stamp timestamp NULL NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP # date_field char(10) latin1_swedish_ci YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 7caf7e78fe9..596dcbf432c 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -251,7 +251,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO 2003-01-01 00:00:00 +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp default now() on update now(), t2 datetime); @@ -276,7 +276,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp, t2 datetime, t3 timestamp); @@ -302,7 +302,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL t3 timestamp NO 0000-00-00 00:00:00 drop table t1; @@ -328,7 +328,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL truncate table t1; insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 1987d9d5773..e246c1fe9e0 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -807,7 +807,8 @@ DROP FUNCTION func2; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and -(column_type = 'varchar(7)' or column_type = 'varchar(20)') +(column_type = 'varchar(7)' or column_type = 'varchar(20)' + or column_type = 'varchar(27)') group by column_type order by num; # diff --git a/sql/field.cc b/sql/field.cc index e04162d5e14..36ba6e6f12c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4616,6 +4616,8 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, /* This timestamp has auto-update */ share->timestamp_field= this; flags|= TIMESTAMP_FLAG; + if (unireg_check != TIMESTAMP_DN_FIELD) + flags|= ON_UPDATE_NOW_FLAG; } } @@ -4629,6 +4631,8 @@ Field_timestamp::Field_timestamp(bool maybe_null_arg, { /* For 4.0 MYD and 4.0 InnoDB compatibility */ flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; + if (unireg_check != TIMESTAMP_DN_FIELD) + flags|= ON_UPDATE_NOW_FLAG; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 049c050c288..a199b808589 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3777,8 +3777,11 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) - end=strmov(tmp,"auto_increment"); - table->field[16]->store(tmp, (uint) (end-tmp), cs); + table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); + if (show_table->timestamp_field == field && + field->unireg_check != Field::TIMESTAMP_DN_FIELD) + table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"), + cs); table->field[18]->store(field->comment.str, field->comment.length, cs); if (schema_table_store_record(thd, table)) @@ -5981,7 +5984,7 @@ ST_FIELD_INFO columns_fields_info[]= {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY}, {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY}, - {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, + {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY}, {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index d3ba0660198..bce9bf3feff 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -7787,7 +7787,7 @@ static void test_explain_bug() verify_prepare_field(result, 5, "Extra", "EXTRA", mysql_get_server_version(mysql) <= 50000 ? MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING, - 0, 0, "", 20, 0); + 0, 0, "", 27, 0); mysql_free_result(result); mysql_stmt_close(stmt); From 7f571c68cf5006d8f7dd6ae36dc5cf8b1a447f2d Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 13 Nov 2007 19:32:12 +0200 Subject: [PATCH 123/128] merge bug 31562 to 5.1 : changed SHOW CREATE VIEW format --- mysql-test/r/lowercase_view.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result index 3bd03c25fac..c37dc41c495 100644 --- a/mysql-test/r/lowercase_view.result +++ b/mysql-test/r/lowercase_view.result @@ -141,8 +141,8 @@ a CREATE OR REPLACE VIEW v1 AS select X.a from t1 AS X group by X.b having (X.a = 1); SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `x`.`a` AS `a` from `t1` `x` group by `x`.`b` having (`x`.`a` = 1) +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `x`.`a` AS `a` from `t1` `x` group by `x`.`b` having (`x`.`a` = 1) latin1 latin1_swedish_ci SELECT * FROM v1; a DROP VIEW v1; From 70f36562bcbcb8c02d54df63f18bf2fd570895da Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Wed, 14 Nov 2007 13:48:21 +0400 Subject: [PATCH 124/128] Fixed bug #32034: On 64bit platforms assigning values of storage engine system variables was not validated and unexpected value was assigned. The check_func_enum function used subtraction from the uint value with the probably negative result. That result of type uint was compared with 0 after casting to signed long type. On architectures where long type is longer than int type the result of comparison was unexpected. --- mysql-test/r/plugin.result | 10 ++++++++++ mysql-test/t/plugin.test | 15 +++++++++++++++ sql/sql_plugin.cc | 2 +- storage/example/ha_example.cc | 30 +++++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 8628acecf55..e4af1535775 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -17,3 +17,13 @@ UNINSTALL PLUGIN EXAMPLE; ERROR 42000: PLUGIN EXAMPLE does not exist UNINSTALL PLUGIN non_exist; ERROR 42000: PLUGIN non_exist does not exist +# +# Bug#32034: check_func_enum() does not check correct values but set it +# to impossible int val +# +INSTALL PLUGIN example SONAME 'ha_example.so'; +SET GLOBAL example_enum_var= e1; +SET GLOBAL example_enum_var= e2; +SET GLOBAL example_enum_var= impossible; +ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible' +UNINSTALL PLUGIN example; diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index fb6d5febe45..d8d6d069676 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -24,3 +24,18 @@ UNINSTALL PLUGIN EXAMPLE; --error 1305 UNINSTALL PLUGIN non_exist; + + +--echo # +--echo # Bug#32034: check_func_enum() does not check correct values but set it +--echo # to impossible int val +--echo # + +INSTALL PLUGIN example SONAME 'ha_example.so'; + +SET GLOBAL example_enum_var= e1; +SET GLOBAL example_enum_var= e2; +--error 1231 +SET GLOBAL example_enum_var= impossible; + +UNINSTALL PLUGIN example; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2af528f6699..57df53672e7 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1944,7 +1944,7 @@ static int check_func_enum(THD *thd, struct st_mysql_sys_var *var, length= sizeof(buff); if (!(str= value->val_str(value, buff, &length))) goto err; - if ((result= find_type(typelib, str, length, 1)-1) < 0) + if ((result= (long)find_type(typelib, str, length, 1)-1) < 0) { strvalue= str; goto err; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index b7186dda676..6d9f4841e06 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -848,6 +848,34 @@ int ha_example::create(const char *name, TABLE *table_arg, struct st_mysql_storage_engine example_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; +static ulong srv_enum_var= 0; + +const char *enum_var_names[]= +{ + "e1", "e2", NullS +}; + +TYPELIB enum_var_typelib= +{ + array_elements(enum_var_names) - 1, "enum_var_typelib", + enum_var_names, NULL +}; + +static MYSQL_SYSVAR_ENUM( + enum_var, // name + srv_enum_var, // varname + PLUGIN_VAR_RQCMDARG, // opt + "Sample ENUM system variable.", // comment + NULL, // check + NULL, // update + 0, // def + &enum_var_typelib); // typelib + +static struct st_mysql_sys_var* example_system_variables[]= { + MYSQL_SYSVAR(enum_var), + NULL +}; + mysql_declare_plugin(example) { MYSQL_STORAGE_ENGINE_PLUGIN, @@ -860,7 +888,7 @@ mysql_declare_plugin(example) example_done_func, /* Plugin Deinit */ 0x0001 /* 0.1 */, NULL, /* status variables */ - NULL, /* system variables */ + example_system_variables, /* system variables */ NULL /* config options */ } mysql_declare_plugin_end; From b56f668ca3314993204dab9671aeeb6ffaf44865 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Wed, 14 Nov 2007 18:56:14 +0400 Subject: [PATCH 125/128] after merge fix --- mysql-test/t/select.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 56396f8a93f..31c8a3f7d11 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3504,6 +3504,9 @@ CREATE VIEW v1 AS SELECT 1 AS ` `; --error 1166 CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +CREATE VIEW v1 AS SELECT 1 AS ` x`; +SELECT `x` FROM v1; + --error 1166 ALTER VIEW v1 AS SELECT 1 AS ` `; From f3600c943728a795701ba5e52b8468065ae5b419 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Wed, 14 Nov 2007 20:40:07 +0400 Subject: [PATCH 126/128] updated result file --- mysql-test/suite/ndb/r/ps_7ndb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result index e6bcb7f035e..fe694520f7e 100644 --- a/mysql-test/suite/ndb/r/ps_7ndb.result +++ b/mysql-test/suite/ndb/r/ps_7ndb.result @@ -63,7 +63,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 From 3b38836e6db0ef6215312184feba927dabdab893 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 15 Nov 2007 11:58:42 +0400 Subject: [PATCH 127/128] updated result file --- .../suite/funcs_1/r/innodb__datadict.result | 130 ++++++++++-------- .../suite/funcs_1/r/memory__datadict.result | 130 ++++++++++-------- .../suite/funcs_1/r/myisam__datadict.result | 130 ++++++++++-------- 3 files changed, 213 insertions(+), 177 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/innodb__datadict.result b/mysql-test/suite/funcs_1/r/innodb__datadict.result index b105e00caf7..5b500575f20 100644 --- a/mysql-test/suite/funcs_1/r/innodb__datadict.result +++ b/mysql-test/suite/funcs_1/r/innodb__datadict.result @@ -2268,7 +2268,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -2567,7 +2567,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -2598,7 +2598,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -2617,12 +2617,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -2675,10 +2675,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -2693,7 +2693,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -2703,23 +2703,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -3031,7 +3031,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -3141,7 +3141,7 @@ cp932 cp932_japanese_ci SJIS for Windows Japanese 2 eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 select sum(id) from collations; sum(id) -11094 +10840 select collation_name, character_set_name into @x,@y from collation_character_set_applicability limit 1; select @x, @y; @@ -3201,8 +3201,16 @@ NULL mysql user 0 mysql PRIMARY 2 User A 3 NULL NULL BTREE select * from views; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from user_privileges order by grantee, privilege_type; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'127.0.0.1' NULL ALTER YES @@ -5528,8 +5536,16 @@ NULL mysql columns_priv 0 mysql PRIMARY 5 Column_name A 0 NULL NULL BTREE select * from information_schema.views limit 0, 5; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from information_schema.user_privileges limit 0, 5; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'localhost' NULL SELECT YES @@ -5582,10 +5598,10 @@ COUNT(*) 36 SELECT COUNT(*) FROM information_schema. collations ; COUNT(*) -128 +127 SELECT COUNT(*) FROM information_schema. collation_character_set_applicability ; COUNT(*) -129 +128 SELECT COUNT(*) FROM information_schema. routines ; COUNT(*) 1 @@ -8542,7 +8558,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -8671,7 +8686,7 @@ COLUMNS CHARACTER_SET_NAME varchar(64) COLUMNS COLLATION_NAME varchar(64) COLUMNS COLUMN_TYPE longtext COLUMNS COLUMN_KEY varchar(3) -COLUMNS EXTRA varchar(20) +COLUMNS EXTRA varchar(27) COLUMNS PRIVILEGES varchar(80) COLUMNS COLUMN_COMMENT varchar(255) COLUMN_PRIVILEGES GRANTEE varchar(81) @@ -9324,7 +9339,6 @@ utf8_roman_ci utf8_persian_ci utf8_esperanto_ci utf8_hungarian_ci -utf8_general_cs ucs2_general_ci ucs2_bin ucs2_unicode_ci @@ -9690,7 +9704,6 @@ utf8_roman_ci utf8 207 Yes 8 utf8_persian_ci utf8 208 Yes 8 utf8_esperanto_ci utf8 209 Yes 8 utf8_hungarian_ci utf8 210 Yes 8 -utf8_general_cs utf8 254 Yes 1 ucs2_general_ci ucs2 35 Yes Yes 1 ucs2_bin ucs2 90 Yes 1 ucs2_unicode_ci ucs2 128 Yes 8 @@ -9854,7 +9867,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -10092,7 +10104,7 @@ CHARACTER_SET_NAME varchar(64) YES NULL COLLATION_NAME varchar(64) YES NULL COLUMN_TYPE longtext NO NULL COLUMN_KEY varchar(3) NO -EXTRA varchar(20) NO +EXTRA varchar(27) NO PRIVILEGES varchar(80) NO COLUMN_COMMENT varchar(255) NO SHOW CREATE TABLE columns; @@ -10114,7 +10126,7 @@ COLUMNS CREATE TEMPORARY TABLE `COLUMNS` ( `COLLATION_NAME` varchar(64) DEFAULT NULL, `COLUMN_TYPE` longtext NOT NULL, `COLUMN_KEY` varchar(3) NOT NULL DEFAULT '', - `EXTRA` varchar(20) NOT NULL DEFAULT '', + `EXTRA` varchar(27) NOT NULL DEFAULT '', `PRIVILEGES` varchar(80) NOT NULL DEFAULT '', `COLUMN_COMMENT` varchar(255) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 @@ -10145,7 +10157,7 @@ NULL information_schema columns CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema columns COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema columns COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema columns COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema columns EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema columns EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema columns PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema columns COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select @@ -10200,7 +10212,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -10474,7 +10486,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -10505,7 +10517,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -10524,12 +10536,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -10582,10 +10594,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -10600,7 +10612,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -10610,23 +10622,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -10938,7 +10950,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -11042,7 +11054,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -11567,7 +11579,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -11614,7 +11626,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -12139,7 +12151,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -12284,7 +12296,7 @@ NULL information_schema COLUMNS NUMERIC_SCALE bigint NULL NULL NULL NULL bigint( 3.0000 information_schema COLUMNS COLLATION_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 information_schema COLUMNS COLUMN_TYPE longtext 4294967295 4294967295 utf8 utf8_general_ci longtext 3.0000 information_schema COLUMNS COLUMN_KEY varchar 3 9 utf8 utf8_general_ci varchar(3) -3.0000 information_schema COLUMNS EXTRA varchar 20 60 utf8 utf8_general_ci varchar(20) +3.0000 information_schema COLUMNS EXTRA varchar 27 81 utf8 utf8_general_ci varchar(27) 3.0000 information_schema COLUMNS PRIVILEGES varchar 80 240 utf8 utf8_general_ci varchar(80) 3.0000 information_schema COLUMNS COLUMN_COMMENT varchar 255 765 utf8 utf8_general_ci varchar(255) 3.0000 information_schema COLUMN_PRIVILEGES GRANTEE varchar 81 243 utf8 utf8_general_ci varchar(81) @@ -12666,7 +12678,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi 3.0000 mysql proc is_deterministic enum 3 9 utf8 utf8_general_ci enum('YES','NO') 3.0000 mysql proc security_type enum 7 21 utf8 utf8_general_ci enum('INVOKER','DEFINER') 1.0000 mysql proc param_list blob 65535 65535 NULL NULL blob -3.0000 mysql proc returns char 64 192 utf8 utf8_general_ci char(64) +1.0000 mysql proc returns longblob 4294967295 4294967295 NULL NULL longblob 1.0000 mysql proc body longblob 4294967295 4294967295 NULL NULL longblob 3.0000 mysql proc definer char 77 231 utf8 utf8_bin char(77) NULL mysql proc created timestamp NULL NULL NULL NULL timestamp diff --git a/mysql-test/suite/funcs_1/r/memory__datadict.result b/mysql-test/suite/funcs_1/r/memory__datadict.result index af0673a393b..ad3e8d862d5 100644 --- a/mysql-test/suite/funcs_1/r/memory__datadict.result +++ b/mysql-test/suite/funcs_1/r/memory__datadict.result @@ -2266,7 +2266,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -2565,7 +2565,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -2596,7 +2596,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -2615,12 +2615,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -2673,10 +2673,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -2691,7 +2691,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -2701,23 +2701,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -3015,7 +3015,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -3124,7 +3124,7 @@ cp932 cp932_japanese_ci SJIS for Windows Japanese 2 eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 select sum(id) from collations; sum(id) -11094 +10840 select collation_name, character_set_name into @x,@y from collation_character_set_applicability limit 1; select @x, @y; @@ -3184,8 +3184,16 @@ NULL mysql user 0 mysql PRIMARY 2 User A 3 NULL NULL BTREE select * from views; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from user_privileges order by grantee, privilege_type; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'127.0.0.1' NULL ALTER YES @@ -5511,8 +5519,16 @@ NULL mysql columns_priv 0 mysql PRIMARY 5 Column_name A 0 NULL NULL BTREE select * from information_schema.views limit 0, 5; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from information_schema.user_privileges limit 0, 5; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'localhost' NULL SELECT YES @@ -5565,10 +5581,10 @@ COUNT(*) 36 SELECT COUNT(*) FROM information_schema. collations ; COUNT(*) -128 +127 SELECT COUNT(*) FROM information_schema. collation_character_set_applicability ; COUNT(*) -129 +128 SELECT COUNT(*) FROM information_schema. routines ; COUNT(*) 1 @@ -8525,7 +8541,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -8654,7 +8669,7 @@ COLUMNS CHARACTER_SET_NAME varchar(64) COLUMNS COLLATION_NAME varchar(64) COLUMNS COLUMN_TYPE longtext COLUMNS COLUMN_KEY varchar(3) -COLUMNS EXTRA varchar(20) +COLUMNS EXTRA varchar(27) COLUMNS PRIVILEGES varchar(80) COLUMNS COLUMN_COMMENT varchar(255) COLUMN_PRIVILEGES GRANTEE varchar(81) @@ -9292,7 +9307,6 @@ utf8_roman_ci utf8_persian_ci utf8_esperanto_ci utf8_hungarian_ci -utf8_general_cs ucs2_general_ci ucs2_bin ucs2_unicode_ci @@ -9658,7 +9672,6 @@ utf8_roman_ci utf8 207 Yes 8 utf8_persian_ci utf8 208 Yes 8 utf8_esperanto_ci utf8 209 Yes 8 utf8_hungarian_ci utf8 210 Yes 8 -utf8_general_cs utf8 254 Yes 1 ucs2_general_ci ucs2 35 Yes Yes 1 ucs2_bin ucs2 90 Yes 1 ucs2_unicode_ci ucs2 128 Yes 8 @@ -9822,7 +9835,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -10060,7 +10072,7 @@ CHARACTER_SET_NAME varchar(64) YES NULL COLLATION_NAME varchar(64) YES NULL COLUMN_TYPE longtext NO NULL COLUMN_KEY varchar(3) NO -EXTRA varchar(20) NO +EXTRA varchar(27) NO PRIVILEGES varchar(80) NO COLUMN_COMMENT varchar(255) NO SHOW CREATE TABLE columns; @@ -10082,7 +10094,7 @@ COLUMNS CREATE TEMPORARY TABLE `COLUMNS` ( `COLLATION_NAME` varchar(64) DEFAULT NULL, `COLUMN_TYPE` longtext NOT NULL, `COLUMN_KEY` varchar(3) NOT NULL DEFAULT '', - `EXTRA` varchar(20) NOT NULL DEFAULT '', + `EXTRA` varchar(27) NOT NULL DEFAULT '', `PRIVILEGES` varchar(80) NOT NULL DEFAULT '', `COLUMN_COMMENT` varchar(255) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 @@ -10113,7 +10125,7 @@ NULL information_schema columns CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema columns COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema columns COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema columns COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema columns EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema columns EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema columns PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema columns COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select @@ -10168,7 +10180,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -10442,7 +10454,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -10473,7 +10485,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -10492,12 +10504,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -10550,10 +10562,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -10568,7 +10580,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -10578,23 +10590,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -10892,7 +10904,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -10995,7 +11007,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -11506,7 +11518,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -11552,7 +11564,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -12063,7 +12075,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -12197,7 +12209,7 @@ NULL information_schema COLUMNS NUMERIC_SCALE bigint NULL NULL NULL NULL bigint( 3.0000 information_schema COLUMNS COLLATION_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 information_schema COLUMNS COLUMN_TYPE longtext 4294967295 4294967295 utf8 utf8_general_ci longtext 3.0000 information_schema COLUMNS COLUMN_KEY varchar 3 9 utf8 utf8_general_ci varchar(3) -3.0000 information_schema COLUMNS EXTRA varchar 20 60 utf8 utf8_general_ci varchar(20) +3.0000 information_schema COLUMNS EXTRA varchar 27 81 utf8 utf8_general_ci varchar(27) 3.0000 information_schema COLUMNS PRIVILEGES varchar 80 240 utf8 utf8_general_ci varchar(80) 3.0000 information_schema COLUMNS COLUMN_COMMENT varchar 255 765 utf8 utf8_general_ci varchar(255) 3.0000 information_schema COLUMN_PRIVILEGES GRANTEE varchar 81 243 utf8 utf8_general_ci varchar(81) @@ -12579,7 +12591,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi 3.0000 mysql proc is_deterministic enum 3 9 utf8 utf8_general_ci enum('YES','NO') 3.0000 mysql proc security_type enum 7 21 utf8 utf8_general_ci enum('INVOKER','DEFINER') 1.0000 mysql proc param_list blob 65535 65535 NULL NULL blob -3.0000 mysql proc returns char 64 192 utf8 utf8_general_ci char(64) +1.0000 mysql proc returns longblob 4294967295 4294967295 NULL NULL longblob 1.0000 mysql proc body longblob 4294967295 4294967295 NULL NULL longblob 3.0000 mysql proc definer char 77 231 utf8 utf8_bin char(77) NULL mysql proc created timestamp NULL NULL NULL NULL timestamp diff --git a/mysql-test/suite/funcs_1/r/myisam__datadict.result b/mysql-test/suite/funcs_1/r/myisam__datadict.result index da478bb2779..5f11a18565c 100644 --- a/mysql-test/suite/funcs_1/r/myisam__datadict.result +++ b/mysql-test/suite/funcs_1/r/myisam__datadict.result @@ -2296,7 +2296,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -2595,7 +2595,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -2626,7 +2626,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -2645,12 +2645,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -2703,10 +2703,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -2721,7 +2721,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -2731,23 +2731,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -3067,7 +3067,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -3194,7 +3194,7 @@ cp932 cp932_japanese_ci SJIS for Windows Japanese 2 eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 select sum(id) from collations; sum(id) -11094 +10840 select collation_name, character_set_name into @x,@y from collation_character_set_applicability limit 1; select @x, @y; @@ -3254,8 +3254,16 @@ NULL mysql user 0 mysql PRIMARY 2 User A 3 NULL NULL BTREE select * from views; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from user_privileges order by grantee, privilege_type; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'127.0.0.1' NULL ALTER YES @@ -5581,8 +5589,16 @@ NULL mysql columns_priv 0 mysql PRIMARY 5 Column_name A 0 NULL NULL BTREE select * from information_schema.views limit 0, 5; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL db_datadict v1 SELECT * FROM information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu SELECT DISTINCT u, NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL db_datadict vu1 SELECT grantee AS u NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu SELECT DISTINCT u, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3 ) +AS server, +SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,'@',1))+3, +LENGTH( SUBSTRING( u, +LENGTH( SUBSTRING_INDEX(u, '@',1)) +3 )) - 1 ) +AS Server_Clean +FROM db_datadict.vu1 NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL db_datadict vu1 SELECT grantee AS u +FROM information_schema.user_privileges NONE NO root@localhost DEFINER latin1 latin1_swedish_ci select * from information_schema.user_privileges limit 0, 5; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'localhost' NULL SELECT YES @@ -5635,10 +5651,10 @@ COUNT(*) 36 SELECT COUNT(*) FROM information_schema. collations ; COUNT(*) -128 +127 SELECT COUNT(*) FROM information_schema. collation_character_set_applicability ; COUNT(*) -129 +128 SELECT COUNT(*) FROM information_schema. routines ; COUNT(*) 1 @@ -8595,7 +8611,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -8724,7 +8739,7 @@ COLUMNS CHARACTER_SET_NAME varchar(64) COLUMNS COLLATION_NAME varchar(64) COLUMNS COLUMN_TYPE longtext COLUMNS COLUMN_KEY varchar(3) -COLUMNS EXTRA varchar(20) +COLUMNS EXTRA varchar(27) COLUMNS PRIVILEGES varchar(80) COLUMNS COLUMN_COMMENT varchar(255) COLUMN_PRIVILEGES GRANTEE varchar(81) @@ -9394,7 +9409,6 @@ utf8_roman_ci utf8_persian_ci utf8_esperanto_ci utf8_hungarian_ci -utf8_general_cs ucs2_general_ci ucs2_bin ucs2_unicode_ci @@ -9760,7 +9774,6 @@ utf8_roman_ci utf8 207 Yes 8 utf8_persian_ci utf8 208 Yes 8 utf8_esperanto_ci utf8 209 Yes 8 utf8_hungarian_ci utf8 210 Yes 8 -utf8_general_cs utf8 254 Yes 1 ucs2_general_ci ucs2 35 Yes Yes 1 ucs2_bin ucs2 90 Yes 1 ucs2_unicode_ci ucs2 128 Yes 8 @@ -9924,7 +9937,6 @@ utf8_roman_ci utf8 utf8_persian_ci utf8 utf8_esperanto_ci utf8 utf8_hungarian_ci utf8 -utf8_general_cs utf8 ucs2_general_ci ucs2 ucs2_bin ucs2 ucs2_unicode_ci ucs2 @@ -10162,7 +10174,7 @@ CHARACTER_SET_NAME varchar(64) YES NULL COLLATION_NAME varchar(64) YES NULL COLUMN_TYPE longtext NO NULL COLUMN_KEY varchar(3) NO -EXTRA varchar(20) NO +EXTRA varchar(27) NO PRIVILEGES varchar(80) NO COLUMN_COMMENT varchar(255) NO SHOW CREATE TABLE columns; @@ -10184,7 +10196,7 @@ COLUMNS CREATE TEMPORARY TABLE `COLUMNS` ( `COLLATION_NAME` varchar(64) DEFAULT NULL, `COLUMN_TYPE` longtext NOT NULL, `COLUMN_KEY` varchar(3) NOT NULL DEFAULT '', - `EXTRA` varchar(20) NOT NULL DEFAULT '', + `EXTRA` varchar(27) NOT NULL DEFAULT '', `PRIVILEGES` varchar(80) NOT NULL DEFAULT '', `COLUMN_COMMENT` varchar(255) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 @@ -10215,7 +10227,7 @@ NULL information_schema columns CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema columns COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema columns COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema columns COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema columns EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema columns EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema columns PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema columns COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select @@ -10270,7 +10282,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -10544,7 +10556,7 @@ NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PR NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references -NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references @@ -10575,7 +10587,7 @@ NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) se NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references -NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references @@ -10594,12 +10606,12 @@ NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI sel NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references -NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references -NULL mysql general_log user_host 2 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references -NULL mysql general_log thread_id 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log server_id 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql general_log command_type 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references -NULL mysql general_log argument 6 NULL YES mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references +NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references +NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references +NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references @@ -10652,10 +10664,10 @@ NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8 NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references -NULL mysql proc returns 10 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references +NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references -NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql proc sql_mode 15 NO set 431 1293 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') select,insert,update,references NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references @@ -10670,7 +10682,7 @@ NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin cha NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references -NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references @@ -10680,23 +10692,23 @@ NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,inse NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references -NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log db 7 NULL YES varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references -NULL mysql slow_log last_insert_id 8 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log insert_id 9 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log db 7 NULL NO varchar 4096 12288 NULL NULL utf8 utf8_general_ci varchar(4096) select,insert,update,references +NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references -NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references @@ -11016,7 +11028,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -11137,7 +11149,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -11670,7 +11682,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -11726,7 +11738,7 @@ NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NU NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS EXTRA 17 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select +NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select @@ -12259,7 +12271,7 @@ NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL N NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references -NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references +NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references @@ -12411,7 +12423,7 @@ NULL information_schema COLUMNS NUMERIC_SCALE bigint NULL NULL NULL NULL bigint( 3.0000 information_schema COLUMNS COLLATION_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 information_schema COLUMNS COLUMN_TYPE longtext 4294967295 4294967295 utf8 utf8_general_ci longtext 3.0000 information_schema COLUMNS COLUMN_KEY varchar 3 9 utf8 utf8_general_ci varchar(3) -3.0000 information_schema COLUMNS EXTRA varchar 20 60 utf8 utf8_general_ci varchar(20) +3.0000 information_schema COLUMNS EXTRA varchar 27 81 utf8 utf8_general_ci varchar(27) 3.0000 information_schema COLUMNS PRIVILEGES varchar 80 240 utf8 utf8_general_ci varchar(80) 3.0000 information_schema COLUMNS COLUMN_COMMENT varchar 255 765 utf8 utf8_general_ci varchar(255) 3.0000 information_schema COLUMN_PRIVILEGES GRANTEE varchar 81 243 utf8 utf8_general_ci varchar(81) @@ -12793,7 +12805,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi 3.0000 mysql proc is_deterministic enum 3 9 utf8 utf8_general_ci enum('YES','NO') 3.0000 mysql proc security_type enum 7 21 utf8 utf8_general_ci enum('INVOKER','DEFINER') 1.0000 mysql proc param_list blob 65535 65535 NULL NULL blob -3.0000 mysql proc returns char 64 192 utf8 utf8_general_ci char(64) +1.0000 mysql proc returns longblob 4294967295 4294967295 NULL NULL longblob 1.0000 mysql proc body longblob 4294967295 4294967295 NULL NULL longblob 3.0000 mysql proc definer char 77 231 utf8 utf8_bin char(77) NULL mysql proc created timestamp NULL NULL NULL NULL timestamp From f1adcf9d75a7697b9d87eafdf2978339f86cf118 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Thu, 15 Nov 2007 12:30:35 +0100 Subject: [PATCH 128/128] Bug#31700: thd->examined_row_count not incremented for 'const' type queries tests adjusted for Windows --- mysql-test/r/log_tables.result | 24 ++++++++++++------------ mysql-test/t/log_tables.test | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 6004c3d082b..1bc98eb38fb 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -830,20 +830,20 @@ INSERT INTO t1 VALUES (1,1,1); INSERT INTO t1 VALUES (2,2,2); INSERT INTO t1 VALUES (3,3,3); INSERT INTO t1 VALUES (4,4,4); -SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4; -Bug#31700 - SCAN f1 f2 f3 -Bug#31700 - SCAN 4 4 4 -SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3; -Bug#31700 - KEY f1 f2 f3 -Bug#31700 - KEY 3 3 3 -SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2; -Bug#31700 - PK f1 f2 f3 -Bug#31700 - PK 2 2 2 +SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4; +Bug#31700 - SCAN f1 f2 f3 SLEEP(1.1) +Bug#31700 - SCAN 4 4 4 0 +SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3; +Bug#31700 - KEY f1 f2 f3 SLEEP(1.1) +Bug#31700 - KEY 3 3 3 0 +SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2; +Bug#31700 - PK f1 f2 f3 SLEEP(1.1) +Bug#31700 - PK 2 2 2 0 SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time; start_time rows_examined rows_sent sql_text -TIMESTAMP 4 1 SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4 -TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3 -TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2 +TIMESTAMP 4 1 SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4 +TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3 +TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2 DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; SET GLOBAL slow_query_log = @old_slow_log_state; diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 39bf8029a7c..f02138fb30b 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -942,9 +942,9 @@ INSERT INTO t1 VALUES (2,2,2); INSERT INTO t1 VALUES (3,3,3); INSERT INTO t1 VALUES (4,4,4); -SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3 FROM t1 WHERE f3=4; -SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3 FROM t1 WHERE f2=3; -SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3 FROM t1 WHERE f1=2; +SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4; +SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3; +SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2; --replace_column 1 TIMESTAMP SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time;