Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list" - Mailing list pgsql-hackers

From Haotian Chen
Subject Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list"
Date
Msg-id KL1PR03MB728644D79999D6BBF65E4D6FA482A@KL1PR03MB7286.apcprd03.prod.outlook.com
Whole thread Raw
Responses Re: Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list"
List pgsql-hackers

Hi hackers,

 

I found that dumped view SQL failed to execute due to the explicit cast

of negative number, and I took a look at the defined SQL in view and then

found -1 in the group by clause. I suppose it’s the main reason the sql

cannot be executed and raised ERROR "GROUP BY position -1 is not in select list"

 

postgres=# create view v1 as select * from t1 group by a,b,-1::int;

CREATE VIEW

postgres=# \d+ v1;

                             View "public.v1"

 Column |  Type   | Collation | Nullable | Default | Storage | Description 

--------+---------+-----------+----------+---------+---------+-------------

 a      | integer |           |          |         | plain   | 

 b      | integer |           |          |         | plain   | 

View definition:

 SELECT a,

    b

   FROM t1

  GROUP BY a, b, (- 1);

 

After exploring codes, I suppose we should treat operator plus constant

as -'nnn'::typename instead of const, my patch just did this by handling

Opexpr especially, but I am not sure it’s the best way or not, BTW do you

guys have any suggestions and another approach?

 

--
Best Regards,
Haotian

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: GUC names in messages
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: possibility to read dumped table's name from file