Merge lp:~stewart/drizzle/embedded-innodb-isolation-level into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Merged
Merged at revision: 1583
Proposed branch: lp:~stewart/drizzle/embedded-innodb-isolation-level
Merge into: lp:~drizzle-trunk/drizzle/development
Prerequisite: lp:~stewart/drizzle/bug586348
Diff against target: 327 lines (+228/-4)
11 files modified
plugin/embedded_innodb/embedded_innodb_engine.cc (+31/-4)
plugin/embedded_innodb/embedded_innodb_engine.h (+1/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_read_uncommitted.result (+32/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_repeatable_read.result (+25/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_serializable.result (+25/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted-master.opt (+1/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted.test (+37/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read-master.opt (+1/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read.test (+37/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable-master.opt (+1/-0)
plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable.test (+37/-0)
To merge this branch: bzr merge lp:~stewart/drizzle/embedded-innodb-isolation-level
Reviewer Review Type Date Requested Status
Brian Aker Pending
Jay Pipes Pending
Review via email: mp+26651@code.launchpad.net

This proposal supersedes a proposal from 2010-06-01.

Description of the change

supports isolation levels in the proper way.

https://bugs.launchpad.net/drizzle/+bug/587772

means that READ COMMITTED doesn't work (a server problem, not embedded innodb)

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

Hi!

I think a static_cast<> is the correct cast template to use here instead of the reinterpret_cast<>:

53 + reinterpret_cast<EmbeddedInnoDBEngine*>(getEngine())->
54 + doStartTransaction(session, START_TRANS_NO_OPTIONS);

since EmbeddedInnoDBEngine is a direct child of plugin::StorageEngine and forward casting should use static_cast<>.

Other than that, great work and good test cases, Stew :)

-jay

review: Needs Fixing
Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/31/2010 02:25 AM, Stewart Smith wrote:
> - ib_trx_t *transaction= get_trx(session);
> - *transaction= ib_trx_begin(IB_TRX_REPEATABLE_READ);
> + reinterpret_cast<EmbeddedInnoDBEngine*>(getEngine())->
> + doStartTransaction(session, START_TRANS_NO_OPTIONS);

Is the reinterpret_cast really needed here? Seems like
getEngine()->doStartTransaction(session, START_TRANS_NO_OPTIONS); should
just work and that the virtual path should take care of getting it back
to EmbeddedInnoDBEngine for you.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwD4/8ACgkQ2Jv7/VK1RgFvWACffvA0riO/9q2uCFPXcGKMbqYw
yzkAn2wYxU06Ox9yWqJJ+I0teS7XrWZJ
=VJK0
-----END PGP SIGNATURE-----

Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

> Is the reinterpret_cast really needed here?

haha. beat you to it ;)

:)
-jay

Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

And a static_cast<> *is* needed because getEngine() returns plugin::StorageEngine and doStartTransaction() is a method of plugin::TransactionalStorageEngine.

So, the code should/could be:

static_cast<plugin::TransactionalStorageEngine *>(getEngine())->doStartTransaction(session, START_TRANS_NO_OPTIONS);

Cheers!
jay

Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

> Is the reinterpret_cast really needed here? Seems like
> getEngine()->doStartTransaction(session, START_TRANS_NO_OPTIONS); should
> just work and that the virtual path should take care of getting it back
> to EmbeddedInnoDBEngine for you.

But getEngine() returns StorageEngine, not TransactionalStorageEngine.

Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

> And a static_cast<> *is* needed because getEngine() returns
> plugin::StorageEngine and doStartTransaction() is a method of
> plugin::TransactionalStorageEngine.
>
> So, the code should/could be:
>
> static_cast<plugin::TransactionalStorageEngine
> *>(getEngine())->doStartTransaction(session, START_TRANS_NO_OPTIONS);

done. thanks!

Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

w00t. :)

review: Approve
Revision history for this message
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal

Hi!

This needs to be remerged with trunk.

Cheers,
   -Brian

review: Needs Fixing
Revision history for this message
Stewart Smith (stewart) wrote :

merged with trunk (at least last nights trunk)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin/embedded_innodb/embedded_innodb_engine.cc'
2--- plugin/embedded_innodb/embedded_innodb_engine.cc 2010-05-28 22:08:11 +0000
3+++ plugin/embedded_innodb/embedded_innodb_engine.cc 2010-06-02 23:17:25 +0000
4@@ -25,7 +25,7 @@
5 Copyright (c) 2008, 2009 Google Inc.
6
7 Portions of this file contain modifications contributed and copyrighted by
8-staticGoogle, Inc. Those modifications are gratefully acknowledged and are described
9+Google, Inc. Those modifications are gratefully acknowledged and are described
10 briefly in the InnoDB documentation. The contributions by Google are
11 incorporated with their permission, and subject to the conditions contained in
12 the file COPYING.Google.
13@@ -225,15 +225,32 @@
14 return (ib_trx_t*) session->getEngineData(embedded_innodb_engine);
15 }
16
17+static ib_trx_level_t tx_isolation_to_ib_trx_level(enum_tx_isolation level)
18+{
19+ switch(level)
20+ {
21+ case ISO_REPEATABLE_READ:
22+ return IB_TRX_REPEATABLE_READ;
23+ case ISO_READ_COMMITTED:
24+ return IB_TRX_READ_COMMITTED;
25+ case ISO_SERIALIZABLE:
26+ return IB_TRX_SERIALIZABLE;
27+ case ISO_READ_UNCOMMITTED:
28+ return IB_TRX_READ_UNCOMMITTED;
29+ }
30+}
31+
32 int EmbeddedInnoDBEngine::doStartTransaction(Session *session,
33 start_transaction_option_t options)
34 {
35 ib_trx_t *transaction;
36+ ib_trx_level_t isolation_level;
37
38 (void)options;
39
40 transaction= get_trx(session);
41- *transaction= ib_trx_begin(IB_TRX_REPEATABLE_READ);
42+ isolation_level= tx_isolation_to_ib_trx_level((enum_tx_isolation)session_tx_isolation(session));
43+ *transaction= ib_trx_begin(isolation_level);
44
45 return 0;
46 }
47@@ -512,8 +529,8 @@
48
49 if(*get_trx(session) == NULL)
50 {
51- ib_trx_t *transaction= get_trx(session);
52- *transaction= ib_trx_begin(IB_TRX_REPEATABLE_READ);
53+ static_cast<EmbeddedInnoDBEngine*>(getEngine())->
54+ doStartTransaction(session, START_TRANS_NO_OPTIONS);
55 }
56
57 if (lock_type != TL_UNLOCK)
58@@ -639,6 +656,16 @@
59 return 0;
60 }
61
62+int EmbeddedInnoDBCursor::external_lock(Session* session, int lock_type)
63+{
64+ ib_cursor_stmt_begin(cursor);
65+
66+ (void)session;
67+ (void)lock_type;
68+
69+ return 0;
70+}
71+
72 static int create_table_add_field(ib_tbl_sch_t schema,
73 const message::Table::Field &field,
74 ib_err_t *err)
75
76=== modified file 'plugin/embedded_innodb/embedded_innodb_engine.h'
77--- plugin/embedded_innodb/embedded_innodb_engine.h 2010-05-26 13:14:09 +0000
78+++ plugin/embedded_innodb/embedded_innodb_engine.h 2010-06-02 23:17:25 +0000
79@@ -51,6 +51,7 @@
80 uint32_t index_flags(uint32_t inx) const;
81 int open(const char *name, int mode, uint32_t test_if_locked);
82 int close(void);
83+ int external_lock(drizzled::Session* session, int lock_type);
84 int doInsertRecord(unsigned char * buf);
85 int doStartTableScan(bool scan);
86 int rnd_next(unsigned char *buf);
87
88=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_read_uncommitted.result'
89--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_read_uncommitted.result 1970-01-01 00:00:00 +0000
90+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_read_uncommitted.result 2010-06-02 23:17:25 +0000
91@@ -0,0 +1,32 @@
92+CREATE TABLE t1 (a int);
93+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
94+BEGIN;
95+INSERT INTO t1 values (1);
96+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
97+BEGIN;
98+SELECT * from t1 order by a;
99+a
100+1
101+INSERT INTO t1 values (2);
102+SELECT * from t1 order by a;
103+a
104+1
105+2
106+COMMIT;
107+BEGIN;
108+SELECT * FROM t1 order by a;
109+a
110+1
111+2
112+COMMIT;
113+SELECT * from t1 order by a;
114+a
115+1
116+2
117+COMMIT;
118+BEGIN;
119+SELECT * from t1 order by a;
120+a
121+1
122+2
123+DROP TABLE t1;
124
125=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_repeatable_read.result'
126--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_repeatable_read.result 1970-01-01 00:00:00 +0000
127+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_repeatable_read.result 2010-06-02 23:17:25 +0000
128@@ -0,0 +1,25 @@
129+CREATE TABLE t1 (a int);
130+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
131+BEGIN;
132+INSERT INTO t1 values (1);
133+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
134+BEGIN;
135+SELECT * from t1;
136+a
137+INSERT INTO t1 values (2);
138+SELECT * from t1;
139+a
140+COMMIT;
141+BEGIN;
142+SELECT * FROM t1;
143+a
144+COMMIT;
145+SELECT * from t1;
146+a
147+COMMIT;
148+BEGIN;
149+SELECT * from t1 order by a;
150+a
151+1
152+2
153+DROP TABLE t1;
154
155=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_serializable.result'
156--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_serializable.result 1970-01-01 00:00:00 +0000
157+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/r/trx_isolation_serializable.result 2010-06-02 23:17:25 +0000
158@@ -0,0 +1,25 @@
159+CREATE TABLE t1 (a int);
160+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
161+BEGIN;
162+INSERT INTO t1 values (1);
163+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
164+BEGIN;
165+SELECT * from t1;
166+a
167+INSERT INTO t1 values (2);
168+SELECT * from t1;
169+a
170+COMMIT;
171+BEGIN;
172+SELECT * FROM t1;
173+a
174+COMMIT;
175+SELECT * from t1;
176+a
177+COMMIT;
178+BEGIN;
179+SELECT * from t1 order by a;
180+a
181+1
182+2
183+DROP TABLE t1;
184
185=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted-master.opt'
186--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted-master.opt 1970-01-01 00:00:00 +0000
187+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted-master.opt 2010-06-02 23:17:25 +0000
188@@ -0,0 +1,1 @@
189+--plugin_add=embedded_innodb --plugin_remove=innobase
190
191=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted.test'
192--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted.test 1970-01-01 00:00:00 +0000
193+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_read_uncommitted.test 2010-06-02 23:17:25 +0000
194@@ -0,0 +1,37 @@
195+connect (a,localhost,root,,);
196+connect (b,localhost,root,,);
197+
198+connection a;
199+CREATE TABLE t1 (a int);
200+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
201+BEGIN;
202+INSERT INTO t1 values (1);
203+
204+connection b;
205+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
206+BEGIN;
207+SELECT * from t1 order by a;
208+
209+connection a;
210+INSERT INTO t1 values (2);
211+
212+connection b;
213+SELECT * from t1 order by a;
214+COMMIT;
215+BEGIN;
216+SELECT * FROM t1 order by a;
217+
218+connection a;
219+COMMIT;
220+
221+connection b;
222+SELECT * from t1 order by a;
223+COMMIT;
224+BEGIN;
225+SELECT * from t1 order by a;
226+
227+DROP TABLE t1;
228+
229+disconnect a;
230+disconnect b;
231+connection default;
232
233=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read-master.opt'
234--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read-master.opt 1970-01-01 00:00:00 +0000
235+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read-master.opt 2010-06-02 23:17:25 +0000
236@@ -0,0 +1,1 @@
237+--plugin_add=embedded_innodb --plugin_remove=innobase
238
239=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read.test'
240--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read.test 1970-01-01 00:00:00 +0000
241+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_repeatable_read.test 2010-06-02 23:17:25 +0000
242@@ -0,0 +1,37 @@
243+connect (a,localhost,root,,);
244+connect (b,localhost,root,,);
245+
246+connection a;
247+CREATE TABLE t1 (a int);
248+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
249+BEGIN;
250+INSERT INTO t1 values (1);
251+
252+connection b;
253+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
254+BEGIN;
255+SELECT * from t1;
256+
257+connection a;
258+INSERT INTO t1 values (2);
259+
260+connection b;
261+SELECT * from t1;
262+COMMIT;
263+BEGIN;
264+SELECT * FROM t1;
265+
266+connection a;
267+COMMIT;
268+
269+connection b;
270+SELECT * from t1;
271+COMMIT;
272+BEGIN;
273+SELECT * from t1 order by a;
274+
275+DROP TABLE t1;
276+
277+disconnect a;
278+disconnect b;
279+connection default;
280
281=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable-master.opt'
282--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable-master.opt 1970-01-01 00:00:00 +0000
283+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable-master.opt 2010-06-02 23:17:25 +0000
284@@ -0,0 +1,1 @@
285+--plugin_add=embedded_innodb --plugin_remove=innobase
286
287=== added file 'plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable.test'
288--- plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable.test 1970-01-01 00:00:00 +0000
289+++ plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/trx_isolation_serializable.test 2010-06-02 23:17:25 +0000
290@@ -0,0 +1,37 @@
291+connect (a,localhost,root,,);
292+connect (b,localhost,root,,);
293+
294+connection a;
295+CREATE TABLE t1 (a int);
296+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
297+BEGIN;
298+INSERT INTO t1 values (1);
299+
300+connection b;
301+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
302+BEGIN;
303+SELECT * from t1;
304+
305+connection a;
306+INSERT INTO t1 values (2);
307+
308+connection b;
309+SELECT * from t1;
310+COMMIT;
311+BEGIN;
312+SELECT * FROM t1;
313+
314+connection a;
315+COMMIT;
316+
317+connection b;
318+SELECT * from t1;
319+COMMIT;
320+BEGIN;
321+SELECT * from t1 order by a;
322+
323+DROP TABLE t1;
324+
325+disconnect a;
326+disconnect b;
327+connection default;