Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-16 Thread Tom Lane
Thomas Munro writes: > On Fri, Oct 13, 2017 at 10:01 AM, Tom Lane wrote: >> But I see very >> little case for allowing CTEs to capture such references, because surely >> we are never going to allow that to do anything useful, and we have >> several years of precedent now that they don't capture.

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-15 Thread Thomas Munro
On Fri, Oct 13, 2017 at 10:01 AM, Tom Lane wrote: > But I see very > little case for allowing CTEs to capture such references, because surely > we are never going to allow that to do anything useful, and we have > several years of precedent now that they don't capture. For what it's worth, SQL Se

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Julien Rouhaud
On Fri, Oct 13, 2017 at 5:22 AM, Tom Lane wrote: > Thomas Munro writes: >> On Fri, Oct 13, 2017 at 12:46 PM, Tom Lane wrote: >>> Yeah, I agree --- personally I'd never write a query like that. But >>> the fact that somebody ran into it when v10 has been out for barely >>> a week suggests that p

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Tom Lane
Thomas Munro writes: > On Fri, Oct 13, 2017 at 12:46 PM, Tom Lane wrote: >> Yeah, I agree --- personally I'd never write a query like that. But >> the fact that somebody ran into it when v10 has been out for barely >> a week suggests that people are doing it. > Not exactly -- Julien's bug repor

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Thomas Munro
On Fri, Oct 13, 2017 at 12:46 PM, Tom Lane wrote: > Thomas Munro writes: >> On Fri, Oct 13, 2017 at 10:01 AM, Tom Lane wrote: >>> The CTE was simply not part of the available namespace for the INSERT's >>> target, so it found the regular table instead. v10 has thus broken >>> cases that used to

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Tom Lane
Thomas Munro writes: > On Fri, Oct 13, 2017 at 10:01 AM, Tom Lane wrote: >> The CTE was simply not part of the available namespace for the INSERT's >> target, so it found the regular table instead. v10 has thus broken >> cases that used to work. I think that's a bug. > Hmm. Yeah. I have to s

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Thomas Munro
On Fri, Oct 13, 2017 at 10:01 AM, Tom Lane wrote: > Thomas Munro writes: >> Before that, CTE used as modify targets produced a different error message: > >> postgres=# WITH d AS (SELECT 42) INSERT INTO d VALUES (1); >> ERROR: relation "d" does not exist >> LINE 1: WITH d AS (SELECT 42) INSERT IN

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Tom Lane
Thomas Munro writes: > On Fri, Oct 13, 2017 at 8:50 AM, Tom Lane wrote: >> Hm. I actually think the bug here is that 18ce3a4ab introduced >> anything into setTargetTable at all. There was never previously >> any assumption that the target could be anything but a regular >> table, so we just ign

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Thomas Munro
On Fri, Oct 13, 2017 at 8:50 AM, Tom Lane wrote: > Julien Rouhaud writes: >> On Mon, Oct 9, 2017 at 10:43 PM, Thomas Munro >> wrote: >>> I suppose we could consider moving the schemaname check into >>> getRTEForSpecialRelationType(), since otherwise both callers need to >>> do that (and as you d

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-12 Thread Tom Lane
Julien Rouhaud writes: > On Mon, Oct 9, 2017 at 10:43 PM, Thomas Munro > wrote: >> I suppose we could consider moving the schemaname check into >> getRTEForSpecialRelationType(), since otherwise both callers need to >> do that (and as you discovered, one forgot). > Thanks for the feedback. That

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-09 Thread Julien Rouhaud
On Mon, Oct 9, 2017 at 10:43 PM, Thomas Munro wrote: > > I suppose we could consider moving the schemaname check into > getRTEForSpecialRelationType(), since otherwise both callers need to > do that (and as you discovered, one forgot). Thanks for the feedback. That was my first idea, but I assum

Re: [HACKERS] oversight in EphemeralNamedRelation support

2017-10-09 Thread Thomas Munro
On Tue, Oct 10, 2017 at 2:35 AM, Julien Rouhaud wrote: > Hugo Mercier (in Cc) reported me an error in a query, failing since pg10. > > Simple test case to reproduce: > > CREATE TABLE public.test (id integer); > WITH test AS (select 42) INSERT INTO public.test SELECT * FROM test; > > which will fai

[HACKERS] oversight in EphemeralNamedRelation support

2017-10-09 Thread Julien Rouhaud
Hi, Hugo Mercier (in Cc) reported me an error in a query, failing since pg10. Simple test case to reproduce: CREATE TABLE public.test (id integer); WITH test AS (select 42) INSERT INTO public.test SELECT * FROM test; which will fail with "relation "test" cannot be the target of a modifying stat