Re: Alternative to \copy in psql modelled after \g

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: Alternative to \copy in psql modelled after \g
Дата
Msg-id 529c12d1-fd00-4631-89e7-59e6ef6c46c6@manitou-mail.org
обсуждение исходный текст
Ответ на Re: Alternative to \copy in psql modelled after \g  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: Alternative to \copy in psql modelled after \g  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
    Fabien COELHO wrote:

>   sql> SELECT 1 \g /BAD
>   /BAD: Permission denied
>
>   sql> \echo :ERROR
>   false

That seems broken, because it's pointless to leave out a class of errors
from ERROR. Presumably the purpose of ERROR is to enable
error checking like:
  \if :ERROR
    ... error processing
  \endif

Now if you download data with SELECT or COPY and we can't even
create the file, how is that a good idea to intentionally have the
script fail to detect it? What purpose does it satisfy?

> The documentation states that ERROR is about SQL, not psql internal stuff:
>
>  ERROR true if the last SQL query failed, false if it succeeded.
>        See also SQLSTATE.

ERROR is set by SetResultVariables(PGresult *results, bool success)
and takes the value of "success", ignoring the PGresult.
So why is ERROR independant of the SQL result, relatively to your
claim that it should never reflect anything else?


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


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

Предыдущее
От: navneet nikku
Дата:
Сообщение: Procedures with out parameter(Postgresql 11)
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Procedures with out parameter(Postgresql 11)