pgsql: Record dependencies on the target columns of MERGE actions.

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Record dependencies on the target columns of MERGE actions.
Date: 2026-11-23 19:22:42
Message-ID: E1xVZcg-000000003Y5-0lpM@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Record dependencies on the target columns of MERGE actions.

For an INSERT or UPDATE query, we add a dependency on each target
column, to guard against things like dropping the column or altering
its type, but MERGE didn't get the memo.

Fix by also adding a dependency on each target column of each INSERT
or UPDATE action of a MERGE query.

Backpatch to v15, where MERGE was introduced.

Note: This won't fix existing rules or SQL-standard function bodies,
unless they're re-created.

Reported-by: Henson Choi <assam258(at)gmail(dot)com>
Author: Henson Choi <assam258(at)gmail(dot)com>
Reviewed-by: Prashant Chinnam <crprashant(at)hotmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAAAe_zBHzEFR9bFSiJYfve7%3DQoWG_cL8%2BTWxx8vz47Jy0kUSHQ%40mail.gmail.com
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a1725d9fcede2904ebd7506c306e38fe3912a999

Modified Files
--------------
src/backend/catalog/dependency.c | 52 +++++++++++++++++------
src/test/regress/expected/create_function_sql.out | 43 +++++++++++++++++++
src/test/regress/expected/rules.out | 44 +++++++++++++++++++
src/test/regress/sql/create_function_sql.sql | 21 +++++++++
src/test/regress/sql/rules.sql | 19 +++++++++
5 files changed, 166 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-11-23 20:09:49 pgsql: Add missing #undef in simplehash.h.
Previous Message Nathan Bossart 2026-11-23 18:32:36 pgsql: pg_restore: Fix incompatibilities with extracted tar dumps.