psql - add special variable to reflect the last query status

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql - add special variable to reflect the last query status
Date: 2017-04-04 20:05:10
Message-ID: alpine.DEB.2.20.1704042158020.12290@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


After some discussions about what could be useful since psql scripts now
accepts tests, this patch sets a few variables which can be used by psql
after a "front door" (i.e. actually typed by the user) query:

- RESULT_STATUS: the status of the query
- ERROR: whether the query failed
- ERROR_MESSAGE: ...
- ROW_COUNT: #rows affected

SELECT * FROM ;
\if :ERROR
\echo oops
\q
\endif

I'm not sure that the names are right. Maybe STATUS would be better than
RESULT_STATUS.

--
Fabien.

Attachment Content-Type Size
psql-result-status-1.patch text/x-diff 5.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-04-04 20:13:48 Re: Parallel Append implementation
Previous Message David Steele 2017-04-04 19:16:55 Re: Re: PATCH: pageinspect / add page_checksum and bt_page_items(bytea)