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

Поиск
Список
Период
Сортировка
От Haotian Chen
Тема Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list"
Дата
Msg-id KL1PR03MB728644D79999D6BBF65E4D6FA482A@KL1PR03MB7286.apcprd03.prod.outlook.com
обсуждение исходный текст
Ответы Re: Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list"  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: GUC names in messages
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: proposal: possibility to read dumped table's name from file