Re: BUG #18664: Assert in BeginCopyTo() fails when source DML query rewritten with notifying rule
Tender Wang <tndrwang@gmail.com>
From: Tender Wang <tndrwang@gmail.com>
To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2024-10-21T12:52:34Z
Lists: pgsql-bugs
Attachments
- 0001-Remove-a-correct-Assert.patch (application/octet-stream) patch 0001
PG Bug reporting form <noreply@postgresql.org> 于2024年10月21日周一 19:32写道:
> The following bug has been logged on the website:
>
> Bug reference: 18664
> Logged by: Alexander Lakhin
> Email address: exclusion@gmail.com
> PostgreSQL version: 17.0
> Operating system: Ubuntu 22.04
> Description:
>
> The following script:
> CREATE TABLE t(i int);
> CREATE RULE r AS ON INSERT TO t DO INSTEAD NOTIFY c;
> COPY (INSERT INTO t VALUES (1)) TO stdout;
>
> triggers an Assert in BeginCopyTo():
> TRAP: failed Assert("query->utilityStmt == NULL"), File: "copyto.c", Line:
> 495, PID: 1689825
> ExceptionalCondition at assert.c:52:13
> BeginCopyTo at copyto.c:501:12
> DoCopy at copy.c:313:12
> standard_ProcessUtility at utility.c:738:8
> ProcessUtility at utility.c:523:3
> PortalRunUtility at pquery.c:1158:2
> PortalRunMulti at pquery.c:1315:5
> PortalRun at pquery.c:795:5
> ...
>
> Reproduced starting from 92e38182d.
>
>
Thanks for reporting. I can reproduce on HEAD.
I take a quick look. It seems 92e38182d ignored this case.
I gave a fix that remove the Assert and add an Assert in another if blocks.
Any thoughts?
--
Thanks,
Tender Wang
Commits
-
Fix wrong assertion and poor error messages in "COPY (query) TO".
- c80a1e048397 15.9 landed
- beab395a42b2 13.17 landed
- 6c3b2d204f2b 16.5 landed
- 6a57a457cf7d 12.21 landed
- 68ad9816c189 18.0 landed
- 5e94f616c832 14.14 landed
- 3685ad6188c1 17.1 landed