aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_controldata/pg_controldata.c24
-rw-r--r--src/bin/pg_dump/common.c8
-rw-r--r--src/bin/pg_dump/dumputils.c75
-rw-r--r--src/bin/pg_dump/dumputils.h12
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c54
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h12
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c20
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c23
-rw-r--r--src/bin/pg_dump/pg_dump.c161
-rw-r--r--src/bin/pg_dump/pg_dump.h6
-rw-r--r--src/bin/pg_dump/pg_dumpall.c14
-rw-r--r--src/bin/pg_dump/pg_restore.c6
-rw-r--r--src/bin/pg_encoding/pg_encoding.c10
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c6
-rw-r--r--src/bin/psql/command.c32
-rw-r--r--src/bin/psql/common.c224
-rw-r--r--src/bin/psql/copy.c17
-rw-r--r--src/bin/psql/describe.c61
-rw-r--r--src/bin/psql/help.c14
-rw-r--r--src/bin/psql/input.c56
-rw-r--r--src/bin/psql/large_obj.c6
-rw-r--r--src/bin/psql/mainloop.c67
-rw-r--r--src/bin/psql/mbprint.c8
-rw-r--r--src/bin/psql/print.c20
-rw-r--r--src/bin/psql/print.h5
-rw-r--r--src/bin/psql/prompt.c60
-rw-r--r--src/bin/psql/sprompt.c13
-rw-r--r--src/bin/psql/startup.c8
-rw-r--r--src/bin/psql/stringutils.c31
-rw-r--r--src/bin/psql/tab-complete.c163
-rw-r--r--src/bin/psql/variables.c56
-rw-r--r--src/bin/psql/variables.h37
-rw-r--r--src/bin/scripts/clusterdb.c30
-rw-r--r--src/bin/scripts/common.c6
-rw-r--r--src/bin/scripts/common.h19
-rw-r--r--src/bin/scripts/createdb.c4
-rw-r--r--src/bin/scripts/createlang.c20
-rw-r--r--src/bin/scripts/createuser.c11
-rw-r--r--src/bin/scripts/dropdb.c4
-rw-r--r--src/bin/scripts/droplang.c15
-rw-r--r--src/bin/scripts/vacuumdb.c34
41 files changed, 764 insertions, 688 deletions
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 10a6ed93cc1..c976e5af31f 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
- * $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.10 2003/07/23 08:47:25 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.11 2003/08/04 00:43:27 momjian Exp $
*/
#include "postgres.h"
@@ -27,17 +27,17 @@ usage(const char *progname)
{
printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), progname);
printf
- (
- _(
- "Usage:\n"
- " %s [OPTION]\n\n"
- "Options:\n"
- " DATADIR show cluster control information for DATADIR\n"
- " --help show this help, then exit\n"
- " --version output version information, then exit\n"
- ),
- progname
- );
+ (
+ _(
+ "Usage:\n"
+ " %s [OPTION]\n\n"
+ "Options:\n"
+ " DATADIR show cluster control information for DATADIR\n"
+ " --help show this help, then exit\n"
+ " --version output version information, then exit\n"
+ ),
+ progname
+ );
printf(_("\nIf no data directory is specified, the environment variable PGDATA\nis used.\n\n"));
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
}
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index e404924f44e..2c2537b9d8f 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.73 2003/07/23 08:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.74 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -290,9 +290,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
* attr with the same name, then only dump it if:
*
* - it is NOT NULL and zero parents are NOT NULL
- * OR
+ * OR
* - it has a default value AND the default value does not match
- * all parent default values, or no parents specify a default.
+ * all parent default values, or no parents specify a default.
*
* See discussion on -hackers around 2-Apr-2001.
*----------------------------------------------------------------
@@ -364,9 +364,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
/* Clear it if attr has local definition */
if (g_fout->remoteVersion >= 70300 && tblinfo[i].attislocal[j])
- {
tblinfo[i].inhAttrs[j] = false;
- }
}
}
}
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 095d2fc8644..100f54fefc3 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.6 2003/07/31 17:21:57 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.7 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,9 +23,9 @@
static bool parseAclArray(const char *acls, char ***itemarray, int *nitems);
static bool parseAclItem(const char *item, const char *type, const char *name,
- int remoteVersion,
- PQExpBuffer grantee, PQExpBuffer grantor,
- PQExpBuffer privs, PQExpBuffer privswgo);
+ int remoteVersion,
+ PQExpBuffer grantee, PQExpBuffer grantor,
+ PQExpBuffer privs, PQExpBuffer privswgo);
static char *copyAclUserName(PQExpBuffer output, char *input);
static void AddAcl(PQExpBuffer aclbuf, const char *keyword);
@@ -191,8 +191,12 @@ buildACLCommands(const char *name, const char *type,
char **aclitems;
int naclitems;
int i;
- PQExpBuffer grantee, grantor, privs, privswgo;
- PQExpBuffer firstsql, secondsql;
+ PQExpBuffer grantee,
+ grantor,
+ privs,
+ privswgo;
+ PQExpBuffer firstsql,
+ secondsql;
bool found_owner_privs = false;
if (strlen(acls) == 0)
@@ -209,13 +213,14 @@ buildACLCommands(const char *name, const char *type,
grantor = createPQExpBuffer();
privs = createPQExpBuffer();
privswgo = createPQExpBuffer();
+
/*
- * At the end, these two will be pasted together to form the
- * result. But the owner privileges need to go before the other
- * ones to keep the dependencies valid. In recent versions this
- * is normally the case, but in old versions they come after the
- * PUBLIC privileges and that results in problems if we need to
- * run REVOKE on the owner privileges.
+ * At the end, these two will be pasted together to form the result.
+ * But the owner privileges need to go before the other ones to keep
+ * the dependencies valid. In recent versions this is normally the
+ * case, but in old versions they come after the PUBLIC privileges and
+ * that results in problems if we need to run REVOKE on the owner
+ * privileges.
*/
firstsql = createPQExpBuffer();
secondsql = createPQExpBuffer();
@@ -245,9 +250,10 @@ buildACLCommands(const char *name, const char *type,
&& strcmp(grantor->data, owner) == 0)
{
found_owner_privs = true;
+
/*
- * For the owner, the default privilege level is ALL
- * WITH GRANT OPTION (only ALL prior to 7.4).
+ * For the owner, the default privilege level is ALL WITH
+ * GRANT OPTION (only ALL prior to 7.4).
*/
if (supports_grant_options(remoteVersion)
? strcmp(privswgo->data, "ALL") != 0
@@ -285,7 +291,7 @@ buildACLCommands(const char *name, const char *type,
else if (strncmp(grantee->data, "group ",
strlen("group ")) == 0)
appendPQExpBuffer(secondsql, "GROUP %s;\n",
- fmtId(grantee->data + strlen("group ")));
+ fmtId(grantee->data + strlen("group ")));
else
appendPQExpBuffer(secondsql, "%s;\n", fmtId(grantee->data));
}
@@ -298,7 +304,7 @@ buildACLCommands(const char *name, const char *type,
else if (strncmp(grantee->data, "group ",
strlen("group ")) == 0)
appendPQExpBuffer(secondsql, "GROUP %s",
- fmtId(grantee->data + strlen("group ")));
+ fmtId(grantee->data + strlen("group ")));
else
appendPQExpBuffer(secondsql, "%s", fmtId(grantee->data));
appendPQExpBuffer(secondsql, " WITH GRANT OPTION;\n");
@@ -340,7 +346,7 @@ buildACLCommands(const char *name, const char *type,
* into individual items.
*
* On success, returns true and sets *itemarray and *nitems to describe
- * an array of individual strings. On parse failure, returns false;
+ * an array of individual strings. On parse failure, returns false;
* *itemarray may exist or be NULL.
*
* NOTE: free'ing itemarray is sufficient to deallocate the working storage.
@@ -354,19 +360,21 @@ parseAclArray(const char *acls, char ***itemarray, int *nitems)
int curitem;
/*
- * We expect input in the form of "{item,item,item}" where any item
- * is either raw data, or surrounded by double quotes (in which case
- * embedded characters including backslashes and quotes are backslashed).
+ * We expect input in the form of "{item,item,item}" where any item is
+ * either raw data, or surrounded by double quotes (in which case
+ * embedded characters including backslashes and quotes are
+ * backslashed).
*
* We build the result as an array of pointers followed by the actual
- * string data, all in one malloc block for convenience of deallocation.
- * The worst-case storage need is not more than one pointer and one
- * character for each input character (consider "{,,,,,,,,,,}").
+ * string data, all in one malloc block for convenience of
+ * deallocation. The worst-case storage need is not more than one
+ * pointer and one character for each input character (consider
+ * "{,,,,,,,,,,}").
*/
*itemarray = NULL;
*nitems = 0;
inputlen = strlen(acls);
- if (inputlen < 2 || acls[0] != '{' || acls[inputlen-1] != '}')
+ if (inputlen < 2 || acls[0] != '{' || acls[inputlen - 1] != '}')
return false; /* bad input */
items = (char **) malloc(inputlen * (sizeof(char *) + sizeof(char)));
if (items == NULL)
@@ -384,9 +392,9 @@ parseAclArray(const char *acls, char ***itemarray, int *nitems)
while (*acls != '}' && *acls != ',')
{
if (*acls == '\0')
- return false; /* premature end of string */
+ return false; /* premature end of string */
if (*acls != '"')
- *strings++ = *acls++; /* copy unquoted data */
+ *strings++ = *acls++; /* copy unquoted data */
else
{
/* process quoted substring */
@@ -394,14 +402,14 @@ parseAclArray(const char *acls, char ***itemarray, int *nitems)
while (*acls != '"')
{
if (*acls == '\0')
- return false; /* premature end of string */
+ return false; /* premature end of string */
if (*acls == '\\')
{
acls++;
if (*acls == '\0')
- return false; /* premature end of string */
+ return false; /* premature end of string */
}
- *strings++ = *acls++; /* copy quoted data */
+ *strings++ = *acls++; /* copy quoted data */
}
acls++;
}
@@ -426,7 +434,7 @@ parseAclArray(const char *acls, char ***itemarray, int *nitems)
*
* The returned grantee string will be the dequoted username or groupname
* (preceded with "group " in the latter case). The returned grantor is
- * the dequoted grantor name or empty. Privilege characters are decoded
+ * the dequoted grantor name or empty. Privilege characters are decoded
* and split between privileges with grant option (privswgo) and without
* (privs).
*
@@ -559,11 +567,12 @@ copyAclUserName(PQExpBuffer output, char *input)
while (*input != '"')
{
if (*input == '\0')
- return input; /* really a syntax error... */
+ return input; /* really a syntax error... */
+
/*
* There is no quoting convention here, thus we can't cope
- * with usernames containing double quotes. Keep this code
- * in sync with putid() in backend's acl.c.
+ * with usernames containing double quotes. Keep this
+ * code in sync with putid() in backend's acl.c.
*/
appendPQExpBufferChar(output, *input++);
}
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index 41946af31af..8d8d2b740d1 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dumputils.h,v 1.5 2003/05/30 22:55:15 tgl Exp $
+ * $Id: dumputils.h,v 1.6 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,11 @@ extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
extern const char *fmtId(const char *identifier);
extern void appendStringLiteral(PQExpBuffer buf, const char *str,
- bool escapeAll);
-extern int parse_version(const char *versionString);
+ bool escapeAll);
+extern int parse_version(const char *versionString);
extern bool buildACLCommands(const char *name, const char *type,
- const char *acls, const char *owner,
- int remoteVersion,
- PQExpBuffer sql);
+ const char *acls, const char *owner,
+ int remoteVersion,
+ PQExpBuffer sql);
#endif /* DUMPUTILS_H */
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 5acfc08ba3b..294d92682c1 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.73 2003/07/23 08:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.74 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -206,7 +206,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
sav = SetOutput(AH, ropt->filename, ropt->compression);
ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
-
+
/*
* Drop the items at the start, in reverse order
*/
@@ -280,7 +280,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* If we can output the data, then restore it.
*/
- if (AH->PrintTocDataPtr != NULL && (reqs & REQ_DATA) != 0)
+ if (AH->PrintTocDataPtr !=NULL && (reqs & REQ_DATA) != 0)
{
#ifndef HAVE_LIBZ
if (AH->compression != 0)
@@ -1292,7 +1292,8 @@ _die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_lis
{
_write_msg(modulename, fmt, ap);
- if (AH) {
+ if (AH)
+ {
if (AH->public.verbose)
write_msg(NULL, "*** aborted because of error\n");
if (AH->connection)
@@ -1383,7 +1384,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
size_t
WriteOffset(ArchiveHandle *AH, off_t o, int wasSet)
{
- int off;
+ int off;
/* Save the flag */
(*AH->WriteBytePtr) (AH, wasSet);
@@ -1391,7 +1392,7 @@ WriteOffset(ArchiveHandle *AH, off_t o, int wasSet)
/* Write out off_t smallest byte first, prevents endian mismatch */
for (off = 0; off < sizeof(off_t); off++)
{
- (*AH->WriteBytePtr) (AH, o & 0xFF);
+ (*AH->WriteBytePtr) (AH, o & 0xFF);
o >>= 8;
}
return sizeof(off_t) + 1;
@@ -1400,9 +1401,9 @@ WriteOffset(ArchiveHandle *AH, off_t o, int wasSet)
int
ReadOffset(ArchiveHandle *AH, off_t *o)
{
- int i;
- int off;
- int offsetFlg;
+ int i;
+ int off;
+ int offsetFlg;
/* Initialize to zero */
*o = 0;
@@ -1414,21 +1415,21 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
i = ReadInt(AH);
/* -1 means not set */
if (i < 0)
- return K_OFFSET_POS_NOT_SET;
+ return K_OFFSET_POS_NOT_SET;
else if (i == 0)
- return K_OFFSET_NO_DATA;
+ return K_OFFSET_NO_DATA;
/* Cast to off_t because it was written as an int. */
- *o = (off_t)i;
+ *o = (off_t) i;
return K_OFFSET_POS_SET;
}
/*
- * Read the flag indicating the state of the data pointer.
- * Check if valid and die if not.
+ * Read the flag indicating the state of the data pointer. Check if
+ * valid and die if not.
*
- * This used to be handled by a negative or zero pointer,
- * now we use an extra byte specifically for the state.
+ * This used to be handled by a negative or zero pointer, now we use an
+ * extra byte specifically for the state.
*/
offsetFlg = (*AH->ReadBytePtr) (AH) & 0xFF;
@@ -1438,10 +1439,10 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
case K_OFFSET_NO_DATA:
case K_OFFSET_POS_SET:
- break;
+ break;
default:
- die_horribly(AH, modulename, "Unexpected data offset flag %d\n", offsetFlg);
+ die_horribly(AH, modulename, "Unexpected data offset flag %d\n", offsetFlg);
}
/*
@@ -1454,7 +1455,7 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
else
{
if ((*AH->ReadBytePtr) (AH) != 0)
- die_horribly(AH, modulename, "file offset in dump file is too large\n");
+ die_horribly(AH, modulename, "file offset in dump file is too large\n");
}
}
@@ -2121,7 +2122,7 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user)
dbname ? fmtId(dbname) : "-");
appendPQExpBuffer(qry, " %s\n\n",
fmtId(user));
-
+
ahprintf(AH, qry->data);
destroyPQExpBuffer(qry);
@@ -2304,9 +2305,9 @@ ReadHead(ArchiveHandle *AH)
write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n");
if (AH->version >= K_VERS_1_7)
- AH->offSize = (*AH->ReadBytePtr) (AH);
+ AH->offSize = (*AH->ReadBytePtr) (AH);
else
- AH->offSize = AH->intSize;
+ AH->offSize = AH->intSize;
fmt = (*AH->ReadBytePtr) (AH);
@@ -2363,10 +2364,11 @@ checkSeek(FILE *fp)
if (fseeko(fp, 0, SEEK_CUR) != 0)
return false;
else if (sizeof(off_t) > sizeof(long))
- /*
- * At this point, off_t is too large for long, so we return
- * based on whether an off_t version of fseek is available.
- */
+
+ /*
+ * At this point, off_t is too large for long, so we return based
+ * on whether an off_t version of fseek is available.
+ */
#ifdef HAVE_FSEEKO
return true;
#else
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 078ecb9c983..f893a3ba7fd 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.50 2003/02/01 19:29:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.51 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,7 +74,8 @@ typedef z_stream *z_streamp;
#define K_VERS_1_4 (( (1 * 256 + 4) * 256 + 0) * 256 + 0) /* Date & name in header */
#define K_VERS_1_5 (( (1 * 256 + 5) * 256 + 0) * 256 + 0) /* Handle dependencies */
#define K_VERS_1_6 (( (1 * 256 + 6) * 256 + 0) * 256 + 0) /* Schema field in TOCs */
-#define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0) /* File Offset size in header */
+#define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0) /* File Offset size in
+ * header */
#define K_VERS_MAX (( (1 * 256 + 7) * 256 + 255) * 256 + 0)
/* No of BLOBs to restore in 1 TX */
@@ -155,7 +156,8 @@ typedef struct _archiveHandle
int debugLevel; /* Used for logging (currently only by
* --verbose) */
size_t intSize; /* Size of an integer in the archive */
- size_t offSize; /* Size of a file offset in the archive - Added V1.7 */
+ size_t offSize; /* Size of a file offset in the archive -
+ * Added V1.7 */
ArchiveFormat format; /* Archive format */
sqlparseInfo sqlparse;
@@ -296,8 +298,8 @@ extern int ReadInt(ArchiveHandle *AH);
extern char *ReadStr(ArchiveHandle *AH);
extern size_t WriteStr(ArchiveHandle *AH, const char *s);
-int ReadOffset(ArchiveHandle*, off_t*);
-size_t WriteOffset(ArchiveHandle*, off_t, int);
+int ReadOffset(ArchiveHandle *, off_t *);
+size_t WriteOffset(ArchiveHandle *, off_t, int);
extern void StartRestoreBlobs(ArchiveHandle *AH);
extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid);
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 49a2701a121..802b02811f5 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.24 2003/07/23 08:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.25 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -248,7 +248,7 @@ _WriteExtraToc(ArchiveHandle *AH, TocEntry *te)
static void
_ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
{
- int junk;
+ int junk;
lclTocEntry *ctx = (lclTocEntry *) te->formatData;
if (ctx == NULL)
@@ -257,11 +257,11 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
te->formatData = (void *) ctx;
}
- ctx->dataState = ReadOffset(AH, &(ctx->dataPos) );
+ ctx->dataState = ReadOffset(AH, &(ctx->dataPos));
/*
- * Prior to V1.7 (pg7.3), we dumped the data size as an int
- * now we don't dump it at all.
+ * Prior to V1.7 (pg7.3), we dumped the data size as an int now we
+ * don't dump it at all.
*/
if (AH->version < K_VERS_1_7)
junk = ReadInt(AH);
@@ -551,7 +551,7 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
+ "could not read data block -- expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen;
@@ -674,7 +674,7 @@ _skipData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
+ "could not read data block -- expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen;
@@ -841,10 +841,10 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
if (pos != ctx->filePos)
{
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell used\n");
+
/*
- * Prior to 1.7 (pg7.3) we relied on the internally maintained pointer.
- * Now we rely on off_t always.
- * pos = ctx->filePos;
+ * Prior to 1.7 (pg7.3) we relied on the internally maintained
+ * pointer. Now we rely on off_t always. pos = ctx->filePos;
*/
}
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 11a5eb8f015..88e1595787f 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.36 2003/07/23 08:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.37 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1150,7 +1150,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
int sum,
chk;
size_t len;
- unsigned long ullen;
+ unsigned long ullen;
off_t hPos;
int i;
bool gotBlock = false;
@@ -1242,15 +1242,18 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
* Utility routine to print possibly larger than 32 bit integers in a
* portable fashion. Filled with zeros.
*/
-static void print_val(char *s, uint64 val, unsigned int base, size_t len)
+static void
+print_val(char *s, uint64 val, unsigned int base, size_t len)
{
- int i;
- for (i = len; i > 0; i--)
- {
- int digit = val % base;
- s[i - 1] = '0' + digit;
- val = val / base;
- }
+ int i;
+
+ for (i = len; i > 0; i--)
+ {
+ int digit = val % base;
+
+ s[i - 1] = '0' + digit;
+ val = val / base;
+ }
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e58c316866d..e631623a32b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.340 2003/07/28 00:09:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.341 2003/08/04 00:43:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,7 +42,7 @@
#ifndef HAVE_GETOPT_LONG
#include "getopt_long.h"
-int optreset;
+int optreset;
#endif
#include "access/attnum.h"
@@ -519,12 +519,12 @@ main(int argc, char **argv)
PQerrorMessage(g_conn));
PQclear(res);
- /* Set the datestyle to ISO to ensure the dump's portability */
- res = PQexec(g_conn, "SET DATESTYLE = ISO");
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- exit_horribly(g_fout, NULL, "could not set datestyle to ISO: %s",
- PQerrorMessage(g_conn));
- PQclear(res);
+ /* Set the datestyle to ISO to ensure the dump's portability */
+ res = PQexec(g_conn, "SET DATESTYLE = ISO");
+ if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+ exit_horribly(g_fout, NULL, "could not set datestyle to ISO: %s",
+ PQerrorMessage(g_conn));
+ PQclear(res);
/*
* If supported, set extra_float_digits so that we can dump float data
@@ -577,10 +577,10 @@ main(int argc, char **argv)
/* Now sort the output nicely */
SortTocByOID(g_fout);
- /*
- * Procedural languages have to be declared just after
- * database and schema creation, before they are used.
- */
+ /*
+ * Procedural languages have to be declared just after database and
+ * schema creation, before they are used.
+ */
MoveToStart(g_fout, "ACL LANGUAGE");
MoveToStart(g_fout, "PROCEDURAL LANGUAGE");
MoveToStart(g_fout, "FUNC PROCEDURAL LANGUAGE");
@@ -702,8 +702,8 @@ selectDumpableNamespace(NamespaceInfo *nsinfo)
{
/*
* If a specific table is being dumped, do not dump any complete
- * namespaces. If a specific namespace is being dumped, dump just
- * that namespace. Otherwise, dump all non-system namespaces.
+ * namespaces. If a specific namespace is being dumped, dump just
+ * that namespace. Otherwise, dump all non-system namespaces.
*/
if (selectTableName != NULL)
nsinfo->dump = false;
@@ -1449,8 +1449,8 @@ getNamespaces(int *numNamespaces)
}
/*
- * If the user attempted to dump a specific namespace, check to
- * ensure that the specified namespace actually exists.
+ * If the user attempted to dump a specific namespace, check to ensure
+ * that the specified namespace actually exists.
*/
if (selectSchemaName)
{
@@ -2269,9 +2269,9 @@ getTables(int *numTables)
}
/*
- * If the user is attempting to dump a specific table, check to
- * ensure that the specified table actually exists (and is a table
- * or a view, not a sequence).
+ * If the user is attempting to dump a specific table, check to ensure
+ * that the specified table actually exists (and is a table or a view,
+ * not a sequence).
*/
if (selectTableName)
{
@@ -2424,8 +2424,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{
/* need left join here to not fail on dropped columns ... */
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, "
- "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, "
- "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname "
+ "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, "
+ "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname "
"from pg_catalog.pg_attribute a left join pg_catalog.pg_type t "
"on a.atttypid = t.oid "
"where a.attrelid = '%s'::pg_catalog.oid "
@@ -2442,7 +2442,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
*/
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 as attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, false as attisdropped, null as attislocal, "
- "format_type(t.oid,a.atttypmod) as atttypname "
+ "format_type(t.oid,a.atttypmod) as atttypname "
"from pg_attribute a left join pg_type t "
"on a.atttypid = t.oid "
"where a.attrelid = '%s'::oid "
@@ -2454,7 +2454,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{
/* format_type not available before 7.1 */
appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 as attstattarget, attstorage, attstorage as typstorage, "
- "attnotnull, atthasdef, false as attisdropped, null as attislocal, "
+ "attnotnull, atthasdef, false as attisdropped, null as attislocal, "
"(select typname from pg_type where oid = atttypid) as atttypname "
"from pg_attribute a "
"where attrelid = '%s'::oid "
@@ -2504,11 +2504,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
for (j = 0; j < ntups; j++)
{
- if (j+1 != atoi(PQgetvalue(res, j, i_attnum)))
+ if (j + 1 != atoi(PQgetvalue(res, j, i_attnum)))
{
write_msg(NULL, "invalid attribute numbering in table \"%s\"\n",
tbinfo->relname);
- exit_nicely();
+ exit_nicely();
}
tbinfo->attnames[j] = strdup(PQgetvalue(res, j, i_attname));
tbinfo->atttypnames[j] = strdup(PQgetvalue(res, j, i_atttypname));
@@ -3314,7 +3314,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
*/
if (g_fout->remoteVersion >= 70400)
appendPQExpBuffer(chkquery, "SELECT conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%s'::pg_catalog.oid",
tinfo->oid);
@@ -3345,7 +3345,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
fmtId(conname), consrc);
}
-
+
appendPQExpBuffer(q, ";\n");
(*deps)[depIdx++] = NULL; /* End of List */
@@ -3437,7 +3437,7 @@ dumpOneCompositeType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(q, ",");
}
appendPQExpBuffer(q, "\n);\n");
-
+
/*
* DROP must be fully qualified in case same name appears in
* pg_catalog
@@ -3755,7 +3755,8 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo)
char *prosecdef;
char *lanname;
char *rettypename;
- char *funcproclang; /* Boolean : is this function a PLang handler ? */
+ char *funcproclang; /* Boolean : is this function a PLang
+ * handler ? */
if (finfo->dumped)
goto done;
@@ -3900,7 +3901,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo)
ArchiveEntry(fout, finfo->oid, funcsig_tag,
finfo->pronamespace->nspname,
- finfo->usename, strcmp(funcproclang,"t")?"FUNCTION":"FUNC PROCEDURAL LANGUAGE", NULL,
+ finfo->usename, strcmp(funcproclang, "t") ? "FUNCTION" : "FUNC PROCEDURAL LANGUAGE", NULL,
q->data, delqry->data,
NULL, NULL, NULL);
@@ -4911,7 +4912,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
* Write out grant/revoke information
*
* 'type' must be TABLE, FUNCTION, LANGUAGE, or SCHEMA.
- * 'name' is the formatted name of the object. Must be quoted etc. already.
+ * 'name' is the formatted name of the object. Must be quoted etc. already.
* 'tag' is the tag for the archive entry (typ. unquoted name of object).
* 'nspname' is the namespace the object is in (NULL if none).
* 'owner' is the owner, NULL if there is no owner (for languages).
@@ -4927,12 +4928,15 @@ dumpACL(Archive *fout, const char *type, const char *name,
{
PQExpBuffer sql;
- /* acl_lang is a flag only true if we are dumping language's ACL,
- * so we can set 'type' to a value that is suitable to build
- * SQL requests as for other types.
- */
- bool acl_lang = false;
- if(!strcmp(type,"ACL LANGUAGE")){
+ /*
+ * acl_lang is a flag only true if we are dumping language's ACL, so
+ * we can set 'type' to a value that is suitable to build SQL requests
+ * as for other types.
+ */
+ bool acl_lang = false;
+
+ if (!strcmp(type, "ACL LANGUAGE"))
+ {
type = "LANGUAGE";
acl_lang = true;
}
@@ -5275,9 +5279,9 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 70400)
appendPQExpBuffer(query, "SELECT conname, "
- " pg_catalog.pg_get_constraintdef(c1.oid) AS consrc "
+ " pg_catalog.pg_get_constraintdef(c1.oid) AS consrc "
" from pg_catalog.pg_constraint c1 "
- " where conrelid = '%s'::pg_catalog.oid "
+ " where conrelid = '%s'::pg_catalog.oid "
" and contype = 'c' "
" and not exists "
" (select 1 from "
@@ -5288,7 +5292,7 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
" or (c2.conname[0] = '$' "
" and c1.conname[0] = '$')"
" )"
- " and pg_catalog.pg_get_constraintdef(c2.oid) "
+ " and pg_catalog.pg_get_constraintdef(c2.oid) "
" = pg_catalog.pg_get_constraintdef(c1.oid) "
" and c2.conrelid = i.inhparent) "
" order by conname ",
@@ -5357,7 +5361,7 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
appendPQExpBuffer(q, ",\n ");
appendPQExpBuffer(q, "CONSTRAINT %s ",
- fmtId(name));
+ fmtId(name));
appendPQExpBuffer(q, "%s", expr);
}
PQclear(res2);
@@ -5402,9 +5406,9 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
for (j = 0; j < tbinfo->numatts; j++)
{
/*
- * Dump per-column statistics information. We only issue an ALTER
- * TABLE statement if the attstattarget entry for this column is
- * non-negative (i.e. it's not the default value)
+ * Dump per-column statistics information. We only issue an
+ * ALTER TABLE statement if the attstattarget entry for this
+ * column is non-negative (i.e. it's not the default value)
*/
if (tbinfo->attstattarget[j] >= 0 &&
!tbinfo->attisdropped[j])
@@ -5418,12 +5422,14 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
}
/*
- * Dump per-column storage information. The statement is only dumped if
- * the storage has been changed from the type's default.
+ * Dump per-column storage information. The statement is only
+ * dumped if the storage has been changed from the type's
+ * default.
*/
- if(!tbinfo->attisdropped[j] && tbinfo->attstorage[j] != tbinfo->typstorage[j])
+ if (!tbinfo->attisdropped[j] && tbinfo->attstorage[j] != tbinfo->typstorage[j])
{
- switch (tbinfo->attstorage[j]) {
+ switch (tbinfo->attstorage[j])
+ {
case 'p':
storage = "PLAIN";
break;
@@ -5439,8 +5445,13 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
default:
storage = NULL;
}
- /* Only dump the statement if it's a storage type we recognize */
- if (storage != NULL) {
+
+ /*
+ * Only dump the statement if it's a storage type we
+ * recognize
+ */
+ if (storage != NULL)
+ {
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
fmtId(tbinfo->relname));
appendPQExpBuffer(q, "ALTER COLUMN %s ",
@@ -5605,7 +5616,7 @@ dumpIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
const char *indexrelname = PQgetvalue(res, j, i_indexrelname);
const char *indexdef = PQgetvalue(res, j, i_indexdef);
char contype = *(PQgetvalue(res, j, i_contype));
- bool indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't');
+ bool indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't');
resetPQExpBuffer(q);
resetPQExpBuffer(delq);
@@ -5659,11 +5670,12 @@ dumpIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(indexrelname));
/* If the index is clustered, we need to record that. */
- if (indisclustered) {
- appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
- fmtId(tbinfo->relname));
- appendPQExpBuffer(q, " ON %s;\n",
- fmtId(indexrelname));
+ if (indisclustered)
+ {
+ appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
+ fmtId(tbinfo->relname));
+ appendPQExpBuffer(q, " ON %s;\n",
+ fmtId(indexrelname));
}
ArchiveEntry(fout, indexreloid,
@@ -5684,11 +5696,12 @@ dumpIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBuffer(q, "%s;\n", indexdef);
/* If the index is clustered, we need to record that. */
- if (indisclustered) {
- appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
- fmtId(tbinfo->relname));
- appendPQExpBuffer(q, " ON %s;\n",
- fmtId(indexrelname));
+ if (indisclustered)
+ {
+ appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
+ fmtId(tbinfo->relname));
+ appendPQExpBuffer(q, " ON %s;\n",
+ fmtId(indexrelname));
}
/*
@@ -5889,16 +5902,16 @@ dumpOneSequence(Archive *fout, TableInfo *tbinfo,
snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
appendPQExpBuffer(query,
- "SELECT sequence_name, last_value, increment_by, "
- "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
- " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
- " ELSE max_value "
- "END AS max_value, "
- "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
- " WHEN increment_by < 0 AND min_value = %s THEN NULL "
- " ELSE min_value "
- "END AS min_value, "
- "cache_value, is_cycled, is_called from %s",
+ "SELECT sequence_name, last_value, increment_by, "
+ "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
+ " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
+ " ELSE max_value "
+ "END AS max_value, "
+ "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
+ " WHEN increment_by < 0 AND min_value = %s THEN NULL "
+ " ELSE min_value "
+ "END AS min_value, "
+ "cache_value, is_cycled, is_called from %s",
bufx, bufm,
fmtId(tbinfo->relname));
@@ -5962,7 +5975,7 @@ dumpOneSequence(Archive *fout, TableInfo *tbinfo,
resetPQExpBuffer(query);
appendPQExpBuffer(query,
- "CREATE SEQUENCE %s\n",
+ "CREATE SEQUENCE %s\n",
fmtId(tbinfo->relname));
if (!called)
@@ -5981,7 +5994,7 @@ dumpOneSequence(Archive *fout, TableInfo *tbinfo,
appendPQExpBuffer(query, " NO MINVALUE\n");
appendPQExpBuffer(query,
- " CACHE %s%s;\n",
+ " CACHE %s%s;\n",
cache, (cycled ? "\n CYCLE" : ""));
ArchiveEntry(fout, tbinfo->oid, tbinfo->relname,
@@ -6072,7 +6085,7 @@ dumpConstraints(Archive *fout, TableInfo *tblinfo, int numTables)
resetPQExpBuffer(query);
appendPQExpBuffer(query,
"SELECT oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) as condef "
+ "pg_catalog.pg_get_constraintdef(oid) as condef "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%s'::pg_catalog.oid "
"AND contype = 'f'",
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index c30665a7ba3..3f0d0156c55 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.101 2003/03/20 06:26:30 momjian Exp $
+ * $Id: pg_dump.h,v 1.102 2003/08/04 00:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -128,8 +128,8 @@ typedef struct _tableInfo
char **atttypnames; /* attribute type names */
int *atttypmod; /* type-specific type modifiers */
int *attstattarget; /* attribute statistics targets */
- char *attstorage; /* attribute storage scheme */
- char *typstorage; /* type storage scheme */
+ char *attstorage; /* attribute storage scheme */
+ char *typstorage; /* type storage scheme */
bool *attisdropped; /* true if attr is dropped; don't dump it */
bool *attislocal; /* true if attr has local definition */
bool *attisserial; /* true if attr is serial or bigserial */
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index a7502a7c144..4c59d5d90f8 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.24 2003/07/29 14:17:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.25 2003/08/04 00:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,7 @@
#ifndef HAVE_GETOPT_LONG
#include "getopt_long.h"
-int optreset;
+int optreset;
#endif
#include "dumputils.h"
@@ -278,13 +278,13 @@ dumpUsers(PGconn *conn)
if (server_version >= 70100)
res = executeQuery(conn,
- "SELECT usename, usesysid, passwd, usecreatedb, "
+ "SELECT usename, usesysid, passwd, usecreatedb, "
"usesuper, valuntil "
"FROM pg_shadow "
"WHERE usesysid <> (SELECT datdba FROM pg_database WHERE datname = 'template0')");
else
res = executeQuery(conn,
- "SELECT usename, usesysid, passwd, usecreatedb, "
+ "SELECT usename, usesysid, passwd, usecreatedb, "
"usesuper, valuntil "
"FROM pg_shadow "
"WHERE usesysid <> (SELECT datdba FROM pg_database WHERE datname = 'template1')");
@@ -417,13 +417,13 @@ dumpCreateDB(PGconn *conn)
"coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"datistemplate, datpath, datacl "
- "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
+ "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
"WHERE datallowconn ORDER BY 1");
else if (server_version >= 70100)
res = executeQuery(conn,
"SELECT datname, "
"coalesce("
- "(select usename from pg_shadow where usesysid=datdba), "
+ "(select usename from pg_shadow where usesysid=datdba), "
"(select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"datistemplate, datpath, '' as datacl "
@@ -437,7 +437,7 @@ dumpCreateDB(PGconn *conn)
*/
res = executeQuery(conn,
"SELECT datname, "
- "(select usename from pg_shadow where usesysid=datdba), "
+ "(select usename from pg_shadow where usesysid=datdba), "
"pg_encoding_to_char(d.encoding), "
"'f' as datistemplate, datpath, '' as datacl "
"FROM pg_database d "
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 0a7b0f1d3b1..0598c9c4510 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.48 2003/07/23 08:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.49 2003/08/04 00:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,7 +61,7 @@
#ifndef HAVE_GETOPT_LONG
#include "getopt_long.h"
-int optreset;
+int optreset;
#endif
#ifdef ENABLE_NLS
@@ -401,7 +401,7 @@ usage(const char *progname)
printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"));
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead\n"
- " of reconnecting, if possible\n"));
+ " of reconnecting, if possible\n"));
printf(_(" -X disable-triggers, --disable-triggers\n"
" disable triggers during data-only restore\n"));
diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c
index ecc0c545245..e94c8d3d877 100644
--- a/src/bin/pg_encoding/pg_encoding.c
+++ b/src/bin/pg_encoding/pg_encoding.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.11 2002/10/20 11:33:48 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.12 2003/08/04 00:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,11 @@ main(int argc, char **argv)
{
if (be_only && pg_valid_server_encoding(name) < 0)
exit(1);
- /* pg_encoding_to_char() returns "" if invalid encoding number is given */
+
+ /*
+ * pg_encoding_to_char() returns "" if invalid encoding number
+ * is given
+ */
else if (strcmp("", name))
printf("%s\n", name);
else
@@ -77,7 +81,7 @@ main(int argc, char **argv)
exit(1);
printf("%d\n", enc);
}
- else
+ else
exit(1);
exit(0);
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index bf81bc5d4ab..3aa28738656 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.10 2003/07/23 08:47:32 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.11 2003/08/04 00:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,8 +172,8 @@ main(int argc, char *argv[])
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
- minXlogSeg = strtoul(endptr+1, &endptr2, 0);
- if (endptr2 == endptr+1 || *endptr2 != '\0')
+ minXlogSeg = strtoul(endptr + 1, &endptr2, 0);
+ if (endptr2 == endptr + 1 || *endptr2 != '\0')
{
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index cc1c20bd119..02f083c5a65 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.99 2003/07/28 00:14:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.100 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1291,8 +1291,8 @@ unescape(const unsigned char *source, size_t len)
case '7':
case '8':
case '9':
- c = parse_char((char **)&p);
- break;
+ c = parse_char((char **) &p);
+ break;
default:
c = *p;
@@ -1496,13 +1496,13 @@ SyncVerbosityVariable(void)
switch (SwitchVariable(pset.vars, "VERBOSITY",
"default", "terse", "verbose", NULL))
{
- case 1: /* default */
+ case 1: /* default */
PQsetErrorVerbosity(pset.db, PQERRORS_DEFAULT);
break;
- case 2: /* terse */
+ case 2: /* terse */
PQsetErrorVerbosity(pset.db, PQERRORS_TERSE);
break;
- case 3: /* verbose */
+ case 3: /* verbose */
PQsetErrorVerbosity(pset.db, PQERRORS_VERBOSE);
break;
default: /* not set or unrecognized value */
@@ -1545,11 +1545,11 @@ editFile(const char *fname)
sys = malloc(strlen(editorName) + strlen(fname) + 10 + 1);
if (!sys)
return false;
- sprintf(sys,
+ sprintf(sys,
#ifndef WIN32
- "exec "
+ "exec "
#endif
- "%s '%s'", editorName, fname);
+ "%s '%s'", editorName, fname);
result = system(sys);
if (result == -1)
psql_error("could not start editor \"%s\"\n", editorName);
@@ -1673,7 +1673,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
#ifdef USE_READLINE
#ifdef HAVE_REPLACE_HISTORY_ENTRY
- replace_history_entry(where_history(),query_buf->data,NULL);
+ replace_history_entry(where_history(), query_buf->data, NULL);
#else
add_history(query_buf->data);
#endif
@@ -1913,11 +1913,11 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
else if (strcmp(param, "pager") == 0)
{
if (value && strcasecmp(value, "always") == 0)
- popt->topt.pager = 2;
+ popt->topt.pager = 2;
else if (popt->topt.pager == 1)
- popt->topt.pager = 0;
+ popt->topt.pager = 0;
else
- popt->topt.pager = 1;
+ popt->topt.pager = 1;
if (!quiet)
{
if (popt->topt.pager == 1)
@@ -1978,11 +1978,11 @@ do_shell(const char *command)
else
exit(EXIT_FAILURE);
}
- sprintf(sys,
+ sprintf(sys,
#ifndef WIN32
- "exec "
+ "exec "
#endif
- "%s", shellName);
+ "%s", shellName);
result = system(sys);
free(sys);
}
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 42299129fb9..8bfa3aa139f 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.67 2003/07/31 04:23:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.68 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -44,15 +44,16 @@
#ifndef WIN32
typedef struct timeval TimevalStruct;
+
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
#define DIFF_MSEC(T, U) ((((T)->tv_sec - (U)->tv_sec) * 1000000.0 + (T)->tv_usec - (U)->tv_usec) / 1000.0)
#else
typedef struct _timeb TimevalStruct;
+
#define GETTIMEOFDAY(T) _ftime(T)
#define DIFF_MSEC(T, U) ((((T)->time - (U)->time) * 1000.0 + (T)->millitm - (U)->millitm))
-
#endif
extern bool prompt_state;
@@ -187,7 +188,7 @@ NoticeProcessor(void *arg, const char *message)
* so. We use write() to print to stdout because it's better to use simple
* facilities in a signal handler.
*/
-static PGconn *volatile cancelConn = NULL;
+static PGconn *volatile cancelConn = NULL;
volatile bool cancel_pressed = false;
@@ -227,7 +228,7 @@ handle_sigint(SIGNAL_ARGS)
*
* Returns whether our backend connection is still there.
*/
-static bool
+static bool
ConnectionUp()
{
return PQstatus(pset.db) != CONNECTION_BAD;
@@ -241,15 +242,15 @@ ConnectionUp()
* see if it can be restored.
*
* Returns true if either the connection was still there, or it could be
- * restored successfully; false otherwise. If, however, there was no
+ * restored successfully; false otherwise. If, however, there was no
* connection and the session is non-interactive, this will exit the program
* with a code of EXIT_BADCONN.
*/
static bool
CheckConnection()
{
- bool OK;
-
+ bool OK;
+
OK = ConnectionUp();
if (!OK)
{
@@ -284,21 +285,23 @@ CheckConnection()
*
* Set cancelConn to point to the current database connection.
*/
-static void SetCancelConn(void)
+static void
+SetCancelConn(void)
{
- cancelConn = pset.db;
+ cancelConn = pset.db;
}
/*
* ResetCancelConn
*
- * Set cancelConn to NULL. I don't know what this means exactly, but it saves
+ * Set cancelConn to NULL. I don't know what this means exactly, but it saves
* having to export the variable.
*/
-void ResetCancelConn(void)
+void
+ResetCancelConn(void)
{
- cancelConn = NULL;
+ cancelConn = NULL;
}
@@ -314,33 +317,32 @@ void ResetCancelConn(void)
static bool
AcceptResult(const PGresult *result)
{
- bool OK = true;
+ bool OK = true;
ResetCancelConn();
if (!result)
- {
- OK = false;
- }
- else switch (PQresultStatus(result))
- {
- case PGRES_COMMAND_OK:
- case PGRES_TUPLES_OK:
- case PGRES_COPY_IN:
- /* Fine, do nothing */
- break;
-
- case PGRES_COPY_OUT:
- /* keep cancel connection for copy out state */
- SetCancelConn();
- break;
-
- default:
- OK = false;
- break;
- }
+ OK = false;
+ else
+ switch (PQresultStatus(result))
+ {
+ case PGRES_COMMAND_OK:
+ case PGRES_TUPLES_OK:
+ case PGRES_COPY_IN:
+ /* Fine, do nothing */
+ break;
+
+ case PGRES_COPY_OUT:
+ /* keep cancel connection for copy out state */
+ SetCancelConn();
+ break;
+
+ default:
+ OK = false;
+ break;
+ }
- if (!OK)
+ if (!OK)
{
CheckConnection();
psql_error("%s", PQerrorMessage(pset.db));
@@ -365,7 +367,7 @@ PGresult *
PSQLexec(const char *query, bool start_xact)
{
PGresult *res;
- int echo_hidden;
+ int echo_hidden;
if (!pset.db)
{
@@ -438,41 +440,38 @@ PrintNotifications(void)
*
* Returns true if successful, false otherwise.
*/
-static bool
+static bool
PrintQueryTuples(const PGresult *results)
{
- /* write output to \g argument, if any */
- if (pset.gfname)
- {
- FILE *queryFout_copy = pset.queryFout;
- bool queryFoutPipe_copy = pset.queryFoutPipe;
+ /* write output to \g argument, if any */
+ if (pset.gfname)
+ {
+ FILE *queryFout_copy = pset.queryFout;
+ bool queryFoutPipe_copy = pset.queryFoutPipe;
- pset.queryFout = stdout; /* so it doesn't get
- * closed */
+ pset.queryFout = stdout; /* so it doesn't get closed */
- /* open file/pipe */
- if (!setQFout(pset.gfname))
- {
- pset.queryFout = queryFout_copy;
- pset.queryFoutPipe = queryFoutPipe_copy;
+ /* open file/pipe */
+ if (!setQFout(pset.gfname))
+ {
+ pset.queryFout = queryFout_copy;
+ pset.queryFoutPipe = queryFoutPipe_copy;
return false;
- }
+ }
- printQuery(results, &pset.popt, pset.queryFout);
+ printQuery(results, &pset.popt, pset.queryFout);
- /* close file/pipe, restore old setting */
- setQFout(NULL);
+ /* close file/pipe, restore old setting */
+ setQFout(NULL);
- pset.queryFout = queryFout_copy;
- pset.queryFoutPipe = queryFoutPipe_copy;
+ pset.queryFout = queryFout_copy;
+ pset.queryFoutPipe = queryFoutPipe_copy;
- free(pset.gfname);
- pset.gfname = NULL;
- }
- else
- {
- printQuery(results, &pset.popt, pset.queryFout);
- }
+ free(pset.gfname);
+ pset.gfname = NULL;
+ }
+ else
+ printQuery(results, &pset.popt, pset.queryFout);
return true;
}
@@ -487,65 +486,64 @@ PrintQueryTuples(const PGresult *results)
* Returns true if the query executed successfully, false otherwise.
*/
static bool
-PrintQueryResults(PGresult *results,
- const TimevalStruct *before,
- const TimevalStruct *after)
+PrintQueryResults(PGresult *results,
+ const TimevalStruct * before,
+ const TimevalStruct * after)
{
- bool success = false;
+ bool success = false;
- if (!results)
- return false;
+ if (!results)
+ return false;
switch (PQresultStatus(results))
{
case PGRES_TUPLES_OK:
success = PrintQueryTuples(results);
- break;
- case PGRES_EMPTY_QUERY:
+ break;
+ case PGRES_EMPTY_QUERY:
+ success = true;
+ break;
+ case PGRES_COMMAND_OK:
+ {
+ char buf[10];
+
success = true;
- break;
- case PGRES_COMMAND_OK:
+ sprintf(buf, "%u", (unsigned int) PQoidValue(results));
+ if (!QUIET())
{
- char buf[10];
-
- success = true;
- sprintf(buf, "%u", (unsigned int) PQoidValue(results));
- if (!QUIET())
- {
- if (pset.popt.topt.format == PRINT_HTML)
- {
- fputs("<p>", pset.queryFout);
- html_escaped_print(PQcmdStatus(results), pset.queryFout);
- fputs("</p>\n", pset.queryFout);
- }
- else
- {
- fprintf(pset.queryFout, "%s\n", PQcmdStatus(results));
- }
- }
- SetVariable(pset.vars, "LASTOID", buf);
- break;
+ if (pset.popt.topt.format == PRINT_HTML)
+ {
+ fputs("<p>", pset.queryFout);
+ html_escaped_print(PQcmdStatus(results), pset.queryFout);
+ fputs("</p>\n", pset.queryFout);
+ }
+ else
+ fprintf(pset.queryFout, "%s\n", PQcmdStatus(results));
}
- case PGRES_COPY_OUT:
- success = handleCopyOut(pset.db, pset.queryFout);
+ SetVariable(pset.vars, "LASTOID", buf);
break;
+ }
+ case PGRES_COPY_OUT:
+ success = handleCopyOut(pset.db, pset.queryFout);
+ break;
- case PGRES_COPY_IN:
- if (pset.cur_cmd_interactive && !QUIET())
- puts(gettext("Enter data to be copied followed by a newline.\n"
- "End with a backslash and a period on a line by itself."));
+ case PGRES_COPY_IN:
+ if (pset.cur_cmd_interactive && !QUIET())
+ puts(gettext("Enter data to be copied followed by a newline.\n"
+ "End with a backslash and a period on a line by itself."));
- success = handleCopyIn(pset.db, pset.cur_cmd_source,
- pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL);
- break;
+ success = handleCopyIn(pset.db, pset.cur_cmd_source,
+ pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL);
+ break;
default:
- break;
- }
+ break;
+ }
- fflush(pset.queryFout);
+ fflush(pset.queryFout);
- if (!CheckConnection()) return false;
+ if (!CheckConnection())
+ return false;
/* Possible microtiming output */
if (pset.timing && success)
@@ -572,8 +570,9 @@ bool
SendQuery(const char *query)
{
PGresult *results;
- TimevalStruct before, after;
- bool OK;
+ TimevalStruct before,
+ after;
+ bool OK;
if (!pset.db)
{
@@ -599,7 +598,7 @@ SendQuery(const char *query)
puts(query);
fflush(stdout);
}
-
+
SetCancelConn();
if (PQtransactionStatus(pset.db) == PQTRANS_IDLE &&
@@ -636,7 +635,7 @@ SendQuery(const char *query)
static bool
is_transact_command(const char *query)
{
- int wordlen;
+ int wordlen;
/*
* First we must advance over any whitespace and comments.
@@ -693,13 +692,14 @@ is_transact_command(const char *query)
}
-char parse_char(char **buf)
+char
+parse_char(char **buf)
{
- long l;
+ long l;
- l = strtol(*buf, buf, 0);
- --*buf;
- return (char)l;
+ l = strtol(*buf, buf, 0);
+ --*buf;
+ return (char) l;
}
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index d45fecc539c..6694624cad5 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.31 2003/07/23 08:47:39 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.32 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -28,8 +28,8 @@
#ifdef WIN32
#define strcasecmp(x,y) stricmp(x,y)
-#define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
-#define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)
+#define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
+#define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)
#endif
/*
@@ -142,8 +142,9 @@ parse_slash_copy(const char *args)
goto error;
/*
- * strtokx() will not have returned a multi-character token starting with
- * '.', so we don't need strcmp() here. Likewise for '(', etc, below.
+ * strtokx() will not have returned a multi-character token starting
+ * with '.', so we don't need strcmp() here. Likewise for '(', etc,
+ * below.
*/
if (token[0] == '.')
{
@@ -188,8 +189,7 @@ parse_slash_copy(const char *args)
}
/*
- * Allows old COPY syntax for backward compatibility
- * 2002-06-19
+ * Allows old COPY syntax for backward compatibility 2002-06-19
*/
if (strcasecmp(token, "with") == 0)
{
@@ -227,8 +227,7 @@ parse_slash_copy(const char *args)
0, false, pset.encoding);
/*
- * Allows old COPY syntax for backward compatibility
- * 2002-06-19
+ * Allows old COPY syntax for backward compatibility 2002-06-19
*/
if (token && strcasecmp(token, "using") == 0)
{
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 70264a4487c..4679402282f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.81 2003/07/27 03:32:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.82 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -139,10 +139,10 @@ describeFunctions(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
- "SELECT CASE WHEN p.proretset THEN 'setof ' ELSE '' END ||\n"
- " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
- " n.nspname as \"%s\",\n"
- " p.proname as \"%s\",\n"
+ "SELECT CASE WHEN p.proretset THEN 'setof ' ELSE '' END ||\n"
+ " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
+ " n.nspname as \"%s\",\n"
+ " p.proname as \"%s\",\n"
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\"",
_("Result data type"), _("Schema"), _("Name"),
_("Argument data types"));
@@ -723,7 +723,7 @@ describeOneTableDetails(const char *schemaname,
/* Get column info (index requires additional checks) */
printfPQExpBuffer(&buf, "SELECT a.attname,");
appendPQExpBuffer(&buf, "\n pg_catalog.format_type(a.atttypid, a.atttypmod),"
- "\n (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d"
+ "\n (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d"
"\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
"\n a.attnotnull, a.attnum");
if (verbose)
@@ -765,7 +765,7 @@ describeOneTableDetails(const char *schemaname,
{
/* Name */
#ifdef WIN32
- cells[i * cols + 0] = mbvalidate(PQgetvalue(res, i, 0));
+ cells[i * cols + 0] = mbvalidate(PQgetvalue(res, i, 0));
#else
cells[i * cols + 0] = PQgetvalue(res, i, 0); /* don't free this
* afterwards */
@@ -962,7 +962,7 @@ describeOneTableDetails(const char *schemaname,
foreignkey_count = 0,
rule_count = 0,
trigger_count = 0,
- inherits_count = 0;
+ inherits_count = 0;
int count_footers = 0;
/* count indexes */
@@ -1023,7 +1023,7 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.triggers)
{
printfPQExpBuffer(&buf,
- "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n"
+ "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n"
"FROM pg_catalog.pg_trigger t\n"
"WHERE t.tgrelid = '%s' "
"and (not tgisconstraint "
@@ -1079,7 +1079,8 @@ describeOneTableDetails(const char *schemaname,
* sizeof(*footers));
/* print indexes */
- if (index_count > 0) {
+ if (index_count > 0)
+ {
printfPQExpBuffer(&buf, _("Indexes:"));
footers[count_footers++] = xstrdup(buf.data);
for (i = 0; i < index_count; i++)
@@ -1093,11 +1094,11 @@ describeOneTableDetails(const char *schemaname,
/* Label as primary key or unique (but not both) */
appendPQExpBuffer(&buf,
- strcmp(PQgetvalue(result1, i, 1), "t") == 0
+ strcmp(PQgetvalue(result1, i, 1), "t") == 0
? _(" primary key,") :
- (strcmp(PQgetvalue(result1, i, 2), "t") == 0
- ? _(" unique,")
- : ""));
+ (strcmp(PQgetvalue(result1, i, 2), "t") == 0
+ ? _(" unique,")
+ : ""));
/* Everything after "USING" is echoed verbatim */
indexdef = PQgetvalue(result1, i, 3);
@@ -1112,7 +1113,8 @@ describeOneTableDetails(const char *schemaname,
}
/* print check constraints */
- if (check_count > 0) {
+ if (check_count > 0)
+ {
printfPQExpBuffer(&buf, _("Check constraints:"));
footers[count_footers++] = xstrdup(buf.data);
for (i = 0; i < check_count; i++)
@@ -1126,7 +1128,8 @@ describeOneTableDetails(const char *schemaname,
}
/* print foreign key constraints */
- if (foreignkey_count > 0) {
+ if (foreignkey_count > 0)
+ {
printfPQExpBuffer(&buf, _("Foreign-key constraints:"));
footers[count_footers++] = xstrdup(buf.data);
for (i = 0; i < foreignkey_count; i++)
@@ -1140,7 +1143,8 @@ describeOneTableDetails(const char *schemaname,
}
/* print rules */
- if (rule_count > 0) {
+ if (rule_count > 0)
+ {
printfPQExpBuffer(&buf, _("Rules:"));
footers[count_footers++] = xstrdup(buf.data);
for (i = 0; i < rule_count; i++)
@@ -1158,7 +1162,8 @@ describeOneTableDetails(const char *schemaname,
}
/* print triggers */
- if (trigger_count > 0) {
+ if (trigger_count > 0)
+ {
printfPQExpBuffer(&buf, _("Triggers:"));
footers[count_footers++] = xstrdup(buf.data);
for (i = 0; i < trigger_count; i++)
@@ -1368,9 +1373,9 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
/*
* If showSystem is specified, show only system objects (those in
- * pg_catalog). Otherwise, suppress system objects, including
- * those in pg_catalog and pg_toast. (We don't want to hide temp
- * tables though.)
+ * pg_catalog). Otherwise, suppress system objects, including those
+ * in pg_catalog and pg_toast. (We don't want to hide temp tables
+ * though.)
*/
if (showSystem)
appendPQExpBuffer(&buf, " AND n.nspname = 'pg_catalog'\n");
@@ -1476,11 +1481,11 @@ listConversions(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.conname AS \"%s\",\n"
- " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n"
- " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n"
+ " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n"
+ " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n"
" CASE WHEN c.condefault THEN '%s'\n"
" ELSE '%s' END AS \"%s\"\n"
- "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n"
+ "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n"
"WHERE n.oid = c.connamespace\n",
_("Schema"),
_("Name"),
@@ -1525,8 +1530,8 @@ listCasts(const char *pattern)
initPQExpBuffer(&buf);
/* NEED LEFT JOIN FOR BINARY CASTS */
printfPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
- " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
+ "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
+ " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
" CASE WHEN castfunc = 0 THEN '%s'\n"
" ELSE p.proname\n"
" END as \"%s\",\n"
@@ -1534,7 +1539,7 @@ listCasts(const char *pattern)
" WHEN c.castcontext = 'a' THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"\n"
- "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
+ "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
" ON c.castfunc = p.oid\n"
"ORDER BY 1, 2",
_("Source type"),
@@ -1576,7 +1581,7 @@ listSchemas(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" u.usename AS \"%s\"\n"
- "FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
+ "FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
" ON n.nspowner=u.usesysid\n",
_("Name"),
_("Owner"));
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index a884beb2e66..4b59a3af5fd 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2003 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.75 2003/07/25 21:48:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.76 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -173,7 +173,7 @@ slashUsage(unsigned short int pager)
*/
fprintf(output, _("General\n"));
fprintf(output, _(" \\c[onnect] [DBNAME|- [USER]]\n"
- " connect to new database (currently \"%s\")\n"),
+ " connect to new database (currently \"%s\")\n"),
PQdb(pset.db));
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n"));
@@ -203,7 +203,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\i FILE execute commands from file\n"));
fprintf(output, _(" \\o [FILE] send all query results to file or |pipe\n"));
fprintf(output, _(" \\qecho [STRING]\n"
- " write string to query output stream (see \\o)\n"));
+ " write string to query output stream (see \\o)\n"));
fprintf(output, "\n");
fprintf(output, _("Informational\n"));
@@ -235,7 +235,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\pset NAME [VALUE]\n"
" set table output option\n"
" (NAME := {format|border|expanded|fieldsep|null|recordsep|\n"
- " tuples_only|title|tableattr|pager})\n"));
+ " tuples_only|title|tableattr|pager})\n"));
fprintf(output, _(" \\t show only rows (currently %s)\n"),
ON(pset.popt.topt.tuples_only));
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
@@ -274,7 +274,7 @@ helpSQL(const char *topic, unsigned short int pager)
{
int i;
int items_per_column = (QL_HELP_COUNT + 2) / 3;
- FILE *output;
+ FILE *output;
output = PageOutput(items_per_column + 1, pager);
@@ -283,8 +283,8 @@ helpSQL(const char *topic, unsigned short int pager)
for (i = 0; i < items_per_column; i++)
{
fprintf(output, " %-26s%-26s",
- VALUE_OR_NULL(QL_HELP[i].cmd),
- VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd));
+ VALUE_OR_NULL(QL_HELP[i].cmd),
+ VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd));
if (i + 2 * items_per_column < QL_HELP_COUNT)
fprintf(output, "%-26s",
VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd));
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index b220ed89418..9ebc1dc7f80 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.26 2003/07/27 03:32:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.27 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
@@ -27,12 +27,11 @@ static bool useHistory;
enum histcontrol
{
- hctl_none = 0,
- hctl_ignorespace = 1,
- hctl_ignoredups = 2,
- hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
+ hctl_none = 0,
+ hctl_ignorespace = 1,
+ hctl_ignoredups = 2,
+ hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
};
-
#endif
#ifdef HAVE_ATEXIT
@@ -43,16 +42,17 @@ static void finishInput(void);
static void finishInput(int, void *);
#endif
-#define PSQLHISTORY ".psql_history"
+#define PSQLHISTORY ".psql_history"
#ifdef WIN32
- /*
- * translate DOS console character set into ANSI, needed e.g. for
- * German umlauts
- */
- if (GetVariableBool(pset.vars, "WIN32_CONSOLE"))
- OemToChar(s, s);
+
+ /*
+ * translate DOS console character set into ANSI, needed e.g. for German
+ * umlauts
+ */
+if (GetVariableBool(pset.vars, "WIN32_CONSOLE"))
+ OemToChar(s, s);
#endif
#ifdef USE_READLINE
@@ -64,11 +64,16 @@ GetHistControlConfig(void)
var = GetVariable(pset.vars, "HISTCONTROL");
- if (!var) HC = hctl_none;
- else if (strcmp(var, "ignorespace") == 0) HC = hctl_ignorespace;
- else if (strcmp(var, "ignoredups") == 0) HC = hctl_ignoredups;
- else if (strcmp(var, "ignoreboth") == 0) HC = hctl_ignoreboth;
- else HC = hctl_none;
+ if (!var)
+ HC = hctl_none;
+ else if (strcmp(var, "ignorespace") == 0)
+ HC = hctl_ignorespace;
+ else if (strcmp(var, "ignoredups") == 0)
+ HC = hctl_ignoredups;
+ else if (strcmp(var, "ignoreboth") == 0)
+ HC = hctl_ignoreboth;
+ else
+ HC = hctl_none;
return HC;
}
@@ -111,9 +116,9 @@ gets_interactive(const char *prompt)
HC = GetHistControlConfig();
if (((HC & hctl_ignorespace) && s[0] == ' ') ||
- ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0))
- {
- /* Ignore this line as far as history is concerned */
+ ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0))
+ {
+ /* Ignore this line as far as history is concerned */
}
else
{
@@ -216,7 +221,7 @@ saveHistory(char *fname)
if (useHistory && fname)
{
if (write_history(fname) == 0)
- return true;
+ return true;
psql_error("could not save history to file \"%s\": %s\n", fname, strerror(errno));
}
@@ -244,11 +249,12 @@ finishInput(int exitstatus, void *arg)
if (home)
{
psql_history = (char *) malloc(strlen(home) + 1 +
- strlen(PSQLHISTORY) + 1);
+ strlen(PSQLHISTORY) + 1);
if (psql_history)
{
- int hist_size;
- hist_size = GetVariableNum(pset.vars,"HISTSIZE",-1,-1,true);
+ int hist_size;
+
+ hist_size = GetVariableNum(pset.vars, "HISTSIZE", -1, -1, true);
if (hist_size >= 0)
stifle_history(hist_size);
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c
index a565d204784..720912b5b33 100644
--- a/src/bin/psql/large_obj.c
+++ b/src/bin/psql/large_obj.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.27 2003/06/28 00:12:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.28 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
@@ -20,7 +20,7 @@
/*
- * Prepare to do a large-object operation. We *must* be inside a transaction
+ * Prepare to do a large-object operation. We *must* be inside a transaction
* block for all these operations, so start one if needed.
*
* Returns TRUE if okay, FALSE if failed. *own_transaction is set to indicate
@@ -241,7 +241,7 @@ do_lo_unlink(const char *loid_arg)
if (is_superuser())
{
snprintf(buf, sizeof(buf),
- "DELETE FROM pg_catalog.pg_description WHERE objoid = '%u' "
+ "DELETE FROM pg_catalog.pg_description WHERE objoid = '%u' "
"AND classoid = 'pg_catalog.pg_largeobject'::regclass",
loid);
if (!(res = PSQLexec(buf, false)))
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 32c03cf24f2..d41627c132a 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.55 2003/03/21 03:28:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.56 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -43,8 +43,8 @@ MainLoop(FILE *source)
volatile backslashResult slashCmdStatus = CMD_UNKNOWN;
bool success;
- volatile char in_quote = 0; /* == 0 for no in_quote */
- volatile int in_xcomment = 0; /* in extended comment */
+ volatile char in_quote = 0; /* == 0 for no in_quote */
+ volatile int in_xcomment = 0; /* in extended comment */
volatile int paren_level = 0;
unsigned int query_start;
volatile int count_eof = 0;
@@ -152,33 +152,34 @@ MainLoop(FILE *source)
paren_level = 0;
slashCmdStatus = CMD_UNKNOWN;
}
- /*
- * otherwise, set interactive prompt if necessary and get
- * another line
- */
+
+ /*
+ * otherwise, set interactive prompt if necessary and get another
+ * line
+ */
else if (pset.cur_cmd_interactive)
- {
- int prompt_status;
+ {
+ int prompt_status;
fflush(stdout);
- if (in_quote && in_quote == '\'')
- prompt_status = PROMPT_SINGLEQUOTE;
- else if (in_quote && in_quote == '"')
- prompt_status = PROMPT_DOUBLEQUOTE;
- else if (in_xcomment)
- prompt_status = PROMPT_COMMENT;
- else if (paren_level)
- prompt_status = PROMPT_PAREN;
- else if (query_buf->len > 0)
- prompt_status = PROMPT_CONTINUE;
- else
- prompt_status = PROMPT_READY;
-
- line = gets_interactive(get_prompt(prompt_status));
- }
+ if (in_quote && in_quote == '\'')
+ prompt_status = PROMPT_SINGLEQUOTE;
+ else if (in_quote && in_quote == '"')
+ prompt_status = PROMPT_DOUBLEQUOTE;
+ else if (in_xcomment)
+ prompt_status = PROMPT_COMMENT;
+ else if (paren_level)
+ prompt_status = PROMPT_PAREN;
+ else if (query_buf->len > 0)
+ prompt_status = PROMPT_CONTINUE;
else
- line = gets_fromFile(source);
+ prompt_status = PROMPT_READY;
+
+ line = gets_interactive(get_prompt(prompt_status));
+ }
+ else
+ line = gets_fromFile(source);
/* Setting this will not have effect until next line. */
@@ -199,7 +200,7 @@ MainLoop(FILE *source)
/* This tries to mimic bash's IGNOREEOF feature. */
count_eof++;
- if (count_eof < GetVariableNum(pset.vars,"IGNOREEOF",0,10,false))
+ if (count_eof < GetVariableNum(pset.vars, "IGNOREEOF", 0, 10, false))
{
if (!QUIET())
printf(gettext("Use \"\\q\" to leave %s.\n"), pset.progname);
@@ -208,10 +209,10 @@ MainLoop(FILE *source)
puts(QUIET() ? "" : "\\q");
}
- break;
+ break;
}
- count_eof = 0;
+ count_eof = 0;
pset.lineno++;
@@ -274,7 +275,7 @@ MainLoop(FILE *source)
else if (line[i] == '/' && line[i + thislen] == '*')
{
in_xcomment++;
- if (in_xcomment == 1)
+ if (in_xcomment == 1)
ADVANCE_1;
}
@@ -283,7 +284,7 @@ MainLoop(FILE *source)
{
if (line[i] == '*' && line[i + thislen] == '/' &&
!--in_xcomment)
- ADVANCE_1;
+ ADVANCE_1;
}
/* start of quote? */
@@ -489,10 +490,10 @@ MainLoop(FILE *source)
if (!pset.cur_cmd_interactive)
{
if (!success && die_on_error)
- successResult = EXIT_USER;
- /* Have we lost the db connection? */
+ successResult = EXIT_USER;
+ /* Have we lost the db connection? */
else if (!pset.db)
- successResult = EXIT_BADCONN;
+ successResult = EXIT_BADCONN;
}
} /* while !endoffile/session */
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
index 437d7271c0d..f4dacd2a01d 100644
--- a/src/bin/psql/mbprint.c
+++ b/src/bin/psql/mbprint.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.7 2003/07/27 03:32:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.8 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
@@ -335,13 +335,15 @@ mbvalidate(unsigned char *pwcs, int encoding)
else
{
#ifdef WIN32
+
/*
- * translate characters to DOS console encoding, e.g. needed
- * for German umlauts
+ * translate characters to DOS console encoding, e.g. needed for
+ * German umlauts
*/
if (GetVariableBool(pset.vars, "WIN32_CONSOLE"))
CharToOem(pwcs, pwcs);
#endif
+
/*
* other encodings needing validation should add their own
* routines here
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 2f71aad9bc9..b2bc9afb6dc 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2003 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.40 2003/07/25 21:48:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.41 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -306,7 +306,7 @@ print_aligned_text(const char *title, const char *const * headers,
for (i = 0; i < col_count; i++)
{
- unsigned int nbspace;
+ unsigned int nbspace;
nbspace = widths[i] - head_w[i];
@@ -396,7 +396,7 @@ print_aligned_text(const char *title, const char *const * headers,
static void
print_aligned_vertical(const char *title, const char *const * headers,
- const char *const * cells, const char *const * footers,
+ const char *const * cells, const char *const * footers,
bool opt_barebones, unsigned short int opt_border,
int encoding, FILE *fout)
{
@@ -660,7 +660,8 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
fputs(" <tr valign=\"top\">\n", fout);
fprintf(fout, " <td align=\"%s\">", opt_align[(i) % col_count] == 'r' ? "right" : "left");
- if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only whitespace? */
+ if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
+ * whitespace? */
fputs("&nbsp; ", fout);
else
html_escaped_print(*ptr, fout);
@@ -734,7 +735,8 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
fputs("</th>\n", fout);
fprintf(fout, " <td align=\"%s\">", opt_align[i % col_count] == 'r' ? "right" : "left");
- if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only whitespace? */
+ if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
+ * whitespace? */
fputs("&nbsp; ", fout);
else
html_escaped_print(*ptr, fout);
@@ -1036,7 +1038,7 @@ printTable(const char *title,
{
const char *default_footer[] = {NULL};
unsigned short int border = opt->border;
- FILE *output;
+ FILE *output;
if (opt->format == PRINT_NOTHING)
return;
@@ -1049,9 +1051,9 @@ printTable(const char *title,
if (fout == stdout)
{
- int col_count = 0,
- row_count = 0,
- lines;
+ int col_count = 0,
+ row_count = 0,
+ lines;
const char *const * ptr;
/* rough estimate of columns and rows */
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index a70e7858bbe..7d6377fd36f 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.17 2003/06/12 07:52:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.18 2003/08/04 00:43:29 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -32,8 +32,7 @@ typedef struct _printTableOpt
bool expanded; /* expanded/vertical output (if supported
* by output format) */
unsigned short int pager; /* use pager for output (if to stdout and
- * stdout is a tty)
- * 0=off 1=on 2=always */
+ * stdout is a tty) 0=off 1=on 2=always */
bool tuples_only; /* don't output headers, row counts, etc. */
unsigned short int border; /* Print a border around the table.
* 0=none, 1=dividing lines, 2=full */
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 0df16d4b0c6..a202806926a 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.26 2003/06/28 00:12:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.27 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
@@ -86,14 +86,14 @@ get_prompt(promptStatus_t status)
case PROMPT_PAREN:
prompt_name = "PROMPT2";
break;
-
+
case PROMPT_COPY:
prompt_name = "PROMPT3";
break;
}
if (prompt_name)
- prompt_string = GetVariable(pset.vars, prompt_name);
+ prompt_string = GetVariable(pset.vars, prompt_name);
destination[0] = '\0';
@@ -112,16 +112,17 @@ get_prompt(promptStatus_t status)
strncpy(buf, PQdb(pset.db), MAX_PROMPT_SIZE);
break;
case '~':
- if (pset.db)
- {
+ if (pset.db)
+ {
const char *var;
- if (strcmp(PQdb(pset.db), PQuser(pset.db)) == 0 ||
- ((var = getenv("PGDATABASE")) && strcmp(var, PQdb(pset.db)) == 0))
- strcpy(buf, "~");
- else
- strncpy(buf, PQdb(pset.db), MAX_PROMPT_SIZE);
- }
- break;
+
+ if (strcmp(PQdb(pset.db), PQuser(pset.db)) == 0 ||
+ ((var = getenv("PGDATABASE")) && strcmp(var, PQdb(pset.db)) == 0))
+ strcpy(buf, "~");
+ else
+ strncpy(buf, PQdb(pset.db), MAX_PROMPT_SIZE);
+ }
+ break;
/* DB server hostname (long/short) */
case 'M':
@@ -172,7 +173,7 @@ get_prompt(promptStatus_t status)
case '7':
case '8':
case '9':
- *buf = parse_char((char **)&p);
+ *buf = parse_char((char **) &p);
break;
case 'R':
@@ -210,22 +211,23 @@ get_prompt(promptStatus_t status)
case 'T':
if (!pset.db)
buf[0] = '?';
- else switch (PQtransactionStatus(pset.db))
- {
- case PQTRANS_IDLE:
- buf[0] = '\0';
- break;
- case PQTRANS_ACTIVE:
- case PQTRANS_INTRANS:
- buf[0] = '*';
- break;
- case PQTRANS_INERROR:
- buf[0] = '!';
- break;
- default:
- buf[0] = '?';
- break;
- }
+ else
+ switch (PQtransactionStatus(pset.db))
+ {
+ case PQTRANS_IDLE:
+ buf[0] = '\0';
+ break;
+ case PQTRANS_ACTIVE:
+ case PQTRANS_INTRANS:
+ buf[0] = '*';
+ break;
+ case PQTRANS_INERROR:
+ buf[0] = '!';
+ break;
+ default:
+ buf[0] = '?';
+ break;
+ }
break;
case '?':
diff --git a/src/bin/psql/sprompt.c b/src/bin/psql/sprompt.c
index 0a9eed182bf..e08cb94c883 100644
--- a/src/bin/psql/sprompt.c
+++ b/src/bin/psql/sprompt.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.5 2003/07/27 03:32:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.6 2003/08/04 00:43:29 momjian Exp $
*/
@@ -46,10 +46,11 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
+
#else
#ifdef WIN32
- HANDLE t;
- LPDWORD t_orig;
+ HANDLE t;
+ LPDWORD t_orig;
#endif
#endif
@@ -88,14 +89,14 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
if (!echo)
{
/* get a new handle to turn echo off */
- t_orig=(LPDWORD)malloc(sizeof(DWORD));
- t=GetStdHandle(STD_INPUT_HANDLE);
+ t_orig = (LPDWORD) malloc(sizeof(DWORD));
+ t = GetStdHandle(STD_INPUT_HANDLE);
/* save the old configuration first */
GetConsoleMode(t, t_orig);
/* set to the new mode */
- SetConsoleMode(t, ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT);
+ SetConsoleMode(t, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
}
#endif
#endif
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index ab33c7f4174..c608ea6d452 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.76 2003/07/28 00:14:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.77 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
@@ -23,7 +23,7 @@
#ifndef HAVE_GETOPT_LONG
#include "getopt_long.h"
-int optreset;
+int optreset;
#endif
#include <locale.h>
@@ -75,7 +75,7 @@ struct adhoc_opts
};
static void parse_psql_options(int argc, char *argv[],
- struct adhoc_opts * options);
+ struct adhoc_opts * options);
static void process_psqlrc(void);
static void showVersion(void);
@@ -564,7 +564,7 @@ process_psqlrc(void)
if (home)
{
psqlrc = malloc(strlen(home) + 1 + strlen(PSQLRC) + 1 +
- strlen(PG_VERSION) + 1);
+ strlen(PG_VERSION) + 1);
if (!psqlrc)
{
fprintf(stderr, gettext("%s: out of memory\n"), pset.progname);
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index b6ecf114fe1..2e6ad05e8b4 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.32 2003/03/10 22:28:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.33 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
@@ -28,11 +28,11 @@ static void strip_quotes(char *source, char quote, char escape, int encoding);
* frammishes.
*
* s - string to parse, if NULL continue parsing the last string
- * whitespace - set of whitespace characters that separate tokens
+ * whitespace - set of whitespace characters that separate tokens
* delim - set of non-whitespace separator characters (or NULL)
* quote - set of characters that can quote a token (NULL if none)
* escape - character that can quote quotes (0 if none)
- * del_quotes - if TRUE, strip quotes from the returned token, else return
+ * del_quotes - if TRUE, strip quotes from the returned token, else return
* it exactly as found in the string
* encoding - the active character-set encoding
*
@@ -71,9 +71,10 @@ strtokx(const char *s,
if (s)
{
free(storage);
+
/*
* We may need extra space to insert delimiter nulls for adjacent
- * tokens. 2X the space is a gross overestimate, but it's
+ * tokens. 2X the space is a gross overestimate, but it's
* unlikely that this code will be used on huge strings anyway.
*/
storage = (char *) malloc(2 * strlen(s) + 1);
@@ -105,10 +106,10 @@ strtokx(const char *s,
{
/*
* If not at end of string, we need to insert a null to terminate
- * the returned token. We can just overwrite the next character
- * if it happens to be in the whitespace set ... otherwise move over
- * the rest of the string to make room. (This is why we allocated
- * extra space above).
+ * the returned token. We can just overwrite the next character
+ * if it happens to be in the whitespace set ... otherwise move
+ * over the rest of the string to make room. (This is why we
+ * allocated extra space above).
*/
p = start + 1;
if (*p != '\0')
@@ -148,7 +149,7 @@ strtokx(const char *s,
/*
* If not at end of string, we need to insert a null to terminate
- * the returned token. See notes above.
+ * the returned token. See notes above.
*/
if (*p != '\0')
{
@@ -171,10 +172,10 @@ strtokx(const char *s,
}
/*
- * Otherwise no quoting character. Scan till next whitespace,
- * delimiter or quote. NB: at this point, *start is known not to be
- * '\0', whitespace, delim, or quote, so we will consume at least
- * one character.
+ * Otherwise no quoting character. Scan till next whitespace,
+ * delimiter or quote. NB: at this point, *start is known not to be
+ * '\0', whitespace, delim, or quote, so we will consume at least one
+ * character.
*/
offset = strcspn(start, whitespace);
@@ -197,8 +198,8 @@ strtokx(const char *s,
p = start + offset;
/*
- * If not at end of string, we need to insert a null to terminate
- * the returned token. See notes above.
+ * If not at end of string, we need to insert a null to terminate the
+ * returned token. See notes above.
*/
if (*p != '\0')
{
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index a7e9fbca3d4..5e6abe21077 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.82 2003/07/29 00:03:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.83 2003/08/04 00:43:29 momjian Exp $
*/
/*----------------------------------------------------------------------
@@ -80,7 +80,7 @@ static char *create_command_generator(const char *text, int state);
static char *complete_from_query(const char *text, int state);
static char *complete_from_schema_query(const char *text, int state);
static char *_complete_from_query(int is_schema_query,
- const char *text, int state);
+ const char *text, int state);
static char *complete_from_const(const char *text, int state);
static char *complete_from_list(const char *text, int state);
@@ -411,33 +411,34 @@ initialize_readline(void)
typedef struct
{
char *name;
- int with_schema;
+ int with_schema;
char *query;
} pgsql_thing_t;
pgsql_thing_t words_after_create[] = {
{"AGGREGATE", WITH_SCHEMA, Query_for_list_of_aggregates},
- {"CAST", NO_SCHEMA, NULL}, /* Casts have complex structures for namees, so skip it */
+ {"CAST", NO_SCHEMA, NULL}, /* Casts have complex structures for
+ * namees, so skip it */
{"CONVERSION", NO_SCHEMA, "SELECT conname FROM pg_catalog.pg_conversion WHERE substr(conname,1,%d)='%s'"},
{"DATABASE", NO_SCHEMA, Query_for_list_of_databases},
{"DOMAIN", WITH_SCHEMA, Query_for_list_of_domains},
{"FUNCTION", WITH_SCHEMA, Query_for_list_of_functions},
{"GROUP", NO_SCHEMA, "SELECT groname FROM pg_catalog.pg_group WHERE substr(groname,1,%d)='%s'"},
{"LANGUAGE", NO_SCHEMA, Query_for_list_of_languages},
- {"INDEX", WITH_SCHEMA, Query_for_list_of_indexes},
- {"OPERATOR", NO_SCHEMA, NULL}, /* Querying for this is probably not such
- * a good idea. */
+ {"INDEX", WITH_SCHEMA, Query_for_list_of_indexes},
+ {"OPERATOR", NO_SCHEMA, NULL}, /* Querying for this is probably
+ * not such a good idea. */
{"RULE", NO_SCHEMA, "SELECT rulename FROM pg_catalog.pg_rules WHERE substr(rulename,1,%d)='%s'"},
{"SCHEMA", NO_SCHEMA, Query_for_list_of_schemas},
{"SEQUENCE", WITH_SCHEMA, Query_for_list_of_sequences},
{"TABLE", WITH_SCHEMA, Query_for_list_of_tables},
- {"TEMP", NO_SCHEMA, NULL}, /* for CREATE TEMP TABLE ... */
+ {"TEMP", NO_SCHEMA, NULL}, /* for CREATE TEMP TABLE ... */
{"TRIGGER", NO_SCHEMA, "SELECT tgname FROM pg_catalog.pg_trigger WHERE substr(tgname,1,%d)='%s'"},
- {"TYPE", WITH_SCHEMA, Query_for_list_of_datatypes },
- {"UNIQUE", NO_SCHEMA, NULL}, /* for CREATE UNIQUE INDEX ... */
- {"USER", NO_SCHEMA, Query_for_list_of_users},
+ {"TYPE", WITH_SCHEMA, Query_for_list_of_datatypes},
+ {"UNIQUE", NO_SCHEMA, NULL}, /* for CREATE UNIQUE INDEX ... */
+ {"USER", NO_SCHEMA, Query_for_list_of_users},
{"VIEW", WITH_SCHEMA, Query_for_list_of_views},
- {NULL, NO_SCHEMA, NULL} /* end of list */
+ {NULL, NO_SCHEMA, NULL} /* end of list */
};
@@ -594,9 +595,9 @@ psql_completion(char *text, int start, int end)
};
static char *backslash_commands[] = {
- "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright",
- "\\d", "\\da", "\\dc", "\\dC", "\\dd", "\\dD", "\\df", "\\di",
- "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT",
+ "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright",
+ "\\d", "\\da", "\\dc", "\\dC", "\\dd", "\\dD", "\\df", "\\di",
+ "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT",
"\\dv", "\\du",
"\\e", "\\echo", "\\encoding",
"\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l",
@@ -637,19 +638,22 @@ psql_completion(char *text, int start, int end)
/* CREATE or DROP but not ALTER TABLE sth DROP */
/* complete with something you can create or drop */
- else if (strcasecmp(prev_wd, "CREATE") == 0 ||
+ else if (strcasecmp(prev_wd, "CREATE") == 0 ||
(strcasecmp(prev_wd, "DROP") == 0 &&
- strcasecmp(prev3_wd,"TABLE") != 0 ))
- matches = completion_matches(text, create_command_generator);
+ strcasecmp(prev3_wd, "TABLE") != 0))
+ matches = completion_matches(text, create_command_generator);
/* ALTER */
- /* complete with what you can alter (TABLE, GROUP, USER, ...)
- * unless we're in ALTER TABLE sth ALTER*/
- else if (strcasecmp(prev_wd, "ALTER") == 0 &&
- strcasecmp(prev3_wd, "TABLE") != 0 )
+
+ /*
+ * complete with what you can alter (TABLE, GROUP, USER, ...) unless
+ * we're in ALTER TABLE sth ALTER
+ */
+ else if (strcasecmp(prev_wd, "ALTER") == 0 &&
+ strcasecmp(prev3_wd, "TABLE") != 0)
{
char *list_ALTER[] = {"DATABASE", "GROUP", "SCHEMA", "TABLE",
- "TRIGGER", "USER", NULL};
+ "TRIGGER", "USER", NULL};
COMPLETE_WITH_LIST(list_ALTER);
}
@@ -683,7 +687,7 @@ psql_completion(char *text, int start, int end)
strcasecmp(prev2_wd, "TABLE") == 0)
{
char *list_ALTER2[] = {"ADD", "ALTER", "DROP", "RENAME",
- "OWNER TO", NULL};
+ "OWNER TO", NULL};
COMPLETE_WITH_LIST(list_ALTER2);
}
@@ -695,14 +699,15 @@ psql_completion(char *text, int start, int end)
/* If we have TABLE <sth> DROP, provide COLUMN or CONSTRAINT */
else if (strcasecmp(prev3_wd, "TABLE") == 0 &&
- strcasecmp(prev_wd, "DROP") == 0)
+ strcasecmp(prev_wd, "DROP") == 0)
{
char *list_TABLEDROP[] = {"COLUMN", "CONSTRAINT", NULL};
+
COMPLETE_WITH_LIST(list_TABLEDROP);
}
/* If we have TABLE <sth> DROP COLUMN, provide list of columns */
else if (strcasecmp(prev4_wd, "TABLE") == 0 &&
- strcasecmp(prev2_wd, "DROP") == 0 &&
+ strcasecmp(prev2_wd, "DROP") == 0 &&
strcasecmp(prev_wd, "COLUMN") == 0)
COMPLETE_WITH_ATTR(prev3_wd);
@@ -769,8 +774,8 @@ psql_completion(char *text, int start, int end)
{
char *list_COMMENT[] =
{"DATABASE", "INDEX", "RULE", "SCHEMA", "SEQUENCE", "TABLE",
- "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION", "OPERATOR",
- "TRIGGER", "CONSTRAINT", "DOMAIN", NULL};
+ "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION", "OPERATOR",
+ "TRIGGER", "CONSTRAINT", "DOMAIN", NULL};
COMPLETE_WITH_LIST(list_COMMENT);
}
@@ -849,7 +854,7 @@ psql_completion(char *text, int start, int end)
strcasecmp(prev_wd, "ON") == 0)
{
char *rule_events[] = {"SELECT", "UPDATE", "INSERT",
- "DELETE", NULL};
+ "DELETE", NULL};
COMPLETE_WITH_LIST(rule_events);
}
@@ -966,10 +971,11 @@ psql_completion(char *text, int start, int end)
* sequences, and indexes
*
* keywords DATABASE, FUNCTION, LANGUAGE, SCHEMA added to query result
- * via UNION; seems to work intuitively
- *
- * Note: GRANT/REVOKE can get quite complex; tab-completion as implemented
- * here will only work if the privilege list contains exactly one privilege
+ * via UNION; seems to work intuitively
+ *
+ * Note: GRANT/REVOKE can get quite complex; tab-completion as
+ * implemented here will only work if the privilege list contains
+ * exactly one privilege
*/
else if ((strcasecmp(prev3_wd, "GRANT") == 0 ||
strcasecmp(prev3_wd, "REVOKE") == 0) &&
@@ -977,30 +983,30 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_QUERY("SELECT relname FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n "
" WHERE relkind in ('r','S','v') "
" AND substr(relname,1,%d)='%s' "
- " AND pg_catalog.pg_table_is_visible(c.oid) "
+ " AND pg_catalog.pg_table_is_visible(c.oid) "
" AND relnamespace = n.oid "
- " AND n.nspname NOT IN ('pg_catalog', 'pg_toast') "
- " UNION "
- "SELECT 'DATABASE' AS relname "
- " UNION "
- "SELECT 'FUNCTION' AS relname "
- " UNION "
- "SELECT 'LANGUAGE' AS relname "
- " UNION "
- "SELECT 'SCHEMA' AS relname ");
+ " AND n.nspname NOT IN ('pg_catalog', 'pg_toast') "
+ " UNION "
+ "SELECT 'DATABASE' AS relname "
+ " UNION "
+ "SELECT 'FUNCTION' AS relname "
+ " UNION "
+ "SELECT 'LANGUAGE' AS relname "
+ " UNION "
+ "SELECT 'SCHEMA' AS relname ");
/* Complete "GRANT/REVOKE * ON * " with "TO" */
- else if ((strcasecmp(prev4_wd, "GRANT") == 0 ||
+ else if ((strcasecmp(prev4_wd, "GRANT") == 0 ||
strcasecmp(prev4_wd, "REVOKE") == 0) &&
strcasecmp(prev2_wd, "ON") == 0)
{
- if(strcasecmp(prev_wd, "DATABASE") == 0)
+ if (strcasecmp(prev_wd, "DATABASE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_databases);
- else if(strcasecmp(prev_wd, "FUNCTION") == 0)
+ else if (strcasecmp(prev_wd, "FUNCTION") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions);
- else if(strcasecmp(prev_wd, "LANGUAGE") == 0)
+ else if (strcasecmp(prev_wd, "LANGUAGE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_languages);
- else if(strcasecmp(prev_wd, "SCHEMA") == 0)
+ else if (strcasecmp(prev_wd, "SCHEMA") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
else
COMPLETE_WITH_CONST("TO");
@@ -1008,8 +1014,8 @@ psql_completion(char *text, int start, int end)
/*
* TODO: to complete with user name we need prev5_wd -- wait for a
- * more general solution there
- * same for GRANT <sth> ON { DATABASE | FUNCTION | LANGUAGE | SCHEMA } xxx TO
+ * more general solution there same for GRANT <sth> ON { DATABASE |
+ * FUNCTION | LANGUAGE | SCHEMA } xxx TO
*/
/* INSERT */
@@ -1055,7 +1061,7 @@ psql_completion(char *text, int start, int end)
/* LOCK */
/* Complete LOCK [TABLE] with a list of tables */
else if (strcasecmp(prev_wd, "LOCK") == 0 ||
- (strcasecmp(prev_wd, "TABLE") == 0 &&
+ (strcasecmp(prev_wd, "TABLE") == 0 &&
strcasecmp(prev2_wd, "LOCK") == 0))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables);
@@ -1078,7 +1084,7 @@ psql_completion(char *text, int start, int end)
"ROW SHARE MODE", "ROW EXCLUSIVE MODE",
"SHARE UPDATE EXCLUSIVE MODE", "SHARE MODE",
"SHARE ROW EXCLUSIVE MODE",
- "EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE", NULL};
+ "EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE", NULL};
COMPLETE_WITH_LIST(lock_modes);
}
@@ -1188,9 +1194,9 @@ psql_completion(char *text, int start, int end)
if (strcasecmp(prev2_wd, "DateStyle") == 0)
{
char *my_list[] = {"ISO", "SQL", "Postgres", "German",
- "YMD", "DMY", "MDY",
- "US", "European", "NonEuropean",
- "DEFAULT", NULL};
+ "YMD", "DMY", "MDY",
+ "US", "European", "NonEuropean",
+ "DEFAULT", NULL};
COMPLETE_WITH_LIST(my_list);
}
@@ -1289,7 +1295,7 @@ psql_completion(char *text, int start, int end)
{
char *my_list[] = {"format", "border", "expanded",
"null", "fieldsep", "tuples_only", "title", "tableattr", "pager",
- "recordsep", NULL};
+ "recordsep", NULL};
COMPLETE_WITH_LIST(my_list);
}
@@ -1316,7 +1322,7 @@ psql_completion(char *text, int start, int end)
for (i = 0; words_after_create[i].name; i++)
if (strcasecmp(prev_wd, words_after_create[i].name) == 0)
{
- if(words_after_create[i].with_schema == WITH_SCHEMA)
+ if (words_after_create[i].with_schema == WITH_SCHEMA)
COMPLETE_WITH_SCHEMA_QUERY(words_after_create[i].query);
else
COMPLETE_WITH_QUERY(words_after_create[i].query);
@@ -1397,27 +1403,27 @@ create_command_generator(const char *text, int state)
static char *
complete_from_query(const char *text, int state)
{
- return _complete_from_query(0, text, state);
+ return _complete_from_query(0, text, state);
}
static char *
complete_from_schema_query(const char *text, int state)
{
- return _complete_from_query(1, text, state);
+ return _complete_from_query(1, text, state);
}
/* This creates a list of matching things, according to a query pointed to
by completion_charp.
The query can be one of two kinds:
- - A simple query which must contain a %d and a %s, which will be replaced
+ - A simple query which must contain a %d and a %s, which will be replaced
by the string length of the text and the text itself. The query may also
- have another %s in it, which will be replaced by the value of
+ have another %s in it, which will be replaced by the value of
completion_info_charp.
- or:
+ or:
- A schema query used for completion of both schema and relation names;
these are more complex and must contain in the following order:
- %d %s %d %s %d %s %s %d %s
+ %d %s %d %s %d %s %s %d %s
where %d is the string length of the text and %s the text itself.
See top of file for examples of both kinds of query.
@@ -1445,20 +1451,21 @@ _complete_from_query(int is_schema_query, const char *text, int state)
if (completion_charp == NULL)
return NULL;
- if(is_schema_query)
+ if (is_schema_query)
{
- if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, string_length, text, string_length, text, text, string_length, text,string_length,text) == -1)
- {
- ERROR_QUERY_TOO_LONG;
- return NULL;
- }
+ if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, string_length, text, string_length, text, text, string_length, text, string_length, text) == -1)
+ {
+ ERROR_QUERY_TOO_LONG;
+ return NULL;
+ }
}
- else {
- if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, completion_info_charp) == -1)
- {
- ERROR_QUERY_TOO_LONG;
- return NULL;
- }
+ else
+ {
+ if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, completion_info_charp) == -1)
+ {
+ ERROR_QUERY_TOO_LONG;
+ return NULL;
+ }
}
result = exec_query(query_buffer);
@@ -1488,7 +1495,7 @@ complete_from_list(const char *text, int state)
static int string_length,
list_index,
matches;
- static bool casesensitive;
+ static bool casesensitive;
char *item;
/* need to have a list */
@@ -1520,8 +1527,8 @@ complete_from_list(const char *text, int state)
}
/*
- * No matches found. If we're not case insensitive already, lets switch
- * to being case insensitive and try again
+ * No matches found. If we're not case insensitive already, lets
+ * switch to being case insensitive and try again
*/
if (casesensitive && matches == 0)
{
diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c
index 6b4c42786e7..0f3b74a12c2 100644
--- a/src/bin/psql/variables.c
+++ b/src/bin/psql/variables.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.11 2003/06/28 00:12:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.12 2003/08/04 00:43:29 momjian Exp $
*/
#include "postgres_fe.h"
#include "variables.h"
@@ -67,7 +67,11 @@ GetVariableBool(VariableSpace space, const char *name)
return false; /* not set -> assume "off" */
if (strcmp(val, "off") == 0)
return false;
- /* for backwards compatibility, anything except "off" is taken as "true" */
+
+ /*
+ * for backwards compatibility, anything except "off" is taken as
+ * "true"
+ */
return true;
}
@@ -75,65 +79,69 @@ bool
VariableEquals(VariableSpace space, const char name[], const char value[])
{
const char *var;
+
var = GetVariable(space, name);
return var && (strcmp(var, value) == 0);
}
-int
-GetVariableNum(VariableSpace space,
- const char name[],
- int defaultval,
- int faultval,
- bool allowtrail)
+int
+GetVariableNum(VariableSpace space,
+ const char name[],
+ int defaultval,
+ int faultval,
+ bool allowtrail)
{
const char *var;
- int result;
+ int result;
var = GetVariable(space, name);
if (!var)
- result = defaultval;
+ result = defaultval;
else if (!var[0])
- result = faultval;
+ result = faultval;
else
{
- char *end;
+ char *end;
+
result = strtol(var, &end, 0);
if (!allowtrail && *end)
- result = faultval;
+ result = faultval;
}
return result;
}
int
-SwitchVariable(VariableSpace space, const char name[], const char *opt, ...)
+SwitchVariable(VariableSpace space, const char name[], const char *opt,...)
{
- int result;
+ int result;
const char *var;
var = GetVariable(space, name);
- if (var)
+ if (var)
{
- va_list args;
+ va_list args;
+
va_start(args, opt);
- for (result=1; opt && (strcmp(var, opt) != 0); result++)
- opt = va_arg(args,const char *);
+ for (result = 1; opt && (strcmp(var, opt) != 0); result++)
+ opt = va_arg(args, const char *);
if (!opt)
result = VAR_NOTFOUND;
va_end(args);
}
else
- result = VAR_NOTSET;
+ result = VAR_NOTSET;
return result;
}
-void
+void
PrintVariables(VariableSpace space)
{
- struct _variable *ptr;
- for (ptr = space->next; ptr; ptr = ptr->next)
- printf("%s = '%s'\n", ptr->name, ptr->value);
+ struct _variable *ptr;
+
+ for (ptr = space->next; ptr; ptr = ptr->next)
+ printf("%s = '%s'\n", ptr->name, ptr->value);
}
bool
diff --git a/src/bin/psql/variables.h b/src/bin/psql/variables.h
index ce239975ef3..e69df16a7c3 100644
--- a/src/bin/psql/variables.h
+++ b/src/bin/psql/variables.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.12 2003/06/28 00:12:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.13 2003/08/04 00:43:29 momjian Exp $
*/
/*
@@ -30,33 +30,36 @@ typedef struct _variable *VariableSpace;
VariableSpace CreateVariableSpace(void);
const char *GetVariable(VariableSpace space, const char *name);
-bool GetVariableBool(VariableSpace space, const char *name);
-bool VariableEquals(VariableSpace space, const char name[], const char *opt);
+bool GetVariableBool(VariableSpace space, const char *name);
+bool VariableEquals(VariableSpace space, const char name[], const char *opt);
/* Read numeric variable, or defaultval if it is not set, or faultval if its
- * value is not a valid numeric string. If allowtrail is false, this will
+ * value is not a valid numeric string. If allowtrail is false, this will
* include the case where there are trailing characters after the number.
*/
-int GetVariableNum(VariableSpace space,
- const char name[],
- int defaultval,
- int faultval,
- bool allowtrail);
+int GetVariableNum(VariableSpace space,
+ const char name[],
+ int defaultval,
+ int faultval,
+ bool allowtrail);
-/* Find value of variable <name> among NULL-terminated list of alternative
+/* Find value of variable <name> among NULL-terminated list of alternative
* options. Returns VAR_NOTSET if the variable was not set, VAR_NOTFOUND
* if its value did not occur in the list of options, or the number of the
* matching option. The first option is 1, the second is 2 and so on.
*/
-enum { VAR_NOTSET = 0, VAR_NOTFOUND = -1 };
-int SwitchVariable(VariableSpace space, const char name[],
- const char *opt, ...);
+enum
+{
+VAR_NOTSET = 0, VAR_NOTFOUND = -1};
+int
+SwitchVariable(VariableSpace space, const char name[],
+ const char *opt,...);
-void PrintVariables(VariableSpace space);
+void PrintVariables(VariableSpace space);
-bool SetVariable(VariableSpace space, const char *name, const char *value);
-bool SetVariableBool(VariableSpace space, const char *name);
-bool DeleteVariable(VariableSpace space, const char *name);
+bool SetVariable(VariableSpace space, const char *name, const char *value);
+bool SetVariableBool(VariableSpace space, const char *name);
+bool DeleteVariable(VariableSpace space, const char *name);
#endif /* VARIABLES_H */
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c
index 3f491ac9e74..cd91ad0cb77 100644
--- a/src/bin/scripts/clusterdb.c
+++ b/src/bin/scripts/clusterdb.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/clusterdb.c,v 1.2 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/clusterdb.c,v 1.3 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,12 +15,14 @@
static
-void cluster_one_database(const char *dbname, const char *table,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet);
+void
+cluster_one_database(const char *dbname, const char *table,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet);
static
-void cluster_all_databases(const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet);
+void
+cluster_all_databases(const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet);
static void help(const char *progname);
@@ -104,7 +106,7 @@ main(int argc, char *argv[])
dbname = argv[optind];
break;
default:
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind + 1]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
@@ -124,7 +126,7 @@ main(int argc, char *argv[])
progname);
exit(1);
}
-
+
cluster_all_databases(host, port, username, password,
progname, echo, quiet);
}
@@ -150,9 +152,10 @@ main(int argc, char *argv[])
static
-void cluster_one_database(const char *dbname, const char *table,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+void
+cluster_one_database(const char *dbname, const char *table,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
PQExpBufferData sql;
@@ -194,8 +197,9 @@ void cluster_one_database(const char *dbname, const char *table,
static
-void cluster_all_databases(const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+void
+cluster_all_databases(const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
PGconn *conn;
PGresult *result;
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 2e0612a8e74..dc27a944776 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/common.c,v 1.3 2003/05/27 19:36:54 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/common.c,v 1.4 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,7 +78,7 @@ handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, hel
*/
PGconn *
connectDatabase(const char *dbname, const char *pghost, const char *pgport,
- const char *pguser, bool require_password, const char *progname)
+ const char *pguser, bool require_password, const char *progname)
{
PGconn *conn;
char *password = NULL;
@@ -156,7 +156,7 @@ executeQuery(PGconn *conn, const char *query, const char *progname, bool echo)
/*
- * Check yes/no answer in a localized way. 1=yes, 0=no, -1=neither.
+ * Check yes/no answer in a localized way. 1=yes, 0=no, -1=neither.
*/
/* translator: Make sure the (y/n) prompts match the translation of this. */
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index 8fb33dfd036..8a6431e7245 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -1,7 +1,7 @@
#include "postgres_fe.h"
#ifdef HAVE_GETOPT_H
-# include <getopt.h>
+#include <getopt.h>
#endif
#ifndef HAVE_GETOPT_LONG
@@ -12,26 +12,25 @@
#include "pqexpbuffer.h"
#ifndef HAVE_OPTRESET
-int optreset;
+int optreset;
#endif
const char *get_user_name(const char *progname);
#define _(x) gettext((x))
-void init_nls(void);
+void init_nls(void);
-typedef void (*help_handler)(const char *);
+typedef void (*help_handler) (const char *);
-void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp);
+void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp);
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
-PGconn *
-connectDatabase(const char *dbname, const char *pghost, const char *pgport,
- const char *pguser, bool require_password, const char *progname);
+PGconn *connectDatabase(const char *dbname, const char *pghost, const char *pgport,
+ const char *pguser, bool require_password, const char *progname);
PGresult *
-executeQuery(PGconn *conn, const char *command, const char *progname, bool echo);
+ executeQuery(PGconn *conn, const char *command, const char *progname, bool echo);
int
-check_yesno_response(const char *string);
+ check_yesno_response(const char *string);
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index 7677c2cc7ef..1f7df9104d5 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/createdb.c,v 1.4 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/createdb.c,v 1.5 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
comment = argv[optind + 1];
break;
default:
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind + 2]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c
index 01df2a3275e..3b4a9b060d8 100644
--- a/src/bin/scripts/createlang.c
+++ b/src/bin/scripts/createlang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/createlang.c,v 1.5 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/createlang.c,v 1.6 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -110,9 +110,9 @@ main(int argc, char *argv[])
if (argc - optind > 0)
{
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
if (langname == NULL)
{
fprintf(stderr, _("%s: missing required argument language name\n"), progname);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
@@ -165,37 +165,37 @@ main(int argc, char *argv[])
if (*p >= 'A' && *p <= 'Z')
*p += ('a' - 'A');
- if (strcmp(langname, "plpgsql")==0)
+ if (strcmp(langname, "plpgsql") == 0)
{
trusted = true;
handler = "plpgsql_call_handler";
object = "plpgsql";
}
- else if (strcmp(langname, "pltcl")==0)
+ else if (strcmp(langname, "pltcl") == 0)
{
trusted = true;
handler = "pltcl_call_handler";
object = "pltcl";
}
- else if (strcmp(langname, "pltclu")==0)
+ else if (strcmp(langname, "pltclu") == 0)
{
trusted = false;
handler = "pltclu_call_handler";
object = "pltcl";
}
- else if (strcmp(langname, "plperl")==0)
+ else if (strcmp(langname, "plperl") == 0)
{
trusted = true;
handler = "plperl_call_handler";
object = "plperl";
}
- else if (strcmp(langname, "plperlu")==0)
+ else if (strcmp(langname, "plperlu") == 0)
{
trusted = false;
handler = "plperl_call_handler";
object = "plperl";
}
- else if (strcmp(langname, "plpythonu")==0)
+ else if (strcmp(langname, "plpythonu") == 0)
{
trusted = false;
handler = "plpython_call_handler";
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index 0da4e78318b..f113456fbca 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/createuser.c,v 1.5 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/createuser.c,v 1.6 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -148,11 +148,12 @@ main(int argc, char *argv[])
if (pwprompt)
{
- char *pw1, *pw2;
+ char *pw1,
+ *pw2;
pw1 = simple_prompt("Enter password for new user: ", 100, false);
pw2 = simple_prompt("Enter it again: ", 100, false);
- if (strcmp(pw1, pw2)!=0)
+ if (strcmp(pw1, pw2) != 0)
{
fprintf(stderr, _("Passwords didn't match.\n"));
exit(1);
@@ -242,9 +243,9 @@ help(const char *progname)
printf(_(" -P, --pwprompt assign a password to new user\n"));
printf(_(" -E, --encrypted encrypt stored password\n"));
printf(_(" -N, --unencrypted do no encrypt stored password\n"));
- printf(_(" -i, --sysid=SYSID select sysid for new user\n" ));
+ printf(_(" -i, --sysid=SYSID select sysid for new user\n"));
printf(_(" -e, --echo show the commands being sent to the server\n"));
- printf(_(" -q, --quiet don't write any messages\n"));
+ printf(_(" -q, --quiet don't write any messages\n"));
printf(_(" --help show this help, then exit\n"));
printf(_(" --version output version information, then exit\n"));
printf(_("\nConnection options:\n"));
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c
index a8bcc1a8f71..5e53defd6b3 100644
--- a/src/bin/scripts/dropdb.c
+++ b/src/bin/scripts/dropdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/dropdb.c,v 1.5 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/dropdb.c,v 1.6 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
switch (argc - optind)
{
case 0:
- fprintf(stderr, _("%s: missing required argument database name\n"), progname);
+ fprintf(stderr, _("%s: missing required argument database name\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
case 1:
diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c
index 64d0fb0f429..08a588e3485 100644
--- a/src/bin/scripts/droplang.c
+++ b/src/bin/scripts/droplang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/droplang.c,v 1.4 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/droplang.c,v 1.5 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -104,9 +104,9 @@ main(int argc, char *argv[])
if (argc - optind > 0)
{
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
if (langname == NULL)
{
fprintf(stderr, _("%s: missing required argument language name\n"), progname);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
@@ -159,7 +159,8 @@ main(int argc, char *argv[])
conn = connectDatabase(dbname, host, port, username, password, progname);
/*
- * Make sure the language is installed and find the OID of the handler function
+ * Make sure the language is installed and find the OID of the handler
+ * function
*/
printfPQExpBuffer(&sql, "SELECT lanplcallfoid FROM pg_language WHERE lanname = '%s' AND lanispl;", langname);
result = executeQuery(conn, sql.data, progname, echo);
@@ -178,7 +179,7 @@ main(int argc, char *argv[])
*/
printfPQExpBuffer(&sql, "SELECT count(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '%s';", langname);
result = executeQuery(conn, sql.data, progname, echo);
- if (strcmp(PQgetvalue(result, 0, 0), "0")!=0)
+ if (strcmp(PQgetvalue(result, 0, 0), "0") != 0)
{
PQfinish(conn);
fprintf(stderr,
@@ -193,7 +194,7 @@ main(int argc, char *argv[])
*/
printfPQExpBuffer(&sql, "SELECT count(*) FROM pg_language WHERE lanplcallfoid = %s AND lanname <> '%s';", lanplcallfoid, langname);
result = executeQuery(conn, sql.data, progname, echo);
- if (strcmp(PQgetvalue(result, 0, 0), "0")==0)
+ if (strcmp(PQgetvalue(result, 0, 0), "0") == 0)
keephandler = false;
else
keephandler = true;
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 8018a3f122c..2d17be40d1b 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/scripts/vacuumdb.c,v 1.2 2003/07/23 08:47:41 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/scripts/vacuumdb.c,v 1.3 2003/08/04 00:43:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,13 +15,15 @@
static
-void vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet);
+void
+vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet);
static
-void vacuum_all_databases(bool full, bool verbose, bool analyze,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet);
+void
+vacuum_all_databases(bool full, bool verbose, bool analyze,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet);
static void help(const char *progname);
@@ -120,7 +122,7 @@ main(int argc, char *argv[])
dbname = argv[optind];
break;
default:
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind + 1]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
@@ -140,7 +142,7 @@ main(int argc, char *argv[])
progname);
exit(1);
}
-
+
vacuum_all_databases(full, verbose, analyze,
host, port, username, password,
progname, echo, quiet);
@@ -167,9 +169,10 @@ main(int argc, char *argv[])
static
-void vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+void
+vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
PQExpBufferData sql;
@@ -217,9 +220,10 @@ void vacuum_one_database(const char *dbname, bool full, bool verbose, bool analy
static
-void vacuum_all_databases(bool full, bool verbose, bool analyze,
- const char *host, const char *port, const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+void
+vacuum_all_databases(bool full, bool verbose, bool analyze,
+ const char *host, const char *port, const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
PGconn *conn;
PGresult *result;