pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add some tests for CREATE OR REPLACE VIEW with column additions
Date: Wed, 04 Mar 2026 01:11:51 +0000
Message-ID: <E1vxamF-002GcW-2u@gemulon.postgresql.org> (raw)

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(-)



view thread (3+ messages)

Message-ID: <E1vxamF-002GcW-2u@gemulon.postgresql.org>
Permalink:  ../E1vxamF-002GcW-2u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vxamF-002GcW-2u@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add some tests for CREATE OR REPLACE VIEW with column additions
  In-Reply-To: <E1vxamF-002GcW-2u@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox