diff options
author | Michael Widenius <monty@askmonty.org> | 2011-11-30 18:44:51 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-11-30 18:44:51 +0200 |
commit | 692fcba40397e71c08ed1bcf34d37283eee5a13e (patch) | |
tree | 35c9de70ca8c4dd775e83a35a374cb0f28c8bbdc | |
parent | ca5b1b54312cf9bc4a8252134874d82cf394eb48 (diff) | |
download | mariadb-git-692fcba40397e71c08ed1bcf34d37283eee5a13e.tar.gz |
Fixed compiler warnings and other bugs found by buildbot.
client/mysqltest.cc:
Free mutex after usage (fixes valgrind warnings in embedded server)
mysql-test/include/gis_keys.inc:
Fixed failure in innodb.gis_test
mysql-test/r/gis.result:
Updated result
mysql-test/suite/innodb/r/innodb_gis.result:
Updated results
mysql-test/suite/innodb/t/innodb_bug38231.test:
Added handling of timeouts (happend on some servers in buildbot)
mysql-test/suite/innodb_plugin/r/innodb_gis.result:
Updated results
mysql-test/suite/innodb_plugin/t/innodb.test:
Use error names instead of numbers
mysql-test/suite/innodb_plugin/t/innodb_misc1.test:
This test requires utf8
mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
This test requires Xtradb
sql/sql_base.cc:
Don't print table names for placeholders.
sql/sql_show.cc:
Temporary fix:
Save and restore db and table_name in mysqld_show_create (to get rid of valgrind warning)
A better solution that needs to be investgated is to not change these fields in mysql_derived_prepare()
sql/sql_view.cc:
Fixed valgrind warning
storage/xtradb/handler/ha_innodb.cc:
Don't access THD directly
-rw-r--r-- | client/mysqltest.cc | 21 | ||||
-rw-r--r-- | mysql-test/include/gis_keys.inc | 1 | ||||
-rw-r--r-- | mysql-test/r/gis.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/innodb_gis.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb_bug38231.test | 1 | ||||
-rw-r--r-- | mysql-test/suite/innodb_plugin/r/innodb_gis.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb_plugin/t/innodb.test | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb_plugin/t/innodb_misc1.test | 1 | ||||
-rw-r--r-- | mysql-test/suite/innodb_plugin/t/innodb_mysql.test | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 6 | ||||
-rw-r--r-- | sql/sql_show.cc | 42 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 2 |
13 files changed, 70 insertions, 21 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 668d9ba45ba..a5d9fa677a1 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -262,7 +262,7 @@ struct st_connection pthread_cond_t cond; pthread_t tid; int query_done; - my_bool has_thread; + my_bool has_thread, mutex_inited; #endif /*EMBEDDED_LIBRARY*/ }; @@ -776,10 +776,12 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len, if (flags & QUERY_REAP_FLAG) return mysql_send_query(cn->mysql, q, q_len); - if (pthread_mutex_init(&cn->mutex, NULL) || - pthread_cond_init(&cn->cond, NULL)) + if (!cn->mutex_inited && + (pthread_mutex_init(&cn->mutex, NULL) || + pthread_cond_init(&cn->cond, NULL))) die("Error in the thread library"); + cn->mutex_inited= 1; cn->cur_query= q; cn->cur_query_len= q_len; cn->query_done= 0; @@ -809,9 +811,20 @@ static void wait_query_thread_end(struct st_connection *con) } } +static void free_embedded_data(struct st_connection *con) +{ + if (con->mutex_inited) + { + con->mutex_inited= 0; + pthread_mutex_destroy(&con->mutex); + pthread_cond_destroy(&con->cond); + } +} + #else /*EMBEDDED_LIBRARY*/ #define do_send_query(cn,q,q_len,flags) mysql_send_query(cn->mysql, q, q_len) +#define free_embedded_data(next_con) do { } while(0) #endif /*EMBEDDED_LIBRARY*/ @@ -1165,6 +1178,7 @@ void close_connections() if (next_con->util_mysql) mysql_close(next_con->util_mysql); my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR)); + free_embedded_data(next_con); } my_free(connections, MYF(MY_WME)); DBUG_VOID_RETURN; @@ -4988,6 +5002,7 @@ void do_close_connection(struct st_command *command) mysql_close(con->mysql); con->mysql= 0; + free_embedded_data(con); if (con->util_mysql) mysql_close(con->util_mysql); diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc index ad00c7e1ef9..cc8ec68f7d1 100644 --- a/mysql-test/include/gis_keys.inc +++ b/mysql-test/include/gis_keys.inc @@ -33,6 +33,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +--replace_column 9 # EXPLAIN SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index acb55d225a7..2cf5630e90b 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -947,7 +947,7 @@ COUNT(*) EXPLAIN SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref p p 28 const 1 Using where +1 SIMPLE t2 ref p p 28 const # Using where SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); COUNT(*) 2 diff --git a/mysql-test/suite/innodb/r/innodb_gis.result b/mysql-test/suite/innodb/r/innodb_gis.result index 30daaf129b1..d1237942a6a 100644 --- a/mysql-test/suite/innodb/r/innodb_gis.result +++ b/mysql-test/suite/innodb/r/innodb_gis.result @@ -572,7 +572,7 @@ COUNT(*) EXPLAIN SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref p p 28 const 2 Using where +1 SIMPLE t2 ref p p 28 const # Using where SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); COUNT(*) 2 diff --git a/mysql-test/suite/innodb/t/innodb_bug38231.test b/mysql-test/suite/innodb/t/innodb_bug38231.test index 5021f23d07e..4cf16beba56 100644 --- a/mysql-test/suite/innodb/t/innodb_bug38231.test +++ b/mysql-test/suite/innodb/t/innodb_bug38231.test @@ -72,6 +72,7 @@ UNLOCK TABLES; # clean up -- connection con2 +-- error 0, 1205 -- reap UNLOCK TABLES; diff --git a/mysql-test/suite/innodb_plugin/r/innodb_gis.result b/mysql-test/suite/innodb_plugin/r/innodb_gis.result index 30daaf129b1..d1237942a6a 100644 --- a/mysql-test/suite/innodb_plugin/r/innodb_gis.result +++ b/mysql-test/suite/innodb_plugin/r/innodb_gis.result @@ -572,7 +572,7 @@ COUNT(*) EXPLAIN SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref p p 28 const 2 Using where +1 SIMPLE t2 ref p p 28 const # Using where SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); COUNT(*) 2 diff --git a/mysql-test/suite/innodb_plugin/t/innodb.test b/mysql-test/suite/innodb_plugin/t/innodb.test index 03c8336f214..59e0328bb8d 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb.test +++ b/mysql-test/suite/innodb_plugin/t/innodb.test @@ -1034,11 +1034,11 @@ create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) insert into `t2`values ( 1 ) ; create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb; insert into `t3`values ( 1 ) ; ---error 1451 +--error ER_ROW_IS_REFERENCED_2 delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; ---error 1451 +--error ER_ROW_IS_REFERENCED_2 update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; ---error 1054 +--error ER_BAD_FIELD_ERROR update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; drop table t3,t2,t1; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_misc1.test b/mysql-test/suite/innodb_plugin/t/innodb_misc1.test index e9b6d72aa7d..31f9988d1ac 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_misc1.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_misc1.test @@ -1,4 +1,5 @@ -- source include/have_innodb_plugin.inc +-- source include/have_utf8.inc let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test index 1cdc1b4e2fe..d9981af2d0d 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test @@ -8,6 +8,9 @@ -- source include/have_innodb_plugin.inc -- source include/have_query_cache.inc +# We must run this with XtraDB as otherwise we will get different EXPLAIN's +-- source include/have_xtradb.inc + let $engine_type= InnoDB; let $other_engine_type= MEMORY; # InnoDB does support FOREIGN KEYFOREIGN KEYs diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 54921500e93..e895793f3c8 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4699,9 +4699,6 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) */ for (tables= *start; tables ;tables= tables->next_global) { - DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: 0x%lx", - tables->db, tables->table_name, (long) tables)); - safe_to_ignore_table= FALSE; /* @@ -4714,8 +4711,11 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) { if (tables->view) goto process_view_routines; + DBUG_PRINT("tcache", ("ignoring placeholder for derived table")); continue; } + DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: 0x%lx", + tables->db, tables->table_name, (long) tables)); /* If this TABLE_LIST object is a placeholder for an information_schema table, create a temporary table to represent the information_schema diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bb9a4a1e062..fccb071ccb3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -708,12 +708,30 @@ public: }; +/* + Return CREATE command for table or view + + @param thd Thread handler + @param table_list Table / view + + @return + @retval 0 OK + @retval 1 Error + + @notes + table_list->db and table_list->table_name are kept unchanged to + not cause problems with SP. +*/ + bool mysqld_show_create(THD *thd, TABLE_LIST *table_list) { Protocol *protocol= thd->protocol; char buff[2048]; String buffer(buff, sizeof(buff), system_charset_info); + char *save_db, *save_table_name; + bool retval= TRUE; // Assume error + List<Item> field_list; DBUG_ENTER("mysqld_show_create"); DBUG_PRINT("enter",("db: %s table: %s",table_list->db, table_list->table_name)); @@ -721,13 +739,17 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) /* We want to preserve the tree for views. */ thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW; + /* Store original names if called from SP */ + save_db= table_list->db; + save_table_name= table_list->table_name; + { Show_create_error_handler view_error_suppressor(thd, table_list); thd->push_internal_handler(&view_error_suppressor); bool error= open_normal_and_derived_tables(thd, table_list, 0); thd->pop_internal_handler(); if (error && (thd->killed || thd->main_da.is_error())) - DBUG_RETURN(TRUE); + goto error; } /* TODO: add environment variables show when it become possible */ @@ -735,7 +757,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) { my_error(ER_WRONG_OBJECT, MYF(0), table_list->db, table_list->table_name, "VIEW"); - DBUG_RETURN(TRUE); + goto error; } buffer.length(0); @@ -747,9 +769,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) view_store_create_info(thd, table_list, &buffer) : store_create_info(thd, table_list, &buffer, NULL, FALSE /* show_database */))) - DBUG_RETURN(TRUE); + goto error; - List<Item> field_list; if (table_list->view) { field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN)); @@ -770,7 +791,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(TRUE); + goto error; protocol->prepare_for_resend(); if (table_list->view) protocol->store(table_list->view_name.str, system_charset_info); @@ -798,10 +819,17 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) protocol->store(buffer.ptr(), buffer.length(), buffer.charset()); if (protocol->write()) - DBUG_RETURN(TRUE); + goto error; my_eof(thd); - DBUG_RETURN(FALSE); + retval= FALSE; // ok + +error: + /* Restore table list if called by stored procedure */ + table_list->db= save_db; + table_list->table_name= save_table_name; + DBUG_RETURN(retval); + } bool mysqld_show_create_db(THD *thd, char *dbname, diff --git a/sql/sql_view.cc b/sql/sql_view.cc index df9df89f972..27bdfed6bea 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -848,7 +848,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, thd->variables.sql_mode|= sql_mode; } - DBUG_PRINT("info", ("View: %s", view_query.ptr())); + DBUG_PRINT("info", ("View: %.*s", view_query.length(), view_query.ptr())); /* fill structure */ view->source= thd->lex->create_view_select; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 4f4db23d06c..536871fb9ab 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -2735,7 +2735,7 @@ innobase_commit_low( #ifdef MYSQL_SERVER THD *thd=current_thd; - if (thd && thd->slave_thread) { + if (thd && thd_is_replication_slave_thread(thd)) { /* Update the replication position info inside InnoDB. In embedded server, does nothing. */ const char *log_file_name, *group_relay_log_name; |