Re: BUG #18238: Cross-partitition MERGE/UPDATE with delete-preventing trigger leads to incorrect memory access

Поиск
Список
Период
Сортировка
От jian he
Тема Re: BUG #18238: Cross-partitition MERGE/UPDATE with delete-preventing trigger leads to incorrect memory access
Дата
Msg-id CACJufxEFDPZM_Jk56oD3rpCx0yojc9MNB_YXr3k=Ltpn+MWChQ@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #18238: Cross-partitition MERGE/UPDATE with delete-preventing trigger leads to incorrect memory access  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #18238: Cross-partitition MERGE/UPDATE with delete-preventing trigger leads to incorrect memory access  (jian he <jian.universality@gmail.com>)
Список pgsql-bugs
On Sun, Dec 10, 2023 at 1:10 AM PG Bug reporting form
<noreply@postgresql.org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference:      18238
> Logged by:          Alexander Lakhin
> Email address:      exclusion@gmail.com
> PostgreSQL version: 16.1
> Operating system:   Ubuntu 22.04
> Description:
>
> When the following query:
> CREATE TABLE t (a int) PARTITION BY LIST (a);
> CREATE TABLE tp1 PARTITION OF t FOR VALUES IN (1);
> CREATE TABLE tp2 PARTITION OF t FOR VALUES IN (2);
> INSERT INTO t VALUES (1);
>
> CREATE FUNCTION tf() RETURNS TRIGGER LANGUAGE plpgsql AS
>   $$ BEGIN RETURN NULL; END; $$;
>
> CREATE TRIGGER tr BEFORE DELETE ON t
>   FOR EACH ROW EXECUTE PROCEDURE tf();
>
> MERGE INTO t USING t st ON TRUE WHEN MATCHED THEN UPDATE SET a = 2;
>

--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -1828,10 +1828,10 @@ ExecCrossPartitionUpdate(ModifyTableContext *context,
                 * additional rechecking, and might end up executing a different
                 * action entirely).
                 */
-               if (context->relaction != NULL)
-                       return false;
-               else if (TupIsNull(epqslot))
+               if (TupIsNull(epqslot))
                        return true;
+               else if (context->relaction != NULL)
+                       return false;
                else
                {
                        /* Fetch the most recent version of old tuple. */

seems to work.
but now the new command tag is MERGE 1. should be MERGE 0.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Alexander Lakhin
Дата:
Сообщение: Re: BUG #18224: message bug in libpqwalreceiver.c.
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #18239: select position ('' in 'A') returns 1