postgresql/src
Tom Lane 8a7bd1e6cb 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:22 -04:00
..
backend Fix old bug with coercing the result of a COLLATE expression. 2021-04-12 14:37:22 -04:00
bin pg_checksums: Fix progress reporting. 2021-04-03 00:07:49 +09:00
common Second thoughts on TOAST decompression. 2020-11-02 11:25:18 -05:00
fe_utils psql: call clearerr() just before printing 2021-03-29 18:34:39 -03:00
include Use correct spelling of statistics kind 2021-03-23 05:00:19 +01:00
interfaces Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib 2021-04-02 16:42:29 -04:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Translation updates 2021-02-08 17:41:32 +01:00
port pg_attribute_no_sanitize_alignment() macro 2021-02-13 17:49:08 -05:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:31 -05:00
test Fix old bug with coercing the result of a COLLATE expression. 2021-04-12 14:37:22 -04:00
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:47 -05:00
tools backpatch "jit: Add support for LLVM 12." 2020-12-07 18:32:32 -08:00
tutorial tutorial: land height is "elevation", not "altitude" 2021-03-10 20:25:18 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00