List:Commits« Previous MessageNext Message »
From:tim Date:January 18 2007 3:42pm
Subject:bk commit into 5.1 tree (tsmith:1.2405)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-01-18 08:41:52-07:00, tsmith@stripped +31 -0
  Merge siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/maint/50
  into  siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/maint/51
  MERGE: 1.1810.2368.49

  BUILD/check-cpu@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.13.1.5

  BitKeeper/deleted/.del-CMakeLists.txt~2f6eabb2f69cb33d@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.1.4.2

  BitKeeper/deleted/.del-CMakeLists.txt~2f6eabb2f69cb33d@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Merge rename: innobase/CMakeLists.txt -> BitKeeper/deleted/.del-CMakeLists.txt~2f6eabb2f69cb33d

  Makefile.am@stripped, 2007-01-18 08:37:18-07:00, tsmith@stripped +5 -0
    Use local
    MERGE: 1.68.1.26

  client/mysqltest.c@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.155.9.82

  include/my_global.h@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.96.1.36

  libmysql/libmysql.c@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.233.1.19

  mysql-test/Makefile.am@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.66.1.17

  mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test@stripped, 2007-01-18 08:40:15-07:00, tsmith@stripped +0 -10
    Use local
    MERGE: 1.20.4.2

  mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Merge rename: mysql-test/t/mix_innodb_myisam_binlog.test -> mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test

  mysql-test/lib/mtr_cases.pl@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -3
    Auto merged
    MERGE: 1.12.1.24

  mysql-test/lib/mtr_process.pl@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.25.2.22

  mysql-test/mysql-test-run.pl@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.30.49.47

  mysql-test/t/myisam.test@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.55.1.20

  mysql-test/t/mysql.test@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.4.1.21

  mysql-test/t/mysqladmin.test@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.3.1.1

  mysql-test/t/rpl_rotate_logs.test@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.63.1.4

  mysql-test/t/trigger.test@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.34.11.5

  mysys/mf_iocache.c@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.56.1.8

  mysys/my_read.c@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.13.1.3

  mysys/my_seek.c@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.11.1.8

  scripts/make_binary_distribution.sh@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.101.1.18

  scripts/mysqlbug.sh@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.8.1.1

  sql/field.cc@stripped, 2007-01-18 08:33:29-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.256.1.82

  sql/field.h@stripped, 2007-01-18 08:33:30-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.153.12.11

  sql/item_sum.h@stripped, 2007-01-18 08:33:30-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.102.1.8

  sql/mysqld.cc@stripped, 2007-01-18 08:41:27-07:00, tsmith@stripped +0 -3
    Use local
    MERGE: 1.439.1.149

  sql/opt_range.cc@stripped, 2007-01-18 08:33:30-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.159.1.78

  sql/sql_class.h@stripped, 2007-01-18 08:33:30-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.230.50.1

  sql/sql_parse.cc@stripped, 2007-01-18 08:33:31-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.426.131.2

  storage/myisam/mi_packrec.c@stripped, 2007-01-18 08:33:31-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.30.11.2

  storage/myisam/mi_packrec.c@stripped, 2007-01-18 08:33:28-07:00, tsmith@stripped +0 -0
    Merge rename: myisam/mi_packrec.c -> storage/myisam/mi_packrec.c

  strings/ctype-extra.c@stripped, 2007-01-18 08:41:46-07:00, tsmith@stripped +0 -0
    SCCS merged
    MERGE: 1.23.1.3

  tests/mysql_client_test.c@stripped, 2007-01-18 08:33:31-07:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.167.1.53

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tsmith
# Host:	siva.hindu.god
# Root:	/home/tsmith/m/bk/mrg-jan17/maint/51/RESYNC

--- 1.268/libmysql/libmysql.c	2007-01-10 03:06:17 -07:00
+++ 1.269/libmysql/libmysql.c	2007-01-18 08:33:28 -07:00
@@ -2036,6 +2036,13 @@
     DBUG_RETURN(1);
   }
 
