Skip site navigation (1) Skip section navigation (2)

Re: DDL in transactions?

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Giuseppe Sacco <giuseppe(at)eppesuigoccas(dot)homedns(dot)org>,"pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: DDL in transactions?
Date: 2005-03-31 17:34:14
Message-ID: 424C3496.4010506@logix-tt.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hi, Giuseppe,

Kris Jurka schrieb:
>>My question is: why? Shouldn't DDL be executed immediately?
> 
> No.  DDL in postgresql is fully transactable and may be rolled back or
> committed.  That doesn't explain why the above code doesn't work.  
> Because the two executeUpdates are on the same Statement on the same
> Connection the second execution should see the newly created table because
> it is in the same transaction.  Perhaps you are not showing us the real
> code you are using and you actually have two connections?

You can simply try this out via psql:

lwgeom=# begin;
BEGIN
lwgeom=# create table tester (a int);
CREATE TABLE
lwgeom=# insert into tester values (1);
INSERT 281855490 1
lwgeom=# rollback;
ROLLBACK
lwgeom=# select * from tester;
ERROR:  relation "tester" does not exist
lwgeom=#

HTH,
Markus

In response to

pgsql-jdbc by date

Next:From: NicoDate: 2005-04-01 01:16:46
Subject: only postgresqsl in connection pool
Previous:From: Giuseppe SaccoDate: 2005-03-31 17:24:03
Subject: Re: DDL in transactions?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group