postgresql/src/test/modules
Tom Lane 1281a5c907 Restructure ALTER TABLE execution to fix assorted bugs.
We've had numerous bug reports about how (1) IF NOT EXISTS clauses in
ALTER TABLE don't behave as-expected, and (2) combining certain actions
into one ALTER TABLE doesn't work, though executing the same actions as
separate statements does.  This patch cleans up all of the cases so far
reported from the field, though there are still some oddities associated
with identity columns.

The core problem behind all of these bugs is that we do parse analysis
of ALTER TABLE subcommands too soon, before starting execution of the
statement.  The root of the bugs in group (1) is that parse analysis
schedules derived commands (such as a CREATE SEQUENCE for a serial
column) before it's known whether the IF NOT EXISTS clause should cause
a subcommand to be skipped.  The root of the bugs in group (2) is that
earlier subcommands may change the catalog state that later subcommands
need to be parsed against.

Hence, postpone parse analysis of ALTER TABLE's subcommands, and do
that one subcommand at a time, during "phase 2" of ALTER TABLE which
is the phase that does catalog rewrites.  Thus the catalog effects
of earlier subcommands are already visible when we analyze later ones.
(The sole exception is that we do parse analysis for ALTER COLUMN TYPE
subcommands during phase 1, so that their USING expressions can be
parsed against the table's original state, which is what we need.
Arguably, these bugs stem from falsely concluding that because ALTER
COLUMN TYPE must do early parse analysis, every other command subtype
can too.)

This means that ALTER TABLE itself must deal with execution of any
non-ALTER-TABLE derived statements that are generated by parse analysis.
Add a suitable entry point to utility.c to accept those recursive
calls, and create a struct to pass through the information needed by
the recursive call, rather than making the argument lists of
AlterTable() and friends even longer.

Getting this to work correctly required a little bit of fiddling
with the subcommand pass structure, in particular breaking up
AT_PASS_ADD_CONSTR into multiple passes.  But otherwise it's mostly
a pretty straightforward application of the above ideas.

Fixing the residual issues for identity columns requires refactoring of
where the dependency link from an identity column to its sequence gets
set up.  So that seems like suitable material for a separate patch,
especially since this one is pretty big already.

Discussion: https://postgr.es/m/10365.1558909428@sss.pgh.pa.us
2020-01-15 18:49:24 -05:00
..
brin Add PGXS options to control TAP and isolation tests, take two 2018-12-03 09:27:35 +09:00
commit_ts Initial pgperltidy run for v12. 2019-05-22 13:36:19 -04:00
dummy_index_am Introduce IndexAM fields for parallel vacuum. 2020-01-15 07:24:14 +05:30
dummy_seclabel doc: Fix naming of SELinux 2020-01-10 09:36:55 +09:00
snapshot_too_old Add PGXS options to control TAP and isolation tests, take two 2018-12-03 09:27:35 +09:00
test_bloomfilter Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_ddl_deparse Restructure ALTER TABLE execution to fix assorted bugs. 2020-01-15 18:49:24 -05:00
test_extensions Simplify restriction handling of two-phase commit for temporary objects 2019-01-26 10:45:23 +09:00
test_ginpostinglist Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_integerset Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_misc Avoid using INFO elevel for what are fundamentally debug messages. 2019-09-07 19:03:11 -04:00
test_parser Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_pg_dump Add PGXS options to control TAP and isolation tests, take two 2018-12-03 09:27:35 +09:00
test_predtest Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_rbtree Update copyrights for 2020 2020-01-01 12:21:45 -05:00
test_rls_hooks Make parser rely more heavily on the ParseNamespaceItem data structure. 2020-01-02 11:29:01 -05:00
test_shm_mq Update copyrights for 2020 2020-01-01 12:21:45 -05:00
unsafe_tests Disallow dropping rules on system tables by default 2019-12-20 08:27:37 +01:00
worker_spi Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Revert hooks for session start and end, take two 2019-10-02 09:55:27 +09:00
README Add an enforcement mechanism for global object names in regression tests. 2019-06-29 11:34:00 -04:00

Test extensions and libraries
=============================

src/test/modules contains PostgreSQL extensions that are primarily or entirely
intended for testing PostgreSQL and/or to serve as example code. The extensions
here aren't intended to be installed in a production server and aren't suitable
for "real work".

Furthermore, while you can do "make install" and "make installcheck" in
this directory or its children, it is NOT ADVISABLE to do so with a server
containing valuable data.  Some of these tests may have undesirable
side-effects on roles or other global objects within the tested server.
"make installcheck-world" at the top level does not recurse into this
directory.

Most extensions have their own pg_regress tests or isolationtester specs. Some
are also used by tests elsewhere in the tree.

If you're adding new hooks or other functionality exposed as C-level API this
is where to add the tests for it.