+  /*
+    Reset the last error in any case: that would clear the statement
+    if the previous prepare failed.
+  */
+  stmt->last_errno= 0;
+  stmt->last_error[0]= '\0';
+
   if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
   {
     /* This is second prepare with another statement */
@@ -2049,23 +2056,24 @@
     */
     stmt->bind_param_done= stmt->bind_result_done= FALSE;
     stmt->param_count= stmt->field_count= 0;
-    stmt->last_errno= 0;
-    stmt->last_error[0]= '\0';
     free_root(&stmt->mem_root, MYF(MY_KEEP_PREALLOC));
 
     int4store(buff, stmt->stmt_id);
+
     /*
+      Close statement in server
+
       If there was a 'use' result from another statement, or from
       mysql_use_result it won't be freed in mysql_stmt_free_result and
       we should get 'Commands out of sync' here.
     */
+    stmt->state= MYSQL_STMT_INIT_DONE;
     if (stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt))
     {
       set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
                       mysql->net.sqlstate);
       DBUG_RETURN(1);
     }
-    stmt->state= MYSQL_STMT_INIT_DONE;
   }
 
   if (stmt_command(mysql, COM_STMT_PREPARE, query, length, stmt))

--- 1.30.11.1/myisam/mi_packrec.c	2007-01-17 04:14:31 -07:00
+++ 1.44/storage/myisam/mi_packrec.c	2007-01-18 08:33:31 -07:00
@@ -1481,56 +1481,33 @@
 static int _mi_read_mempack_record(MI_INFO *info,my_off_t filepos,byte *buf);
 static int _mi_read_rnd_mempack_record(MI_INFO*, byte *,my_off_t, my_bool);
 
-#ifndef MAP_NORESERVE
-#define MAP_NORESERVE 0		/* For irix */
-#endif
-#ifndef MAP_FAILED
-#define MAP_FAILED -1
-#endif
-
 my_bool _mi_memmap_file(MI_INFO *info)
 {
-  byte *file_map;
   MYISAM_SHARE *share=info->s;
   DBUG_ENTER("mi_memmap_file");
 
-  if (!share->file_map)
+  if (!info->s->file_map)
   {
-    my_off_t data_file_length= share->state.state.data_file_length;
-    if (data_file_length > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
-    {
-      DBUG_PRINT("warning", ("File is too large for mmap"));
-      DBUG_RETURN(0);
-    }
     if (my_seek(info->dfile,0L,MY_SEEK_END,MYF(0)) <
-        data_file_length + MEMMAP_EXTRA_MARGIN)
+        share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN)
     {
       DBUG_PRINT("warning",("File isn't extended for memmap"));
       DBUG_RETURN(0);
     }
-    file_map=(byte*)
-      my_mmap(0, (size_t) (data_file_length + MEMMAP_EXTRA_MARGIN), PROT_READ,
-              MAP_SHARED | MAP_NORESERVE, info->dfile, 0L);
-    if (file_map == (byte*) MAP_FAILED)
-    {
-      DBUG_PRINT("warning",("mmap failed: errno: %d",errno));
-      my_errno=errno;
+    if (mi_dynmap_file(info, share->state.state.data_file_length))
       DBUG_RETURN(0);
-    }
-    share->file_map= file_map;
   }
   info->opt_flag|= MEMMAP_USED;
-  info->read_record=share->read_record=_mi_read_mempack_record;
-  share->read_rnd=_mi_read_rnd_mempack_record;
+  info->read_record= share->read_record= _mi_read_mempack_record;
+  share->read_rnd= _mi_read_rnd_mempack_record;
   DBUG_RETURN(1);
 }
 
 
 void _mi_unmap_file(MI_INFO *info)
 {
-  VOID(my_munmap(info->s->file_map,
-	      (size_t) info->s->state.state.data_file_length+
-	      MEMMAP_EXTRA_MARGIN));
+  VOID(my_munmap(info->s->file_map, 
+                 (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
 }
 
 

--- 1.65/mysys/mf_iocache.c	2007-01-11 07:25:09 -07:00
+++ 1.66/mysys/mf_iocache.c	2007-01-18 08:33:29 -07:00
@@ -343,11 +343,7 @@
       if (info->type == READ_CACHE)
       {
 	info->write_end=info->write_buffer+info->buffer_length;
-        /*
-          Trigger a new seek only if we have a valid
-          file handle.
-        */
-        info->seek_not_done= (info->file >= 0);
+	info->seek_not_done=1;
       }
       info->end_of_file = ~(my_off_t) 0;
     }

--- 1.1.4.1/innobase/CMakeLists.txt	2007-01-15 08:15:39 -07:00
+++ 1.6/BitKeeper/deleted/.del-CMakeLists.txt~2f6eabb2f69cb33d	2007-01-18 08:33:28 -07:00
@@ -18,9 +18,39 @@
 ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB)
 
 # Bug#19424 - InnoDB: Possibly a memory overrun of the buffer being freed (64-bit Visual C)
-# Removing Win64 compiler optimizations for all innodb/mem/* files.
+# Removing Win64 compiler optimizations for all innodb files.
 IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
-	SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c 
+	SET_SOURCE_FILES_PROPERTIES(btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c 
+							 buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c 
+							 data/data0data.c data/data0type.c 
+							 dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c 
+							 dyn/dyn0dyn.c 
+							 eval/eval0eval.c eval/eval0proc.c 
+							 fil/fil0fil.c 
+							 fsp/fsp0fsp.c
+							 fut/fut0fut.c fut/fut0lst.c 
+							 ha/ha0ha.c ha/hash0hash.c 
+							 ibuf/ibuf0ibuf.c 
+							 pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c 
+							 lock/lock0lock.c
+							 log/log0log.c log/log0recv.c 
+							 mach/mach0data.c 
+							 mem/mem0mem.c mem/mem0pool.c 
+							 mtr/mtr0log.c mtr/mtr0mtr.c 
+							 os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c 
+							 page/page0cur.c page/page0page.c 
+							 que/que0que.c 
+							 read/read0read.c 
+							 rem/rem0cmp.c rem/rem0rec.c
+							 row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c 
+							 row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c 
+							 srv/srv0que.c srv/srv0srv.c srv/srv0start.c 
+							 sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c 
+							 thr/thr0loc.c 
+							 trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c 
+                             trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c 
+							 usr/usr0sess.c 
+							 ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c
 							 PROPERTIES COMPILE_FLAGS -Od)
 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
 
@@ -56,3 +86,7 @@
 					 usr/usr0sess.c 
 					 ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c )
 
