Re: Alternative to \copy in psql modelled after \g - Mailing list pgsql-hackers

From Daniel Verite
Subject Re: Alternative to \copy in psql modelled after \g
Date
Msg-id 529c12d1-fd00-4631-89e7-59e6ef6c46c6@manitou-mail.org
Whole thread Raw
In response to Re: Alternative to \copy in psql modelled after \g  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: Alternative to \copy in psql modelled after \g  (Fabien COELHO <coelho@cri.ensmp.fr>)
List 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 by date:

Previous
From: navneet nikku
Date:
Subject: Procedures with out parameter(Postgresql 11)
Next
From: Pavel Stehule
Date:
Subject: Re: Procedures with out parameter(Postgresql 11)