strange savepoints behaviour: H2 console vs. SQL editor

126 views
Skip to first unread message

Niko Paltzer

unread,
Apr 11, 2016, 10:32:49 AM4/11/16
to H2 Database
Hi,

please consider the following example:


DROP TABLE TEST;

CREATE TABLE TEST(ID NUMERIC(15) NOT NULL);

insert into test values (1);

savepoint test_savepoint;

insert into test values (2);

rollback to savepoint test_savepoint;

select * from test;


If I execute it with the H2 console, I get the expected result: One row with value 1.

If I execute the same snippet with Execute Query (www.executequery.org), using org.h2.Driver from h2-1.3.176.jar (h2.1.4.191.jar resp.), then the result is empty.

I disabled auto-commit in both cases.

Do you have any idea why this difference occurs?

Thanks a lot!

Best, Niko Paltzer

Thomas Mueller

unread,
May 3, 2016, 1:45:46 AM5/3/16
to h2-da...@googlegroups.com
Hi,

I don't know what the problem could be, but maybe you could find out yourself if you enable "JDBC method call logging", by appending ";trace_level_system_out=3" to the database URL. This will log all method calls to system out. If use ";trace_level_file=3" to log to a file (next to the database file).

Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Niko Paltzer

unread,
May 3, 2016, 10:58:22 AM5/3/16
to H2 Database
Hi Thomas,

I did the logging you suggested and the result is attached.

My observations:

In lines 4351-4353 it says:
/**/stat79.execute("savepoint test_savepoint");
05-03 16:52:54 jdbc[4]:
/*SQL */savepoint test_savepoint;

But when doing the rollback (lines 4389-4398) the savepoint is not logged:
/**/conn37.rollback();
05-03 16:52:54 index: TEST_DATA remove ( /* key:2 */ 2)
05-03 16:52:54 pageStore: log - s: 4 table: 15 row: ( /* key:2 */ 2)
05-03 16:52:54 index: TEST_DATA remove ( /* key:1 */ 1)
05-03 16:52:54 pageStore: updateRecord page[521] data leaf table:15 TEST entries:0 parent:0 keys:null offsets:null
05-03 16:52:54 pageStore: log - s: 4 table: 15 row: ( /* key:1 */ 1)
05-03 16:52:54 pageStore: log commit s: 4
05-03 16:52:54 lock: 4 exclusive write lock unlock TEST
05-03 16:52:54 jdbc[4]:
/*SQL t:1*/ROLLBACK;

Does that mean, that Execute Query does not pass this information to the driver and just executes a "rollback" instead of "rollback to savepoint test_savepoint"?

Thanks again.

Best, Niko


On Tuesday, May 3, 2016 at 7:45:46 AM UTC+2, Thomas Mueller wrote:
Hi,

I don't know what the problem could be, but maybe you could find out yourself if you enable "JDBC method call logging", by appending ";trace_level_system_out=3" to the database URL. This will log all method calls to system out. If use ";trace_level_file=3" to log to a file (next to the database file).

Regards,
Thomas


On Monday, April 11, 2016, Niko Paltzer <nik...@gmail.com> wrote:
Hi,

please consider the following example:


DROP TABLE TEST;

CREATE TABLE TEST(ID NUMERIC(15) NOT NULL);

insert into test values (1);

savepoint test_savepoint;

insert into test values (2);

rollback to savepoint test_savepoint;

select * from test;


If I execute it with the H2 console, I get the expected result: One row with value 1.

If I execute the same snippet with Execute Query (www.executequery.org), using org.h2.Driver from h2-1.3.176.jar (h2.1.4.191.jar resp.), then the result is empty.

I disabled auto-commit in both cases.

Do you have any idea why this difference occurs?

Thanks a lot!

Best, Niko Paltzer

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscribe@googlegroups.com.
test.trace.db

Thomas Mueller

unread,
May 11, 2016, 4:16:26 AM5/11/16
to h2-da...@googlegroups.com
Hi,

Well according to the trace file, you have called "conn.rollback()" instead of "conn.rollback(sp)".

If you don't find the problem, you would need to provide a simple, reproducible test case (just one Java class with a main method and JDBC API calls, no dependencies).

Regards,
Thomas
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.

To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.

Niko Paltzer

unread,
May 13, 2016, 7:09:57 AM5/13/16
to H2 Database
Hi Thomas,

it is indeed a bug in Execute Query that will be fixed in future.

Thanks for your hints!

Best, Niko
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscribe@googlegroups.com.

To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscribe@googlegroups.com.

tak...@executequery.org

unread,
May 13, 2016, 11:18:36 AM5/13/16
to H2 Database
hi

i have modified the way rollback commands are determined to cater for this sort of case.

please replace your eq.jar file in your install directory for Execute Query with the one here:

it will also be included as a part of the next release from the normal bundles. 
let me know of any issues.

thanks :)
Takis
Reply all
Reply to author
Forward
0 new messages