diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2000-01-29 16:58:54 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2000-01-29 16:58:54 +0000 |
commit | 2b84cbb60f6ff6cb58d42dff026aaf0b2e9ca8ab (patch) | |
tree | dcd592dcfdebbc799bd225ac8bf50c0dfe1e61eb /src/bin/psql/command.c | |
parent | 7e7416bd4e221fd95701a048eaf2893ab379d9a5 (diff) | |
download | postgresql-2b84cbb60f6ff6cb58d42dff026aaf0b2e9ca8ab.tar.gz postgresql-2b84cbb60f6ff6cb58d42dff026aaf0b2e9ca8ab.zip |
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
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index a12d311b2e0..1441fbc0bcc 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -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,12 +992,42 @@ 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 * * If you do not specify a filename, the current query buffer will be copied |