Environment
+
+ PGDATABASE
+
+ If set, the name of the database to create, unless overridden on
+ the command line.
+
+
+
+
PGHOST
PGPORT
Default connection parameters. PGUSER also
determines the name of the database to create, if it is not
- specified in the command line.
+ specified on the command line or by PGDATABASE.
Examples
-
To create the database demo using the default
database server:
The response is the same as you would have gotten from running the
CREATE DATABASE SQL command.
-
-
To create the database demo using the
server on host eden>, port 5000, using the
CREATE DATABASE
-
+ PGDATABASE
PGHOST
PGPORT
PGUSER
Examples
-
To install pltcl into the database
template1:
$ createlang pltcl template1
-
The new user is allowed to create other users.
- (Note: actually, this makes the new user a superuser>.
+ (Note: Actually, this makes the new user a superuser>.
The option is poorly named.)
Examples
-
To create a user joe on the default database
server:
CREATE USER
-
-
To create the same user joe using the
server on host eden>, port 5000, avoiding the prompts and
CREATE USER
-
Examples
-
To destroy the database demo on the default
database server:
DROP DATABASE
-
-
To destroy the database demo using the
server on host eden, port 5000, with verification and a peek
DROP DATABASE
-
+ PGDATABASE
PGHOST
PGPORT
PGUSER
Examples
-
To remove pltcl:
-
Examples
-
To remove user joe from the default database
server:
DROP USER
-
-
To remove user joe using the postmaster on host
eden, port 5000, with verification and a peek at the underlying
DROP USER
-
dbname
- Specifies the name of the database to be dumped.
+ Specifies the name of the database to be dumped. If this is
+ not specified, the environment variable
+ PGDATABASE is used. If that is not set, the
+ user name specified for the connection is used.
- Connect as the given user.
+ Connect as the given user
PGDATABASE
-
-
- Database to dump, unless overridden on the command line.
-
-
-
-
-
PGHOST
PGPORT
PGUSER
-
+
- Connect as the given user.
+ Connect as the given user
Specifies the name of the database to be cleaned or analyzed.
+ If this is not specified and (or
+ ) is not used, the database name is read
+ from the environment variable PGDATABASE. If
+ that is not set, the user name specified for the connection is
+ used.
+ PGDATABASE
PGHOST
PGPORT
PGUSER
Examples
-
To clean the database test:
-
-
To clean and analyze for the optimizer a database named
bigdb:
$ vacuumdb --analyze bigdb
-
-
To clean a single table
foo in a database named
$ vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
-
* as this notice is not removed.
*
* The author is not responsible for loss or damages that may
- * result from it's use.
+ * result from its use.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.52 2002/07/04 15:35:07 momjian Exp $
- *
- *
- * Initial version.
- *
- * Fixed version number initialization in _allocAH (pg_backup_archiver.c)
- *
- *
- * Added {Start,End}RestoreBlobs to allow extended TX during BLOB restore.
- *
- * - strdup() the current user just in case it's deallocated from it's TOC
- * entry. Should *never* happen, but that's what they said about the
- * Titanic...
- *
- * - Check results of IO routines more carefully.
- *
- * - When dropping the schema, reconnect as owner of each object.
- *
- * - Only disable triggers in DataOnly (or implied data-only) restores.
- *
- *
- * - Rudimentary support for dependencies in archives. Current implementation
- * uses dependencies to modify the OID used in sorting TOC entries.
- * This will NOT handle multi-level dependencies, but will manage simple
- * relationships like UDTs & their functions.
- *
- * - Treat OIDs with more respect (avoid using ints, use macros for
- * conversion & comparison).
- *
- * - Treat SEQUENCE SET TOC entries as data entries rather than schema
- * entries.
- * - Make allowance for data entries that did not have a data dumper
- * routine (eg. SEQUENCE SET)
- *
- * - Fix handling of {data/schema}-only restores when using a full
- * backup file; prior version was restoring schema in data-only
- * restores. Added enum to make code easier to understand.
- *
- * - Modified _tocEntryRequired to handle '/Max OID' as a special
- * case (ie. as a DATA item) as per bugs reported by Bruce Momjian
- * around 17-Jan-2002.
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.53 2002/08/10 16:57:31 petere Exp $
*
*-------------------------------------------------------------------------
*/
WriteInt(AH, crtm.tm_mon);
WriteInt(AH, crtm.tm_year);
WriteInt(AH, crtm.tm_isdst);
- WriteStr(AH, AH->dbname);
+ WriteStr(AH, PQdb(AH->connection));
}
void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.44 2002/07/04 15:35:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.45 2002/08/10 16:57:31 petere Exp $
*
*-------------------------------------------------------------------------
*/
CustomOutPtr CustomOutPtr; /* Alternate script output routine */
/* Stuff for direct DB connection */
- char *username;
- char *dbname; /* Name of db for connection */
char *archdbname; /* DB name *read* from archive */
- char *pghost;
- char *pgport;
bool requirePassword;
PGconn *connection;
PGconn *blobConnection; /* Connection for BLOB xref */
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.35 2002/07/06 20:12:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.36 2002/08/10 16:57:31 petere Exp $
*
*-------------------------------------------------------------------------
*/
PQfinish(AH->connection);
AH->connection = newConn;
- free(AH->username);
- AH->username = strdup(newusername);
- /* XXX Why don't we update AH->dbname? */
-
/* don't assume we still know the output schema */
if (AH->currSchema)
free(AH->currSchema);
if (AH->connection)
die_horribly(AH, modulename, "already connected to a database\n");
- if (!dbname && !(dbname = getenv("PGDATABASE")))
- die_horribly(AH, modulename, "no database name specified\n");
-
- AH->dbname = strdup(dbname);
-
- if (pghost != NULL)
- AH->pghost = strdup(pghost);
- else
- AH->pghost = NULL;
-
- if (pgport != NULL)
- AH->pgport = strdup(pgport);
- else
- AH->pgport = NULL;
-
- if (username != NULL)
- AH->username = strdup(username);
- else
- AH->username = NULL;
-
if (reqPwd)
{
password = simple_prompt("Password: ", 100, false);
do
{
need_pass = false;
- AH->connection = PQsetdbLogin(AH->pghost, AH->pgport, NULL, NULL,
- AH->dbname, AH->username, password);
+ AH->connection = PQsetdbLogin(pghost, pgport, NULL, NULL,
+ dbname, username, password);
if (!AH->connection)
die_horribly(AH, modulename, "failed to connect to database\n");
/* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD)
die_horribly(AH, modulename, "connection to database \"%s\" failed: %s",
- AH->dbname, PQerrorMessage(AH->connection));
+ PQdb(AH->connection), PQerrorMessage(AH->connection));
/* check for version mismatch */
_check_database_version(AH, ignoreVersion);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.280 2002/08/04 05:03:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.281 2002/08/10 16:57:31 petere Exp $
*
*-------------------------------------------------------------------------
*/
exit(1);
}
- /* Get the target database name */
+ /* Get database name from command line */
if (optind < argc)
dbname = argv[optind];
- else
- dbname = getenv("PGDATABASE");
- if (!dbname)
- {
- write_msg(NULL, "no database name specified\n");
- exit(1);
- }
if (dataOnly && schemaOnly)
{
if (g_fout->remoteVersion < 70300)
{
if (g_fout->remoteVersion >= 70100)
- g_last_builtin_oid = findLastBuiltinOid_V71(dbname);
+ g_last_builtin_oid = findLastBuiltinOid_V71(PQdb(((ArchiveHandle *)g_conn)->connection));
else
g_last_builtin_oid = findLastBuiltinOid_V70();
if (g_verbose)
* as this notice is not removed.
*
* The author is not responsible for loss or damages that may
- * result from it's use.
+ * result from its use.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.37 2002/07/11 02:00:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.38 2002/08/10 16:57:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
*
* 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"
#endif
/* Find default user, in case we need it. */
- user = getenv("USER");
+ user = getenv("PGUSER");
if (!user)
{
#ifndef WIN32
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 >> " */
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.23 2002/06/20 20:29:42 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.24 2002/08/10 16:57:32 petere Exp $
#
#-------------------------------------------------------------------------
fi
if [ -z "$dbname" ]; then
- if [ "$PGUSER" ]; then
+ if [ "$PGDATABASE" ]; then
+ dbname="$PGDATABASE"
+ elif [ "$PGUSER" ]; then
dbname="$PGUSER"
else
dbname=`${PATHNAME}pg_id -u -n`
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.36 2002/06/20 20:29:42 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.37 2002/08/10 16:57:32 petere Exp $
#
#-------------------------------------------------------------------------
if [ -z "$dbname" ]; then
- if [ "$PGUSER" ]; then
+ if [ "$PGDATABASE" ]; then
+ dbname="$PGDATABASE"
+ elif [ "$PGUSER" ]; then
dbname="$PGUSER"
else
dbname=`${PATHNAME}pg_id -u -n`
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.23 2002/06/20 20:29:42 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.24 2002/08/10 16:57:32 petere Exp $
#
#-------------------------------------------------------------------------
if [ -z "$dbname" ]; then
- if [ "$PGUSER" ]; then
+ if [ "$PGDATABASE" ]; then
+ dbname="$PGDATABASE"
+ elif [ "$PGUSER" ]; then
dbname="$PGUSER"
else
dbname=`${PATHNAME}pg_id -u -n`
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.22 2002/06/20 20:29:42 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.23 2002/08/10 16:57:32 petere Exp $
#
#-------------------------------------------------------------------------
dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database WHERE datallowconn'`
elif [ -z "$dbname" ]; then
- if [ "$PGUSER" ]; then
+ if [ "$PGDATABASE" ]; then
+ dbname="$PGDATABASE"
+ elif [ "$PGUSER" ]; then
dbname="$PGUSER"
else
dbname=`${PATHNAME}pg_id -u -n`