From: | ZhangChi <798604270(at)qq(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result |
Date: | 2025-08-30 01:51:46 |
Message-ID: | tencent_E04DDAE3FA433396407721AEB3E655C81C09@qq.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi tom lane,
Thanks for your reply.
I still have a problem with this. When an INSERT fails, why not undo all the effects of the INSERT?
Original
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Date: 2025年8月29日 23:13
To: 798604270 <798604270(at)qq(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result
PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> In the following test case, the `EXECUTE` statement will fail with an error
> `result of range union would not be contiguous`. The final SELECT query
> should return 1 row as there is only one value `1` in t1.c0 and only one
> value `1` in t3.c0, however, the query returns 0 rows.
I don't see a bug here particularly. If you check the contents of
table t3 at the end of the test, you will see
c0 | c1
----+------------------------
2 | [-761818403,793731612)
(1 row)
in the "wrong" case. This shows that the prepared insert advanced
the sequence underlying "c0 bigserial" before failing, whereas
in the default plan_cache_mode the error occurred before touching
the sequence. This discrepancy isn't a bug. It occurs because
in the default mode the planner will attempt to constant-fold
that messy range expression during planning, and thus it will
hit the range union failure before anything is done to the
sequence. In the generic case the failure occurs in the executor,
and the sequence has already been advanced.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2025-08-30 01:57:05 | Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result |
Previous Message | Ran Benita | 2025-08-29 19:45:18 | Broken PQtrace CopyData display |