From: | Haotian Chen <charliett2233(at)outlook(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list" |
Date: | 2023-11-30 06:06:20 |
Message-ID: | KL1PR03MB728644D79999D6BBF65E4D6FA482A@KL1PR03MB7286.apcprd03.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
v1-0001-fix-dump-view-fails-with-group-by-clause.patch | application/octet-stream | 1.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2023-11-30 06:13:19 | Re: proposal: possibility to read dumped table's name from file |
Previous Message | Michael Paquier | 2023-11-30 05:59:21 | Re: GUC names in messages |