1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

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.
This commit is contained in:
Tom Lane
2003-06-28 00:12:40 +00:00
parent ea20397b79
commit f9ebf36970
14 changed files with 476 additions and 463 deletions

View File

@@ -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 '`':