Re: Core dump happens when execute sql CREATE VIEW v1(c1) AS (SELECT ('4' COLLATE "C")::INT FROM generate_series(1, 10));

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yulin PEI <ypeiae(at)connect(dot)ust(dot)hk>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Core dump happens when execute sql CREATE VIEW v1(c1) AS (SELECT ('4' COLLATE "C")::INT FROM generate_series(1, 10));
Date: 2021-04-12 16:59:43
Message-ID: 2936041.1618246783@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yulin PEI <ypeiae(at)connect(dot)ust(dot)hk> writes:
> I found it could cause a crash when executing sql statement: `CREATE VIEW v1(c1) AS (SELECT ('4' COLLATE "C")::INT FROM generate_series(1, 10)); ` in postgres 13.2 release.

Nice catch. I don't think the code in DefineVirtualRelation is wrong:
exprCollation shouldn't report any collation for an expression of a
non-collatable type. Rather the problem is with an old kluge in
coerce_type(), which will push a type coercion underneath a CollateExpr
... without any mind for the possibility that the coercion result isn't
collatable. So the right fix is more or less the attached.

regards, tom lane

Attachment Content-Type Size
fix-bogus-collation-coercion.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-04-12 17:03:11 Re: Uninitialized scalar variable (UNINIT) (src/backend/statistics/extended_stats.c)
Previous Message Ranier Vilela 2021-04-12 16:55:13 Re: Uninitialized scalar variable (UNINIT) (src/backend/statistics/extended_stats.c)