From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: TODO items for window functions |
Date: | 2008-12-29 19:59:16 |
Message-ID: | 1230580756.6455.14.camel@dell.linuxdev.us.dell.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, 2008-12-29 at 12:35 -0500, Tom Lane wrote:
> we could lock the rows. However, consider something like this:
>
> select x, lead(x) over() from table for update limit 1;
>
> Because of the LIMIT, we'd only lock the first-returned row ...
> but the values returned would also depend on the second row of the
> table, which wouldn't get locked. In general the results could
> depend on any or all rows of the table but we might lock only some.
> This seems to me to be at variance with how you'd expect SELECT FOR
> UPDATE to behave, so I'm inclined to leave the prohibition in there
> --- at least until someone comes up with a convincing use-case for
> SELECT FOR UPDATE together with a window function, and explains why
> he doesn't care about relevant rows possibly not getting locked.
>
How is that different from a subselect?
create table foo(a int, b int);
create table bar(c int, d int);
insert into foo values(1, 10);
insert into foo values(2, 20);
insert into bar values(100, 1000);
-- connection1
BEGIN;
select a, b, (select d from bar where c = 100) as d from foo
where a = 1 for update;
-- connection2
BEGIN;
select a, b, (select d from bar where c = 100) as d from foo
where a = 2 for update;
The single tuple in bar affects both results, but the second connection
is not blocked.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Bernd Helmle | 2008-12-29 20:53:43 | Re: WIP: Automatic view update rules |
Previous Message | Alvaro Herrera | 2008-12-29 18:36:39 | Re: TODO items for window functions |