From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
Cc: | 253540651(at)qq(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17151: A SEGV in optimizer |
Date: | 2021-08-18 15:55:58 |
Message-ID: | 1458262.1629302158@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
> This seems to happen on all supported versions. A segmentation fault
> happens during "DELETE FROM v0". The minimum reproduce steps are:
> CREATE TABLE v0 ( v1 INTEGER ) ;
> CREATE RULE v1 AS
> ON DELETE TO v0 DO SELECT
> FOR UPDATE OF old;
> DELETE FROM v0 ;
> What happens in the DELETE statement is that LockRows node receives a
> tuple from Result node and attempts to acquire a row lock on it but it
> shouldn't. I guess that analyzing the SELECT query in rule v1 should
> raise an error in the first place since there is no 'old' table in its
> FROM clause. I'm still investigating this issue.
Agreed, this ought to be rejected. In the original case, OLD wasn't
mentioned explicitly, but the parser still attempted to lock it,
which is a slightly different bug.
I think that the fix might be as easy as the attached. In your
example, this would result in
ERROR: relation "old" in FOR UPDATE clause not found in FROM clause
which is not terribly specific, but it's not really wrong either.
Seeing that nobody has complained of this in ~20 years, I doubt
we need to work harder on the error message.
(This passes check-world, but I've not double-checked to make sure
that inFromCl will be set in exactly the cases we want.)
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
dont-lock-OLD-and-NEW.patch | text/x-diff | 799 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-08-18 18:01:46 | Re: BUG #17152: ERROR: AddressSanitizer: SEGV on unknown address |
Previous Message | Tom Lane | 2021-08-18 15:36:00 | Re: BUG #17152: ERROR: AddressSanitizer: SEGV on unknown address |