google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Creating a local temporary table: option to not commit a transaction #214

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, creating a temporary table commits an open transaction. There are 
use cases where this is not acceptable, for example when it is not known yet 
whether the temp table is needed at the beginning of a transaction.

Original issue reported on code.google.com by thomas.t...@gmail.com on 1 Jul 2010 at 10:35

GoogleCodeExporter commented 9 years ago
Implemented in version 1.2.139. Example usage:

set autocommit true;
create table test(id int);
insert into test values(1);
set autocommit false;
insert into test values(2);
create local temporary table temp(id int primary key, name varchar(255)) 
transactional;
insert into temp values(1, 'test');
rollback;
select * from test;
drop table test;
drop table temp;

set autocommit true;
create table test(id int);
insert into test values(1);
set autocommit false;
insert into test values(2);
create local temporary table temp(id int primary key, name varchar(255)) on 
commit drop transactional;
insert into temp values(1, 'test');
select * from temp;
rollback;
select * from test;
drop table test;
-- table already dropped, so this will fail:
select * from temp;

Original comment by thomas.t...@gmail.com on 10 Jul 2010 at 2:15