+# (Bug#19424) Removing Win64 compiler optimizations innobase project.
+IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
+	SET_TARGET_PROPERTIES(innobase PROPERTIES COMPILE_FLAGS "/Od")
+ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")

--- 1.20.4.1/mysql-test/t/mix_innodb_myisam_binlog.test	2007-01-16 09:52:14 -07:00
+++ 1.32/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test	2007-01-18 08:40:15 -07:00
@@ -9,6 +9,7 @@
 -- source include/not_embedded.inc
 
 -- source include/have_innodb.inc
+-- source include/have_debug.inc
 
 --disable_warnings
 drop table if exists t1, t2;
@@ -28,9 +29,9 @@
 insert into t2 select * from t1;
 commit;
 
---replace_column 5 #
---replace_result "xid=14" "xid=8"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -42,8 +43,9 @@
 # should say some changes to non-transact1onal tables couldn't be rolled back
 rollback;
 
---replace_column 5 #
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -57,9 +59,9 @@
 rollback to savepoint my_savepoint;
 commit;
 
---replace_column 5 #
---replace_result "xid=47" "xid=25"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -75,9 +77,9 @@
 commit;
 select a from t1 order by a; # check that savepoints work :)
 
---replace_column 5 #
---replace_result "xid=69" "xid=37"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 # and when ROLLBACK is not explicit?
 delete from t1;
@@ -97,8 +99,9 @@
 # so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that
 # logging has been done, we use a user lock.
 select get_lock("a",10);
---replace_column 5 #
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 # and when not in a transact1on?
 delete from t1;
@@ -108,9 +111,9 @@
 insert into t1 values(9);
 insert into t2 select * from t1;
 
---replace_column 5 #
---replace_result "xid=117" "xid=60"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 # Check that when the query updat1ng the MyISAM table is the first in the
 # transaction, we log it immediately.
@@ -121,15 +124,15 @@
 insert into t1 values(10); # first make t1 non-empty
 begin;
 insert into t2 select * from t1;
---replace_column 5 #
---replace_result "xid=131" "xid=66"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 insert into t1 values(11);
 commit;
 
---replace_column 5 #
---replace_result "xid=131" "xid=66" "xid=134" "xid=68"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 
 # Check that things work like before this BEGIN/ROLLBACK code was added,
@@ -146,9 +149,9 @@
 insert into t2 select * from t1;
 commit;
 
---replace_column 5 #
---replace_result "xid=153" "xid=78"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -159,8 +162,9 @@
 insert into t2 select * from t1;
 rollback;
 
