summaryrefslogtreecommitdiff
path: root/tests/bug25714.c
diff options
context:
space:
mode:
authorunknown <antony@pcg5ppc.xiphis.org>2007-07-23 23:35:43 -0700
committerunknown <antony@pcg5ppc.xiphis.org>2007-07-23 23:35:43 -0700
commit0f85ae9f2cb88dd8a17aaa5f69639e3e22fd0f9f (patch)
tree08599e66c46ca787fcb363a53ba51081b988fd4e /tests/bug25714.c
parent7d3cecca0ae25abdc2943e79410a19bdde5fff54 (diff)
downloadmariadb-git-0f85ae9f2cb88dd8a17aaa5f69639e3e22fd0f9f.tar.gz
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/mysql-test-run.pl: bug25714 implement support to run C test for bug25714 sql/ha_federated.cc: 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: bug25714 build C test for bug mysql-test/include/have_bug25714.inc: New BitKeeper file ``mysql-test/include/have_bug25714.inc'' mysql-test/r/federated_bug_25714.result: New BitKeeper file ``mysql-test/r/federated_bug_25714.result'' mysql-test/r/have_bug25714.require: New BitKeeper file ``mysql-test/r/have_bug25714.require'' mysql-test/t/federated_bug_25714.test: New BitKeeper file ``mysql-test/t/federated_bug_25714.test'' tests/bug25714.c: New BitKeeper file ``tests/bug25714.c''
Diffstat (limited to 'tests/bug25714.c')
-rw-r--r--tests/bug25714.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/bug25714.c b/tests/bug25714.c
new file mode 100644
index 00000000000..d163b8ad00e
--- /dev/null
+++ b/tests/bug25714.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <mysql.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+int main (int argc, char **argv)
+{
+ MYSQL conn;
+ int OK;
+
+ const char* query4= "INSERT INTO federated.t1 SET Value=54";
+ const char* query5= "INSERT INTO federated.t1 SET Value=55";
+
+ 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));
+ }
+
+ OK = mysql_real_query (&conn, query4, strlen(query4));
+
+ assert(0 == OK);
+
+ printf("%ld inserted\n",
+ (long) mysql_insert_id(&conn));
+
+ OK = mysql_real_query (&conn, query5, strlen(query5));
+
+ assert(0 == OK);
+
+ printf("%ld inserted\n",
+ (long) mysql_insert_id(&conn));
+
+ mysql_close(&conn);
+
+ return 0;
+};