COPY TO: provide hint when WHERE clause is used

Поиск
Список
Период
Сортировка
От torikoshia
Тема COPY TO: provide hint when WHERE clause is used
Дата
Msg-id 3520c224c5ffac0113aef84a9179f37e@oss.nttdata.com
обсуждение исходный текст
Список pgsql-hackers
Hi,

I saw a user wanted to restrict the rows copied by COPY TO using a WHERE
clause, but ran into an error.

As you know, COPY FROM supports WHERE, but COPY TO does not:

   =# copy t1 to stdout where i > 5;
   ERROR:  WHERE clause not allowed with COPY TO
   LINE 1: copy t1 to stdout where i > 5;
                           ^

In such cases, we can do with specifying a query as the target of COPY:

   =# copy (select i from t1 where i > 5) to stdout;

However, as shown in the first example, no hint is provided in the error
message.

For views or others, COPY TO already provides a helpful hint message:

   =# copy v1 to stdout;
   ERROR:  cannot copy from view "v1"
   HINT:  Try the COPY (SELECT ...) TO variant.

Considering what the user was trying to do, it might be helpful to
provide a similar hint in this case as well.
I’ve attached a patch that adds such a hint.

What do you think?


--
Regards,

--
Atsushi Torikoshi
Seconded from NTT DATA Japan Corporation to SRA OSS K.K.
Вложения

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