Обсуждение: locking a table

Поиск
Список
Период
Сортировка

locking a table

От
Andreas Schmitz
Дата:
Hello *,

I just tried to lock a table in exclusive mode following the syntax provided
by \h lock

LOCK [ TABLE ] name [, ...] IN lockmode MODE

and I get the following result:


newsdb=# lock table dpa in lockmode 'exclusive';
ERROR:  parser: parse error at or near "lockmode" at character 19
newsdb=# lock table dpa in lockmode exclusive;
ERROR:  parser: parse error at or near "lockmode" at character 19
newsdb=#

Did I get it totally wrong and I am badly in need of some holidays or is there
something wrong with the syntax ?

kind regards,

-andreas

--
Andreas Schmitz - Phone +49 201 8501 318
Cityweb-Technik-Service-Gesellschaft mbH
Friedrichstr. 12 - Fax +49 201 8501 104
45128 Essen - email a.schmitz@cityweb.de


Re: locking a table

От
Simone Tellini
Дата:
On Mon, 23 Dec 2002 18:02:24 +0100
Andreas Schmitz <a.schmitz@cityweb.de> wrote:

AS> LOCK [ TABLE ] name [, ...] IN lockmode MODE
[...]
AS> newsdb=# lock table dpa in lockmode 'exclusive';
AS> ERROR:  parser: parse error at or near "lockmode" at character 19

you might want to try "lock dpa in exclusive mode;"

--

Simone Tellini
E-mail: tellini@areabusiness.it
http://www.areabusiness.it


Re: locking a table

От
Andreas Schmitz
Дата:
On Monday 23 December 2002 18:35, Simone Tellini wrote:
> lock dpa in exclusive mode;

thanks a lot. thats it.

regards

-andreas

--
Andreas Schmitz - Phone +49 201 8501 318
Cityweb-Technik-Service-Gesellschaft mbH
Friedrichstr. 12 - Fax +49 201 8501 104
45128 Essen - email a.schmitz@cityweb.de


Re: locking a table

От
Andreas Schmitz
Дата:
On Monday 23 December 2002 18:35, Simone Tellini wrote:
> On Mon, 23 Dec 2002 18:02:24 +0100
> Andreas Schmitz <a.schmitz@cityweb.de> wrote:
>
> AS> LOCK [ TABLE ] name [, ...] IN lockmode MODE
> [...]
> AS> newsdb=# lock table dpa in lockmode 'exclusive';
> AS> ERROR:  parser: parse error at or near "lockmode" at character 19
>
> you might want to try "lock dpa in exclusive mode;"

Hi,

newsdb3=# lock dpa in exclusive mode;

that one worked without errors. connecting as a normal user

 psql -U dbimport newsdb3

and doing a

newsdb3=> select id from dpa limit 5;
   id
--------
  73424
  73430
  69445
  73431
 109217
(5 rows)

Maybe I have a different idea of exclusive.

kind regards

-andreas

--
Andreas Schmitz - Phone +49 201 8501 318
Cityweb-Technik-Service-Gesellschaft mbH
Friedrichstr. 12 - Fax +49 201 8501 104
45128 Essen - email a.schmitz@cityweb.de


Re: locking a table

От
Tom Lane
Дата:
Andreas Schmitz <a.schmitz@cityweb.de> writes:
> Maybe I have a different idea of exclusive.

Locks are held till the end of the current transaction ... so you need
something like

    begin;
    lock ...;
    do whatever ...;
    commit;

to do anything useful with an explicit lock.  A standalone LOCK command
will drop the lock as soon as it's acquired.

            regards, tom lane