postgresql/src/test
Tom Lane 43f2e7634d Fix mis-deparsing of ORDER BY lists when there is a name conflict.
If an ORDER BY item in SELECT is a bare identifier, the parser
first seeks it as an output column name of the SELECT (for SQL92
compatibility).  However, ruleutils.c is expecting the SQL99
interpretation where such a name is an input column name.  So it's
possible to produce an incorrect display of a view in the (admittedly
pretty ill-advised) case where some other column is renamed in the
SELECT output list to match an ORDER BY column.

This can be fixed by table-qualifying such names in the dumped
view text.  To avoid cluttering less-ill-advised queries, we'd
like to do so only when there's an actual name conflict.
That requires passing the current get_query_def call's resultDesc
parameter down to get_variable, so that it can determine what
the output column names are.  In hopes of reducing rather than
increasing notational clutter in ruleutils.c, I moved that value
into the deparse_context struct and removed it from the parameter
lists of get_query_def's other subroutines.

I made a few other cosmetic changes while at it:
* Likewise move the colNamesVisible parameter into deparse_context.
* Rename deparse_context's windowTList field to targetList,
since it's no longer used only in connection with WINDOW clauses.
* Replace the special_exprkind field with a bool inGroupBy,
since that was all it was being used for, and the apparent
flexibility of storing a ParseExprKind proved to be illusory.
(We need a separate varInOrderBy field to make this patch work.)
* Remove useless save/restore logic in get_select_query_def.

In principle, this bug is quite old.  However, it seems unreachable
before 1b4d280ea, because before that the presence of "new" and "old"
entries in a view's rangetable caused us to always table-qualify every
Var reference in dumped views.  Hence, back-patch to v16 where that
came in.

Per bug #18589 from Quynh Tran.

Discussion: https://postgr.es/m/18589-70091cb81db1a3f1@postgresql.org
2024-08-29 13:24:17 -04:00
..
authentication Fix an assortment of typos 2024-05-04 02:33:25 +12:00
examples Update copyright for 2024 2024-01-03 20:49:05 -05:00
icu Address more review comments on commit 2d819a08a1. 2024-03-18 11:58:13 -07:00
isolation Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands 2024-08-24 18:48:48 +03:00
kerberos Move Kerberos module 2024-04-08 02:49:30 +03:00
ldap ldapurl is supported with simple bind 2024-07-23 10:17:55 +02:00
locale Update copyright for 2024 2024-01-03 20:49:05 -05:00
mb
modules Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands 2024-08-24 18:48:48 +03:00
perl Log more info when wait-for-catchup tests time out. 2024-08-12 13:18:36 -04:00
recovery Message style improvements 2024-08-29 14:43:34 +02:00
regress Fix mis-deparsing of ORDER BY lists when there is a name conflict. 2024-08-29 13:24:17 -04:00
ssl Force nodes for SSL tests to start in TCP mode 2024-07-08 11:40:58 -04:00
subscription Rename the conflict types for the origin differ cases. 2024-08-29 09:12:12 +05:30
Makefile Refactor PG_TEST_EXTRA logic in autoconf build 2022-09-20 11:24:16 -07:00
meson.build Move libpq encryption negotiation tests 2024-04-12 19:52:37 +03:00
README Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00

PostgreSQL tests
================

This directory contains a variety of test infrastructure as well as some of the
tests in PostgreSQL. Not all tests are here -- in particular, there are more in
individual contrib/ modules and in src/bin.

Not all these tests get run by "make check". Check src/test/Makefile to see
which tests get run automatically.

authentication/
  Tests for authentication (but see also below)

examples/
  Demonstration programs for libpq that double as regression tests via
  "make check"

isolation/
  Tests for concurrent behavior at the SQL level

kerberos/
  Tests for Kerberos/GSSAPI authentication and encryption

ldap/
  Tests for LDAP-based authentication

locale/
  Sanity checks for locale data, encodings, etc

mb/
  Tests for multibyte encoding (UTF-8) support

modules/
  Extensions used only or mainly for test purposes, generally not suitable
  for installing in production databases

perl/
  Infrastructure for Perl-based TAP tests

recovery/
  Test suite for recovery and replication

regress/
  PostgreSQL's main regression test suite, pg_regress

ssl/
  Tests to exercise and verify SSL certificate handling

subscription/
  Tests for logical replication