Assert when executing query on partitioned table

From: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Assert when executing query on partitioned table
Date: 2025-02-20 11:13:53
Message-ID: f5fffe4b-11b2-4557-a864-3587ff9b4c36@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

I got an Assert when executing an "INSERT ... ON CONFLICT ... UPDATE
..." query on partitioned table. Managed to reproduce this situation.

Reproduction order.
-------------------

1) Apply the patch
[v1-0001-Triggering-Assert-on-query-with-ON-CONFLICT.patch] to "master"
branch.

2) Build postgres with key "--enable-injection-points" + build an
extension "injection_points" (src/test/modules/injection_points).

3) Run isolation test onconflict.spec:
make check -C src/test/modules/injection_points

Assert is triggered in postgres with stack, see attached file [stack.txt].

Clarification.
--------------
In the query "INSERT ... ON CONFLICT ... UPDATE ..." when executing
INSERT, a conflict is triggered. But when trying to execute UPDATE, our
tuple has already been moved to another partition and Assert is triggered.

Fixing.
-------
I suggest replace Assert with an error message, see
[v1-0001-draft-of-fix.patch]. This is not a final fix as I am confused
by the comment for Assert: "we don't support an UPDATE of INSERT ON
CONFLICT for a partitioned table".
(Why "don't support an UPDATE"?
It's not forbidden by syntax or errors ...)

--
With best regards,
Dmitry Koval

Postgres Professional: http://postgrespro.com

Attachment Content-Type Size
stack.txt text/plain 3.1 KB
v1-0001-Triggering-Assert-on-query-with-ON-CONFLICT.patch text/plain 3.2 KB
v1-0001-draft-of-fix.patch text/plain 759 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2025-02-20 11:20:29 Re: Add XMLNamespaces to XMLElement
Previous Message Zhijie Hou (Fujitsu) 2025-02-20 11:02:45 RE: create subscription with (origin = none, copy_data = on)