---replace_column 5 #
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -174,9 +178,9 @@
 rollback to savepoint my_savepoint;
 commit;
 
---replace_column 5 #
---replace_result "xid=185" "xid=94"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 delete from t1;
 delete from t2;
@@ -192,9 +196,9 @@
 commit;
 select a from t1 order by a; # check that savepoints work :)
 
---replace_column 5 #
---replace_result "xid=206" "xid=105"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 
 # Test for BUG#5714, where a MyISAM update in the transaction used to
 # release row-level locks in InnoDB
@@ -205,7 +209,7 @@
 delete from t1;
 delete from t2;
 --disable_warnings
-alter table t2 type=MyISAM;
+alter table t2 engine=MyISAM;
 --enable_warnings
 insert into t1 values (1);
 begin;
@@ -230,8 +234,8 @@
 drop table t1,t2;
 commit;
 
-# test for BUG#7947 - DO RELEASE_LOCK() not written to binlog on rollback in the middle
-# of a transaction
+# test for BUG#7947 - DO RELEASE_LOCK() not written to binlog on rollback in
+# the middle of a transaction
 
 connection con2;
 begin;
@@ -253,14 +257,77 @@
 disconnect con2;
 connection con3;
 select get_lock("lock1",60);
---replace_column 5 #
---replace_result "xid=206" "xid=105" "xid=224" "xid=114" "xid=227" "xid=115" "xid=231" "xid=117" "xid=258" "xid=132"
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
 do release_lock("lock1");
 drop table t0,t2;
 
 # End of 4.1 tests
 
+#
+# Test behaviour of CREATE ... SELECT when mixing MyISAM and InnoDB tables
+#
+
+set autocommit=0;
+CREATE TABLE t1 (a int, b int) engine=myisam;
+reset master;
+INSERT INTO t1 values (1,1),(1,2);
+--error 1062
+CREATE TABLE t2 (primary key (a)) engine=innodb select * from t1;
+# This should give warning
+DROP TABLE if exists t2;
+INSERT INTO t1 values (3,3);
+--error 1062
+CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+# This should give warning
+DROP TABLE IF EXISTS t2;
+
+CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
+INSERT INTO t1 VALUES (4,4);
+--error 1062
+CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+SELECT * from t2;
+TRUNCATE table t2;
+INSERT INTO t1 VALUES (5,5);
+--error 1062
+INSERT INTO t2 select * from t1;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+INSERT INTO t1 values (6,6);
+CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb ;
+INSERT INTO t1 values (7,7);
+ROLLBACK;
+INSERT INTO t1 values (8,8);
+--error 1062
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+COMMIT;
+INSERT INTO t1 values (9,9);
+--error 1062
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+SELECT * from t2;
+TRUNCATE table t2;
+INSERT INTO t1 values (10,10);
+--error 1062
+INSERT INTO t2 select * from t1;
+SELECT * from t1;
+INSERT INTO t2 values (100,100);
+--error 1062
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+COMMIT;
+INSERT INTO t2 values (101,101);
+--error 1062
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+SELECT * from t2;
+DROP TABLE t1,t2;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+show binlog events from 102;
+
 # Test for BUG#16559 (ROLLBACK should always have a zero error code in
 # binlog). Has to be here and not earlier, as the SELECTs influence
 # XIDs differently between normal and ps-protocol (and SHOW BINLOG
@@ -280,16 +347,3 @@
 connection con4;
 select get_lock("a",10); # wait for rollback to finish
 
-# we check that the error code of the "ROLLBACK" event is 0 and not
-# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
-# and does not make slave to stop)
---exec $MYSQL_BINLOG --start-position=547 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval select
-(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
-is not null;
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval select
-@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
-@a not like "%#%error_code=%error_code=%";
-drop table t1, t2;

--- 1.32/mysql-test/t/mysql.test	2006-11-29 15:53:01 -07:00
+++ 1.33/mysql-test/t/mysql.test	2007-01-18 08:33:29 -07:00
@@ -145,20 +145,23 @@
 #
 # Bug #19216: Client crashes on long SELECT
 #
---exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp
-# 3400 * 20 makes 68000 columns that is more than the max number that can fit 
-# in a 16 bit number.
-let $i= 3400;
-while ($i)
-{
-  --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
-  dec $i;
-}
+# Create large SELECT
+# - 3400 * 20 makes 68000 columns that is more than the
+#   max number that can fit in a 16 bit number.
+
+--perl
+open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die;
+print FILE "select\n";
+print FILE "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',\n" x 3400;
+print FILE "'b';\n";
+close FILE;
+EOF
 
---exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
 --disable_query_log
 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
 --enable_query_log
+
+--remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp
 
 #
 # Bug #20103: Escaping with backslash does not work

--- 1.262/client/mysqltest.c	2007-01-11 06:09:57 -07:00
+++ 1.263/client/mysqltest.c	2007-01-18 08:33:28 -07:00
@@ -725,6 +725,20 @@
 }
 
 
