Search Postgresql Archives

Re: using DROP in a transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Willy-Bas Loos" <willybas@xxxxxxxxx> writes:
> then in TTY2, run
>   begin;
>   drop table test;
>   create table test (id int4 primary key);
>   insert into test (id) values (2);

> then, in TTY1:
>   select * from test;

> Actually, i thought of a longer test, but it stops here - there is no
> response, no prompt anaymore, until i cancel the query.

DROP TABLE takes an exclusive lock.  The SELECT is waiting for that
lock to be released.

You could shorten the length of the exclusive lock by creating and
filling the replacement table under a new name, then DROP, then
rename the new table into place and immediately commit.  But you
aren't going to be able to eliminate it entirely.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux