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/[email protected]

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

Reply via email to