+void close_statements()
+{
+  struct st_connection *con;
+  DBUG_ENTER("close_statements");
+  for (con= connections; con < next_con; con++)
+  {
+    if (con->stmt)
+      mysql_stmt_close(con->stmt);
+    con->stmt= 0;
+  }
+  DBUG_VOID_RETURN;
+}
+
+
 void close_files()
 {
   DBUG_ENTER("close_files");
@@ -2908,6 +2922,10 @@
 	}
       }
 #endif
+      if (next_con->stmt)
+        mysql_stmt_close(next_con->stmt);
+      next_con->stmt= 0;
+
       mysql_close(&con->mysql);
       if (con->util_mysql)
 	mysql_close(con->util_mysql);
@@ -5112,6 +5130,14 @@
     dynstr_free(&ds_execute_warnings);
   }
 
+
+  /* Close the statement if - no reconnect, need new prepare */
+  if (mysql->reconnect)
+  {
+    mysql_stmt_close(stmt);
+    cur_con->stmt= NULL;
+  }
+
   /*
     We save the return code (mysql_stmt_errno(stmt)) from the last call sent
     to the server into the mysqltest builtin variable $mysql_errno. This
@@ -5119,10 +5145,7 @@
   */
 
   var_set_errno(mysql_stmt_errno(stmt));
-#ifndef BUG15518_FIXED
-  mysql_stmt_close(stmt);
-  cur_con->stmt= NULL;
-#endif
+
   DBUG_VOID_RETURN;
 }
 
@@ -5909,6 +5932,8 @@
 	break;
       case Q_DISABLE_PS_PROTOCOL:
         ps_protocol_enabled= 0;
+        /* Close any open statements */
+        close_statements();
         break;
       case Q_ENABLE_PS_PROTOCOL:
         ps_protocol_enabled= ps_protocol;
@@ -5918,6 +5943,8 @@
         break;
       case Q_ENABLE_RECONNECT:
         set_reconnect(&cur_con->mysql, 1);
+        /* Close any open statements - no reconnect, need new prepare */
+        close_statements();
         break;
       case Q_DISABLE_PARSING:
         if (parsing_disabled == 0)

--- 1.225/tests/mysql_client_test.c	2007-01-15 13:49:47 -07:00
+++ 1.226/tests/mysql_client_test.c	2007-01-18 08:33:31 -07:00
@@ -11014,7 +11014,7 @@
     rc= mysql_stmt_execute(stmt);
     check_execute(stmt, rc);
     rc= my_process_stmt_result(stmt);
-    assert(1 == rc);
+    DIE_UNLESS(1 == rc);
   }
   mysql_stmt_close(stmt);
 
@@ -11057,7 +11057,7 @@
     rc= mysql_stmt_execute(stmt);
     check_execute(stmt, rc);
     rc= my_process_stmt_result(stmt);
-    assert(4 == rc);
+    DIE_UNLESS(4 == rc);
   }
   mysql_stmt_close(stmt);
 
@@ -11140,7 +11140,7 @@
   rc= mysql_stmt_execute(stmt);
   check_execute(stmt, rc);
   rc= my_process_stmt_result(stmt);
-  assert(0 == rc);
+  DIE_UNLESS(0 == rc);
 
   mysql_stmt_close(stmt);
 
@@ -11193,7 +11193,7 @@
     rc= mysql_stmt_execute(stmt);
     check_execute(stmt, rc);
     rc= my_process_stmt_result(stmt);
-    assert(0 == rc);
+    DIE_UNLESS(0 == rc);
   }
 
   mysql_stmt_close(stmt);
@@ -11256,7 +11256,7 @@
     rc= mysql_stmt_execute(select_stmt);
     check_execute(select_stmt, rc);
     rowcount= (int)my_process_stmt_result(select_stmt);
