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