summaryrefslogtreecommitdiff
path: root/src/bin/psql/prompt.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-06-28 00:12:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-06-28 00:12:40 +0000
commitf9ebf36970df6e61142dbe7590482cd240fdb66a (patch)
tree9dd310595417c131d80a018540029ec822729424 /src/bin/psql/prompt.c
parentea20397b79f795441d48eae0ace03caf4c108a3c (diff)
Update psql for some features of new FE/BE protocol. There is a
client-side AUTOCOMMIT mode now: '\set AUTOCOMMIT off' supports SQL-spec commit behavior. Get rid of LO_TRANSACTION hack --- the LO operations just work now, using libpq's ability to track the transaction status. Add a VERBOSE variable to control verboseness of error message display, and add a %T prompt-string code to show current transaction-block status. Superuser state display in the prompt string correctly follows SET SESSION AUTHORIZATION commands. Control-C works to get out of COPY IN state.
Diffstat (limited to 'src/bin/psql/prompt.c')
-rw-r--r--src/bin/psql/prompt.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index f9d66b752ec..0df16d4b0c6 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.25 2003/04/04 20:42:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.26 2003/06/28 00:12:40 tgl Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
@@ -44,6 +44,7 @@
* or a ! if session is not connected to a database;
* in prompt2 -, *, ', or ";
* in prompt3 nothing
+ * %T - transaction status: empty, *, !, ? (unknown or no connection)
* %? - the error code of the last query (not yet implemented)
* %% - a percent sign
*
@@ -172,7 +173,7 @@ get_prompt(promptStatus_t status)
case '8':
case '9':
*buf = parse_char((char **)&p);
- break;
+ break;
case 'R':
switch (status)
@@ -204,20 +205,39 @@ get_prompt(promptStatus_t status)
buf[0] = '\0';
break;
}
+ break;
+
+ case 'T':
+ if (!pset.db)
+ buf[0] = '?';
+ else switch (PQtransactionStatus(pset.db))
+ {
+ case PQTRANS_IDLE:
+ buf[0] = '\0';
+ break;
+ case PQTRANS_ACTIVE:
+ case PQTRANS_INTRANS:
+ buf[0] = '*';
+ break;
+ case PQTRANS_INERROR:
+ buf[0] = '!';
+ break;
+ default:
+ buf[0] = '?';
+ break;
+ }
+ break;
case '?':
/* not here yet */
break;
case '#':
- {
- if (pset.issuper)
- buf[0] = '#';
- else
- buf[0] = '>';
-
- break;
- }
+ if (is_superuser())
+ buf[0] = '#';
+ else
+ buf[0] = '>';
+ break;
/* execute command */
case '`':