1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

A few minor psql enhancements

Initdb help correction
Changed end/abort to commit/rollback and changed related notices
Commented out way old printing functions in libpq
Fixed a typo in alter table / alter column
This commit is contained in:
Peter Eisentraut
2000-01-29 16:58:54 +00:00
parent 7e7416bd4e
commit 2b84cbb60f
49 changed files with 821 additions and 870 deletions

View File

@@ -1,9 +1,9 @@
/*
* psql - the PostgreSQL interactive terminal
*
* Copyright 2000 by PostgreSQL Global Development Team
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.15 2000/01/23 01:27:37 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.16 2000/01/29 16:58:48 petere Exp $
*/
#include <c.h>
#include "command.h"
@@ -361,7 +361,7 @@ exec_command(const char *cmd,
switch (cmd[1])
{
case '\0':
case '?':
case '+':
if (options[0])
success = describeTableDetails(options[0], show_verbose);
else
@@ -992,11 +992,41 @@ do_connect(const char *new_dbname, const char *new_user)
SetVariable(pset.vars, "HOST", PQhost(pset.db));
SetVariable(pset.vars, "PORT", PQport(pset.db));
pset.issuper = test_superuser(PQuser(pset.db));
return success;
}
/*
* Test if the given user is a database superuser.
* (Used to set up the prompt right.)
*/
bool
test_superuser(const char * username)
{
PGresult *res;
char buf[64 + NAMEDATALEN];
bool answer;
if (!username)
return false;
sprintf(buf, "SELECT usesuper FROM pg_user WHERE usename = '%.*s'", NAMEDATALEN, username);
res = PSQLexec(buf);
answer =
(PQntuples(res)>0 && PQnfields(res)>0
&& !PQgetisnull(res,0,0)
&& PQgetvalue(res,0,0)
&& strcmp(PQgetvalue(res,0,0), "t")==0);
PQclear(res);
return answer;
}
/*
* do_edit -- handler for \e
*