From: Marc Alff Date: February 16 2012 10:48am Subject: bzr push into mysql-trunk-wl5259 branch (marc.alff:3382 to 3384) List-Archive: http://lists.mysql.com/commits/142902 Message-Id: <201202161049.q1GAnO1j011718@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3384 Marc Alff 2012-02-16 Test cleanup modified: mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test 3383 Marc Alff 2012-02-16 [merge] Merge mysql-trunk --> mysql-trunk-wl5259 added: include/my_rnd.h sql/global_threads.h sql/my_rnd.cc modified: libmysql/CMakeLists.txt mysql-test/r/derived.result mysql-test/suite/innodb/t/innodb_bug-13628249.test mysql-test/suite/innodb/t/innodb_bug53756.test mysql-test/t/derived.test mysql-test/t/disabled.def sql/CMakeLists.txt sql/event_scheduler.cc sql/keycaches.cc sql/keycaches.h sql/mysqld.cc sql/mysqld.h sql/password.c sql/rpl_master.cc sql/signal_handler.cc sql/sql_class.cc sql/sql_class.h sql/sql_insert.cc sql/sql_list.h sql/sql_optimizer.cc sql/sql_parse.cc sql/sql_select.cc sql/sql_show.cc sql/sql_test.cc sql/sql_tmp_table.cc storage/innobase/lock/lock0lock.cc unittest/gunit/sql_list-t.cc 3382 Marc Alff 2012-02-15 More test cases added: mysql-test/suite/perfschema/r/hostcache_ipv4_passwd.result mysql-test/suite/perfschema/r/hostcache_ipv4_ssl.result mysql-test/suite/perfschema/r/hostcache_ipv6_passwd.result mysql-test/suite/perfschema/r/hostcache_ipv6_ssl.result mysql-test/suite/perfschema/t/hostcache_ipv4_passwd.test mysql-test/suite/perfschema/t/hostcache_ipv4_ssl.test mysql-test/suite/perfschema/t/hostcache_ipv6_passwd-master.opt mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test mysql-test/suite/perfschema/t/hostcache_ipv6_ssl-master.opt mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test === added file 'include/my_rnd.h' --- a/include/my_rnd.h 1970-01-01 00:00:00 +0000 +++ b/include/my_rnd.h 2012-02-15 18:54:54 +0000 @@ -0,0 +1,38 @@ +#ifndef MY_RANDOM_INCLUDED +#define MY_RANDOM_INCLUDED + +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/* + A wrapper to use OpenSSL/YaSSL PRNGs. +*/ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +double my_rnd_ssl(struct rand_struct *rand_st); + +#ifdef __cplusplus +} +#endif + +#endif /* MY_RANDOM_INCLUDED */ === modified file 'libmysql/CMakeLists.txt' --- a/libmysql/CMakeLists.txt 2012-01-30 09:30:13 +0000 +++ b/libmysql/CMakeLists.txt 2012-02-15 18:54:54 +0000 @@ -146,6 +146,7 @@ SET(CLIENT_SOURCES ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c + ../sql/my_rnd.cc ) ADD_CONVENIENCE_LIBRARY(clientlib ${CLIENT_SOURCES}) DTRACE_INSTRUMENT(clientlib) === modified file 'mysql-test/r/derived.result' --- a/mysql-test/r/derived.result 2012-01-30 13:13:15 +0000 +++ b/mysql-test/r/derived.result 2012-02-13 10:42:27 +0000 @@ -1949,3 +1949,16 @@ ORDER BY grandparent.col_varchar_nokey; g1 r DROP TABLE t1, t2, t3; +# +# Bug#13457552: Crash on instantiating a derived table in a query with +# empty result. +# +CREATE TABLE t1 ( pk INT, col_blob BLOB ) ENGINE = MyISAM; +CREATE TABLE t2 ( pk INT, col_blob BLOB ) ENGINE = InnoDB; +SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +pk +EXPLAIN SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DERIVED t2 ALL NULL NULL NULL NULL 1 +DROP TABLE t1,t2; === modified file 'mysql-test/suite/innodb/t/innodb_bug-13628249.test' --- a/mysql-test/suite/innodb/t/innodb_bug-13628249.test 2012-02-14 10:27:14 +0000 +++ b/mysql-test/suite/innodb/t/innodb_bug-13628249.test 2012-02-15 14:50:33 +0000 @@ -29,34 +29,26 @@ INSERT INTO t1 VALUES(1), (2), (3), (4); # Request a crash on next execution of commit. SET SESSION debug="+d,crash_commit_before"; +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart:--innodb-force-recovery=3" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + # Execute the statement that causes the crash. --error 2013 COMMIT; -# Write file to make mysql-test-run.pl start up the server again ---exec echo "restart:--innodb-force-recovery=3" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect - -# Turn on reconnect --enable_reconnect - -# Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc +--disable_reconnect SELECT * FROM t1; -# Turn off reconnect again ---disable_reconnect +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--shutdown_server +--source include/wait_until_disconnected.inc -# Write file to make mysql-test-run.pl start up the server again --exec echo "restart:--innodb-force-recovery=5" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect - -# Turn on reconnect --enable_reconnect - -# Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc - -# Turn off reconnect again --disable_reconnect SELECT * FROM t1; === modified file 'mysql-test/suite/innodb/t/innodb_bug53756.test' --- a/mysql-test/suite/innodb/t/innodb_bug53756.test 2011-03-15 15:11:17 +0000 +++ b/mysql-test/suite/innodb/t/innodb_bug53756.test 2012-02-15 14:37:06 +0000 @@ -139,6 +139,9 @@ INSERT INTO bug_53756 VALUES (666,666); # Request a crash on next execution of commit. SET SESSION debug="+d,crash_commit_before"; # +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +# # Execute the statement that causes the crash. --error 2013 COMMIT; @@ -154,9 +157,6 @@ COMMIT; --echo # --echo # Restart server. # -# Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -# # Turn on reconnect --enable_reconnect # === modified file 'mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test 2012-02-15 12:05:06 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test 2012-02-16 10:47:43 +0000 @@ -7,6 +7,7 @@ --source include/not_embedded.inc --source include/have_debug.inc +--source include/have_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state === modified file 'mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test 2012-02-15 12:05:06 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test 2012-02-16 10:47:43 +0000 @@ -7,6 +7,7 @@ --source include/not_embedded.inc --source include/have_debug.inc +--source include/have_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state === modified file 'mysql-test/t/derived.test' --- a/mysql-test/t/derived.test 2011-11-30 11:36:14 +0000 +++ b/mysql-test/t/derived.test 2012-02-13 10:42:27 +0000 @@ -1307,3 +1307,14 @@ eval $query; DROP TABLE t1, t2, t3; +--echo # +--echo # Bug#13457552: Crash on instantiating a derived table in a query with +--echo # empty result. +--echo # +CREATE TABLE t1 ( pk INT, col_blob BLOB ) ENGINE = MyISAM; +CREATE TABLE t2 ( pk INT, col_blob BLOB ) ENGINE = InnoDB; +SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +EXPLAIN SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +DROP TABLE t1,t2; + + === modified file 'mysql-test/t/disabled.def' --- a/mysql-test/t/disabled.def 2011-12-05 12:01:10 +0000 +++ b/mysql-test/t/disabled.def 2012-02-15 11:09:43 +0000 @@ -14,3 +14,4 @@ read_many_rows_innodb : Bug#11748886 sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested archive-big : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc log_tables-big : Bug#11756699 2010-11-15 mattiasj report already exists +events_restart @windows : Bug#11748899 2012-02-15 agopi The test started failing on windows after the fix for bug#11748899 === modified file 'sql/CMakeLists.txt' --- a/sql/CMakeLists.txt 2012-01-05 10:14:20 +0000 +++ b/sql/CMakeLists.txt 2012-02-15 18:54:54 +0000 @@ -72,6 +72,7 @@ SET(SQL_SHARED_SOURCES mdl.cc mf_iocache.cc my_decimal.cc + my_rnd.cc net_serv.cc opt_explain.cc opt_range.cc === modified file 'sql/event_scheduler.cc' --- a/sql/event_scheduler.cc 2011-10-06 11:06:34 +0000 +++ b/sql/event_scheduler.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "event_db_repository.h" #include "sql_connect.h" // init_new_connection_handler_thread #include "sql_acl.h" // SUPER_ACL +#include "global_threads.h" /** @addtogroup Event_Scheduler === added file 'sql/global_threads.h' --- a/sql/global_threads.h 1970-01-01 00:00:00 +0000 +++ b/sql/global_threads.h 2012-02-15 13:57:17 +0000 @@ -0,0 +1,28 @@ +/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */ + +#ifndef GLOBAL_THREADS_INCLUDED +#define GLOBAL_THREADS_INCLUDED + +/* + TODO: Make a proper interface for keeping track of global threads. + */ +#include "sql_list.h" +#include "sql_class.h" + +extern I_List threads; +extern uint volatile thread_count; + +#endif // GLOBAL_THREADS_INCLUDED === modified file 'sql/keycaches.cc' --- a/sql/keycaches.cc 2011-06-30 15:50:45 +0000 +++ b/sql/keycaches.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,33 +21,6 @@ NAMED_ILIST key_caches; -/** - ilink (intrusive list element) with a name -*/ -class NAMED_ILINK :public ilink -{ -public: - const char *name; - uint name_length; - uchar* data; - - NAMED_ILINK(I_List *links, const char *name_arg, - uint name_length_arg, uchar* data_arg) - :name_length(name_length_arg), data(data_arg) - { - name= my_strndup(name_arg, name_length, MYF(MY_WME)); - links->push_back(this); - } - inline bool cmp(const char *name_cmp, uint length) - { - return length == name_length && !memcmp(name, name_cmp, length); - } - ~NAMED_ILINK() - { - my_free((void *) name); - } -}; - uchar* find_named(I_List *list, const char *name, uint length, NAMED_ILINK **found) { === modified file 'sql/keycaches.h' --- a/sql/keycaches.h 2011-06-30 15:50:45 +0000 +++ b/sql/keycaches.h 2012-02-15 13:57:17 +0000 @@ -24,7 +24,34 @@ extern "C" typedef int (*process_key_cache_t) (const char *, KEY_CACHE *); } -class NAMED_ILINK; +/** + ilink (intrusive list element) with a name +*/ +class NAMED_ILINK :public ilink +{ +public: + const char *name; + uint name_length; + uchar* data; + + NAMED_ILINK(I_List *links, const char *name_arg, + uint name_length_arg, uchar* data_arg) + :name_length(name_length_arg), data(data_arg) + { + name= my_strndup(name_arg, name_length, MYF(MY_WME)); + links->push_back(this); + } + + bool cmp(const char *name_cmp, uint length) + { + return length == name_length && !memcmp(name, name_cmp, length); + } + + ~NAMED_ILINK() + { + my_free((void *) name); + } +}; class NAMED_ILIST: public I_List { === added file 'sql/my_rnd.cc' --- a/sql/my_rnd.cc 1970-01-01 00:00:00 +0000 +++ b/sql/my_rnd.cc 2012-02-15 18:54:54 +0000 @@ -0,0 +1,73 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include + +#if defined(HAVE_YASSL) + +#if defined(YASSL_PREFIX) +#define RAND_bytes yaRAND_bytes +#endif /* YASSL_PREFIX */ + +#include + +#elif defined(HAVE_OPENSSL) +#include +#endif /* HAVE_YASSL */ + + +/* + A wrapper to use OpenSSL/yaSSL PRNGs. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Generate a random number using the OpenSSL/yaSSL supplied + random number generator if available. + + @param rand_st [INOUT] Structure used for number generation + only if none of the SSL libraries are + available. + + @retval Generated random number. +*/ + +double my_rnd_ssl(struct rand_struct *rand_st) +{ + +#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL) + int rc; + unsigned int res; + +#if defined(HAVE_YASSL) + rc= yaSSL::RAND_bytes((unsigned char *) &res, sizeof (unsigned int)); +#else + rc= RAND_bytes((unsigned char *) &res, sizeof (unsigned int)); +#endif /* HAVE_YASSL */ + + if (rc) + return (double)res / (double)UINT_MAX; + else +#endif /* defined(HAVE_YASSL) || defined(HAVE_OPENSSL) */ + return my_rnd(rand_st); +} + +#ifdef __cplusplus +} +#endif === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2012-02-08 15:55:31 +0000 +++ b/sql/mysqld.cc 2012-02-16 10:36:35 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,6 +71,9 @@ #include "sql_callback.h" #include "opt_trace_context.h" +#include "global_threads.h" +#include "mysqld.h" + #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #include "../storage/perfschema/pfs_server.h" #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ === modified file 'sql/mysqld.h' --- a/sql/mysqld.h 2012-02-08 15:55:31 +0000 +++ b/sql/mysqld.h 2012-02-16 10:36:35 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,7 +107,6 @@ extern bool opt_ignore_builtin_innodb; extern my_bool opt_character_set_client_handshake; extern bool volatile abort_loop; extern bool in_bootstrap; -extern uint volatile thread_count; extern uint connection_count; extern my_bool opt_safe_user_create; extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; @@ -233,7 +232,6 @@ extern MYSQL_FILE *bootstrap_file; extern my_bool old_mode; extern LEX_STRING opt_init_connect, opt_init_slave; extern int bootstrap_error; -extern I_List threads; extern char err_shared_dir[]; extern TYPELIB thread_handling_typelib; extern my_decimal decimal_zero; === modified file 'sql/password.c' --- a/sql/password.c 2011-07-04 00:25:46 +0000 +++ b/sql/password.c 2012-02-15 18:54:54 +0000 @@ -64,6 +64,7 @@ #include #include #include +#include #include "mysql.h" /************ MySQL 3.23-4.0 authentication routines: untouched ***********/ @@ -321,7 +322,7 @@ void create_random_string(char *to, uint char *end= to + length; /* Use pointer arithmetics as it is faster way to do so. */ for (; to < end; to++) - *to= (char) (my_rnd(rand_st)*94+33); + *to= (char) (my_rnd_ssl(rand_st) * 94 + 33); *to= '\0'; } === modified file 'sql/rpl_master.cc' --- a/sql/rpl_master.cc 2012-01-22 17:00:21 +0000 +++ b/sql/rpl_master.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ #include "sql_priv.h" #include "unireg.h" #include "sql_parse.h" // check_access +#include "global_threads.h" #ifdef HAVE_REPLICATION #include "sql_acl.h" // SUPER_ACL === modified file 'sql/signal_handler.cc' --- a/sql/signal_handler.cc 2011-12-02 13:33:08 +0000 +++ b/sql/signal_handler.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ #include "sys_vars.h" #include "my_stacktrace.h" +#include "global_threads.h" #ifdef __WIN__ #include === modified file 'sql/sql_class.cc' --- a/sql/sql_class.cc 2012-02-08 15:25:17 +0000 +++ b/sql/sql_class.cc 2012-02-15 13:57:17 +0000 @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,6 +57,8 @@ #include "sql_parse.h" // is_update_query #include "sql_callback.h" #include "lock.h" +#include "global_threads.h" +#include "mysqld.h" #include @@ -2069,17 +2071,6 @@ void THD::close_active_vio() #endif -struct Item_change_record: public ilink -{ - Item **place; - Item *old_value; - /* Placement new was hidden by `new' in ilink (TODO: check): */ - static void *operator new(size_t size, void *mem) { return mem; } - static void operator delete(void *ptr, size_t size) {} - static void operator delete(void *ptr, void *mem) { /* never called */ } -}; - - /* Register an item tree tree transformation, performed by the query optimizer. We need a pointer to runtime_memroot because it may be != === modified file 'sql/sql_class.h' --- a/sql/sql_class.h 2012-01-31 15:16:16 +0000 +++ b/sql/sql_class.h 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1052,7 +1052,7 @@ class Server_side_cursor; be used explicitly. */ -class Statement: public ilink, public Query_arena +class Statement: public Query_arena { Statement(const Statement &rhs); /* not implemented: */ Statement &operator=(const Statement &rhs); /* non-copyable */ @@ -1205,6 +1205,7 @@ public: Close all cursors of this connection that use tables of a storage engine that has transaction-specific state and therefore can not survive COMMIT or ROLLBACK. Currently all but MyISAM cursors are closed. + CURRENTLY NOT IMPLEMENTED! */ void close_transient_cursors(); void erase(Statement *statement); @@ -1214,7 +1215,6 @@ public: private: HASH st_hash; HASH names_hash; - I_List transient_cursor_list; Statement *last_found_statement; }; @@ -1655,7 +1655,12 @@ extern Log_throttle log_throttle_qni; yet another time. */ -struct Item_change_record; +struct Item_change_record: public ilink +{ + Item **place; + Item *old_value; +}; + typedef I_List Item_change_list; @@ -2149,7 +2154,8 @@ my_micro_time_to_timeval(ulonglong micro a thread/connection descriptor */ -class THD :public Statement, +class THD :public ilink, + public Statement, public Open_tables_state, public MDL_context_owner { === modified file 'sql/sql_insert.cc' --- a/sql/sql_insert.cc 2012-01-31 15:16:16 +0000 +++ b/sql/sql_insert.cc 2012-02-15 13:57:17 +0000 @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -81,6 +81,7 @@ #include "delayable_insert_operation.h" #include "sql_tmp_table.h" // tmp tables #include "sql_optimizer.h" // JOIN +#include "global_threads.h" #include "debug_sync.h" @@ -1838,7 +1839,7 @@ int check_that_all_fields_are_given_valu @note that custom operator new/delete are inherited from the ilink class. */ -class delayed_row :public ilink { +class delayed_row :public ilink { public: char *record; enum_duplicates dup; @@ -1980,7 +1981,7 @@ bool delayed_row::copy_context(THD *thd, @note that custom operator new/delete are inherited from the ilink class. */ -class Delayed_insert :public ilink { +class Delayed_insert :public ilink { uint locks_in_memory; thr_lock_type delayed_lock; public: === modified file 'sql/sql_list.h' --- a/sql/sql_list.h 2011-10-06 11:06:34 +0000 +++ b/sql/sql_list.h 2012-02-15 13:57:17 +0000 @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_SQL_LIST_H #define INCLUDES_MYSQL_SQL_LIST_H -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -573,41 +573,43 @@ public: }; +template class base_ilist; +template class base_ilist_iterator; + /* A simple intrusive list which automaticly removes element from list on delete (for THD element) + NOTE: this inherently unsafe, since we rely on to have + the same layout as ilink (see base_ilist::sentinel). + Please consider using a different strategy for linking objects. */ -struct ilink +template +class ilink { - struct ilink **prev,*next; - static void *operator new(size_t size) throw () - { - return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATALERROR)); - } - static void operator delete(void* ptr_arg, size_t size) - { - my_free(ptr_arg); - } + T **prev, *next; +public: + ilink() : prev(NULL), next(NULL) {} - inline ilink() - { - prev=0; next=0; - } - inline void unlink() + void unlink() { /* Extra tests because element doesn't have to be linked */ if (prev) *prev= next; if (next) next->prev=prev; - prev=0 ; next=0; + prev= NULL; + next= NULL; } + virtual ~ilink() { unlink(); } /*lint -e1740 */ + + friend class base_ilist; + friend class base_ilist_iterator; }; /* Needed to be able to have an I_List of char* strings in mysqld.cc. */ -class i_string: public ilink +class i_string: public ilink { public: const char* ptr; @@ -616,7 +618,7 @@ public: }; /* needed for linked list of two strings for replicate-rewrite-db */ -class i_string_pair: public ilink +class i_string_pair: public ilink { public: const char* key; @@ -630,38 +632,48 @@ public: template class I_List_iterator; +template class base_ilist { - struct ilink *first; - struct ilink last; + T *first; + ilink sentinel; public: - inline void empty() { first= &last; last.prev= &first; } + void empty() { + first= static_cast(&sentinel); + sentinel.prev= &first; + } base_ilist() { empty(); } - inline bool is_empty() { return first == &last; } - inline void push_front(ilink *a) + bool is_empty() { return first == static_cast(&sentinel); } + + /// Pushes new element in front of list. + void push_front(T *a) { first->prev= &a->next; - a->next=first; a->prev= &first; first=a; + a->next= first; + a->prev= &first; + first= a; } - inline void push_back(ilink *a) + + /// Pushes new element to the end of the list, i.e. in front of the sentinel. + void push_back(T *a) { - *last.prev= a; - a->next= &last; - a->prev= last.prev; - last.prev= &a->next; + *sentinel.prev= a; + a->next= static_cast(&sentinel); + a->prev= sentinel.prev; + sentinel.prev= &a->next; } - inline struct ilink *get() + + // Unlink first element, and return it. + T *get() { - struct ilink *first_link=first; - if (first_link == &last) - return 0; - first_link->unlink(); // Unlink from list + if (is_empty()) + return NULL; + T *first_link= first; + first_link->unlink(); return first_link; } - inline struct ilink *head() - { - return (first != &last) ? first : 0; - } + + T *head() { return is_empty() ? NULL : first; } /** Moves list elements to new owner, and empties current owner (i.e. this). @@ -674,11 +686,11 @@ public: { DBUG_ASSERT(new_owner->is_empty()); new_owner->first= first; - new_owner->last= last; + new_owner->sentinel= sentinel; empty(); } - friend class base_ilist_iterator; + friend class base_ilist_iterator; private: /* We don't want to allow copying of this class, as that would give us @@ -690,18 +702,24 @@ public: }; +template class base_ilist_iterator { - base_ilist *list; - struct ilink **el,*current; + base_ilist *list; + T **el, *current; public: - base_ilist_iterator(base_ilist &list_par) :list(&list_par), - el(&list_par.first),current(0) {} - void *next(void) + base_ilist_iterator(base_ilist &list_par) : + list(&list_par), + el(&list_par.first), + current(NULL) + {} + + T *next(void) { /* This is coded to allow push_back() while iterating */ current= *el; - if (current == &list->last) return 0; + if (current == static_cast(&list->sentinel)) + return NULL; el= ¤t->next; return current; } @@ -709,18 +727,17 @@ public: template -class I_List :private base_ilist +class I_List :private base_ilist { public: - I_List() :base_ilist() {} - inline void empty() { base_ilist::empty(); } - inline bool is_empty() { return base_ilist::is_empty(); } - inline void push_front(T* a) { base_ilist::push_front(a); } - inline void push_back(T* a) { base_ilist::push_back(a); } - inline T* get() { return (T*) base_ilist::get(); } - inline T* head() { return (T*) base_ilist::head(); } - inline void move_elements_to(I_List* new_owner) { - base_ilist::move_elements_to(new_owner); + using base_ilist::empty; + using base_ilist::is_empty; + using base_ilist::get; + using base_ilist::push_front; + using base_ilist::push_back; + using base_ilist::head; + void move_elements_to(I_List* new_owner) { + base_ilist::move_elements_to(new_owner); } #ifndef _lint friend class I_List_iterator; @@ -728,11 +745,12 @@ public: }; -template class I_List_iterator :public base_ilist_iterator +template +class I_List_iterator :public base_ilist_iterator { public: - I_List_iterator(I_List &a) : base_ilist_iterator(a) {} - inline T* operator++(int) { return (T*) base_ilist_iterator::next(); } + I_List_iterator(I_List &a) : base_ilist_iterator(a) {} + inline T* operator++(int) { return base_ilist_iterator::next(); } }; /** === modified file 'sql/sql_optimizer.cc' --- a/sql/sql_optimizer.cc 2012-02-14 14:42:12 +0000 +++ b/sql/sql_optimizer.cc 2012-02-15 13:57:17 +0000 @@ -944,7 +944,7 @@ void reset_nj_counters(List Return in cond_value FALSE if condition is impossible (1 = 2) *****************************************************************************/ -class COND_CMP :public ilink { +class COND_CMP :public ilink { public: static void *operator new(size_t size) { === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2012-02-08 14:27:40 +0000 +++ b/sql/sql_parse.cc 2012-02-16 10:36:35 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -97,6 +97,7 @@ #include "sql_bootstrap.h" #include "opt_explain.h" #include "sql_rewrite.h" +#include "global_threads.h" #include using std::max; === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2012-02-08 15:25:17 +0000 +++ b/sql/sql_select.cc 2012-02-15 10:47:01 +0000 @@ -783,7 +783,8 @@ bool JOIN::prepare_result(List **c error= 0; /* Create result tables for materialized views. */ - if (select_lex->handle_derived(thd->lex, &mysql_derived_create)) + if (!zero_result_cause && + select_lex->handle_derived(thd->lex, &mysql_derived_create)) goto err; (void) result->prepare2(); // Currently, this cannot fail. === modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2012-02-08 12:49:33 +0000 +++ b/sql/sql_show.cc 2012-02-15 14:01:06 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,6 +57,7 @@ #include "opt_trace.h" // Optimizer trace information schema tables #include "sql_tmp_table.h" // Tmp tables #include "sql_optimizer.h" // JOIN +#include "global_threads.h" #include using std::max; @@ -1995,7 +1996,7 @@ view_store_create_info(THD *thd, TABLE_L returns for each thread: thread id, user, host, db, command, info ****************************************************************************/ -class thread_info :public ilink { +class thread_info :public ilink { public: static void *operator new(size_t size) { === modified file 'sql/sql_test.cc' --- a/sql/sql_test.cc 2011-12-14 12:32:55 +0000 +++ b/sql/sql_test.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,6 +39,8 @@ #include "events.h" #endif +#include "global_threads.h" + static const char *lock_descriptions[] = { /* TL_UNLOCK */ "No lock", === modified file 'sql/sql_tmp_table.cc' --- a/sql/sql_tmp_table.cc 2012-02-10 09:06:59 +0000 +++ b/sql/sql_tmp_table.cc 2012-02-15 10:47:01 +0000 @@ -1647,6 +1647,11 @@ bool create_myisam_tmp_table(TABLE *tabl if (share->keys) { // Get keys for ni_create bool using_unique_constraint=0; + if (share->keys > 1) + { + DBUG_ASSERT(0); // This code can't handle more than 1 key + share->keys= 1; + } HA_KEYSEG *seg= (HA_KEYSEG*) alloc_root(&table->mem_root, sizeof(*seg) * keyinfo->key_parts); if (!seg) === modified file 'storage/innobase/lock/lock0lock.cc' --- a/storage/innobase/lock/lock0lock.cc 2012-02-14 07:44:56 +0000 +++ b/storage/innobase/lock/lock0lock.cc 2012-02-15 17:40:20 +0000 @@ -5082,19 +5082,19 @@ lock_print_info_summary( ut_error; case PURGE_STATE_RUN: - fprintf(stderr, "running"); + fprintf(file, "running"); /* Check if it is waiting for more data to arrive. */ if (!purge_sys->running) { - fprintf(stderr, " but idle"); + fprintf(file, " but idle"); } break; case PURGE_STATE_STOP: - fprintf(stderr, "stopped"); + fprintf(file, "stopped"); break; } - fprintf(stderr, "\n"); + fprintf(file, "\n"); fprintf(file, "History list length %lu\n", === modified file 'unittest/gunit/sql_list-t.cc' --- a/unittest/gunit/sql_list-t.cc 2011-12-20 09:51:05 +0000 +++ b/unittest/gunit/sql_list-t.cc 2012-02-15 13:57:17 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -142,16 +142,16 @@ TEST_F(SqlListTest, DeepCopy) { int values[] = {11, 22, 33, 42, 5}; insert_values(values, &m_int_list); - MEM_ROOT *mem_root= (MEM_ROOT*) malloc(1 << 20); - init_alloc_root(mem_root, 4096, 4096); - List list_copy(m_int_list, mem_root); + MEM_ROOT mem_root; + init_alloc_root(&mem_root, 4096, 4096); + List list_copy(m_int_list, &mem_root); EXPECT_EQ(list_copy.elements, m_int_list.elements); while (!list_copy.is_empty()) { EXPECT_EQ(*m_int_list.pop(), *list_copy.pop()); } EXPECT_TRUE(m_int_list.is_empty()); - free(mem_root); + free_root(&mem_root, MYF(0)); } @@ -175,7 +175,7 @@ TEST_F(SqlListTest, Iterate) // A simple helper class for testing intrusive lists. -class Linked_node : public ilink +class Linked_node : public ilink { public: Linked_node(int val) : m_value(val) {} @@ -183,6 +183,7 @@ public: private: int m_value; }; +const Linked_node * const null_node= NULL; // An example of a test without any fixture. @@ -191,17 +192,17 @@ TEST(SqlIlistTest, ConstructAndDestruct) I_List i_list; I_List_iterator i_list_iter(i_list); EXPECT_TRUE(i_list.is_empty()); - const Linked_node *null_node= NULL; EXPECT_EQ(null_node, i_list_iter++); } // Tests iteration over intrusive lists. -TEST(SqlIlistTest, Iterate) +TEST(SqlIlistTest, PushBackAndIterate) { I_List i_list; I_List_iterator i_list_iter(i_list); int values[] = {11, 22, 33, 42, 5}; + EXPECT_EQ(null_node, i_list.head()); for (int ix= 0; ix < array_size(values); ++ix) { i_list.push_back(new Linked_node(values[ix])); @@ -213,6 +214,12 @@ TEST(SqlIlistTest, Iterate) { EXPECT_EQ(values[value_number++], node->get_value()); } + for (value_number= 0; (node= i_list.get()); ++value_number) + { + EXPECT_EQ(values[value_number], node->get_value()); + delete node; + } + EXPECT_EQ(array_size(values), value_number); } // Another iteration test over intrusive lists. @@ -232,6 +239,8 @@ TEST(SqlIlistTest, PushFrontAndIterate) { EXPECT_EQ(values[value_number--], node->get_value()); } + while ((node= i_list.get())) + delete node; } static int cmp_test(void *a, void *b, void *c) No bundle (reason: useless for push emails).