postgresql/src/backend
Michael Paquier ecfed4a122 Improve error handling of column references in expression transformation
Column references are not allowed in default expressions and partition
bound expressions, and are restricted as such once the transformation of
their expressions is done.  However, trying to use more complex column
references can lead to confusing error messages.  For example, trying to
use a two-field column reference name for default expressions and
partition bounds leads to "missing FROM-clause entry for table", which
makes no sense in their respective context.

In order to make the errors generated more useful, this commit adds more
verbose messages when transforming column references depending on the
context.  This has a little consequence though: for example an
expression using an aggregate with a column reference as argument would
cause an error to be generated for the column reference, while the
aggregate was the problem reported before this commit because column
references get transformed first.

The confusion exists for default expressions for a long time, and the
problem is new as of v12 for partition bounds.  Still per the lack of
complaints on the matter no backpatch is done.

The patch has been written by Amit Langote and me, and Tom Lane has
provided the improvement of the documentation for default expressions on
the CREATE TABLE page.

Author: Amit Langote, Michael Paquier
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/20190326020853.GM2558@paquier.xyz
2019-03-27 21:04:25 +09:00
..
access Switch some palloc/memset calls to palloc0 2019-03-27 12:02:50 +09:00
bootstrap tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
catalog Improve error handling of column references in expression transformation 2019-03-27 21:04:25 +09:00
commands Fix partitioned index creation bug with dropped columns 2019-03-26 20:19:28 -03:00
executor tableam: Add table_get_latest_tid, to wrap heap_get_latest_tid. 2019-03-25 17:14:48 -07:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Renaming for new subscripting mechanism 2019-02-01 12:50:32 -03:00
lib Further code review for new integerset code. 2019-03-25 12:23:48 -04:00
libpq Add DNS SRV support for LDAP server discovery. 2019-03-21 15:28:17 +13:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Fix use of wrong datatype with sizeof(). 2019-03-25 11:28:06 -04:00
optimizer Build "other rels" of appendrel baserels in a separate step. 2019-03-26 18:21:10 -04:00
parser Improve error handling of column references in expression transformation 2019-03-27 21:04:25 +09:00
partitioning Fix misplaced const 2019-03-26 09:23:08 +01:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Add shared_memory_type GUC. 2019-02-03 12:47:26 +01:00
postmaster Add macro to cast away volatile without allowing changes to underlying type 2019-03-25 09:37:03 +01:00
regex Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
replication Add walreceiver API to get remote server version 2019-03-15 10:16:26 +01:00
rewrite tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Rename nodes/relation.h to nodes/pathnodes.h. 2019-01-29 16:49:25 -05:00
storage Track unowned relations in doubly-linked list 2019-03-27 02:39:39 +01:00
tcop Transaction chaining 2019-03-24 11:33:02 +01:00
tsearch Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
utils Fix off-by-one error in txid_status(). 2019-03-27 21:30:04 +13:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00