summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2001-10-25 05:50:21 +0000
committerBruce Momjian <bruce@momjian.us>2001-10-25 05:50:21 +0000
commitb81844b1738c584d92330a5ccd0fbd8b603d2886 (patch)
tree4fae0d4cd26048177fc5cd1a2dd91abc99ba0f99 /src/bin
parent59da2105d8e6d95345b3b942a2e2aba8cead4838 (diff)
downloadpostgresql-b81844b1738c584d92330a5ccd0fbd8b603d2886.tar.gz
pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/common.c58
-rw-r--r--src/bin/pg_dump/pg_backup.h37
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c176
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h36
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c9
-rw-r--r--src/bin/pg_dump/pg_backup_db.c46
-rw-r--r--src/bin/pg_dump/pg_backup_files.c3
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c24
-rw-r--r--src/bin/pg_dump/pg_dump.c507
-rw-r--r--src/bin/pg_dump/pg_dump.h32
-rw-r--r--src/bin/pg_dump/pg_restore.c144
-rw-r--r--src/bin/pg_encoding/pg_encoding.c30
-rw-r--r--src/bin/pg_passwd/pg_passwd.c2
-rw-r--r--src/bin/pgtclsh/pgtclAppInit.c1
-rw-r--r--src/bin/pgtclsh/pgtkAppInit.c1
-rw-r--r--src/bin/psql/command.c56
-rw-r--r--src/bin/psql/command.h15
-rw-r--r--src/bin/psql/common.c17
-rw-r--r--src/bin/psql/common.h21
-rw-r--r--src/bin/psql/copy.h3
-rw-r--r--src/bin/psql/describe.c130
-rw-r--r--src/bin/psql/describe.h5
-rw-r--r--src/bin/psql/help.c16
-rw-r--r--src/bin/psql/help.h3
-rw-r--r--src/bin/psql/input.c10
-rw-r--r--src/bin/psql/input.h3
-rw-r--r--src/bin/psql/large_obj.c10
-rw-r--r--src/bin/psql/large_obj.h3
-rw-r--r--src/bin/psql/mainloop.c20
-rw-r--r--src/bin/psql/mainloop.h4
-rw-r--r--src/bin/psql/mbprint.c308
-rw-r--r--src/bin/psql/mbprint.h12
-rw-r--r--src/bin/psql/print.c127
-rw-r--r--src/bin/psql/print.h18
-rw-r--r--src/bin/psql/prompt.c8
-rw-r--r--src/bin/psql/prompt.h17
-rw-r--r--src/bin/psql/settings.h3
-rw-r--r--src/bin/psql/startup.c29
-rw-r--r--src/bin/psql/stringutils.h3
-rw-r--r--src/bin/psql/tab-complete.c28
-rw-r--r--src/bin/psql/tab-complete.h3
-rw-r--r--src/bin/psql/variables.h3
42 files changed, 1003 insertions, 978 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index b04b3d8eb7..d9d358892c 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.59 2001/10/22 19:31:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.60 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -166,13 +166,13 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
selfInd = findTableByOid(tblinfo, numTables, oid);
if (selfInd >= 0)
write_msg(NULL, "failed sanity check, parent oid %s of table %s (oid %s) not found\n",
- inhinfo[i].inhparent,
- tblinfo[selfInd].relname,
- oid);
+ inhinfo[i].inhparent,
+ tblinfo[selfInd].relname,
+ oid);
else
write_msg(NULL, "failed sanity check, parent oid %s of table (oid %s) not found\n",
- inhinfo[i].inhparent,
- oid);
+ inhinfo[i].inhparent,
+ oid);
exit_nicely();
}
@@ -267,7 +267,7 @@ strInArray(const char *pattern, char **arr, int arr_size)
*
*/
-TableInfo *
+TableInfo *
dumpSchema(Archive *fout,
int *numTablesPtr,
const char *tablename,
@@ -411,12 +411,12 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
int parentInd;
int inhAttrInd;
int (*parentIndexes)[];
- bool foundAttr; /* Attr was found in a parent */
+ bool foundAttr; /* Attr was found in a parent */
bool foundNotNull; /* Attr was NOT NULL in a parent */
bool defaultsMatch; /* All non-empty defaults match */
bool defaultsFound; /* Found a default in a parent */
- char *attrDef;
- char *inhDef;
+ char *attrDef;
+ char *inhDef;
/*
* we go backwards because the tables in tblinfo are in OID order,
@@ -438,15 +438,13 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
&parentIndexes);
/*
- * For each attr, check the parent info: if no parent has
- * an attr with the same name, then it's not inherited. If there
- * *is* an attr with the same name, then only dump it if:
+ * For each attr, check the parent info: if no parent has an attr
+ * with the same name, then it's not inherited. If there *is* an
+ * attr with the same name, then only dump it if:
*
- * - it is NOT NULL and zero parents are NOT NULL
- * OR
- * - it has a default value AND the default value
- * does not match all parent default values, or
- * no parents specify a default.
+ * - it is NOT NULL and zero parents are NOT NULL OR - it has a
+ * default value AND the default value does not match all parent
+ * default values, or no parents specify a default.
*
* See discussion on -hackers around 2-Apr-2001.
*/
@@ -479,7 +477,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
{
foundAttr = true;
foundNotNull |= tblinfo[parentInd].notnull[inhAttrInd];
- if (attrDef != NULL) /* It we have a default, check parent */
+ if (attrDef != NULL) /* It we have a default,
+ * check parent */
{
inhDef = tblinfo[parentInd].adef_expr[inhAttrInd];
@@ -492,25 +491,31 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
};
};
- /*
- * Based on the scan of the parents, decide if we
- * can rely on the inherited attr
+ /*
+ * Based on the scan of the parents, decide if we can rely on
+ * the inherited attr
*/
- if (foundAttr) /* Attr was inherited */
+ if (foundAttr) /* Attr was inherited */
{
/* Set inherited flag by default */
tblinfo[i].inhAttrs[j] = 1;
tblinfo[i].inhAttrDef[j] = 1;
tblinfo[i].inhNotNull[j] = 1;
- /* Clear it if attr had a default, but parents did not, or mismatch */
- if ( (attrDef != NULL) && (!defaultsFound || !defaultsMatch) )
+ /*
+ * Clear it if attr had a default, but parents did not, or
+ * mismatch
+ */
+ if ((attrDef != NULL) && (!defaultsFound || !defaultsMatch))
{
tblinfo[i].inhAttrs[j] = 0;
tblinfo[i].inhAttrDef[j] = 0;
}
- /* Clear it if NOT NULL and none of the parents were NOT NULL */
+ /*
+ * Clear it if NOT NULL and none of the parents were NOT
+ * NULL
+ */
if (tblinfo[i].notnull[j] && !foundNotNull)
{
tblinfo[i].inhAttrs[j] = 0;
@@ -631,7 +636,6 @@ fmtId(const char *rawid, bool force_quotes)
appendPQExpBufferChar(id_return, '\"');
for (cp = rawid; *cp; cp++)
{
-
/*
* Did we find a double-quote in the string? Then make this a
* double double-quote per SQL99. Before, we put in a
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index b06ff43973..3c359ff99f 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.15 2001/10/03 21:58:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.16 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -56,11 +56,11 @@
typedef enum _archiveFormat
{
- archUnknown = 0,
- archCustom = 1,
- archFiles = 2,
- archTar = 3,
- archNull = 4
+ archUnknown = 0,
+ archCustom = 1,
+ archFiles = 2,
+ archTar = 3,
+ archNull = 4
} ArchiveFormat;
/*
@@ -69,10 +69,10 @@ typedef enum _archiveFormat
*/
typedef struct _Archive
{
- int verbose;
- int remoteVersion;
- int minRemoteVersion;
- int maxRemoteVersion;
+ int verbose;
+ int remoteVersion;
+ int minRemoteVersion;
+ int maxRemoteVersion;
/* The rest is private */
} Archive;
@@ -85,7 +85,8 @@ typedef struct _restoreOptions
* original object owner */
int noReconnect; /* Don't reconnect to database under any
* cirsumstances */
- int use_setsessauth; /* use SET SESSSION AUTHORIZATION instead of \connect */
+ int use_setsessauth;/* use SET SESSSION AUTHORIZATION instead
+ * of \connect */
char *superuser; /* Username to use as superuser */
int dataOnly;
int dropSchema;
@@ -123,18 +124,20 @@ typedef struct _restoreOptions
int limitToList;
int compression;
- int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */
+ int suppressDumpWarnings; /* Suppress output of WARNING
+ * entries to stderr */
} RestoreOptions;
/*
* Main archiver interface.
*/
-extern void exit_horribly(Archive *AH, const char *modulename, const char *fmt, ...)
-__attribute__((format(printf,3,4)));
+extern void
+exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
+__attribute__((format(printf, 3, 4)));
extern char *
-simple_prompt(const char *prompt, int maxlen, bool echo);
+ simple_prompt(const char *prompt, int maxlen, bool echo);
/* Lets the archibe know we have a DB connection to shutdown if it dies */
@@ -189,8 +192,8 @@ extern void SortTocFromFile(Archive *AH, RestoreOptions *ropt);
/* Convenience functions used only when writing DATA */
extern int archputs(const char *s, Archive *AH);
extern int archputc(const char c, Archive *AH);
-extern int archprintf(Archive *AH, const char *fmt, ...)
+extern int
+archprintf(Archive *AH, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
-
#endif
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 55bbddec9b..75c5ef0075 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.34 2001/10/23 21:26:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.35 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -42,20 +42,20 @@
* - Only disable triggers in DataOnly (or implied data-only) restores.
*
* Modifications - 31-Mar-2001 - pjw@rhyme.com.au
- *
+ *
* - Rudimentary support for dependencies in archives. Current implementation
* uses dependencies to modify the OID used in sorting TOC entries.
* This will NOT handle multi-level dependencies, but will manage simple
* relationships like UDTs & their functions.
*
- * - Treat OIDs with more respect (avoid using ints, use macros for
+ * - Treat OIDs with more respect (avoid using ints, use macros for
* conversion & comparison).
*
* Modifications - 10-May-2001 - pjw@rhyme.com.au
* - Treat SEQUENCE SET TOC entries as data entries rather than schema
* entries.
* - Make allowance for data entries that did not have a data dumper
- * routine (eg. SEQUENCE SET)
+ * routine (eg. SEQUENCE SET)
*
*-------------------------------------------------------------------------
*/
@@ -88,7 +88,7 @@ static void _moveAfter(ArchiveHandle *AH, TocEntry *pos, TocEntry *te);
static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te);
static int _discoverArchiveFormat(ArchiveHandle *AH);
static void _fixupOidInfo(TocEntry *te);
-static Oid _findMaxOID(const char *((*deps)[]));
+static Oid _findMaxOID(const char *((*deps)[]));
const char *progname;
static char *modulename = gettext_noop("archiver");
@@ -110,7 +110,7 @@ static int _restoringToDB(ArchiveHandle *AH);
/* Create a new archive */
/* Public */
-Archive *
+Archive *
CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
const int compression)
@@ -122,7 +122,7 @@ CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
/* Open an existing archive */
/* Public */
-Archive *
+Archive *
OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
{
ArchiveHandle *AH = _allocAH(FileSpec, fmt, 0, archModeRead);
@@ -167,8 +167,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
*
* NB: create+dropSchema is useless because if you're creating the DB,
* there's no need to drop individual items in it. Moreover, if we
- * tried to do that then we'd issue the drops in the database initially
- * connected to, not the one we will create, which is very bad...
+ * tried to do that then we'd issue the drops in the database
+ * initially connected to, not the one we will create, which is very
+ * bad...
*/
if (ropt->create && ropt->noReconnect)
die_horribly(AH, modulename, "-C and -R are incompatible options\n");
@@ -238,7 +239,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
write_msg(modulename, "WARNING:\n"
" Data restoration may fail because existing triggers cannot be disabled\n"
" (no superuser user name specified). This is only a problem when\n"
- " restoring into a database with already existing triggers.\n");
+ " restoring into a database with already existing triggers.\n");
/*
* Setup the output file if necessary.
@@ -283,11 +284,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
- if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
+ if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->defn);
else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt);
- }
+ }
defnDumped = false;
@@ -306,18 +307,20 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
ahlog(AH, 1, "connecting to new database %s as user %s\n", te->name, te->owner);
_reconnectAsUser(AH, te->name, te->owner);
}
- }
+ }
/*
* If we have a data component, then process it
*/
- if ( (reqs & 2) != 0 )
+ if ((reqs & 2) != 0)
{
- /* hadDumper will be set if there is genuine data component for this
- * node. Otherwise, we need to check the defn field for statements
- * that need to be executed in data-only restores.
+ /*
+ * hadDumper will be set if there is genuine data component
+ * for this node. Otherwise, we need to check the defn field
+ * for statements that need to be executed in data-only
+ * restores.
*/
- if (te->hadDumper)
+ if (te->hadDumper)
{
/*
* If we can output the data, then restore it.
@@ -332,16 +335,17 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_printTocEntry(AH, te, ropt, true);
/*
- * Maybe we can't do BLOBS, so check if this node is for BLOBS
+ * Maybe we can't do BLOBS, so check if this node is
+ * for BLOBS
*/
if ((strcmp(te->desc, "BLOBS") == 0) && !_canRestoreBlobs(AH))
{
ahprintf(AH, "--\n-- SKIPPED \n--\n\n");
/*
- * This is a bit nasty - we assume, for the moment, that
- * if a custom output is used, then we don't want
- * warnings.
+ * This is a bit nasty - we assume, for the
+ * moment, that if a custom output is used, then
+ * we don't want warnings.
*/
if (!AH->CustomOutPtr)
write_msg(modulename, "WARNING: skipping large object restoration\n");
@@ -353,21 +357,23 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_disableTriggersIfNecessary(AH, te, ropt);
/*
- * Reconnect if necessary (_disableTriggers may have
- * reconnected)
+ * Reconnect if necessary (_disableTriggers may
+ * have reconnected)
*/
_reconnectAsOwner(AH, NULL, te);
ahlog(AH, 1, "restoring data for table %s\n", te->name);
/*
- * If we have a copy statement, use it. As of V1.3, these
- * are separate to allow easy import from withing a
- * database connection. Pre 1.3 archives can not use DB
- * connections and are sent to output only.
+ * If we have a copy statement, use it. As of
+ * V1.3, these are separate to allow easy import
+ * from withing a database connection. Pre 1.3
+ * archives can not use DB connections and are
+ * sent to output only.
*
- * For V1.3+, the table data MUST have a copy statement so
- * that we can go into appropriate mode with libpq.
+ * For V1.3+, the table data MUST have a copy
+ * statement so that we can go into appropriate
+ * mode with libpq.
*/
if (te->copyStmt && strlen(te->copyStmt) > 0)
ahprintf(AH, te->copyStmt);
@@ -377,8 +383,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_enableTriggersIfNecessary(AH, te, ropt);
}
}
- } else if (!defnDumped) {
- /* If we haven't already dumped the defn part, do so now */
+ }
+ else if (!defnDumped)
+ {
+ /* If we haven't already dumped the defn part, do so now */
ahlog(AH, 1, "executing %s %s\n", te->desc, te->name);
_printTocEntry(AH, te, ropt, false);
}
@@ -493,7 +501,6 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop
{
if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH))
{
-
/*
* If we're not allowing changes for ownership, then remember
* the user so we can change it back here. Otherwise, let
@@ -552,7 +559,6 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
{
if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH))
{
-
/*
* If we're not allowing changes for ownership, then remember
* the user so we can change it back here. Otherwise, let
@@ -1065,7 +1071,6 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
#ifdef HAVE_LIBZ
char fmode[10];
-
#endif
int fn = 0;
@@ -1233,7 +1238,6 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
}
else
{
-
/*
* If we're doing a restore, and it's direct to DB, and we're
* connected then send it to the DB.
@@ -1262,7 +1266,7 @@ _write_msg(const char *modulename, const char *fmt, va_list ap)
}
void
-write_msg(const char *modulename, const char *fmt, ...)
+write_msg(const char *modulename, const char *fmt,...)
{
va_list ap;
@@ -1469,7 +1473,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
int wantClose = 0;
#if 0
- write_msg(modulename, "attempting to ascertain archive format\n");
+ write_msg(modulename, "attempting to ascertain archive format\n");
#endif
if (AH->lookahead)
@@ -1534,7 +1538,6 @@ _discoverArchiveFormat(ArchiveHandle *AH)
}
else
{
-
/*
* *Maybe* we have a tar archive format file... So, read first 512
* byte header...
@@ -1554,7 +1557,6 @@ _discoverArchiveFormat(ArchiveHandle *AH)
/* If we can't seek, then mark the header as read */
if (fseek(fh, 0, SEEK_SET) != 0)
{
-
/*
* NOTE: Formats that use the looahead buffer can unset this in
* their Init routine.
@@ -1588,7 +1590,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
ArchiveHandle *AH;
#if 0
- write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt);
+ write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt);
#endif
AH = (ArchiveHandle *) calloc(1, sizeof(ArchiveHandle));
@@ -1638,7 +1640,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
AH->OF = stdout;
#if 0
- write_msg(modulename, "archive format is %d\n", fmt);
+ write_msg(modulename, "archive format is %d\n", fmt);
#endif
if (fmt == archUnknown)
@@ -1747,12 +1749,10 @@ WriteToc(ArchiveHandle *AH)
if (te->depOid != NULL)
{
i = 0;
- while( (dep = (*te->depOid)[i++]) != NULL)
- {
+ while ((dep = (*te->depOid)[i++]) != NULL)
WriteStr(AH, dep);
- }
}
- WriteStr(AH, NULL); /* Terminate List */
+ WriteStr(AH, NULL); /* Terminate List */
if (AH->WriteExtraTocPtr)
(*AH->WriteExtraTocPtr) (AH, te);
@@ -1764,7 +1764,7 @@ void
ReadToc(ArchiveHandle *AH)
{
int i;
- char *((*deps)[]);
+ char *((*deps)[]);
int depIdx;
int depSize;
@@ -1800,14 +1800,14 @@ ReadToc(ArchiveHandle *AH)
if (AH->version >= K_VERS_1_5)
{
depSize = 100;
- deps = malloc(sizeof(char*) * depSize);
+ deps = malloc(sizeof(char *) * depSize);
depIdx = 0;
do
{
if (depIdx > depSize)
{
depSize *= 2;
- deps = realloc(deps, sizeof(char*) * depSize);
+ deps = realloc(deps, sizeof(char *) * depSize);
}
(*deps)[depIdx] = ReadStr(AH);
#if 0
@@ -1815,12 +1815,12 @@ ReadToc(ArchiveHandle *AH)
write_msg(modulename, "read dependency for %s -> %s\n",
te->name, (*deps)[depIdx]);
#endif
- } while ( (*deps)[depIdx++] != NULL);
+ } while ((*deps)[depIdx++] != NULL);
- if (depIdx > 1) /* We have a non-null entry */
- te->depOid = realloc(deps, sizeof(char*) * depIdx); /* trim it */
+ if (depIdx > 1) /* We have a non-null entry */
+ te->depOid = realloc(deps, sizeof(char *) * depIdx); /* trim it */
else
- te->depOid = NULL; /* no deps */
+ te->depOid = NULL; /* no deps */
}
else
te->depOid = NULL;
@@ -1918,7 +1918,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
* user, this won't do anything.
*
* If we're currently restoring right into a database, this will
- * actuall establish a connection. Otherwise it puts a \connect into
+ * actuall establish a connection. Otherwise it puts a \connect into
* the script output.
*/
static void
@@ -1928,7 +1928,10 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user)
|| (strcmp(AH->currUser, user) == 0 && !dbname))
return; /* no need to do anything */
- /* Use SET SESSION AUTHORIZATION if allowed and no database change needed */
+ /*
+ * Use SET SESSION AUTHORIZATION if allowed and no database change
+ * needed
+ */
if (!dbname && AH->ropt->use_setsessauth)
{
if (RestoringToDB(AH))
@@ -1961,8 +1964,10 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user)
dbname ? dbname : "-",
user ? user : "-");
- /* NOTE: currUser keeps track of what the imaginary session user
- in our script is */
+ /*
+ * NOTE: currUser keeps track of what the imaginary session user in
+ * our script is
+ */
if (AH->currUser)
free(AH->currUser);
@@ -1988,14 +1993,12 @@ _reconnectAsOwner(ArchiveHandle *AH, const char *dbname, TocEntry *te)
static int
_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData)
{
- char *pfx;
+ char *pfx;
if (isData)
- {
pfx = "Data for ";
- } else {
+ else
pfx = "";
- }
ahprintf(AH, "--\n-- %sTOC Entry ID %d (OID %s)\n--\n-- Name: %s Type: %s Owner: %s\n",
pfx, te->id, te->oid, te->name, te->desc, te->owner);
@@ -2136,7 +2139,6 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
te = AH->toc;
for (i = 0; i <= AH->tocCount + 1; i++)
{
-
/*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
* te->oidVal);
@@ -2159,7 +2161,6 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
te = AH->toc;
for (i = 0; i <= AH->tocCount + 1; i++)
{
-
/*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
* te->oidVal);
@@ -2187,39 +2188,48 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
/* If we have a deterministic answer, return it. */
if (cmpval != 0)
- return cmpval;
+ return cmpval;
/* More comparisons required */
- if ( oideq(id1, te1->maxDepOidVal) ) /* maxOid1 came from deps */
+ if (oideq(id1, te1->maxDepOidVal)) /* maxOid1 came from deps */
{
- if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 also came from deps */
+ if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 also came from
+ * deps */
{
- cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base OIDs */
+ cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base
+ * OIDs */
}
- else /* MaxOid2 was entry OID */
+ else
+/* MaxOid2 was entry OID */
{
- return 1; /* entry1 > entry2 */
+ return 1; /* entry1 > entry2 */
};
- }
- else /* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */
+ }
+ else
+/* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */
{
- if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 came from deps */
+ if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 came from deps */
{
- return -1; /* entry1 < entry2 */
+ return -1; /* entry1 < entry2 */
}
- else /* MaxOid2 was entry OID - deps don't matter */
+ else
+/* MaxOid2 was entry OID - deps don't matter */
{
cmpval = 0;
};
};
- /* If we get here, then we've done another comparison
- * Once again, a 0 result means we require even more
+ /*
+ * If we get here, then we've done another comparison Once again, a 0
+ * result means we require even more
*/
if (cmpval != 0)
return cmpval;
- /* Entire OID details match, so use ID number (ie. original pg_dump order) */
+ /*
+ * Entire OID details match, so use ID number (ie. original pg_dump
+ * order)
+ */
return _tocSortCompareByIDNum(te1, te2);
}
@@ -2245,35 +2255,35 @@ _tocSortCompareByIDNum(const void *p1, const void *p2)
* Assuming Oid and depOid are set, work out the various
* Oid values used in sorting.
*/
-static void
+static void
_fixupOidInfo(TocEntry *te)
{
te->oidVal = atooid(te->oid);
te->maxDepOidVal = _findMaxOID(te->depOid);
/* For the purpose of sorting, find the max OID. */
- if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0)
+ if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0)
te->maxOidVal = te->oidVal;
else
te->maxOidVal = te->maxDepOidVal;
}
-/*
- * Find the max OID value for a given list of string Oid values
+/*
+ * Find the max OID value for a given list of string Oid values
*/
static Oid
_findMaxOID(const char *((*deps)[]))
{
const char *dep;
int i;
- Oid maxOid = (Oid)0;
+ Oid maxOid = (Oid) 0;
Oid currOid;
if (!deps)
return maxOid;
i = 0;
- while( (dep = (*deps)[i++]) != NULL)
+ while ((dep = (*deps)[i++]) != NULL)
{
currOid = atooid(dep);
if (oidcmp(maxOid, currOid) < 0)
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index fee94d83b0..1d099452ee 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.37 2001/08/22 20:23:23 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.38 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* - Initial version.
@@ -61,7 +61,6 @@ typedef struct _z_stream
int avail_out;
} z_stream;
typedef z_stream *z_streamp;
-
#endif
#include "pg_backup.h"
@@ -69,7 +68,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 5
-#define K_VERS_REV 6
+#define K_VERS_REV 6
/* Data block types */
#define BLK_DATA 1
@@ -119,8 +118,8 @@ typedef int (*TocSortCompareFn) (const void *te1, const void *te2);
typedef enum _archiveMode
{
- archModeWrite,
- archModeRead
+ archModeWrite,
+ archModeRead
} ArchiveMode;
typedef struct _outputContext
@@ -131,10 +130,10 @@ typedef struct _outputContext
typedef enum
{
- SQL_SCAN = 0,
- SQL_IN_SQL_COMMENT,
- SQL_IN_EXT_COMMENT,
- SQL_IN_QUOTE
+ SQL_SCAN = 0,
+ SQL_IN_SQL_COMMENT,
+ SQL_IN_EXT_COMMENT,
+ SQL_IN_QUOTE
} sqlparseState;
typedef struct
@@ -189,8 +188,8 @@ typedef struct _archiveHandle
ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */
ClosePtr ClosePtr; /* Close the archive */
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data
- * associated with
- * the current archive format */
+ * associated with the current
+ * archive format */
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with
* archie format */
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
@@ -222,7 +221,7 @@ typedef struct _archiveHandle
int loFd; /* BLOB fd */
int writingBlob; /* Flag */
- int createdBlobXref;/* Flag */
+ int createdBlobXref; /* Flag */
int blobCount; /* # of blobs restored */
int lastID; /* Last internal ID for a TOC entry */
@@ -256,11 +255,11 @@ typedef struct _tocEntry
char *dropStmt;
char *copyStmt;
char *owner;
- char *oid; /* Oid of source of entry */
+ char *oid; /* Oid of source of entry */
Oid oidVal; /* Value of above */
const char *((*depOid)[]);
Oid maxDepOidVal; /* Value of largest OID in deps */
- Oid maxOidVal; /* Max of entry OID and max dep OID */
+ Oid maxOidVal; /* Max of entry OID and max dep OID */
int printed; /* Indicates if entry defn has been dumped */
DataDumperPtr dataDumper; /* Routine to dump data for object */
@@ -273,8 +272,8 @@ typedef struct _tocEntry
/* Used everywhere */
extern const char *progname;
-extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, ...) __attribute__((format(printf,3,4)));
-extern void write_msg(const char *modulename, const char *fmt, ...) __attribute__((format(printf,2,3)));
+extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
+extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(printf, 2, 3)));
extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH);
@@ -316,8 +315,7 @@ extern char *ConnectedUser(ArchiveHandle *AH);
extern int ConnectedUserIsSuperuser(ArchiveHandle *AH);
int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH);
-int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf,2,3)));
-
-void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf,3,4)));
+int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf, 2, 3)));
+void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf, 3, 4)));
#endif
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 76d4a78ff7..c6d9ff5123 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.15 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.16 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -447,7 +447,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
if ((TocIDRequired(AH, id, ropt) & 2) != 0)
die_horribly(AH, modulename,
"Dumping a specific TOC data block out of order is not supported"
- " without id on this input stream (fseek required)\n");
+ " without id on this input stream (fseek required)\n");
switch (blkType)
{
@@ -533,7 +533,6 @@ _PrintData(ArchiveHandle *AH)
#ifdef HAVE_LIBZ
int res;
char *out = ctx->zlibOut;
-
#endif
#ifdef HAVE_LIBZ
@@ -549,7 +548,6 @@ _PrintData(ArchiveHandle *AH)
if (inflateInit(zp) != Z_OK)
die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg);
}
-
#endif
blkLen = ReadInt(AH);
@@ -910,7 +908,6 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te)
#else
AH->compression = 0;
-
#endif
/* Just be paranoid - maybe End is called after Start, with no Write */
@@ -944,7 +941,6 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
|| (zp->avail_in != 0)
)
{
-
/*
* Extra paranoia: avoid zero-length chunks since a zero
* length chunk is the EOF marker. This should never happen
@@ -952,7 +948,6 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
*/
if (zp->avail_out < zlibOutSize)
{
-
/*
* printf("Wrote %d byte deflated chunk\n", zlibOutSize -
* zp->avail_out);
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 0749c24bb5..aeea9d02c8 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.28 2001/10/18 21:57:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.29 2001/10/25 05:49:52 momjian Exp $
*
* NOTES
*
@@ -64,7 +64,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
{
int length;
char *destination;
- FILE *termin, *termout;
+ FILE *termin,
+ *termout;
+
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
@@ -77,8 +79,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
prompt_state = true; /* disable SIGINT */
/*
- * Do not try to collapse these into one "w+" mode file.
- * Doesn't work on some platforms (eg, HPUX 10.20).
+ * Do not try to collapse these into one "w+" mode file. Doesn't work
+ * on some platforms (eg, HPUX 10.20).
*/
termin = fopen("/dev/tty", "r");
termout = fopen("/dev/tty", "w");
@@ -101,7 +103,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
tcsetattr(fileno(termin), TCSAFLUSH, &t);
}
#endif
-
+
if (prompt)
{
fputs(gettext(prompt), termout);
@@ -152,17 +154,17 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
static int
-_parse_version(ArchiveHandle *AH, const char* versionString)
+_parse_version(ArchiveHandle *AH, const char *versionString)
{
int cnt;
- int vmaj, vmin, vrev;
+ int vmaj,
+ vmin,
+ vrev;
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
if (cnt < 2)
- {
die_horribly(AH, modulename, "unable to parse version string \"%s\"\n", versionString);
- }
if (cnt == 2)
vrev = 0;
@@ -195,8 +197,8 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
AH->public.remoteVersion = remoteversion;
- if (myversion != remoteversion
- && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) )
+ if (myversion != remoteversion
+ && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion))
{
write_msg(NULL, "server version: %s; %s version: %s\n",
remoteversion_str, progname, PG_VERSION);
@@ -261,7 +263,7 @@ ConnectedUser(ArchiveHandle *AH)
/*
* Reconnect to the server. If dbname is not NULL, use that database,
* else the one associated with the archive handle. If username is
- * not NULL, use that user name, else the one from the handle. If
+ * not NULL, use that user name, else the one from the handle. If
* both the database and the user and match the existing connection
* already, nothing will be done.
*
@@ -348,7 +350,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
noPwd = (strcmp(PQerrorMessage(newConn),
"fe_sendauth: no password supplied\n") == 0);
badPwd = (strncmp(PQerrorMessage(newConn),
- "Password authentication failed for user", 39) == 0);
+ "Password authentication failed for user", 39) == 0);
if (noPwd || badPwd)
{
@@ -432,8 +434,8 @@ ConnectDatabase(Archive *AHX,
AH->requirePassword = false;
/*
- * Start the connection. Loop until we have a password if
- * requested by backend.
+ * Start the connection. Loop until we have a password if requested
+ * by backend.
*/
do
{
@@ -480,7 +482,8 @@ ConnectDatabase(Archive *AHX,
}
-static void notice_processor(void *arg, const char *message)
+static void
+notice_processor(void *arg, const char *message)
{
write_msg(NULL, "%s", message);
}
@@ -635,7 +638,6 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
/* We may have finished Copy In, and have a non-empty buffer */
if (!AH->pgCopyIn)
{
-
/*
* The following is a mini state machine to assess then of of an
* SQL statement. It really only needs to parse good SQL, or at
@@ -754,7 +756,7 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
appendPQExpBuffer(tblQry, "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t "
" WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid "
- " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename);
+ " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename);
res = PQexec(AH->blobConnection, tblQry->data);
if (!res)
@@ -791,13 +793,13 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
uRes = PQexec(AH->blobConnection, tblQry->data);
if (!uRes)
die_horribly(AH, modulename,
- "could not update column \"%s\" of table \"%s\": %s",
- attr, tablename, PQerrorMessage(AH->blobConnection));
+ "could not update column \"%s\" of table \"%s\": %s",
+ attr, tablename, PQerrorMessage(AH->blobConnection));
if (PQresultStatus(uRes) != PGRES_COMMAND_OK)
die_horribly(AH, modulename,
- "error while updating column \"%s\" of table \"%s\": %s",
- attr, tablename, PQerrorMessage(AH->blobConnection));
+ "error while updating column \"%s\" of table \"%s\": %s",
+ attr, tablename, PQerrorMessage(AH->blobConnection));
PQclear(uRes);
}
diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c
index db54ca0fd9..dfc1fdd2a1 100644
--- a/src/bin/pg_dump/pg_backup_files.c
+++ b/src/bin/pg_dump/pg_backup_files.c
@@ -20,7 +20,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.13 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.14 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -550,4 +550,3 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
die_horribly(AH, modulename, "could not close large object TOC file: %s\n", strerror(errno));
}
-
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 35d8e9b344..4f99c96781 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.18 2001/09/21 21:58:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.19 2001/10/25 05:49:52 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -66,7 +66,6 @@ typedef FILE ThingFile;
#else
typedef FILE ThingFile;
-
#endif
typedef struct
@@ -110,7 +109,6 @@ static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
#ifdef __NOT_USED__
static char *tarGets(char *buf, int len, TAR_MEMBER *th);
-
#endif
static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...);
@@ -173,7 +171,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
if (ctx->tarFH == NULL)
die_horribly(NULL, modulename,
- "could not open TOC file for output: %s\n", strerror(errno));
+ "could not open TOC file for output: %s\n", strerror(errno));
ctx->tarFHpos = 0;
@@ -323,7 +321,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
#ifdef HAVE_LIBZ
char fmode[10];
-
#endif
if (mode == 'r')
@@ -350,7 +347,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
#else
tm->nFH = ctx->tarFH;
-
#endif
}
@@ -379,7 +375,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
#else
tm->nFH = tm->tmpFH;
-
#endif
tm->AH = AH;
@@ -396,7 +391,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
static void
tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
{
-
/*
* Close the GZ file since we dup'd. This will flush the buffers.
*/
@@ -458,7 +452,6 @@ tarGets(char *buf, int len, TAR_MEMBER *th)
return s;
}
-
#endif
/*
@@ -706,12 +699,12 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
StartRestoreBlobs(AH);
- th = tarOpen(AH, NULL, 'r');/* Open next file */
+ th = tarOpen(AH, NULL, 'r'); /* Open next file */
while (th != NULL)
{
ctx->FH = th;
- oid = (Oid)strtoul(&th->targetFile[5], NULL, 10);
+ oid = (Oid) strtoul(&th->targetFile[5], NULL, 10);
if (strncmp(th->targetFile, "blob_", 5) == 0 && oid != 0)
{
@@ -796,7 +789,6 @@ _CloseArchive(ArchiveHandle *AH)
if (AH->mode == archModeWrite)
{
-
/*
* Write the Header & TOC to the archive FIRST
*/
@@ -854,7 +846,7 @@ _CloseArchive(ArchiveHandle *AH)
{
if (fputc(0, ctx->tarFH) == EOF)
die_horribly(AH, modulename,
- "could not write null block at end of tar archive\n");
+ "could not write null block at end of tar archive\n");
}
}
@@ -1028,7 +1020,7 @@ static void
_tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
{
lclContext *ctx = (lclContext *) AH->formatData;
- FILE *tmp = th->tmpFH;/* Grab it for convenience */
+ FILE *tmp = th->tmpFH; /* Grab it for convenience */
char buf[32768];
int cnt;
int len = 0;
@@ -1120,7 +1112,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
id = atoi(th->targetFile);
if ((TocIDRequired(AH, id, AH->ropt) & 2) != 0)
die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: "
- "%s is required, but comes before %s in the archive file.\n",
+ "%s is required, but comes before %s in the archive file.\n",
th->targetFile, filename);
/* Header doesn't match, so read to next header */
@@ -1207,7 +1199,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
if (chk != sum)
die_horribly(AH, modulename,
"corrupt tar header found in %s "
- "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
+ "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
&name[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH));
th->targetFile = strdup(name);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ce97db498f..9307a52d08 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.234 2001/10/22 19:31:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.235 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -65,8 +65,8 @@
typedef enum _formatLiteralOptions
{
- CONV_ALL = 0,
- PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we
+ CONV_ALL = 0,
+ PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we
* want to make a mask. */
/* We could make this a bit mask for control chars, but I don't */
/* see any value in making it more complex...the current code */
@@ -74,8 +74,8 @@ typedef enum _formatLiteralOptions
} formatLiteralOptions;
static void dumpComment(Archive *fout, const char *target, const char *oid,
- const char *classname, int subid,
- const char *((*deps)[]));
+ const char *classname, int subid,
+ const char *((*deps)[]));
static void dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool dataOnly);
static void dumpACL(Archive *fout, TableInfo tbinfo);
static void dumpTriggers(Archive *fout, const char *tablename,
@@ -141,71 +141,71 @@ help(const char *progname)
#ifdef HAVE_GETOPT_LONG
puts(gettext(
" -a, --data-only dump only the data, not the schema\n"
- " -b, --blobs include large objects in dump\n"
- " -c, --clean clean (drop) schema prior to create\n"
- " -C, --create include commands to create database in dump\n"
- " -d, --inserts dump data as INSERT, rather than COPY, commands\n"
- " -D, --column-inserts dump data as INSERT commands with column names\n"
- " -f, --file=FILENAME output file name\n"
- " -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
- " -h, --host=HOSTNAME database server host name\n"
- " -i, --ignore-version proceed even when server version mismatches\n"
- " pg_dump version\n"
- " -n, --no-quotes suppress most quotes around identifiers\n"
- " -N, --quotes enable most quotes around identifiers\n"
- " -o, --oids include oids in dump\n"
- " -O, --no-owner do not output \\connect commands in plain\n"
- " text format\n"
- " -p, --port=PORT database server port number\n"
- " -R, --no-reconnect disable ALL reconnections to the database in\n"
- " plain text format\n"
- " -s, --schema-only dump only the schema, no data\n"
- " -S, --superuser=NAME specify the superuser user name to use in\n"
- " plain text format\n"
- " -t, --table=TABLE dump this table only (* for all)\n"
+ " -b, --blobs include large objects in dump\n"
+ " -c, --clean clean (drop) schema prior to create\n"
+ " -C, --create include commands to create database in dump\n"
+ " -d, --inserts dump data as INSERT, rather than COPY, commands\n"
+ " -D, --column-inserts dump data as INSERT commands with column names\n"
+ " -f, --file=FILENAME output file name\n"
+ " -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
+ " -h, --host=HOSTNAME database server host name\n"
+ " -i, --ignore-version proceed even when server version mismatches\n"
+ " pg_dump version\n"
+ " -n, --no-quotes suppress most quotes around identifiers\n"
+ " -N, --quotes enable most quotes around identifiers\n"
+ " -o, --oids include oids in dump\n"
+ " -O, --no-owner do not output \\connect commands in plain\n"
+ " text format\n"
+ " -p, --port=PORT database server port number\n"
+ " -R, --no-reconnect disable ALL reconnections to the database in\n"
+ " plain text format\n"
+ " -s, --schema-only dump only the schema, no data\n"
+ " -S, --superuser=NAME specify the superuser user name to use in\n"
+ " plain text format\n"
+ " -t, --table=TABLE dump this table only (* for all)\n"
" -U, --username=NAME connect as specified database user\n"
- " -v, --verbose verbose mode\n"
- " -W, --password force password prompt (should happen automatically)\n"
- " -x, --no-privileges do not dump privileges (grant/revoke)\n"
- " -X use-set-session-authorization, --use-set-session-authorization\n"
- " output SET SESSION AUTHORIZATION commands rather\n"
- " than \\connect commands\n"
- " -Z, --compress {0-9} compression level for compressed formats\n"
- ));
+ " -v, --verbose verbose mode\n"
+ " -W, --password force password prompt (should happen automatically)\n"
+ " -x, --no-privileges do not dump privileges (grant/revoke)\n"
+ " -X use-set-session-authorization, --use-set-session-authorization\n"
+ " output SET SESSION AUTHORIZATION commands rather\n"
+ " than \\connect commands\n"
+ " -Z, --compress {0-9} compression level for compressed formats\n"
+ ));
#else
puts(gettext(
" -a dump only the data, not the schema\n"
- " -b include large objects in dump\n"
- " -c clean (drop) schema prior to create\n"
- " -C include commands to create database in dump\n"
- " -d dump data as INSERT, rather than COPY, commands\n"
- " -D dump data as INSERT commands with column names\n"
- " -f FILENAME output file name\n"
- " -F {c|t|p} output file format (custom, tar, plain text)\n"
- " -h HOSTNAME database server host name\n"
- " -i proceed even when server version mismatches\n"
- " pg_dump version\n"
- " -n suppress most quotes around identifiers\n"
- " -N enable most quotes around identifiers\n"
- " -o include oids in dump\n"
- " -O do not output \\connect commands in plain\n"
- " text format\n"
- " -p PORT database server port number\n"
- " -R disable ALL reconnections to the database in\n"
- " plain text format\n"
- " -s dump only the schema, no data\n"
- " -S NAME specify the superuser user name to use in\n"
- " plain text format\n"
- " -t TABLE dump this table only (* for all)\n"
+ " -b include large objects in dump\n"
+ " -c clean (drop) schema prior to create\n"
+ " -C include commands to create database in dump\n"
+ " -d dump data as INSERT, rather than COPY, commands\n"
+ " -D dump data as INSERT commands with column names\n"
+ " -f FILENAME output file name\n"
+ " -F {c|t|p} output file format (custom, tar, plain text)\n"
+ " -h HOSTNAME database server host name\n"
+ " -i proceed even when server version mismatches\n"
+ " pg_dump version\n"
+ " -n suppress most quotes around identifiers\n"
+ " -N enable most quotes around identifiers\n"
+ " -o include oids in dump\n"
+ " -O do not output \\connect commands in plain\n"
+ " text format\n"
+ " -p PORT database server port number\n"
+ " -R disable ALL reconnections to the database in\n"
+ " plain text format\n"
+ " -s dump only the schema, no data\n"
+ " -S NAME specify the superuser user name to use in\n"
+ " plain text format\n"
+ " -t TABLE dump this table only (* for all)\n"
" -U NAME connect as specified database user\n"
- " -v verbose mode\n"
- " -W force password prompt (should happen automatically)\n"
- " -x do not dump privileges (grant/revoke)\n"
- " -X use-set-session-authorization\n"
- " output SET SESSION AUTHORIZATION commands rather\n"
- " than \\connect commands\n"
- " -Z {0-9} compression level for compressed formats\n"
- ));
+ " -v verbose mode\n"
+ " -W force password prompt (should happen automatically)\n"
+ " -x do not dump privileges (grant/revoke)\n"
+ " -X use-set-session-authorization\n"
+ " output SET SESSION AUTHORIZATION commands rather\n"
+ " than \\connect commands\n"
+ " -Z {0-9} compression level for compressed formats\n"
+ ));
#endif
puts(gettext("If no database name is not supplied, then the PGDATABASE environment\n"
"variable value is used.\n\n"
@@ -250,7 +250,6 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
if (oids && hasoids)
{
-
/*
* archprintf(fout, "COPY %s WITH OIDS FROM stdin;\n",
* fmtId(classname, force_quotes));
@@ -264,7 +263,6 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
}
else
{
-
/*
* archprintf(fout, "COPY %s FROM stdin;\n", fmtId(classname,
* force_quotes));
@@ -291,7 +289,7 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
{
write_msg(NULL, "SQL command to dump the contents of table \"%s\" executed abnormally.\n",
classname);
- write_msg(NULL, "The server returned status %d when %d was expected.\n",
+ write_msg(NULL, "The server returned status %d when %d was expected.\n",
PQresultStatus(res), PGRES_COPY_OUT);
write_msg(NULL, "The command was: %s\n", query);
exit_nicely();
@@ -399,11 +397,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
int field;
if (fout->remoteVersion >= 70100)
- {
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM ONLY %s", fmtId(classname, force_quotes));
- } else {
+ else
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM %s", fmtId(classname, force_quotes));
- }
res = PQexec(g_conn, q->data);
if (!res ||
@@ -414,8 +410,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
write_msg(NULL, "The command was: %s\n", q->data);
exit_nicely();
}
-
- do {
+
+ do
+ {
PQclear(res);
res = PQexec(g_conn, "FETCH 100 FROM _pg_dump_cursor");
@@ -458,9 +455,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
{
case INT2OID:
case INT4OID:
- case OIDOID: /* int types */
+ case OIDOID: /* int types */
case FLOAT4OID:
- case FLOAT8OID:/* float types */
+ case FLOAT8OID: /* float types */
/* These types are printed without quotes */
archprintf(fout, "%s",
PQgetvalue(res, tuple, field));
@@ -471,10 +468,11 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
PQgetvalue(res, tuple, field));
break;
default:
-
+
/*
* All other types are printed as string literals,
- * with appropriate escaping of special characters.
+ * with appropriate escaping of special
+ * characters.
*/
resetPQExpBuffer(q);
formatStringLiteral(q, PQgetvalue(res, tuple, field), CONV_ALL);
@@ -485,7 +483,7 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
archprintf(fout, ");\n");
}
- } while( PQntuples(res) > 0 );
+ } while (PQntuples(res) > 0);
PQclear(res);
res = PQexec(g_conn, "CLOSE _pg_dump_cursor");
@@ -528,7 +526,6 @@ formatStringLiteral(PQExpBuffer buf, const char *str, const formatLiteralOptions
|| (ch != '\n' && ch != '\t')
))
{
-
/*
* generate octal escape for control chars other than
* whitespace
@@ -618,10 +615,12 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
static int
-parse_version(const char* versionString)
+parse_version(const char *versionString)
{
int cnt;
- int vmaj, vmin, vrev;
+ int vmaj,
+ vmin,
+ vrev;
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
@@ -698,12 +697,13 @@ main(int argc, char **argv)
{"help", no_argument, NULL, '?'},
{"version", no_argument, NULL, 'V'},
- /* the following options don't have an equivalent short option
- letter, but are available as '-X long-name' */
+ /*
+ * the following options don't have an equivalent short option
+ * letter, but are available as '-X long-name'
+ */
{"use-set-session-authorization", no_argument, &use_setsessauth, 1}
};
int optindex;
-
#endif
#ifdef ENABLE_NLS
@@ -891,15 +891,14 @@ main(int argc, char **argv)
break;
/*
- * Option letters were getting scarce, so I invented
- * this new scheme: '-X feature' turns on some
- * feature. Compare to the -f option in GCC. You
- * should also add an equivalent GNU-style option
- * --feature. Features that require arguments should
- * use '-X feature=foo'.
+ * Option letters were getting scarce, so I invented this
+ * new scheme: '-X feature' turns on some feature.
+ * Compare to the -f option in GCC. You should also add
+ * an equivalent GNU-style option --feature. Features
+ * that require arguments should use '-X feature=foo'.
*/
case 'X':
- if (strcmp(optarg, "use-set-session-authorization")==0)
+ if (strcmp(optarg, "use-set-session-authorization") == 0)
use_setsessauth = 1;
else
{
@@ -918,7 +917,7 @@ main(int argc, char **argv)
case '-':
fprintf(stderr,
gettext("%s was compiled without support for long options.\n"
- "Use --help for help on invocation options.\n"),
+ "Use --help for help on invocation options.\n"),
progname);
exit(1);
break;
@@ -936,8 +935,8 @@ main(int argc, char **argv)
if (optind < (argc - 1))
{
fprintf(stderr,
- gettext("%s: too many command line options (first is '%s')\n"
- "Try '%s --help' for more information.\n"),
+ gettext("%s: too many command line options (first is '%s')\n"
+ "Try '%s --help' for more information.\n"),
progname, argv[optind + 1], progname);
exit(1);
}
@@ -1023,7 +1022,7 @@ main(int argc, char **argv)
* Open the database using the Archiver, so it knows about it. Errors
* mean death.
*/
- g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
+ g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
g_fout->maxRemoteVersion = parse_version(PG_VERSION);
g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, username, force_password, ignore_version);
@@ -1086,6 +1085,7 @@ main(int argc, char **argv)
MoveToEnd(g_fout, "TRIGGER");
MoveToEnd(g_fout, "RULE");
MoveToEnd(g_fout, "SEQUENCE SET");
+
/*
* Moving all comments to end is annoying, but must do it for comments
* on stuff we just moved, and we don't seem to have quite enough
@@ -1115,7 +1115,8 @@ main(int argc, char **argv)
else
ropt->compression = compressLevel;
- ropt->suppressDumpWarnings = true; /* We've already shown them */
+ ropt->suppressDumpWarnings = true; /* We've already shown
+ * them */
RestoreArchive(g_fout, ropt);
}
@@ -1220,11 +1221,9 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
/* Cursor to get all BLOB tables */
if (AH->remoteVersion >= 70100)
- {
appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT DISTINCT loid FROM pg_largeobject");
- } else {
+ else
appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT oid from pg_class where relkind = 'l'");
- }
res = PQexec(g_conn, oidQry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
@@ -1300,7 +1299,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
* numTypes is set to the number of types read in
*
*/
-TypeInfo *
+TypeInfo *
getTypes(int *numTypes)
{
PGresult *res;
@@ -1341,18 +1340,20 @@ getTypes(int *numTypes)
if (g_fout->remoteVersion < 70100)
{
appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, "
- "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
- "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
- "typname as typedefn "
- "from pg_type");
- } else {
+ "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
+ "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, "
+ "(select usename from pg_user where typowner = usesysid) as usename, "
+ "typname as typedefn "
+ "from pg_type");
+ }
+ else
+ {
appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, "
- "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
- "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
- "format_type(pg_type.oid, NULL) as typedefn "
- "from pg_type");
+ "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
+ "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, "
+ "(select usename from pg_user where typowner = usesysid) as usename, "
+ "format_type(pg_type.oid, NULL) as typedefn "
+ "from pg_type");
}
res = PQexec(g_conn, query->data);
@@ -1450,7 +1451,7 @@ getTypes(int *numTypes)
*
* numOprs is set to the number of operators read in
*/
-OprInfo *
+OprInfo *
getOperators(int *numOprs)
{
PGresult *res;
@@ -1812,7 +1813,7 @@ clearAggInfo(AggInfo *agginfo, int numArgs)
*
* numAggs is set to the number of aggregates read in
*/
-AggInfo *
+AggInfo *
getAggregates(int *numAggs)
{
PGresult *res;
@@ -1836,18 +1837,20 @@ getAggregates(int *numAggs)
if (g_fout->remoteVersion < 70100)
{
appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn1 as aggtransfn, "
- "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, "
- "agginitval1 as agginitval, "
- "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, "
- "(select usename from pg_user where aggowner = usesysid) as usename "
- "from pg_aggregate");
- } else {
+ "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, "
+ "agginitval1 as agginitval, "
+ "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, "
+ "(select usename from pg_user where aggowner = usesysid) as usename "
+ "from pg_aggregate");
+ }
+ else
+ {
appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn, "
- "aggfinalfn, aggtranstype, aggbasetype, "
- "agginitval, "
- "'t'::boolean as convertok, "
- "(select usename from pg_user where aggowner = usesysid) as usename "
- "from pg_aggregate");
+ "aggfinalfn, aggtranstype, aggbasetype, "
+ "agginitval, "
+ "'t'::boolean as convertok, "
+ "(select usename from pg_user where aggowner = usesysid) as usename "
+ "from pg_aggregate");
}
res = PQexec(g_conn, query->data);
@@ -1908,7 +1911,7 @@ getAggregates(int *numAggs)
*
*
*/
-FuncInfo *
+FuncInfo *
getFuncs(int *numFuncs)
{
PGresult *res;
@@ -1936,21 +1939,23 @@ getFuncs(int *numFuncs)
{
appendPQExpBuffer(query,
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
- "proretset, proargtypes, prosrc, probin, "
- "(select usename from pg_user where proowner = usesysid) as usename, "
- "proiscachable, 'f'::boolean as proisstrict "
- "from pg_proc "
- "where pg_proc.oid > '%u'::oid",
- g_last_builtin_oid);
- } else {
+ "proretset, proargtypes, prosrc, probin, "
+ "(select usename from pg_user where proowner = usesysid) as usename, "
+ "proiscachable, 'f'::boolean as proisstrict "
+ "from pg_proc "
+ "where pg_proc.oid > '%u'::oid",
+ g_last_builtin_oid);
+ }
+ else
+ {
appendPQExpBuffer(query,
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
- "proretset, proargtypes, prosrc, probin, "
- "(select usename from pg_user where proowner = usesysid) as usename, "
- "proiscachable, proisstrict "
- "from pg_proc "
- "where pg_proc.oid > '%u'::oid",
- g_last_builtin_oid);
+ "proretset, proargtypes, prosrc, probin, "
+ "(select usename from pg_user where proowner = usesysid) as usename, "
+ "proiscachable, proisstrict "
+ "from pg_proc "
+ "where pg_proc.oid > '%u'::oid",
+ g_last_builtin_oid);
}
res = PQexec(g_conn, query->data);
@@ -2029,7 +2034,7 @@ getFuncs(int *numFuncs)
*
* numTables is set to the number of tables read in
*/
-TableInfo *
+TableInfo *
getTables(int *numTables, FuncInfo *finfo, int numFuncs)
{
PGresult *res;
@@ -2066,28 +2071,30 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (g_fout->remoteVersion >= 70200)
{
appendPQExpBuffer(query,
- "SELECT pg_class.oid, relname, relacl, relkind, "
+ "SELECT pg_class.oid, relname, relacl, relkind, "
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, relhasoids "
+ "relchecks, reltriggers, relhasindex, relhasoids "
"from pg_class "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
else if (g_fout->remoteVersion >= 70100)
{
/* all tables have oids in 7.1 */
appendPQExpBuffer(query,
- "SELECT pg_class.oid, relname, relacl, relkind, "
+ "SELECT pg_class.oid, relname, relacl, relkind, "
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
+ "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
"from pg_class "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
- } else {
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ }
+ else
+ {
/*
* Before 7.1, view relkind was not set to 'v', so we must check
* if we have a view by looking for a rule in pg_rewrite.
@@ -2095,18 +2102,18 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
appendPQExpBuffer(query,
"SELECT c.oid, relname, relacl, "
"CASE WHEN relhasrules and relkind = 'r' "
- " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
- " r.ev_class = c.oid AND r.ev_type = '1') "
+ " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
+ " r.ev_class = c.oid AND r.ev_type = '1') "
"THEN '%c'::\"char\" "
"ELSE relkind END AS relkind,"
"(select usename from pg_user where relowner = usesysid) as usename, "
- "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
+ "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids "
"from pg_class c "
"where relname !~ '^pg_' "
"and relkind in ('%c', '%c', '%c') "
"order by oid",
RELKIND_VIEW,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
res = PQexec(g_conn, query->data);
@@ -2155,10 +2162,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT definition as viewdef, ");
- /* XXX 7.2 - replace with att from pg_views or some other generic source */
+
+ /*
+ * XXX 7.2 - replace with att from pg_views or some other
+ * generic source
+ */
appendPQExpBuffer(query, "(select oid from pg_rewrite where "
- " rulename=('_RET' || viewname)::name) as view_oid"
- " from pg_views where viewname = ");
+ " rulename=('_RET' || viewname)::name) as view_oid"
+ " from pg_views where viewname = ");
formatStringLiteral(query, tblinfo[i].relname, CONV_ALL);
appendPQExpBuffer(query, ";");
@@ -2177,7 +2188,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
tblinfo[i].relname);
else
write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n",
- tblinfo[i].relname);
+ tblinfo[i].relname);
exit_nicely();
}
@@ -2206,8 +2217,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
*
* Exclude inherited CHECKs from CHECK constraints total. If a
* constraint matches by name and condition with a constraint
- * belonging to a parent class (OR conditions match and both
- * names start with '$', we assume it was inherited.
+ * belonging to a parent class (OR conditions match and both names
+ * start with '$', we assume it was inherited.
*/
if (tblinfo[i].ncheck > 0)
{
@@ -2225,11 +2236,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
appendPQExpBuffer(query, "SELECT rcname, rcsrc from pg_relcheck "
" where rcrelid = '%s'::oid "
" and not exists "
- " (select * from pg_relcheck as c, pg_inherits as i "
- " where i.inhrelid = pg_relcheck.rcrelid "
+ " (select * from pg_relcheck as c, pg_inherits as i "
+ " where i.inhrelid = pg_relcheck.rcrelid "
" and (c.rcname = pg_relcheck.rcname "
" or ( c.rcname[0] = '$' "
- " and pg_relcheck.rcname[0] = '$')"
+ " and pg_relcheck.rcname[0] = '$')"
" )"
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
@@ -2251,7 +2262,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
exit_nicely();
}
- /* Set ncheck to the number of *non-inherited* CHECK constraints */
+ /*
+ * Set ncheck to the number of *non-inherited* CHECK
+ * constraints
+ */
tblinfo[i].ncheck = ntups2;
i_rcname = PQfnumber(res2, "rcname");
@@ -2296,7 +2310,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (PQntuples(res2) > 1)
{
write_msg(NULL, "query to obtain primary key of table \"%s\" produced more than one result\n",
- tblinfo[i].relname);
+ tblinfo[i].relname);
exit_nicely();
}
@@ -2375,11 +2389,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer(query);
appendPQExpBuffer(query,
- "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, "
- "tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, oid, "
- "(select relname from pg_class where oid = tgconstrrelid) "
- " as tgconstrrelname "
+ "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, "
+ "tgisconstraint, tgconstrname, tgdeferrable, "
+ "tgconstrrelid, tginitdeferred, oid, "
+ "(select relname from pg_class where oid = tgconstrrelid) "
+ " as tgconstrrelname "
"from pg_trigger "
"where tgrelid = '%s'::oid ",
tblinfo[i].oid);
@@ -2541,17 +2555,18 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
{
tgconstrrelid = PQgetvalue(res2, i2, i_tgconstrrelid);
- if (strcmp(tgconstrrelid, "0") != 0) {
+ if (strcmp(tgconstrrelid, "0") != 0)
+ {
if (PQgetisnull(res2, i2, i_tgconstrrelname))
{
write_msg(NULL, "query produced NULL referenced table name for foreign key trigger \"%s\" on table \"%s\" (oid of table: %s)\n",
- tgname, tblinfo[i].relname, tgconstrrelid);
+ tgname, tblinfo[i].relname, tgconstrrelid);
exit_nicely();
}
appendPQExpBuffer(query, " FROM %s",
- fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes));
+ fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes));
}
if (!tgdeferrable)
appendPQExpBuffer(query, " NOT");
@@ -2610,7 +2625,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer(query);
appendPQExpBuffer(query, "TRIGGER %s ",
- fmtId(tgname, force_quotes));
+ fmtId(tgname, force_quotes));
appendPQExpBuffer(query, "ON %s",
fmtId(tblinfo[i].relname, force_quotes));
tblinfo[i].triggers[i2].tgcomment = strdup(query->data);
@@ -2643,7 +2658,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
*
* numInherits is set to the number of tables read in
*/
-InhInfo *
+InhInfo *
getInherits(int *numInherits)
{
PGresult *res;
@@ -2737,28 +2752,30 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{
/* Fake the LOJ below */
appendPQExpBuffer(q,
- " SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
- " a.attnotnull, a.atthasdef, NULL as atttypedefn "
- " from pg_attribute a, pg_type t "
- " where a.attrelid = '%s'::oid "
- " and a.attnum > 0 "
- " and a.atttypid = t.oid "
- " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, "
- " a.attnotnull, a.atthasdef, NULL as atttypedefn "
- " from pg_attribute a "
- " where a.attrelid = '%s'::oid "
- " and a.attnum > 0 "
- " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)"
- " order by attnum",
- tblinfo[i].oid, tblinfo[i].oid);
-
- } else {
+ " SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
+ " a.attnotnull, a.atthasdef, NULL as atttypedefn "
+ " from pg_attribute a, pg_type t "
+ " where a.attrelid = '%s'::oid "
+ " and a.attnum > 0 "
+ " and a.atttypid = t.oid "
+ " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, "
+ " a.attnotnull, a.atthasdef, NULL as atttypedefn "
+ " from pg_attribute a "
+ " where a.attrelid = '%s'::oid "
+ " and a.attnum > 0 "
+ " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)"
+ " order by attnum",
+ tblinfo[i].oid, tblinfo[i].oid);
+
+ }
+ else
+ {
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, t.typname, a.atttypmod, "
- "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
- "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid "
- "where a.attrelid = '%s'::oid "
- "and a.attnum > 0 order by attnum",
- tblinfo[i].oid);
+ "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
+ "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid "
+ "where a.attrelid = '%s'::oid "
+ "and a.attnum > 0 order by attnum",
+ tblinfo[i].oid);
}
res = PQexec(g_conn, q->data);
@@ -2796,7 +2813,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (PQgetisnull(res, j, i_typname))
{
write_msg(NULL, "query produced NULL name for data type of column %d of table %s\n",
- j+1, tblinfo[i].relname);
+ j + 1, tblinfo[i].relname);
exit_nicely();
}
@@ -2863,7 +2880,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
*
*
*/
-IndInfo *
+IndInfo *
getIndexes(int *numIndexes)
{
int i;
@@ -2891,11 +2908,11 @@ getIndexes(int *numIndexes)
appendPQExpBuffer(query,
"SELECT i.indexrelid as indexreloid, "
"i.indrelid as indreloid, "
- "t1.relname as indexrelname, t2.relname as indrelname, "
+ "t1.relname as indexrelname, t2.relname as indrelname, "
"pg_get_indexdef(i.indexrelid) as indexdef, "
"i.indisprimary, i.indkey "
"from pg_index i, pg_class t1, pg_class t2 "
- "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
+ "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
"and i.indexrelid > '%u'::oid "
"and t2.relname !~ '^pg_' ",
g_last_builtin_oid);
@@ -2981,7 +2998,7 @@ dumpComment(Archive *fout, const char *target, const char *oid,
{
appendPQExpBuffer(query, "SELECT description FROM pg_description "
"WHERE objoid = '%s'::oid and classoid = "
- "(SELECT oid FROM pg_class where relname = '%s') "
+ "(SELECT oid FROM pg_class where relname = '%s') "
"and objsubid = %d",
oid, classname, subid);
}
@@ -2997,7 +3014,7 @@ dumpComment(Archive *fout, const char *target, const char *oid,
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get comment on oid %s failed: %s",
- oid, PQerrorMessage(g_conn));
+ oid, PQerrorMessage(g_conn));
exit_nicely();
}
@@ -3052,7 +3069,7 @@ dumpDBComment(Archive *fout)
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get database oid failed: %s",
- PQerrorMessage(g_conn));
+ PQerrorMessage(g_conn));
exit_nicely();
}
@@ -3108,7 +3125,7 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
(strcmp(tinfo[i].typinput, "array_in") == 0))
continue;
- deps = malloc(sizeof(char*) * 10);
+ deps = malloc(sizeof(char *) * 10);
depIdx = 0;
/*
@@ -3198,7 +3215,7 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
else
appendPQExpBuffer(q, ");\n");
- (*deps)[depIdx++] = NULL; /* End of List */
+ (*deps)[depIdx++] = NULL; /* End of List */
ArchiveEntry(fout, tinfo[i].oid, tinfo[i].typname, "TYPE", deps,
q->data, delq->data, "", tinfo[i].usename, NULL, NULL);
@@ -3249,7 +3266,7 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to obtain list of procedural languages failed: %s",
- PQerrorMessage(g_conn));
+ PQerrorMessage(g_conn));
exit_nicely();
}
ntups = PQntuples(res);
@@ -3277,7 +3294,7 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
if (fidx >= numFuncs)
{
write_msg(NULL, "handler procedure for procedural language %s not found\n",
- PQgetvalue(res, i, i_lanname));
+ PQgetvalue(res, i, i_lanname));
exit_nicely();
}
@@ -3422,7 +3439,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
finfo[i].proname);
write_msg(NULL, "reason: data type name of argument %d (oid %s) not found\n",
- j, finfo[i].argtypes[j]);
+ j, finfo[i].argtypes[j]);
goto done;
}
@@ -3644,11 +3661,11 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
resetPQExpBuffer(delq);
appendPQExpBuffer(delq, "DROP OPERATOR %s (%s",
oprinfo[i].oprname,
- findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft,
- zeroAsNone));
+ findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft,
+ zeroAsNone));
appendPQExpBuffer(delq, ", %s);\n",
- findTypeByOid(tinfo, numTypes, oprinfo[i].oprright,
- zeroAsNone));
+ findTypeByOid(tinfo, numTypes, oprinfo[i].oprright,
+ zeroAsNone));
resetPQExpBuffer(q);
appendPQExpBuffer(q,
@@ -3704,7 +3721,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
resetPQExpBuffer(details);
/* skip all the builtin oids */
- if ( oidle( atooid(agginfo[i].oid), g_last_builtin_oid) )
+ if (oidle(atooid(agginfo[i].oid), g_last_builtin_oid))
continue;
resetPQExpBuffer(aggSig);
@@ -3720,9 +3737,9 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
resetPQExpBuffer(q);
appendPQExpBuffer(q, "-- WARNING: aggregate function %s could not be dumped correctly for this database version; ignored\n",
- aggSig->data);
+ aggSig->data);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
@@ -3739,7 +3756,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid);
appendPQExpBuffer(q, "-- reason: aggbasetype (oid %s) not found\n", agginfo[i].aggbasetype);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
appendPQExpBuffer(details, "BASETYPE = %s, ", name);
@@ -3757,7 +3774,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid);
appendPQExpBuffer(q, "-- reason: aggtranstype (oid %s) not found\n", agginfo[i].aggtranstype);
ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL,
- q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL);
+ q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL);
continue;
}
appendPQExpBuffer(details,
@@ -3914,7 +3931,6 @@ dumpACL(Archive *fout, TableInfo tbinfo)
/* Scan comma-separated ACL items */
for (tok = strtok(aclbuf, ","); tok != NULL; tok = strtok(NULL, ","))
{
-
/*
* Token may start with '{' and/or '"'. Actually only the start
* of the string should have '{', but we don't verify that.
@@ -3981,9 +3997,9 @@ dumpACL(Archive *fout, TableInfo tbinfo)
static void
_dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
{
- int32 tmp_typmod;
- int precision;
- int scale;
+ int32 tmp_typmod;
+ int precision;
+ int scale;
/* Show lengths on bpchar and varchar */
if (!strcmp(tblinfo[i].typnames[j], "bpchar"))
@@ -3993,7 +4009,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
appendPQExpBuffer(q, "character");
if (len > 1)
appendPQExpBuffer(q, "(%d)",
- tblinfo[i].atttypmod[j] - VARHDRSZ);
+ tblinfo[i].atttypmod[j] - VARHDRSZ);
}
else if (!strcmp(tblinfo[i].typnames[j], "varchar"))
{
@@ -4001,7 +4017,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
if (tblinfo[i].atttypmod[j] != -1)
{
appendPQExpBuffer(q, "(%d)",
- tblinfo[i].atttypmod[j] - VARHDRSZ);
+ tblinfo[i].atttypmod[j] - VARHDRSZ);
}
}
else if (!strcmp(tblinfo[i].typnames[j], "numeric"))
@@ -4018,19 +4034,18 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
}
/*
- * char is an internal single-byte data type; Let's
- * make sure we force it through with quotes. - thomas
- * 1998-12-13
+ * char is an internal single-byte data type; Let's make sure we force
+ * it through with quotes. - thomas 1998-12-13
*/
else if (!strcmp(tblinfo[i].typnames[j], "char"))
{
appendPQExpBuffer(q, "%s",
- fmtId(tblinfo[i].typnames[j], true));
+ fmtId(tblinfo[i].typnames[j], true));
}
else
{
appendPQExpBuffer(q, "%s",
- fmtId(tblinfo[i].typnames[j], false));
+ fmtId(tblinfo[i].typnames[j], false));
}
}
@@ -4106,9 +4121,9 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
objoid = tblinfo[i].viewoid;
appendPQExpBuffer(delq, "DROP VIEW %s;\n", fmtId(tblinfo[i].relname, force_quotes));
appendPQExpBuffer(q, "CREATE VIEW %s as %s\n", fmtId(tblinfo[i].relname, force_quotes), tblinfo[i].viewdef);
- commentDeps = malloc(sizeof(char*) * 2);
+ commentDeps = malloc(sizeof(char *) * 2);
(*commentDeps)[0] = strdup(objoid);
- (*commentDeps)[1] = NULL; /* end of list */
+ (*commentDeps)[1] = NULL; /* end of list */
}
else
{
@@ -4135,11 +4150,9 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
appendPQExpBuffer(q, "%s ", fmtId(tblinfo[i].attnames[j], force_quotes));
if (g_fout->remoteVersion >= 70100)
- {
appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]);
- } else {
+ else
_dumpTableAttr70(fout, tblinfo, i, j, q);
- }
/* Default value */
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
@@ -4182,7 +4195,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
if (k >= numIndexes)
{
write_msg(NULL, "dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n",
- tblinfo[i].pkIndexOid);
+ tblinfo[i].pkIndexOid);
exit_nicely();
}
@@ -4238,7 +4251,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
appendPQExpBuffer(q, ".");
appendPQExpBuffer(q, "%s", fmtId(tblinfo[i].attnames[j], force_quotes));
dumpComment(fout, q->data, tblinfo[i].oid,
- "pg_class", j+1, commentDeps);
+ "pg_class", j + 1, commentDeps);
}
/* Dump Table Comments */
@@ -4295,7 +4308,7 @@ static const char *
getAttrName(int attrnum, TableInfo *tblInfo)
{
if (attrnum > 0 && attrnum <= tblInfo->numatts)
- return tblInfo->attnames[attrnum-1];
+ return tblInfo->attnames[attrnum - 1];
switch (attrnum)
{
case SelfItemPointerAttributeNumber:
@@ -4314,7 +4327,7 @@ getAttrName(int attrnum, TableInfo *tblInfo)
return "tableoid";
}
write_msg(NULL, "getAttrName(): invalid column number %d for table %s\n",
- attrnum, tblInfo->relname);
+ attrnum, tblInfo->relname);
exit_nicely();
return NULL; /* keep compiler quiet */
}
@@ -4344,7 +4357,7 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
if (tableInd < 0)
{
write_msg(NULL, "dumpIndexes(): failed sanity check, table %s was not found\n",
- indinfo[i].indrelname);
+ indinfo[i].indrelname);
exit_nicely();
}
@@ -4352,14 +4365,18 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
if (strcmp(indinfo[i].indisprimary, "t") == 0)
{
#if 0
- /* PK: Enable this code when ALTER TABLE supports PK constraints. */
+
+ /*
+ * PK: Enable this code when ALTER TABLE supports PK
+ * constraints.
+ */
PQExpBuffer consDef = getPKconstraint(&tblinfo[tableInd], &indinfo[i]);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "Alter Table %s Add %s;",
- fmtId(tblinfo[tableInd].relname, force_quotes),
+ fmtId(tblinfo[tableInd].relname, force_quotes),
consDef->data);
ArchiveEntry(fout, indinfo[i].oid, tblinfo[tableInd].primary_key_name,
@@ -4386,9 +4403,9 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
appendPQExpBuffer(delq, "DROP INDEX %s;\n", id1->data);
/*
- * We make the index belong to the owner of its table, which
- * is not necessarily right but should answer 99% of the time.
- * Would have to add owner name to IndInfo to do it right.
+ * We make the index belong to the owner of its table, which is
+ * not necessarily right but should answer 99% of the time. Would
+ * have to add owner name to IndInfo to do it right.
*/
ArchiveEntry(fout, indinfo[i].indexreloid, id1->data,
"INDEX", NULL, q->data, delq->data,
@@ -4433,7 +4450,6 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap)
if (m > 0)
{
-
/*
* Print out the tuples but only print tuples with at least 1
* field.
@@ -4468,7 +4484,6 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap)
free(outVals);
}
}
-
#endif
/*
@@ -4635,14 +4650,14 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool
if (PQntuples(res) != 1)
{
write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
- tbinfo.relname, PQntuples(res));
+ tbinfo.relname, PQntuples(res));
exit_nicely();
}
if (strcmp(PQgetvalue(res, 0, 0), tbinfo.relname) != 0)
{
write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n",
- tbinfo.relname, PQgetvalue(res, 0, 0));
+ tbinfo.relname, PQgetvalue(res, 0, 0));
exit_nicely();
}
@@ -4659,8 +4674,8 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool
* basic CREATE SEQUENCE statement (use last_val for start if called
* is false, else use min_val for start_val).
*
- * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff
- * we load data
+ * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load
+ * data
*/
if (!dataOnly)
@@ -4788,7 +4803,7 @@ dumpRules(Archive *fout, const char *tablename,
PQresultStatus(res) != PGRES_TUPLES_OK)
{
write_msg(NULL, "query to get rules associated with table \"%s\" failed: %s",
- tblinfo[t].relname, PQerrorMessage(g_conn));
+ tblinfo[t].relname, PQerrorMessage(g_conn));
exit_nicely();
}
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index dbd7f598d7..a08105ca35 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-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.73 2001/10/22 19:31:09 tgl Exp $
+ * $Id: pg_dump.h,v 1.74 2001/10/25 05:49:53 momjian Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -92,18 +92,20 @@ typedef struct _tableInfo
char *relacl;
char *viewdef;
char *viewoid; /* OID of view - should be >= oid of table
- * important because views may be constructed
- * manually from rules, and rule may ref things
- * created after the base table was created.
- */
+ * important because views may be
+ * constructed manually from rules, and
+ * rule may ref things created after the
+ * base table was created. */
bool sequence;
bool hasoids; /* does it have OIDs? */
int numatts; /* number of attributes */
int *inhAttrs; /* an array of flags, one for each
* attribute if the value is 1, then this
* attribute is an inherited attribute */
- int *inhAttrDef; /* Flags indicating if attrdef is inherited */
- int *inhNotNull; /* Flags indicating if NOT NULL in inherited */
+ int *inhAttrDef; /* Flags indicating if attrdef is
+ * inherited */
+ int *inhNotNull; /* Flags indicating if NOT NULL in
+ * inherited */
char **attnames; /* the attribute names */
char **atttypedefns; /* formatted column type definitions */
char **typnames; /* fill out attributes */
@@ -157,7 +159,8 @@ typedef struct _aggInfo
char *aggbasetype;
char *agginitval;
char *usename;
- int convertok; /* Flag to indicate of version convertsion is OK */
+ int convertok; /* Flag to indicate of version convertsion
+ * is OK */
} AggInfo;
typedef struct _oprInfo
@@ -165,7 +168,7 @@ typedef struct _oprInfo
char *oid;
char *oprname;
char *oprkind; /*----------
- * b = binary,
+ * b = binary,
* l = left unary
* r = right unary
*----------
@@ -221,11 +224,11 @@ extern void dumpSchemaIdx(Archive *fout,
typedef enum _OidOptions
{
- zeroAsOpaque = 1,
- zeroAsAny = 2,
- zeroAsStar = 4,
- zeroAsNone = 8,
- useBaseTypeName = 1024
+ zeroAsOpaque = 1,
+ zeroAsAny = 2,
+ zeroAsStar = 4,
+ zeroAsNone = 8,
+ useBaseTypeName = 1024
} OidOptions;
extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts);
@@ -276,5 +279,4 @@ extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
TableInfo *tbinfo, int numTables, const char *tablename);
extern const char *fmtId(const char *identifier, bool force_quotes);
extern void exit_nicely(void);
-
#endif /* PG_DUMP_H */
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 94571db53b..3152126f8c 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.26 2001/09/04 03:20:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.27 2001/10/25 05:49:53 momjian Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -123,12 +123,14 @@ main(int argc, char **argv)
{"username", 1, NULL, 'U'},
{"verbose", 0, NULL, 'v'},
- /* the following options don't have an equivalent short option
- letter, but are available as '-X long-name' */
+ /*
+ * the following options don't have an equivalent short option
+ * letter, but are available as '-X long-name'
+ */
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
{NULL, 0, NULL, 0}
};
-#endif /* HAVE_GETOPT_LONG */
+#endif /* HAVE_GETOPT_LONG */
#ifdef ENABLE_NLS
@@ -275,7 +277,7 @@ main(int argc, char **argv)
break;
case 'X':
- if (strcmp(optarg, "use-set-session-authorization")==0)
+ if (strcmp(optarg, "use-set-session-authorization") == 0)
use_setsessauth = 1;
else
{
@@ -375,80 +377,80 @@ static void
usage(const char *progname)
{
printf(gettext(
- "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
- "Usage:\n %s [options] [file]\n\n"
- "Options:\n"),
+ "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
+ "Usage:\n %s [options] [file]\n\n"
+ "Options:\n"),
progname, progname);
#ifdef HAVE_GETOPT_LONG
puts(gettext(
- " -a, --data-only restore only the data, no schema\n"
- " -c, --clean clean (drop) schema prior to create\n"
- " -C, --create issue commands to create the database\n"
- " -d, --dbname=NAME specify database name\n"
- " -f, --file=FILENAME TOC output file name (see -l)\n"
- " -F, --format={c|t} specify backup file format\n"
- " -h, --host=HOSTNAME server host name\n"
- " -i, --index=NAME restore named index\n"
- " -l, --list dump summarized TOC for of the archive\n"
- " -L, --use-list=FILENAME use specified table of contents for ordering\n"
- " output from this file\n"
- " -N, --orig-order restore in original dump order\n"
- " -o, --oid-order restore in oid order\n"
- " -O, --no-owner do not reconnect to database to match\n"
- " object owner\n"
- " -p, --port=PORT server port number\n"
- " -P, --function=NAME restore named function\n"
- " -r, --rearrange rearrange output to put indexes etc. at end\n"
- " -R, --no-reconnect disallow ALL reconnections to the database\n"
- " -s, --schema-only restore only the schema, no data\n"
- " -S, --superuser=NAME specify the superuser user name to use for\n"
- " disabling triggers\n"
- " -t, --table=NAME restore named table\n"
- " -T, --trigger=NAME restore named trigger\n"
+ " -a, --data-only restore only the data, no schema\n"
+ " -c, --clean clean (drop) schema prior to create\n"
+ " -C, --create issue commands to create the database\n"
+ " -d, --dbname=NAME specify database name\n"
+ " -f, --file=FILENAME TOC output file name (see -l)\n"
+ " -F, --format={c|t} specify backup file format\n"
+ " -h, --host=HOSTNAME server host name\n"
+ " -i, --index=NAME restore named index\n"
+ " -l, --list dump summarized TOC for of the archive\n"
+ " -L, --use-list=FILENAME use specified table of contents for ordering\n"
+ " output from this file\n"
+ " -N, --orig-order restore in original dump order\n"
+ " -o, --oid-order restore in oid order\n"
+ " -O, --no-owner do not reconnect to database to match\n"
+ " object owner\n"
+ " -p, --port=PORT server port number\n"
+ " -P, --function=NAME restore named function\n"
+ " -r, --rearrange rearrange output to put indexes etc. at end\n"
+ " -R, --no-reconnect disallow ALL reconnections to the database\n"
+ " -s, --schema-only restore only the schema, no data\n"
+ " -S, --superuser=NAME specify the superuser user name to use for\n"
+ " disabling triggers\n"
+ " -t, --table=NAME restore named table\n"
+ " -T, --trigger=NAME restore named trigger\n"
" -U, --username=NAME connect as specified database user\n"
- " -v, --verbose verbose mode\n"
- " -W, --password force password prompt (should happen automatically)\n"
- " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"
- " -X use-set-session-authorization, --use-set-session-authorization\n"
- " use SET SESSION AUTHORIZATION commands instead\n"
- " of reconnecting, if possible\n"
- ));
+ " -v, --verbose verbose mode\n"
+ " -W, --password force password prompt (should happen automatically)\n"
+ " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"
+ " -X use-set-session-authorization, --use-set-session-authorization\n"
+ " use SET SESSION AUTHORIZATION commands instead\n"
+ " of reconnecting, if possible\n"
+ ));
-#else /* not HAVE_GETOPT_LONG */
+#else /* not HAVE_GETOPT_LONG */
puts(gettext(
- " -a restore only the data, no schema\n"
- " -c clean (drop) schema prior to create\n"
- " -C issue commands to create the database\n"
- " -d NAME specify database name\n"
- " -f FILENAME TOC output file name (see -l)\n"
- " -F {c|t} specify backup file format\n"
- " -h HOSTNAME server host name\n"
- " -i NAME restore named index\n"
- " -l dump summarized TOC for this file\n"
- " -L FILENAME use specified table of contents for ordering\n"
- " output from this file\n"
- " -N restore in original dump order\n"
- " -o restore in oid order\n"
- " -O do not output reconnect to database to match\n"
- " object owner\n"
- " -p PORT server port number\n"
- " -P NAME restore named function\n"
- " -r rearrange output to put indexes etc. at end\n"
- " -R disallow ALL reconnections to the database\n"
- " -s restore only the schema, no data\n"
- " -S NAME specify the superuser user name to use for\n"
- " disabling triggers\n"
- " -t NAME restore named table\n"
- " -T NAME restore named trigger\n"
+ " -a restore only the data, no schema\n"
+ " -c clean (drop) schema prior to create\n"
+ " -C issue commands to create the database\n"
+ " -d NAME specify database name\n"
+ " -f FILENAME TOC output file name (see -l)\n"
+ " -F {c|t} specify backup file format\n"
+ " -h HOSTNAME server host name\n"
+ " -i NAME restore named index\n"
+ " -l dump summarized TOC for this file\n"
+ " -L FILENAME use specified table of contents for ordering\n"
+ " output from this file\n"
+ " -N restore in original dump order\n"
+ " -o restore in oid order\n"
+ " -O do not output reconnect to database to match\n"
+ " object owner\n"
+ " -p PORT server port number\n"
+ " -P NAME restore named function\n"
+ " -r rearrange output to put indexes etc. at end\n"
+ " -R disallow ALL reconnections to the database\n"
+ " -s restore only the schema, no data\n"
+ " -S NAME specify the superuser user name to use for\n"
+ " disabling triggers\n"
+ " -t NAME restore named table\n"
+ " -T NAME restore named trigger\n"
" -U NAME connect as specified database user\n"
- " -v verbose mode\n"
- " -W force password prompt (should happen automatically)\n"
- " -x skip restoration of access privileges (grant/revoke)\n"
- " -X use-set-session-authorization\n"
- " use SET SESSION AUTHORIZATION commands instead\n"
- " of reconnecting, if possible\n"
- ));
+ " -v verbose mode\n"
+ " -W force password prompt (should happen automatically)\n"
+ " -x skip restoration of access privileges (grant/revoke)\n"
+ " -X use-set-session-authorization\n"
+ " use SET SESSION AUTHORIZATION commands instead\n"
+ " of reconnecting, if possible\n"
+ ));
#endif
puts(gettext("If no input file name is supplied, then standard input is used.\n"));
puts(gettext("Report bugs to <pgsql-bugs@postgresql.org>."));
diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c
index 3e2b84e0bd..f63a01b90e 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.9 2001/09/06 04:57:29 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.10 2001/10/25 05:49:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,17 +22,17 @@ static void usage(void);
int
main(int argc, char **argv)
{
- char *p;
- int enc;
- bool be_only = FALSE;
+ char *p;
+ int enc;
+ bool be_only = FALSE;
if (argc < 2)
{
usage();
exit(1);
}
-
- if (strcmp(argv[1], "-b")==0)
+
+ if (strcmp(argv[1], "-b") == 0)
{
if (argc < 3)
{
@@ -44,14 +44,14 @@ main(int argc, char **argv)
}
else
p = argv[1];
-
+
if (p && *p && isdigit((unsigned char) *p))
{
/*
* Encoding number to name
*/
- char *name;
-
+ char *name;
+
enc = atoi(p);
if ((name = (char *) pg_encoding_to_char(enc)))
@@ -74,16 +74,16 @@ main(int argc, char **argv)
printf("%d\n", enc);
}
exit(0);
- }
+ }
exit(1);
}
static void
usage()
{
- fprintf(stderr,
- "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n"
- "options:"
- " -b check if encoding is valid for backend\n\n"
- );
+ fprintf(stderr,
+ "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n"
+ "options:"
+ " -b check if encoding is valid for backend\n\n"
+ );
}
diff --git a/src/bin/pg_passwd/pg_passwd.c b/src/bin/pg_passwd/pg_passwd.c
index 4c9790b677..831c382370 100644
--- a/src/bin/pg_passwd/pg_passwd.c
+++ b/src/bin/pg_passwd/pg_passwd.c
@@ -16,7 +16,6 @@
#include <crypt.h>
#else
extern char *crypt(const char *, const char *);
-
#endif
/*
@@ -289,7 +288,6 @@ prompt_for_password(char *prompt, char *password)
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
-
#endif
#ifdef HAVE_TERMIOS_H
diff --git a/src/bin/pgtclsh/pgtclAppInit.c b/src/bin/pgtclsh/pgtclAppInit.c
index 487e11eaf5..cfdda03a8b 100644
--- a/src/bin/pgtclsh/pgtclAppInit.c
+++ b/src/bin/pgtclsh/pgtclAppInit.c
@@ -23,7 +23,6 @@
#ifdef NEED_MATHERR
extern int matherr();
int *tclDummyMathPtr = (int *) matherr;
-
#endif
diff --git a/src/bin/pgtclsh/pgtkAppInit.c b/src/bin/pgtclsh/pgtkAppInit.c
index 3f3b43bf30..46b20edac7 100644
--- a/src/bin/pgtclsh/pgtkAppInit.c
+++ b/src/bin/pgtclsh/pgtkAppInit.c
@@ -23,7 +23,6 @@
#ifdef NEED_MATHERR
extern int matherr();
int *tclDummyMathPtr = (int *) matherr;
-
#endif
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index b6f8be54e8..004b8bacaf 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.60 2001/10/11 16:54:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.61 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -56,7 +56,7 @@ static backslashResult exec_command(const char *cmd,
enum option_type
{
- OT_NORMAL, OT_SQLID, OT_FILEPIPE
+ OT_NORMAL, OT_SQLID, OT_FILEPIPE
};
static char *scan_option(char **string, enum option_type type, char *quote, bool semicolon);
static char *unescape(const unsigned char *source, size_t len);
@@ -130,11 +130,10 @@ HandleSlashCmds(const char *line,
if (status == CMD_UNKNOWN)
{
-
/*
- * If the command was not recognized, try to parse it as a one-letter
- * command with immediately following argument (a still-supported,
- * but no longer encouraged, syntax).
+ * If the command was not recognized, try to parse it as a
+ * one-letter command with immediately following argument (a
+ * still-supported, but no longer encouraged, syntax).
*/
char new_cmd[2];
@@ -144,7 +143,10 @@ HandleSlashCmds(const char *line,
/* use line for options, because my_line was clobbered above */
status = exec_command(new_cmd, line + 1, &continue_parse, query_buf);
- /* continue_parse must be relative to my_line for calculation below */
+ /*
+ * continue_parse must be relative to my_line for calculation
+ * below
+ */
continue_parse += my_line - line;
#if 0 /* turned out to be too annoying */
@@ -262,8 +264,8 @@ exec_command(const char *cmd,
/* \cd */
else if (strcmp(cmd, "cd") == 0)
{
- char *opt = scan_option(&string, OT_NORMAL, NULL, true);
- char *dir;
+ char *opt = scan_option(&string, OT_NORMAL, NULL, true);
+ char *dir;
if (opt)
dir = opt;
@@ -279,12 +281,14 @@ exec_command(const char *cmd,
exit(EXIT_FAILURE);
}
dir = pw->pw_dir;
-#else /* WIN32 */
- /* On Windows, 'cd' without arguments prints the current
- directory, so if someone wants to code this here
- instead... */
+#else /* WIN32 */
+
+ /*
+ * On Windows, 'cd' without arguments prints the current
+ * directory, so if someone wants to code this here instead...
+ */
dir = "/";
-#endif /* WIN32 */
+#endif /* WIN32 */
}
if (chdir(dir) == -1)
@@ -315,6 +319,7 @@ exec_command(const char *cmd,
{
char *name;
bool show_verbose;
+
name = scan_option(&string, OT_SQLID, NULL, true);
show_verbose = strchr(cmd, '+') ? true : false;
@@ -359,7 +364,7 @@ exec_command(const char *cmd,
break;
case 'u':
success = describeUsers(name);
- break;
+ break;
default:
status = CMD_UNKNOWN;
}
@@ -401,7 +406,7 @@ exec_command(const char *cmd,
fout = pset.queryFout;
else
fout = stdout;
-
+
while ((value = scan_option(&string, OT_NORMAL, &quoted, false)))
{
if (!quoted && strcmp(value, "-n") == 0)
@@ -649,7 +654,6 @@ exec_command(const char *cmd,
}
else
{
-
/*
* Set variable to the concatenation of the arguments.
*/
@@ -866,7 +870,6 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
switch (options_string[pos])
{
-
/*
* Double quoted string
*/
@@ -937,7 +940,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
*string = options_string + jj + 1;
if (quote)
*quote = '"';
-
+
return return_val;
}
@@ -1119,10 +1122,13 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
return_val[token_end] = 0;
/* Strip any trailing semi-colons for some types */
- if (semicolon) {
- int i;
- for (i = strlen(return_val)-1; i && return_val[i]==';'; i--);
- if (i<strlen(return_val)-1) return_val[i+1]='\0';
+ if (semicolon)
+ {
+ int i;
+
+ for (i = strlen(return_val) - 1; i && return_val[i] == ';'; i--);
+ if (i < strlen(return_val) - 1)
+ return_val[i + 1] = '\0';
}
if (type == OT_SQLID)
@@ -1331,7 +1337,6 @@ do_connect(const char *new_dbname, const char *new_user)
}
else
{
-
/*
* we don't want unpredictable things to happen in scripting
* mode
@@ -1466,7 +1471,6 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
#ifndef WIN32
struct stat before,
after;
-
#endif
if (filename_arg)
@@ -1626,7 +1630,7 @@ _align2string(enum printFormat in)
{
switch (in)
{
- case PRINT_NOTHING:
+ case PRINT_NOTHING:
return "nothing";
break;
case PRINT_UNALIGNED:
diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h
index f719d2aa20..8141201eea 100644
--- a/src/bin/psql/command.h
+++ b/src/bin/psql/command.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.10 2000/04/12 17:16:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.11 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COMMAND_H
#define COMMAND_H
@@ -16,12 +16,12 @@
typedef enum _backslashResult
{
- CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */
- CMD_SEND, /* query complete; send off */
- CMD_SKIP_LINE, /* keep building query */
- CMD_TERMINATE, /* quit program */
- CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */
- CMD_ERROR /* the execution of the backslash command
+ CMD_UNKNOWN = 0,/* not done parsing yet (internal only) */
+ CMD_SEND, /* query complete; send off */
+ CMD_SKIP_LINE, /* keep building query */
+ CMD_TERMINATE, /* quit program */
+ CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */
+ CMD_ERROR /* the execution of the backslash command
* resulted in an error */
} backslashResult;
@@ -40,5 +40,4 @@ bool do_pset(const char *param,
const char *value,
printQueryOpt *popt,
bool quiet);
-
#endif /* COMMAND_H */
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 336d813878..0380f1f1bc 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.36 2001/10/18 21:57:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.37 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
@@ -176,7 +176,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
{
int length;
char *destination;
- FILE *termin, *termout;
+ FILE *termin,
+ *termout;
+
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
@@ -189,8 +191,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
prompt_state = true; /* disable SIGINT */
/*
- * Do not try to collapse these into one "w+" mode file.
- * Doesn't work on some platforms (eg, HPUX 10.20).
+ * Do not try to collapse these into one "w+" mode file. Doesn't work
+ * on some platforms (eg, HPUX 10.20).
*/
termin = fopen("/dev/tty", "r");
termout = fopen("/dev/tty", "w");
@@ -213,7 +215,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
tcsetattr(fileno(termin), TCSAFLUSH, &t);
}
#endif
-
+
if (prompt)
{
fputs(gettext(prompt), termout);
@@ -304,7 +306,6 @@ handle_sigint(SIGNAL_ARGS)
}
errno = save_errno; /* just in case the write changed it */
}
-
#endif /* not WIN32 */
@@ -314,7 +315,7 @@ handle_sigint(SIGNAL_ARGS)
* This is the way to send "backdoor" queries (those not directly entered
* by the user). It is subject to -E but not -e.
*/
-PGresult *
+PGresult *
PSQLexec(const char *query)
{
PGresult *res;
@@ -509,7 +510,7 @@ SendQuery(const char *query)
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."));
+ "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);
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index f9604bf90d..617e4d5a84 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.14 2001/10/03 21:58:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.15 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
@@ -13,28 +13,27 @@
#include "pqsignal.h"
#include "libpq-fe.h"
-extern char *xstrdup(const char *string);
+extern char *xstrdup(const char *string);
-extern bool setQFout(const char *fname);
+extern bool setQFout(const char *fname);
-extern void psql_error(const char *fmt, ...)
+extern void
+psql_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 1, 2)));
-extern void NoticeProcessor(void *arg, const char *message);
+extern void NoticeProcessor(void *arg, const char *message);
-extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
+extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
extern volatile bool cancel_pressed;
extern PGconn *cancelConn;
#ifndef WIN32
-extern void handle_sigint(SIGNAL_ARGS);
-
+extern void handle_sigint(SIGNAL_ARGS);
#endif /* not WIN32 */
-extern PGresult *PSQLexec(const char *query);
-
-extern bool SendQuery(const char *query);
+extern PGresult *PSQLexec(const char *query);
+extern bool SendQuery(const char *query);
#endif /* COMMON_H */
diff --git a/src/bin/psql/copy.h b/src/bin/psql/copy.h
index 66114fdbf4..3bda9913f3 100644
--- a/src/bin/psql/copy.h
+++ b/src/bin/psql/copy.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.9 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.10 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef COPY_H
#define COPY_H
@@ -19,5 +19,4 @@ bool do_copy(const char *args);
bool handleCopyOut(PGconn *conn, FILE *copystream);
bool handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt);
-
#endif
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 62fec530e9..6fefdf49da 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.40 2001/10/06 14:41:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.41 2001/10/25 05:49:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -54,7 +54,7 @@ describeAggregates(const char *name)
" obj_description(a.oid, 'pg_aggregate') as \"%s\"\n"
"FROM pg_aggregate a\n",
_("Name"), _("(all types)"),
- _("Data type"), _("Description") );
+ _("Data type"), _("Description"));
if (name)
{
@@ -98,7 +98,7 @@ describeFunctions(const char *name, bool verbose)
" p.proname as \"%s\",\n"
" oidvectortypes(p.proargtypes) as \"%s\"",
_("Result data type"), _("Name"),
- _("Argument data types") );
+ _("Argument data types"));
if (verbose)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
@@ -107,7 +107,7 @@ describeFunctions(const char *name, bool verbose)
" p.prosrc as \"%s\",\n"
" obj_description(p.oid, 'pg_proc') as \"%s\"",
_("Owner"), _("Language"),
- _("Source code"), _("Description") );
+ _("Source code"), _("Description"));
if (!verbose)
strcat(buf,
@@ -155,7 +155,7 @@ describeTypes(const char *name, bool verbose)
snprintf(buf, sizeof(buf),
"SELECT format_type(t.oid, NULL) AS \"%s\",\n",
- _("Name") );
+ _("Name"));
if (verbose)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
" t.typname AS \"%s\",\n"
@@ -163,10 +163,10 @@ describeTypes(const char *name, bool verbose)
" THEN CAST('var' AS text)\n"
" ELSE CAST(t.typlen AS text)\n"
" END AS \"%s\",\n",
- _("Internal name"), _("Size") );
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+ _("Internal name"), _("Size"));
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
" obj_description(t.oid, 'pg_type') as \"%s\"\n",
- _("Description") );
+ _("Description"));
/*
* do not include array types (start with underscore), do not include
@@ -218,7 +218,7 @@ describeOperators(const char *name)
"FROM pg_proc p, pg_operator o\n"
"WHERE RegprocToOid(o.oprcode) = p.oid\n",
_("Name"), _("Left arg type"), _("Right arg type"),
- _("Result type"), _("Description") );
+ _("Result type"), _("Description"));
if (name)
{
strcat(buf, " AND o.oprname = '");
@@ -265,10 +265,10 @@ listAllDbs(bool desc)
#endif
if (desc)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
- ",\n obj_description(d.oid, 'pg_database') as \"%s\"",
+ ",\n obj_description(d.oid, 'pg_database') as \"%s\"",
_("Description"));
strcat(buf,
- "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n"
+ "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n"
"ORDER BY 1;");
res = PSQLexec(buf);
@@ -347,32 +347,32 @@ objectDescription(const char *object)
"SELECT DISTINCT tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n"
"FROM (\n"
- /* Aggregate descriptions */
+ /* Aggregate descriptions */
" SELECT a.oid as oid, a.tableoid as tableoid,\n"
- " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_aggregate a\n"
- /* Function descriptions (except in/outs for datatypes) */
+ /* Function descriptions (except in/outs for datatypes) */
"UNION ALL\n"
" SELECT p.oid as oid, p.tableoid as tableoid,\n"
- " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_proc p\n"
- " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n"
+ " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n"
- /* Operator descriptions (must get comment via associated function) */
+ /* Operator descriptions (must get comment via associated function) */
"UNION ALL\n"
" SELECT RegprocToOid(o.oprcode) as oid,\n"
" (SELECT oid FROM pg_class WHERE relname = 'pg_proc') as tableoid,\n"
- " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_operator o\n"
- /* Type description */
+ /* Type description */
"UNION ALL\n"
" SELECT t.oid as oid, t.tableoid as tableoid,\n"
- " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n"
+ " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n"
" FROM pg_type t\n"
- /* Relation (tables, views, indexes, sequences) descriptions */
+ /* Relation (tables, views, indexes, sequences) descriptions */
"UNION ALL\n"
" SELECT c.oid as oid, c.tableoid as tableoid,\n"
" CAST(c.relname AS text) as name,\n"
@@ -381,17 +381,17 @@ objectDescription(const char *object)
" AS text) as object\n"
" FROM pg_class c\n"
- /* Rule description (ignore rules for views) */
+ /* Rule description (ignore rules for views) */
"UNION ALL\n"
" SELECT r.oid as oid, r.tableoid as tableoid,\n"
- " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_rewrite r\n"
" WHERE r.rulename !~ '^_RET'\n"
- /* Trigger description */
+ /* Trigger description */
"UNION ALL\n"
" SELECT t.oid as oid, t.tableoid as tableoid,\n"
- " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n"
+ " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n"
" FROM pg_trigger t\n"
") AS tt,\n"
@@ -664,10 +664,10 @@ describeTableDetails(const char *name, bool desc)
error = true;
else
{
- char *indisunique = PQgetvalue(result, 0, 0);
- char *indisprimary = PQgetvalue(result, 0, 1);
- char *indamname = PQgetvalue(result, 0, 2);
- char *indpred = PQgetvalue(result, 0, 3);
+ char *indisunique = PQgetvalue(result, 0, 0);
+ char *indisprimary = PQgetvalue(result, 0, 1);
+ char *indamname = PQgetvalue(result, 0, 2);
+ char *indpred = PQgetvalue(result, 0, 3);
footers = xmalloc(3 * sizeof(*footers));
/* XXX This construction is poorly internationalized. */
@@ -704,18 +704,18 @@ describeTableDetails(const char *name, bool desc)
else if (tableinfo.relkind == 'r')
{
/* Footer information about a table */
- PGresult *result1 = NULL,
- *result2 = NULL,
- *result3 = NULL,
- *result4 = NULL,
- *result5 = NULL,
- *result6 = NULL;
+ PGresult *result1 = NULL,
+ *result2 = NULL,
+ *result3 = NULL,
+ *result4 = NULL,
+ *result5 = NULL,
+ *result6 = NULL;
int index_count = 0,
- primary_count = 0,
- unique_count = 0,
- constr_count = 0,
- rule_count = 0,
- trigger_count = 0;
+ primary_count = 0,
+ unique_count = 0,
+ constr_count = 0,
+ rule_count = 0,
+ trigger_count = 0;
int count_footers = 0;
/* count indexes */
@@ -724,7 +724,7 @@ describeTableDetails(const char *name, bool desc)
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND NOT i.indisunique ORDER BY c2.relname",
+ "AND NOT i.indisunique ORDER BY c2.relname",
name);
result1 = PSQLexec(buf);
if (!result1)
@@ -739,7 +739,7 @@ describeTableDetails(const char *name, bool desc)
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND i.indisprimary AND i.indisunique ORDER BY c2.relname",
+ "AND i.indisprimary AND i.indisunique ORDER BY c2.relname",
name);
result5 = PSQLexec(buf);
if (!result5)
@@ -754,7 +754,7 @@ describeTableDetails(const char *name, bool desc)
sprintf(buf, "SELECT c2.relname\n"
"FROM pg_class c, pg_class c2, pg_index i\n"
"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
- "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname",
+ "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname",
name);
result6 = PSQLexec(buf);
if (!result6)
@@ -808,18 +808,18 @@ describeTableDetails(const char *name, bool desc)
}
footers = xmalloc((index_count + primary_count + unique_count +
- constr_count + rule_count + trigger_count + 1)
- * sizeof(*footers));
+ constr_count + rule_count + trigger_count + 1)
+ * sizeof(*footers));
/* print indexes */
for (i = 0; i < index_count; i++)
{
- char *s = _("Indexes");
+ char *s = _("Indexes");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result1, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result1, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result1, i, 0));
if (i < index_count - 1)
strcat(buf, ",");
@@ -829,12 +829,12 @@ describeTableDetails(const char *name, bool desc)
/* print primary keys */
for (i = 0; i < primary_count; i++)
{
- char *s = _("Primary key");
+ char *s = _("Primary key");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result5, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result5, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result5, i, 0));
if (i < primary_count - 1)
strcat(buf, ",");
@@ -844,12 +844,12 @@ describeTableDetails(const char *name, bool desc)
/* print unique constraints */
for (i = 0; i < unique_count; i++)
{
- char *s = _("Unique keys");
+ char *s = _("Unique keys");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result6, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result6, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result6, i, 0));
if (i < unique_count - 1)
strcat(buf, ",");
@@ -859,26 +859,26 @@ describeTableDetails(const char *name, bool desc)
/* print constraints */
for (i = 0; i < constr_count; i++)
{
- char *s = _("Check constraints");
+ char *s = _("Check constraints");
if (i == 0)
snprintf(buf, sizeof(buf), _("%s: \"%s\" %s"), s,
- PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
+ PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
else
- snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int)strlen(s), "",
- PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
+ snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int) strlen(s), "",
+ PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0));
footers[count_footers++] = xstrdup(buf);
}
/* print rules */
for (i = 0; i < rule_count; i++)
{
- char *s = _("Rules");
+ char *s = _("Rules");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result3, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result3, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result3, i, 0));
if (i < rule_count - 1)
strcat(buf, ",");
@@ -888,12 +888,12 @@ describeTableDetails(const char *name, bool desc)
/* print triggers */
for (i = 0; i < trigger_count; i++)
{
- char *s = _("Triggers");
+ char *s = _("Triggers");
if (i == 0)
snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result4, i, 0));
else
- snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result4, i, 0));
+ snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result4, i, 0));
if (i < trigger_count - 1)
strcat(buf, ",");
@@ -944,16 +944,16 @@ describeTableDetails(const char *name, bool desc)
*/
bool
-describeUsers (const char *name)
+describeUsers(const char *name)
{
char buf[384 + REGEXP_CUTOFF];
PGresult *res;
printQueryOpt myopt = pset.popt;
-
+
snprintf(buf, sizeof(buf),
"SELECT u.usename AS \"%s\",\n"
" u.usesysid AS \"%s\",\n"
- " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n"
+ " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n"
" WHEN u.usesuper THEN CAST('%s' AS text)\n"
" WHEN u.usecreatedb THEN CAST('%s' AS text)\n"
" ELSE CAST('' AS text)\n"
@@ -962,7 +962,7 @@ describeUsers (const char *name)
_("User name"), _("User ID"),
_("superuser, create database"),
_("superuser"), _("create database"),
- _("Attributes") );
+ _("Attributes"));
if (name)
{
strcat(buf, "WHERE u.usename ~ '^");
@@ -1033,7 +1033,7 @@ listTables(const char *infotype, const char *name, bool desc)
",\n obj_description(c.oid, 'pg_class') as \"%s\"",
_("Description"));
strcat(buf,
- "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n"
+ "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n"
"WHERE c.relkind IN (");
if (showTables)
strcat(buf, "'r',");
@@ -1045,7 +1045,7 @@ listTables(const char *infotype, const char *name, bool desc)
strcat(buf, "'S',");
if (showSystem && showTables)
strcat(buf, "'s',");
- strcat(buf, "''"); /* dummy */
+ strcat(buf, "''"); /* dummy */
strcat(buf, ")\n");
if (showSystem)
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 98821fbed0..2fc05f9d32 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.10 2001/05/09 17:29:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.11 2001/10/25 05:49:53 momjian Exp $
*/
#ifndef DESCRIBE_H
#define DESCRIBE_H
@@ -23,7 +23,7 @@ bool describeTypes(const char *name, bool verbose);
bool describeOperators(const char *name);
/* \du */
-bool describeUsers(const char *name);
+bool describeUsers(const char *name);
/* \z (or \dp) */
bool permissionsList(const char *name);
@@ -39,5 +39,4 @@ bool listAllDbs(bool desc);
/* \dt, \di, \ds, \dS, etc. */
bool listTables(const char *infotype, const char *name, bool desc);
-
#endif /* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 46d5794afa..b4614627a7 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.41 2001/06/11 18:23:33 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.42 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "help.h"
@@ -54,7 +54,6 @@ usage(void)
#ifndef WIN32
struct passwd *pw = NULL;
-
#endif
/* Find default user, in case we need it. */
@@ -132,10 +131,10 @@ usage(void)
puts(_(" -X Do not read startup file (~/.psqlrc)"));
puts(_(
- "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n"
- "(for SQL commands) from within psql, or consult the psql section in\n"
- "the PostgreSQL documentation.\n\n"
- "Report bugs to <pgsql-bugs@postgresql.org>."));
+ "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n"
+ "(for SQL commands) from within psql, or consult the psql section in\n"
+ "the PostgreSQL documentation.\n\n"
+ "Report bugs to <pgsql-bugs@postgresql.org>."));
}
@@ -152,7 +151,6 @@ struct winsize
int ws_row;
int ws_col;
};
-
#endif
void
@@ -193,7 +191,7 @@ slashUsage(void)
/* if you add/remove a line here, change the row test above */
fprintf(fout, _(" \\a toggle between unaligned and aligned output mode\n"));
fprintf(fout, _(" \\c[onnect] [DBNAME|- [USER]]\n"
- " connect to new database (currently \"%s\")\n"),
+ " connect to new database (currently \"%s\")\n"),
PQdb(pset.db));
fprintf(fout, _(" \\C TITLE set table title\n"));
fprintf(fout, _(" \\cd [DIRNAME] change the current working directory\n"));
@@ -334,5 +332,5 @@ print_copyright(void)
"PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n"
"AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n"
"SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
- );
+ );
}
diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h
index 47fed65b41..36cf326a01 100644
--- a/src/bin/psql/help.h
+++ b/src/bin/psql/help.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.6 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.7 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef HELP_H
#define HELP_H
@@ -15,5 +15,4 @@ void slashUsage(void);
void helpSQL(const char *topic);
void print_copyright(void);
-
#endif
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 17cfee41ae..32872e9d71 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.17 2001/09/11 23:08:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.18 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
@@ -19,18 +19,17 @@
/* (of course there is no runtime command for doing that :) */
#ifdef USE_READLINE
static bool useReadline;
-
#endif
#ifdef USE_HISTORY
static bool useHistory;
-
#endif
#ifdef HAVE_ATEXIT
-static void finishInput(void);
+static void finishInput(void);
+
#else
/* designed for use with on_exit() */
-static void finishInput(int, void*);
+static void finishInput(int, void *);
#endif
@@ -48,7 +47,6 @@ gets_interactive(char *prompt)
#ifdef USE_HISTORY
const char *var;
static char *prev_hist = NULL;
-
#endif
#ifdef USE_READLINE
diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h
index ff9deade1d..86caad4f0e 100644
--- a/src/bin/psql/input.h
+++ b/src/bin/psql/input.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.12 2001/09/11 23:08:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.13 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef INPUT_H
#define INPUT_H
@@ -39,5 +39,4 @@ char *gets_fromFile(FILE *source);
void initializeInput(int flags);
bool saveHistory(char *fname);
-
#endif /* INPUT_H */
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c
index 5fe95a4343..9aba63767e 100644
--- a/src/bin/psql/large_obj.c
+++ b/src/bin/psql/large_obj.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.17 2001/10/04 22:39:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.18 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
@@ -194,9 +194,9 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
/* XXX ought to replace this with some kind of COMMENT command */
if (comment_arg && pset.issuper)
{
- char *cmdbuf;
- char *bufptr;
- int slen = strlen(comment_arg);
+ char *cmdbuf;
+ char *bufptr;
+ int slen = strlen(comment_arg);
cmdbuf = malloc(slen * 2 + 256);
if (!cmdbuf)
@@ -210,7 +210,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
}
sprintf(cmdbuf,
"INSERT INTO pg_description VALUES ('%u', "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject'),"
+ "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject'),"
" 0, '", loid);
bufptr = cmdbuf + strlen(cmdbuf);
for (i = 0; i < slen; i++)
diff --git a/src/bin/psql/large_obj.h b/src/bin/psql/large_obj.h
index b8fcfde04d..85e708b1a4 100644
--- a/src/bin/psql/large_obj.h
+++ b/src/bin/psql/large_obj.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.8 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef LARGE_OBJ_H
#define LARGE_OBJ_H
@@ -12,5 +12,4 @@ bool do_lo_export(const char *loid_arg, const char *filename_arg);
bool do_lo_import(const char *filename_arg, const char *comment_arg);
bool do_lo_unlink(const char *loid_arg);
bool do_lo_list(void);
-
#endif /* LARGE_OBJ_H */
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 3c8e8ec268..f728e4df1f 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.40 2001/06/02 18:25:18 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.41 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -101,7 +101,6 @@ MainLoop(FILE *source)
{
if (!pset.cur_cmd_interactive)
{
-
/*
* You get here if you stopped a script with Ctrl-C and a
* query cancel was issued. In that case we don't do the
@@ -137,14 +136,15 @@ MainLoop(FILE *source)
}
}
- /* establish the control-C handler only after main_loop_jmp is ready */
- pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
-
+ /*
+ * establish the control-C handler only after main_loop_jmp is
+ * ready
+ */
+ pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
#endif /* not WIN32 */
if (slashCmdStatus == CMD_NEWEDIT)
{
-
/*
* just returned from editing the line? then just copy to the
* input buffer
@@ -393,7 +393,7 @@ MainLoop(FILE *source)
line = new;
len = strlen(new);
- goto rescan;/* reparse the just substituted */
+ goto rescan; /* reparse the just substituted */
}
else
{
@@ -410,7 +410,6 @@ MainLoop(FILE *source)
/* is there anything else on the line? */
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
-
/*
* insert a cosmetic newline, if this is not the first
* line in the buffer
@@ -454,7 +453,6 @@ MainLoop(FILE *source)
/* is there anything else on the line for the command? */
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
-
/*
* insert a cosmetic newline, if this is not the first
* line in the buffer
@@ -563,8 +561,8 @@ MainLoop(FILE *source)
/*
* Reset SIGINT handler because main_loop_jmp will be invalid as soon
* as we exit this routine. If there is an outer MainLoop instance,
- * it will re-enable ^C catching as soon as it gets back to the top
- * of its loop and resets main_loop_jmp to point to itself.
+ * it will re-enable ^C catching as soon as it gets back to the top of
+ * its loop and resets main_loop_jmp to point to itself.
*/
#ifndef WIN32
pqsignal(SIGINT, SIG_DFL);
diff --git a/src/bin/psql/mainloop.h b/src/bin/psql/mainloop.h
index cc832f194b..55e0a65fb1 100644
--- a/src/bin/psql/mainloop.h
+++ b/src/bin/psql/mainloop.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.10 2001/02/10 02:31:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.11 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef MAINLOOP_H
#define MAINLOOP_H
@@ -14,9 +14,7 @@
#include <setjmp.h>
extern sigjmp_buf main_loop_jmp;
-
#endif
int MainLoop(FILE *source);
-
#endif /* MAINLOOP_H */
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
index 986861fe4a..1ca86f0e50 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.1 2001/10/15 01:25:10 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.2 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
@@ -26,21 +26,23 @@
* original available at : http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
*/
-struct mbinterval {
+struct mbinterval
+{
unsigned short first;
unsigned short last;
};
/* auxiliary function for binary search in interval table */
static int
-mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
+mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max)
{
- int min = 0;
- int mid;
+ int min = 0;
+ int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
- while (max >= min) {
+ while (max >= min)
+ {
mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
@@ -57,28 +59,28 @@ mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
/* The following functions define the column width of an ISO 10646
* character as follows:
*
- * - The null character (U+0000) has a column width of 0.
+ * - The null character (U+0000) has a column width of 0.
*
- * - Other C0/C1 control characters and DEL will lead to a return
- * value of -1.
+ * - Other C0/C1 control characters and DEL will lead to a return
+ * value of -1.
*
- * - Non-spacing and enclosing combining characters (general
- * category code Mn or Me in the Unicode database) have a
- * column width of 0.
+ * - Non-spacing and enclosing combining characters (general
+ * category code Mn or Me in the Unicode database) have a
+ * column width of 0.
*
- * - Other format characters (general category code Cf in the Unicode
- * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
+ * - Other format characters (general category code Cf in the Unicode
+ * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
*
- * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
- * have a column width of 0.
+ * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
+ * have a column width of 0.
*
- * - Spacing characters in the East Asian Wide (W) or East Asian
- * FullWidth (F) category as defined in Unicode Technical
- * Report #11 have a column width of 2.
+ * - Spacing characters in the East Asian Wide (W) or East Asian
+ * FullWidth (F) category as defined in Unicode Technical
+ * Report #11 have a column width of 2.
*
- * - All remaining characters (including all printable
- * ISO 8859-1 and WGL4 characters, Unicode control characters,
- * etc.) have a column width of 1.
+ * - All remaining characters (including all printable
+ * ISO 8859-1 and WGL4 characters, Unicode control characters,
+ * etc.) have a column width of 1.
*
* This implementation assumes that wchar_t characters are encoded
* in ISO 10646.
@@ -89,68 +91,69 @@ ucs_wcwidth(pg_wchar ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct mbinterval combining[] = {
- { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
- { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
- { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
- { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
- { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
- { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
- { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
- { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
- { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
- { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
- { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
- { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
- { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
- { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
- { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
- { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
- { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
- { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
- { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
- { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
- { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
- { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
- { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
- { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
- { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
- { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
- { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
- { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
- { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
- { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
- { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
- { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
- { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
- { 0xFFF9, 0xFFFB }
+ {0x0300, 0x034E}, {0x0360, 0x0362}, {0x0483, 0x0486},
+ {0x0488, 0x0489}, {0x0591, 0x05A1}, {0x05A3, 0x05B9},
+ {0x05BB, 0x05BD}, {0x05BF, 0x05BF}, {0x05C1, 0x05C2},
+ {0x05C4, 0x05C4}, {0x064B, 0x0655}, {0x0670, 0x0670},
+ {0x06D6, 0x06E4}, {0x06E7, 0x06E8}, {0x06EA, 0x06ED},
+ {0x070F, 0x070F}, {0x0711, 0x0711}, {0x0730, 0x074A},
+ {0x07A6, 0x07B0}, {0x0901, 0x0902}, {0x093C, 0x093C},
+ {0x0941, 0x0948}, {0x094D, 0x094D}, {0x0951, 0x0954},
+ {0x0962, 0x0963}, {0x0981, 0x0981}, {0x09BC, 0x09BC},
+ {0x09C1, 0x09C4}, {0x09CD, 0x09CD}, {0x09E2, 0x09E3},
+ {0x0A02, 0x0A02}, {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42},
+ {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A70, 0x0A71},
+ {0x0A81, 0x0A82}, {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5},
+ {0x0AC7, 0x0AC8}, {0x0ACD, 0x0ACD}, {0x0B01, 0x0B01},
+ {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43},
+ {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B82, 0x0B82},
+ {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD}, {0x0C3E, 0x0C40},
+ {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
+ {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD},
+ {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D}, {0x0DCA, 0x0DCA},
+ {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31},
+ {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1},
+ {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, {0x0EC8, 0x0ECD},
+ {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, {0x0F37, 0x0F37},
+ {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, {0x0F80, 0x0F84},
+ {0x0F86, 0x0F87}, {0x0F90, 0x0F97}, {0x0F99, 0x0FBC},
+ {0x0FC6, 0x0FC6}, {0x102D, 0x1030}, {0x1032, 0x1032},
+ {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059},
+ {0x1160, 0x11FF}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6},
+ {0x17C9, 0x17D3}, {0x180B, 0x180E}, {0x18A9, 0x18A9},
+ {0x200B, 0x200F}, {0x202A, 0x202E}, {0x206A, 0x206F},
+ {0x20D0, 0x20E3}, {0x302A, 0x302F}, {0x3099, 0x309A},
+ {0xFB1E, 0xFB1E}, {0xFE20, 0xFE23}, {0xFEFF, 0xFEFF},
+ {0xFFF9, 0xFFFB}
};
/* test for 8-bit control characters */
- if (ucs == 0) {
+ if (ucs == 0)
return 0;
- }
- if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) {
+ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff)
return -1;
- }
/* binary search in table of non-spacing characters */
if (mbbisearch(ucs, combining,
- sizeof(combining) / sizeof(struct mbinterval) - 1)) {
+ sizeof(combining) / sizeof(struct mbinterval) - 1))
return 0;
- }
- /* if we arrive here, ucs is not a combining or C0/C1 control character */
+ /*
+ * if we arrive here, ucs is not a combining or C0/C1 control
+ * character
+ */
- return 1 +
+ return 1 +
(ucs >= 0x1100 &&
- (ucs <= 0x115f || /* Hangul Jamo init. consonants */
+ (ucs <= 0x115f || /* Hangul Jamo init. consonants */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
- ucs != 0x303f) || /* CJK ... Yi */
- (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
- (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
- (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
- (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
+ ucs != 0x303f) || /* CJK ... Yi */
+ (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
+ (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility
+ * Ideographs */
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
+ (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
(ucs >= 0x20000 && ucs <= 0x2ffff)));
}
@@ -158,28 +161,32 @@ ucs_wcwidth(pg_wchar ucs)
pg_wchar
utf2ucs(const unsigned char *c)
{
- /* one char version of pg_utf2wchar_with_len.
- * no control here, c must point to a large enough string
+ /*
+ * one char version of pg_utf2wchar_with_len. no control here, c must
+ * point to a large enough string
*/
- if ((*c & 0x80) == 0) {
- return (pg_wchar)c[0];
- }
- else if ((*c & 0xe0) == 0xc0) {
- return (pg_wchar)(((c[0] & 0x1f) << 6) |
- (c[1] & 0x3f));
+ if ((*c & 0x80) == 0)
+ return (pg_wchar) c[0];
+ else if ((*c & 0xe0) == 0xc0)
+ {
+ return (pg_wchar) (((c[0] & 0x1f) << 6) |
+ (c[1] & 0x3f));
}
- else if ((*c & 0xf0) == 0xe0) {
- return (pg_wchar)(((c[0] & 0x0f) << 12) |
- ((c[1] & 0x3f) << 6) |
- (c[2] & 0x3f));
+ else if ((*c & 0xf0) == 0xe0)
+ {
+ return (pg_wchar) (((c[0] & 0x0f) << 12) |
+ ((c[1] & 0x3f) << 6) |
+ (c[2] & 0x3f));
}
- else if ((*c & 0xf0) == 0xf0) {
- return (pg_wchar)(((c[0] & 0x07) << 18) |
- ((c[1] & 0x3f) << 12) |
- ((c[2] & 0x3f) << 6) |
- (c[3] & 0x3f));
+ else if ((*c & 0xf0) == 0xf0)
+ {
+ return (pg_wchar) (((c[0] & 0x07) << 18) |
+ ((c[1] & 0x3f) << 12) |
+ ((c[2] & 0x3f) << 6) |
+ (c[3] & 0x3f));
}
- else {
+ else
+ {
/* that is an invalid code on purpose */
return 0xffffffff;
}
@@ -190,14 +197,15 @@ utf2ucs(const unsigned char *c)
static int
mb_utf_wcswidth(unsigned char *pwcs, int len)
{
- int w, l = 0;
- int width = 0;
+ int w,
+ l = 0;
+ int width = 0;
- for (;*pwcs && len > 0; pwcs+=l) {
+ for (; *pwcs && len > 0; pwcs += l)
+ {
l = pg_utf_mblen(pwcs);
- if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) {
+ if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0))
return width;
- }
len -= l;
width += w;
}
@@ -207,91 +215,95 @@ mb_utf_wcswidth(unsigned char *pwcs, int len)
static int
utf_charcheck(const unsigned char *c)
{
- /* Unicode 3.1 compliant validation :
- * for each category, it checks the combination of each byte to make sur
- * it maps to a valid range. It also returns -1 for the following UCS values:
- * ucs > 0x10ffff
- * ucs & 0xfffe = 0xfffe
- * 0xfdd0 < ucs < 0xfdef
- * ucs & 0xdb00 = 0xd800 (surrogates)
+ /*
+ * Unicode 3.1 compliant validation : for each category, it checks the
+ * combination of each byte to make sur it maps to a valid range. It
+ * also returns -1 for the following UCS values: ucs > 0x10ffff ucs &
+ * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800
+ * (surrogates)
*/
- if ((*c & 0x80) == 0) {
+ if ((*c & 0x80) == 0)
return 1;
- }
- else if ((*c & 0xe0) == 0xc0) {
+ else if ((*c & 0xe0) == 0xc0)
+ {
/* two-byte char */
- if(((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) {
+ if (((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01))
return 2;
- }
return -1;
}
- else if ((*c & 0xf0) == 0xe0) {
+ else if ((*c & 0xf0) == 0xe0)
+ {
/* three-byte char */
if (((c[1] & 0xc0) == 0x80) &&
(((c[0] & 0x0f) != 0x00) || ((c[1] & 0x20) == 0x20)) &&
- ((c[2] & 0xc0) == 0x80)) {
- int z = c[0] & 0x0f;
- int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f);
- int lx = yx & 0x7f;
+ ((c[2] & 0xc0) == 0x80))
+ {
+ int z = c[0] & 0x0f;
+ int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f);
+ int lx = yx & 0x7f;
/* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */
if (((z == 0x0f) &&
(((yx & 0xffe) == 0xffe) ||
- (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
- ((z == 0x0d) && ((yx & 0xb00) == 0x800))) {
+ (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
+ ((z == 0x0d) && ((yx & 0xb00) == 0x800)))
return -1;
- }
return 3;
}
return -1;
}
- else if ((*c & 0xf8) == 0xf0) {
- int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4);
+ else if ((*c & 0xf8) == 0xf0)
+ {
+ int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4);
/* four-byte char */
if (((c[1] & 0xc0) == 0x80) &&
(u > 0x00) && (u <= 0x10) &&
- ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) {
+ ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80))
+ {
/* test for 0xzzzzfffe/0xzzzzfffff */
if (((c[1] & 0x0f) == 0x0f) && ((c[2] & 0x3f) == 0x3f) &&
- ((c[3] & 0x3e) == 0x3e)) {
+ ((c[3] & 0x3e) == 0x3e))
return -1;
- }
return 4;
}
return -1;
}
return -1;
}
-
+
static unsigned char *
mb_utf_validate(unsigned char *pwcs)
{
- int l = 0;
+ int l = 0;
unsigned char *p = pwcs;
unsigned char *p0 = pwcs;
- while( *pwcs ) {
- if ((l = utf_charcheck(pwcs)) > 0) {
- if (p != pwcs) {
- int i;
- for( i = 0; i < l; i++) {
+ while (*pwcs)
+ {
+ if ((l = utf_charcheck(pwcs)) > 0)
+ {
+ if (p != pwcs)
+ {
+ int i;
+
+ for (i = 0; i < l; i++)
*p++ = *pwcs++;
- }
}
- else {
+ else
+ {
pwcs += l;
p += l;
}
}
- else {
+ else
+ {
/* we skip the char */
pwcs++;
}
}
- if (p != pwcs) {
+ if (p != pwcs)
*p = '\0';
- }
return p0;
}
@@ -300,35 +312,41 @@ mb_utf_validate(unsigned char *pwcs)
*/
int
-pg_wcswidth(unsigned char *pwcs, int len) {
- if (pset.encoding == PG_UTF8) {
+pg_wcswidth(unsigned char *pwcs, int len)
+{
+ if (pset.encoding == PG_UTF8)
return mb_utf_wcswidth(pwcs, len);
- }
- else {
- /* obviously, other encodings may want to fix this, but I don't know them
- * myself, unfortunately.
+ else
+ {
+ /*
+ * obviously, other encodings may want to fix this, but I don't
+ * know them myself, unfortunately.
*/
return len;
}
}
unsigned char *
-mbvalidate(unsigned char *pwcs) {
- if (pset.encoding == PG_UTF8) {
+mbvalidate(unsigned char *pwcs)
+{
+ if (pset.encoding == PG_UTF8)
return mb_utf_validate(pwcs);
- }
- else {
- /* other encodings needing validation should add their own routines here
+ else
+ {
+ /*
+ * other encodings needing validation should add their own
+ * routines here
*/
return pwcs;
}
}
-#else /* !MULTIBYTE */
+
+#else /* !MULTIBYTE */
/* in single-byte environment, all cells take 1 column */
-int pg_wcswidth(unsigned char *pwcs, int len) {
+int
+pg_wcswidth(unsigned char *pwcs, int len)
+{
return len;
}
#endif
-
-
diff --git a/src/bin/psql/mbprint.h b/src/bin/psql/mbprint.h
index adf92f5305..4d0cab1b9d 100644
--- a/src/bin/psql/mbprint.h
+++ b/src/bin/psql/mbprint.h
@@ -1,4 +1,4 @@
-/* $Id: mbprint.h,v 1.1 2001/10/15 04:52:59 ishii Exp $ */
+/* $Id: mbprint.h,v 1.2 2001/10/25 05:49:54 momjian Exp $ */
#ifndef MBPRINT_H
#define MBPRINT_H
@@ -7,12 +7,10 @@
#include "mb/pg_wchar.h"
-pg_wchar utf2ucs(const unsigned char *c);
+pg_wchar utf2ucs(const unsigned char *c);
unsigned char *mbvalidate(unsigned char *pwcs);
-#endif /* MULTIBYTE */
-
-int pg_wcswidth(unsigned char *pwcs, int len);
-
-#endif /* MBPRINT_H */
+#endif /* MULTIBYTE */
+int pg_wcswidth(unsigned char *pwcs, int len);
+#endif /* MBPRINT_H */
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index c3f71951ba..97ca96d660 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.22 2001/10/15 01:25:10 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "print.h"
@@ -218,7 +218,8 @@ print_aligned_text(const char *title, const char *const * headers,
#ifdef MULTIBYTE
unsigned int cell_count = 0;
- unsigned int *head_w, *cell_w;
+ unsigned int *head_w,
+ *cell_w;
#endif
unsigned int i,
@@ -240,38 +241,39 @@ print_aligned_text(const char *title, const char *const * headers,
#ifdef MULTIBYTE
head_w = calloc(col_count, sizeof(*head_w));
- if (!head_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!head_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
/* count rows */
- for (ptr = cells; *ptr; ptr++) {
- cell_count++;
- }
+ for (ptr = cells; *ptr; ptr++)
+ cell_count++;
cell_w = calloc(cell_count, sizeof(*cell_w));
- if (!cell_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!cell_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
#endif
-
+
/* calc column widths */
- for (i = 0; i < col_count; i++) {
- if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > widths[i]) {
+ for (i = 0; i < col_count; i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > widths[i])
widths[i] = tmp;
- }
#ifdef MULTIBYTE
head_w[i] = tmp;
#endif
}
- for (i = 0, ptr = cells; *ptr; ptr++, i++) {
- if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > widths[i % col_count]) {
+ for (i = 0, ptr = cells; *ptr; ptr++, i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > widths[i % col_count])
widths[i % col_count] = tmp;
- }
#ifdef MULTIBYTE
cell_w[i] = tmp;
#endif
@@ -287,14 +289,14 @@ print_aligned_text(const char *title, const char *const * headers,
total_w += widths[i];
/* print title */
- if (title && !opt_barebones) {
- int tlen;
- if ((tlen = pg_wcswidth((unsigned char *)title, strlen(title))) >= total_w) {
+ if (title && !opt_barebones)
+ {
+ int tlen;
+
+ if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w)
fprintf(fout, "%s\n", title);
- }
- else {
+ else
fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title);
- }
}
/* print headers */
@@ -310,16 +312,17 @@ print_aligned_text(const char *title, const char *const * headers,
for (i = 0; i < col_count; i++)
{
- int nbspace;
+ int nbspace;
+
#ifdef MULTIBYTE
- nbspace = widths[i] - head_w[i];
+ nbspace = widths[i] - head_w[i];
#else
- nbspace = widths[i] - strlen(headers[i]);
+ nbspace = widths[i] - strlen(headers[i]);
#endif
/* centered */
- fprintf(fout, "%-*s%s%-*s",
- nbspace / 2, "", headers[i], (nbspace+1) / 2, "");
+ fprintf(fout, "%-*s%s%-*s",
+ nbspace / 2, "", headers[i], (nbspace + 1) / 2, "");
if (i < col_count - 1)
{
@@ -352,10 +355,11 @@ print_aligned_text(const char *title, const char *const * headers,
}
/* content */
- if (opt_align[(i) % col_count] == 'r') {
+ if (opt_align[(i) % col_count] == 'r')
+ {
#ifdef MULTIBYTE
- fprintf(fout, "%*s%s",
- widths[i % col_count] - cell_w[i], "", cells[i] );
+ fprintf(fout, "%*s%s",
+ widths[i % col_count] - cell_w[i], "", cells[i]);
#else
fprintf(fout, "%*s", widths[i % col_count], cells[i]);
#endif
@@ -364,10 +368,11 @@ print_aligned_text(const char *title, const char *const * headers,
{
if ((i + 1) % col_count == 0 && opt_border != 2)
fputs(cells[i], fout);
- else {
+ else
+ {
#ifdef MULTIBYTE
- fprintf(fout, "%-s%*s", cells[i],
- widths[i % col_count] - cell_w[i], "" );
+ fprintf(fout, "%-s%*s", cells[i],
+ widths[i % col_count] - cell_w[i], "");
#else
fprintf(fout, "%-*s", widths[i % col_count], cells[i]);
#endif
@@ -425,9 +430,11 @@ print_aligned_vertical(const char *title, const char *const * headers,
hwidth = 0,
dwidth = 0;
char *divider;
+
#ifdef MULTIBYTE
unsigned int cell_count = 0;
- unsigned int *cell_w,*head_w;
+ unsigned int *cell_w,
+ *head_w;
#endif
if (cells[0] == NULL)
@@ -438,36 +445,36 @@ print_aligned_vertical(const char *title, const char *const * headers,
#ifdef MULTIBYTE
/* pre-count headers */
- for (ptr = headers; *ptr; ptr++) {
- col_count++;
- }
+ for (ptr = headers; *ptr; ptr++)
+ col_count++;
head_w = calloc(col_count, sizeof(*head_w));
- if (!head_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
+ if (!head_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
}
for (i = 0; i < col_count; i++)
{
- if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > hwidth)
+ if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > hwidth)
hwidth = tmp;
head_w[i] = tmp;
}
- for (ptr = cells; *ptr; ptr++) {
- cell_count++;
- }
+ for (ptr = cells; *ptr; ptr++)
+ cell_count++;
cell_w = calloc(cell_count, sizeof(*cell_w));
- if (!cell_w) {
- perror("calloc");
- exit(EXIT_FAILURE);
- }
+ if (!cell_w)
+ {
+ perror("calloc");
+ exit(EXIT_FAILURE);
+ }
/* find longest data cell */
- for (i = 0, ptr = cells; *ptr; ptr++, i++) {
- if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > dwidth) {
+ for (i = 0, ptr = cells; *ptr; ptr++, i++)
+ {
+ if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > dwidth)
dwidth = tmp;
- }
- cell_w[i] = tmp;
+ cell_w[i] = tmp;
}
#else
/* count columns and find longest header */
@@ -479,7 +486,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
}
/* find longest data cell */
- for (ptr = cells; *ptr; ptr++) {
+ for (ptr = cells; *ptr; ptr++)
+ {
if ((tmp = strlen(*ptr)) > dwidth)
dwidth = tmp;
}
@@ -571,7 +579,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
if (opt_border < 2)
fprintf(fout, "%s\n", *ptr);
- else {
+ else
+ {
#ifdef MULTIBYTE
fprintf(fout, "%-s%*s |\n", *ptr, dwidth - cell_w[i], "");
#else
@@ -1152,7 +1161,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
exit(EXIT_FAILURE);
}
- for (i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++)
+ {
#ifdef MULTIBYTE
headers[i] = mbvalidate(PQfname(result, i));
#else
@@ -1173,7 +1183,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
{
if (PQgetisnull(result, i / nfields, i % nfields))
cells[i] = opt->nullPrint ? opt->nullPrint : "";
- else {
+ else
+ {
#ifdef MULTIBYTE
cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields));
#else
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index 1cc3bcb6e2..d469149b69 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.9 2001/05/12 19:44:46 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.10 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -12,11 +12,12 @@
enum printFormat
{
- PRINT_NOTHING = 0, /* to make sure someone initializes this */
- PRINT_UNALIGNED,
- PRINT_ALIGNED,
- PRINT_HTML,
- PRINT_LATEX
+ PRINT_NOTHING = 0, /* to make sure someone
+ * initializes this */
+ PRINT_UNALIGNED,
+ PRINT_ALIGNED,
+ PRINT_HTML,
+ PRINT_LATEX
/* add your favourite output format here ... */
};
@@ -64,7 +65,7 @@ typedef struct _printQueryOpt
char *title; /* override title */
char **footers; /* override footer (default is "(xx
* rows)") */
- bool default_footer; /* print default footer if footers==NULL */
+ bool default_footer; /* print default footer if footers==NULL */
} printQueryOpt;
/*
@@ -73,7 +74,6 @@ typedef struct _printQueryOpt
* It calls the printTable above with all the things set straight.
*/
void
-printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
-
+ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
#endif /* PRINT_H */
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 12818d8afa..f01a55b569 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.21 2001/08/24 19:59:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.22 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
@@ -33,7 +33,7 @@
*
* Defined interpolations are:
* %M - database server "hostname.domainname", "[local]" for AF_UNIX
- * sockets, "[local:/dir/name]" if not default
+ * sockets, "[local:/dir/name]" if not default
* %m - like %M, but hostname only (before first dot), or always "[local]"
* %> - database server port number
* %n - database user name
@@ -120,7 +120,7 @@ get_prompt(promptStatus_t status)
case 'm':
if (pset.db)
{
- const char * host = PQhost(pset.db);
+ const char *host = PQhost(pset.db);
/* INET socket */
if (host && host[0] && host[0] != '/')
@@ -134,7 +134,7 @@ get_prompt(promptStatus_t status)
else
{
if (!host
- || strcmp(host, DEFAULT_PGSOCKET_DIR)==0
+ || strcmp(host, DEFAULT_PGSOCKET_DIR) == 0
|| *p == 'm')
strncpy(buf, "[local]", MAX_PROMPT_SIZE);
else
diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h
index 0c0c209ff3..4c2b0a693b 100644
--- a/src/bin/psql/prompt.h
+++ b/src/bin/psql/prompt.h
@@ -3,22 +3,21 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef PROMPT_H
#define PROMPT_H
typedef enum _promptStatus
{
- PROMPT_READY,
- PROMPT_CONTINUE,
- PROMPT_COMMENT,
- PROMPT_SINGLEQUOTE,
- PROMPT_DOUBLEQUOTE,
- PROMPT_PAREN,
- PROMPT_COPY
+ PROMPT_READY,
+ PROMPT_CONTINUE,
+ PROMPT_COMMENT,
+ PROMPT_SINGLEQUOTE,
+ PROMPT_DOUBLEQUOTE,
+ PROMPT_PAREN,
+ PROMPT_COPY
} promptStatus_t;
char *get_prompt(promptStatus_t status);
-
#endif /* PROMPT_H */
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
index d5d306b158..1be01f445c 100644
--- a/src/bin/psql/settings.h
+++ b/src/bin/psql/settings.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.10 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.11 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef SETTINGS_H
#define SETTINGS_H
@@ -69,5 +69,4 @@ extern PsqlSettings pset;
#define EXIT_BADCONN 2
#define EXIT_USER 3
-
#endif
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index bd0dddcb36..75d04551c3 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.51 2001/06/30 17:26:12 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.52 2001/10/25 05:49:54 momjian Exp $
*/
#include "postgres_fe.h"
@@ -56,11 +56,11 @@ PsqlSettings pset;
*/
enum _actions
{
- ACT_NOTHING = 0,
- ACT_SINGLE_SLASH,
- ACT_LIST_DB,
- ACT_SINGLE_QUERY,
- ACT_FILE
+ ACT_NOTHING = 0,
+ ACT_SINGLE_SLASH,
+ ACT_LIST_DB,
+ ACT_SINGLE_QUERY,
+ ACT_FILE
};
struct adhoc_opts
@@ -87,7 +87,6 @@ static void
#ifdef USE_SSL
static void
printSSLInfo(void);
-
#endif
@@ -167,7 +166,6 @@ main(int argc, char *argv[])
if (options.username)
{
-
/*
* The \001 is a hack to support the deprecated -u option which
* issues a username prompt. The recommended option is -U followed
@@ -241,7 +239,7 @@ main(int argc, char *argv[])
/*
* process file given by -f
*/
- if (options.action == ACT_FILE && strcmp(options.action_string, "-")!=0)
+ if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0)
{
if (!options.no_psqlrc)
process_psqlrc();
@@ -286,8 +284,8 @@ main(int argc, char *argv[])
printf(gettext("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
"Type: \\copyright for distribution terms\n"
" \\h for help with SQL commands\n"
- " \\? for help on internal slash commands\n"
- " \\g or terminate with semicolon to execute query\n"
+ " \\? for help on internal slash commands\n"
+ " \\g or terminate with semicolon to execute query\n"
" \\q to quit\n\n"),
pset.progname);
#ifdef USE_SSL
@@ -302,7 +300,7 @@ main(int argc, char *argv[])
process_psqlrc();
if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1);
- if (options.action_string) /* -f - was used */
+ if (options.action_string) /* -f - was used */
pset.inputfile = "<stdin>";
successResult = MainLoop(stdin);
}
@@ -326,7 +324,6 @@ int getopt(int, char *const[], const char *);
/* And it requires progname to be set */
char *__progname = "psql";
-
#endif
static void
@@ -367,7 +364,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
};
int optindex;
-
#endif /* HAVE_GETOPT_LONG */
extern char *optarg;
@@ -554,7 +550,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case '-':
fprintf(stderr,
gettext("%s was compiled without support for long options.\n"
- "Use --help for help on invocation options.\n"),
+ "Use --help for help on invocation options.\n"),
pset.progname);
exit(EXIT_FAILURE);
break;
@@ -673,7 +669,7 @@ showVersion(void)
puts(gettext("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n"
"Portions Copyright (c) 1996, Regents of the University of California\n"
- "Read the file COPYRIGHT or use the command \\copyright to see the\n"
+ "Read the file COPYRIGHT or use the command \\copyright to see the\n"
"usage and distribution terms."));
}
@@ -699,5 +695,4 @@ printSSLInfo(void)
printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"),
SSL_get_cipher(ssl), sslbits);
}
-
#endif
diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h
index 4201fd5300..2d7bdaa86b 100644
--- a/src/bin/psql/stringutils.h
+++ b/src/bin/psql/stringutils.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.14 2000/02/07 23:10:07 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.15 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef STRINGUTILS_H
#define STRINGUTILS_H
@@ -17,5 +17,4 @@ extern char *strtokx(const char *s,
char *was_quoted,
unsigned int *token_pos,
int encoding);
-
#endif /* STRINGUTILS_H */
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index c76d9c807a..500ded13fe 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.38 2001/09/21 03:32:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.39 2001/10/25 05:49:54 momjian Exp $
*/
/*----------------------------------------------------------------------
@@ -106,7 +106,7 @@ void
initialize_readline(void)
{
rl_readline_name = pset.progname;
- rl_attempted_completion_function = (void *)psql_completion;
+ rl_attempted_completion_function = (void *) psql_completion;
rl_basic_word_break_characters = "\t\n@$><=;|&{( ";
@@ -584,7 +584,11 @@ psql_completion(char *text, int start, int end)
/* Complete INSERT INTO with table names */
else if (strcasecmp(prev2_wd, "INSERT") == 0 && strcasecmp(prev_wd, "INTO") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_tables);
- /* Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT VALUES" */
+
+ /*
+ * Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT
+ * VALUES"
+ */
else if (strcasecmp(prev3_wd, "INSERT") == 0 && strcasecmp(prev2_wd, "INTO") == 0)
{
char *list_INSERT[] = {"DEFAULT VALUES", "SELECT", "VALUES", NULL};
@@ -662,19 +666,17 @@ psql_completion(char *text, int start, int end)
/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev_wd, "SESSION") == 0)
{
- char *my_list[] = {"AUTHORIZATION",
- "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL",
- NULL};
+ char *my_list[] = {"AUTHORIZATION",
+ "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL",
+ NULL};
COMPLETE_WITH_LIST(my_list);
}
/* Complete SET SESSION AUTHORIZATION with username */
- else if (strcasecmp(prev3_wd, "SET") == 0
+ else if (strcasecmp(prev3_wd, "SET") == 0
&& strcasecmp(prev2_wd, "SESSION") == 0
&& strcasecmp(prev_wd, "AUTHORIZATION") == 0)
- {
COMPLETE_WITH_QUERY(Query_for_list_of_users);
- }
/* Complete SET <var> with "TO" */
else if (strcasecmp(prev2_wd, "SET") == 0 &&
strcasecmp(prev4_wd, "UPDATE") != 0)
@@ -755,12 +757,12 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(my_list);
}
else if (strcmp(prev_wd, "\\cd") == 0 ||
- strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
+ strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
strcmp(prev_wd, "\\g") == 0 ||
strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
- strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
+ strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
strcmp(prev_wd, "\\s") == 0 ||
- strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
+ strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
)
matches = completion_matches(text, filename_completion_function);
@@ -1110,7 +1112,5 @@ dequote_file_name(char *text, char quote_char)
return s;
}
-
#endif /* 0 */
-
#endif /* USE_READLINE */
diff --git a/src/bin/psql/tab-complete.h b/src/bin/psql/tab-complete.h
index 81182eae53..7200fd6feb 100644
--- a/src/bin/psql/tab-complete.h
+++ b/src/bin/psql/tab-complete.h
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.6 2001/02/10 02:31:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.7 2001/10/25 05:49:54 momjian Exp $
*/
#ifndef TAB_COMPLETE_H
#define TAB_COMPLETE_H
@@ -11,5 +11,4 @@
#include "postgres_fe.h"
void initialize_readline(void);
-
#endif
diff --git a/src/bin/psql/variables.h b/src/bin/psql/variables.h
index 0814d71a9a..8e96966f8e 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.8 2000/04/12 17:16:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.9 2001/10/25 05:49:54 momjian Exp $
*/
/*
@@ -36,5 +36,4 @@ bool SetVariableBool(VariableSpace space, const char *name);
bool DeleteVariable(VariableSpace space, const char *name);
void DestroyVariableSpace(VariableSpace space);
-
#endif /* VARIABLES_H */