From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Making CASE error handling less surprising |
Date: | 2020-07-24 15:22:10 |
Message-ID: | 433224.1595604130@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Ah, I see what you mean. Yeah, that throws an error today, and it
> still would with the patch I was envisioning (attached), because
> inlining does Param substitution in a different way. I'm not
> sure that we could realistically fix the inlining case with this
> sort of approach.
Here's another example that we can't possibly fix with Param substitution
hacking, because there are no Params involved in the first place:
select f1, case when f1 = 42 then 1/i else null end
from (select f1, 0 as i from int4_tbl) ss;
Pulling up the subquery results in "1/0", so this fails today,
even though "f1 = 42" is never true.
Attached is a v3 patch that incorporates the leakproofness idea.
As shown in the new case.sql tests, this does fix both the SQL
function and subquery-pullup cases.
To keep the join regression test results the same, I marked int48()
as leakproof, which is surely safe enough. Probably we should make
a push to mark all unconditionally-safe implicit coercions as
leakproof, but that's a separate matter.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
safer-CASE-handling-3.patch | text/x-diff | 15.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2020-07-24 15:33:52 | Any objections to implementing LogicalDecodeMessageCB for pgoutput? |
Previous Message | Robert Haas | 2020-07-24 15:18:48 | Re: Default setting for enable_hashagg_disk |