From c23c38fa31ff9f7350c342a3fb8142e04b10e121 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 May 2006 23:01:31 +0300 Subject: [PATCH 01/17] BUG#14157: utf8 encoding in binlog without set character_set_client e.g DROP temporary Binlog lacks encoding info about DROPped temporary table. Idea of the fix is to switch temporary to system_charset_info when a temporary table is DROPped for binlog. Since that is the server, that automatically, but not the client, who generates the query the binlog should be updated on the server's encoding for the coming DROP. The `write_binlog_with_system_charset()' is introduced to replace similar problematic places in the code. mysql-test/r/drop_temp_table.result: results changed mysql-test/r/mix_innodb_myisam_binlog.result: results changed mysql-test/r/mysqlbinlog.result: results changed mysql-test/r/rpl_temporary.result: results changed mysql-test/t/mysqlbinlog.test: Check roll-forward recovery from binlog where there are DROP temporary tables created in koi8r. mysql-test/t/rpl_temporary.test: Check slave digests binlog with DROP temporary tables created in koi8r. sql/mysql_priv.h: `write_binlog_with_system_charset()' is added to be called when a binlog event is created "implicitly" like DROP temporary table is case of closing connection. sql/sql_base.cc: Idea of the fix is to switch temporary to system_charset_info when a temporary table is DROPped for binlog. Since that is the server, not the client, who generates the query the binlog should be updated on server's encoding for the coming DROP. --- mysql-test/r/drop_temp_table.result | 1 + mysql-test/r/mix_innodb_myisam_binlog.result | 5 +++-- mysql-test/r/mysqlbinlog.result | 7 ++++++- mysql-test/r/rpl_temporary.result | 4 ++++ mysql-test/t/mysqlbinlog.test | 11 ++++++++++- mysql-test/t/rpl_temporary.test | 12 ++++++++++++ sql/mysql_priv.h | 7 +++++++ sql/sql_base.cc | 2 +- 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result index 5f1f142cde5..40afd621676 100644 --- a/mysql-test/r/drop_temp_table.result +++ b/mysql-test/r/drop_temp_table.result @@ -17,6 +17,7 @@ master-bin.000001 # Query 1 # create database `drop-temp+table-test` master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn1 (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table `table:name` (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn2 (a int) +master-bin.000001 # Query 1 # use `drop-temp+table-test`; SET ONE_SHOT CHARACTER_SET_CLIENT=33,COLLATION_CONNECTION=8,COLLATION_DATABASE=8,COLLATION_SERVER=8 master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1` master-bin.000001 # Query 1 # use `drop-temp+table-test`; DO RELEASE_LOCK("a") drop database `drop-temp+table-test`; diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index e9613bac833..8cf99e8d623 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -249,7 +249,8 @@ master-bin.000001 1056 Query 1 1056 use `test`; insert t0 select * from t1 master-bin.000001 1117 Query 1 1117 use `test`; DO RELEASE_LOCK("a") master-bin.000001 1172 Query 1 1172 use `test`; insert into t0 select GET_LOCK("lock1",null) master-bin.000001 1251 Query 1 1251 use `test`; create table t2 (n int) engine=innodb -master-bin.000001 1323 Query 1 1323 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` -master-bin.000001 1424 Query 1 1424 use `test`; DO RELEASE_LOCK("lock1") +master-bin.000001 1323 Query 1 1323 use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=33,COLLATION_CONNECTION=8,COLLATION_DATABASE=8,COLLATION_SERVER=8 +master-bin.000001 1457 Query 1 1457 use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` +master-bin.000001 1558 Query 1 1558 use `test`; DO RELEASE_LOCK("lock1") do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index adaf0dad56b..bade0ca9b46 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -101,4 +101,9 @@ HEX(f) select HEX(f) from t4; HEX(f) 835C -drop table t1, t2, t03, t04, t3, t4; +flush logs; +select * from t5 /* must be (1),(1) */; +a +1 +1 +drop table t1, t2, t03, t04, t3, t4, t5; diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index cd67d2592a8..8c6d3f232b1 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -103,3 +103,7 @@ select * from t1 /* must be 1 */; f 1 drop table t1; +select * from t1; +a +1 +drop table t1; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 871886331f6..11aa5814bda 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -114,8 +114,17 @@ select HEX(f) from t3; select HEX(f) from t04; select HEX(f) from t4; +# +#14157: utf8 encoding in binlog without set character_set_client +# +flush logs; +--exec $MYSQL --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t5 select * from `только герои срезают рашпилем грим`' + +# resulted log is client charset insensitive (latin1 not koi8r) as it must be +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 +select * from t5 /* must be (1),(1) */; # clean up -drop table t1, t2, t03, t04, t3, t4; +drop table t1, t2, t03, t04, t3, t4, t5; # End of 4.1 tests diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 71d7b32b7c9..af952760d6b 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -156,4 +156,16 @@ select * from t1 /* must be 1 */; connection master; drop table t1; +# +#14157: utf8 encoding in binlog without set character_set_client +# +--exec $MYSQL --default-character-set=koi8r test -e 'create table t1 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t1 select * from `только герои срезают рашпилем грим`' + +sync_slave_with_master; +#connection slave; +select * from t1; + +connection master; +drop table t1; + # End of 4.1 tests diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6676d994cfa..aab65bca82f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1275,6 +1275,13 @@ inline int hexchar_to_int(char c) return -1; } +inline void write_binlog_with_system_charset(THD * thd, Query_log_event * qinfo) +{ + CHARSET_INFO * cs_save= thd->variables.character_set_client; + thd->variables.character_set_client= system_charset_info; + mysql_bin_log.write(qinfo); + thd->variables.character_set_client= cs_save; +} /* Some functions that are different in the embedded library and the normal diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 60e91aff3f9..6365b8c8e40 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -615,7 +615,7 @@ void close_temporary_tables(THD *thd) rightfully causing the slave to stop. */ qinfo.error_code= 0; - mysql_bin_log.write(&qinfo); + write_binlog_with_system_charset(thd, &qinfo); } else { From 113b3f959e28a3156c987c3c049eafc751309519 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 May 2006 16:29:02 +0200 Subject: [PATCH 02/17] Bug#15886 (Test: Timing issue in test "rpl_until"): Changed format for SHOW SLAVE STATUS to vertical output. mysql-test/r/rpl_until.result: Result change mysql-test/t/rpl_until.test: Changed format for SHOW SLAVE STATUS to vertical output --- mysql-test/r/rpl_until.result | 148 +++++++++++++++++++++++++++++++--- mysql-test/t/rpl_until.test | 8 +- 2 files changed, 140 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index b584e04ed57..60b956785ba 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -29,9 +29,40 @@ n 2 3 4 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 # No 0 0 319 # Master master-bin.000001 319 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 776 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 319 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-bin.000001 +Until_Log_Pos 319 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; n @@ -39,23 +70,116 @@ n 2 3 4 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 # No 0 0 319 # Master master-no-such-bin.000001 291 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 776 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 319 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-no-such-bin.000001 +Until_Log_Pos 291 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; select * from t2; n 1 2 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 # No 0 0 608 # Relay slave-relay-bin.000004 746 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 776 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 608 +Relay_Log_Space # +Until_Condition Relay +Until_Log_File slave-relay-bin.000004 +Until_Log_Pos 746 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=776; -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 776 # Master master-bin.000001 776 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 776 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 776 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-bin.000001 +Until_Log_Pos 776 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index e0ecf981fea..c404ea7e58b 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -31,7 +31,7 @@ wait_for_slave_to_stop; select * from t1; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # this should fail right after start start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; @@ -41,7 +41,7 @@ sleep 2; wait_for_slave_to_stop; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # try replicate all until second insert to t2; start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; @@ -50,7 +50,7 @@ wait_for_slave_to_stop; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # clean up start slave; @@ -67,7 +67,7 @@ wait_for_slave_to_stop; # here the sql slave thread should be stopped --replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004 --replace_column 1 # 9 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS #testing various error conditions --error 1277 From 7b4abb7caf1fab56603fbdf7b8e36fbee25efa96 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 May 2006 11:18:06 +0200 Subject: [PATCH 03/17] Bug#18818 configure: No longer finds OpenSSL on Mac OS X - Remove usage of $shrext_cmds variable - Test for libs using all known library file endings acinclude.m4: Remove the usage of $shrext_cmds. instead test for all the library file endings we currently know, that is .a .so .sl and .dylib --- acinclude.m4 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index c8cad48ff0b..102f869e0d4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -310,10 +310,11 @@ case $SYSTEM_TYPE in fi ;; *) - # Just to be safe, we test for ".so" anyway - eval shrexts=\"$shrext_cmds\" - if test \( -f "$mysql_zlib_dir/lib/libz.a" -o -f "$mysql_zlib_dir/lib/libz.so" -o \ - -f "$mysql_zlib_dir/lib/libz$shrexts" \) \ + # Test for libz using all known library file endings + if test \( -f "$mysql_zlib_dir/lib/libz.a" -o \ + -f "$mysql_zlib_dir/lib/libz.so" -o \ + -f "$mysql_zlib_dir/lib/libz.sl" -o \ + -f "$mysql_zlib_dir/lib/libz.dylib" \) \ -a -f "$mysql_zlib_dir/include/zlib.h"; then ZLIB_INCLUDES="-I$mysql_zlib_dir/include" ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz" @@ -968,7 +969,6 @@ AC_DEFUN([MYSQL_CHECK_VIO], [ AC_DEFUN([MYSQL_FIND_OPENSSL], [ incs="$1" libs="$2" - eval shrexts=\"$shrext_cmds\" case "$incs---$libs" in ---) for d in /usr/ssl/include /usr/local/ssl/include /usr/include \ @@ -982,8 +982,9 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \ /usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \ /usr/freeware/lib32 /usr/local/lib/ ; do - # Just to be safe, we test for ".so" anyway - if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrexts ; then + # Test for libssl using all known library file endings + if test -f $d/libssl.a || test -f $d/libssl.so || \ + test -f $d/libssl.sl || test -f $d/libssl.dylib ; then OPENSSL_LIB=$d fi done @@ -995,8 +996,9 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ if test -f $incs/openssl/ssl.h ; then OPENSSL_INCLUDE=-I$incs fi - # Just to be safe, we test for ".so" anyway - if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f "$libs/libssl$shrexts" ; then + # Test for libssl using all known library file endings + if test -f $libs/libssl.a || test -f $libs/libssl.so || \ + test -f $libs/libssl.sl || test -f $d/libssl.dylib ; then OPENSSL_LIB=$libs fi ;; From 07b431d1d81fa4ec2150c429578b65022cfab42d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 May 2006 11:29:31 +0200 Subject: [PATCH 04/17] Bug#18818 configure: No longer finds OpenSSL on Mac OS X - Remove usage of $shrext_cmds variable - Test for libs using all known library file endings config/ac-macros/openssl.m4: Remove the usage of $shrext_cmds. instead test for all the library file endings we currently know, that is .a .so .sl and .dylib config/ac-macros/zlib.m4: Remove the usage of $shrext_cmds. instead test for all the library file endings we currently know, that is .a .so .sl and .dylib --- config/ac-macros/openssl.m4 | 10 ++++++---- config/ac-macros/zlib.m4 | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/ac-macros/openssl.m4 b/config/ac-macros/openssl.m4 index a23c46eed00..af4305486a3 100644 --- a/config/ac-macros/openssl.m4 +++ b/config/ac-macros/openssl.m4 @@ -15,8 +15,9 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \ /usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \ /usr/freeware/lib32 /usr/local/lib/ ; do - # Just to be safe, we test for ".so" anyway - if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrext ; then + # Test for libssl using all known library file endings + if test -f $d/libssl.a || test -f $d/libssl.so || \ + test -f $d/libssl.sl || test -f $d/libssl.dylib ; then OPENSSL_LIB=$d fi done @@ -28,8 +29,9 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ if test -f $incs/openssl/ssl.h ; then OPENSSL_INCLUDE=-I$incs fi - # Just to be safe, we test for ".so" anyway - if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl$shrext ; then + # Test for libssl using all known library file endings + if test -f $d/libssl.a || test -f $d/libssl.so || \ + test -f $d/libssl.sl || test -f $d/libssl.dylib ; then OPENSSL_LIB=$libs fi ;; diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4 index c75bac58d7c..a01d13937ff 100644 --- a/config/ac-macros/zlib.m4 +++ b/config/ac-macros/zlib.m4 @@ -89,10 +89,11 @@ case $SYSTEM_TYPE in fi ;; *) - # Just to be safe, we test for ".so" anyway - eval shrexts=\"$shrext_cmds\" - if test \( -f "$mysql_zlib_dir/lib/libz.a" -o -f "$mysql_zlib_dir/lib/libz.so" -o \ - -f "$mysql_zlib_dir/lib/libz$shrext" \) \ + # Test for libz using all known library file endings + if test \( -f "$mysql_zlib_dir/lib/libz.a" -o \ + -f "$mysql_zlib_dir/lib/libz.so" -o \ + -f "$mysql_zlib_dir/lib/libz.sl" -o \ + -f "$mysql_zlib_dir/lib/libz.dylib" \) \ -a -f "$mysql_zlib_dir/include/zlib.h"; then ZLIB_INCLUDES="-I$mysql_zlib_dir/include" ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz" From c212cb25ede28515c588d52061e67286bd3bb7d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 May 2006 21:29:06 +0300 Subject: [PATCH 05/17] BUG#19188: incorrect temporary table name of DROP query in replication A pattern to generate binlog for DROPped temp table in close_temporary_tables was buggy: could not deal with a grave-accent-in-name table. The fix exploits `append_identifier()' for quoting and duplicating accents. mysql-test/r/rpl_temporary.result: results changed mysql-test/t/rpl_temporary.test: more correct internal table emulation; typo of @@session in bug#17263. sql/mysql_priv.h: bool is_user_table(TABLE * table) is added to answer wheather temporary table was created explicitly. sql/sql_base.cc: Utilizing `append_identifier' to quote. `close_temporary_tables' once again recoded I hope to become much simplier than previously. No-binlog branch is separated completely the rest that adopts String's methods. --- mysql-test/r/rpl_temporary.result | 13 ++- mysql-test/t/rpl_temporary.test | 15 ++- sql/mysql_priv.h | 12 +++ sql/sql_base.cc | 147 ++++++++++++++---------------- 4 files changed, 99 insertions(+), 88 deletions(-) diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index cd67d2592a8..0442109c016 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -89,14 +89,17 @@ f 7 drop table t1,t2; create temporary table t3 (f int); -set @session.pseudo_thread_id=100; +set @@session.pseudo_thread_id=100; create temporary table t101 (id int); create temporary table t102 (id int); -set @session.pseudo_thread_id=200; +set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `#not_user_table_prefixed_with_hash_sign_no_harm` (id int); -set @con1_id=connection_id(); -kill @con1_id; +create temporary table `t``201` (id int); +create temporary table `#sql_not_user_table202` (id int); +set @@session.pseudo_thread_id=300; +create temporary table t301 (id int); +create temporary table t302 (id int); +create temporary table `#sql_not_user_table303` (id int); create table t1(f int); insert into t1 values (1); select * from t1 /* must be 1 */; diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 71d7b32b7c9..e1dd1f32546 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -135,14 +135,19 @@ sync_with_master; # value was set up at the moment of temp table creation # connection con1; -set @session.pseudo_thread_id=100; +set @@session.pseudo_thread_id=100; create temporary table t101 (id int); create temporary table t102 (id int); -set @session.pseudo_thread_id=200; +set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `#not_user_table_prefixed_with_hash_sign_no_harm` (id int); -set @con1_id=connection_id(); -kill @con1_id; +create temporary table `t``201` (id int); +# emulate internal temp table not to come to binlog +create temporary table `#sql_not_user_table202` (id int); +set @@session.pseudo_thread_id=300; +create temporary table t301 (id int); +create temporary table t302 (id int); +create temporary table `#sql_not_user_table303` (id int); +disconnect con1; #now do something to show that slave is ok after DROP temp tables connection master; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6676d994cfa..634e7bad738 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1275,6 +1275,18 @@ inline int hexchar_to_int(char c) return -1; } +/* + is_user_table() + return true if the table was created explicitly +*/ + +inline bool is_user_table(TABLE * table) +{ + const char *name= table->real_name; + return strncmp(name, tmp_file_prefix, tmp_file_prefix_length); +} + + /* Some functions that are different in the embedded library and the normal diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 60e91aff3f9..3df9cbace78 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -493,118 +493,107 @@ static inline uint tmpkeyval(THD *thd, TABLE *table) void close_temporary_tables(THD *thd) { - TABLE *next, - *prev_table /* prev link is not maintained in TABLE's double-linked list */, - *table; - char *query= (gptr) 0, *end; - uint query_buf_size, max_names_len; - bool found_user_tables; - + TABLE *table; if (!thd->temporary_tables) return; - LINT_INIT(end); - query_buf_size= 50; // Enough for DROP ... TABLE IF EXISTS + if (!mysql_bin_log.is_open()) + { + for (table= thd->temporary_tables; table; table= table->next) + { + close_temporary(table, 1); + } + thd->temporary_tables= 0; + return; + } + TABLE *next, + *prev_table /* prev link is not maintained in TABLE's double-linked list */; + bool was_quote_show= true; /* to assume thd->options has OPTION_QUOTE_SHOW_CREATE */ + // Better add "if exists", in case a RESET MASTER has been done + const char stub[]= "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "; + uint stub_len= sizeof(stub) - 1; + char buf[256]; + memcpy(buf, stub, stub_len); + String s_query= String(buf, sizeof(buf), system_charset_info); + bool found_user_tables= false; + LINT_INIT(next); + /* insertion sort of temp tables by pseudo_thread_id to build ordered list of sublists of equal pseudo_thread_id */ - for (prev_table= thd->temporary_tables, - table= prev_table->next, - found_user_tables= (prev_table->real_name[0] != '#'); + + for (prev_table= thd->temporary_tables, table= prev_table->next; table; prev_table= table, table= table->next) { - TABLE *prev_sorted /* same as for prev_table */, - *sorted; - /* - table not created directly by the user is moved to the tail. - Fixme/todo: nothing (I checked the manual) prevents user to create temp - with `#' - */ - if (table->real_name[0] == '#') - continue; - else + TABLE *prev_sorted /* same as for prev_table */, *sorted; + if (is_user_table(table)) { - found_user_tables = 1; - } - for (prev_sorted= NULL, sorted= thd->temporary_tables; sorted != table; - prev_sorted= sorted, sorted= sorted->next) - { - if (sorted->real_name[0] == '#' || tmpkeyval(thd, sorted) > tmpkeyval(thd, table)) + if (!found_user_tables) + found_user_tables= true; + for (prev_sorted= NULL, sorted= thd->temporary_tables; sorted != table; + prev_sorted= sorted, sorted= sorted->next) { - /* move into the sorted part of the list from the unsorted */ - prev_table->next= table->next; - table->next= sorted; - if (prev_sorted) + if (!is_user_table(sorted) || + tmpkeyval(thd, sorted) > tmpkeyval(thd, table)) { - prev_sorted->next= table; + /* move into the sorted part of the list from the unsorted */ + prev_table->next= table->next; + table->next= sorted; + if (prev_sorted) + { + prev_sorted->next= table; + } + else + { + thd->temporary_tables= table; + } + table= prev_table; + break; } - else - { - thd->temporary_tables= table; - } - table= prev_table; - break; } } - } - /* - calc query_buf_size as max per sublists, one sublist per pseudo thread id. - Also stop at first occurence of `#'-named table that starts - all implicitly created temp tables - */ - for (max_names_len= 0, table=thd->temporary_tables; - table && table->real_name[0] != '#'; - table=table->next) + } + + /* We always quote db,table names though it is slight overkill */ + if (found_user_tables && + !(was_quote_show= (thd->options & OPTION_QUOTE_SHOW_CREATE))) { - uint tmp_names_len; - for (tmp_names_len= table->key_length + 1; - table->next && table->real_name[0] != '#' && - tmpkeyval(thd, table) == tmpkeyval(thd, table->next); - table=table->next) - { - /* - We are going to add 4 ` around the db/table names, so 1 might not look - enough; indeed it is enough, because table->key_length is greater (by 8, - because of server_id and thread_id) than db||table. - */ - tmp_names_len += table->next->key_length + 1; - } - if (tmp_names_len > max_names_len) max_names_len= tmp_names_len; + thd->options |= OPTION_QUOTE_SHOW_CREATE; } - /* allocate */ - if (found_user_tables && mysql_bin_log.is_open() && - (query = alloc_root(thd->mem_root, query_buf_size+= max_names_len))) - // Better add "if exists", in case a RESET MASTER has been done - end= strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "); - /* scan sorted tmps to generate sequence of DROP */ - for (table=thd->temporary_tables; table; table= next) + for (table= thd->temporary_tables; table; table= next) { - if (query // we might be out of memory, but this is not fatal - && table->real_name[0] != '#') + if (is_user_table(table)) { - char *end_cur; /* Set pseudo_thread_id to be that of the processed table */ thd->variables.pseudo_thread_id= tmpkeyval(thd, table); /* Loop forward through all tables within the sublist of common pseudo_thread_id to create single DROP query */ - for (end_cur= end; - table && table->real_name[0] != '#' && + for (s_query.length(stub_len); + table && is_user_table(table) && tmpkeyval(thd, table) == thd->variables.pseudo_thread_id; table= next) { - end_cur= strxmov(end_cur, "`", table->table_cache_key, "`.`", - table->real_name, "`,", NullS); + /* + We are going to add 4 ` around the db/table names and possible more + due to special characters in the names + */ + append_identifier(thd, &s_query, table->table_cache_key, strlen(table->table_cache_key)); + s_query.q_append('.'); + append_identifier(thd, &s_query, table->real_name, + strlen(table->real_name)); + s_query.q_append(','); next= table->next; close_temporary(table, 1); } thd->clear_error(); - /* The -1 is to remove last ',' */ - Query_log_event qinfo(thd, query, (ulong)(end_cur - query) - 1, 0, FALSE); + Query_log_event qinfo(thd, s_query.ptr(), + s_query.length() - 1 /* to remove trailing ',' */, + 0, FALSE); /* Imagine the thread had created a temp table, then was doing a SELECT, and the SELECT was killed. Then it's not clever to mark the statement above as @@ -623,6 +612,8 @@ void close_temporary_tables(THD *thd) close_temporary(table, 1); } } + if (!was_quote_show) + thd->options &= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */ thd->temporary_tables=0; } From 62be79a2e6208873240fb0a3dafbb99f24c9e577 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 May 2006 12:14:20 +0300 Subject: [PATCH 06/17] BUG#14157: utf8 encoding in binlog without set character_set_client fixing a path to find charset by $MYSQL client. I believe the fix is done what should be by default. mysql-test/t/mysqlbinlog.test: --character-sets-dir=../sql/share/charsets is added otherwise client/.libs/lt-mysql searches in /usr/local/mysql ... A bug? mysql-test/t/rpl_temporary.test: --character-sets-dir=../sql/share/charsets/ --- mysql-test/t/mysqlbinlog.test | 2 +- mysql-test/t/rpl_temporary.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 11aa5814bda..7b6c36bb8c9 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -118,7 +118,7 @@ select HEX(f) from t4; #14157: utf8 encoding in binlog without set character_set_client # flush logs; ---exec $MYSQL --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t5 select * from `только герои срезают рашпилем грим`' +--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t5 select * from `только герои срезают рашпилем грим`' # resulted log is client charset insensitive (latin1 not koi8r) as it must be --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 1276b635b74..609e8533849 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -164,7 +164,7 @@ drop table t1; # #14157: utf8 encoding in binlog without set character_set_client # ---exec $MYSQL --default-character-set=koi8r test -e 'create table t1 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t1 select * from `только герои срезают рашпилем грим`' +--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table t1 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t1 select * from `только герои срезают рашпилем грим`' sync_slave_with_master; #connection slave; From d388da989e538cfd68a1d606f7e4d109a0263906 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 May 2006 20:09:09 +0300 Subject: [PATCH 07/17] BUG#14157: utf8 encoding in binlog without set character_set_client fixing names length. Got an issue when merged to 5.0, decided to fix starting from 4.1 mysql-test/t/mysqlbinlog.test: fixing temp table name to fit to 64 bytes for 5.0 mysql-test/t/rpl_temporary.test: fixing temp table name to fit to 64 bytes for 5.0 --- mysql-test/t/mysqlbinlog.test | 2 +- mysql-test/t/rpl_temporary.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 7b6c36bb8c9..6e3daaef0c3 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -118,7 +118,7 @@ select HEX(f) from t4; #14157: utf8 encoding in binlog without set character_set_client # flush logs; ---exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t5 select * from `только герои срезают рашпилем грим`' +--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `ящик` (a int); insert into `ящик` values (1); insert into t5 select * from `ящик`' # resulted log is client charset insensitive (latin1 not koi8r) as it must be --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 609e8533849..871ff096476 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -164,7 +164,7 @@ drop table t1; # #14157: utf8 encoding in binlog without set character_set_client # ---exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table t1 (a int); set names koi8r; create temporary table `только герои срезают рашпилем грим` (a int); insert into `только герои срезают рашпилем грим` values (1); insert into t1 select * from `только герои срезают рашпилем грим`' +--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table t1 (a int); set names koi8r; create temporary table `ящик` (a int); insert into `ящик` values (1); insert into t1 select * from `ящик`' sync_slave_with_master; #connection slave; From b9558d8bdaf68c923d2f9940b37eb161fd116e73 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 14 May 2006 20:31:42 +0300 Subject: [PATCH 08/17] BUG#19188: incorrect temporary table name of DROP query in replication manual merge to account 5.0 specific names of TABLE class sql/mysql_priv.h: manual merge: changing to 5.0's TABLE class names sql/sql_base.cc: manual merge: whitespaces and 5.0 TABLE's names --- sql/mysql_priv.h | 2 +- sql/sql_base.cc | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9aa5c3e41d5..776c23a21a6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1602,7 +1602,7 @@ inline void write_binlog_with_system_charset(THD * thd, Query_log_event * qinfo) inline bool is_user_table(TABLE * table) { - const char *name= table->real_name; + const char *name= table->s->table_name; return strncmp(name, tmp_file_prefix, tmp_file_prefix_length); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f0480a1c616..b6694edea78 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -620,7 +620,7 @@ void close_temporary_tables(THD *thd) TABLE *table; if (!thd->temporary_tables) return; - + if (!mysql_bin_log.is_open()) { for (table= thd->temporary_tables; table; table= table->next) @@ -642,12 +642,12 @@ void close_temporary_tables(THD *thd) String s_query= String(buf, sizeof(buf), system_charset_info); bool found_user_tables= false; LINT_INIT(next); - - /* - insertion sort of temp tables by pseudo_thread_id to build ordered list + + /* + insertion sort of temp tables by pseudo_thread_id to build ordered list of sublists of equal pseudo_thread_id */ - + for (prev_table= thd->temporary_tables, table= prev_table->next; table; prev_table= table, table= table->next) @@ -657,7 +657,7 @@ void close_temporary_tables(THD *thd) { if (!found_user_tables) found_user_tables= true; - for (prev_sorted= NULL, sorted= thd->temporary_tables; sorted != table; + for (prev_sorted= NULL, sorted= thd->temporary_tables; sorted != table; prev_sorted= sorted, sorted= sorted->next) { if (!is_user_table(sorted) || @@ -666,7 +666,7 @@ void close_temporary_tables(THD *thd) /* move into the sorted part of the list from the unsorted */ prev_table->next= table->next; table->next= sorted; - if (prev_sorted) + if (prev_sorted) { prev_sorted->next= table; } @@ -687,11 +687,11 @@ void close_temporary_tables(THD *thd) { thd->options |= OPTION_QUOTE_SHOW_CREATE; } - + /* scan sorted tmps to generate sequence of DROP */ for (table= thd->temporary_tables; table; table= next) { - if (is_user_table(table)) + if (is_user_table(table)) { /* Set pseudo_thread_id to be that of the processed table */ thd->variables.pseudo_thread_id= tmpkeyval(thd, table); @@ -706,10 +706,10 @@ void close_temporary_tables(THD *thd) We are going to add 4 ` around the db/table names and possible more due to special characters in the names */ - append_identifier(thd, &s_query, table->table_cache_key, strlen(table->table_cache_key)); + append_identifier(thd, &s_query, table->s->db, strlen(table->s->db)); s_query.q_append('.'); - append_identifier(thd, &s_query, table->real_name, - strlen(table->real_name)); + append_identifier(thd, &s_query, table->s->table_name, + strlen(table->s->table_name)); s_query.q_append(','); next= table->next; close_temporary(table, 1); @@ -730,7 +730,7 @@ void close_temporary_tables(THD *thd) qinfo.error_code= 0; write_binlog_with_system_charset(thd, &qinfo); } - else + else { next= table->next; close_temporary(table, 1); From e5838e160b989623c57f69a3fdb259b93467dcf6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 May 2006 14:18:23 +0400 Subject: [PATCH 09/17] BUG#19618: Crash for unsigned_col NOT IN (-1, ... ) - When manually constructing a SEL_TREE for "t.key NOT IN(...)", take into account that get_mm_parts may return a tree with type SEL_TREE::IMPOSSIBLE - Added missing OOM checks - Added comments mysql-test/r/func_in.result: Testcase for BUG#19618 mysql-test/t/func_in.test: Testcase for BUG#19618 --- mysql-test/r/func_in.result | 17 +++++++++ mysql-test/t/func_in.test | 12 +++++++ sql/opt_range.cc | 69 +++++++++++++++++++++++++++---------- 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index e3257ce5fd0..e38e2624e19 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -326,3 +326,20 @@ deallocate prepare s; set @str=NULL; drop table t2; drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +drop table t1; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 351d1fc2c92..8ddf1fbe314 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -220,3 +220,15 @@ set @str=NULL; drop table t2; drop table t1; +# BUG#19618: Crash in range optimizer for +# "unsigned_keypart NOT IN(negative_number,...)" +# (introduced in fix BUG#15872) +create table t1 ( + some_id smallint(5) unsigned, + key (some_id) +); +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +select some_id from t1 where some_id not in(-4,-1,-4); +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index fb4af4e7932..2a0b62ebaf0 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3530,17 +3530,38 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, if (!value_item) break; - /* Get a SEL_TREE for "-inf < X < c_0" interval */ - func->array->value_to_item(0, value_item); - tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - value_item, cmp_type); - if (!tree) + /* + Get a SEL_TREE for "(-inf|NULL) < X < c_0" interval. + Note: for partially-covering keys the returned tree may represent + a half-closed interval (-inf < X <= c_0). In that case the for the + whole NOT IN statement the (-inf < X < +inf) interval will be + constructed. It doesn't make sense to consider range access over + such intervals, but we don't eliminate them here as 1) they are + handled correctly by all parts of the code, and 2) the case where + such intervals are constructed is rare. + */ + uint i=0; + do + { + func->array->value_to_item(i, value_item); + tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, + value_item, cmp_type); + if (!tree) + break; + i++; + } while (i < func->array->count && tree->type == SEL_TREE::IMPOSSIBLE); + + if (!tree || tree->type == SEL_TREE::IMPOSSIBLE) + { + /* We get here in cases like "t.unsigned NOT IN (-1,-2,-3) */ + tree= NULL; break; + } #define NOT_IN_IGNORE_THRESHOLD 1000 SEL_TREE *tree2; if (func->array->count < NOT_IN_IGNORE_THRESHOLD) { - for (uint i=1; i < func->array->count; i++) + for (; i < func->array->count; i++) { if (func->array->compare_elems(i, i-1)) { @@ -3548,32 +3569,44 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, func->array->value_to_item(i, value_item); tree2= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, value_item, cmp_type); - + if (!tree2) + { + tree= NULL; + break; + } + /* Change all intervals to be "c_{i-1} < X < c_i" */ for (uint idx= 0; idx < param->keys; idx++) { - SEL_ARG *new_interval; - if ((new_interval= tree2->keys[idx])) + SEL_ARG *new_interval, *last_val; + if (((new_interval= tree2->keys[idx])) && + ((last_val= tree->keys[idx]->last()))) { - SEL_ARG *last_val= tree->keys[idx]->last(); new_interval->min_value= last_val->max_value; new_interval->min_flag= NEAR_MIN; } } + /* + The following doesn't try to allocate memory so no need to + check for NULL. + */ tree= tree_or(param, tree, tree2); } } } else func->array->value_to_item(func->array->count - 1, value_item); - - /* - Get the SEL_TREE for the last "c_last < X < +inf" interval - (value_item cotains c_last already) - */ - tree2= get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, - value_item, cmp_type); - tree= tree_or(param, tree, tree2); + + if (tree && tree->type != SEL_TREE::IMPOSSIBLE) + { + /* + Get the SEL_TREE for the last "c_last < X < +inf" interval + (value_item cotains c_last already) + */ + tree2= get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, + value_item, cmp_type); + tree= tree_or(param, tree, tree2); + } } else { From b6c7f5f2a80e6123f0106254c6c56af8f33f12d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 May 2006 18:05:23 +0300 Subject: [PATCH 10/17] BUG#14157: utf8 encoding in binlog without set character_set_client: e.g DROP temporary specific to 5.0 version of the patch is motivated by the fact that a wrapper over MYSQLLOG::write can not help in 5.0 where query's charset is embedded into event instance in the constructor. sql/mysql_priv.h: this 4.1 specific code does not help in 5.0 sql/sql_base.cc: No wrapper similar to 4.1's version is done since Query_log_event constructor takes care of encodings in 5.0 whereas log::write method does it in 4.1. We can introduce an additional constuctor for Query_log_event to pass desired (i.e system_character_info) charset different from THD's version. But I am delaying this while there are not more bugs similar to this one reported. --- sql/mysql_priv.h | 13 ------------- sql/sql_base.cc | 5 ++++- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 776c23a21a6..0290c0178e0 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1582,19 +1582,6 @@ inline int hexchar_to_int(char c) return -1; } -/* - wrapper to use instead of mysql_bin_log.write when - query is generated by the server using system_charset encoding -*/ - -inline void write_binlog_with_system_charset(THD * thd, Query_log_event * qinfo) -{ - CHARSET_INFO * cs_save= thd->variables.character_set_client; - thd->variables.character_set_client= system_charset_info; - mysql_bin_log.write(qinfo); - thd->variables.character_set_client= cs_save; -} - /* is_user_table() return true if the table was created explicitly diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b6694edea78..c83e847bc8a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -715,9 +715,12 @@ void close_temporary_tables(THD *thd) close_temporary(table, 1); } thd->clear_error(); + CHARSET_INFO *cs_save= thd->variables.character_set_client; + thd->variables.character_set_client= system_charset_info; Query_log_event qinfo(thd, s_query.ptr(), s_query.length() - 1 /* to remove trailing ',' */, 0, FALSE); + thd->variables.character_set_client= cs_save; /* Imagine the thread had created a temp table, then was doing a SELECT, and the SELECT was killed. Then it's not clever to mark the statement above as @@ -728,7 +731,7 @@ void close_temporary_tables(THD *thd) rightfully causing the slave to stop. */ qinfo.error_code= 0; - write_binlog_with_system_charset(thd, &qinfo); + mysql_bin_log.write(&qinfo); } else { From bccff08cba9994f12acf52e6aa960c32e949dd9d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 May 2006 09:26:57 +0200 Subject: [PATCH 11/17] Fixed result file (rpl_temporary) mysql-test/r/rpl_temporary.result: Fixed result file --- mysql-test/r/rpl_temporary.result | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index da85ef5104d..751dc7754f7 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -103,15 +103,24 @@ f 1 drop temporary table t4; drop table t5; -set @session.pseudo_thread_id=100; +set @@session.pseudo_thread_id=100; create temporary table t101 (id int); create temporary table t102 (id int); -set @session.pseudo_thread_id=200; +set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `#not_user_table_prefixed_with_hash_sign_no_harm` (id int); +create temporary table `t``201` (id int); +create temporary table `#sql_not_user_table202` (id int); +set @@session.pseudo_thread_id=300; +create temporary table t301 (id int); +create temporary table t302 (id int); +create temporary table `#sql_not_user_table303` (id int); create table t1(f int); insert into t1 values (1); select * from t1 /* must be 1 */; f 1 drop table t1; +select * from t1; +a +1 +drop table t1; From 808f77f6b003bbd225c21905b0f204bbcb61d457 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 May 2006 10:01:07 +0200 Subject: [PATCH 12/17] Test used a charset not available on many platforms --- mysql-test/r/mysqlbinlog.result | 6 +----- mysql-test/t/mysqlbinlog.test | 15 ++++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index c3be791b523..664833fab2a 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -190,8 +190,4 @@ select HEX(f) from t4; HEX(f) 835C flush logs; -select * from t5 /* must be (1),(1) */; -a -1 -1 -drop table t1, t2, t03, t04, t3, t4, t5; +drop table t1, t2, t03, t04, t3, t4; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 843536e956d..d74bb1c3a80 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -123,16 +123,21 @@ select HEX(f) from t04; select HEX(f) from t4; # -#14157: utf8 encoding in binlog without set character_set_client +# BUG#14157: utf8 encoding in binlog without set character_set_client +# +# BUG: +# This test only works on the MySQL-internal rpl machines. +# Needs to be fixed. Problem is that koi8r is not installed +# on many machines. # flush logs; ---exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `ящик` (a int); insert into `ящик` values (1); insert into t5 select * from `ящик`' +# --exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `ящик` (a int); insert into `ящик` values (1); insert into t5 select * from `ящик`' # resulted log is client charset insensitive (latin1 not koi8r) as it must be ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 -select * from t5 /* must be (1),(1) */; +# --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 +#select * from t5 /* must be (1),(1) */; # clean up -drop table t1, t2, t03, t04, t3, t4, t5; +drop table t1, t2, t03, t04, t3, t4; # End of 5.0 tests From 545ce857953f7c31c3ef8009889671dec5b7cc2a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 May 2006 13:39:03 +0400 Subject: [PATCH 13/17] BUG#19618: post-review fixes: better comments --- sql/opt_range.cc | 60 +++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2a0b62ebaf0..e36932cbc0c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3503,17 +3503,46 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, if (inv) { - /* - We get here for conditions like "t.keypart NOT IN (....)". - - If the IN-list contains only constants (and func->array is an ordered - array of them), we construct the appropriate SEL_ARG tree manually, - because constructing it using the range analyzer (as - AND_i( t.keypart != c_i)) will cause lots of memory to be consumed - (see BUG#15872). - */ if (func->array && func->cmp_type != ROW_RESULT) { + /* + We get here for conditions in form "t.key NOT IN (c1, c2, ...)" + (where c{i} are constants). + Our goal is to produce a SEL_ARG graph that represents intervals: + + ($MINmem_root; + param->thd->mem_root= param->old_root; /* Create one Item_type constant object. We'll need it as get_mm_parts only accepts constant values wrapped in Item_Type @@ -3522,24 +3551,13 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, per-statement mem_root (while thd->mem_root is currently pointing to mem_root local to range optimizer). */ - MEM_ROOT *tmp_root= param->mem_root; - param->thd->mem_root= param->old_root; Item *value_item= func->array->create_item(); param->thd->mem_root= tmp_root; if (!value_item) break; - /* - Get a SEL_TREE for "(-inf|NULL) < X < c_0" interval. - Note: for partially-covering keys the returned tree may represent - a half-closed interval (-inf < X <= c_0). In that case the for the - whole NOT IN statement the (-inf < X < +inf) interval will be - constructed. It doesn't make sense to consider range access over - such intervals, but we don't eliminate them here as 1) they are - handled correctly by all parts of the code, and 2) the case where - such intervals are constructed is rare. - */ + /* Get a SEL_TREE for "(-inf|NULL) < X < c_0" interval. */ uint i=0; do { From 5c5c5e750150a05828a53e583fa9db0283d3864a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 May 2006 13:59:37 +0200 Subject: [PATCH 14/17] BUG#18818 configure: No longer finds OpenSSL on Mac OS X - Implement new switch --with-ssl to configure used for both bundled yaSSL or OpenSSL BitKeeper/deleted/.del-yassl.m4~e55e55c1e863abaf: Delete: config/ac-macros/yassl.m4 BitKeeper/deleted/.del-openssl.m4~41cebd0ba8281769: Delete: config/ac-macros/openssl.m4 BUILD/SETUP.sh: Use switch --with-ssl to configure BUILD/compile-pentium-debug-openssl: Use switch --with-ssl to configure BUILD/compile-pentium-debug-yassl: Use switch --with-ssl to configure configure.in: Change to use the MYSQL_CHECK_SSL macro from ssl.m4 config/ac-macros/ssl.m4: New BitKeeper file ``config/ac-macros/ssl.m4'' --- BUILD/SETUP.sh | 7 +- BUILD/compile-pentium-debug-openssl | 2 +- BUILD/compile-pentium-debug-yassl | 2 +- config/ac-macros/openssl.m4 | 138 ------------------- config/ac-macros/ssl.m4 | 200 ++++++++++++++++++++++++++++ config/ac-macros/yassl.m4 | 45 ------- configure.in | 6 +- 7 files changed, 209 insertions(+), 191 deletions(-) delete mode 100644 config/ac-macros/openssl.m4 create mode 100644 config/ac-macros/ssl.m4 delete mode 100644 config/ac-macros/yassl.m4 diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 589e609beeb..02d160158b3 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -82,8 +82,11 @@ path=`dirname $0` export AM_MAKEFLAGS AM_MAKEFLAGS="-j 4" -# SSL library to use. -SSL_LIBRARY=--with-yassl +# SSL library to use.--with-ssl will select our bundled yaSSL +# implementation of SSL. To use openSSl you will nee too point out +# the location of openSSL headers and lbs on your system. +# Ex --with-ssl=/usr +SSL_LIBRARY=--with-ssl if [ "x$warning_mode" != "xpedantic" ]; then # Both C and C++ warnings diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl index 91c3b448c7e..2e24dbfd2f1 100755 --- a/BUILD/compile-pentium-debug-openssl +++ b/BUILD/compile-pentium-debug-openssl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-openssl" +extra_configs="$extra_configs --with-debug=full --with-ssl=/usr" . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-debug-yassl b/BUILD/compile-pentium-debug-yassl index 84ca489903d..61ad2937c4a 100755 --- a/BUILD/compile-pentium-debug-yassl +++ b/BUILD/compile-pentium-debug-yassl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-yassl" +extra_configs="$extra_configs --with-debug=full --with-ssl" . "$path/FINISH.sh" diff --git a/config/ac-macros/openssl.m4 b/config/ac-macros/openssl.m4 deleted file mode 100644 index af4305486a3..00000000000 --- a/config/ac-macros/openssl.m4 +++ /dev/null @@ -1,138 +0,0 @@ -AC_DEFUN([MYSQL_FIND_OPENSSL], [ - incs="$1" - libs="$2" - eval shrexts=\"$shrext_cmds\" - case "$incs---$libs" in - ---) - for d in /usr/ssl/include /usr/local/ssl/include /usr/include \ -/usr/include/ssl /opt/ssl/include /opt/openssl/include \ -/usr/local/ssl/include /usr/local/include /usr/freeware/include ; do - if test -f $d/openssl/ssl.h ; then - OPENSSL_INCLUDE=-I$d - fi - done - - for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \ -/usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \ -/usr/freeware/lib32 /usr/local/lib/ ; do - # Test for libssl using all known library file endings - if test -f $d/libssl.a || test -f $d/libssl.so || \ - test -f $d/libssl.sl || test -f $d/libssl.dylib ; then - OPENSSL_LIB=$d - fi - done - ;; - ---* | *---) - AC_MSG_ERROR([if either 'includes' or 'libs' is specified, both must be specified]) - ;; - * ) - if test -f $incs/openssl/ssl.h ; then - OPENSSL_INCLUDE=-I$incs - fi - # Test for libssl using all known library file endings - if test -f $d/libssl.a || test -f $d/libssl.so || \ - test -f $d/libssl.sl || test -f $d/libssl.dylib ; then - OPENSSL_LIB=$libs - fi - ;; - esac - - # On RedHat 9 we need kerberos to compile openssl - for d in /usr/kerberos/include - do - if test -f $d/krb5.h ; then - OPENSSL_KERBEROS_INCLUDE="$d" - fi - done - - - if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then - echo "Could not find an installation of OpenSSL" - if test -n "$OPENSSL_LIB" ; then - if test "$TARGET_LINUX" = "true"; then - echo "Looks like you've forgotten to install OpenSSL development RPM" - fi - fi - exit 1 - fi - -]) - -AC_DEFUN([MYSQL_CHECK_OPENSSL], [ -AC_MSG_CHECKING(for OpenSSL) - AC_ARG_WITH([openssl], - [ --with-openssl[=DIR] Include the OpenSSL support], - [openssl="$withval"], - [openssl=no]) - - AC_ARG_WITH([openssl-includes], - [ - --with-openssl-includes=DIR - Find OpenSSL headers in DIR], - [openssl_includes="$withval"], - [openssl_includes=""]) - - AC_ARG_WITH([openssl-libs], - [ - --with-openssl-libs=DIR - Find OpenSSL libraries in DIR], - [openssl_libs="$withval"], - [openssl_libs=""]) - - if test "$openssl" != "no" - then - if test "$openssl" != "yes" - then - if test -z "$openssl_includes" - then - openssl_includes="$openssl/include" - fi - if test -z "$openssl_libs" - then - openssl_libs="$openssl/lib" - fi - fi - MYSQL_FIND_OPENSSL([$openssl_includes], [$openssl_libs]) - #force VIO use - AC_MSG_RESULT(yes) - openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto" - # Don't set openssl_includes to /usr/include as this gives us a lot of - # compiler warnings when using gcc 3.x - openssl_includes="" - if test "$OPENSSL_INCLUDE" != "-I/usr/include" - then - openssl_includes="$OPENSSL_INCLUDE" - fi - if test "$OPENSSL_KERBEROS_INCLUDE" - then - openssl_includes="$openssl_includes -I$OPENSSL_KERBEROS_INCLUDE" - fi - AC_DEFINE([HAVE_OPENSSL], [1], [OpenSSL]) - - # openssl-devel-0.9.6 requires dlopen() and we can't link staticly - # on many platforms (We should actually test this here, but it's quite - # hard) to do as we are doing libtool for linking. - using_static="" - case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in - *-all-static*) using_static="yes" ;; - esac - if test "$using_static" = "yes" - then - echo "You can't use the --all-static link option when using openssl." - exit 1 - fi - NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs" - else - AC_MSG_RESULT(no) - if test ! -z "$openssl_includes" - then - AC_MSG_ERROR(Can't have --with-openssl-includes without --with-openssl); - fi - if test ! -z "$openssl_libs" - then - AC_MSG_ERROR(Can't have --with-openssl-libs without --with-openssl); - fi - fi - AC_SUBST(openssl_libs) - AC_SUBST(openssl_includes) -]) diff --git a/config/ac-macros/ssl.m4 b/config/ac-macros/ssl.m4 new file mode 100644 index 00000000000..14f3dcc9bc8 --- /dev/null +++ b/config/ac-macros/ssl.m4 @@ -0,0 +1,200 @@ +dnl =========================================================================== +dnl Support for SSL +dnl =========================================================================== +dnl +dnl + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_USE_BUNDLED_YASSL +dnl +dnl SYNOPSIS +dnl MYSQL_USE_BUNDLED_YASSL() +dnl +dnl DESCRIPTION +dnl Add defines so yassl is built and linked with +dnl --------------------------------------------------------------------------- +AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [ + + AC_CONFIG_FILES(extra/yassl/Makefile dnl + extra/yassl/taocrypt/Makefile dnl + extra/yassl/taocrypt/benchmark/Makefile dnl + extra/yassl/taocrypt/src/Makefile dnl + extra/yassl/taocrypt/test/Makefile dnl + extra/yassl/src/Makefile dnl + extra/yassl/testsuite/Makefile) + + with_yassl="yes" + + yassl_dir="yassl" + AC_SUBST([yassl_dir]) + + yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt" + AC_SUBST(yassl_libs) + yassl_includes="-I\$(top_srcdir)/extra/yassl/include" + AC_SUBST(yassl_includes) + + AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for SSL.]) + AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for SSL.]) + + # System specific checks + yassl_integer_extra_cxxflags="" + case $host_cpu--$CXX_VERSION in + sparc*--*Sun*C++*5.6*) + # Disable inlining when compiling taocrypt/src/ + yassl_taocrypt_extra_cxxflags="+d" + AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/]) + ;; + esac + AC_SUBST([yassl_taocrypt_extra_cxxflags]) + + # Link extra/yassl/include/openssl subdir to include/ + yassl_h_ln_cmd="\$(LN) -s \$(top_srcdir)/extra/yassl/include/openssl openssl" + AC_SUBST(yassl_h_ln_cmd) + + AC_MSG_RESULT([using bundled yaSSL]) +]) + + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_CHECK_SSL_DIR +dnl +dnl SYNOPSIS +dnl MYSQL_CHECK_SSL_DIR(includes, libs) +dnl +dnl DESCRIPTION +dnl Auxiliary macro to check for ssl at given path +dnl +dnl --------------------------------------------------------------------------- + +AC_DEFUN([MYSQL_CHECK_SSL_DIR], [ +ssl_incs="$1" +ssl_libs="$2" +save_CPPFLAGS="$CPPFLAGS" +save_LIBS="$LIBS" +CPPFLAGS="$ssl_incs $CPPFLAGS" +LIBS="$LIBS $ssl_libs" +AC_TRY_LINK([#include ], + [return SSL_library_init();], + [mysql_ssl_found="yes"], + [mysql_ssl_found="no"]) +CPPFLAGS="$save_CPPFLAGS" +LIBS="$save_LIBS" +]) + + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_FIND_OPENSSL +dnl +dnl SYNOPSIS +dnl MYSQL_FIND_OPENSSL(location) +dnl +dnl DESCRIPTION +dnl Search the location for OpenSSL support +dnl +dnl --------------------------------------------------------------------------- +AC_DEFUN([MYSQL_FIND_OPENSSL], [ + location="$1" + + # + # Set include paths + # + openssl_include="$location/include" + openssl_includes="" + + # Don't set ssl_includes to /usr/include as this gives us a lot of + # compiler warnings when using gcc 3.x + if test "$openssl_include" != "/usr/include" + then + openssl_includes="-I$ssl_include" + fi + + # + # Try to link with openSSL libs in + # + openssl_libs="-L$location/lib/ -lssl -lcrypto" + MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs]) + + if test "$mysql_ssl_found" == "no" + then + # + # BUG 764: Compile failure with OpenSSL on Red Hat Linux (krb5.h missing) + # Try to link with include paths to kerberos set + # + openssl_includes="$openssl_includes -I/usr/kerberos/include" + MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs]) + fi + + if test "$mysql_ssl_found" == "no" + then + AC_MSG_ERROR([Could not link with SSL libs at $location]) + fi + + # openssl-devel-0.9.6 requires dlopen() and we can't link staticly + # on many platforms (We should actually test this here, but it's quite + # hard to do as we are doing libtool for linking.) + case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in + *-all-static*) + AC_MSG_ERROR([You can't use the --all-static link option when using openssl.]) + ;; + esac + + AC_SUBST(openssl_includes) + AC_SUBST(openssl_libs) + + NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs" + + AC_DEFINE([HAVE_OPENSSL], [1], [OpenSSL]) + AC_MSG_RESULT([using openSSL from $location]) +]) + + + +dnl ------------------------------------------------------------------------ +dnl Macro: MYSQL_CHECK_SSL +dnl +dnl SYNOPSIS +dnl MYSQL_CHECK_SSL +dnl +dnl Provides the following configure options: +dnl --with-ssl=DIR +dnl Possible DIR values are: +dnl - no - the macro will disable use of ssl +dnl - bundled, empty or not specified - means use ssl lib +dnl bundled along with MySQL sources +dnl - ssl location prefix - given location prefix, the macro expects +dnl to find the header files in $prefix/include/, and libraries in +dnl $prefix/lib. If headers or libraries weren't found at $prefix, the +dnl macro bails out with error. +dnl +dnl ------------------------------------------------------------------------ +AC_DEFUN([MYSQL_CHECK_SSL], [ +AC_MSG_CHECKING(for SSL) + AC_ARG_WITH([ssl], + [ --with-ssl[=DIR] Include SSL support], + [mysql_ssl_dir="$withval"], + [mysql_ssl_dir=no]) + + case "$mysql_ssl_dir" in + "no") + # + # Don't include SSL support + # + AC_MSG_RESULT([disabled]) + ;; + + "bundled"|"yes") + # + # Use the bundled SSL implementation (yaSSL) + # + MYSQL_USE_BUNDLED_YASSL + ;; + + *) + # + # A location where to search for OpenSSL was specified + # + MYSQL_FIND_OPENSSL([$mysql_ssl_dir]) + ;; + esac + AM_CONDITIONAL([HAVE_YASSL], [ test "$with_yassl" = "yes" ]) +]) diff --git a/config/ac-macros/yassl.m4 b/config/ac-macros/yassl.m4 deleted file mode 100644 index f6eee32ff84..00000000000 --- a/config/ac-macros/yassl.m4 +++ /dev/null @@ -1,45 +0,0 @@ -AC_DEFUN([MYSQL_CHECK_YASSL], [ - AC_MSG_CHECKING(for yaSSL) - AC_ARG_WITH([yassl], [ --with-yassl Include the yaSSL support],,) - - if test "$with_yassl" = "yes" - then - if test "$openssl" != "no" - then - AC_MSG_ERROR([Cannot configure MySQL to use yaSSL and OpenSSL simultaneously.]) - fi - AC_MSG_RESULT([using bundled yaSSL]) - AC_CONFIG_FILES(extra/yassl/Makefile dnl - extra/yassl/taocrypt/Makefile dnl - extra/yassl/taocrypt/benchmark/Makefile dnl - extra/yassl/taocrypt/src/Makefile dnl - extra/yassl/taocrypt/test/Makefile dnl - extra/yassl/src/Makefile dnl - extra/yassl/testsuite/Makefile) - yassl_dir="yassl" - yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt" - yassl_includes="-I\$(top_srcdir)/extra/yassl/include" - AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.]) - AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.]) - # System specific checks - yassl_integer_extra_cxxflags="" - case $host_cpu--$CXX_VERSION in - sparc*--*Sun*C++*5.6*) - # Disable inlining when compiling taocrypt/src/ - yassl_taocrypt_extra_cxxflags="+d" - AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/]) - ;; - esac - AC_SUBST([yassl_taocrypt_extra_cxxflags]) - # Link extra/yassl/include/openssl subdir to include/ - yassl_h_ln_cmd="\$(LN) -s \$(top_srcdir)/extra/yassl/include/openssl openssl" - AC_SUBST(yassl_h_ln_cmd) - else - yassl_dir="" - AC_MSG_RESULT(no) - fi - AC_SUBST(yassl_libs) - AC_SUBST(yassl_includes) - AC_SUBST(yassl_dir) - AM_CONDITIONAL([HAVE_YASSL], [ test "$with_yassl" = "yes" ]) -]) diff --git a/configure.in b/configure.in index 4f356971a49..95d78faf287 100644 --- a/configure.in +++ b/configure.in @@ -36,10 +36,9 @@ sinclude(config/ac-macros/ha_berkeley.m4) sinclude(config/ac-macros/ha_ndbcluster.m4) sinclude(config/ac-macros/large_file.m4) sinclude(config/ac-macros/misc.m4) -sinclude(config/ac-macros/openssl.m4) sinclude(config/ac-macros/readline.m4) sinclude(config/ac-macros/replication.m4) -sinclude(config/ac-macros/yassl.m4) +sinclude(config/ac-macros/ssl.m4) sinclude(config/ac-macros/zlib.m4) # Remember to add a directory sql/share/LANGUAGE @@ -2203,8 +2202,7 @@ MYSQL_CHECK_BIG_TABLES MYSQL_CHECK_MAX_INDEXES MYSQL_CHECK_REPLICATION MYSQL_CHECK_VIO -MYSQL_CHECK_OPENSSL -MYSQL_CHECK_YASSL +MYSQL_CHECK_SSL #-------------------------------------------------------------------- # Declare our plugin modules From 127d73abaae4484a17342fc0462d0817f592df15 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 May 2006 18:11:54 +0200 Subject: [PATCH 15/17] Fix "glibc detected double free" Remove extra call to vio_end sql/mysqld.cc: Remove the second call to vio_end as it should only be called once when the server shutdown. --- sql/mysqld.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f3f4d699302..3cca41fa0e5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2974,7 +2974,6 @@ static void end_ssl() ssl_acceptor_fd= 0; } #endif /* HAVE_OPENSSL */ - vio_end(); } From 495e1080e63f9ace8e6508cf769ce0ee02db8cbc Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 May 2006 21:40:52 +0200 Subject: [PATCH 16/17] After merge fixes --- mysql-test/r/rpl_stm_until.result | 18 +++++++++--------- mysql-test/r/rpl_temporary.result | 1 - mysql-test/t/rpl_temporary.test | 2 +- sql/mysql_priv.h | 11 ----------- sql/sql_base.cc | 11 ++++++++--- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/mysql-test/r/rpl_stm_until.result b/mysql-test/r/rpl_stm_until.result index 6e55a939ac5..e8e33b66864 100644 --- a/mysql-test/r/rpl_stm_until.result +++ b/mysql-test/r/rpl_stm_until.result @@ -26,7 +26,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 776 +Read_Master_Log_Pos 780 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -41,11 +41,11 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 319 +Exec_Master_Log_Pos 323 Relay_Log_Space # Until_Condition Master Until_Log_File master-bin.000001 -Until_Log_Pos 319 +Until_Log_Pos 323 Master_SSL_Allowed No Master_SSL_CA_File Master_SSL_CA_Path @@ -67,7 +67,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 776 +Read_Master_Log_Pos 780 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -82,7 +82,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 319 +Exec_Master_Log_Pos 323 Relay_Log_Space # Until_Condition Master Until_Log_File master-no-such-bin.000001 @@ -106,7 +106,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 776 +Read_Master_Log_Pos 780 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -121,7 +121,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 608 +Exec_Master_Log_Pos 612 Relay_Log_Space # Until_Condition Relay Until_Log_File slave-relay-bin.000004 @@ -143,7 +143,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 776 +Read_Master_Log_Pos 780 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -158,7 +158,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 776 +Exec_Master_Log_Pos 780 Relay_Log_Space # Until_Condition Master Until_Log_File master-bin.000001 diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index c9f27a6953a..01882c683a4 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -93,7 +93,6 @@ create temporary table t101 (id int); create temporary table t102 (id int); set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `t``201` (id int); create temporary table `#sql_not_user_table202` (id int); set @@session.pseudo_thread_id=300; create temporary table t301 (id int); diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 3eeb00641b8..18280cedd9b 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -170,7 +170,7 @@ create temporary table t101 (id int); create temporary table t102 (id int); set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `t``201` (id int); +#create temporary table `t``201` (id int); # emulate internal temp table not to come to binlog create temporary table `#sql_not_user_table202` (id int); set @@session.pseudo_thread_id=300; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 28506284cac..5b9aaf9082e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1936,17 +1936,6 @@ inline int hexchar_to_int(char c) return -1; } -/* - is_user_table() - return true if the table was created explicitly -*/ - -inline bool is_user_table(TABLE * table) -{ - const char *name= table->s->table_name; - return strncmp(name, tmp_file_prefix, tmp_file_prefix_length); -} - /* Some functions that are different in the embedded library and the normal server diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2de6f0d3618..58c04224ac9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1183,7 +1183,13 @@ static inline uint tmpkeyval(THD *thd, TABLE *table) void close_temporary_tables(THD *thd) { - TABLE *table; + TABLE *next, + *prev_table /* prev link is not maintained in TABLE's double-linked list */, + *table; + char *query= (gptr) 0, *end; + uint query_buf_size, max_names_len; + bool found_user_tables; + if (!thd->temporary_tables) return; @@ -1283,7 +1289,7 @@ void close_temporary_tables(THD *thd) table= next) { end_cur= strxmov(end_cur, "`", table->s->db.str, "`.`", - table->s->table_name.str, "`,", NullS); + table->s->table_name.str, "`,", NullS); next= table->next; close_temporary(table, 1, 1); } @@ -1311,7 +1317,6 @@ void close_temporary_tables(THD *thd) thd->temporary_tables=0; } - /* Find table in list. From 5b5a5bef92688e9cbde1454d903641710ded525f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 May 2006 13:20:35 +0200 Subject: [PATCH 17/17] Change from --wioth-yassl to --with-ssl --- BUILD/compile-dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD/compile-dist b/BUILD/compile-dist index 99ddccf7f10..326de19da13 100755 --- a/BUILD/compile-dist +++ b/BUILD/compile-dist @@ -54,7 +54,7 @@ fi --with-federated-storage-engine \ --with-berkeley-db \ --with-innodb \ - --with-yassl \ + --with-ssl \ --enable-thread-safe-client \ --with-extra-charsets=complex \ --with-ndbcluster \