diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2002-08-10 16:57:32 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2002-08-10 16:57:32 +0000 |
commit | 029aa97f2d90a2ef97b2c0ca917bea7268392eb1 (patch) | |
tree | b5a7c08bf2030f7c0b4b1a6cc64ba6e2a809efdb /src/bin/psql/help.c | |
parent | 60ac5b805e63ee0055fa9ff44a8486953f6dcbbc (diff) | |
download | postgresql-029aa97f2d90a2ef97b2c0ca917bea7268392eb1.tar.gz postgresql-029aa97f2d90a2ef97b2c0ca917bea7268392eb1.zip |
Make sure all clients have the same understanding of default user name
and database. In particular, make script wrappers understand the
PGDATABASE environment variable.
Diffstat (limited to 'src/bin/psql/help.c')
-rw-r--r-- | src/bin/psql/help.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 592a8af3fbc..02d76039752 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.52 2002/07/15 01:56:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.53 2002/08/10 16:57:32 petere Exp $ */ #include "postgres_fe.h" #include "print.h" @@ -58,7 +58,7 @@ usage(void) #endif /* Find default user, in case we need it. */ - user = getenv("USER"); + user = getenv("PGUSER"); if (!user) { #ifndef WIN32 @@ -70,9 +70,13 @@ usage(void) psql_error("could not get current user name: %s\n", strerror(errno)); exit(EXIT_FAILURE); } -#else - user = "?"; -#endif +#else /* WIN32 */ + char buf[128]; + DWORD bufsize = sizeof(buf) - 1; + + if (GetUserName(buf, &bufsize)) + user = buf; +#endif /* WIN32 */ } /* If this " is the start of the string then it ought to end there to fit in 80 columns >> " */ |