aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/initdb/initdb.c395
-rw-r--r--src/bin/pg_config/pg_config.c91
-rw-r--r--src/bin/pg_controldata/pg_controldata.c7
-rw-r--r--src/bin/pg_ctl/pg_ctl.c368
-rw-r--r--src/bin/pg_dump/common.c28
-rw-r--r--src/bin/pg_dump/dumputils.c19
-rw-r--r--src/bin/pg_dump/dumputils.h10
-rw-r--r--src/bin/pg_dump/pg_backup.h10
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c154
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h33
-rw-r--r--src/bin/pg_dump/pg_backup_db.c173
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c4
-rw-r--r--src/bin/pg_dump/pg_dump.c331
-rw-r--r--src/bin/pg_dump/pg_dump.h23
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c209
-rw-r--r--src/bin/pg_dump/pg_dumpall.c88
-rw-r--r--src/bin/pg_dump/pg_restore.c9
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c17
-rw-r--r--src/bin/pgevent/pgevent.c123
-rw-r--r--src/bin/pgevent/pgmsgevent.h81
-rw-r--r--src/bin/psql/command.c28
-rw-r--r--src/bin/psql/command.h4
-rw-r--r--src/bin/psql/common.c58
-rw-r--r--src/bin/psql/copy.c46
-rw-r--r--src/bin/psql/describe.c95
-rw-r--r--src/bin/psql/help.c8
-rw-r--r--src/bin/psql/input.c12
-rw-r--r--src/bin/psql/mainloop.c16
-rw-r--r--src/bin/psql/print.c24
-rw-r--r--src/bin/psql/prompt.c26
-rw-r--r--src/bin/psql/psqlscan.h14
-rw-r--r--src/bin/psql/settings.h4
-rw-r--r--src/bin/psql/startup.c34
-rw-r--r--src/bin/psql/tab-complete.c227
-rw-r--r--src/bin/scripts/clusterdb.c8
-rw-r--r--src/bin/scripts/common.c4
-rw-r--r--src/bin/scripts/createlang.c4
-rw-r--r--src/bin/scripts/droplang.c6
-rw-r--r--src/bin/scripts/vacuumdb.c8
39 files changed, 1452 insertions, 1347 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 9865a24a489..86a5c4b1bab 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -39,7 +39,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.52 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.53 2004/08/29 05:06:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,7 +53,7 @@
#include <signal.h>
#include <errno.h>
#ifdef HAVE_LANGINFO_H
-# include <langinfo.h>
+#include <langinfo.h>
#endif
#include "libpq/pqsignal.h"
@@ -73,7 +73,7 @@ int optreset;
/*
* these values are passed in by makefile defines
*/
-char *share_path = NULL;
+char *share_path = NULL;
/* values to be obtained from arguments */
char *pg_data = "";
@@ -87,8 +87,8 @@ char *lc_time = "";
char *lc_messages = "";
char *username = "";
bool pwprompt = false;
-char *pwfilename = NULL;
-char *authmethod = "";
+char *pwfilename = NULL;
+char *authmethod = "";
bool debug = false;
bool noclean = false;
bool show_setting = false;
@@ -122,12 +122,12 @@ int n_buffers = 50;
/*
* Warning messages for authentication methods
*/
-char *authtrust_warning = \
- "# CAUTION: Configuring the system for local \"trust\" authentication allows\n"
- "# any local user to connect as any PostgreSQL user, including the database\n"
- "# superuser. If you do not trust all your local users, use another\n"
- "# authenication method.\n";
-char *authwarning = NULL;
+char *authtrust_warning = \
+"# CAUTION: Configuring the system for local \"trust\" authentication allows\n"
+"# any local user to connect as any PostgreSQL user, including the database\n"
+"# superuser. If you do not trust all your local users, use another\n"
+"# authenication method.\n";
+char *authwarning = NULL;
/*
* Centralized knowledge of switches to pass to backend
@@ -141,20 +141,20 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on
/* path to 'initdb' binary directory */
-char bin_path[MAXPGPATH];
-char backend_exec[MAXPGPATH];
+char bin_path[MAXPGPATH];
+char backend_exec[MAXPGPATH];
static void *xmalloc(size_t size);
static char *xstrdup(const char *s);
static char **replace_token(char **lines, char *token, char *replacement);
static char **readfile(char *path);
static void writefile(char *path, char **lines);
-static int mkdir_p(char *path, mode_t omode);
+static int mkdir_p(char *path, mode_t omode);
static void exit_nicely(void);
static char *get_id(void);
static char *get_encoding_id(char *encoding_name);
static char *get_short_version(void);
-static int check_data_dir(void);
+static int check_data_dir(void);
static bool mkdatadir(const char *subdir);
static void set_input(char **dest, char *filename);
static void check_input(char *path);
@@ -564,9 +564,9 @@ get_id(void)
{
fprintf(stderr,
_("%s: cannot be run as root\n"
- "Please log in (using, e.g., \"su\") as the "
- "(unprivileged) user that will\n"
- "own the server process.\n"),
+ "Please log in (using, e.g., \"su\") as the "
+ "(unprivileged) user that will\n"
+ "own the server process.\n"),
progname);
exit(1);
}
@@ -610,9 +610,7 @@ get_encoding_id(char *encoding_name)
{
if ((enc = pg_char_to_encoding(encoding_name)) >= 0 &&
pg_valid_server_encoding(encoding_name) >= 0)
- {
return encodingid_to_string(enc);
- }
}
fprintf(stderr, _("%s: \"%s\" is not a valid server encoding name\n"),
progname, encoding_name ? encoding_name : "(null)");
@@ -627,106 +625,106 @@ get_encoding_id(char *encoding_name)
struct encoding_match
{
- enum pg_enc pg_enc_code;
+ enum pg_enc pg_enc_code;
char *system_enc_name;
};
struct encoding_match encoding_match_list[] = {
- { PG_EUC_JP, "EUC-JP" },
- { PG_EUC_JP, "eucJP" },
- { PG_EUC_JP, "IBM-eucJP" },
- { PG_EUC_JP, "sdeckanji" },
-
- { PG_EUC_CN, "EUC-CN" },
- { PG_EUC_CN, "eucCN" },
- { PG_EUC_CN, "IBM-eucCN" },
- { PG_EUC_CN, "GB2312" },
- { PG_EUC_CN, "dechanzi" },
-
- { PG_EUC_KR, "EUC-KR" },
- { PG_EUC_KR, "eucKR" },
- { PG_EUC_KR, "IBM-eucKR" },
- { PG_EUC_KR, "deckorean" },
- { PG_EUC_KR, "5601" },
-
- { PG_EUC_TW, "EUC-TW" },
- { PG_EUC_TW, "eucTW" },
- { PG_EUC_TW, "IBM-eucTW" },
- { PG_EUC_TW, "cns11643" },
+ {PG_EUC_JP, "EUC-JP"},
+ {PG_EUC_JP, "eucJP"},
+ {PG_EUC_JP, "IBM-eucJP"},
+ {PG_EUC_JP, "sdeckanji"},
+
+ {PG_EUC_CN, "EUC-CN"},
+ {PG_EUC_CN, "eucCN"},
+ {PG_EUC_CN, "IBM-eucCN"},
+ {PG_EUC_CN, "GB2312"},
+ {PG_EUC_CN, "dechanzi"},
+
+ {PG_EUC_KR, "EUC-KR"},
+ {PG_EUC_KR, "eucKR"},
+ {PG_EUC_KR, "IBM-eucKR"},
+ {PG_EUC_KR, "deckorean"},
+ {PG_EUC_KR, "5601"},
+
+ {PG_EUC_TW, "EUC-TW"},
+ {PG_EUC_TW, "eucTW"},
+ {PG_EUC_TW, "IBM-eucTW"},
+ {PG_EUC_TW, "cns11643"},
#ifdef NOT_VERIFIED
- { PG_JOHAB, "???" },
+ {PG_JOHAB, "???"},
#endif
- { PG_UTF8, "UTF-8" },
- { PG_UTF8, "utf8" },
+ {PG_UTF8, "UTF-8"},
+ {PG_UTF8, "utf8"},
- { PG_LATIN1, "ISO-8859-1" },
- { PG_LATIN1, "ISO8859-1" },
- { PG_LATIN1, "iso88591" },
+ {PG_LATIN1, "ISO-8859-1"},
+ {PG_LATIN1, "ISO8859-1"},
+ {PG_LATIN1, "iso88591"},
- { PG_LATIN2, "ISO-8859-2" },
- { PG_LATIN2, "ISO8859-2" },
- { PG_LATIN2, "iso88592" },
+ {PG_LATIN2, "ISO-8859-2"},
+ {PG_LATIN2, "ISO8859-2"},
+ {PG_LATIN2, "iso88592"},
- { PG_LATIN3, "ISO-8859-3" },
- { PG_LATIN3, "ISO8859-3" },
- { PG_LATIN3, "iso88593" },
+ {PG_LATIN3, "ISO-8859-3"},
+ {PG_LATIN3, "ISO8859-3"},
+ {PG_LATIN3, "iso88593"},
- { PG_LATIN4, "ISO-8859-4" },
- { PG_LATIN4, "ISO8859-4" },
- { PG_LATIN4, "iso88594" },
+ {PG_LATIN4, "ISO-8859-4"},
+ {PG_LATIN4, "ISO8859-4"},
+ {PG_LATIN4, "iso88594"},
- { PG_LATIN5, "ISO-8859-9" },
- { PG_LATIN5, "ISO8859-9" },
- { PG_LATIN5, "iso88599" },
+ {PG_LATIN5, "ISO-8859-9"},
+ {PG_LATIN5, "ISO8859-9"},
+ {PG_LATIN5, "iso88599"},
- { PG_LATIN6, "ISO-8859-10" },
- { PG_LATIN6, "ISO8859-10" },
- { PG_LATIN6, "iso885910" },
+ {PG_LATIN6, "ISO-8859-10"},
+ {PG_LATIN6, "ISO8859-10"},
+ {PG_LATIN6, "iso885910"},
- { PG_LATIN7, "ISO-8859-13" },
- { PG_LATIN7, "ISO8859-13" },
- { PG_LATIN7, "iso885913" },
+ {PG_LATIN7, "ISO-8859-13"},
+ {PG_LATIN7, "ISO8859-13"},
+ {PG_LATIN7, "iso885913"},
- { PG_LATIN8, "ISO-8859-14" },
- { PG_LATIN8, "ISO8859-14" },
- { PG_LATIN8, "iso885914" },
+ {PG_LATIN8, "ISO-8859-14"},
+ {PG_LATIN8, "ISO8859-14"},
+ {PG_LATIN8, "iso885914"},
- { PG_LATIN9, "ISO-8859-15" },
- { PG_LATIN9, "ISO8859-15" },
- { PG_LATIN9, "iso885915" },
+ {PG_LATIN9, "ISO-8859-15"},
+ {PG_LATIN9, "ISO8859-15"},
+ {PG_LATIN9, "iso885915"},
- { PG_LATIN10, "ISO-8859-16" },
- { PG_LATIN10, "ISO8859-16" },
- { PG_LATIN10, "iso885916" },
+ {PG_LATIN10, "ISO-8859-16"},
+ {PG_LATIN10, "ISO8859-16"},
+ {PG_LATIN10, "iso885916"},
- { PG_WIN1256, "CP1256" },
- { PG_TCVN, "CP1258" },
+ {PG_WIN1256, "CP1256"},
+ {PG_TCVN, "CP1258"},
#ifdef NOT_VERIFIED
- { PG_WIN874, "???" },
+ {PG_WIN874, "???"},
#endif
- { PG_KOI8R, "KOI8-R" },
- { PG_WIN1251, "CP1251" },
- { PG_ALT, "CP866" },
+ {PG_KOI8R, "KOI8-R"},
+ {PG_WIN1251, "CP1251"},
+ {PG_ALT, "CP866"},
- { PG_ISO_8859_5, "ISO-8859-5" },
- { PG_ISO_8859_5, "ISO8859-5" },
- { PG_ISO_8859_5, "iso88595" },
+ {PG_ISO_8859_5, "ISO-8859-5"},
+ {PG_ISO_8859_5, "ISO8859-5"},
+ {PG_ISO_8859_5, "iso88595"},
- { PG_ISO_8859_6, "ISO-8859-6" },
- { PG_ISO_8859_6, "ISO8859-6" },
- { PG_ISO_8859_6, "iso88596" },
+ {PG_ISO_8859_6, "ISO-8859-6"},
+ {PG_ISO_8859_6, "ISO8859-6"},
+ {PG_ISO_8859_6, "iso88596"},
- { PG_ISO_8859_7, "ISO-8859-7" },
- { PG_ISO_8859_7, "ISO8859-7" },
- { PG_ISO_8859_7, "iso88597" },
+ {PG_ISO_8859_7, "ISO-8859-7"},
+ {PG_ISO_8859_7, "ISO8859-7"},
+ {PG_ISO_8859_7, "iso88597"},
- { PG_ISO_8859_8, "ISO-8859-8" },
- { PG_ISO_8859_8, "ISO8859-8" },
- { PG_ISO_8859_8, "iso88598" },
+ {PG_ISO_8859_8, "ISO-8859-8"},
+ {PG_ISO_8859_8, "ISO8859-8"},
+ {PG_ISO_8859_8, "iso88598"},
- { PG_SQL_ASCII, NULL } /* end marker */
+ {PG_SQL_ASCII, NULL} /* end marker */
};
static char *
@@ -753,15 +751,15 @@ get_encoding_from_locale(const char *ctype)
static void
check_encodings_match(int pg_enc, const char *ctype)
{
- char *sys;
- int i;
+ char *sys;
+ int i;
sys = get_encoding_from_locale(ctype);
for (i = 0; encoding_match_list[i].system_enc_name; i++)
{
if (pg_enc == encoding_match_list[i].pg_enc_code
- && strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0)
+ && strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0)
{
free(sys);
return;
@@ -772,9 +770,9 @@ check_encodings_match(int pg_enc, const char *ctype)
_("%s: warning: encoding mismatch\n"), progname);
fprintf(stderr,
_("The encoding you selected (%s) and the encoding that the selected\n"
- "locale uses (%s) are not known to match. This may lead to\n"
+ "locale uses (%s) are not known to match. This may lead to\n"
"misbehavior in various character string processing functions. To fix\n"
- "this situation, rerun %s and either do not specify an encoding\n"
+ "this situation, rerun %s and either do not specify an encoding\n"
"explicitly, or choose a matching combination.\n"),
pg_encoding_to_char(pg_enc), sys, progname);
@@ -785,8 +783,8 @@ check_encodings_match(int pg_enc, const char *ctype)
static int
find_matching_encoding(const char *ctype)
{
- char *sys;
- int i;
+ char *sys;
+ int i;
sys = get_encoding_from_locale(ctype);
@@ -802,7 +800,7 @@ find_matching_encoding(const char *ctype)
free(sys);
return -1;
}
-#endif /* HAVE_LANGINFO_H && CODESET */
+#endif /* HAVE_LANGINFO_H && CODESET */
/*
* get short version of VERSION
@@ -924,7 +922,7 @@ check_input(char *path)
{
fprintf(stderr,
_("%s: file \"%s\" does not exist\n"
- "This means you have a corrupted installation or identified\n"
+ "This means you have a corrupted installation or identified\n"
"the wrong directory with the invocation option -L.\n"),
progname, path);
exit(1);
@@ -1019,7 +1017,7 @@ test_buffers(void)
{
char cmd[MAXPGPATH];
static const int bufs[] = {1000, 900, 800, 700, 600, 500,
- 400, 300, 200, 100, 50};
+ 400, 300, 200, 100, 50};
static const int len = sizeof(bufs) / sizeof(int);
int i,
status;
@@ -1100,16 +1098,16 @@ setup_config(void)
"host all all ::1",
"#host all all ::1");
#endif
-
+
/* Replace default authentication methods */
conflines = replace_token(conflines,
- "@authmethod@",
+ "@authmethod@",
authmethod);
-
+
conflines = replace_token(conflines,
"@authcomment@",
- strcmp(authmethod,"trust") ? "" : authtrust_warning);
-
+ strcmp(authmethod, "trust") ? "" : authtrust_warning);
+
snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data);
writefile(path, conflines);
@@ -1160,9 +1158,9 @@ bootstrap_template1(char *short_version)
if (strcmp(headerline, *bki_lines) != 0)
{
fprintf(stderr,
- _("%s: input file \"%s\" does not belong to PostgreSQL %s\n"
- "Check your installation or specify the correct path "
- "using the option -L.\n"),
+ _("%s: input file \"%s\" does not belong to PostgreSQL %s\n"
+ "Check your installation or specify the correct path "
+ "using the option -L.\n"),
progname, bki_file, PG_VERSION);
exit_nicely();
@@ -1175,8 +1173,8 @@ bootstrap_template1(char *short_version)
/*
* Pass correct LC_xxx environment to bootstrap.
*
- * The shell script arranged to restore the LC settings afterwards,
- * but there doesn't seem to be any compelling reason to do that.
+ * The shell script arranged to restore the LC settings afterwards, but
+ * there doesn't seem to be any compelling reason to do that.
*/
snprintf(cmd, sizeof(cmd), "LC_COLLATE=%s", lc_collate);
putenv(xstrdup(cmd));
@@ -1287,13 +1285,13 @@ get_set_pwd(void)
* Read password from file
*
* Ideally this should insist that the file not be world-readable.
- * However, this option is mainly intended for use on Windows where
- * file permissions may not exist at all, so we'll skip the paranoia
- * for now.
+ * However, this option is mainly intended for use on Windows
+ * where file permissions may not exist at all, so we'll skip the
+ * paranoia for now.
*/
- FILE *pwf = fopen(pwfilename,"r");
- char pwdbuf[MAXPGPATH];
- int i;
+ FILE *pwf = fopen(pwfilename, "r");
+ char pwdbuf[MAXPGPATH];
+ int i;
if (!pwf)
{
@@ -1310,11 +1308,11 @@ get_set_pwd(void)
fclose(pwf);
i = strlen(pwdbuf);
- while (i > 0 && (pwdbuf[i-1] == '\r' || pwdbuf[i-1] == '\n'))
+ while (i > 0 && (pwdbuf[i - 1] == '\r' || pwdbuf[i - 1] == '\n'))
pwdbuf[--i] = '\0';
-
+
pwd1 = xstrdup(pwdbuf);
-
+
}
printf(_("setting password ... "));
fflush(stdout);
@@ -1327,7 +1325,7 @@ get_set_pwd(void)
PG_CMD_OPEN;
if (fprintf(pg,
- "ALTER USER \"%s\" WITH PASSWORD '%s';\n", effective_user, pwd1) < 0)
+ "ALTER USER \"%s\" WITH PASSWORD '%s';\n", effective_user, pwd1) < 0)
{
/* write failure */
exit_nicely();
@@ -1341,7 +1339,7 @@ get_set_pwd(void)
{
fprintf(stderr,
_("%s: The password file was not generated. "
- "Please report this problem.\n"),
+ "Please report this problem.\n"),
progname);
exit_nicely();
}
@@ -1676,7 +1674,8 @@ setup_schema(void)
lines = readfile(info_schema_file);
/*
- * We use -N here to avoid backslashing stuff in information_schema.sql
+ * We use -N here to avoid backslashing stuff in
+ * information_schema.sql
*/
snprintf(cmd, sizeof(cmd),
"\"%s\" %s -N template1 >%s",
@@ -2000,7 +1999,7 @@ main(int argc, char *argv[])
{"lc-time", required_argument, NULL, 6},
{"lc-messages", required_argument, NULL, 7},
{"no-locale", no_argument, NULL, 8},
- {"auth", required_argument, NULL, 'A'},
+ {"auth", required_argument, NULL, 'A'},
{"pwprompt", no_argument, NULL, 'W'},
{"pwfile", required_argument, NULL, 9},
{"username", required_argument, NULL, 'U'},
@@ -2033,19 +2032,19 @@ main(int argc, char *argv[])
progname = get_progname(argv[0]);
set_pglocale_pgservice(argv[0], "initdb");
- if (argc > 1)
- {
- if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
- {
- usage(progname);
- exit(0);
- }
- if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
- {
- puts("initdb (PostgreSQL) " PG_VERSION);
- exit(0);
- }
- }
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+ {
+ usage(progname);
+ exit(0);
+ }
+ if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+ {
+ puts("initdb (PostgreSQL) " PG_VERSION);
+ exit(0);
+ }
+ }
/* process command-line options */
@@ -2070,7 +2069,7 @@ main(int argc, char *argv[])
break;
case 'd':
debug = true;
- printf(_("Running in debug mode.\n"));
+ printf(_("Running in debug mode.\n"));
break;
case 'n':
noclean = true;
@@ -2111,7 +2110,7 @@ main(int argc, char *argv[])
break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ progname);
exit(1);
}
}
@@ -2126,7 +2125,7 @@ main(int argc, char *argv[])
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
- progname, argv[optind + 1]);
+ progname, argv[optind + 1]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
}
@@ -2136,39 +2135,41 @@ main(int argc, char *argv[])
fprintf(stderr, _("%s: you cannot specify both password prompt and password file\n"), progname);
exit(1);
}
-
+
if (authmethod == NULL || !strlen(authmethod))
{
authwarning = _("\nWARNING: enabling \"trust\" authentication for local connections.\n"
"You can change this by editing pg_hba.conf or using the -A flag the\n"
"next time you run initdb.\n");
- authmethod="trust";
+ authmethod = "trust";
}
- if (strcmp(authmethod,"md5") &&
- strcmp(authmethod,"ident") &&
- strncmp(authmethod,"ident ",6) && /* ident with space = param */
- strcmp(authmethod,"trust") &&
+ if (strcmp(authmethod, "md5") &&
+ strcmp(authmethod, "ident") &&
+ strncmp(authmethod, "ident ", 6) && /* ident with space =
+ * param */
+ strcmp(authmethod, "trust") &&
#ifdef USE_PAM
- strcmp(authmethod,"pam") &&
- strncmp(authmethod,"pam ",4) && /* pam with space = param */
+ strcmp(authmethod, "pam") &&
+ strncmp(authmethod, "pam ", 4) && /* pam with space = param */
#endif
- strcmp(authmethod,"crypt") &&
- strcmp(authmethod,"password")
+ strcmp(authmethod, "crypt") &&
+ strcmp(authmethod, "password")
)
+
/*
- * Kerberos methods not listed because they are not supported
- * over local connections and are rejected in hba.c
+ * Kerberos methods not listed because they are not supported over
+ * local connections and are rejected in hba.c
*/
{
fprintf(stderr, _("%s: unknown authentication method \"%s\".\n"), progname, authmethod);
exit(1);
}
- if ((!strcmp(authmethod,"md5") ||
- !strcmp(authmethod,"crypt") ||
- !strcmp(authmethod,"password")) &&
- !(pwprompt || pwfilename))
+ if ((!strcmp(authmethod, "md5") ||
+ !strcmp(authmethod, "crypt") ||
+ !strcmp(authmethod, "password")) &&
+ !(pwprompt || pwfilename))
{
fprintf(stderr, _("%s: you need to specify a password for the superuser to enable %s authentication.\n"), progname, authmethod);
exit(1);
@@ -2198,9 +2199,9 @@ main(int argc, char *argv[])
/*
* we have to set PGDATA for postgres rather than pass it on the
- * command line to avoid dumb quoting problems on Windows, and we would
- * especially need quotes otherwise on Windows because paths there are
- * most likely to have embedded spaces.
+ * command line to avoid dumb quoting problems on Windows, and we
+ * would especially need quotes otherwise on Windows because paths
+ * there are most likely to have embedded spaces.
*/
pgdenv = xmalloc(8 + strlen(pg_data));
sprintf(pgdenv, "PGDATA=%s", pg_data);
@@ -2211,16 +2212,16 @@ main(int argc, char *argv[])
{
if (ret == -1)
fprintf(stderr,
- _("The program \"postgres\" is needed by %s "
- "but was not found in the same directory as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"postgres\" is needed by %s "
+ "but was not found in the same directory as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
else
fprintf(stderr,
- _("The program \"postgres\" was found by %s "
- "but was not the same version as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"postgres\" was found by %s "
+ "but was not the same version as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
exit(1);
}
@@ -2239,7 +2240,7 @@ main(int argc, char *argv[])
fprintf(stderr, _("%s: input file location must be an absolute path\n"), progname);
exit(1);
}
-
+
canonicalize_path(share_path);
if ((short_version = get_short_version()) == NULL)
@@ -2298,8 +2299,8 @@ main(int argc, char *argv[])
setlocales();
printf(_("The files belonging to this database system will be owned "
- "by user \"%s\".\n"
- "This user must also own the server process.\n\n"),
+ "by user \"%s\".\n"
+ "This user must also own the server process.\n\n"),
effective_user);
if (strcmp(lc_ctype, lc_collate) == 0 &&
@@ -2307,18 +2308,16 @@ main(int argc, char *argv[])
strcmp(lc_ctype, lc_numeric) == 0 &&
strcmp(lc_ctype, lc_monetary) == 0 &&
strcmp(lc_ctype, lc_messages) == 0)
- {
printf(_("The database cluster will be initialized with locale %s.\n"), lc_ctype);
- }
else
{
printf(_("The database cluster will be initialized with locales\n"
- " COLLATE: %s\n"
- " CTYPE: %s\n"
- " MESSAGES: %s\n"
- " MONETARY: %s\n"
- " NUMERIC: %s\n"
- " TIME: %s\n"),
+ " COLLATE: %s\n"
+ " CTYPE: %s\n"
+ " MESSAGES: %s\n"
+ " MONETARY: %s\n"
+ " NUMERIC: %s\n"
+ " TIME: %s\n"),
lc_collate,
lc_ctype,
lc_messages,
@@ -2332,7 +2331,8 @@ main(int argc, char *argv[])
{
if (strlen(encoding) == 0)
{
- int tmp;
+ int tmp;
+
tmp = find_matching_encoding(lc_ctype);
if (tmp == -1)
{
@@ -2344,14 +2344,14 @@ main(int argc, char *argv[])
else
{
encodingid = encodingid_to_string(tmp);
- printf(_("The default database encoding has accordingly been set to %s.\n"),
+ printf(_("The default database encoding has accordingly been set to %s.\n"),
pg_encoding_to_char(tmp));
}
}
else
check_encodings_match(atoi(encodingid), lc_ctype);
}
-#endif /* HAVE_LANGINFO_H && CODESET */
+#endif /* HAVE_LANGINFO_H && CODESET */
printf("\n");
@@ -2418,9 +2418,9 @@ main(int argc, char *argv[])
/* Present and not empty */
fprintf(stderr,
_("%s: directory \"%s\" exists but is not empty\n"
- "If you want to create a new database system, either remove or empty\n"
- "the directory \"%s\" or run %s\n"
- "with an argument other than \"%s\".\n"),
+ "If you want to create a new database system, either remove or empty\n"
+ "the directory \"%s\" or run %s\n"
+ "with an argument other than \"%s\".\n"),
progname, pg_data, pg_data, progname, pg_data);
exit(1); /* no further message needed */
@@ -2449,9 +2449,9 @@ main(int argc, char *argv[])
/*
* Determine platform-specific config settings
*
- * Use reasonable values if kernel will let us, else scale back. Probe for
- * max_connections first since it is subject to more constraints than
- * shared_buffers.
+ * Use reasonable values if kernel will let us, else scale back. Probe
+ * for max_connections first since it is subject to more constraints
+ * than shared_buffers.
*/
set_null_conf();
@@ -2465,7 +2465,10 @@ main(int argc, char *argv[])
/* Bootstrap template1 */
bootstrap_template1(short_version);
- /* Make the per-database PG_VERSION for template1 only after init'ing it */
+ /*
+ * Make the per-database PG_VERSION for template1 only after init'ing
+ * it
+ */
set_short_version(short_version, "base/1");
/* Create the stuff we don't need to use bootstrap mode for */
@@ -2496,11 +2499,11 @@ main(int argc, char *argv[])
fprintf(stderr, authwarning);
printf(_("\nSuccess. You can now start the database server using:\n\n"
- " %s%s%s/postmaster -D %s%s%s\n"
- "or\n"
- " %s%s%s/pg_ctl -D %s%s%s -l logfile start\n\n"),
- QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH,
- QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH);
+ " %s%s%s/postmaster -D %s%s%s\n"
+ "or\n"
+ " %s%s%s/pg_ctl -D %s%s%s -l logfile start\n\n"),
+ QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH,
+ QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH);
return 0;
}
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
index 5e9a86dea9b..547628d911c 100644
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -11,13 +11,13 @@
* accomodate the possibility that the installation has been relocated from
* the place originally configured.
*
- * author of C translation: Andrew Dunstan mailto:andrew@dunslane.net
+ * author of C translation: Andrew Dunstan mailto:andrew@dunslane.net
*
* This code is released under the terms of the PostgreSQL License.
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.5 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.6 2004/08/29 05:06:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,9 +33,9 @@ static char *progname;
static void
help()
{
- printf(_("\n%s provides information about the installed version of PostgreSQL.\n\n"),progname);
+ printf(_("\n%s provides information about the installed version of PostgreSQL.\n\n"), progname);
printf(_("Usage:\n"));
- printf(_(" %s OPTION...\n\n"),progname);
+ printf(_(" %s OPTION...\n\n"), progname);
printf(_("Options:\n"));
printf(_(" --bindir show location of user executables\n"));
printf(_(" --includedir show location of C header files of the client\n"));
@@ -54,97 +54,98 @@ help()
static void
advice()
{
- fprintf(stderr,_("\nTry \"%s --help\" for more information\n"),progname);
+ fprintf(stderr, _("\nTry \"%s --help\" for more information\n"), progname);
}
int
-main (int argc, char ** argv)
+main(int argc, char **argv)
{
- int i;
- int ret;
- char mypath[MAXPGPATH];
- char otherpath[MAXPGPATH];
+ int i;
+ int ret;
+ char mypath[MAXPGPATH];
+ char otherpath[MAXPGPATH];
- progname = (char *)get_progname(argv[0]);
+ progname = (char *) get_progname(argv[0]);
if (argc < 2)
{
- fprintf(stderr,_("%s: argument required\n"),progname);
+ fprintf(stderr, _("%s: argument required\n"), progname);
advice();
exit(1);
}
- for (i=1; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
- if (strcmp(argv[i],"--bindir") == 0 ||
- strcmp(argv[i],"--includedir") == 0 ||
- strcmp(argv[i],"--includedir-server") == 0 ||
- strcmp(argv[i],"--libdir") == 0 ||
- strcmp(argv[i],"--pkglibdir") == 0 ||
- strcmp(argv[i],"--pgxs") == 0 ||
- strcmp(argv[i],"--configure") == 0)
+ if (strcmp(argv[i], "--bindir") == 0 ||
+ strcmp(argv[i], "--includedir") == 0 ||
+ strcmp(argv[i], "--includedir-server") == 0 ||
+ strcmp(argv[i], "--libdir") == 0 ||
+ strcmp(argv[i], "--pkglibdir") == 0 ||
+ strcmp(argv[i], "--pgxs") == 0 ||
+ strcmp(argv[i], "--configure") == 0)
{
/* come back to these later */
- continue;
+ continue;
}
- if (strcmp(argv[i],"--version") == 0)
+ if (strcmp(argv[i], "--version") == 0)
{
printf("PostgreSQL " PG_VERSION "\n");
exit(0);
}
- if (strcmp(argv[i],"--help") == 0 || strcmp(argv[i],"-?") == 0)
+ if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
{
help();
exit(0);
}
- fprintf(stderr,_("%s: invalid argument: %s\n"),progname,argv[i]);
+ fprintf(stderr, _("%s: invalid argument: %s\n"), progname, argv[i]);
advice();
exit(1);
}
- ret = find_my_exec(argv[0],mypath);
+ ret = find_my_exec(argv[0], mypath);
if (ret)
{
- fprintf(stderr,"%s: could not locate my own executable\n",progname);
+ fprintf(stderr, "%s: could not locate my own executable\n", progname);
exit(1);
}
- for (i=1; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
- if (strcmp(argv[i],"--configure") == 0)
+ if (strcmp(argv[i], "--configure") == 0)
{
/* the VAL_CONFIGURE macro must be defined by the Makefile */
- printf("%s\n",VAL_CONFIGURE);
+ printf("%s\n", VAL_CONFIGURE);
continue;
}
- if (strcmp(argv[i],"--bindir") == 0)
+ if (strcmp(argv[i], "--bindir") == 0)
{
/* assume we are located in the bindir */
- char *lastsep;
- strcpy(otherpath,mypath);
- lastsep = strrchr(otherpath,'/');
+ char *lastsep;
+
+ strcpy(otherpath, mypath);
+ lastsep = strrchr(otherpath, '/');
if (lastsep)
*lastsep = '\0';
}
- else if (strcmp(argv[i],"--includedir") == 0)
- get_include_path(mypath,otherpath);
- else if (strcmp(argv[i],"--includedir-server") ==0)
- get_includeserver_path(mypath,otherpath);
- else if (strcmp(argv[i],"--libdir") == 0)
- get_lib_path(mypath,otherpath);
- else if (strcmp(argv[i],"--pkglibdir") == 0)
- get_pkglib_path(mypath,otherpath);
- else if (strcmp(argv[i],"--pgxs") == 0)
+ else if (strcmp(argv[i], "--includedir") == 0)
+ get_include_path(mypath, otherpath);
+ else if (strcmp(argv[i], "--includedir-server") == 0)
+ get_includeserver_path(mypath, otherpath);
+ else if (strcmp(argv[i], "--libdir") == 0)
+ get_lib_path(mypath, otherpath);
+ else if (strcmp(argv[i], "--pkglibdir") == 0)
+ get_pkglib_path(mypath, otherpath);
+ else if (strcmp(argv[i], "--pgxs") == 0)
{
- get_pkglib_path(mypath,otherpath);
- strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);
+ get_pkglib_path(mypath, otherpath);
+ strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1);
}
- printf("%s\n",otherpath);
+ printf("%s\n", otherpath);
}
return 0;
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 53054979a96..2bfc30f9e6e 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.18 2004/07/21 22:31:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.19 2004/08/29 05:06:53 momjian Exp $
*/
#include "postgres.h"
@@ -143,9 +143,10 @@ main(int argc, char *argv[])
localtime(&(ControlFile.time)));
strftime(ckpttime_str, sizeof(ckpttime_str), strftime_fmt,
localtime(&(ControlFile.checkPointCopy.time)));
+
/*
- * Format system_identifier separately to keep platform-dependent format
- * code out of the translatable message string.
+ * Format system_identifier separately to keep platform-dependent
+ * format code out of the translatable message string.
*/
snprintf(sysident_str, sizeof(sysident_str), UINT64_FORMAT,
ControlFile.system_identifier);
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 47233193b9c..dda80adeaa4 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.29 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.30 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,7 +30,7 @@ typedef long pgpid_t;
#define _(x) gettext((x))
-#define WHITESPACE "\f\n\r\t\v" /* as defined by isspace() */
+#define WHITESPACE "\f\n\r\t\v" /* as defined by isspace() */
/* postmaster version ident string */
#define PM_VERSIONSTR "postmaster (PostgreSQL) " PG_VERSION "\n"
@@ -41,7 +41,7 @@ typedef enum
SMART_MODE,
FAST_MODE,
IMMEDIATE_MODE
-} ShutdownMode;
+} ShutdownMode;
typedef enum
@@ -56,7 +56,7 @@ typedef enum
REGISTER_COMMAND,
UNREGISTER_COMMAND,
RUN_AS_SERVICE_COMMAND
-} CtlCommand;
+} CtlCommand;
static bool do_wait = false;
@@ -64,7 +64,7 @@ static bool wait_set = false;
static int wait_seconds = 60;
static bool silence_echo = false;
static ShutdownMode shutdown_mode = SMART_MODE;
-static int sig = SIGTERM; /* default */
+static int sig = SIGTERM; /* default */
static CtlCommand ctl_command = NO_COMMAND;
static char *pg_data = NULL;
static char *pgdata_opt = NULL;
@@ -72,12 +72,13 @@ static char *post_opts = NULL;
static const char *progname;
static char *log_file = NULL;
static char *postgres_path = NULL;
-static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
+static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
static char *register_username = NULL;
static char *register_password = NULL;
static char *argv0 = NULL;
-static void write_stderr(const char *fmt,...)
+static void
+write_stderr(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(printf, 1, 2)));
@@ -93,19 +94,20 @@ static void do_restart(void);
static void do_reload(void);
static void do_status(void);
static void do_kill(pgpid_t pid);
+
#ifdef WIN32
-static bool pgwin32_IsInstalled(SC_HANDLE);
-static char* pgwin32_CommandLine(bool);
+static bool pgwin32_IsInstalled(SC_HANDLE);
+static char *pgwin32_CommandLine(bool);
static void pgwin32_doRegister();
static void pgwin32_doUnregister();
static void pgwin32_SetServiceStatus(DWORD);
static void WINAPI pgwin32_ServiceHandler(DWORD);
-static void WINAPI pgwin32_ServiceMain(DWORD, LPTSTR*);
+static void WINAPI pgwin32_ServiceMain(DWORD, LPTSTR *);
static void pgwin32_doRunAsService();
#endif
static pgpid_t get_pgpid(void);
static char **readfile(char *path);
-static int start_postmaster(void);
+static int start_postmaster(void);
static bool test_postmaster_connection(void);
static char def_postopts_file[MAXPGPATH];
@@ -120,9 +122,11 @@ write_eventlog(int level, const char *line)
{
static HANDLE evtHandle = INVALID_HANDLE_VALUE;
- if (evtHandle == INVALID_HANDLE_VALUE) {
- evtHandle = RegisterEventSource(NULL,"PostgreSQL");
- if (evtHandle == NULL) {
+ if (evtHandle == INVALID_HANDLE_VALUE)
+ {
+ evtHandle = RegisterEventSource(NULL, "PostgreSQL");
+ if (evtHandle == NULL)
+ {
evtHandle = INVALID_HANDLE_VALUE;
return;
}
@@ -131,7 +135,7 @@ write_eventlog(int level, const char *line)
ReportEvent(evtHandle,
level,
0,
- 0, /* All events are Id 0 */
+ 0, /* All events are Id 0 */
NULL,
1,
0,
@@ -147,24 +151,28 @@ write_eventlog(int level, const char *line)
static void
write_stderr(const char *fmt,...)
{
- va_list ap;
+ va_list ap;
va_start(ap, fmt);
#ifndef WIN32
/* On Unix, we just fprintf to stderr */
vfprintf(stderr, fmt, ap);
#else
- /* On Win32, we print to stderr if running on a console, or write to
- * eventlog if running as a service */
- if (!isatty(fileno(stderr))) /* Running as a service */
+
+ /*
+ * On Win32, we print to stderr if running on a console, or write to
+ * eventlog if running as a service
+ */
+ if (!isatty(fileno(stderr))) /* Running as a service */
{
- char errbuf[2048]; /* Arbitrary size? */
+ char errbuf[2048]; /* Arbitrary size? */
vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
write_eventlog(EVENTLOG_ERROR_TYPE, errbuf);
}
- else /* Not running as service, write to stderr */
+ else
+/* Not running as service, write to stderr */
vfprintf(stderr, fmt, ap);
#endif
va_end(ap);
@@ -294,19 +302,19 @@ static int
start_postmaster(void)
{
/*
- * Since there might be quotes to handle here, it is easier simply
- * to pass everything to a shell to process them.
+ * Since there might be quotes to handle here, it is easier simply to
+ * pass everything to a shell to process them.
*/
char cmd[MAXPGPATH];
-
+
/*
- * Win32 needs START /B rather than "&".
+ * Win32 needs START /B rather than "&".
*
- * Win32 has a problem with START and quoted executable names.
- * You must add a "" as the title at the beginning so you can quote
- * the executable name:
- * http://www.winnetmag.com/Article/ArticleID/14589/14589.html
- * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
+ * Win32 has a problem with START and quoted executable names. You must
+ * add a "" as the title at the beginning so you can quote the
+ * executable name:
+ * http://www.winnetmag.com/Article/ArticleID/14589/14589.html
+ * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
*/
if (log_file != NULL)
#ifndef WIN32
@@ -314,16 +322,16 @@ start_postmaster(void)
#else
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
#endif
- SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
- DEVNULL, log_file, SYSTEMQUOTE);
+ SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
+ DEVNULL, log_file, SYSTEMQUOTE);
else
#ifndef WIN32
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
#else
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
#endif
- SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
- DEVNULL, SYSTEMQUOTE);
+ SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
+ DEVNULL, SYSTEMQUOTE);
return system(cmd);
}
@@ -338,7 +346,7 @@ test_postmaster_connection(void)
bool success = false;
int i;
char portstr[32];
- char *p;
+ char *p;
*portstr = '\0';
@@ -349,14 +357,14 @@ test_postmaster_connection(void)
/* advance past whitespace/quoting */
while (isspace(*p) || *p == '\'' || *p == '"')
p++;
-
+
if (strncmp(p, "-p", strlen("-p")) == 0)
{
p += strlen("-p");
/* advance past whitespace/quoting */
while (isspace(*p) || *p == '\'' || *p == '"')
p++;
- StrNCpy(portstr, p, Min(strcspn(p, "\"'"WHITESPACE) + 1,
+ StrNCpy(portstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1,
sizeof(portstr)));
/* keep looking, maybe there is another -p */
}
@@ -373,7 +381,7 @@ test_postmaster_connection(void)
optlines = readfile(conf_file);
if (optlines != NULL)
{
- for (;*optlines != NULL; optlines++)
+ for (; *optlines != NULL; optlines++)
{
p = *optlines;
@@ -389,7 +397,7 @@ test_postmaster_connection(void)
p++;
while (isspace(*p))
p++;
- StrNCpy(portstr, p, Min(strcspn(p, "#"WHITESPACE) + 1,
+ StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
sizeof(portstr)));
/* keep looking, maybe there is another */
}
@@ -407,7 +415,7 @@ test_postmaster_connection(void)
for (i = 0; i < wait_seconds; i++)
{
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
- "template1", NULL, NULL)) != NULL &&
+ "template1", NULL, NULL)) != NULL &&
PQstatus(conn) == CONNECTION_OK)
{
PQfinish(conn);
@@ -466,8 +474,8 @@ do_start(void)
else if (optlines[0] == NULL || optlines[1] != NULL)
{
write_stderr(_("%s: option file %s must have exactly 1 line\n"),
- progname, ctl_command == RESTART_COMMAND ?
- postopts_file : def_postopts_file);
+ progname, ctl_command == RESTART_COMMAND ?
+ postopts_file : def_postopts_file);
exit(1);
}
else
@@ -475,17 +483,17 @@ do_start(void)
optline = optlines[0];
len = strcspn(optline, "\r\n");
optline[len] = '\0';
-
+
if (ctl_command == RESTART_COMMAND)
{
char *arg1;
-
+
arg1 = strchr(optline, '\'');
if (arg1 == NULL || arg1 == optline)
post_opts = "";
else
{
- *(arg1 - 1) = '\0'; /* this should be a space */
+ *(arg1 - 1) = '\0'; /* this should be a space */
post_opts = arg1;
}
if (postgres_path != NULL)
@@ -498,8 +506,8 @@ do_start(void)
/* No -D or -D already added during server start */
if (ctl_command == RESTART_COMMAND || pgdata_opt == NULL)
- pgdata_opt = "";
-
+ pgdata_opt = "";
+
if (postgres_path == NULL)
{
char *postmaster_path;
@@ -512,7 +520,7 @@ do_start(void)
{
if (ret == -1)
write_stderr(_("The program \"postmaster\" is needed by %s "
- "but was not found in the same directory as "
+ "but was not found in the same directory as "
"\"%s\".\n"
"Check your installation.\n"),
progname, progname);
@@ -590,7 +598,7 @@ do_stop(void)
if (kill((pid_t) pid, sig) != 0)
{
write_stderr(_("stop signal failed (PID: %ld): %s\n"), pid,
- strerror(errno));
+ strerror(errno));
exit(1);
}
@@ -607,7 +615,7 @@ do_stop(void)
printf(_("waiting for postmaster to shut down..."));
fflush(stdout);
}
-
+
for (cnt = 0; cnt < wait_seconds; cnt++)
{
if ((pid = get_pgpid()) != 0)
@@ -617,17 +625,17 @@ do_stop(void)
printf(".");
fflush(stdout);
}
- pg_usleep(1000000); /* 1 sec */
+ pg_usleep(1000000); /* 1 sec */
}
else
break;
}
-
- if (pid != 0) /* pid file still exists */
+
+ if (pid != 0) /* pid file still exists */
{
if (!silence_echo)
printf(_(" failed\n"));
-
+
write_stderr(_("%s: postmaster does not shut down\n"), progname);
exit(1);
}
@@ -671,7 +679,7 @@ do_restart(void)
if (kill((pid_t) pid, sig) != 0)
{
write_stderr(_("stop signal failed (PID: %ld): %s\n"), pid,
- strerror(errno));
+ strerror(errno));
exit(1);
}
@@ -740,7 +748,7 @@ do_reload(void)
if (kill((pid_t) pid, sig) != 0)
{
write_stderr(_("reload signal failed (PID: %ld): %s\n"), pid,
- strerror(errno));
+ strerror(errno));
exit(1);
}
@@ -768,7 +776,8 @@ do_status(void)
pid = -pid;
fprintf(stdout, _("%s: a standalone backend \"postgres\" is running (PID: %ld)\n"), progname, pid);
}
- else /* postmaster */
+ else
+/* postmaster */
{
char **optlines;
@@ -789,26 +798,30 @@ do_kill(pgpid_t pid)
if (kill((pid_t) pid, sig) != 0)
{
write_stderr(_("signal %d failed (PID: %ld): %s\n"), sig, pid,
- strerror(errno));
+ strerror(errno));
exit(1);
}
}
#ifdef WIN32
-static bool pgwin32_IsInstalled(SC_HANDLE hSCM)
+static bool
+pgwin32_IsInstalled(SC_HANDLE hSCM)
{
- SC_HANDLE hService = OpenService(hSCM, register_servicename, SERVICE_QUERY_CONFIG);
- bool bResult = (hService != NULL);
+ SC_HANDLE hService = OpenService(hSCM, register_servicename, SERVICE_QUERY_CONFIG);
+ bool bResult = (hService != NULL);
+
if (bResult)
CloseServiceHandle(hService);
return bResult;
}
-static char* pgwin32_CommandLine(bool registration)
+static char *
+pgwin32_CommandLine(bool registration)
{
static char cmdLine[MAXPGPATH];
- int ret;
+ int ret;
+
if (registration)
ret = find_my_exec(argv0, cmdLine);
else
@@ -821,34 +834,34 @@ static char* pgwin32_CommandLine(bool registration)
if (registration)
{
- if (strcasecmp(cmdLine+strlen(cmdLine)-4,".exe"))
+ if (strcasecmp(cmdLine + strlen(cmdLine) - 4, ".exe"))
{
/* If commandline does not end in .exe, append it */
- strcat(cmdLine,".exe");
+ strcat(cmdLine, ".exe");
}
- strcat(cmdLine," runservice -N \"");
- strcat(cmdLine,register_servicename);
- strcat(cmdLine,"\"");
+ strcat(cmdLine, " runservice -N \"");
+ strcat(cmdLine, register_servicename);
+ strcat(cmdLine, "\"");
}
if (pg_data)
{
- strcat(cmdLine," -D \"");
- strcat(cmdLine,pg_data);
- strcat(cmdLine,"\"");
+ strcat(cmdLine, " -D \"");
+ strcat(cmdLine, pg_data);
+ strcat(cmdLine, "\"");
}
if (do_wait)
strcat(cmdLine, " -w");
-
+
if (post_opts)
{
- strcat(cmdLine," ");
+ strcat(cmdLine, " ");
if (registration)
- strcat(cmdLine," -o \"");
- strcat(cmdLine,post_opts);
+ strcat(cmdLine, " -o \"");
+ strcat(cmdLine, post_opts);
if (registration)
- strcat(cmdLine,"\"");
+ strcat(cmdLine, "\"");
}
return cmdLine;
@@ -857,8 +870,9 @@ static char* pgwin32_CommandLine(bool registration)
static void
pgwin32_doRegister()
{
- SC_HANDLE hService;
- SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ SC_HANDLE hService;
+ SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+
if (hSCM == NULL)
{
write_stderr(_("Unable to open service manager\n"));
@@ -867,18 +881,18 @@ pgwin32_doRegister()
if (pgwin32_IsInstalled(hSCM))
{
CloseServiceHandle(hSCM);
- write_stderr(_("Service \"%s\" already registered\n"),register_servicename);
+ write_stderr(_("Service \"%s\" already registered\n"), register_servicename);
exit(1);
}
if ((hService = CreateService(hSCM, register_servicename, register_servicename,
- SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
- SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
+ SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
pgwin32_CommandLine(true),
- NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
+ NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
{
CloseServiceHandle(hSCM);
- write_stderr(_("Unable to register service \"%s\" [%d]\n"), register_servicename, (int)GetLastError());
+ write_stderr(_("Unable to register service \"%s\" [%d]\n"), register_servicename, (int) GetLastError());
exit(1);
}
CloseServiceHandle(hService);
@@ -888,8 +902,9 @@ pgwin32_doRegister()
static void
pgwin32_doUnregister()
{
- SC_HANDLE hService;
- SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ SC_HANDLE hService;
+ SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+
if (hSCM == NULL)
{
write_stderr(_("Unable to open service manager\n"));
@@ -898,20 +913,21 @@ pgwin32_doUnregister()
if (!pgwin32_IsInstalled(hSCM))
{
CloseServiceHandle(hSCM);
- write_stderr(_("Service \"%s\" not registered\n"),register_servicename);
+ write_stderr(_("Service \"%s\" not registered\n"), register_servicename);
exit(1);
}
if ((hService = OpenService(hSCM, register_servicename, DELETE)) == NULL)
{
CloseServiceHandle(hSCM);
- write_stderr(_("Unable to open service \"%s\" [%d]\n"), register_servicename, (int)GetLastError());
+ write_stderr(_("Unable to open service \"%s\" [%d]\n"), register_servicename, (int) GetLastError());
exit(1);
}
- if (!DeleteService(hService)) {
+ if (!DeleteService(hService))
+ {
CloseServiceHandle(hService);
CloseServiceHandle(hSCM);
- write_stderr(_("Unable to unregister service \"%s\" [%d]\n"), register_servicename, (int)GetLastError());
+ write_stderr(_("Unable to unregister service \"%s\" [%d]\n"), register_servicename, (int) GetLastError());
exit(1);
}
CloseServiceHandle(hService);
@@ -920,29 +936,34 @@ pgwin32_doUnregister()
static SERVICE_STATUS status;
-static SERVICE_STATUS_HANDLE hStatus = (SERVICE_STATUS_HANDLE)0;
+static SERVICE_STATUS_HANDLE hStatus = (SERVICE_STATUS_HANDLE) 0;
static HANDLE shutdownHandles[2];
static pid_t postmasterPID = -1;
-#define shutdownEvent shutdownHandles[0]
+
+#define shutdownEvent shutdownHandles[0]
#define postmasterProcess shutdownHandles[1]
-static void pgwin32_SetServiceStatus(DWORD currentState)
+static void
+pgwin32_SetServiceStatus(DWORD currentState)
{
status.dwCurrentState = currentState;
- SetServiceStatus(hStatus, (LPSERVICE_STATUS)&status);
+ SetServiceStatus(hStatus, (LPSERVICE_STATUS) & status);
}
-static void WINAPI pgwin32_ServiceHandler(DWORD request)
+static void WINAPI
+pgwin32_ServiceHandler(DWORD request)
{
switch (request)
{
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
- /*
- * We only need a short wait hint here as it just needs to wait for
- * the next checkpoint. They occur every 5 seconds during shutdown
+
+ /*
+ * We only need a short wait hint here as it just needs to
+ * wait for the next checkpoint. They occur every 5 seconds
+ * during shutdown
*/
- status.dwWaitHint = 10000;
+ status.dwWaitHint = 10000;
pgwin32_SetServiceStatus(SERVICE_STOP_PENDING);
SetEvent(shutdownEvent);
return;
@@ -950,10 +971,10 @@ static void WINAPI pgwin32_ServiceHandler(DWORD request)
case SERVICE_CONTROL_PAUSE:
/* Win32 config reloading */
status.dwWaitHint = 5000;
- kill(postmasterPID,SIGHUP);
+ kill(postmasterPID, SIGHUP);
return;
- /* FIXME: These could be used to replace other signals etc */
+ /* FIXME: These could be used to replace other signals etc */
case SERVICE_CONTROL_CONTINUE:
case SERVICE_CONTROL_INTERROGATE:
default:
@@ -961,63 +982,62 @@ static void WINAPI pgwin32_ServiceHandler(DWORD request)
}
}
-static void WINAPI pgwin32_ServiceMain(DWORD argc, LPTSTR *argv)
+static void WINAPI
+pgwin32_ServiceMain(DWORD argc, LPTSTR * argv)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
- DWORD ret;
+ DWORD ret;
/* Initialize variables */
- status.dwWin32ExitCode = S_OK;
- status.dwCheckPoint = 0;
- status.dwWaitHint = 60000;
- status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
- status.dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN|SERVICE_ACCEPT_PAUSE_CONTINUE;
- status.dwServiceSpecificExitCode = 0;
+ status.dwWin32ExitCode = S_OK;
+ status.dwCheckPoint = 0;
+ status.dwWaitHint = 60000;
+ status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_PAUSE_CONTINUE;
+ status.dwServiceSpecificExitCode = 0;
status.dwCurrentState = SERVICE_START_PENDING;
- memset(&pi,0,sizeof(pi));
- memset(&si,0,sizeof(si));
+ memset(&pi, 0, sizeof(pi));
+ memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
/* Register the control request handler */
- if ((hStatus = RegisterServiceCtrlHandler(register_servicename, pgwin32_ServiceHandler)) == (SERVICE_STATUS_HANDLE)0)
+ if ((hStatus = RegisterServiceCtrlHandler(register_servicename, pgwin32_ServiceHandler)) == (SERVICE_STATUS_HANDLE) 0)
return;
- if ((shutdownEvent = CreateEvent(NULL,true,false,NULL)) == NULL)
+ if ((shutdownEvent = CreateEvent(NULL, true, false, NULL)) == NULL)
return;
/* Start the postmaster */
pgwin32_SetServiceStatus(SERVICE_START_PENDING);
- if (!CreateProcess(NULL,pgwin32_CommandLine(false),NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
+ if (!CreateProcess(NULL, pgwin32_CommandLine(false), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
{
pgwin32_SetServiceStatus(SERVICE_STOPPED);
return;
}
- postmasterPID = pi.dwProcessId;
- postmasterProcess = pi.hProcess;
+ postmasterPID = pi.dwProcessId;
+ postmasterProcess = pi.hProcess;
CloseHandle(pi.hThread);
pgwin32_SetServiceStatus(SERVICE_RUNNING);
/* Wait for quit... */
- ret = WaitForMultipleObjects(2,shutdownHandles,FALSE,INFINITE);
+ ret = WaitForMultipleObjects(2, shutdownHandles, FALSE, INFINITE);
pgwin32_SetServiceStatus(SERVICE_STOP_PENDING);
switch (ret)
{
- case WAIT_OBJECT_0: /* shutdown event */
- kill(postmasterPID,SIGINT);
-
- /*
- * Increment the checkpoint and try again
- * Abort after 12 checkpoints as the postmaster has probably hung
+ case WAIT_OBJECT_0: /* shutdown event */
+ kill(postmasterPID, SIGINT);
+
+ /*
+ * Increment the checkpoint and try again Abort after 12
+ * checkpoints as the postmaster has probably hung
*/
- while (WaitForSingleObject(postmasterProcess,5000) == WAIT_TIMEOUT && status.dwCheckPoint < 12)
- {
+ while (WaitForSingleObject(postmasterProcess, 5000) == WAIT_TIMEOUT && status.dwCheckPoint < 12)
status.dwCheckPoint++;
- }
break;
- case (WAIT_OBJECT_0+1): /* postmaster went down */
+ case (WAIT_OBJECT_0 + 1): /* postmaster went down */
break;
default:
@@ -1031,13 +1051,14 @@ static void WINAPI pgwin32_ServiceMain(DWORD argc, LPTSTR *argv)
pgwin32_SetServiceStatus(SERVICE_STOPPED);
}
-static void pgwin32_doRunAsService()
+static void
+pgwin32_doRunAsService()
{
- SERVICE_TABLE_ENTRY st[] = {{ register_servicename, pgwin32_ServiceMain },
- { NULL, NULL }};
+ SERVICE_TABLE_ENTRY st[] = {{register_servicename, pgwin32_ServiceMain},
+ {NULL, NULL}};
+
StartServiceCtrlDispatcher(st);
}
-
#endif
static void
@@ -1052,7 +1073,7 @@ static void
do_help(void)
{
printf(_("%s is a utility to start, stop, restart, reload configuration files,\n"
- "report the status of a PostgreSQL server, or kill a PostgreSQL process\n\n"), progname);
+ "report the status of a PostgreSQL server, or kill a PostgreSQL process\n\n"), progname);
printf(_("Usage:\n"));
printf(_(" %s start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n"), progname);
@@ -1080,9 +1101,9 @@ do_help(void)
printf(_("If the -D option is omitted, the environment variable PGDATA is used.\n\n"));
printf(_("Options for start or restart:\n"));
printf(_(" -l, --log FILENAME write (or append) server log to FILENAME. The\n"
- " use of this option is highly recommended.\n"));
+ " use of this option is highly recommended.\n"));
printf(_(" -o OPTIONS command line options to pass to the postmaster\n"
- " (PostgreSQL server executable)\n"));
+ " (PostgreSQL server executable)\n"));
printf(_(" -p PATH-TO-POSTMASTER normally not necessary\n\n"));
printf(_("Options for stop or restart:\n"));
printf(_(" -m SHUTDOWN-MODE may be 'smart', 'fast', or 'immediate'\n\n"));
@@ -1175,7 +1196,7 @@ main(int argc, char **argv)
int option_index;
int c;
pgpid_t killproc = 0;
-
+
#ifdef WIN32
setvbuf(stderr, NULL, _IONBF, 0);
#endif
@@ -1192,8 +1213,8 @@ main(int argc, char **argv)
umask(077);
- if (argc > 1)
- {
+ if (argc > 1)
+ {
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 ||
strcmp(argv[1], "-?") == 0)
{
@@ -1208,13 +1229,13 @@ main(int argc, char **argv)
}
/*
- * 'Action' can be before or after args so loop over both.
- * Some getopt_long() implementations will reorder argv[]
- * to place all flags first (GNU?), but we don't rely on it.
- * Our /port version doesn't do that.
+ * 'Action' can be before or after args so loop over both. Some
+ * getopt_long() implementations will reorder argv[] to place all
+ * flags first (GNU?), but we don't rely on it. Our /port version
+ * doesn't do that.
*/
optind = 1;
-
+
/* process command-line options */
while (optind < argc)
{
@@ -1223,18 +1244,22 @@ main(int argc, char **argv)
switch (c)
{
case 'D':
- {
- int len = strlen(optarg);
- char *env_var;
-
- env_var = xmalloc(len + 8);
- snprintf(env_var, len + 8, "PGDATA=%s", optarg);
- putenv(env_var);
- /* Show -D for easier postmaster 'ps' identification */
- pgdata_opt = xmalloc(len + 7);
- snprintf(pgdata_opt, len + 7, "-D \"%s\" ", optarg);
- break;
- }
+ {
+ int len = strlen(optarg);
+ char *env_var;
+
+ env_var = xmalloc(len + 8);
+ snprintf(env_var, len + 8, "PGDATA=%s", optarg);
+ putenv(env_var);
+
+ /*
+ * Show -D for easier postmaster 'ps'
+ * identification
+ */
+ pgdata_opt = xmalloc(len + 7);
+ snprintf(pgdata_opt, len + 7, "-D \"%s\" ", optarg);
+ break;
+ }
case 'l':
log_file = xstrdup(optarg);
break;
@@ -1251,24 +1276,25 @@ main(int argc, char **argv)
postgres_path = xstrdup(optarg);
break;
case 'P':
- register_password = xstrdup(optarg);
+ register_password = xstrdup(optarg);
break;
case 's':
silence_echo = true;
break;
case 'U':
- if (strchr(optarg,'\\'))
- register_username = xstrdup(optarg);
- else /* Prepend .\ for local accounts */
+ if (strchr(optarg, '\\'))
+ register_username = xstrdup(optarg);
+ else
+/* Prepend .\ for local accounts */
{
- register_username = malloc(strlen(optarg)+3);
+ register_username = malloc(strlen(optarg) + 3);
if (!register_username)
{
write_stderr(_("%s: out of memory\n"), progname);
exit(1);
}
- strcpy(register_username,".\\");
- strcat(register_username,optarg);
+ strcpy(register_username, ".\\");
+ strcat(register_username, optarg);
}
break;
case 'w':
@@ -1285,7 +1311,7 @@ main(int argc, char **argv)
exit(1);
}
}
-
+
/* Process an action */
if (optind < argc)
{
@@ -1295,7 +1321,7 @@ main(int argc, char **argv)
do_advice();
exit(1);
}
-
+
if (strcmp(argv[optind], "start") == 0)
ctl_command = START_COMMAND;
else if (strcmp(argv[optind], "stop") == 0)
@@ -1409,15 +1435,15 @@ main(int argc, char **argv)
do_kill(killproc);
break;
#ifdef WIN32
- case REGISTER_COMMAND:
- pgwin32_doRegister();
- break;
- case UNREGISTER_COMMAND:
- pgwin32_doUnregister();
- break;
- case RUN_AS_SERVICE_COMMAND:
- pgwin32_doRunAsService();
- break;
+ case REGISTER_COMMAND:
+ pgwin32_doRegister();
+ break;
+ case UNREGISTER_COMMAND:
+ pgwin32_doUnregister();
+ break;
+ case RUN_AS_SERVICE_COMMAND:
+ pgwin32_doRunAsService();
+ break;
#endif
default:
break;
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 9243763e539..cbf1b8a3bb2 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.83 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.84 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,14 +49,14 @@ static int numCatalogIds = 0;
* These variables are static to avoid the notational cruft of having to pass
* them into findTableByOid() and friends.
*/
-static TableInfo *tblinfo;
-static TypeInfo *typinfo;
-static FuncInfo *funinfo;
-static OprInfo *oprinfo;
-static int numTables;
-static int numTypes;
-static int numFuncs;
-static int numOperators;
+static TableInfo *tblinfo;
+static TypeInfo *typinfo;
+static FuncInfo *funinfo;
+static OprInfo *oprinfo;
+static int numTables;
+static int numTypes;
+static int numFuncs;
+static int numOperators;
static void flagInhTables(TableInfo *tbinfo, int numTables,
@@ -65,7 +65,7 @@ static void flagInhAttrs(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits);
static int DOCatalogIdCompare(const void *p1, const void *p2);
static void findParentsByOid(TableInfo *self,
- InhInfo *inhinfo, int numInherits);
+ InhInfo *inhinfo, int numInherits);
static int strInArray(const char *pattern, char **arr, int arr_size);
@@ -302,7 +302,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
{
defaultsFound = true;
defaultsMatch &= (strcmp(attrDef->adef_expr,
- inhDef->adef_expr) == 0);
+ inhDef->adef_expr) == 0);
}
}
}
@@ -358,7 +358,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
for (k = 0; k < numParents; k++)
{
- int l;
+ int l;
parent = parents[k];
for (l = 0; l < parent->ncheck; l++)
@@ -403,7 +403,7 @@ AssignDumpId(DumpableObject *dobj)
while (dobj->dumpId >= allocedDumpIds)
{
- int newAlloc;
+ int newAlloc;
if (allocedDumpIds <= 0)
{
@@ -470,7 +470,7 @@ findObjectByDumpId(DumpId dumpId)
*
* We use binary search in a sorted list that is built on first call.
* If AssignDumpId() and findObjectByCatalogId() calls were intermixed,
- * the code would work, but possibly be very slow. In the current usage
+ * the code would work, but possibly be very slow. In the current usage
* pattern that does not happen, indeed we only need to build the list once.
*/
DumpableObject *
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index f2f9cf80d48..dabb6159028 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.14 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.15 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -154,7 +154,7 @@ void
appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
{
static const char suffixes[] = "_XXXXXXX";
- int nextchar = 0;
+ int nextchar = 0;
PQExpBuffer delimBuf = createPQExpBuffer();
/* start with $ + dqprefix if not NULL */
@@ -163,15 +163,15 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
appendPQExpBuffer(delimBuf, dqprefix);
/*
- * Make sure we choose a delimiter which (without the trailing $)
- * is not present in the string being quoted. We don't check with the
+ * Make sure we choose a delimiter which (without the trailing $) is
+ * not present in the string being quoted. We don't check with the
* trailing $ because a string ending in $foo must not be quoted with
* $foo$.
*/
while (strstr(str, delimBuf->data) != NULL)
{
appendPQExpBufferChar(delimBuf, suffixes[nextchar++]);
- nextchar %= sizeof(suffixes)-1;
+ nextchar %= sizeof(suffixes) - 1;
}
/* add trailing $ */
@@ -195,9 +195,9 @@ appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
bool escapeAll, const char *dqprefix)
{
if (strchr(str, '\'') == NULL && strchr(str, '\\') == NULL)
- appendStringLiteral(buf,str,escapeAll);
+ appendStringLiteral(buf, str, escapeAll);
else
- appendStringLiteralDQ(buf,str,dqprefix);
+ appendStringLiteralDQ(buf, str, dqprefix);
}
@@ -621,7 +621,10 @@ copyAclUserName(PQExpBuffer output, char *input)
while (*input && *input != '=')
{
- /* If user name isn't quoted, then just add it to the output buffer */
+ /*
+ * If user name isn't quoted, then just add it to the output
+ * buffer
+ */
if (*input != '"')
appendPQExpBufferChar(output, *input++);
else
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index a0476bb6d39..40e1942e07a 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.12 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.13 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,10 +21,10 @@
extern const char *fmtId(const char *identifier);
extern void appendStringLiteral(PQExpBuffer buf, const char *str,
bool escapeAll);
-extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
- const char *dqprefix);
-extern void appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
- bool escapeAll, const char *dqprefix);
+extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
+ const char *dqprefix);
+extern void appendStringLiteralDQOpt(PQExpBuffer buf, const char *str,
+ bool escapeAll, const char *dqprefix);
extern int parse_version(const char *versionString);
extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
extern bool buildACLCommands(const char *name, const char *type,
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 7723203df7f..293985508f1 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.32 2004/08/20 04:20:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.33 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,10 +70,12 @@ typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
typedef struct _restoreOptions
{
int create; /* Issue commands to create the database */
- int noOwner; /* Don't try to match original object owner */
+ int noOwner; /* Don't try to match original object
+ * owner */
int disable_triggers; /* disable triggers during
* data-only restore */
- int use_setsessauth; /* Use SET SESSION AUTHORIZATION commands instead of OWNER TO */
+ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
+ * instead of OWNER TO */
char *superuser; /* Username to use as superuser */
int dataOnly;
int dropSchema;
@@ -179,4 +181,4 @@ archprintf(Archive *AH, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
-#endif /* PG_BACKUP_H */
+#endif /* PG_BACKUP_H */
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 698e7fd524e..a4786e4b62c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.94 2004/08/20 20:00:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.95 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,12 +47,12 @@ static char *modulename = gettext_noop("archiver");
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode);
-static char *_getObjectFromDropStmt(const char *dropStmt, const char *type);
+static char *_getObjectFromDropStmt(const char *dropStmt, const char *type);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
static void fixPriorBlobRefs(ArchiveHandle *AH, TocEntry *blobte,
- RestoreOptions *ropt);
+ RestoreOptions *ropt);
static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
static void _doSetWithOids(ArchiveHandle *AH, const bool withOids);
@@ -167,7 +167,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
ConnectDatabase(AHX, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->requirePassword, ropt->ignoreVersion);
- /* If we're talking to the DB directly, don't send comments since they obscure SQL when displaying errors */
+
+ /*
+ * If we're talking to the DB directly, don't send comments since
+ * they obscure SQL when displaying errors
+ */
AH->noTocComments = 1;
}
@@ -294,7 +298,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* If we can output the data, then restore it.
*/
- if (AH->PrintTocDataPtr != NULL && (reqs & REQ_DATA) != 0)
+ if (AH->PrintTocDataPtr !=NULL && (reqs & REQ_DATA) != 0)
{
#ifndef HAVE_LIBZ
if (AH->compression != 0)
@@ -350,10 +354,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
* If we just restored blobs, fix references in
* previously-loaded tables; otherwise, if we
* previously restored blobs, fix references in
- * this table. Note that in standard cases the BLOBS
- * entry comes after all TABLE DATA entries, but
- * we should cope with other orders in case the
- * user demands reordering.
+ * this table. Note that in standard cases the
+ * BLOBS entry comes after all TABLE DATA entries,
+ * but we should cope with other orders in case
+ * the user demands reordering.
*/
if (strcmp(te->desc, "BLOBS") == 0)
fixPriorBlobRefs(AH, te, ropt);
@@ -376,7 +380,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
}
}
te = te->next;
- } /* end loop over TOC entries */
+ } /* end loop over TOC entries */
/*
* Scan TOC again to output ownership commands and ACLs
@@ -424,7 +428,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* After restoring BLOBS, fix all blob references in previously-restored
- * tables. (Normally, the BLOBS entry should appear after all TABLE DATA
+ * tables. (Normally, the BLOBS entry should appear after all TABLE DATA
* entries, so this will in fact handle all blob references.)
*/
static void
@@ -504,8 +508,8 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop
/*
* Become superuser if possible, since they are the only ones who can
- * update pg_class. If -S was not given, assume the initial user identity
- * is a superuser.
+ * update pg_class. If -S was not given, assume the initial user
+ * identity is a superuser.
*/
_becomeUser(AH, ropt->superuser);
@@ -543,8 +547,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
/*
* Become superuser if possible, since they are the only ones who can
- * update pg_class. If -S was not given, assume the initial user identity
- * is a superuser.
+ * update pg_class. If -S was not given, assume the initial user
+ * identity is a superuser.
*/
_becomeUser(AH, ropt->superuser);
@@ -650,7 +654,7 @@ ArchiveEntry(Archive *AHX,
newToc->formatData = NULL;
- if (AH->ArchiveEntryPtr != NULL)
+ if (AH->ArchiveEntryPtr !=NULL)
(*AH->ArchiveEntryPtr) (AH, newToc);
}
@@ -664,7 +668,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
char *fmtName;
if (ropt->filename)
- sav = SetOutput(AH, ropt->filename, 0 /* no compression */);
+ sav = SetOutput(AH, ropt->filename, 0 /* no compression */ );
ahprintf(AH, ";\n; Archive created at %s", ctime(&AH->createDate));
ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
@@ -942,9 +946,8 @@ archprintf(Archive *AH, const char *fmt,...)
/*
* This is paranoid: deal with the possibility that vsnprintf is
- * willing to ignore trailing null
- * or returns > 0 even if string does not fit. It may be the case that
- * it returns cnt = bufsize
+ * willing to ignore trailing null or returns > 0 even if string does
+ * not fit. It may be the case that it returns cnt = bufsize
*/
while (cnt < 0 || cnt >= (bSize - 1))
{
@@ -1236,48 +1239,45 @@ die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...)
/* on some error, we may decide to go on... */
void
-warn_or_die_horribly(ArchiveHandle *AH,
- const char *modulename, const char *fmt, ...)
+warn_or_die_horribly(ArchiveHandle *AH,
+ const char *modulename, const char *fmt,...)
{
- va_list ap;
+ va_list ap;
- switch(AH->stage) {
+ switch (AH->stage)
+ {
case STAGE_NONE:
/* Do nothing special */
break;
case STAGE_INITIALIZING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while INITIALIZING:\n");
- }
break;
case STAGE_PROCESSING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while PROCESSING TOC:\n");
- }
break;
case STAGE_FINALIZING:
- if (AH->stage != AH->lastErrorStage) {
+ if (AH->stage != AH->lastErrorStage)
write_msg(modulename, "Error while FINALIZING:\n");
- }
break;
}
- if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE) {
+ if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE)
+ {
write_msg(modulename, "Error from TOC Entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId,
- AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
- AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
+ AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
+ AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
}
AH->lastErrorStage = AH->stage;
AH->lastErrorTE = AH->currentTE;
va_start(ap, fmt);
if (AH->public.exit_on_error)
- {
_die_horribly(AH, modulename, fmt, ap);
- }
else
{
_write_msg(modulename, fmt, ap);
@@ -1312,7 +1312,6 @@ _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te)
pos->prev->next = te;
pos->prev = te;
}
-
#endif
static TocEntry *
@@ -1689,7 +1688,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
* later if necessary */
AH->currSchema = strdup(""); /* ditto */
AH->currWithOids = -1; /* force SET */
-
+
AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
if (!AH->toc)
die_horribly(AH, modulename, "out of memory\n");
@@ -1863,7 +1862,7 @@ ReadToc(ArchiveHandle *AH)
/* Sanity check */
if (te->dumpId <= 0)
die_horribly(AH, modulename,
- "entry ID %d out of range -- perhaps a corrupt TOC\n",
+ "entry ID %d out of range -- perhaps a corrupt TOC\n",
te->dumpId);
te->hadDumper = ReadInt(AH);
@@ -1901,7 +1900,7 @@ ReadToc(ArchiveHandle *AH)
}
else
te->withOids = true;
-
+
/* Read TOC entry dependencies */
if (AH->version >= K_VERS_1_5)
{
@@ -2129,7 +2128,7 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
PQExpBuffer cmd = createPQExpBuffer();
appendPQExpBuffer(cmd, "SET default_with_oids = %s;", withOids ?
- "true" : "false");
+ "true" : "false");
if (RestoringToDB(AH))
{
@@ -2138,7 +2137,7 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
res = PQexec(AH->connection, cmd->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_die_horribly(AH, modulename,
+ warn_or_die_horribly(AH, modulename,
"could not set default_with_oids: %s",
PQerrorMessage(AH->connection));
@@ -2192,7 +2191,7 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user)
free(AH->currSchema);
AH->currSchema = strdup("");
AH->currWithOids = -1;
-
+
/* re-establish fixed state */
_doSetFixedOutputState(AH);
}
@@ -2224,7 +2223,7 @@ _becomeUser(ArchiveHandle *AH, const char *user)
}
/*
- * Become the owner of the the given TOC entry object. If
+ * Become the owner of the the given TOC entry object. If
* changes in ownership are not allowed, this doesn't do anything.
*/
static void
@@ -2278,9 +2277,9 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
res = PQexec(AH->connection, qry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_die_horribly(AH, modulename,
- "could not set search_path to \"%s\": %s",
- schemaName, PQerrorMessage(AH->connection));
+ warn_or_die_horribly(AH, modulename,
+ "could not set search_path to \"%s\": %s",
+ schemaName, PQerrorMessage(AH->connection));
PQclear(res);
}
@@ -2304,21 +2303,27 @@ static char *
_getObjectFromDropStmt(const char *dropStmt, const char *type)
{
/* Chop "DROP" off the front and make a copy */
- char *first = strdup(dropStmt + 5);
- char *last = first + strlen(first) - 1; /* Points to the last real char in extract */
- char *buf = NULL;
+ char *first = strdup(dropStmt + 5);
+ char *last = first + strlen(first) - 1; /* Points to the last
+ * real char in extract */
+ char *buf = NULL;
- /* Loop from the end of the string until last char is no longer '\n' or ';' */
- while (last >= first && (*last == '\n' || *last == ';')) {
+ /*
+ * Loop from the end of the string until last char is no longer '\n'
+ * or ';'
+ */
+ while (last >= first && (*last == '\n' || *last == ';'))
last--;
- }
/* Insert end of string one place after last */
*(last + 1) = '\0';
- /* Take off CASCADE if necessary. Only TYPEs seem to have this, but may
- * as well check for all */
- if ((last - first) >= 8) {
+ /*
+ * Take off CASCADE if necessary. Only TYPEs seem to have this, but
+ * may as well check for all
+ */
+ if ((last - first) >= 8)
+ {
if (strcmp(last - 7, " CASCADE") == 0)
last -= 8;
}
@@ -2329,22 +2334,22 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
/* Special case VIEWs and SEQUENCEs. They must use ALTER TABLE. */
if (strcmp(type, "VIEW") == 0 && (last - first) >= 5)
{
- int len = 6 + strlen(first + 5) + 1;
+ int len = 6 + strlen(first + 5) + 1;
+
buf = malloc(len);
snprintf(buf, len, "TABLE %s", first + 5);
- free (first);
+ free(first);
}
else if (strcmp(type, "SEQUENCE") == 0 && (last - first) >= 9)
{
- int len = 6 + strlen(first + 9) + 1;
+ int len = 6 + strlen(first + 9) + 1;
+
buf = malloc(len);
snprintf(buf, len, "TABLE %s", first + 9);
- free (first);
+ free(first);
}
else
- {
buf = first;
- }
return buf;
}
@@ -2352,7 +2357,7 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
static void
_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass)
{
- const char *pfx;
+ const char *pfx;
/* ACLs are dumped only during acl pass */
if (acl_pass)
@@ -2366,7 +2371,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
return;
}
- if (AH->noTocComments)
+ if (AH->noTocComments)
return;
/*
@@ -2399,7 +2404,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
te->dumpId, te->catalogId.tableoid, te->catalogId.oid);
if (te->nDeps > 0)
{
- int i;
+ int i;
ahprintf(AH, "-- Dependencies:");
for (i = 0; i < te->nDeps; i++)
@@ -2411,16 +2416,16 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-",
te->owner);
- if (AH->PrintExtraTocPtr != NULL)
+ if (AH->PrintExtraTocPtr !=NULL)
(*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n");
/*
* Actually print the definition.
*
- * Really crude hack for suppressing AUTHORIZATION clause of CREATE SCHEMA
- * when --no-owner mode is selected. This is ugly, but I see no other
- * good way ...
+ * Really crude hack for suppressing AUTHORIZATION clause of CREATE
+ * SCHEMA when --no-owner mode is selected. This is ugly, but I see
+ * no other good way ...
*/
if (AH->ropt && AH->ropt->noOwner && strcmp(te->desc, "SCHEMA") == 0)
{
@@ -2434,10 +2439,10 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* If we aren't using SET SESSION AUTH to determine ownership, we must
- * instead issue an ALTER OWNER command. Ugly, since we have to
- * cons one up based on the dropStmt. We don't need this for schemas
- * (since we use CREATE SCHEMA AUTHORIZATION instead), nor for some other
- * object types.
+ * instead issue an ALTER OWNER command. Ugly, since we have to cons
+ * one up based on the dropStmt. We don't need this for schemas
+ * (since we use CREATE SCHEMA AUTHORIZATION instead), nor for some
+ * other object types.
*/
if (!ropt->noOwner && !ropt->use_setsessauth &&
strlen(te->owner) > 0 && strlen(te->dropStmt) > 0 &&
@@ -2452,7 +2457,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
strcmp(te->desc, "VIEW") == 0 ||
strcmp(te->desc, "SEQUENCE") == 0))
{
- char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
+ char *temp = _getObjectFromDropStmt(te->dropStmt, te->desc);
ahprintf(AH, "ALTER %s OWNER TO %s;\n\n", temp, fmtId(te->owner));
free(temp);
@@ -2460,7 +2465,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* If it's an ACL entry, it might contain SET SESSION AUTHORIZATION
- * commands, so we can no longer assume we know the current auth setting.
+ * commands, so we can no longer assume we know the current auth
+ * setting.
*/
if (strncmp(te->desc, "ACL", 3) == 0)
{
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 9664ab23651..c44a0ad1bf8 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.60 2004/08/20 20:00:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.61 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,8 +79,11 @@ typedef z_stream *z_streamp;
#define K_VERS_1_6 (( (1 * 256 + 6) * 256 + 0) * 256 + 0) /* Schema field in TOCs */
#define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0) /* File Offset size in
* header */
-#define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0) /* change interpretation of ID numbers and dependencies */
-#define K_VERS_1_9 (( (1 * 256 + 9) * 256 + 0) * 256 + 0) /* add default_with_oids tracking */
+#define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0) /* change interpretation
+ * of ID numbers and
+ * dependencies */
+#define K_VERS_1_9 (( (1 * 256 + 9) * 256 + 0) * 256 + 0) /* add default_with_oids
+ * tracking */
#define K_VERS_MAX (( (1 * 256 + 9) * 256 + 255) * 256 + 0)
@@ -149,15 +152,15 @@ typedef struct
char lastChar;
char quoteChar;
int braceDepth;
- PQExpBuffer tagBuf;
+ PQExpBuffer tagBuf;
} sqlparseInfo;
-typedef enum
+typedef enum
{
- STAGE_NONE = 0,
- STAGE_INITIALIZING,
- STAGE_PROCESSING,
- STAGE_FINALIZING
+ STAGE_NONE = 0,
+ STAGE_INITIALIZING,
+ STAGE_PROCESSING,
+ STAGE_FINALIZING
} ArchiverStage;
typedef struct _archiveHandle
@@ -258,16 +261,16 @@ typedef struct _archiveHandle
char *currUser; /* current username */
char *currSchema; /* current schema */
bool currWithOids; /* current default_with_oids setting */
-
+
void *lo_buf;
size_t lo_buf_used;
size_t lo_buf_size;
- int noTocComments;
- ArchiverStage stage;
- ArchiverStage lastErrorStage;
- struct _tocEntry *currentTE;
- struct _tocEntry *lastErrorTE;
+ int noTocComments;
+ ArchiverStage stage;
+ ArchiverStage lastErrorStage;
+ struct _tocEntry *currentTE;
+ struct _tocEntry *lastErrorTE;
} ArchiveHandle;
typedef struct _tocEntry
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 7ae61c80825..1489bfbc167 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
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.56 2004/08/28 22:52:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.57 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,8 +37,8 @@ static void notice_processor(void *arg, const char *message);
static char *_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos);
static char *_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos);
-static int _isIdentChar(unsigned char c);
-static int _isDQChar(unsigned char c, int atStart);
+static int _isIdentChar(unsigned char c);
+static int _isDQChar(unsigned char c, int atStart);
#define DB_MAX_ERR_STMT 128
@@ -304,7 +304,7 @@ static int
_executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
{
PGresult *res;
- char errStmt[DB_MAX_ERR_STMT];
+ char errStmt[DB_MAX_ERR_STMT];
/* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */
res = PQexec(conn, qry->data);
@@ -323,15 +323,16 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
else
{
strncpy(errStmt, qry->data, DB_MAX_ERR_STMT);
- if (errStmt[DB_MAX_ERR_STMT-1] != '\0') {
- errStmt[DB_MAX_ERR_STMT-4] = '.';
- errStmt[DB_MAX_ERR_STMT-3] = '.';
- errStmt[DB_MAX_ERR_STMT-2] = '.';
- errStmt[DB_MAX_ERR_STMT-1] = '\0';
+ if (errStmt[DB_MAX_ERR_STMT - 1] != '\0')
+ {
+ errStmt[DB_MAX_ERR_STMT - 4] = '.';
+ errStmt[DB_MAX_ERR_STMT - 3] = '.';
+ errStmt[DB_MAX_ERR_STMT - 2] = '.';
+ errStmt[DB_MAX_ERR_STMT - 1] = '\0';
}
warn_or_die_horribly(AH, modulename, "%s: %s Command was: %s\n",
- desc, PQerrorMessage(AH->connection),
- errStmt);
+ desc, PQerrorMessage(AH->connection),
+ errStmt);
}
}
@@ -431,8 +432,8 @@ static char *
_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
{
int pos = 0; /* Current position */
- char *sqlPtr;
- int consumed;
+ char *sqlPtr;
+ int consumed;
int startDT = 0;
/*
@@ -454,22 +455,24 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
/* Loop until character consumed */
do
{
- /* If a character needs to be scanned in a different state,
- * consumed can be set to 0 to avoid advancing. Care must
- * be taken to ensure internal state is not damaged.
+ /*
+ * If a character needs to be scanned in a different state,
+ * consumed can be set to 0 to avoid advancing. Care must be
+ * taken to ensure internal state is not damaged.
*/
consumed = 1;
switch (AH->sqlparse.state)
- {
-
- case SQL_SCAN: /* Default state == 0, set in _allocAH */
+ {
+
+ case SQL_SCAN: /* Default state == 0, set in _allocAH */
if (qry[pos] == ';' && AH->sqlparse.braceDepth == 0)
{
- /* We've got the end of a statement.
- * Send It & reset the buffer.
+ /*
+ * We've got the end of a statement. Send It &
+ * reset the buffer.
*/
-
+
/*
* fprintf(stderr, " sending: '%s'\n\n",
* AH->sqlBuf->data);
@@ -477,28 +480,30 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
ExecuteSqlCommand(AH, AH->sqlBuf, "could not execute query", false);
resetPQExpBuffer(AH->sqlBuf);
AH->sqlparse.lastChar = '\0';
-
+
/*
- * Remove any following newlines - so that embedded
- * COPY commands don't get a starting newline.
+ * Remove any following newlines - so that
+ * embedded COPY commands don't get a starting
+ * newline.
*/
pos++;
for (; pos < (eos - qry) && qry[pos] == '\n'; pos++);
-
+
/* We've got our line, so exit */
return qry + pos;
}
else
{
- /*
- * Look for normal boring quote chars, or dollar-quotes. We make
- * the assumption that $-quotes will not have an ident character
+ /*
+ * Look for normal boring quote chars, or
+ * dollar-quotes. We make the assumption that
+ * $-quotes will not have an ident character
* before them in all pg_dump output.
*/
- if ( qry[pos] == '"'
- || qry[pos] == '\''
- || ( qry[pos] == '$' && _isIdentChar(AH->sqlparse.lastChar) == 0 )
- )
+ if (qry[pos] == '"'
+ || qry[pos] == '\''
+ || (qry[pos] == '$' && _isIdentChar(AH->sqlparse.lastChar) == 0)
+ )
{
/* fprintf(stderr,"[startquote]\n"); */
AH->sqlparse.state = SQL_IN_QUOTE;
@@ -524,18 +529,20 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
AH->sqlparse.braceDepth++;
else if (qry[pos] == ')')
AH->sqlparse.braceDepth--;
-
+
AH->sqlparse.lastChar = qry[pos];
}
break;
-
+
case SQL_IN_DOLLARTAG:
-
- /* Like a quote, we look for a closing char *but* we only
- * allow a very limited set of contained chars, and no escape chars.
- * If invalid chars are found, we abort tag processing.
+
+ /*
+ * Like a quote, we look for a closing char *but* we
+ * only allow a very limited set of contained chars,
+ * and no escape chars. If invalid chars are found, we
+ * abort tag processing.
*/
-
+
if (qry[pos] == '$')
{
/* fprintf(stderr,"[endquote]\n"); */
@@ -545,18 +552,21 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
else
{
- if ( _isDQChar(qry[pos], startDT) )
+ if (_isDQChar(qry[pos], startDT))
{
/* Valid, so add */
appendPQExpBufferChar(AH->sqlparse.tagBuf, qry[pos]);
}
else
{
- /* Jump back to 'scan' state, we're not really in a tag,
- * and valid tag chars do not include the various chars
- * we look for in this state machine, so it's safe to just
- * jump from this state back to SCAN. We set consumed = 0
- * so that this char gets rescanned in new state.
+ /*
+ * Jump back to 'scan' state, we're not really
+ * in a tag, and valid tag chars do not
+ * include the various chars we look for in
+ * this state machine, so it's safe to just
+ * jump from this state back to SCAN. We set
+ * consumed = 0 so that this char gets
+ * rescanned in new state.
*/
destroyPQExpBuffer(AH->sqlparse.tagBuf);
AH->sqlparse.state = SQL_SCAN;
@@ -565,32 +575,35 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
startDT = 0;
break;
-
+
case SQL_IN_DOLLARQUOTE:
+
/*
- * Comparing the entire string backwards each time is NOT efficient,
- * but dollar quotes in pg_dump are small and the code is a lot simpler.
+ * Comparing the entire string backwards each time is
+ * NOT efficient, but dollar quotes in pg_dump are
+ * small and the code is a lot simpler.
*/
sqlPtr = AH->sqlBuf->data + AH->sqlBuf->len - AH->sqlparse.tagBuf->len;
-
- if (strncmp(AH->sqlparse.tagBuf->data, sqlPtr, AH->sqlparse.tagBuf->len) == 0) {
+
+ if (strncmp(AH->sqlparse.tagBuf->data, sqlPtr, AH->sqlparse.tagBuf->len) == 0)
+ {
/* End of $-quote */
AH->sqlparse.state = SQL_SCAN;
destroyPQExpBuffer(AH->sqlparse.tagBuf);
}
break;
-
+
case SQL_IN_SQL_COMMENT:
if (qry[pos] == '\n')
AH->sqlparse.state = SQL_SCAN;
break;
-
+
case SQL_IN_EXT_COMMENT:
if (AH->sqlparse.lastChar == '*' && qry[pos] == '/')
AH->sqlparse.state = SQL_SCAN;
break;
-
+
case SQL_IN_QUOTE:
if (!AH->sqlparse.backSlash && AH->sqlparse.quoteChar == qry[pos])
@@ -600,7 +613,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
else
{
-
+
if (qry[pos] == '\\')
{
if (AH->sqlparse.lastChar == '\\')
@@ -612,13 +625,13 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
AH->sqlparse.backSlash = 0;
}
break;
-
+
}
} while (consumed == 0);
- AH->sqlparse.lastChar = qry[pos];
- /* fprintf(stderr, "\n"); */
+ AH->sqlparse.lastChar = qry[pos];
+ /* fprintf(stderr, "\n"); */
}
/*
@@ -804,7 +817,7 @@ InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new)
PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry,
- "INSERT INTO %s(oldOid, newOid) VALUES ('%u', '%u')",
+ "INSERT INTO %s(oldOid, newOid) VALUES ('%u', '%u')",
BLOB_XREF_TABLE, old, new);
ExecuteSqlCommand(AH, qry, "could not create large object cross-reference entry", true);
@@ -864,37 +877,33 @@ CommitTransactionXref(ArchiveHandle *AH)
destroyPQExpBuffer(qry);
}
-static int _isIdentChar(unsigned char c)
+static int
+_isIdentChar(unsigned char c)
{
- if ( (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z')
- || (c >= '0' && c <= '9')
- || (c == '_')
- || (c == '$')
- || (c >= (unsigned char)'\200') /* no need to check <= \377 */
- )
- {
+ if ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || (c >= '0' && c <= '9')
+ || (c == '_')
+ || (c == '$')
+ || (c >= (unsigned char) '\200') /* no need to check <=
+ * \377 */
+ )
return 1;
- }
else
- {
return 0;
- }
}
-static int _isDQChar(unsigned char c, int atStart)
+static int
+_isDQChar(unsigned char c, int atStart)
{
- if ( (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z')
- || (c == '_')
- || (atStart == 0 && c >= '0' && c <= '9')
- || (c >= (unsigned char)'\200') /* no need to check <= \377 */
- )
- {
+ if ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || (c == '_')
+ || (atStart == 0 && c >= '0' && c <= '9')
+ || (c >= (unsigned char) '\200') /* no need to check <=
+ * \377 */
+ )
return 1;
- }
else
- {
return 0;
- }
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index f472c9de02d..c01ff2066d1 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.43 2004/05/07 00:24:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.44 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -160,7 +160,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
AH->formatData = (void *) ctx;
ctx->filePos = 0;
ctx->isSpecialScript = 0;
-
+
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *) malloc(LOBBUFSIZE);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4baecec11d5..fce0b6e7767 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.385 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.386 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,14 +102,14 @@ char g_opaque_type[10]; /* name for the opaque type */
char g_comment_start[10];
char g_comment_end[10];
-static const CatalogId nilCatalogId = { 0, 0 };
+static const CatalogId nilCatalogId = {0, 0};
/* these are to avoid passing around info for findNamespace() */
static NamespaceInfo *g_namespaces;
static int g_numNamespaces;
/* flag to turn on/off dollar quoting */
-static int disable_dollar_quoting = 0;
+static int disable_dollar_quoting = 0;
static void help(const char *progname);
@@ -118,8 +118,8 @@ static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
-static int findComments(Archive *fout, Oid classoid, Oid objoid,
- CommentItem **items);
+static int findComments(Archive *fout, Oid classoid, Oid objoid,
+ CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
@@ -152,7 +152,7 @@ static void getDependencies(void);
static void getDomainConstraints(TypeInfo *tinfo);
static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
static char *format_function_signature(FuncInfo *finfo, char **argnames,
- bool honor_quotes);
+ bool honor_quotes);
static const char *convertRegProcReference(const char *proc);
static const char *convertOperatorReference(const char *opr);
static Oid findLastBuiltinOid_V71(const char *);
@@ -170,7 +170,7 @@ static const char *getAttrName(int attrnum, TableInfo *tblInfo);
static const char *fmtCopyColumnList(const TableInfo *ti);
static void do_sql_command(PGconn *conn, const char *query);
static void check_sql_result(PGresult *res, PGconn *conn, const char *query,
- ExecStatusType expected);
+ ExecStatusType expected);
int
@@ -582,9 +582,10 @@ main(int argc, char **argv)
*
* In 7.3 or later, we can rely on dependency information to help us
* determine a safe order, so the initial sort is mostly for cosmetic
- * purposes: we sort by name to ensure that logically identical schemas
- * will dump identically. Before 7.3 we don't have dependencies and
- * we use OID ordering as an (unreliable) guide to creation order.
+ * purposes: we sort by name to ensure that logically identical
+ * schemas will dump identically. Before 7.3 we don't have
+ * dependencies and we use OID ordering as an (unreliable) guide to
+ * creation order.
*/
getDumpableObjects(&dobjs, &numObjs);
@@ -596,8 +597,8 @@ main(int argc, char **argv)
sortDumpableObjects(dobjs, numObjs);
/*
- * Create archive TOC entries for all the objects to be dumped,
- * in a safe order.
+ * Create archive TOC entries for all the objects to be dumped, in a
+ * safe order.
*/
if (g_fout->verbose)
@@ -616,9 +617,7 @@ main(int argc, char **argv)
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
- {
dumpDumpableObject(g_fout, dobjs[i]);
- }
if (g_fout->verbose)
dumpTimestamp(g_fout, "Completed on");
@@ -820,15 +819,15 @@ dumpTableData_copy(Archive *fout, void *dcontext)
if (oids && hasoids)
{
appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname),
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname),
column_list);
}
else
{
appendPQExpBuffer(q, "COPY %s %s TO stdout;",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname),
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname),
column_list);
}
res = PQexec(g_conn, q->data);
@@ -943,15 +942,15 @@ dumpTableData_insert(Archive *fout, void *dcontext)
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM ONLY %s",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname));
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname));
}
else
{
appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
"SELECT * FROM %s",
- fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
- classname));
+ fmtQualifiedId(tbinfo->dobj.namespace->dobj.name,
+ classname));
}
res = PQexec(g_conn, q->data);
@@ -1089,7 +1088,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
fmtId(tbinfo->dobj.name));
appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n",
fmtCopyColumnList(tbinfo),
- (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
+ (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
copyStmt = copyBuf->data;
}
else
@@ -1135,6 +1134,7 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
tdinfo = (TableDataInfo *) malloc(sizeof(TableDataInfo));
tdinfo->dobj.objType = DO_TABLE_DATA;
+
/*
* Note: use tableoid 0 so that this object won't be mistaken
* for something that pg_depend entries apply to.
@@ -1188,7 +1188,7 @@ dumpDatabase(Archive *AH)
if (g_fout->remoteVersion >= 80000)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace "
"FROM pg_database "
@@ -1198,7 +1198,7 @@ dumpDatabase(Archive *AH)
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
@@ -1210,7 +1210,7 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(dbQry, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
"oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
@@ -1257,9 +1257,7 @@ dumpDatabase(Archive *AH)
appendStringLiteral(creaQry, encoding, true);
}
if (strlen(tablespace) > 0 && strcmp(tablespace, "pg_default") != 0)
- {
appendPQExpBuffer(creaQry, " TABLESPACE = %s", fmtId(tablespace));
- }
appendPQExpBuffer(creaQry, ";\n");
appendPQExpBuffer(delQry, "DROP DATABASE %s;\n",
@@ -1303,11 +1301,11 @@ dumpDatabase(Archive *AH)
static void
dumpTimestamp(Archive *AH, char *msg)
{
- char buf[256];
- time_t now = time(NULL);
+ char buf[256];
+ time_t now = time(NULL);
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
- {
+ {
PQExpBuffer qry = createPQExpBuffer();
appendPQExpBuffer(qry, "-- ");
@@ -1528,15 +1526,15 @@ getNamespaces(int *numNamespaces)
if (g_fout->remoteVersion >= 80000)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
- "(select usename from pg_user where nspowner = usesysid) as usename, "
+ "(select usename from pg_user where nspowner = usesysid) as usename, "
"nspacl, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = nsptablespace) AS nsptablespace "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = nsptablespace) AS nsptablespace "
"FROM pg_namespace");
}
else
{
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
- "(select usename from pg_user where nspowner = usesysid) as usename, "
+ "(select usename from pg_user where nspowner = usesysid) as usename, "
"nspacl, NULL AS nsptablespace "
"FROM pg_namespace");
}
@@ -1689,7 +1687,7 @@ getTypes(int *numTypes)
"typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1701,7 +1699,7 @@ getTypes(int *numTypes)
"0::oid as typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1715,7 +1713,7 @@ getTypes(int *numTypes)
"0::oid as typnamespace, "
"(select usename from pg_user where typowner = usesysid) as usename, "
"typinput::oid as typinput, "
- "typoutput::oid as typoutput, typelem, typrelid, "
+ "typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
@@ -1753,7 +1751,7 @@ getTypes(int *numTypes)
AssignDumpId(&tinfo[i].dobj);
tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
- tinfo[i].dobj.catId.oid);
+ tinfo[i].dobj.catId.oid);
tinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput));
typoutput = atooid(PQgetvalue(res, i, i_typoutput));
@@ -1764,7 +1762,7 @@ getTypes(int *numTypes)
/*
* If it's a table's rowtype, use special type code to facilitate
- * sorting into the desired order. (We don't want to consider it
+ * sorting into the desired order. (We don't want to consider it
* an ordinary type because that would bring the table up into the
* datatype part of the dump order.)
*/
@@ -1795,9 +1793,9 @@ getTypes(int *numTypes)
/*
* Make sure there are dependencies from the type to its input and
- * output functions. (We don't worry about typsend, typreceive, or
- * typanalyze since those are only valid in 7.4 and later, wherein
- * the standard dependency mechanism will pick them up.)
+ * output functions. (We don't worry about typsend, typreceive,
+ * or typanalyze since those are only valid in 7.4 and later,
+ * wherein the standard dependency mechanism will pick them up.)
*/
funcInfo = findFuncByOid(tinfo[i].typinput);
if (funcInfo)
@@ -1902,7 +1900,7 @@ getOperators(int *numOprs)
AssignDumpId(&oprinfo[i].dobj);
oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname));
oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)),
- oprinfo[i].dobj.catId.oid);
+ oprinfo[i].dobj.catId.oid);
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
@@ -1932,7 +1930,7 @@ getConversions(int *numConversions)
int ntups;
int i;
PQExpBuffer query = createPQExpBuffer();
- ConvInfo *convinfo;
+ ConvInfo *convinfo;
int i_tableoid;
int i_oid;
int i_conname;
@@ -1940,7 +1938,8 @@ getConversions(int *numConversions)
int i_usename;
/* Conversions didn't exist pre-7.3 */
- if (g_fout->remoteVersion < 70300) {
+ if (g_fout->remoteVersion < 70300)
+ {
*numConversions = 0;
return NULL;
}
@@ -1955,7 +1954,7 @@ getConversions(int *numConversions)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
"connamespace, "
- "(select usename from pg_user where conowner = usesysid) as usename "
+ "(select usename from pg_user where conowner = usesysid) as usename "
"FROM pg_conversion");
res = PQexec(g_conn, query->data);
@@ -1980,7 +1979,7 @@ getConversions(int *numConversions)
AssignDumpId(&convinfo[i].dobj);
convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)),
- convinfo[i].dobj.catId.oid);
+ convinfo[i].dobj.catId.oid);
convinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
}
@@ -2066,7 +2065,7 @@ getOpclasses(int *numOpclasses)
AssignDumpId(&opcinfo[i].dobj);
opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname));
opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)),
- opcinfo[i].dobj.catId.oid);
+ opcinfo[i].dobj.catId.oid);
opcinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
if (g_fout->remoteVersion >= 70300)
@@ -2173,16 +2172,17 @@ getAggregates(int *numAggs)
AssignDumpId(&agginfo[i].aggfn.dobj);
agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname));
agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)),
- agginfo[i].aggfn.dobj.catId.oid);
+ agginfo[i].aggfn.dobj.catId.oid);
agginfo[i].aggfn.usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(agginfo[i].aggfn.usename) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggfn.dobj.name);
- agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */
+ agginfo[i].aggfn.lang = InvalidOid; /* not currently
+ * interesting */
agginfo[i].aggfn.nargs = 1;
agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid));
agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_aggbasetype));
- agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */
+ agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */
agginfo[i].aggfn.proacl = strdup(PQgetvalue(res, i, i_aggacl));
agginfo[i].anybasetype = false; /* computed when it's dumped */
agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */
@@ -2293,7 +2293,7 @@ getFuncs(int *numFuncs)
AssignDumpId(&finfo[i].dobj);
finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname));
finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
- finfo[i].dobj.catId.oid);
+ finfo[i].dobj.catId.oid);
finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype));
@@ -2427,7 +2427,7 @@ getTables(int *numTables)
else if (g_fout->remoteVersion >= 70200)
{
appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, relkind, "
+ "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
"(select usename from pg_user where relowner = usesysid) as usename, "
"relchecks, reltriggers, "
@@ -2444,7 +2444,7 @@ getTables(int *numTables)
{
/* all tables have oids in 7.1 */
appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, relkind, "
+ "SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
"(select usename from pg_user where relowner = usesysid) as usename, "
"relchecks, reltriggers, "
@@ -2530,7 +2530,7 @@ getTables(int *numTables)
AssignDumpId(&tblinfo[i].dobj);
tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)),
- tblinfo[i].dobj.catId.oid);
+ tblinfo[i].dobj.catId.oid);
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
@@ -2580,8 +2580,8 @@ getTables(int *numTables)
resetPQExpBuffer(lockquery);
appendPQExpBuffer(lockquery,
"LOCK TABLE %s IN ACCESS SHARE MODE",
- fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
- tblinfo[i].dobj.name));
+ fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
+ tblinfo[i].dobj.name));
do_sql_command(g_conn, lockquery->data);
}
@@ -2593,8 +2593,9 @@ getTables(int *numTables)
/*
* If the user is attempting to dump a specific table, check to ensure
- * that the specified table actually exists. (This is a bit simplistic
- * since we don't fully check the combination of -n and -t switches.)
+ * that the specified table actually exists. (This is a bit
+ * simplistic since we don't fully check the combination of -n and -t
+ * switches.)
*/
if (selectTableName)
{
@@ -2721,9 +2722,9 @@ getIndexes(TableInfo tblinfo[], int numTables)
/*
* The point of the messy-looking outer join is to find a
* constraint that is related by an internal dependency link to
- * the index. If we find one, create a CONSTRAINT entry linked
- * to the INDEX entry. We assume an index won't have more than
- * one internal dependency.
+ * the index. If we find one, create a CONSTRAINT entry linked to
+ * the INDEX entry. We assume an index won't have more than one
+ * internal dependency.
*/
resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 80000)
@@ -2737,7 +2738,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"c.contype, c.conname, "
"c.tableoid as contableoid, "
"c.oid as conoid, "
- "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace "
+ "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace "
"FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d "
@@ -2781,7 +2782,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, "
"t.relname as indexname, "
- "pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, false as indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char "
@@ -2803,7 +2804,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
"t.oid, "
"t.relname as indexname, "
- "pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, false as indisclustered, "
"CASE WHEN i.indisprimary THEN 'p'::char "
@@ -2858,11 +2859,11 @@ getIndexes(TableInfo tblinfo[], int numTables)
/*
* In pre-7.4 releases, indkeys may contain more entries than
* indnkeys says (since indnkeys will be 1 for a functional
- * index). We don't actually care about this case since we don't
- * examine indkeys except for indexes associated with PRIMARY
- * and UNIQUE constraints, which are never functional indexes.
- * But we have to allocate enough space to keep parseOidArray
- * from complaining.
+ * index). We don't actually care about this case since we
+ * don't examine indkeys except for indexes associated with
+ * PRIMARY and UNIQUE constraints, which are never functional
+ * indexes. But we have to allocate enough space to keep
+ * parseOidArray from complaining.
*/
indxinfo[j].indkeys = (Oid *) malloc(INDEX_MAX_KEYS * sizeof(Oid));
parseOidArray(PQgetvalue(res, j, i_indkey),
@@ -2961,7 +2962,7 @@ getConstraints(TableInfo tblinfo[], int numTables)
resetPQExpBuffer(query);
appendPQExpBuffer(query,
"SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) as condef "
+ "pg_catalog.pg_get_constraintdef(oid) as condef "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
"AND contype = 'f'",
@@ -3024,8 +3025,8 @@ getDomainConstraints(TypeInfo *tinfo)
return;
/*
- * select appropriate schema to ensure names in constraint are properly
- * qualified
+ * select appropriate schema to ensure names in constraint are
+ * properly qualified
*/
selectSourceSchema(tinfo->dobj.namespace->dobj.name);
@@ -3033,7 +3034,7 @@ getDomainConstraints(TypeInfo *tinfo)
if (g_fout->remoteVersion >= 70400)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname",
@@ -3076,9 +3077,10 @@ getDomainConstraints(TypeInfo *tinfo)
constrinfo[i].conindex = 0;
constrinfo[i].coninherited = false;
constrinfo[i].separate = false;
+
/*
- * Make the domain depend on the constraint, ensuring it won't
- * be output till any constraint dependencies are OK.
+ * Make the domain depend on the constraint, ensuring it won't be
+ * output till any constraint dependencies are OK.
*/
addObjectDependency(&tinfo->dobj,
constrinfo[i].dobj.dumpId);
@@ -3149,7 +3151,7 @@ getRules(int *numRules)
for (i = 0; i < ntups; i++)
{
- Oid ruletableoid;
+ Oid ruletableoid;
ruleinfo[i].dobj.objType = DO_RULE;
ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
@@ -3164,10 +3166,10 @@ getRules(int *numRules)
if (ruleinfo[i].ruletable)
{
/*
- * If the table is a view, force its ON SELECT rule to be sorted
- * before the view itself --- this ensures that any dependencies
- * for the rule affect the table's positioning. Other rules
- * are forced to appear after their table.
+ * If the table is a view, force its ON SELECT rule to be
+ * sorted before the view itself --- this ensures that any
+ * dependencies for the rule affect the table's positioning.
+ * Other rules are forced to appear after their table.
*/
if (ruleinfo[i].ruletable->relkind == RELKIND_VIEW &&
ruleinfo[i].ev_type == '1' && ruleinfo[i].is_instead)
@@ -3245,7 +3247,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
"tgfoid::pg_catalog.regproc as tgfname, "
"tgtype, tgnargs, tgargs, "
"tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
"tgconstrrelid::pg_catalog.regclass as tgconstrrelname "
"from pg_catalog.pg_trigger t "
"where tgrelid = '%u'::pg_catalog.oid "
@@ -3262,7 +3264,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
"SELECT tgname, tgfoid::regproc as tgfname, "
"tgtype, tgnargs, tgargs, "
"tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
"(select relname from pg_class where oid = tgconstrrelid) "
" as tgconstrrelname "
"from pg_trigger "
@@ -3449,9 +3451,10 @@ getProcLangs(int *numProcLangs)
planginfo[i].lanvalidator = InvalidOid;
planginfo[i].lanacl = strdup("{=U}");
+
/*
- * We need to make a dependency to ensure the function will
- * be dumped first. (In 7.3 and later the regular dependency
+ * We need to make a dependency to ensure the function will be
+ * dumped first. (In 7.3 and later the regular dependency
* mechanism will handle this for us.)
*/
funcInfo = findFuncByOid(planginfo[i].lanplcallfoid);
@@ -3506,7 +3509,7 @@ getCasts(int *numCasts)
"FROM pg_type t1, pg_type t2, pg_proc p "
"WHERE p.pronargs = 1 AND "
"p.proargtypes[0] = t1.oid AND "
- "p.prorettype = t2.oid AND p.proname = t2.typname "
+ "p.prorettype = t2.oid AND p.proname = t2.typname "
"ORDER BY 3,4");
}
@@ -3528,7 +3531,7 @@ getCasts(int *numCasts)
for (i = 0; i < ntups; i++)
{
- PQExpBufferData namebuf;
+ PQExpBufferData namebuf;
TypeInfo *sTypeInfo;
TypeInfo *tTypeInfo;
@@ -3557,8 +3560,8 @@ getCasts(int *numCasts)
if (OidIsValid(castinfo[i].castfunc))
{
/*
- * We need to make a dependency to ensure the function will
- * be dumped first. (In 7.3 and later the regular dependency
+ * We need to make a dependency to ensure the function will be
+ * dumped first. (In 7.3 and later the regular dependency
* mechanism will handle this for us.)
*/
FuncInfo *funcInfo;
@@ -3741,7 +3744,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tbinfo->attislocal[j] = (PQgetvalue(res, j, i_attislocal)[0] == 't');
tbinfo->attisserial[j] = false; /* fix below */
tbinfo->notnull[j] = (PQgetvalue(res, j, i_attnotnull)[0] == 't');
- tbinfo->attrdefs[j] = NULL; /* fix below */
+ tbinfo->attrdefs[j] = NULL; /* fix below */
if (PQgetvalue(res, j, i_atthasdef)[0] == 't')
hasdefaults = true;
/* these flags will be set in flagInhAttrs() */
@@ -3808,7 +3811,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
for (j = 0; j < numDefaults; j++)
{
- int adnum;
+ int adnum;
attrdefs[j].dobj.objType = DO_ATTRDEF;
attrdefs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0));
@@ -3824,9 +3827,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/*
* Defaults on a VIEW must always be dumped as separate
* ALTER TABLE commands. Defaults on regular tables are
- * dumped as part of the CREATE TABLE if possible. To check
- * if it's safe, we mark the default as needing to appear
- * before the CREATE.
+ * dumped as part of the CREATE TABLE if possible. To
+ * check if it's safe, we mark the default as needing to
+ * appear before the CREATE.
*/
if (tbinfo->relkind == RELKIND_VIEW)
{
@@ -3869,7 +3872,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_fout->remoteVersion >= 70400)
{
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
" AND contype = 'c' "
@@ -3952,6 +3955,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
constrs[j].separate = false;
addObjectDependency(&tbinfo->dobj,
constrs[j].dobj.dumpId);
+
/*
* If the constraint is inherited, this will be detected
* later. We also detect later if the constraint must be
@@ -4110,7 +4114,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
@@ -4130,7 +4134,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
@@ -4169,9 +4173,9 @@ findComments(Archive *fout, Oid classoid, Oid objoid,
ncomments = collectComments(fout, &comments);
/*
- * Pre-7.2, pg_description does not contain classoid, so collectComments
- * just stores a zero. If there's a collision on object OID, well, you
- * get duplicate comments.
+ * Pre-7.2, pg_description does not contain classoid, so
+ * collectComments just stores a zero. If there's a collision on
+ * object OID, well, you get duplicate comments.
*/
if (fout->remoteVersion < 70200)
classoid = 0;
@@ -4180,7 +4184,7 @@ findComments(Archive *fout, Oid classoid, Oid objoid,
* Do binary search to find some item matching the object.
*/
low = &comments[0];
- high = &comments[ncomments-1];
+ high = &comments[ncomments - 1];
while (low <= high)
{
middle = low + (high - low) / 2;
@@ -4412,12 +4416,12 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
qnspname = strdup(fmtId(nspinfo->dobj.name));
/*
- * Note that ownership is shown in the AUTHORIZATION clause,
- * while the archive entry is listed with empty owner (causing
- * it to be emitted with SET SESSION AUTHORIZATION DEFAULT).
- * This seems the best way of dealing with schemas owned by
- * users without CREATE SCHEMA privilege. Further hacking has
- * to be applied for --no-owner mode, though!
+ * Note that ownership is shown in the AUTHORIZATION clause, while the
+ * archive entry is listed with empty owner (causing it to be emitted
+ * with SET SESSION AUTHORIZATION DEFAULT). This seems the best way of
+ * dealing with schemas owned by users without CREATE SCHEMA
+ * privilege. Further hacking has to be applied for --no-owner mode,
+ * though!
*/
appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
@@ -4813,7 +4817,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
if (!domcheck->separate)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
- fmtId(domcheck->dobj.name), domcheck->condef);
+ fmtId(domcheck->dobj.name), domcheck->condef);
}
appendPQExpBuffer(q, ";\n");
@@ -4961,17 +4965,16 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
return;
/*
- * Current theory is to dump PLs iff their underlying functions
- * will be dumped (are in a dumpable namespace, or have a
- * non-system OID in pre-7.3 databases). Actually, we treat the
- * PL itself as being in the underlying function's namespace,
- * though it isn't really. This avoids searchpath problems for
- * the HANDLER clause.
+ * Current theory is to dump PLs iff their underlying functions will
+ * be dumped (are in a dumpable namespace, or have a non-system OID in
+ * pre-7.3 databases). Actually, we treat the PL itself as being in
+ * the underlying function's namespace, though it isn't really. This
+ * avoids searchpath problems for the HANDLER clause.
*
- * If the underlying function is in the pg_catalog namespace,
- * we won't have loaded it into finfo[] at all; therefore,
- * treat failure to find it in finfo[] as indicating we shouldn't
- * dump it, not as an error condition. Ditto for the validator.
+ * If the underlying function is in the pg_catalog namespace, we won't
+ * have loaded it into finfo[] at all; therefore, treat failure to
+ * find it in finfo[] as indicating we shouldn't dump it, not as an
+ * error condition. Ditto for the validator.
*/
funcInfo = findFuncByOid(plang->lanplcallfoid);
@@ -5007,7 +5010,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
/* Cope with possibility that validator is in different schema */
if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace)
appendPQExpBuffer(defqry, "%s.",
- fmtId(validatorInfo->dobj.namespace->dobj.name));
+ fmtId(validatorInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
fmtId(validatorInfo->dobj.name));
}
@@ -5204,6 +5207,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (strcmp(prosrc, "-") != 0)
{
appendPQExpBuffer(asPart, ", ");
+
/*
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
@@ -5229,7 +5233,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (proargnames && *proargnames)
{
- int nitems = 0;
+ int nitems = 0;
if (!parsePGArray(proargnames, &argnamearray, &nitems) ||
nitems != finfo->nargs)
@@ -5345,8 +5349,8 @@ dumpCast(Archive *fout, CastInfo *cast)
* As per discussion we dump casts if one or more of the underlying
* objects (the conversion function and the two data types) are not
* builtin AND if all of the non-builtin objects namespaces are
- * included in the dump. Builtin meaning, the namespace name does
- * not start with "pg_".
+ * included in the dump. Builtin meaning, the namespace name does not
+ * start with "pg_".
*/
sourceInfo = findTypeByOid(cast->castsource);
targetInfo = findTypeByOid(cast->casttarget);
@@ -5364,8 +5368,8 @@ dumpCast(Archive *fout, CastInfo *cast)
return;
/*
- * Skip cast if function isn't from pg_ and that namespace is
- * not dumped.
+ * Skip cast if function isn't from pg_ and that namespace is not
+ * dumped.
*/
if (funcInfo &&
strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 &&
@@ -5406,13 +5410,13 @@ dumpCast(Archive *fout, CastInfo *cast)
else
{
/*
- * Always qualify the function name, in case it is not in pg_catalog
- * schema (format_function_signature won't qualify it).
+ * Always qualify the function name, in case it is not in
+ * pg_catalog schema (format_function_signature won't qualify it).
*/
appendPQExpBuffer(defqry, "WITH FUNCTION %s.",
fmtId(funcInfo->dobj.namespace->dobj.name));
appendPQExpBuffer(defqry, "%s",
- format_function_signature(funcInfo, NULL, true));
+ format_function_signature(funcInfo, NULL, true));
}
if (cast->castcontext == 'a')
@@ -5754,7 +5758,7 @@ convertRegProcReference(const char *proc)
static const char *
convertOperatorReference(const char *opr)
{
- OprInfo *oprInfo;
+ OprInfo *oprInfo;
/* In all cases "0" means a null reference */
if (strcmp(opr, "0") == 0)
@@ -6046,8 +6050,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
/* Get conversion-specific details */
appendPQExpBuffer(query, "SELECT conname, "
- "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
- "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
+ "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
+ "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
"conproc, condefault "
"FROM pg_catalog.pg_conversion c "
"WHERE c.oid = '%u'::pg_catalog.oid",
@@ -6087,8 +6091,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
fmtId(convinfo->dobj.name));
appendPQExpBuffer(q, "CREATE %sCONVERSION %s FOR ",
- (condefault) ? "DEFAULT " : "",
- fmtId(convinfo->dobj.name));
+ (condefault) ? "DEFAULT " : "",
+ fmtId(convinfo->dobj.name));
appendStringLiteral(q, conforencoding, true);
appendPQExpBuffer(q, " TO ");
appendStringLiteral(q, contoencoding, true);
@@ -6332,22 +6336,22 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
aggsig_tag,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
false, "AGGREGATE", q->data, delq->data, NULL,
- agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
+ agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
NULL, NULL);
/* Dump Aggregate Comments */
resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
dumpComment(fout, q->data,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/*
* Since there is no GRANT ON AGGREGATE syntax, we have to make the
- * ACL command look like a function's GRANT; in particular this affects
- * the syntax for aggregates on ANY.
+ * ACL command look like a function's GRANT; in particular this
+ * affects the syntax for aggregates on ANY.
*/
free(aggsig);
free(aggsig_tag);
@@ -6582,8 +6586,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
/*
- * Default value --- suppress if inherited, serial,
- * or to be printed separately.
+ * Default value --- suppress if inherited, serial, or to
+ * be printed separately.
*/
if (tbinfo->attrdefs[j] != NULL &&
!tbinfo->inhAttrDef[j] &&
@@ -6641,7 +6645,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(q, ", ");
if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
appendPQExpBuffer(q, "%s.",
- fmtId(parentRel->dobj.namespace->dobj.name));
+ fmtId(parentRel->dobj.namespace->dobj.name));
appendPQExpBuffer(q, "%s",
fmtId(parentRel->dobj.name));
}
@@ -6723,7 +6727,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
- (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
+ (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
reltypename, q->data, delq->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL);
@@ -6752,7 +6756,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
return;
/* Don't print inherited or serial defaults, either */
- if (tbinfo->inhAttrDef[adnum-1] || tbinfo->attisserial[adnum-1])
+ if (tbinfo->inhAttrDef[adnum - 1] || tbinfo->attisserial[adnum - 1])
return;
q = createPQExpBuffer();
@@ -6765,8 +6769,8 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
adinfo->adef_expr);
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -6857,8 +6861,8 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
}
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "DROP INDEX %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -6925,7 +6929,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
fmtId(tbinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (",
fmtId(coninfo->dobj.name),
- coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
+ coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE");
for (k = 0; k < indxinfo->indnkeys; k++)
{
@@ -6964,8 +6968,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
}
/*
- * DROP must be fully qualified in case same name appears
- * in pg_catalog
+ * DROP must be fully qualified in case same name appears in
+ * pg_catalog
*/
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s.",
fmtId(tbinfo->dobj.namespace->dobj.name));
@@ -7191,7 +7195,7 @@ findLastBuiltinOid_V71(const char *dbname)
* find the last built in oid
*
* For 7.0, we do this by assuming that the last thing that initdb does is to
- * create the pg_indexes view. This sucks in general, but seeing that 7.0.x
+ * create the pg_indexes view. This sucks in general, but seeing that 7.0.x
* initdb won't be changing anymore, it'll do.
*/
static Oid
@@ -7204,7 +7208,7 @@ findLastBuiltinOid_V70(void)
res = PQexec(g_conn,
"SELECT oid FROM pg_class WHERE relname = 'pg_indexes'");
check_sql_result(res, g_conn,
- "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'",
+ "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'",
PGRES_TUPLES_OK);
ntups = PQntuples(res);
if (ntups < 1)
@@ -7348,15 +7352,17 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (!schemaOnly)
{
- TableInfo *owning_tab;
+ TableInfo *owning_tab;
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
+
/*
- * If this is a SERIAL sequence, then use the pg_get_serial_sequence
- * function to avoid hard-coding the sequence name. Note that this
- * implicitly assumes that the sequence and its owning table are in
- * the same schema, because we don't schema-qualify the reference.
+ * If this is a SERIAL sequence, then use the
+ * pg_get_serial_sequence function to avoid hard-coding the
+ * sequence name. Note that this implicitly assumes that the
+ * sequence and its owning table are in the same schema, because
+ * we don't schema-qualify the reference.
*/
if (OidIsValid(tbinfo->owning_tab) &&
(owning_tab = findTableByOid(tbinfo->owning_tab)) != NULL)
@@ -7364,7 +7370,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query, "pg_catalog.pg_get_serial_sequence(");
appendStringLiteral(query, fmtId(owning_tab->dobj.name), true);
appendPQExpBuffer(query, ", ");
- appendStringLiteral(query, owning_tab->attnames[tbinfo->owning_col-1], true);
+ appendStringLiteral(query, owning_tab->attnames[tbinfo->owning_col - 1], true);
appendPQExpBuffer(query, ")");
}
else
@@ -7579,8 +7585,8 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
return;
/*
- * If it is an ON SELECT rule, we do not need to dump it because
- * it will be handled via CREATE VIEW for the table.
+ * If it is an ON SELECT rule, we do not need to dump it because it
+ * will be handled via CREATE VIEW for the table.
*/
if (rinfo->ev_type == '1' && rinfo->is_instead)
return;
@@ -7729,8 +7735,9 @@ getDependencies(void)
dobj = findObjectByCatalogId(objId);
/*
- * Failure to find objects mentioned in pg_depend is not unexpected,
- * since for example we don't collect info about TOAST tables.
+ * Failure to find objects mentioned in pg_depend is not
+ * unexpected, since for example we don't collect info about TOAST
+ * tables.
*/
if (dobj == NULL)
{
@@ -7885,7 +7892,7 @@ static char *
myFormatType(const char *typname, int32 typmod)
{
char *result;
- bool isarray = false;
+ bool isarray = false;
PQExpBuffer buf = createPQExpBuffer();
/* Handle array types */
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 37cd7613e26..6c3c02707af 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-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.111 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.112 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,7 +39,7 @@ typedef struct
Oid oid;
} CatalogId;
-typedef int DumpId;
+typedef int DumpId;
/*
@@ -105,6 +105,7 @@ typedef struct _namespaceInfo
typedef struct _typeInfo
{
DumpableObject dobj;
+
/*
* Note: dobj.name is the pg_type.typname entry. format_type() might
* produce something different than typname
@@ -199,22 +200,22 @@ typedef struct _tableInfo
bool *attisserial; /* true if attr is serial or bigserial */
/*
- * Note: we need to store per-attribute notnull, default, and constraint
- * stuff for all interesting tables so that we can tell which constraints
- * were inherited.
+ * Note: we need to store per-attribute notnull, default, and
+ * constraint stuff for all interesting tables so that we can tell
+ * which constraints were inherited.
*/
bool *notnull; /* Not null constraints on attributes */
- struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
+ struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
bool *inhAttrs; /* true if each attribute is inherited */
bool *inhAttrDef; /* true if attr's default is inherited */
bool *inhNotNull; /* true if NOT NULL is inherited */
- struct _constraintInfo *checkexprs; /* CHECK constraints */
+ struct _constraintInfo *checkexprs; /* CHECK constraints */
/*
* Stuff computed only for dumpable tables.
*/
int numParents; /* number of (immediate) parent tables */
- struct _tableInfo **parents; /* TableInfos of immediate parents */
+ struct _tableInfo **parents; /* TableInfos of immediate parents */
} TableInfo;
typedef struct _attrDefInfo
@@ -271,7 +272,7 @@ typedef struct _triggerInfo
} TriggerInfo;
/*
- * struct ConstraintInfo is used for all constraint types. However we
+ * struct ConstraintInfo is used for all constraint types. However we
* use a different objType for foreign key constraints, to make it easier
* to sort them the way we want.
*/
@@ -328,8 +329,8 @@ extern char g_opaque_type[10]; /* name for the opaque type */
*/
extern TableInfo *getSchemaData(int *numTablesPtr,
- const bool schemaOnly,
- const bool dataOnly);
+ const bool schemaOnly,
+ const bool dataOnly);
typedef enum _OidOptions
{
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index b74d442d89f..79696f452f7 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.5 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.6 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,30 +22,30 @@ static char *modulename = gettext_noop("sorter");
/*
* Sort priority for object types when dumping a pre-7.3 database.
* Objects are sorted by priority levels, and within an equal priority level
- * by OID. (This is a relatively crude hack to provide semi-reasonable
+ * by OID. (This is a relatively crude hack to provide semi-reasonable
* behavior for old databases without full dependency info.)
*/
static const int oldObjectTypePriority[] =
{
- 1, /* DO_NAMESPACE */
- 2, /* DO_TYPE */
- 2, /* DO_FUNC */
- 2, /* DO_AGG */
- 3, /* DO_OPERATOR */
- 4, /* DO_OPCLASS */
- 5, /* DO_CONVERSION */
- 6, /* DO_TABLE */
- 8, /* DO_ATTRDEF */
- 12, /* DO_INDEX */
- 13, /* DO_RULE */
- 14, /* DO_TRIGGER */
- 11, /* DO_CONSTRAINT */
- 15, /* DO_FK_CONSTRAINT */
- 2, /* DO_PROCLANG */
- 2, /* DO_CAST */
- 9, /* DO_TABLE_DATA */
- 7, /* DO_TABLE_TYPE */
- 10 /* DO_BLOBS */
+ 1, /* DO_NAMESPACE */
+ 2, /* DO_TYPE */
+ 2, /* DO_FUNC */
+ 2, /* DO_AGG */
+ 3, /* DO_OPERATOR */
+ 4, /* DO_OPCLASS */
+ 5, /* DO_CONVERSION */
+ 6, /* DO_TABLE */
+ 8, /* DO_ATTRDEF */
+ 12, /* DO_INDEX */
+ 13, /* DO_RULE */
+ 14, /* DO_TRIGGER */
+ 11, /* DO_CONSTRAINT */
+ 15, /* DO_FK_CONSTRAINT */
+ 2, /* DO_PROCLANG */
+ 2, /* DO_CAST */
+ 9, /* DO_TABLE_DATA */
+ 7, /* DO_TABLE_TYPE */
+ 10 /* DO_BLOBS */
};
/*
@@ -54,46 +54,46 @@ static const int oldObjectTypePriority[] =
*/
static const int newObjectTypePriority[] =
{
- 1, /* DO_NAMESPACE */
- 3, /* DO_TYPE */
- 4, /* DO_FUNC */
- 5, /* DO_AGG */
- 6, /* DO_OPERATOR */
- 7, /* DO_OPCLASS */
- 9, /* DO_CONVERSION */
- 10, /* DO_TABLE */
- 12, /* DO_ATTRDEF */
- 16, /* DO_INDEX */
- 17, /* DO_RULE */
- 18, /* DO_TRIGGER */
- 15, /* DO_CONSTRAINT */
- 19, /* DO_FK_CONSTRAINT */
- 2, /* DO_PROCLANG */
- 8, /* DO_CAST */
- 13, /* DO_TABLE_DATA */
- 11, /* DO_TABLE_TYPE */
- 14 /* DO_BLOBS */
+ 1, /* DO_NAMESPACE */
+ 3, /* DO_TYPE */
+ 4, /* DO_FUNC */
+ 5, /* DO_AGG */
+ 6, /* DO_OPERATOR */
+ 7, /* DO_OPCLASS */
+ 9, /* DO_CONVERSION */
+ 10, /* DO_TABLE */
+ 12, /* DO_ATTRDEF */
+ 16, /* DO_INDEX */
+ 17, /* DO_RULE */
+ 18, /* DO_TRIGGER */
+ 15, /* DO_CONSTRAINT */
+ 19, /* DO_FK_CONSTRAINT */
+ 2, /* DO_PROCLANG */
+ 8, /* DO_CAST */
+ 13, /* DO_TABLE_DATA */
+ 11, /* DO_TABLE_TYPE */
+ 14 /* DO_BLOBS */
};
static int DOTypeNameCompare(const void *p1, const void *p2);
static int DOTypeOidCompare(const void *p1, const void *p2);
static bool TopoSort(DumpableObject **objs,
- int numObjs,
- DumpableObject **ordering,
- int *nOrdering);
+ int numObjs,
+ DumpableObject **ordering,
+ int *nOrdering);
static void addHeapElement(int val, int *heap, int heapLength);
static int removeHeapElement(int *heap, int heapLength);
static void findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs);
static bool findLoop(DumpableObject *obj,
- DumpId startPoint,
- DumpableObject **workspace,
- int depth,
- int *newDepth);
+ DumpId startPoint,
+ DumpableObject **workspace,
+ int depth,
+ int *newDepth);
static void repairDependencyLoop(DumpableObject **loop,
- int nLoop);
+ int nLoop);
static void describeDumpableObject(DumpableObject *obj,
- char *buf, int bufsize);
+ char *buf, int bufsize);
/*
@@ -185,7 +185,7 @@ DOTypeOidCompare(const void *p1, const void *p2)
void
sortDumpableObjects(DumpableObject **objs, int numObjs)
{
- DumpableObject **ordering;
+ DumpableObject **ordering;
int nOrdering;
if (numObjs <= 0)
@@ -207,11 +207,11 @@ sortDumpableObjects(DumpableObject **objs, int numObjs)
* TopoSort -- topological sort of a dump list
*
* Generate a re-ordering of the dump list that satisfies all the dependency
- * constraints shown in the dump list. (Each such constraint is a fact of a
+ * constraints shown in the dump list. (Each such constraint is a fact of a
* partial ordering.) Minimize rearrangement of the list not needed to
* achieve the partial ordering.
*
- * The input is the list of numObjs objects in objs[]. This list is not
+ * The input is the list of numObjs objects in objs[]. This list is not
* modified.
*
* Returns TRUE if able to build an ordering that satisfies all the
@@ -233,32 +233,33 @@ static bool
TopoSort(DumpableObject **objs,
int numObjs,
DumpableObject **ordering, /* output argument */
- int *nOrdering) /* output argument */
+ int *nOrdering) /* output argument */
{
DumpId maxDumpId = getMaxDumpId();
int *pendingHeap;
int *beforeConstraints;
int *idMap;
- DumpableObject *obj;
+ DumpableObject *obj;
int heapLength;
int i,
j,
k;
/*
- * This is basically the same algorithm shown for topological sorting in
- * Knuth's Volume 1. However, we would like to minimize unnecessary
- * rearrangement of the input ordering; that is, when we have a choice
- * of which item to output next, we always want to take the one highest
- * in the original list. Therefore, instead of maintaining an unordered
- * linked list of items-ready-to-output as Knuth does, we maintain a heap
- * of their item numbers, which we can use as a priority queue. This
- * turns the algorithm from O(N) to O(N log N) because each insertion or
- * removal of a heap item takes O(log N) time. However, that's still
- * plenty fast enough for this application.
+ * This is basically the same algorithm shown for topological sorting
+ * in Knuth's Volume 1. However, we would like to minimize
+ * unnecessary rearrangement of the input ordering; that is, when we
+ * have a choice of which item to output next, we always want to take
+ * the one highest in the original list. Therefore, instead of
+ * maintaining an unordered linked list of items-ready-to-output as
+ * Knuth does, we maintain a heap of their item numbers, which we can
+ * use as a priority queue. This turns the algorithm from O(N) to O(N
+ * log N) because each insertion or removal of a heap item takes O(log
+ * N) time. However, that's still plenty fast enough for this
+ * application.
*/
- *nOrdering = numObjs; /* for success return */
+ *nOrdering = numObjs; /* for success return */
/* Eliminate the null case */
if (numObjs <= 0)
@@ -272,9 +273,9 @@ TopoSort(DumpableObject **objs,
/*
* Scan the constraints, and for each item in the input, generate a
* count of the number of constraints that say it must be before
- * something else. The count for the item with dumpId j is
- * stored in beforeConstraints[j]. We also make a map showing the
- * input-order index of the item with dumpId j.
+ * something else. The count for the item with dumpId j is stored in
+ * beforeConstraints[j]. We also make a map showing the input-order
+ * index of the item with dumpId j.
*/
beforeConstraints = (int *) malloc((maxDumpId + 1) * sizeof(int));
if (beforeConstraints == NULL)
@@ -304,23 +305,24 @@ TopoSort(DumpableObject **objs,
* the indexes of items that already have beforeConstraints[id] == 0.
*
* The essential property of a heap is heap[(j-1)/2] >= heap[j] for each
- * j in the range 1..heapLength-1 (note we are using 0-based subscripts
- * here, while the discussion in Knuth assumes 1-based subscripts).
- * So, if we simply enter the indexes into pendingHeap[] in decreasing
- * order, we a-fortiori have the heap invariant satisfied at completion
- * of this loop, and don't need to do any sift-up comparisons.
+ * j in the range 1..heapLength-1 (note we are using 0-based
+ * subscripts here, while the discussion in Knuth assumes 1-based
+ * subscripts). So, if we simply enter the indexes into pendingHeap[]
+ * in decreasing order, we a-fortiori have the heap invariant
+ * satisfied at completion of this loop, and don't need to do any
+ * sift-up comparisons.
*/
heapLength = 0;
- for (i = numObjs; --i >= 0; )
+ for (i = numObjs; --i >= 0;)
{
if (beforeConstraints[objs[i]->dumpId] == 0)
pendingHeap[heapLength++] = i;
}
/*--------------------
- * Now emit objects, working backwards in the output list. At each step,
+ * Now emit objects, working backwards in the output list. At each step,
* we use the priority heap to select the last item that has no remaining
- * before-constraints. We remove that item from the heap, output it to
+ * before-constraints. We remove that item from the heap, output it to
* ordering[], and decrease the beforeConstraints count of each of the
* items it was constrained against. Whenever an item's beforeConstraints
* count is thereby decreased to zero, we insert it into the priority heap
@@ -343,7 +345,7 @@ TopoSort(DumpableObject **objs,
/* Update beforeConstraints counts of its predecessors */
for (k = 0; k < obj->nDeps; k++)
{
- int id = obj->dependencies[k];
+ int id = obj->dependencies[k];
if ((--beforeConstraints[id]) == 0)
addHeapElement(idMap[id], pendingHeap, heapLength++);
@@ -448,7 +450,7 @@ removeHeapElement(int *heap, int heapLength)
* before trying TopoSort again. We can safely repair loops that are
* disjoint (have no members in common); if we find overlapping loops
* then we repair only the first one found, because the action taken to
- * repair the first might have repaired the other as well. (If not,
+ * repair the first might have repaired the other as well. (If not,
* we'll fix it on the next go-round.)
*
* objs[] lists the objects TopoSort couldn't sort
@@ -459,25 +461,25 @@ static void
findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
{
/*
- * We use a workspace array, the initial part of which stores
- * objects already processed, and the rest of which is used as
- * temporary space to try to build a loop in. This is convenient
- * because we do not care about loops involving already-processed
- * objects (see notes above); we can easily reject such loops in
- * findLoop() because of this representation. After we identify
- * and process a loop, we can add it to the initial part of the
- * workspace just by moving the boundary pointer.
+ * We use a workspace array, the initial part of which stores objects
+ * already processed, and the rest of which is used as temporary space
+ * to try to build a loop in. This is convenient because we do not
+ * care about loops involving already-processed objects (see notes
+ * above); we can easily reject such loops in findLoop() because of
+ * this representation. After we identify and process a loop, we can
+ * add it to the initial part of the workspace just by moving the
+ * boundary pointer.
*
- * When we determine that an object is not part of any interesting
- * loop, we also add it to the initial part of the workspace. This
- * is not necessary for correctness, but saves later invocations of
+ * When we determine that an object is not part of any interesting loop,
+ * we also add it to the initial part of the workspace. This is not
+ * necessary for correctness, but saves later invocations of
* findLoop() from uselessly chasing references to such an object.
*
- * We make the workspace large enough to hold all objects in the
- * original universe. This is probably overkill, but it's provably
- * enough space...
+ * We make the workspace large enough to hold all objects in the original
+ * universe. This is probably overkill, but it's provably enough
+ * space...
*/
- DumpableObject **workspace;
+ DumpableObject **workspace;
int initiallen;
bool fixedloop;
int i;
@@ -491,9 +493,9 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
for (i = 0; i < nObjs; i++)
{
DumpableObject *obj = objs[i];
- int newlen;
+ int newlen;
- workspace[initiallen] = NULL; /* see test below */
+ workspace[initiallen] = NULL; /* see test below */
if (findLoop(obj, obj->dumpId, workspace, initiallen, &newlen))
{
@@ -506,10 +508,10 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs)
else
{
/*
- * Didn't find a loop, but add this object to workspace anyway,
- * unless it's already present. We piggyback on the test that
- * findLoop() already did: it won't have tentatively added obj
- * to workspace if it's already present.
+ * Didn't find a loop, but add this object to workspace
+ * anyway, unless it's already present. We piggyback on the
+ * test that findLoop() already did: it won't have tentatively
+ * added obj to workspace if it's already present.
*/
if (workspace[initiallen] == obj)
initiallen++;
@@ -561,12 +563,15 @@ findLoop(DumpableObject *obj,
if (workspace[i] == obj)
return false;
}
+
/*
* Okay, tentatively add obj to workspace
*/
workspace[depth++] = obj;
+
/*
- * See if we've found a loop back to the desired startPoint; if so, done
+ * See if we've found a loop back to the desired startPoint; if so,
+ * done
*/
for (i = 0; i < obj->nDeps; i++)
{
@@ -576,6 +581,7 @@ findLoop(DumpableObject *obj,
return true;
}
}
+
/*
* Recurse down each outgoing branch
*/
@@ -620,6 +626,7 @@ repairTypeFuncLoop(DumpableObject *typeobj, DumpableObject *funcobj)
if (inputFuncInfo == NULL)
return;
addObjectDependency(funcobj, inputFuncInfo->dobj.dumpId);
+
/*
* Make sure the input function's dependency on type gets removed too;
* if it hasn't been done yet, we'd end up with loops involving the
@@ -900,7 +907,7 @@ repairDependencyLoop(DumpableObject **loop,
write_msg(modulename, "WARNING: could not resolve dependency loop among these items:\n");
for (i = 0; i < nLoop; i++)
{
- char buf[1024];
+ char buf[1024];
describeDumpableObject(loop[i], buf, sizeof(buf));
write_msg(modulename, " %s\n", buf);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index dec81f58390..1a9e4cdf16a 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.50 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.51 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,7 +59,7 @@ static PGconn *connectDatabase(const char *dbname, const char *pghost, const cha
const char *pguser, bool require_password);
static PGresult *executeQuery(PGconn *conn, const char *query);
-char pg_dump_bin[MAXPGPATH];
+char pg_dump_bin[MAXPGPATH];
PQExpBuffer pgdumpopts;
bool output_clean = false;
bool skip_acls = false;
@@ -67,9 +67,9 @@ bool verbose = false;
int server_version;
/* flags for -X long options */
-int disable_dollar_quoting = 0;
-int disable_triggers = 0;
-int use_setsessauth = 0;
+int disable_dollar_quoting = 0;
+int disable_triggers = 0;
+int use_setsessauth = 0;
int
main(int argc, char *argv[])
@@ -82,7 +82,8 @@ main(int argc, char *argv[])
bool globals_only = false;
bool schema_only = false;
PGconn *conn;
- int c, ret;
+ int c,
+ ret;
static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
@@ -140,16 +141,16 @@ main(int argc, char *argv[])
{
if (ret == -1)
fprintf(stderr,
- _("The program \"pg_dump\" is needed by %s "
- "but was not found in the same directory as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"pg_dump\" is needed by %s "
+ "but was not found in the same directory as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
else
fprintf(stderr,
- _("The program \"pg_dump\" was found by %s "
- "but was not the same version as \"%s\".\n"
- "Check your installation.\n"),
- progname, progname);
+ _("The program \"pg_dump\" was found by %s "
+ "but was not the same version as \"%s\".\n"
+ "Check your installation.\n"),
+ progname, progname);
exit(1);
}
@@ -231,7 +232,7 @@ main(int argc, char *argv[])
else if (strcmp(optarg, "disable-triggers") == 0)
appendPQExpBuffer(pgdumpopts, " -X disable-triggers");
else if (strcmp(optarg, "use-set-session-authorization") == 0)
- /* no-op, still allowed for compatibility */ ;
+ /* no-op, still allowed for compatibility */ ;
else
{
fprintf(stderr,
@@ -251,14 +252,14 @@ main(int argc, char *argv[])
}
}
- /* Add long options to the pg_dump argument list */
+ /* Add long options to the pg_dump argument list */
if (disable_dollar_quoting)
appendPQExpBuffer(pgdumpopts, " -X disable-dollar-quoting");
if (disable_triggers)
appendPQExpBuffer(pgdumpopts, " -X disable-triggers");
if (use_setsessauth)
appendPQExpBuffer(pgdumpopts, " -X use-set-session-authorization");
-
+
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
@@ -273,7 +274,7 @@ main(int argc, char *argv[])
printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
if (verbose)
- dumpTimestamp("Started on");
+ dumpTimestamp("Started on");
printf("\\connect \"template1\"\n\n");
@@ -330,7 +331,7 @@ help(void)
printf(_(" -X disable-dollar-quoting, --disable-dollar-quoting\n"
" disable dollar quoting, use SQL standard quoting\n"));
printf(_(" -X disable-triggers, --disable-triggers\n"
- " disable triggers during data-only restore\n"));
+ " disable triggers during data-only restore\n"));
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SESSION AUTHORIZATION commands instead of\n"
" OWNER TO commands\n"));
@@ -378,15 +379,20 @@ dumpUsers(PGconn *conn, bool initdbonly)
for (i = 0; i < PQntuples(res); i++)
{
const char *username;
- bool clusterowner;
+ bool clusterowner;
PQExpBuffer buf = createPQExpBuffer();
+
username = PQgetvalue(res, i, 0);
clusterowner = (strcmp(PQgetvalue(res, i, 6), "t") == 0);
/* Check which pass we're on */
- if ((initdbonly && !clusterowner) || (!initdbonly && clusterowner)) continue;
+ if ((initdbonly && !clusterowner) || (!initdbonly && clusterowner))
+ continue;
- /* Dump ALTER USER for the cluster owner and CREATE USER for all other users */
+ /*
+ * Dump ALTER USER for the cluster owner and CREATE USER for all
+ * other users
+ */
if (!clusterowner)
appendPQExpBuffer(buf, "CREATE USER %s WITH SYSID %s",
fmtId(username),
@@ -502,22 +508,22 @@ dumpTablespaces(PGconn *conn)
* pg_xxx)
*/
res = executeQuery(conn, "SELECT spcname, "
- "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
+ "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
"spclocation, spcacl "
"FROM pg_catalog.pg_tablespace "
"WHERE spcname NOT LIKE 'pg\\_%'");
-
+
if (PQntuples(res) > 0)
printf("--\n-- Tablespaces\n--\n\n");
for (i = 0; i < PQntuples(res); i++)
{
PQExpBuffer buf = createPQExpBuffer();
- char *spcname = PQgetvalue(res, i, 0);
- char *spcowner = PQgetvalue(res, i, 1);
- char *spclocation = PQgetvalue(res, i, 2);
- char *spcacl = PQgetvalue(res, i, 3);
- char *fspcname;
+ char *spcname = PQgetvalue(res, i, 0);
+ char *spcowner = PQgetvalue(res, i, 1);
+ char *spclocation = PQgetvalue(res, i, 2);
+ char *spcacl = PQgetvalue(res, i, 3);
+ char *fspcname;
/* needed for buildACLCommands() */
fspcname = strdup(fmtId(spcname));
@@ -778,11 +784,15 @@ makeAlterConfigCommand(const char *arrayitem, const char *type, const char *name
*pos = 0;
appendPQExpBuffer(buf, "ALTER %s %s ", type, fmtId(name));
appendPQExpBuffer(buf, "SET %s TO ", fmtId(mine));
- /* Some GUC variable names are 'LIST' type and hence must not be quoted. */
+
+ /*
+ * Some GUC variable names are 'LIST' type and hence must not be
+ * quoted.
+ */
if (strcasecmp(mine, "DateStyle") == 0
- || strcasecmp(mine, "search_path") == 0)
+ || strcasecmp(mine, "search_path") == 0)
appendPQExpBuffer(buf, "%s", pos + 1);
- else
+ else
appendStringLiteral(buf, pos + 1, false);
appendPQExpBuffer(buf, ";\n");
@@ -841,10 +851,10 @@ runPgDump(const char *dbname)
int ret;
/*
- * Win32 has to use double-quotes for args, rather than single quotes.
- * Strangely enough, this is the only place we pass a database name
- * on the command line, except template1 that doesn't need quoting.
- */
+ * Win32 has to use double-quotes for args, rather than single quotes.
+ * Strangely enough, this is the only place we pass a database name on
+ * the command line, except template1 that doesn't need quoting.
+ */
#ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
#else
@@ -871,7 +881,7 @@ runPgDump(const char *dbname)
#else
appendPQExpBufferChar(cmd, '"');
#endif
-
+
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
if (verbose)
@@ -994,8 +1004,8 @@ executeQuery(PGconn *conn, const char *query)
static void
dumpTimestamp(char *msg)
{
- char buf[256];
- time_t now = time(NULL);
+ char buf[256];
+ time_t now = time(NULL);
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
printf("-- %s %s\n\n", msg, buf);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 918a93a6568..90628da0674 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.60 2004/08/20 04:20:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.61 2004/08/29 05:06:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -326,7 +326,8 @@ main(int argc, char **argv)
AH->verbose = opts->verbose;
/*
- * Whether to keep submitting sql commands as "pg_restore ... | psql ... "
+ * Whether to keep submitting sql commands as "pg_restore ... | psql
+ * ... "
*/
AH->exit_on_error = opts->exit_on_error;
@@ -340,11 +341,11 @@ main(int argc, char **argv)
/* done, print a summary of ignored errors */
if (AH->n_errors)
- fprintf(stderr, _("WARNING, errors ignored on restore: %d\n"),
+ fprintf(stderr, _("WARNING, errors ignored on restore: %d\n"),
AH->n_errors);
/* AH may be freed in CloseArchive? */
- exit_code = AH->n_errors? 1: 0;
+ exit_code = AH->n_errors ? 1 : 0;
CloseArchive(AH);
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index a7f4397f5dd..936026230ec 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.22 2004/08/29 04:13:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.23 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,7 @@ extern char *optarg;
#define _(x) gettext((x))
-char XLogDir[MAXPGPATH]; /* not static, see xlog_internal.h */
+char XLogDir[MAXPGPATH]; /* not static, see xlog_internal.h */
static char ControlFilePath[MAXPGPATH];
static ControlFileData ControlFile; /* pg_control values */
@@ -432,8 +432,8 @@ PrintControlValues(bool guessed)
printf(_("pg_control values:\n\n"));
/*
- * Format system_identifier separately to keep platform-dependent format
- * code out of the translatable message string.
+ * Format system_identifier separately to keep platform-dependent
+ * format code out of the translatable message string.
*/
snprintf(sysident_str, sizeof(sysident_str), UINT64_FORMAT,
ControlFile.system_identifier);
@@ -476,7 +476,7 @@ RewriteControlFile(void)
/* adjust in case we are changing segment size */
newXlogSeg *= ControlFile.xlog_seg_size;
- newXlogSeg = (newXlogSeg + XLogSegSize-1) / XLogSegSize;
+ newXlogSeg = (newXlogSeg + XLogSegSize - 1) / XLogSegSize;
/* be sure we wrap around correctly at end of a logfile */
NextLogSeg(newXlogId, newXlogSeg);
@@ -589,8 +589,11 @@ KillExistingXLOG(void)
errno = 0;
}
#ifdef WIN32
- /* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
- not in released version */
+
+ /*
+ * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
+ * not in released version
+ */
if (GetLastError() == ERROR_NO_MORE_FILES)
errno = 0;
#endif
diff --git a/src/bin/pgevent/pgevent.c b/src/bin/pgevent/pgevent.c
index 71d08b603f9..6d72b60b092 100644
--- a/src/bin/pgevent/pgevent.c
+++ b/src/bin/pgevent/pgevent.c
@@ -2,11 +2,11 @@
*
* pgevent.c
* Defines the entry point for pgevent dll.
- * The DLL defines event source for backend
+ * The DLL defines event source for backend
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.1 2004/06/20 01:32:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.2 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,65 +17,69 @@
#include "string.h"
/* Global variables */
-HANDLE g_module = NULL; /* hModule of DLL */
+HANDLE g_module = NULL; /* hModule of DLL */
/* Prototypes */
-STDAPI DllRegisterServer(void) ;
-STDAPI DllUnregisterServer(void);
-BOOL WINAPI DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved );
+STDAPI
+DllRegisterServer(void);
+STDAPI DllUnregisterServer(void);
+BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved);
/*
- * DllRegisterServer --- Instructs DLL to create its registry entries
+ * DllRegisterServer --- Instructs DLL to create its registry entries
*/
-STDAPI DllRegisterServer(void)
+STDAPI
+DllRegisterServer(void)
{
- HKEY key;
- DWORD data;
- char buffer[_MAX_PATH];
+ HKEY key;
+ DWORD data;
+ char buffer[_MAX_PATH];
- /* Set the name of DLL full path name. */
- if (!GetModuleFileName((HMODULE)g_module, buffer, sizeof(buffer)))
+ /* Set the name of DLL full path name. */
+ if (!GetModuleFileName((HMODULE) g_module, buffer, sizeof(buffer)))
{
- MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK|MB_ICONSTOP);
- return SELFREG_E_TYPELIB;
+ MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ return SELFREG_E_TYPELIB;
}
- /* Add PostgreSQL source name as a subkey under the Application
- key in the EventLog registry key. */
- if ( RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key) )
+ /*
+ * Add PostgreSQL source name as a subkey under the Application key in
+ * the EventLog registry key.
+ */
+ if (RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key))
{
- MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
- return SELFREG_E_TYPELIB;
+ MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ return SELFREG_E_TYPELIB;
}
- /* Add the name to the EventMessageFile subkey. */
- if (RegSetValueEx(key,
- "EventMessageFile",
- 0,
- REG_EXPAND_SZ,
- (LPBYTE) buffer,
- strlen(buffer) + 1))
+ /* Add the name to the EventMessageFile subkey. */
+ if (RegSetValueEx(key,
+ "EventMessageFile",
+ 0,
+ REG_EXPAND_SZ,
+ (LPBYTE) buffer,
+ strlen(buffer) + 1))
{
- MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
- return SELFREG_E_TYPELIB;
+ MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ return SELFREG_E_TYPELIB;
}
-
- /* Set the supported event types in the TypesSupported subkey. */
- data = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
-
- if (RegSetValueEx(key,
- "TypesSupported",
- 0,
- REG_DWORD,
- (LPBYTE) &data,
- sizeof(DWORD)))
+
+ /* Set the supported event types in the TypesSupported subkey. */
+ data = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
+
+ if (RegSetValueEx(key,
+ "TypesSupported",
+ 0,
+ REG_DWORD,
+ (LPBYTE) & data,
+ sizeof(DWORD)))
{
- MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
- return SELFREG_E_TYPELIB;
+ MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ return SELFREG_E_TYPELIB;
}
-
- RegCloseKey(key);
+
+ RegCloseKey(key);
return S_OK;
}
@@ -83,15 +87,18 @@ STDAPI DllRegisterServer(void)
* DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer
*/
-STDAPI DllUnregisterServer(void)
+STDAPI
+DllUnregisterServer(void)
{
- /* Remove PostgreSQL source name as a subkey under the Application
- key in the EventLog registry key. */
-
- if ( RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL") )
+ /*
+ * Remove PostgreSQL source name as a subkey under the Application key
+ * in the EventLog registry key.
+ */
+
+ if (RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL"))
{
- MessageBox(NULL, "Could not delete the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
- return SELFREG_E_TYPELIB;
+ MessageBox(NULL, "Could not delete the registry key.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
+ return SELFREG_E_TYPELIB;
}
return S_OK;
}
@@ -100,15 +107,13 @@ STDAPI DllUnregisterServer(void)
* DllMain --- is an optional entry point into a DLL.
*/
-BOOL WINAPI DllMain( HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
+BOOL WINAPI
+DllMain(HANDLE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+)
{
- if ( ul_reason_for_call == DLL_PROCESS_ATTACH )
- {
+ if (ul_reason_for_call == DLL_PROCESS_ATTACH)
g_module = hModule;
- }
- return TRUE;
+ return TRUE;
}
-
diff --git a/src/bin/pgevent/pgmsgevent.h b/src/bin/pgevent/pgmsgevent.h
index fad729d3536..94e0bcf7e5b 100644
--- a/src/bin/pgevent/pgmsgevent.h
+++ b/src/bin/pgevent/pgmsgevent.h
@@ -1,45 +1,44 @@
-//
-// Values are 32 bit values layed out as follows:
-//
-// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-// +---+-+-+-----------------------+-------------------------------+
-// |Sev|C|R| Facility | Code |
-// +---+-+-+-----------------------+-------------------------------+
-//
-// where
-//
-// Sev - is the severity code
-//
-// 00 - Success
-// 01 - Informational
-// 10 - Warning
-// 11 - Error
-//
-// C - is the Customer code flag
-//
-// R - is a reserved bit
-//
-// Facility - is the facility code
-//
-// Code - is the facility's status code
-//
-//
-// Define the facility codes
-//
+/* */
+/* Values are 32 bit values layed out as follows: */
+/* */
+/* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 */
+/* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 */
+/* +---+-+-+-----------------------+-------------------------------+ */
+/* |Sev|C|R| Facility | Code | */
+/* +---+-+-+-----------------------+-------------------------------+ */
+/* */
+/* where */
+/* */
+/* Sev - is the severity code */
+/* */
+/* 00 - Success */
+/* 01 - Informational */
+/* 10 - Warning */
+/* 11 - Error */
+/* */
+/* C - is the Customer code flag */
+/* */
+/* R - is a reserved bit */
+/* */
+/* Facility - is the facility code */
+/* */
+/* Code - is the facility's status code */
+/* */
+/* */
+/* Define the facility codes */
+/* */
-//
-// Define the severity codes
-//
+/* */
+/* Define the severity codes */
+/* */
-//
-// MessageId: PGWIN32_EVENTLOG_MSG
-//
-// MessageText:
-//
-// %1
-//
-#define PGWIN32_EVENTLOG_MSG 0x00000000L
-
+/* */
+/* MessageId: PGWIN32_EVENTLOG_MSG */
+/* */
+/* MessageText: */
+/* */
+/* %1 */
+/* */
+#define PGWIN32_EVENTLOG_MSG 0x00000000L
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index cc00575fba5..220299bf2bd 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.124 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.125 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -44,8 +44,8 @@
/* functions for use in this file */
static backslashResult exec_command(const char *cmd,
- PsqlScanState scan_state,
- PQExpBuffer query_buf);
+ PsqlScanState scan_state,
+ PQExpBuffer query_buf);
static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
static bool do_connect(const char *new_dbname, const char *new_user);
static bool do_shell(const char *command);
@@ -92,7 +92,7 @@ HandleSlashCmds(PsqlScanState scan_state,
* one-letter command with immediately following argument (a
* still-supported, but no longer encouraged, syntax).
*/
- char new_cmd[2];
+ char new_cmd[2];
/* don't change cmd until we know it's okay */
new_cmd[0] = cmd[0];
@@ -266,7 +266,7 @@ exec_command(const char *cmd,
else if (pg_strcasecmp(cmd, "copy") == 0)
{
char *opt = psql_scan_slash_option(scan_state,
- OT_WHOLE_LINE, NULL, false);
+ OT_WHOLE_LINE, NULL, false);
success = do_copy(opt);
free(opt);
@@ -397,7 +397,7 @@ exec_command(const char *cmd,
fout = stdout;
while ((value = psql_scan_slash_option(scan_state,
- OT_NORMAL, &quoted, false)))
+ OT_NORMAL, &quoted, false)))
{
if (!quoted && strcmp(value, "-n") == 0)
no_newline = true;
@@ -419,7 +419,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "encoding") == 0)
{
char *encoding = psql_scan_slash_option(scan_state,
- OT_NORMAL, NULL, false);
+ OT_NORMAL, NULL, false);
if (!encoding)
{
@@ -447,7 +447,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "f") == 0)
{
char *fname = psql_scan_slash_option(scan_state,
- OT_NORMAL, NULL, false);
+ OT_NORMAL, NULL, false);
success = do_pset("fieldsep", fname, &pset.popt, quiet);
free(fname);
@@ -457,7 +457,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "g") == 0)
{
char *fname = psql_scan_slash_option(scan_state,
- OT_FILEPIPE, NULL, false);
+ OT_FILEPIPE, NULL, false);
if (!fname)
pset.gfname = NULL;
@@ -474,7 +474,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0)
{
char *opt = psql_scan_slash_option(scan_state,
- OT_WHOLE_LINE, NULL, false);
+ OT_WHOLE_LINE, NULL, false);
helpSQL(opt, pset.popt.topt.pager);
free(opt);
@@ -582,7 +582,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "o") == 0 || strcmp(cmd, "out") == 0)
{
char *fname = psql_scan_slash_option(scan_state,
- OT_FILEPIPE, NULL, true);
+ OT_FILEPIPE, NULL, true);
expand_tilde(&fname);
success = setQFout(fname);
@@ -710,7 +710,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "T") == 0)
{
char *value = psql_scan_slash_option(scan_state,
- OT_NORMAL, NULL, false);
+ OT_NORMAL, NULL, false);
success = do_pset("tableattr", value, &pset.popt, quiet);
free(value);
@@ -822,7 +822,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "z") == 0)
{
char *pattern = psql_scan_slash_option(scan_state,
- OT_NORMAL, NULL, true);
+ OT_NORMAL, NULL, true);
success = permissionsList(pattern);
if (pattern)
@@ -833,7 +833,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "!") == 0)
{
char *opt = psql_scan_slash_option(scan_state,
- OT_WHOLE_LINE, NULL, false);
+ OT_WHOLE_LINE, NULL, false);
success = do_shell(opt);
free(opt);
diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h
index 2899111e83d..8149d93396b 100644
--- a/src/bin/psql/command.h
+++ b/src/bin/psql/command.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.20 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.21 2004/08/29 05:06:54 momjian Exp $
*/
#ifndef COMMAND_H
#define COMMAND_H
@@ -26,7 +26,7 @@ typedef enum _backslashResult
extern backslashResult HandleSlashCmds(PsqlScanState scan_state,
- PQExpBuffer query_buf);
+ PQExpBuffer query_buf);
extern int process_file(char *filename);
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 0d0eadee904..b3e0bbfb8d6 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.89 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.90 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -57,7 +57,6 @@ typedef struct _timeb TimevalStruct;
#define DIFF_MSEC(T, U) \
(((T)->time - (U)->time) * 1000.0 + \
((T)->millitm - (U)->millitm))
-
#endif
extern bool prompt_state;
@@ -358,10 +357,19 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
int loc = 0;
const char *sp;
- int clen, slen, i, *qidx, *scridx, qoffset, scroffset, ibeg, iend,
- loc_line;
- char *wquery;
- bool beg_trunc, end_trunc;
+ int clen,
+ slen,
+ i,
+ *qidx,
+ *scridx,
+ qoffset,
+ scroffset,
+ ibeg,
+ iend,
+ loc_line;
+ char *wquery;
+ bool beg_trunc,
+ end_trunc;
PQExpBufferData msg;
if (pset.verbosity == PQERRORS_TERSE)
@@ -420,17 +428,17 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
psql_assert(clen < slen);
/* convert loc to zero-based offset in qidx/scridx arrays */
- loc--;
+ loc--;
/* do we have something to show? */
if (loc >= 0 && loc <= clen)
{
- /* input line number of our syntax error. */
+ /* input line number of our syntax error. */
loc_line = 1;
/* first included char of extract. */
- ibeg = 0;
+ ibeg = 0;
/* last-plus-1 included char of extract. */
- iend = clen;
+ iend = clen;
/*
* Replace tabs with spaces in the writable copy. (Later we might
@@ -438,31 +446,31 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
* but not today.)
*
* Extract line number and begin and end indexes of line containing
- * error location. There will not be any newlines or carriage
+ * error location. There will not be any newlines or carriage
* returns in the selected extract.
*/
- for (i=0; i<clen; i++)
+ for (i = 0; i < clen; i++)
{
/* character length must be 1 or it's not ASCII */
- if ((qidx[i+1]-qidx[i]) == 1)
+ if ((qidx[i + 1] - qidx[i]) == 1)
{
- if (wquery[qidx[i]] == '\t')
+ if (wquery[qidx[i]] == '\t')
wquery[qidx[i]] = ' ';
else if (wquery[qidx[i]] == '\r' || wquery[qidx[i]] == '\n')
{
if (i < loc)
{
/*
- * count lines before loc. Each \r or \n counts
+ * count lines before loc. Each \r or \n counts
* as a line except when \r \n appear together.
*/
if (wquery[qidx[i]] == '\r' ||
i == 0 ||
- (qidx[i]-qidx[i-1]) != 1 ||
- wquery[qidx[i-1]] != '\r')
+ (qidx[i] - qidx[i - 1]) != 1 ||
+ wquery[qidx[i - 1]] != '\r')
loc_line++;
/* extract beginning = last line start before loc. */
- ibeg = i+1;
+ ibeg = i + 1;
}
else
{
@@ -478,30 +486,30 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
/* If the line extracted is too long, we truncate it. */
beg_trunc = false;
end_trunc = false;
- if (scridx[iend]-scridx[ibeg] > DISPLAY_SIZE)
+ if (scridx[iend] - scridx[ibeg] > DISPLAY_SIZE)
{
/*
* We first truncate right if it is enough. This code might
* be off a space or so on enforcing MIN_RIGHT_CUT if there's
* a wide character right there, but that should be okay.
*/
- if (scridx[ibeg]+DISPLAY_SIZE >= scridx[loc]+MIN_RIGHT_CUT)
+ if (scridx[ibeg] + DISPLAY_SIZE >= scridx[loc] + MIN_RIGHT_CUT)
{
- while (scridx[iend]-scridx[ibeg] > DISPLAY_SIZE)
+ while (scridx[iend] - scridx[ibeg] > DISPLAY_SIZE)
iend--;
end_trunc = true;
}
else
{
/* Truncate right if not too close to loc. */
- while (scridx[loc]+MIN_RIGHT_CUT < scridx[iend])
+ while (scridx[loc] + MIN_RIGHT_CUT < scridx[iend])
{
iend--;
end_trunc = true;
}
/* Truncate left if still too long. */
- while (scridx[iend]-scridx[ibeg] > DISPLAY_SIZE)
+ while (scridx[iend] - scridx[ibeg] > DISPLAY_SIZE)
{
ibeg++;
beg_trunc = true;
@@ -510,7 +518,7 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
}
/* the extract MUST contain the target position! */
- psql_assert(ibeg<=loc && loc<=iend);
+ psql_assert(ibeg <= loc && loc <= iend);
/* truncate working copy at desired endpoint */
wquery[qidx[iend]] = '\0';
@@ -526,9 +534,7 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
*/
scroffset = 0;
for (i = 0; i < msg.len; i += PQmblen(&msg.data[i], pset.encoding))
- {
scroffset += PQdsplen(&msg.data[i], pset.encoding);
- }
/* Finish and emit the message. */
appendPQExpBufferStr(&msg, &wquery[qidx[ibeg]]);
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 8dbb091b95a..bf7aad15d49 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.53 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.54 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -70,8 +70,8 @@ struct copy_options
char *null;
char *quote;
char *escape;
- char *force_quote_list;
- char *force_notnull_list;
+ char *force_quote_list;
+ char *force_notnull_list;
};
@@ -232,7 +232,7 @@ parse_slash_copy(const char *args)
result->file = NULL;
}
else if (pg_strcasecmp(token, "pstdin") == 0 ||
- pg_strcasecmp(token, "pstdout") == 0)
+ pg_strcasecmp(token, "pstdout") == 0)
{
result->psql_inout = true;
result->file = NULL;
@@ -271,8 +271,8 @@ parse_slash_copy(const char *args)
if (token)
{
/*
- * WITH is optional. Also, the backend will allow WITH followed by
- * nothing, so we do too.
+ * WITH is optional. Also, the backend will allow WITH followed
+ * by nothing, so we do too.
*/
if (pg_strcasecmp(token, "with") == 0)
token = strtokx(NULL, whitespace, NULL, NULL,
@@ -280,19 +280,15 @@ parse_slash_copy(const char *args)
while (token)
{
- bool fetch_next;
+ bool fetch_next;
fetch_next = true;
-
+
/* someday allow BINARY here */
if (pg_strcasecmp(token, "oids") == 0)
- {
result->oids = true;
- }
else if (pg_strcasecmp(token, "csv") == 0)
- {
result->csv_mode = true;
- }
else if (pg_strcasecmp(token, "delimiter") == 0)
{
token = strtokx(NULL, whitespace, NULL, "'",
@@ -434,7 +430,7 @@ do_copy(const char *args)
PGresult *result;
bool success;
struct stat st;
-
+
/* parse options */
options = parse_slash_copy(args);
@@ -483,10 +479,8 @@ do_copy(const char *args)
}
if (options->csv_mode)
- {
appendPQExpBuffer(&query, " CSV");
- }
-
+
if (options->quote)
{
if (options->quote[0] == '\'')
@@ -504,14 +498,10 @@ do_copy(const char *args)
}
if (options->force_quote_list)
- {
appendPQExpBuffer(&query, " FORCE QUOTE %s", options->force_quote_list);
- }
if (options->force_notnull_list)
- {
appendPQExpBuffer(&query, " FORCE NOT NULL %s", options->force_notnull_list);
- }
if (options->file)
canonicalize_path(options->file);
@@ -521,16 +511,16 @@ do_copy(const char *args)
if (options->file)
copystream = fopen(options->file, PG_BINARY_R);
else if (!options->psql_inout)
- copystream = pset.cur_cmd_source;
+ copystream = pset.cur_cmd_source;
else
- copystream = stdin;
+ copystream = stdin;
}
else
{
if (options->file)
copystream = fopen(options->file, "w");
else if (!options->psql_inout)
- copystream = pset.queryFout;
+ copystream = pset.queryFout;
else
copystream = stdout;
}
@@ -578,7 +568,7 @@ do_copy(const char *args)
PQclear(result);
- if (options->file != NULL)
+ if (options->file != NULL)
{
if (fclose(copystream) != 0)
{
@@ -676,13 +666,11 @@ handleCopyIn(PGconn *conn, FILE *copystream)
{
if (!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."));
prompt = get_prompt(PROMPT_COPY);
}
else
- {
prompt = NULL;
- }
while (!copydone)
{ /* for each input line ... */
@@ -720,8 +708,8 @@ handleCopyIn(PGconn *conn, FILE *copystream)
if (c == EOF && s == copybuf && firstload)
{
/*
- * We are guessing a little bit as to the right line-ending
- * here...
+ * We are guessing a little bit as to the right
+ * line-ending here...
*/
if (saw_cr)
PQputline(conn, "\\.\r\n");
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 30b8443ca6e..2596688815f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.105 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.106 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -39,8 +39,8 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
const char *schemavar, const char *namevar,
const char *altnamevar, const char *visibilityrule);
-static void add_tablespace_footer(char relkind, Oid tablespace,
- char **footers, int *count, PQExpBufferData buf);
+static void add_tablespace_footer(char relkind, Oid tablespace,
+ char **footers, int *count, PQExpBufferData buf);
/*----------------
* Handlers for various slash commands displaying some sort of list
@@ -112,25 +112,26 @@ describeTablespaces(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 70500) {
- fprintf(stderr, _("This server version (%d) does not support tablespaces.\n"),
- pset.sversion);
- return true;
+ if (pset.sversion < 70500)
+ {
+ fprintf(stderr, _("This server version (%d) does not support tablespaces.\n"),
+ pset.sversion);
+ return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT spcname AS \"%s\",\n"
- " pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
+ " pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
" spclocation AS \"%s\"",
_("Name"), _("Owner"), _("Location"));
if (verbose)
appendPQExpBuffer(&buf,
- ",\n spcacl as \"%s\"",
- _("Access privileges"));
-
+ ",\n spcacl as \"%s\"",
+ _("Access privileges"));
+
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_tablespace\n");
@@ -697,7 +698,7 @@ describeOneTableDetails(const char *schemaname,
char relkind;
bool hasindex;
bool hasrules;
- bool hasoids;
+ bool hasoids;
Oid tablespace;
} tableinfo;
bool show_modifiers = false;
@@ -711,8 +712,8 @@ describeOneTableDetails(const char *schemaname,
/* Get general table info */
printfPQExpBuffer(&buf,
- "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
- "relhasoids %s \n"
+ "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
+ "relhasoids %s \n"
"FROM pg_catalog.pg_class WHERE oid = '%s'",
pset.sversion >= 70500 ? ", reltablespace" : "",
oid);
@@ -736,8 +737,8 @@ describeOneTableDetails(const char *schemaname,
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
- tableinfo.tablespace = (pset.sversion >= 70500) ?
- atooid(PQgetvalue(res, 0, 6)) : 0;
+ tableinfo.tablespace = (pset.sversion >= 70500) ?
+ atooid(PQgetvalue(res, 0, 6)) : 0;
PQclear(res);
headers[0] = _("Column");
@@ -895,8 +896,8 @@ describeOneTableDetails(const char *schemaname,
PGresult *result;
printfPQExpBuffer(&buf,
- "SELECT i.indisunique, i.indisprimary, i.indisclustered, a.amname, c2.relname,\n"
- " pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
+ "SELECT i.indisunique, i.indisprimary, i.indisclustered, a.amname, c2.relname,\n"
+ " pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
"FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n"
"WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
"AND i.indrelid = c2.oid",
@@ -941,7 +942,7 @@ describeOneTableDetails(const char *schemaname,
footers = pg_malloc_zero(4 * sizeof(*footers));
footers[count_footers++] = pg_strdup(tmpbuf.data);
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
- footers, &count_footers, tmpbuf);
+ footers, &count_footers, tmpbuf);
footers[count_footers] = NULL;
}
@@ -1020,8 +1021,8 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.hasindex)
{
printfPQExpBuffer(&buf,
- "SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, "
- "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)\n"
+ "SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, "
+ "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)\n"
"FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
"WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
"ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname",
@@ -1038,10 +1039,10 @@ describeOneTableDetails(const char *schemaname,
{
printfPQExpBuffer(&buf,
"SELECT "
- "pg_catalog.pg_get_constraintdef(r.oid, true), "
+ "pg_catalog.pg_get_constraintdef(r.oid, true), "
"conname\n"
"FROM pg_catalog.pg_constraint r\n"
- "WHERE r.conrelid = '%s' AND r.contype = 'c'",
+ "WHERE r.conrelid = '%s' AND r.contype = 'c'",
oid);
result2 = PSQLexec(buf.data, false);
if (!result2)
@@ -1102,7 +1103,7 @@ describeOneTableDetails(const char *schemaname,
{
printfPQExpBuffer(&buf,
"SELECT conname,\n"
- " pg_catalog.pg_get_constraintdef(oid, true) as condef\n"
+ " pg_catalog.pg_get_constraintdef(oid, true) as condef\n"
"FROM pg_catalog.pg_constraint r\n"
"WHERE r.conrelid = '%s' AND r.contype = 'f'",
oid);
@@ -1255,14 +1256,15 @@ describeOneTableDetails(const char *schemaname,
if (verbose)
{
- char *s = _("Contains OIDs");
+ char *s = _("Contains OIDs");
+
printfPQExpBuffer(&buf, "%s: %s", s,
(tableinfo.hasoids ? _("yes") : _("no")));
footers[count_footers++] = pg_strdup(buf.data);
}
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
- footers, &count_footers, buf);
+ footers, &count_footers, buf);
/* end of list marker */
footers[count_footers] = NULL;
@@ -1315,29 +1317,30 @@ error_return:
static void
-add_tablespace_footer(char relkind, Oid tablespace, char **footers,
- int *count, PQExpBufferData buf)
+add_tablespace_footer(char relkind, Oid tablespace, char **footers,
+ int *count, PQExpBufferData buf)
{
/* relkinds for which we support tablespaces */
- if(relkind == 'r' || relkind == 'i')
+ if (relkind == 'r' || relkind == 'i')
{
/*
* We ignore the database default tablespace so that users not
* using tablespaces don't need to know about them.
*/
- if(tablespace != 0)
+ if (tablespace != 0)
{
PGresult *result1 = NULL;
+
printfPQExpBuffer(&buf, "SELECT spcname FROM pg_tablespace \n"
- "WHERE oid = '%u';", tablespace);
+ "WHERE oid = '%u';", tablespace);
result1 = PSQLexec(buf.data, false);
- if (!result1)
+ if (!result1)
return;
/* Should always be the case, but.... */
- if(PQntuples(result1) > 0)
+ if (PQntuples(result1) > 0)
{
printfPQExpBuffer(&buf, _("Tablespace: \"%s\""),
- PQgetvalue(result1, 0, 0));
+ PQgetvalue(result1, 0, 0));
footers[(*count)++] = pg_strdup(buf.data);
}
PQclear(result1);
@@ -1716,21 +1719,21 @@ listSchemas(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
- "SELECT n.nspname AS \"%s\",\n"
- " u.usename AS \"%s\"",
- _("Name"), _("Owner"));
-
+ "SELECT n.nspname AS \"%s\",\n"
+ " u.usename AS \"%s\"",
+ _("Name"), _("Owner"));
+
if (verbose)
appendPQExpBuffer(&buf,
- ",\n n.nspacl as \"%s\","
- " pg_catalog.obj_description(n.oid, 'pg_namespace') as \"%s\"",
- _("Access privileges"), _("Description"));
-
+ ",\n n.nspacl as \"%s\","
+ " pg_catalog.obj_description(n.oid, 'pg_namespace') as \"%s\"",
+ _("Access privileges"), _("Description"));
+
appendPQExpBuffer(&buf,
- "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
- " ON n.nspowner=u.usesysid\n"
- "WHERE (n.nspname NOT LIKE 'pg\\\\_temp\\\\_%%' OR\n"
- " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
+ "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
+ " ON n.nspowner=u.usesysid\n"
+ "WHERE (n.nspname NOT LIKE 'pg\\\\_temp\\\\_%%' OR\n"
+ " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
processNamePattern(&buf, pattern, true, false,
NULL, "n.nspname", NULL,
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index a11074baa18..24d2c8f59f1 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.92 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.93 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -237,7 +237,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\pset NAME [VALUE]\n"
" set table output option\n"
" (NAME := {format|border|expanded|fieldsep|footer|null|\n"
- " recordsep|tuples_only|title|tableattr|pager})\n"));
+ " recordsep|tuples_only|title|tableattr|pager})\n"));
fprintf(output, _(" \\t show only rows (currently %s)\n"),
ON(pset.popt.topt.tuples_only));
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
@@ -250,7 +250,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\lo_export LOBOID FILE\n"
" \\lo_import FILE [COMMENT] \n"
" \\lo_list\n"
- " \\lo_unlink LOBOID large object operations\n"));
+ " \\lo_unlink LOBOID large object operations\n"));
if (output != stdout)
{
@@ -308,7 +308,7 @@ helpSQL(const char *topic, unsigned short int pager)
FILE *output;
size_t len;
int nl_count = 0;
- char *ch;
+ char *ch;
/* don't care about trailing spaces or semicolons */
len = strlen(topic);
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 9fcaccc9b90..072df4abcee 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.36 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.37 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
@@ -171,7 +171,7 @@ initializeInput(int flags)
#ifdef USE_READLINE
if (flags & 1)
{
- char home[MAXPGPATH];
+ char home[MAXPGPATH];
useReadline = true;
initialize_readline();
@@ -182,7 +182,7 @@ initializeInput(int flags)
using_history();
if (get_home_path(home))
{
- char *psql_history;
+ char *psql_history;
psql_history = pg_malloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
@@ -230,12 +230,12 @@ finishInput(int exitstatus, void *arg)
#ifdef USE_READLINE
if (useHistory)
{
- char home[MAXPGPATH];
+ char home[MAXPGPATH];
if (get_home_path(home))
{
- char *psql_history;
- int hist_size;
+ char *psql_history;
+ int hist_size;
psql_history = pg_malloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 5de64b217d4..c555710a347 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.63 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.64 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -45,6 +45,7 @@ MainLoop(FILE *source)
volatile promptStatus_t prompt_status = PROMPT_READY;
volatile int count_eof = 0;
volatile bool die_on_error = false;
+
/* Save the prior command source */
FILE *prev_cmd_source;
bool prev_cmd_interactive;
@@ -107,9 +108,7 @@ MainLoop(FILE *source)
prompt_status = PROMPT_READY;
if (pset.cur_cmd_interactive)
- {
putc('\n', stdout);
- }
else
{
successResult = EXIT_USER;
@@ -245,10 +244,11 @@ MainLoop(FILE *source)
/* handle backslash command */
/*
- * If we added a newline to query_buf, and nothing else has
- * been inserted in query_buf by the lexer, then strip off
- * the newline again. This avoids any change to query_buf
- * when a line contains only a backslash command.
+ * If we added a newline to query_buf, and nothing else
+ * has been inserted in query_buf by the lexer, then strip
+ * off the newline again. This avoids any change to
+ * query_buf when a line contains only a backslash
+ * command.
*/
if (query_buf->len == added_nl_pos)
query_buf->data[--query_buf->len] = '\0';
@@ -256,7 +256,7 @@ MainLoop(FILE *source)
slashCmdStatus = HandleSlashCmds(scan_state,
query_buf->len > 0 ?
- query_buf : previous_buf);
+ query_buf : previous_buf);
success = slashCmdStatus != CMD_ERROR;
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 7d710240d9d..f4347252690 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.50 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.51 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -389,7 +389,11 @@ print_aligned_text(const char *title, const char *const * headers,
fprintf(fout, "%s\n", *ptr);
#ifndef __MINGW32__
- /* for some reason MinGW outputs an extra newline, so this supresses it */
+
+ /*
+ * for some reason MinGW outputs an extra newline, so this supresses
+ * it
+ */
fputc('\n', fout);
#endif
@@ -839,15 +843,15 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
fputs("\\begin{tabular}{", fout);
if (opt_border == 2)
- fputs("| ", fout);
- for (i = 0; i < col_count; i++)
+ fputs("| ", fout);
+ for (i = 0; i < col_count; i++)
{
- fputc(*(opt_align + i), fout);
- if (opt_border != 0 && i < col_count - 1)
- fputs (" | ", fout);
+ fputc(*(opt_align + i), fout);
+ if (opt_border != 0 && i < col_count - 1)
+ fputs(" | ", fout);
}
if (opt_border == 2)
- fputs(" |", fout);
+ fputs(" |", fout);
fputs("}\n", fout);
@@ -861,9 +865,9 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
{
if (i != 0)
fputs(" & ", fout);
- fputs("\\textit{", fout);
+ fputs("\\textit{", fout);
latex_escaped_print(*ptr, fout);
- fputc('}', fout);
+ fputc('}', fout);
}
}
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 912eb00888d..909adb37b19 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.36 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.37 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
@@ -289,18 +289,20 @@ get_prompt(promptStatus_t status)
break;
}
- case '[':
- case ']':
+ case '[':
+ case ']':
#if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
- /*
- * readline >=4.0 undocumented feature: non-printing
- * characters in prompt strings must be marked as such,
- * in order to properly display the line during editing.
- */
- buf[0] = '\001';
- buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
-#endif /* USE_READLINE */
- break;
+
+ /*
+ * readline >=4.0 undocumented feature: non-printing
+ * characters in prompt strings must be marked as
+ * such, in order to properly display the line during
+ * editing.
+ */
+ buf[0] = '\001';
+ buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+#endif /* USE_READLINE */
+ break;
default:
buf[0] = *p;
diff --git a/src/bin/psql/psqlscan.h b/src/bin/psql/psqlscan.h
index 8c0b963a1e7..a4cb945a239 100644
--- a/src/bin/psql/psqlscan.h
+++ b/src/bin/psql/psqlscan.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/psqlscan.h,v 1.2 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/psqlscan.h,v 1.3 2004/08/29 05:06:54 momjian Exp $
*/
#ifndef PSQLSCAN_H
#define PSQLSCAN_H
@@ -40,12 +40,12 @@ extern PsqlScanState psql_scan_create(void);
extern void psql_scan_destroy(PsqlScanState state);
extern void psql_scan_setup(PsqlScanState state,
- const char *line, int line_len);
+ const char *line, int line_len);
extern void psql_scan_finish(PsqlScanState state);
extern PsqlScanResult psql_scan(PsqlScanState state,
- PQExpBuffer query_buf,
- promptStatus_t *prompt);
+ PQExpBuffer query_buf,
+ promptStatus_t *prompt);
extern void psql_scan_reset(PsqlScanState state);
@@ -54,9 +54,9 @@ extern bool psql_scan_in_quote(PsqlScanState state);
extern char *psql_scan_slash_command(PsqlScanState state);
extern char *psql_scan_slash_option(PsqlScanState state,
- enum slash_option_type type,
- char *quote,
- bool semicolon);
+ enum slash_option_type type,
+ char *quote,
+ bool semicolon);
extern void psql_scan_slash_command_end(PsqlScanState state);
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
index b5bbb937ea1..2c44b3133fb 100644
--- a/src/bin/psql/settings.h
+++ b/src/bin/psql/settings.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.20 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.21 2004/08/29 05:06:54 momjian Exp $
*/
#ifndef SETTINGS_H
#define SETTINGS_H
@@ -41,7 +41,7 @@ typedef struct _psqlSettings
FILE *cur_cmd_source; /* describe the status of the current main
* loop */
bool cur_cmd_interactive;
- int sversion; /* backend server version */
+ int sversion; /* backend server version */
const char *progname; /* in case you renamed psql */
char *inputfile; /* for error reporting */
unsigned lineno; /* also for error reporting */
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 8e94ced3637..e1be68b145d 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.98 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.99 2004/08/29 05:06:54 momjian Exp $
*/
#include "postgres_fe.h"
@@ -45,7 +45,7 @@ int optreset;
PsqlSettings pset;
#define SYSPSQLRC "psqlrc"
-#define PSQLRC ".psqlrc"
+#define PSQLRC ".psqlrc"
/*
* Structures to pass information between the option parsing routine
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
}
#ifdef WIN32
- setvbuf(stderr,NULL,_IONBF,0);
+ setvbuf(stderr, NULL, _IONBF, 0);
#endif
pset.cur_cmd_source = stdin;
pset.cur_cmd_interactive = false;
@@ -287,7 +287,7 @@ main(int argc, char *argv[])
"Type: \\copyright for distribution terms\n"
" \\h for help with SQL commands\n"
" \\? for help with psql commands\n"
- " \\g or terminate with semicolon to execute query\n"
+ " \\g or terminate with semicolon to execute query\n"
" \\q to quit\n\n"),
pset.progname, PG_VERSION);
#ifdef USE_SSL
@@ -574,10 +574,10 @@ static void
process_psqlrc(char *argv0)
{
char *psqlrc;
- char home[MAXPGPATH];
- char global_file[MAXPGPATH];
- char my_exec_path[MAXPGPATH];
- char etc_path[MAXPGPATH];
+ char home[MAXPGPATH];
+ char global_file[MAXPGPATH];
+ char my_exec_path[MAXPGPATH];
+ char etc_path[MAXPGPATH];
find_my_exec(argv0, my_exec_path);
get_etc_path(my_exec_path, etc_path);
@@ -610,7 +610,7 @@ process_psqlrc_file(char *filename)
if (access(psqlrc, R_OK) == 0)
process_file(psqlrc);
else if (access(filename, R_OK) == 0)
- process_file(filename);
+ process_file(filename);
free(psqlrc);
}
@@ -652,7 +652,6 @@ printSSLInfo(void)
printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"),
SSL_get_cipher(ssl), sslbits);
}
-
#endif
@@ -666,15 +665,18 @@ printSSLInfo(void)
static void
checkWin32Codepage(void)
{
- unsigned int wincp, concp;
+ unsigned int wincp,
+ concp;
wincp = GetACP();
concp = GetConsoleCP();
- if (wincp != concp) {
- printf("Warning: Console codepage (%u) differs from windows codepage (%u)\n"
- " 8-bit characters will not work correctly. See PostgreSQL\n"
- " documentation \"Installation on Windows\" for details.\n\n",
- concp, wincp);
+ if (wincp != concp)
+ {
+ printf("Warning: Console codepage (%u) differs from windows codepage (%u)\n"
+ " 8-bit characters will not work correctly. See PostgreSQL\n"
+ " documentation \"Installation on Windows\" for details.\n\n",
+ concp, wincp);
}
}
+
#endif
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index c2d2bfc2542..76449bceea7 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.113 2004/08/29 04:13:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.114 2004/08/29 05:06:54 momjian Exp $
*/
/*----------------------------------------------------------------------
@@ -81,28 +81,35 @@ typedef struct SchemaQuery
* "pg_catalog.pg_class c". Note that "pg_namespace n" will be added.
*/
const char *catname;
+
/*
- * Selection condition --- only rows meeting this condition are candidates
- * to display. If catname mentions multiple tables, include the
- * necessary join condition here. For example, "c.relkind = 'r'".
- * Write NULL (not an empty string) if not needed.
+ * Selection condition --- only rows meeting this condition are
+ * candidates to display. If catname mentions multiple tables,
+ * include the necessary join condition here. For example, "c.relkind
+ * = 'r'". Write NULL (not an empty string) if not needed.
*/
const char *selcondition;
+
/*
* Visibility condition --- which rows are visible without schema
- * qualification? For example, "pg_catalog.pg_table_is_visible(c.oid)".
+ * qualification? For example,
+ * "pg_catalog.pg_table_is_visible(c.oid)".
*/
const char *viscondition;
+
/*
- * Namespace --- name of field to join to pg_namespace.oid.
- * For example, "c.relnamespace".
+ * Namespace --- name of field to join to pg_namespace.oid. For
+ * example, "c.relnamespace".
*/
const char *namespace;
+
/*
* Result --- the appropriately-quoted name to return, in the case of
- * an unqualified name. For example, "pg_catalog.quote_ident(c.relname)".
+ * an unqualified name. For example,
+ * "pg_catalog.quote_ident(c.relname)".
*/
const char *result;
+
/*
* In some cases a different result must be used for qualified names.
* Enter that here, or write NULL if result can be used.
@@ -121,9 +128,10 @@ static int completion_max_records;
* the completion callback functions. Ugly but there is no better way.
*/
static const char *completion_charp; /* to pass a string */
-static const char * const *completion_charpp; /* to pass a list of strings */
-static const char *completion_info_charp; /* to pass a second string */
-static const SchemaQuery *completion_squery; /* to pass a SchemaQuery */
+static const char *const * completion_charpp; /* to pass a list of
+ * strings */
+static const char *completion_info_charp; /* to pass a second string */
+static const SchemaQuery *completion_squery; /* to pass a SchemaQuery */
/* A couple of macros to ease typing. You can use these to complete the given
string with
@@ -306,7 +314,7 @@ static const SchemaQuery Query_for_list_of_views = {
* restricted to names matching a partially entered name. In these queries,
* %s will be replaced by the text entered so far (suitably escaped to
* become a SQL literal string). %d will be replaced by the length of the
- * string (in unescaped form). A second %s, if present, will be replaced
+ * string (in unescaped form). A second %s, if present, will be replaced
* by a suitably-escaped version of the string provided in
* completion_info_charp.
*
@@ -401,17 +409,17 @@ static const pgsql_thing_t words_after_create[] = {
{"GROUP", "SELECT pg_catalog.quote_ident(groname) FROM pg_catalog.pg_group WHERE substring(pg_catalog.quote_ident(groname),1,%d)='%s'"},
{"LANGUAGE", Query_for_list_of_languages},
{"INDEX", NULL, &Query_for_list_of_indexes},
- {"OPERATOR", NULL, NULL}, /* Querying for this is probably
- * not such a good idea. */
+ {"OPERATOR", NULL, NULL}, /* Querying for this is probably not such
+ * a good idea. */
{"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'"},
{"SCHEMA", Query_for_list_of_schemas},
{"SEQUENCE", NULL, &Query_for_list_of_sequences},
{"TABLE", NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
- {"TEMP", NULL, NULL}, /* for CREATE TEMP TABLE ... */
+ {"TEMP", NULL, NULL}, /* for CREATE TEMP TABLE ... */
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'"},
{"TYPE", NULL, &Query_for_list_of_datatypes},
- {"UNIQUE", NULL, NULL}, /* for CREATE UNIQUE INDEX ... */
+ {"UNIQUE", NULL, NULL}, /* for CREATE UNIQUE INDEX ... */
{"USER", Query_for_list_of_users},
{"VIEW", NULL, &Query_for_list_of_views},
{NULL, NULL, NULL} /* end of list */
@@ -442,7 +450,7 @@ static char *dequote_file_name(char *text, char quote_char);
void
initialize_readline(void)
{
- rl_readline_name = (char *)pset.progname;
+ rl_readline_name = (char *) pset.progname;
rl_attempted_completion_function = (void *) psql_completion;
rl_basic_word_break_characters = "\t\n@$><=;|&{( ";
@@ -473,15 +481,15 @@ psql_completion(char *text, int start, int end)
*prev3_wd,
*prev4_wd;
- static const char * const sql_commands[] = {
+ static const char *const sql_commands[] = {
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CHECKPOINT", "CLOSE", "CLUSTER", "COMMENT",
"COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE", "DELETE", "DROP", "END", "EXECUTE",
"EXPLAIN", "FETCH", "GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY",
- "PREPARE", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK", "SAVEPOINT",
- "SELECT", "SET", "SHOW", "START", "TRUNCATE", "UNLISTEN", "UPDATE", "VACUUM", NULL
+ "PREPARE", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK", "SAVEPOINT",
+ "SELECT", "SET", "SHOW", "START", "TRUNCATE", "UNLISTEN", "UPDATE", "VACUUM", NULL
};
- static const char * const pgsql_variables[] = {
+ static const char *const pgsql_variables[] = {
/* these SET arguments are known in gram.y */
"CONSTRAINTS",
"NAMES",
@@ -587,7 +595,7 @@ psql_completion(char *text, int start, int end)
NULL
};
- static const char * const backslash_commands[] = {
+ static const char *const backslash_commands[] = {
"\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright",
"\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\df",
"\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS",
@@ -646,19 +654,19 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev3_wd, "TABLE") != 0)
{
static const char *const list_ALTER[] =
- {"AGGREGATE", "CONVERSATION", "DATABASE","DOMAIN", "FUNCTION",
- "GROUP", "INDEX", "LANGUAGE", "OPERATOR", "SCHEMA", "SEQUENCE", "TABLE",
+ {"AGGREGATE", "CONVERSATION", "DATABASE", "DOMAIN", "FUNCTION",
+ "GROUP", "INDEX", "LANGUAGE", "OPERATOR", "SCHEMA", "SEQUENCE", "TABLE",
"TABLESPACE", "TRIGGER", "TYPE", "USER", NULL};
COMPLETE_WITH_LIST(list_ALTER);
}
-
+
/* ALTER AGGREGATE,CONVERSION,FUNCTION,SCHEMA <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
(pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||
- pg_strcasecmp(prev2_wd, "CONVERSION") == 0 ||
- pg_strcasecmp(prev2_wd, "FUNCTION") == 0 ||
- pg_strcasecmp(prev2_wd, "SCHEMA") == 0 ))
+ pg_strcasecmp(prev2_wd, "CONVERSION") == 0 ||
+ pg_strcasecmp(prev2_wd, "FUNCTION") == 0 ||
+ pg_strcasecmp(prev2_wd, "SCHEMA") == 0))
{
static const char *const list_ALTERGEN[] =
{"OWNER TO", "RENAME TO", NULL};
@@ -682,7 +690,7 @@ psql_completion(char *text, int start, int end)
{
static const char *const list_ALTERINDEX[] =
{"SET TABLESPACE", "OWNER TO", "RENAME TO", NULL};
-
+
COMPLETE_WITH_LIST(list_ALTERINDEX);
}
@@ -763,11 +771,11 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev_wd, "COLUMN") == 0)
COMPLETE_WITH_ATTR(prev3_wd);
else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
- pg_strcasecmp(prev_wd, "CLUSTER") == 0)
+ pg_strcasecmp(prev_wd, "CLUSTER") == 0)
COMPLETE_WITH_CONST("ON");
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
- pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
- pg_strcasecmp(prev_wd, "ON") == 0)
+ pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
+ pg_strcasecmp(prev_wd, "ON") == 0)
{
completion_info_charp = prev3_wd;
COMPLETE_WITH_QUERY(Query_for_index_of_table);
@@ -781,16 +789,16 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_TABLESET);
}
- /* If we have TABLE <sth> SET TABLESPACE provide a list of tablespaces*/
+ /* If we have TABLE <sth> SET TABLESPACE provide a list of tablespaces */
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
pg_strcasecmp(prev2_wd, "SET") == 0 &&
pg_strcasecmp(prev_wd, "TABLESPACE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
- /* If we have TABLE <sth> SET WITHOUT provide CLUSTER or OIDS*/
+ /* If we have TABLE <sth> SET WITHOUT provide CLUSTER or OIDS */
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
pg_strcasecmp(prev2_wd, "SET") == 0 &&
pg_strcasecmp(prev_wd, "WITHOUT") == 0)
- {
+ {
static const char *const list_TABLESET2[] =
{"CLUSTER", "OIDS", NULL};
@@ -841,35 +849,38 @@ psql_completion(char *text, int start, int end)
/* BEGIN, END, COMMIT, ABORT */
else if (pg_strcasecmp(prev_wd, "BEGIN") == 0 ||
- pg_strcasecmp(prev_wd, "END") == 0 ||
- pg_strcasecmp(prev_wd, "COMMIT") == 0 ||
- pg_strcasecmp(prev_wd, "ABORT") == 0)
+ pg_strcasecmp(prev_wd, "END") == 0 ||
+ pg_strcasecmp(prev_wd, "COMMIT") == 0 ||
+ pg_strcasecmp(prev_wd, "ABORT") == 0)
{
- static const char * const list_TRANS[] =
+ static const char *const list_TRANS[] =
{"WORK", "TRANSACTION", NULL};
COMPLETE_WITH_LIST(list_TRANS);
}
/* RELEASE SAVEPOINT */
- else if ( pg_strcasecmp(prev_wd, "RELEASE") == 0 )
+ else if (pg_strcasecmp(prev_wd, "RELEASE") == 0)
COMPLETE_WITH_CONST("SAVEPOINT");
/* ROLLBACK*/
- else if ( pg_strcasecmp(prev_wd, "ROLLBACK") == 0 )
+ else if (pg_strcasecmp(prev_wd, "ROLLBACK") == 0)
{
- static const char * const list_TRANS[] =
+ static const char *const list_TRANS[] =
{"WORK", "TRANSACTION", "TO SAVEPOINT", NULL};
COMPLETE_WITH_LIST(list_TRANS);
}
/* CLUSTER */
- /* If the previous word is CLUSTER and not without produce list
- * of indexes. */
+
+ /*
+ * If the previous word is CLUSTER and not without produce list of
+ * indexes.
+ */
else if (pg_strcasecmp(prev_wd, "CLUSTER") == 0 &&
- pg_strcasecmp(prev2_wd, "WITHOUT") != 0)
+ pg_strcasecmp(prev2_wd, "WITHOUT") != 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
/* If we have CLUSTER <sth>, then add "ON" */
- else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
- pg_strcasecmp(prev_wd,"ON") != 0)
+ else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
+ pg_strcasecmp(prev_wd, "ON") != 0)
COMPLETE_WITH_CONST("ON");
/*
@@ -891,8 +902,8 @@ psql_completion(char *text, int start, int end)
{
static const char *const list_COMMENT[] =
{"CAST", "CONVERSION", "DATABASE", "INDEX", "LANGUAGE", "RULE", "SCHEMA",
- "SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION",
- "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", NULL};
+ "SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION",
+ "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", NULL};
COMPLETE_WITH_LIST(list_COMMENT);
}
@@ -1046,7 +1057,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev_wd, "FETCH") == 0 ||
pg_strcasecmp(prev_wd, "MOVE") == 0)
{
- static const char * const list_FETCH1[] =
+ static const char *const list_FETCH1[] =
{"ABSOLUT", "BACKWARD", "FORWARD", "RELATIVE", NULL};
COMPLETE_WITH_LIST(list_FETCH1);
@@ -1055,7 +1066,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev2_wd, "FETCH") == 0 ||
pg_strcasecmp(prev2_wd, "MOVE") == 0)
{
- static const char * const list_FETCH2[] =
+ static const char *const list_FETCH2[] =
{"ALL", "NEXT", "PRIOR", NULL};
COMPLETE_WITH_LIST(list_FETCH2);
@@ -1068,7 +1079,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
pg_strcasecmp(prev3_wd, "MOVE") == 0)
{
- static const char * const list_FROMTO[] =
+ static const char *const list_FROMTO[] =
{"FROM", "TO", NULL};
COMPLETE_WITH_LIST(list_FROMTO);
@@ -1079,9 +1090,9 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev_wd, "GRANT") == 0 ||
pg_strcasecmp(prev_wd, "REVOKE") == 0)
{
- static const char * const list_privileg[] =
+ static const char *const list_privileg[] =
{"SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "REFERENCES",
- "TRIGGER", "CREATE", "TEMPORARY", "EXECUTE", "USAGE", "ALL", NULL};
+ "TRIGGER", "CREATE", "TEMPORARY", "EXECUTE", "USAGE", "ALL", NULL};
COMPLETE_WITH_LIST(list_privileg);
}
@@ -1157,7 +1168,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev3_wd, "INSERT") == 0 &&
pg_strcasecmp(prev2_wd, "INTO") == 0)
{
- static const char * const list_INSERT[] =
+ static const char *const list_INSERT[] =
{"DEFAULT VALUES", "SELECT", "VALUES", NULL};
COMPLETE_WITH_LIST(list_INSERT);
@@ -1167,7 +1178,7 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev3_wd, "INTO") == 0 &&
prev_wd[strlen(prev_wd) - 1] == ')')
{
- static const char * const list_INSERT[] =
+ static const char *const list_INSERT[] =
{"SELECT", "VALUES", NULL};
COMPLETE_WITH_LIST(list_INSERT);
@@ -1200,12 +1211,12 @@ psql_completion(char *text, int start, int end)
(pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
pg_strcasecmp(prev4_wd, "LOCK") == 0)))
{
- static const char * const lock_modes[] =
+ static const char *const lock_modes[] =
{"ACCESS SHARE MODE",
- "ROW SHARE MODE", "ROW EXCLUSIVE MODE",
- "SHARE UPDATE EXCLUSIVE MODE", "SHARE MODE",
- "SHARE ROW EXCLUSIVE MODE",
- "EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE", NULL};
+ "ROW SHARE MODE", "ROW EXCLUSIVE MODE",
+ "SHARE UPDATE EXCLUSIVE MODE", "SHARE MODE",
+ "SHARE ROW EXCLUSIVE MODE",
+ "EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE", NULL};
COMPLETE_WITH_LIST(lock_modes);
}
@@ -1215,12 +1226,12 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(relname) FROM pg_catalog.pg_listener WHERE substring(pg_catalog.quote_ident(relname),1,%d)='%s'");
/* OWNER TO - complete with available users*/
else if (pg_strcasecmp(prev2_wd, "OWNER") == 0 &&
- pg_strcasecmp(prev_wd, "TO") == 0)
+ pg_strcasecmp(prev_wd, "TO") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_users);
/* REINDEX */
else if (pg_strcasecmp(prev_wd, "REINDEX") == 0)
{
- static const char * const list_REINDEX[] =
+ static const char *const list_REINDEX[] =
{"TABLE", "DATABASE", "INDEX", NULL};
COMPLETE_WITH_LIST(list_REINDEX);
@@ -1259,7 +1270,7 @@ psql_completion(char *text, int start, int end)
&& pg_strcasecmp(prev2_wd, "AS") == 0
&& pg_strcasecmp(prev_wd, "TRANSACTION") == 0))
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"ISOLATION", "READ", NULL};
COMPLETE_WITH_LIST(my_list);
@@ -1270,7 +1281,7 @@ psql_completion(char *text, int start, int end)
|| (pg_strcasecmp(prev4_wd, "CHARACTERISTICS") == 0
&& pg_strcasecmp(prev3_wd, "AS") == 0))
&& (pg_strcasecmp(prev2_wd, "TRANSACTION") == 0
- || pg_strcasecmp(prev2_wd, "WORK") == 0)
+ || pg_strcasecmp(prev2_wd, "WORK") == 0)
&& pg_strcasecmp(prev_wd, "ISOLATION") == 0)
COMPLETE_WITH_CONST("LEVEL");
else if ((pg_strcasecmp(prev4_wd, "SET") == 0
@@ -1278,41 +1289,41 @@ psql_completion(char *text, int start, int end)
|| pg_strcasecmp(prev4_wd, "START") == 0
|| pg_strcasecmp(prev4_wd, "AS") == 0)
&& (pg_strcasecmp(prev3_wd, "TRANSACTION") == 0
- || pg_strcasecmp(prev3_wd, "WORK") == 0)
+ || pg_strcasecmp(prev3_wd, "WORK") == 0)
&& pg_strcasecmp(prev2_wd, "ISOLATION") == 0
&& pg_strcasecmp(prev_wd, "LEVEL") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"READ", "REPEATABLE", "SERIALIZABLE", NULL};
COMPLETE_WITH_LIST(my_list);
}
else if ((pg_strcasecmp(prev4_wd, "TRANSACTION") == 0 ||
- pg_strcasecmp(prev4_wd, "WORK") == 0) &&
+ pg_strcasecmp(prev4_wd, "WORK") == 0) &&
pg_strcasecmp(prev3_wd, "ISOLATION") == 0 &&
pg_strcasecmp(prev2_wd, "LEVEL") == 0 &&
pg_strcasecmp(prev_wd, "READ") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"UNCOMMITTED", "COMMITTED", NULL};
COMPLETE_WITH_LIST(my_list);
}
- else if ((pg_strcasecmp(prev4_wd, "TRANSACTION") == 0 ||
- pg_strcasecmp(prev4_wd, "WORK") == 0) &&
+ else if ((pg_strcasecmp(prev4_wd, "TRANSACTION") == 0 ||
+ pg_strcasecmp(prev4_wd, "WORK") == 0) &&
pg_strcasecmp(prev3_wd, "ISOLATION") == 0 &&
pg_strcasecmp(prev2_wd, "LEVEL") == 0 &&
pg_strcasecmp(prev_wd, "REPEATABLE") == 0)
COMPLETE_WITH_CONST("READ");
else if ((pg_strcasecmp(prev3_wd, "SET") == 0 ||
- pg_strcasecmp(prev3_wd, "BEGIN") == 0 ||
- pg_strcasecmp(prev3_wd, "START") == 0 ||
- pg_strcasecmp(prev3_wd, "AS") == 0) &&
+ pg_strcasecmp(prev3_wd, "BEGIN") == 0 ||
+ pg_strcasecmp(prev3_wd, "START") == 0 ||
+ pg_strcasecmp(prev3_wd, "AS") == 0) &&
(pg_strcasecmp(prev2_wd, "TRANSACTION") == 0 ||
- pg_strcasecmp(prev2_wd, "WORK") == 0) &&
+ pg_strcasecmp(prev2_wd, "WORK") == 0) &&
pg_strcasecmp(prev_wd, "READ") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"ONLY", "WRITE", NULL};
COMPLETE_WITH_LIST(my_list);
@@ -1321,7 +1332,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev3_wd, "SET") == 0 &&
pg_strcasecmp(prev2_wd, "CONSTRAINTS") == 0)
{
- static const char * const constraint_list[] =
+ static const char *const constraint_list[] =
{"DEFERRED", "IMMEDIATE", NULL};
COMPLETE_WITH_LIST(constraint_list);
@@ -1330,7 +1341,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
pg_strcasecmp(prev_wd, "SESSION") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"AUTHORIZATION", "CHARACTERISTICS AS TRANSACTION", NULL};
COMPLETE_WITH_LIST(my_list);
@@ -1346,28 +1357,28 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("TO");
/* Suggest possible variable values */
else if (pg_strcasecmp(prev3_wd, "SET") == 0 &&
- (pg_strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0))
+ (pg_strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0))
{
if (pg_strcasecmp(prev2_wd, "DateStyle") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"ISO", "SQL", "Postgres", "German",
- "YMD", "DMY", "MDY",
- "US", "European", "NonEuropean",
- "DEFAULT", NULL};
+ "YMD", "DMY", "MDY",
+ "US", "European", "NonEuropean",
+ "DEFAULT", NULL};
COMPLETE_WITH_LIST(my_list);
}
else if (pg_strcasecmp(prev2_wd, "GEQO") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"ON", "OFF", "DEFAULT", NULL};
COMPLETE_WITH_LIST(my_list);
}
else
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"DEFAULT", NULL};
COMPLETE_WITH_LIST(my_list);
@@ -1463,10 +1474,10 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(sql_commands);
else if (strcmp(prev_wd, "\\pset") == 0)
{
- static const char * const my_list[] =
+ static const char *const my_list[] =
{"format", "border", "expanded",
- "null", "fieldsep", "tuples_only", "title", "tableattr", "pager",
- "recordsep", NULL};
+ "null", "fieldsep", "tuples_only", "title", "tableattr", "pager",
+ "recordsep", NULL};
COMPLETE_WITH_LIST(my_list);
}
@@ -1631,7 +1642,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
/* Set up suitably-escaped copies of textual inputs */
if (text)
{
- e_text = pg_malloc(strlen(text) * 2 + 1);
+ e_text = pg_malloc(strlen(text) *2 + 1);
PQescapeString(e_text, text, strlen(text));
}
else
@@ -1639,7 +1650,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
if (completion_info_charp)
{
- size_t charp_len;
+ size_t charp_len;
charp_len = strlen(completion_info_charp);
e_info_charp = pg_malloc(charp_len * 2 + 1);
@@ -1671,27 +1682,29 @@ _complete_from_query(int is_schema_query, const char *text, int state)
appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'",
completion_squery->result,
string_length, e_text);
+
/*
- * When fetching relation names, suppress system catalogs unless
- * the input-so-far begins with "pg_". This is a compromise
- * between not offering system catalogs for completion at all,
- * and having them swamp the result when the input is just "p".
+ * When fetching relation names, suppress system catalogs
+ * unless the input-so-far begins with "pg_". This is a
+ * compromise between not offering system catalogs for
+ * completion at all, and having them swamp the result when
+ * the input is just "p".
*/
if (strcmp(completion_squery->catname,
"pg_catalog.pg_class c") == 0 &&
- strncmp(text, "pg_", 3) != 0)
+ strncmp(text, "pg_", 3) !=0)
{
appendPQExpBuffer(&query_buffer,
- " AND c.relnamespace <> (SELECT oid FROM"
- " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')");
+ " AND c.relnamespace <> (SELECT oid FROM"
+ " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')");
}
/*
- * Add in matching schema names, but only if there is more than
- * one potential match among schema names.
+ * Add in matching schema names, but only if there is more
+ * than one potential match among schema names.
*/
appendPQExpBuffer(&query_buffer, "\nUNION\n"
- "SELECT pg_catalog.quote_ident(n.nspname) || '.' "
+ "SELECT pg_catalog.quote_ident(n.nspname) || '.' "
"FROM pg_catalog.pg_namespace n "
"WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'",
string_length, e_text);
@@ -1703,11 +1716,11 @@ _complete_from_query(int is_schema_query, const char *text, int state)
string_length, e_text);
/*
- * Add in matching qualified names, but only if there is exactly
- * one schema matching the input-so-far.
+ * Add in matching qualified names, but only if there is
+ * exactly one schema matching the input-so-far.
*/
appendPQExpBuffer(&query_buffer, "\nUNION\n"
- "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s "
+ "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s "
"FROM %s, pg_catalog.pg_namespace n "
"WHERE %s = n.oid AND ",
qualresult,
@@ -1719,7 +1732,11 @@ _complete_from_query(int is_schema_query, const char *text, int state)
appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) || '.' || %s,1,%d)='%s'",
qualresult,
string_length, e_text);
- /* This condition exploits the single-matching-schema rule to speed up the query */
+
+ /*
+ * This condition exploits the single-matching-schema rule to
+ * speed up the query
+ */
appendPQExpBuffer(&query_buffer,
" AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d) ="
" substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1)",
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c
index adbb4b4248f..857b56bb723 100644
--- a/src/bin/scripts/clusterdb.c
+++ b/src/bin/scripts/clusterdb.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 2002-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.10 2004/08/29 04:13:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.11 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,13 +14,11 @@
#include "dumputils.h"
-static void
-cluster_one_database(const char *dbname, const char *table,
+static void cluster_one_database(const char *dbname, const char *table,
const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet);
-static void
-cluster_all_databases(const char *host, const char *port,
+static void cluster_all_databases(const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet);
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 42d9496ad4f..7fe8b406018 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.10 2004/08/29 04:13:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.11 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,7 +35,7 @@ get_user_name(const char *progname)
return pw->pw_name;
#else
static char username[128]; /* remains after function exit */
- DWORD len = sizeof(username)-1;
+ DWORD len = sizeof(username) - 1;
if (!GetUserName(username, &len))
{
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c
index 1c92fec9b67..e8d741584a1 100644
--- a/src/bin/scripts/createlang.c
+++ b/src/bin/scripts/createlang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.13 2004/08/29 04:13:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.14 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -249,7 +249,7 @@ main(int argc, char *argv[])
PQclear(result);
}
else
- validatorexists = true; /* don't try to create it */
+ validatorexists = true; /* don't try to create it */
/*
* Create the function(s) and the language
diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c
index 04da9e69d17..42b72e73a00 100644
--- a/src/bin/scripts/droplang.c
+++ b/src/bin/scripts/droplang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.12 2004/08/29 04:13:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.13 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -165,8 +165,8 @@ main(int argc, char *argv[])
conn = connectDatabase(dbname, host, port, username, password, progname);
/*
- * Make sure the language is installed and find the OIDs of the handler
- * and validator functions
+ * Make sure the language is installed and find the OIDs of the
+ * handler and validator functions
*/
printfPQExpBuffer(&sql, "SELECT lanplcallfoid, lanvalidator FROM pg_language WHERE lanname = '%s' AND lanispl;", langname);
result = executeQuery(conn, sql.data, progname, echo);
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 308206953d1..20198863603 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.10 2004/08/29 04:13:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.11 2004/08/29 05:06:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,14 +14,12 @@
#include "common.h"
-static void
-vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
+static void vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
const char *table,
const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet);
-static void
-vacuum_all_databases(bool full, bool verbose, bool analyze,
+static void vacuum_all_databases(bool full, bool verbose, bool analyze,
const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet);