pgsql: Add some tests for CREATE OR REPLACE VIEW with column additions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add some tests for CREATE OR REPLACE VIEW with column additions
Date: 2026-03-04 01:11:51
Message-ID: E1vxamF-002GcW-2u@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add some tests for CREATE OR REPLACE VIEW with column additions

When working on an already-defined view with matching attributes, CREATE
OR REPLACE VIEW would internally generate an ALTER TABLE command with a
set of AT_AddColumnToView sub-commands, one for each attribute added.

Such a command is stored in event triggers twice:
- Once as a simple command.
- Once as an ALTER TABLE command, as it has sub-commands.

There was no test coverage to track this command pattern in terms of
event triggers and DDL deparsing:
- For the test module test_ddl_deparse, two command notices are issued.
- For event triggers, a CREATE VIEW command is logged twice, which may
look a bit weird first, but again this maps with the internal behavior
of how the commands are built, and how the event trigger code reacts in
terms of commands gathered.

While on it, this adds a test for CREATE SCHEMA with a CREATE VIEW
command embedded in it, case supported by the grammar but not covered
yet.

This hole in the test coverage has been found while digging into what
would be a similar behavior for sequences if adding attributes to them
with ALTER TABLE variants, after the initial relation creation.

Discussion: https://postgr.es/m/aaFG9bqkEn0RhLJG@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9ef6381829cb92a23ed7730335a669cb16af3580

Modified Files
--------------
src/test/modules/test_ddl_deparse/expected/create_view.out | 6 ++++++
src/test/modules/test_ddl_deparse/sql/create_view.sql | 3 +++
src/test/regress/expected/event_trigger.out | 10 +++++++++-
src/test/regress/sql/event_trigger.sql | 7 ++++++-
4 files changed, 24 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2026-03-04 01:59:30 pgsql: Remove redundant restriction checks in apply_child_basequals
Previous Message Melanie Plageman 2026-03-03 21:04:39 pgsql: Add read_stream_{pause,resume}()