-    assert((i+1) == rowcount);
+    DIE_UNLESS((i+1) == rowcount);
   }
   mysql_stmt_close(insert_stmt);
   mysql_stmt_close(select_stmt);
@@ -11297,7 +11297,7 @@
     rc= mysql_stmt_execute(stmt);
     check_execute(stmt, rc);
     rc= my_process_stmt_result(stmt);
-    assert(3 == rc);
+    DIE_UNLESS(3 == rc);
   }
   mysql_stmt_close(stmt);
 
@@ -11373,7 +11373,7 @@
   rc= mysql_stmt_execute(stmt);
   check_execute(stmt, rc);
   rc= my_process_stmt_result(stmt);
-  assert(1 == rc);
+  DIE_UNLESS(1 == rc);
 
   mysql_stmt_close(stmt);
   rc= mysql_query(mysql, "DROP VIEW v1");
@@ -12859,6 +12859,82 @@
   DIE_UNLESS(!mysql_errno(mysql));
 }
 
+/*
+  Bug #15518 - Reusing a stmt that has failed during prepare
+  does not clear error
+*/
+
+static void test_bug15518()
+{
+  MYSQL_STMT *stmt;
+  MYSQL* mysql1;
+  int rc;
+  myheader("test_bug15518");
+
+  mysql1= mysql_init(NULL);
+
+  if (!mysql_real_connect(mysql1, opt_host, opt_user, opt_password,
+                          opt_db ? opt_db : "test", opt_port, opt_unix_socket,
+                          CLIENT_MULTI_STATEMENTS))
+  {
+    fprintf(stderr, "Failed to connect to the database\n");
+    DIE_UNLESS(0);
+  }
+
+  stmt= mysql_stmt_init(mysql1);
+
+  /*
+    The prepare of foo should fail with errno 1064 since
+    it's not a valid query
+  */
+  rc= mysql_stmt_prepare(stmt, "foo", 3);
+  if (!opt_silent)
+    fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n",
+            rc, mysql_stmt_errno(stmt), mysql_errno(mysql1));
+  DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql1));
+
+  /*
+    Use the same stmt and reprepare with another query that
+    suceeds
+  */
+  rc= mysql_stmt_prepare(stmt, "SHOW STATUS", 12);
+  if (!opt_silent)
+    fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n",
+            rc, mysql_stmt_errno(stmt), mysql_errno(mysql1));
+  DIE_UNLESS(!rc || mysql_stmt_errno(stmt) || mysql_errno(mysql1));
+
+  mysql_stmt_close(stmt);
+  DIE_UNLESS(!mysql_errno(mysql1));
+
+  /*
+    part2, when connection to server has been closed
+    after first prepare
+  */
+  stmt= mysql_stmt_init(mysql1);
+  rc= mysql_stmt_prepare(stmt, "foo", 3);
+  if (!opt_silent)
+    fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n",
+            rc, mysql_stmt_errno(stmt), mysql_errno(mysql1));
+  DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql1));
+
+  /* Close connection to server */
+  mysql_close(mysql1);
+
+  /*
+    Use the same stmt and reprepare with another query that
+    suceeds. The prepare should fail with error 2013 since
+    connection to server has been closed.
+  */
+  rc= mysql_stmt_prepare(stmt, "SHOW STATUS", 12);
+  if (!opt_silent)
+    fprintf(stdout, "rc: %d, mysql_stmt_errno: %d\n",
+            rc, mysql_stmt_errno(stmt));
+  DIE_UNLESS(rc && mysql_stmt_errno(stmt));
+
+  mysql_stmt_close(stmt);
+  DIE_UNLESS(mysql_errno(mysql1));
+}
+
 
 static void test_view_sp_list_fields()
 {
@@ -15035,7 +15111,7 @@
     }
     else
     {
-      assert(0==1);
+      DIE_UNLESS(0==1);
     }
   }
 
@@ -15989,6 +16065,7 @@
   { "test_bug19671", test_bug19671 },
   { "test_bug21206", test_bug21206 },
   { "test_bug21726", test_bug21726 },
+  { "test_bug15518", test_bug15518 },
   { "test_bug23383", test_bug23383 },
   { "test_bug21635", test_bug21635 },
   { "test_status", test_status},
Thread
bk commit into 5.1 tree (tsmith:1.2405)tim18 Jan