agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Advisory locks
3+ messages / 2 participants
[nested] [flat]

* Advisory locks
@ 2015-02-11 10:32 Tom Paynter <tompaynter@tdpe.co.uk>
  2015-02-11 10:40 ` Re: Advisory locks daku.sandor@gmail.com
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Paynter @ 2015-02-11 10:32 UTC (permalink / raw)
  To: pgsql-sql

Hello All,

I have a quick question about advisory locks, that I have not been able to
figure out from the documentation.


Say I have two tables:
CREATE TABLE table_a
(
table_a_id        serial primary key,
some more rows....
);

CREATE TABLE table_b
(
table_b_id        serial primary key,
some more rows....
);


And I execute the following lines (from separate sessions):
SELECT pg_advisory_lock(table_a_id) FROM table_a WHERE table_a_id=5;
SELECT pg_advisory_lock(table_b_id) FROM table_b WHERE table_b_id=5;


Will this try to acquire the same lock?
Or is the id tied to the table somehow?


Thanks for your time.
Tom



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Advisory locks
  2015-02-11 10:32 Advisory locks Tom Paynter <tompaynter@tdpe.co.uk>
@ 2015-02-11 10:40 ` daku.sandor@gmail.com
  2015-02-11 10:49   ` Re: Advisory locks Tom Paynter <tompaynter@tdpe.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: daku.sandor@gmail.com @ 2015-02-11 10:40 UTC (permalink / raw)
  To: Tom Paynter <tompaynter@tdpe.co.uk>; pgsql-sql

The parameter of the pg_advisory_lock is a simple bigint and of course it is completely unaware of the source of the value.

Regards,
Sándor Daku

  Original Message  
From: Tom Paynter
Sent: 2015. február 11., szerda 11:33
To: pgsql-sql@postgresql.org
Subject: [SQL] Advisory locks

Hello All,

I have a quick question about advisory locks, that I have not been able to
figure out from the documentation.


Say I have two tables:
CREATE TABLE table_a
(
table_a_id serial primary key,
some more rows....
);

CREATE TABLE table_b
(
table_b_id serial primary key,
some more rows....
);


And I execute the following lines (from separate sessions):
SELECT pg_advisory_lock(table_a_id) FROM table_a WHERE table_a_id=5;
SELECT pg_advisory_lock(table_b_id) FROM table_b WHERE table_b_id=5;


Will this try to acquire the same lock?
Or is the id tied to the table somehow?


Thanks for your time.
Tom



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Advisory locks
  2015-02-11 10:32 Advisory locks Tom Paynter <tompaynter@tdpe.co.uk>
  2015-02-11 10:40 ` Re: Advisory locks daku.sandor@gmail.com
@ 2015-02-11 10:49   ` Tom Paynter <tompaynter@tdpe.co.uk>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Paynter @ 2015-02-11 10:49 UTC (permalink / raw)
  To: pgsql-sql

Thank you Sándor,

Just out of interest, is the following done just to make sure a row exists:
SELECT pg_advisory_lock(table_a_id) FROM table_a WHERE table_a_id=5;

As opposed to:
SELECT pg_advisory_lock(5);

Cheers,
Tom



On Wed, February 11, 2015 10:40 am, daku.sandor@gmail.com wrote:
> The parameter of the pg_advisory_lock is a simple bigint and of course it
> is completely unaware of the source of the value.
>
> Regards,
> Sándor Daku
>
>
>   Original Message  
> From: Tom Paynter
> Sent: 2015. február 11., szerda 11:33
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Advisory locks
>
>
> Hello All,
>
>
> I have a quick question about advisory locks, that I have not been able
> to figure out from the documentation.
>
>
> Say I have two tables:
> CREATE TABLE table_a
> (
> table_a_id serial primary key, some more rows.... );
>
>
> CREATE TABLE table_b
> (
> table_b_id serial primary key, some more rows.... );
>
>
>
> And I execute the following lines (from separate sessions):
> SELECT pg_advisory_lock(table_a_id) FROM table_a WHERE table_a_id=5;
> SELECT pg_advisory_lock(table_b_id) FROM table_b WHERE table_b_id=5;
>
>
>
> Will this try to acquire the same lock?
> Or is the id tied to the table somehow?
>
>
>
> Thanks for your time.
> Tom
>
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
>




-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-02-11 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-02-11 10:32 Advisory locks Tom Paynter <tompaynter@tdpe.co.uk>
2015-02-11 10:40 ` daku.sandor@gmail.com
2015-02-11 10:49   ` Tom Paynter <tompaynter@tdpe.co.uk>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox