diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2003-09-03 22:05:09 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2003-09-03 22:05:09 +0000 |
commit | 29a20145fd2d1859eb3ec1788240244d0b50f68f (patch) | |
tree | 6b83ccf2e9b2c6104c3ebb9f4a4b78581d9c827b /src/bin/psql/common.c | |
parent | 4e85f760e6b1cccfb82be8078257ade01435573e (diff) | |
download | postgresql-29a20145fd2d1859eb3ec1788240244d0b50f68f.tar.gz postgresql-29a20145fd2d1859eb3ec1788240244d0b50f68f.zip |
Pass session_authorization to the client and make psql update its prompt
accordingly.
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r-- | src/bin/psql/common.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index cead3c65904..70551a2a3d5 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.72 2003/08/14 18:48:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.73 2003/09/03 22:05:08 petere Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -724,3 +724,26 @@ is_superuser(void) return false; } + + +/* + * Return the session user of the current connection. + * + * Note: this will correctly detect the session user only with a + * protocol-3.0 or newer backend; otherwise it will return the + * connection user. + */ +const char * +session_username(void) +{ + const char *val; + + if (!pset.db) + return NULL; + + val = PQparameterStatus(pset.db, "session_authorization"); + if (val) + return val; + else + return PQuser(pset.db); +} |