postgresql/src/backend
Tom Lane c402b02b9f Fix old bug with coercing the result of a COLLATE expression.
There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs.com
2021-04-12 14:37:49 -04:00
..
access Remove COMMIT_TS_SETTS record. 2021-04-12 00:04:30 +09:00
bootstrap Split backend status and progress related functionality out of pgstat.c. 2021-04-03 11:42:52 -07:00
catalog Standardize pg_authid oid_symbol values. 2021-04-10 12:01:41 -07:00
commands Avoid unnecessary table open/close in TRUNCATE command. 2021-04-12 00:05:58 +09:00
executor Fixes for query_id feature 2021-04-08 11:16:01 -04:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Speedup ScalarArrayOpExpr evaluation 2021-04-08 23:51:22 +12:00
lib Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq Refactor hba_authname 2021-04-07 14:24:47 +02:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Improve slightly misleading comments in nodeFuncs.c 2021-04-10 19:19:45 +12:00
optimizer Speedup ScalarArrayOpExpr evaluation 2021-04-08 23:51:22 +12:00
parser Fix old bug with coercing the result of a COLLATE expression. 2021-04-12 14:37:49 -04:00
partitioning Speedup ScalarArrayOpExpr evaluation 2021-04-08 23:51:22 +12:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
postmaster Set pg_class.reltuples for partitioned tables 2021-04-09 11:50:33 -04:00
regex Further tweak memory management for regex DFAs. 2021-03-08 16:32:29 -05:00
replication Allow TRUNCATE command to truncate foreign tables. 2021-04-08 20:56:08 +09:00
rewrite Clean up treatment of missing default and CHECK-constraint records. 2021-04-06 10:34:39 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Fix uninitialized variable from commit a4d75c86b. 2021-04-11 11:46:46 -04:00
storage Optionally prefetch referenced data in recovery. 2021-04-08 23:20:42 +12:00
tcop SQL-standard function body 2021-04-07 21:47:55 +02:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 22:22:47 -04:00
utils Move log_autovacuum_min_duration into its correct sections 2021-04-12 13:53:17 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00