pgsql: Fix old bug with coercing the result of a COLLATE expression.
От | Tom Lane |
---|---|
Тема | pgsql: Fix old bug with coercing the result of a COLLATE expression. |
Дата | |
Msg-id | E1lW1Rk-0008Rb-6x@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
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 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/27011bcffa74a5113c9b5408c678315e74fb9a70 Modified Files -------------- src/backend/parser/parse_coerce.c | 29 ++++++++++++++++++----------- src/test/regress/expected/collate.out | 16 +++++++++++++++- src/test/regress/sql/collate.sql | 6 ++++++ 3 files changed, 39 insertions(+), 12 deletions(-)
В списке pgsql-committers по дате отправления: