[PATCH] Fix null pointer dereference in PG19
Aleksander Alekseev <aleksander@tigerdata.com>
From: Aleksander Alekseev <aleksander@tigerdata.com>
To: PostgreSQL Development <pgsql-hackers@postgresql.org>
Date: 2026-04-21T13:40:49Z
Lists: pgsql-hackers
Attachments
- stacktrace.txt (text/plain)
- crash.sql (application/sql)
- v1-0001-Forbid-FOR-PORTION-OF-on-views-with-INSTEAD-OF-tr.patch (text/x-patch) patch v1-0001
Hi, I discovered that it's possible to crash Postgres when using VIEWS, FOR PORTION OF syntax and INSTEAD OF triggers together. See crash.sql. This happens because in ExecModifyTable() around line 4827 there is no check for `relkind == RELKIND_VIEW`. If this is the case `tupleid` ends up being NULL which causes null pointer dereference later when ExecDeleteEpilogue() or ExecUpdateEpilogue() calls ExecForPortionOfLeftovers() with tupleid = NULL. An example stacktrace is attached. I propose fixing this by explicitly forbidding using the named features together. See the patch. -- Best regards, Aleksander Alekseev