Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Tom Lane
"Jonathan S. Katz" writes: > On 2/17/23 1:18 PM, Tom Lane wrote: >> It can be reproduced with INSERT too, on the same principle as the others: >> put the DML command inside a WITH, and give it an alias conflicting with >> the outer query. > Ah, I see based on your example below. I did not alias t

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Jonathan S. Katz
On 2/17/23 1:18 PM, Tom Lane wrote: It can be reproduced with INSERT too, on the same principle as the others: put the DML command inside a WITH, and give it an alias conflicting with the outer query. Ah, I see based on your example below. I did not alias the INSERT statement in the way (and

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Tom Lane
"Jonathan S. Katz" writes: > I spoke too soon -- I was looking at the wrong logs. I did reproduce it > with UPDATE, but not INSERT. It can be reproduced with INSERT too, on the same principle as the others: put the DML command inside a WITH, and give it an alias conflicting with the outer query.

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Jonathan S. Katz
On 2/17/23 11:19 AM, Jonathan S. Katz wrote: On 2/17/23 10:09 AM, Tom Lane wrote: Agreed on that -- while it's harder to set up, I do prefer the original example[1] to demonstrate this, as it shows the issue given it does not have those multiple occurrences, at least not within the same conte

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Jonathan S. Katz
On 2/17/23 10:09 AM, Tom Lane wrote: "Jonathan S. Katz" writes: Good catch. Do you have thoughts on how we can adjust the naming logic to handle cases like this? I think it's perfectly fine that ruleutils decided to use different aliases for the two different occurrences of "t1": the statemen

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Tom Lane
"Jonathan S. Katz" writes: > Good catch. Do you have thoughts on how we can adjust the naming logic > to handle cases like this? I think it's perfectly fine that ruleutils decided to use different aliases for the two different occurrences of "t1": the statement is quite confusing as written. Th

Re: The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread Jonathan S. Katz
On 2/17/23 5:22 AM, vignesh C wrote: Hi, The output sql generated by pg_dump for the below function refers to a modified table name: create table t1 (c1 int); create table t2 (c1 int); CREATE OR REPLACE FUNCTION test_fun(c1 int) RETURNS void LANGUAGE SQL BEGIN ATOMIC WITH delete_t1 AS (

The output sql generated by pg_dump for a create function refers to a modified table name

2023-02-17 Thread vignesh C
Hi, The output sql generated by pg_dump for the below function refers to a modified table name: create table t1 (c1 int); create table t2 (c1 int); CREATE OR REPLACE FUNCTION test_fun(c1 int) RETURNS void LANGUAGE SQL BEGIN ATOMIC WITH delete_t1 AS ( DELETE FROM t1 WHERE c1 = $1