Merge lp:~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Merged
Merged at revision: 1536
Proposed branch: lp:~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh
Merge into: lp:~drizzle-trunk/drizzle/development
Prerequisite: lp:~stewart/drizzle/embedded-innodb-autoincrement
Diff against target: 77 lines (+52/-0)
4 files modified
plugin/embedded_innodb/embedded_innodb_engine.cc (+25/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/basic_create_select.result (+16/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select-master.opt (+1/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select.test (+10/-0)
To merge this branch: bzr merge lp:~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Brian Aker Pending
Drizzle Developers Pending
Review via email: mp+23815@code.launchpad.net

Description of the change

Support CREATE SELECT properly. This means we jump through an amazingly silly hoop.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

Huh. Nice explanation in your blog post. Ugly, but it works. :)

review: Approve
1430. By Stewart Smith

Merged embedded-innodb-autoincrement into embedded-innodb-create-select-transaction-arrgh.

1431. By Stewart Smith

Merged embedded-innodb-autoincrement into embedded-innodb-create-select-transaction-arrgh.

1432. By Stewart Smith

merge trunk

1433. By Stewart Smith

merge getInitialAutoIncrementValue() calls new names for index_init and index_end()

1434. By Stewart Smith

Merged embedded-innodb-autoincrement into embedded-innodb-create-select-transaction-arrgh.

1435. By Stewart Smith

Merged embedded-innodb-autoincrement into embedded-innodb-create-select-transaction-arrgh.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugin/embedded_innodb/embedded_innodb_engine.cc'
--- plugin/embedded_innodb/embedded_innodb_engine.cc 2010-05-17 13:02:40 +0000
+++ plugin/embedded_innodb/embedded_innodb_engine.cc 2010-05-17 13:02:41 +0000
@@ -1372,6 +1372,31 @@
1372 ib_cursor_attach_trx(cursor, transaction);1372 ib_cursor_attach_trx(cursor, transaction);
13731373
1374 err= ib_cursor_first(cursor);1374 err= ib_cursor_first(cursor);
1375 if (current_session->lex->sql_command == SQLCOM_CREATE_TABLE
1376 && err == DB_MISSING_HISTORY)
1377 {
1378 /* See https://bugs.launchpad.net/drizzle/+bug/556978
1379 *
1380 * In CREATE SELECT, transaction is started in ::store_lock
1381 * at the start of the statement, before the table is created.
1382 * This means the table doesn't exist in our snapshot,
1383 * and we get a DB_MISSING_HISTORY error on ib_cursor_first().
1384 * The way to get around this is to here, restart the transaction
1385 * and continue.
1386 *
1387 * yuck.
1388 */
1389
1390 EmbeddedInnoDBEngine *innodb_engine= static_cast<EmbeddedInnoDBEngine*>(engine);
1391 err= ib_cursor_reset(cursor);
1392 innodb_engine->doCommit(current_session, true);
1393 innodb_engine->doStartTransaction(current_session, START_TRANS_NO_OPTIONS);
1394 transaction= *get_trx(ha_session());
1395 assert(err == DB_SUCCESS);
1396 ib_cursor_attach_trx(cursor, transaction);
1397 err= ib_cursor_first(cursor);
1398 }
1399
1375 assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);1400 assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);
13761401
13771402
13781403
=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/basic_create_select.result'
--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/basic_create_select.result 1970-01-01 00:00:00 +0000
+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/basic_create_select.result 2010-05-17 13:02:41 +0000
@@ -0,0 +1,16 @@
1create table t1 (d int primary key);
2create table t2 (d int primary key);
3insert into t1 values ("100000000");
4insert into t2 values (2);
5create table t3 (d int primary key) as select t2.d from t2 union select t1.d from t1;
6select * from t3;
7d
82
9100000000
10show create table t3;
11Table Create Table
12t3 CREATE TABLE `t3` (
13 `d` int NOT NULL,
14 PRIMARY KEY (`d`) USING BTREE
15) ENGINE=DEFAULT
16drop table t1, t2, t3;
017
=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select-master.opt'
--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select-master.opt 1970-01-01 00:00:00 +0000
+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select-master.opt 2010-05-17 13:02:41 +0000
@@ -0,0 +1,1 @@
1--plugin_add=embedded_innodb --plugin_remove=innobase
02
=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select.test'
--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select.test 1970-01-01 00:00:00 +0000
+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/basic_create_select.test 2010-05-17 13:02:41 +0000
@@ -0,0 +1,10 @@
1create table t1 (d int primary key);
2create table t2 (d int primary key);
3insert into t1 values ("100000000");
4insert into t2 values (2);
5create table t3 (d int primary key) as select t2.d from t2 union select t1.d from t1;
6select * from t3;
7--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
8show create table t3;
9drop table t1, t2, t3;
10