Below is the list of changes that have just been committed into a local
5.0 repository of antony. When antony 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-07-17 12:25:46-07:00, antony@stripped +8 -0
Bug#25714
"getGeneratedKeys() does not work with FEDERATED table"
mysql_insert() expected the storage engine to update the row data
during the write_row() operation with the value of the new auto-
increment field. The field must be updated when only one row has
been inserted as mysql_insert() would ignore the thd->last_insert.
This patch implements HA_STATUS_AUTO support in ha_federated::info()
and ensures that ha_federated::write_row() does update the row's
auto-increment value.
The test case was written in C as the protocol's 'id' value is
accessible through libmysqlclient and not via SQL statements.
mysql-test-run.pl was extended to enable running the test binary.
mysql-test/include/have_bug25714.inc@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +7 -0
New BitKeeper file ``mysql-test/include/have_bug25714.inc''
mysql-test/include/have_bug25714.inc@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +0 -0
mysql-test/mysql-test-run.pl@stripped, 2007-07-17 12:25:39-07:00, antony@stripped +12 -0
bug25714
implement support to run C test for bug25714
mysql-test/r/federated_bug_25714.result@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +56 -0
New BitKeeper file ``mysql-test/r/federated_bug_25714.result''
mysql-test/r/federated_bug_25714.result@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +0 -0
mysql-test/r/have_bug25714.require@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +2 -0
New BitKeeper file ``mysql-test/r/have_bug25714.require''
mysql-test/r/have_bug25714.require@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +0 -0
mysql-test/t/federated_bug_25714.test@stripped, 2007-07-17 12:25:41-07:00, antony@stripped +47 -0
New BitKeeper file ``mysql-test/t/federated_bug_25714.test''
mysql-test/t/federated_bug_25714.test@stripped, 2007-07-17 12:25:41-07:00, antony@stripped +0 -0
sql/ha_federated.cc@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +11 -3
bug25714
The storage engine instance property auto_increment_value was not
being set.
mysql_insert() requires that the storage engine updates the row with
the auto-increment value, especially when only inserting one row.
Implement support for ha_federated::info(HA_STATUS_AUTO)
tests/Makefile.am@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +4 -1
bug25714
build C test for bug
tests/bug25714.c@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +51 -0
New BitKeeper file ``tests/bug25714.c''
tests/bug25714.c@stripped, 2007-07-17 12:25:40-07:00, antony@stripped +0 -0
diff -Nrup a/mysql-test/include/have_bug25714.inc b/mysql-test/include/have_bug25714.inc
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/include/have_bug25714.inc 2007-07-17 12:25:40 -07:00
@@ -0,0 +1,7 @@
+#
+# Check if the variable MYSQL_BUG25714 is set
+#
+--require r/have_bug25714.require
+disable_query_log;
+eval select LENGTH("MYSQL_BUG25714") > 0 as "have_bug25714_exe";
+enable_query_log;
diff -Nrup a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
--- a/mysql-test/mysql-test-run.pl 2007-06-26 03:26:20 -07:00
+++ b/mysql-test/mysql-test-run.pl 2007-07-17 12:25:39 -07:00
@@ -144,6 +144,7 @@ our $exe_mysqladmin;
our $exe_mysql_upgrade;
our $exe_mysqlbinlog;
our $exe_mysql_client_test;
+our $exe_bug25714;
our $exe_mysqld;
our $exe_mysqlcheck;
our $exe_mysqldump;
@@ -1630,6 +1631,12 @@ sub executable_setup () {
"$glob_basedir/tests/mysql_client_test",
"$glob_basedir/bin/mysql_client_test");
}
+
+ # Look for bug25714 executable which may _not_ exist in
+ # some versions, test using it should be skipped
+ $exe_bug25714=
+ mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
+ "$glob_basedir/tests/bug25714");
}
@@ -2009,6 +2016,11 @@ sub environment_setup () {
"--character-sets-dir=$path_charsetsdir";
$ENV{'MYSQL'}= $cmdline_mysql;
+
+ # ----------------------------------------------------
+ # Setup env so childs can execute bug25714
+ # ----------------------------------------------------
+ $ENV{'MYSQL_BUG25714'}= $exe_bug25714;
# ----------------------------------------------------
# Setup env so childs can execute mysql_client_test
diff -Nrup a/mysql-test/r/federated_bug_25714.result b/mysql-test/r/federated_bug_25714.result
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/federated_bug_25714.result 2007-07-17 12:25:40 -07:00
@@ -0,0 +1,56 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+stop slave;
+DROP DATABASE IF EXISTS federated;
+CREATE DATABASE federated;
+DROP DATABASE IF EXISTS federated;
+CREATE DATABASE federated;
+DROP TABLE IF EXISTS federated.bug_13118_table;
+CREATE TABLE federated.t1 (
+`id` int auto_increment primary key,
+`value` int
+) ENGINE=MyISAM;
+INSERT INTO federated.t1 SET value=1;
+INSERT INTO federated.t1 SET value=2;
+INSERT INTO federated.t1 SET value=2;
+DROP TABLE IF EXISTS fed;
+CREATE TABLE federated.t1 (
+`id` int auto_increment primary key,
+`value` int
+) ENGINE=FEDERATED
+CONNECTION='mysql://root@stripped:SLAVE_PORT/federated/t1';
+SELECT * from federated.t1;
+id value
+1 1
+2 2
+3 2
+INSERT INTO federated.t1 SET value=4;
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+4
+
+5 inserted
+6 inserted
+
+7 inserted
+8 inserted
+SELECT * from federated.t1;
+id value
+1 1
+2 2
+3 2
+4 4
+5 54
+6 55
+7 54
+8 55
+DROP TABLE federated.t1;
+DROP TABLE federated.t1;
+DROP TABLE IF EXISTS federated.t1;
+DROP DATABASE IF EXISTS federated;
+DROP TABLE IF EXISTS federated.t1;
+DROP DATABASE IF EXISTS federated;
diff -Nrup a/mysql-test/r/have_bug25714.require b/mysql-test/r/have_bug25714.require
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/have_bug25714.require 2007-07-17 12:25:40 -07:00
@@ -0,0 +1,2 @@
+have_bug25714_exe
+1
diff -Nrup a/mysql-test/t/federated_bug_25714.test b/mysql-test/t/federated_bug_25714.test
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/federated_bug_25714.test 2007-07-17 12:25:41 -07:00
@@ -0,0 +1,47 @@
+--source include/have_bug25714.inc
+source include/federated.inc;
+
+
+connection slave;
+--disable_warnings
+DROP TABLE IF EXISTS federated.bug_13118_table;
+--enable_warnings
+
+CREATE TABLE federated.t1 (
+ `id` int auto_increment primary key,
+ `value` int
+ ) ENGINE=MyISAM;
+INSERT INTO federated.t1 SET value=1;
+INSERT INTO federated.t1 SET value=2;
+INSERT INTO federated.t1 SET value=2;
+
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS fed;
+--enable_warnings
+
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval CREATE TABLE federated.t1 (
+ `id` int auto_increment primary key,
+ `value` int
+ ) ENGINE=FEDERATED
+ CONNECTION='mysql://root@stripped:$SLAVE_MYPORT/federated/t1';
+
+SELECT * from federated.t1;
+
+INSERT INTO federated.t1 SET value=4;
+
+SELECT LAST_INSERT_ID();
+
+--exec $MYSQL_BUG25714 $SLAVE_MYPORT
+--exec $MYSQL_BUG25714 $MASTER_MYPORT
+
+SELECT * from federated.t1;
+
+DROP TABLE federated.t1;
+connection slave;
+DROP TABLE federated.t1;
+
+
+source include/federated_cleanup.inc;
+
diff -Nrup a/sql/ha_federated.cc b/sql/ha_federated.cc
--- a/sql/ha_federated.cc 2007-06-29 15:14:00 -07:00
+++ b/sql/ha_federated.cc 2007-07-17 12:25:40 -07:00
@@ -1811,8 +1811,13 @@ int ha_federated::write_row(byte *buf)
field, then store the last_insert_id() value from the foreign server
*/
if (auto_increment_update_required)
+ {
update_auto_increment();
+ /* mysql_insert() uses this for protocol return value */
+ table->next_number_field->store(auto_increment_value, 1);
+ }
+
DBUG_RETURN(0);
}
@@ -1896,7 +1901,8 @@ void ha_federated::update_auto_increment
THD *thd= current_thd;
DBUG_ENTER("ha_federated::update_auto_increment");
- thd->insert_id(mysql->last_used_con->insert_id);
+ ha_federated::info(HA_STATUS_AUTO);
+ thd->insert_id(auto_increment_value);
DBUG_PRINT("info",("last_insert_id: %ld", (long) auto_increment_value));
DBUG_VOID_RETURN;
@@ -2688,8 +2694,10 @@ int ha_federated::info(uint flag)
block_size= 4096;
}
- if (result)
- mysql_free_result(result);
+ if (flag & HA_STATUS_AUTO)
+ auto_increment_value= mysql->last_used_con->insert_id;
+
+ mysql_free_result(result);
DBUG_RETURN(0);
diff -Nrup a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am 2007-03-15 07:52:03 -07:00
+++ b/tests/Makefile.am 2007-07-17 12:25:40 -07:00
@@ -28,7 +28,7 @@ EXTRA_DIST = auto_increment.res auto_in
CMakeLists.txt
bin_PROGRAMS = mysql_client_test
-noinst_PROGRAMS = insert_test select_test thread_test
+noinst_PROGRAMS = insert_test select_test thread_test bug25714
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
$(openssl_includes)
@@ -44,6 +44,9 @@ insert_test_SOURCES= insert_test.c
select_test_SOURCES= select_test.c
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
+
+bug25714_SOURCES= bug25714.c
+bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
# Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK
diff -Nrup a/tests/bug25714.c b/tests/bug25714.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/tests/bug25714.c 2007-07-17 12:25:40 -07:00
@@ -0,0 +1,51 @@
+#include <mysql.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+
+int main (int argc, char **argv)
+{
+ MYSQL conn;
+
+ if (argc != 2)
+ return -1;
+
+ mysql_init (&conn);
+ if (!mysql_real_connect (
+ &conn,
+ "127.0.0.1",
+ "root",
+ "",
+ "test",
+ atoi(argv[1]),
+ NULL,
+ CLIENT_FOUND_ROWS)) {
+ fprintf(stderr, "Failed to connect to database: Error: %s\n",
+ mysql_error(&conn));
+ return 1;
+ } else {
+ printf("%s\n", mysql_error(&conn));
+ }
+
+ int OK;
+
+ const char* query4 = "INSERT INTO federated.t1 SET Value=54";
+
+ OK = mysql_real_query (&conn, query4, strlen(query4));
+
+ assert(0 == OK);
+
+ printf("%ld inserted\n",
+ (long) mysql_insert_id(&conn));
+
+ const char* query5 = "INSERT INTO federated.t1 SET Value=55";
+
+ OK = mysql_real_query (&conn, query5, strlen(query5));
+
+ assert(0 == OK);
+
+ printf("%ld inserted\n",
+ (long) mysql_insert_id(&conn));
+
+ return 0;
+};
| Thread |
|---|
| • bk commit into 5.0 tree (antony:1.2527) BUG#25714 | antony | 17 Jul |