1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +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/variables.c,v 1.10 2003/03/20 06:43:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.11 2003/06/28 00:12:40 tgl Exp $
*/
#include "postgres_fe.h"
#include "variables.h"
@ -33,8 +33,6 @@ CreateVariableSpace(void)
return ptr;
}
const char *
GetVariable(VariableSpace space, const char *name)
{
@ -59,14 +57,19 @@ GetVariable(VariableSpace space, const char *name)
return NULL;
}
bool
GetVariableBool(VariableSpace space, const char *name)
{
return GetVariable(space, name) != NULL ? true : false;
}
const char *val;
val = GetVariable(space, name);
if (val == NULL)
return false; /* not set -> assume "off" */
if (strcmp(val, "off") == 0)
return false;
/* for backwards compatibility, anything except "off" is taken as "true" */
return true;
}
bool
VariableEquals(VariableSpace space, const char name[], const char value[])
@ -76,7 +79,6 @@ VariableEquals(VariableSpace space, const char name[], const char value[])
return var && (strcmp(var, value) == 0);
}
int
GetVariableNum(VariableSpace space,
const char name[],
@ -103,7 +105,6 @@ GetVariableNum(VariableSpace space,
return result;
}
int
SwitchVariable(VariableSpace space, const char name[], const char *opt, ...)
{
@ -117,17 +118,16 @@ SwitchVariable(VariableSpace space, const char name[], const char *opt, ...)
va_start(args, opt);
for (result=1; opt && (strcmp(var, opt) != 0); result++)
opt = va_arg(args,const char *);
if (!opt) result = var_notfound;
if (!opt)
result = VAR_NOTFOUND;
va_end(args);
}
else
result = var_notset;
result = VAR_NOTSET;
return result;
}
void
PrintVariables(VariableSpace space)
{
@ -136,7 +136,6 @@ PrintVariables(VariableSpace space)
printf("%s = '%s'\n", ptr->name, ptr->value);
}
bool
SetVariable(VariableSpace space, const char *name, const char *value)
{
@ -176,16 +175,12 @@ SetVariable(VariableSpace space, const char *name, const char *value)
return previous->next->value ? true : false;
}
bool
SetVariableBool(VariableSpace space, const char *name)
{
return SetVariable(space, name, "");
return SetVariable(space, name, "on");
}
bool
DeleteVariable(VariableSpace space, const char *name)
{
@ -217,15 +212,3 @@ DeleteVariable(VariableSpace space, const char *name)
return true;
}
void
DestroyVariableSpace(VariableSpace space)
{
if (!space)
return;
DestroyVariableSpace(space->next);
free(space);
}