summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
commit1dc34982511d91ef8a2b71bdcb870f067c1b3da9 (patch)
tree1046adab1d4b964e0c38afeec0ee6546f61d9a8a /src/bin
parent790c01d28099587bbe2c623d4389b62ee49b1dee (diff)
downloadpostgresql-1dc34982511d91ef8a2b71bdcb870f067c1b3da9.tar.gz
Standard pgindent run for 8.1.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/initdb/initdb.c246
-rw-r--r--src/bin/pg_config/pg_config.c81
-rw-r--r--src/bin/pg_controldata/pg_controldata.c14
-rw-r--r--src/bin/pg_ctl/pg_ctl.c70
-rw-r--r--src/bin/pg_dump/common.c25
-rw-r--r--src/bin/pg_dump/dumputils.c63
-rw-r--r--src/bin/pg_dump/pg_backup.h19
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c182
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h38
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c37
-rw-r--r--src/bin/pg_dump/pg_backup_db.c81
-rw-r--r--src/bin/pg_dump/pg_backup_files.c4
-rw-r--r--src/bin/pg_dump/pg_backup_null.c5
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c76
-rw-r--r--src/bin/pg_dump/pg_dump.c678
-rw-r--r--src/bin/pg_dump/pg_dump.h13
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c113
-rw-r--r--src/bin/pg_dump/pg_dumpall.c76
-rw-r--r--src/bin/pg_dump/pg_restore.c12
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c59
-rw-r--r--src/bin/pgevent/pgevent.c10
-rw-r--r--src/bin/psql/command.c85
-rw-r--r--src/bin/psql/common.c134
-rw-r--r--src/bin/psql/common.h4
-rw-r--r--src/bin/psql/copy.c19
-rw-r--r--src/bin/psql/describe.c229
-rw-r--r--src/bin/psql/help.c136
-rw-r--r--src/bin/psql/input.c8
-rw-r--r--src/bin/psql/large_obj.c8
-rw-r--r--src/bin/psql/mainloop.c40
-rw-r--r--src/bin/psql/mbprint.c22
-rw-r--r--src/bin/psql/print.c224
-rw-r--r--src/bin/psql/print.h29
-rw-r--r--src/bin/psql/prompt.c9
-rw-r--r--src/bin/psql/settings.h11
-rw-r--r--src/bin/psql/startup.c49
-rw-r--r--src/bin/psql/stringutils.c35
-rw-r--r--src/bin/psql/tab-complete.c2869
-rw-r--r--src/bin/psql/variables.c6
-rw-r--r--src/bin/scripts/common.c8
-rw-r--r--src/bin/scripts/common.h18
-rw-r--r--src/bin/scripts/createlang.c12
-rw-r--r--src/bin/scripts/createuser.c6
-rw-r--r--src/bin/scripts/droplang.c34
-rw-r--r--src/bin/scripts/reindexdb.c96
45 files changed, 3873 insertions, 2120 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index f0d97f13f9..d79e4985a7 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -18,7 +18,7 @@
* to produce a new database.
*
* For largely-historical reasons, the template1 database is the one built
- * by the basic bootstrap process. After it is complete, template0 and
+ * by the basic bootstrap process. After it is complete, template0 and
* the default database, postgres, are made just by copying template1.
*
* To create template1, we run the postgres (backend) program in bootstrap
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.98 2005/08/28 22:21:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.99 2005/10/15 02:49:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,50 +74,50 @@ int optreset;
/*
* these values are passed in by makefile defines
*/
-static char *share_path = NULL;
+static char *share_path = NULL;
/* values to be obtained from arguments */
-static char *pg_data = "";
-static char *encoding = "";
-static char *locale = "";
-static char *lc_collate = "";
-static char *lc_ctype = "";
-static char *lc_monetary = "";
-static char *lc_numeric = "";
-static char *lc_time = "";
-static char *lc_messages = "";
-static char *username = "";
-static bool pwprompt = false;
-static char *pwfilename = NULL;
-static char *authmethod = "";
-static bool debug = false;
-static bool noclean = false;
-static bool show_setting = false;
+static char *pg_data = "";
+static char *encoding = "";
+static char *locale = "";
+static char *lc_collate = "";
+static char *lc_ctype = "";
+static char *lc_monetary = "";
+static char *lc_numeric = "";
+static char *lc_time = "";
+static char *lc_messages = "";
+static char *username = "";
+static bool pwprompt = false;
+static char *pwfilename = NULL;
+static char *authmethod = "";
+static bool debug = false;
+static bool noclean = false;
+static bool show_setting = false;
/* internal vars */
static const char *progname;
-static char *encodingid = "0";
-static char *bki_file;
-static char *desc_file;
-static char *hba_file;
-static char *ident_file;
-static char *conf_file;
-static char *conversion_file;
-static char *info_schema_file;
-static char *features_file;
-static char *system_views_file;
-static char *effective_user;
-static bool made_new_pgdata = false;
-static bool found_existing_pgdata = false;
-static char infoversion[100];
-static bool caught_signal = false;
-static bool output_failed = false;
-static int output_errno = 0;
+static char *encodingid = "0";
+static char *bki_file;
+static char *desc_file;
+static char *hba_file;
+static char *ident_file;
+static char *conf_file;
+static char *conversion_file;
+static char *info_schema_file;
+static char *features_file;
+static char *system_views_file;
+static char *effective_user;
+static bool made_new_pgdata = false;
+static bool found_existing_pgdata = false;
+static char infoversion[100];
+static bool caught_signal = false;
+static bool output_failed = false;
+static int output_errno = 0;
/* defaults */
-static int n_connections = 10;
-static int n_buffers = 50;
+static int n_connections = 10;
+static int n_buffers = 50;
/*
* Warning messages for authentication methods
@@ -127,7 +127,7 @@ static int n_buffers = 50;
"# 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" \
"# authentication method.\n"
-static char *authwarning = NULL;
+static char *authwarning = NULL;
/*
* Centralized knowledge of switches to pass to backend
@@ -141,13 +141,14 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on
/* path to 'initdb' binary directory */
-static char bin_path[MAXPGPATH];
-static char backend_exec[MAXPGPATH];
+static char bin_path[MAXPGPATH];
+static char backend_exec[MAXPGPATH];
static void *pg_malloc(size_t size);
static char *xstrdup(const char *s);
static char **replace_token(char **lines,
- const char *token, const char *replacement);
+ const char *token, const char *replacement);
+
#ifndef HAVE_UNIX_SOCKETS
static char **filter_lines_with_token(char **lines, const char *token);
#endif
@@ -335,7 +336,9 @@ static char **
filter_lines_with_token(char **lines, const char *token)
{
int numlines = 1;
- int i, src, dst;
+ int i,
+ src,
+ dst;
char **result;
for (i = 0; lines[i]; i++)
@@ -458,7 +461,7 @@ writefile(char *path, char **lines)
static FILE *
popen_check(const char *command, const char *mode)
{
- FILE *cmdfd;
+ FILE *cmdfd;
fflush(stdout);
fflush(stderr);
@@ -531,14 +534,13 @@ mkdir_p(char *path, mode_t omode)
{
/*
* POSIX 1003.2: For each dir operand that does not name an
- * existing directory, effects equivalent to those caused by
- * the following command shall occcur:
+ * existing directory, effects equivalent to those caused by the
+ * following command shall occcur:
*
- * mkdir -p -m $(umask -S),u+wx $(dirname dir) && mkdir [-m mode]
- * dir
+ * mkdir -p -m $(umask -S),u+wx $(dirname dir) && mkdir [-m mode] dir
*
- * We change the user's umask and then restore it, instead of
- * doing chmod's.
+ * We change the user's umask and then restore it, instead of doing
+ * chmod's.
*/
oumask = umask(0);
numask = oumask & ~(S_IWUSR | S_IXUSR);
@@ -606,7 +608,7 @@ exit_nicely(void)
{
if (made_new_pgdata || found_existing_pgdata)
fprintf(stderr,
- _("%s: data directory \"%s\" not removed at user's request\n"),
+ _("%s: data directory \"%s\" not removed at user's request\n"),
progname, pg_data);
}
@@ -640,7 +642,6 @@ get_id(void)
exit(1);
}
#endif
-
#else /* the windows code */
struct passwd_win32
@@ -829,7 +830,7 @@ check_encodings_match(int pg_enc, const char *ctype)
for (i = 0; encoding_match_list[i].system_enc_name; i++)
{
if (pg_enc == encoding_match_list[i].pg_enc_code
- && pg_strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0)
+ && pg_strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0)
{
free(sys);
return;
@@ -839,11 +840,11 @@ check_encodings_match(int pg_enc, const char *ctype)
fprintf(stderr,
_("%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"
- "misbehavior in various character string processing functions. To fix\n"
- "this situation, rerun %s and either do not specify an encoding\n"
- "explicitly, or choose a matching combination.\n"),
+ _("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"
+ "misbehavior in various character string processing functions. To fix\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);
free(sys);
@@ -944,9 +945,10 @@ check_data_dir(void)
}
#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;
@@ -969,7 +971,7 @@ mkdatadir(const char *subdir)
char *path;
path = pg_malloc(strlen(pg_data) + 2 +
- (subdir == NULL ? 0 : strlen(subdir)));
+ (subdir == NULL ? 0 : strlen(subdir)));
if (subdir != NULL)
sprintf(path, "%s/%s", pg_data, subdir);
@@ -1008,7 +1010,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);
@@ -1205,28 +1207,30 @@ setup_config(void)
conflines = readfile(hba_file);
#ifndef HAVE_UNIX_SOCKETS
- conflines = filter_lines_with_token(conflines,"@remove-line-for-nolocal@");
+ conflines = filter_lines_with_token(conflines, "@remove-line-for-nolocal@");
#else
- conflines = replace_token(conflines,"@remove-line-for-nolocal@","");
+ conflines = replace_token(conflines, "@remove-line-for-nolocal@", "");
#endif
#ifdef HAVE_IPV6
- /*
+
+ /*
* Probe to see if there is really any platform support for IPv6, and
* comment out the relevant pg_hba line if not. This avoids runtime
* warnings if getaddrinfo doesn't actually cope with IPv6. Particularly
- * useful on Windows, where executables built on a machine with IPv6
- * may have to run on a machine without.
+ * useful on Windows, where executables built on a machine with IPv6 may
+ * have to run on a machine without.
*/
{
struct addrinfo *gai_result;
struct addrinfo hints;
- int err = 0;
+ int err = 0;
+
#ifdef WIN32
/* need to call WSAStartup before calling getaddrinfo */
- WSADATA wsaData;
+ WSADATA wsaData;
- err = WSAStartup(MAKEWORD(2,2), &wsaData);
+ err = WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif
/* for best results, this code should match parse_hba() */
@@ -1245,12 +1249,12 @@ setup_config(void)
"host all all ::1",
"#host all all ::1");
}
-#else /* !HAVE_IPV6 */
+#else /* !HAVE_IPV6 */
/* If we didn't compile IPV6 support at all, always comment it out */
conflines = replace_token(conflines,
"host all all ::1",
"#host all all ::1");
-#endif /* HAVE_IPV6 */
+#endif /* HAVE_IPV6 */
/* Replace default authentication methods */
conflines = replace_token(conflines,
@@ -1259,7 +1263,7 @@ setup_config(void)
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);
@@ -1311,9 +1315,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();
}
@@ -1325,8 +1329,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));
@@ -1368,8 +1372,8 @@ setup_auth(void)
char **line;
static char *pg_authid_setup[] = {
/*
- * Create triggers to ensure manual updates to shared catalogs
- * will be reflected into their "flat file" copies.
+ * Create triggers to ensure manual updates to shared catalogs will be
+ * reflected into their "flat file" copies.
*/
"CREATE TRIGGER pg_sync_pg_database "
" AFTER INSERT OR UPDATE OR DELETE ON pg_database "
@@ -1382,8 +1386,8 @@ setup_auth(void)
" FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger();\n",
/*
- * The authid table shouldn't be readable except through views,
- * to ensure passwords are not publicly visible.
+ * The authid table shouldn't be readable except through views, to
+ * ensure passwords are not publicly visible.
*/
"REVOKE ALL on pg_authid FROM public;\n",
NULL
@@ -1440,9 +1444,9 @@ 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];
@@ -1545,14 +1549,14 @@ setup_depend(void)
char **line;
static char *pg_depend_setup[] = {
/*
- * Make PIN entries in pg_depend for all objects made so far in
- * the tables that the dependency code handles. This is overkill
- * (the system doesn't really depend on having every last weird
- * datatype, for instance) but generating only the minimum
- * required set of dependencies seems hard.
+ * Make PIN entries in pg_depend for all objects made so far in the
+ * tables that the dependency code handles. This is overkill (the
+ * system doesn't really depend on having every last weird datatype,
+ * for instance) but generating only the minimum required set of
+ * dependencies seems hard.
*
- * Note that we deliberately do not pin the system views, which
- * haven't been created yet.
+ * Note that we deliberately do not pin the system views, which haven't
+ * been created yet.
*
* First delete any already-made entries; PINs override all else, and
* must be the only entries for their objects.
@@ -1728,7 +1732,7 @@ setup_conversion(void)
/*
* Set up privileges
*
- * We mark most system catalogs as world-readable. We don't currently have
+ * We mark most system catalogs as world-readable. We don't currently have
* to touch functions, languages, or databases, because their default
* permissions are OK.
*
@@ -1815,8 +1819,7 @@ 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",
@@ -1907,8 +1910,8 @@ make_template0(void)
/*
* Explicitly revoke public create-schema and create-temp-table
- * privileges in template1 and template0; else the latter would be
- * on by default
+ * privileges in template1 and template0; else the latter would be on
+ * by default
*/
"REVOKE CREATE,TEMPORARY ON DATABASE template1 FROM public;\n",
"REVOKE CREATE,TEMPORARY ON DATABASE template0 FROM public;\n",
@@ -2034,9 +2037,10 @@ static char *
escape_quotes(const char *src)
{
int len = strlen(src),
- i, j;
- char *result = pg_malloc(len * 2 + 1);
-
+ i,
+ j;
+ char *result = pg_malloc(len * 2 + 1);
+
for (i = 0, j = 0; i < len; i++)
{
if (SQL_STR_DOUBLE(src[i]))
@@ -2102,8 +2106,7 @@ setlocales(void)
}
/*
- * override absent/invalid config settings from initdb's locale
- * settings
+ * override absent/invalid config settings from initdb's locale settings
*/
if (strlen(lc_ctype) == 0 || !chklocale(lc_ctype))
@@ -2204,7 +2207,7 @@ main(int argc, char *argv[])
char *pgdenv; /* PGDATA value gotten from and sent to
* environment */
char bin_dir[MAXPGPATH];
- char *pg_data_native;
+ char *pg_data_native;
static const char *subdirs[] = {
"global",
"pg_xlog",
@@ -2337,8 +2340,7 @@ main(int argc, char *argv[])
if (strcmp(authmethod, "md5") &&
strcmp(authmethod, "ident") &&
- strncmp(authmethod, "ident ", 6) && /* ident with space =
- * param */
+ strncmp(authmethod, "ident ", 6) && /* ident with space = param */
strcmp(authmethod, "trust") &&
#ifdef USE_PAM
strcmp(authmethod, "pam") &&
@@ -2391,10 +2393,10 @@ main(int argc, char *argv[])
canonicalize_path(pg_data);
/*
- * 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.
+ * 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.
*/
pgdenv = pg_malloc(8 + strlen(pg_data));
sprintf(pgdenv, "PGDATA=%s", pg_data);
@@ -2403,7 +2405,7 @@ main(int argc, char *argv[])
if ((ret = find_other_exec(argv[0], "postgres", PG_VERSIONSTR,
backend_exec)) < 0)
{
- char full_path[MAXPGPATH];
+ char full_path[MAXPGPATH];
if (find_my_exec(argv[0], full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH);
@@ -2557,8 +2559,7 @@ main(int argc, char *argv[])
umask(077);
/*
- * now we are starting to do real work, trap signals so we can clean
- * up
+ * now we are starting to do real work, trap signals so we can clean up
*/
/* some of these are not valid on Windows */
@@ -2650,9 +2651,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();
@@ -2667,8 +2668,7 @@ main(int argc, char *argv[])
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");
@@ -2697,22 +2697,22 @@ main(int argc, char *argv[])
make_template0();
make_postgres();
-
+
if (authwarning != NULL)
fprintf(stderr, "%s", authwarning);
/* Get directory specification used to start this executable */
strcpy(bin_dir, argv[0]);
get_parent_directory(bin_dir);
-
+
printf(_("\nSuccess. You can now start the database server using:\n\n"
" %s%s%spostmaster%s -D %s%s%s\n"
"or\n"
" %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"),
- QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
- QUOTE_PATH, pg_data_native, QUOTE_PATH,
- QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
- QUOTE_PATH, pg_data_native, QUOTE_PATH);
+ QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
+ QUOTE_PATH, pg_data_native, QUOTE_PATH,
+ QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
+ QUOTE_PATH, pg_data_native, QUOTE_PATH);
return 0;
}
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
index b5ea5265a9..9943ddf6f8 100644
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -17,7 +17,7 @@
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.16 2005/10/13 17:58:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.17 2005/10/15 02:49:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,7 @@
#include "port.h"
static const char *progname;
-static char mypath[MAXPGPATH];
+static char mypath[MAXPGPATH];
/*
@@ -37,7 +37,7 @@ static char mypath[MAXPGPATH];
* C:/Progra~1/
*
* This can fail in 2 ways - if the path doesn't exist, or short names are
- * disabled. In the first case, don't return any path. In the second case,
+ * disabled. In the first case, don't return any path. In the second case,
* we leave the path in the long form. In this case, it does still seem to
* fix elements containing spaces which is all we actually need.
*/
@@ -49,8 +49,9 @@ cleanup_path(char *path)
if (GetShortPathName(path, path, MAXPGPATH - 1) == 0)
{
- /* Ignore ERROR_INVALID_PARAMETER as it almost certainly
- * means that short names are disabled
+ /*
+ * Ignore ERROR_INVALID_PARAMETER as it almost certainly means that
+ * short names are disabled
*/
if (GetLastError() != ERROR_INVALID_PARAMETER)
{
@@ -78,8 +79,8 @@ cleanup_path(char *path)
static void
show_bindir(bool all)
{
- char path[MAXPGPATH];
- char *lastsep;
+ char path[MAXPGPATH];
+ char *lastsep;
if (all)
printf("BINDIR = ");
@@ -97,7 +98,7 @@ show_bindir(bool all)
static void
show_docdir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("DOCDIR = ");
@@ -109,7 +110,7 @@ show_docdir(bool all)
static void
show_includedir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("INCLUDEDIR = ");
@@ -121,7 +122,7 @@ show_includedir(bool all)
static void
show_pkgincludedir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("PKGINCLUDEDIR = ");
@@ -133,7 +134,7 @@ show_pkgincludedir(bool all)
static void
show_includedir_server(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("INCLUDEDIR-SERVER = ");
@@ -145,7 +146,7 @@ show_includedir_server(bool all)
static void
show_libdir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("LIBDIR = ");
@@ -157,7 +158,7 @@ show_libdir(bool all)
static void
show_pkglibdir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("PKGLIBDIR = ");
@@ -169,7 +170,7 @@ show_pkglibdir(bool all)
static void
show_localedir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("LOCALEDIR = ");
@@ -181,7 +182,7 @@ show_localedir(bool all)
static void
show_mandir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("MANDIR = ");
@@ -193,7 +194,7 @@ show_mandir(bool all)
static void
show_sharedir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("SHAREDIR = ");
@@ -205,7 +206,7 @@ show_sharedir(bool all)
static void
show_sysconfdir(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("SYSCONFDIR = ");
@@ -217,7 +218,7 @@ show_sysconfdir(bool all)
static void
show_pgxs(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
if (all)
printf("PGXS = ");
@@ -376,28 +377,28 @@ typedef struct
} InfoItem;
static const InfoItem info_items[] = {
- { "--bindir", show_bindir },
- { "--docdir", show_docdir },
- { "--includedir", show_includedir },
- { "--pkgincludedir", show_pkgincludedir },
- { "--includedir-server", show_includedir_server },
- { "--libdir", show_libdir },
- { "--pkglibdir", show_pkglibdir },
- { "--localedir", show_localedir },
- { "--mandir", show_mandir },
- { "--sharedir", show_sharedir },
- { "--sysconfdir", show_sysconfdir },
- { "--pgxs", show_pgxs },
- { "--configure", show_configure },
- { "--cc", show_cc },
- { "--cppflags", show_cppflags },
- { "--cflags", show_cflags },
- { "--cflags_sl", show_cflags_sl },
- { "--ldflags", show_ldflags },
- { "--ldflags_sl", show_ldflags_sl },
- { "--libs", show_libs },
- { "--version", show_version },
- { NULL, NULL }
+ {"--bindir", show_bindir},
+ {"--docdir", show_docdir},
+ {"--includedir", show_includedir},
+ {"--pkgincludedir", show_pkgincludedir},
+ {"--includedir-server", show_includedir_server},
+ {"--libdir", show_libdir},
+ {"--pkglibdir", show_pkglibdir},
+ {"--localedir", show_localedir},
+ {"--mandir", show_mandir},
+ {"--sharedir", show_sharedir},
+ {"--sysconfdir", show_sysconfdir},
+ {"--pgxs", show_pgxs},
+ {"--configure", show_configure},
+ {"--cc", show_cc},
+ {"--cppflags", show_cppflags},
+ {"--cflags", show_cflags},
+ {"--cflags_sl", show_cflags_sl},
+ {"--ldflags", show_ldflags},
+ {"--ldflags_sl", show_ldflags_sl},
+ {"--libs", show_libs},
+ {"--version", show_version},
+ {NULL, NULL}
};
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c5573ee59e..4e9a9afa0e 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.26 2005/10/03 00:28:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.27 2005/10/15 02:49:37 momjian Exp $
*/
#include "postgres.h"
@@ -129,11 +129,11 @@ main(int argc, char *argv[])
if (!EQ_CRC32(crc, ControlFile.crc))
printf(_("WARNING: Calculated CRC checksum does not match value stored in file.\n"
"Either the file is corrupt, or it has a different layout than this program\n"
- "is expecting. The results below are untrustworthy.\n\n"));
+ "is expecting. The results below are untrustworthy.\n\n"));
/*
- * Use variable for format to suppress overly-anal-retentive gcc
- * warning about %c
+ * Use variable for format to suppress overly-anal-retentive gcc warning
+ * about %c
*/
strftime(pgctime_str, sizeof(pgctime_str), strftime_fmt,
localtime(&(ControlFile.time)));
@@ -141,8 +141,8 @@ main(int argc, char *argv[])
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);
@@ -157,7 +157,7 @@ main(int argc, char *argv[])
printf(_("Latest checkpoint location: %X/%X\n"),
ControlFile.checkPoint.xlogid, ControlFile.checkPoint.xrecoff);
printf(_("Prior checkpoint location: %X/%X\n"),
- ControlFile.prevCheckPoint.xlogid, ControlFile.prevCheckPoint.xrecoff);
+ ControlFile.prevCheckPoint.xlogid, ControlFile.prevCheckPoint.xrecoff);
printf(_("Latest checkpoint's REDO location: %X/%X\n"),
ControlFile.checkPointCopy.redo.xlogid, ControlFile.checkPointCopy.redo.xrecoff);
printf(_("Latest checkpoint's UNDO location: %X/%X\n"),
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index fe03b818e2..7c12a72c6d 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-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.60 2005/07/25 04:52:32 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.61 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -326,22 +326,21 @@ 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 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:
+ * 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 /* Cygwin doesn't have START */
+#ifndef WIN32 /* Cygwin doesn't have START */
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
DEVNULL, log_file, SYSTEMQUOTE);
@@ -351,7 +350,7 @@ start_postmaster(void)
DEVNULL, log_file, SYSTEMQUOTE);
#endif
else
-#ifndef WIN32 /* Cygwin doesn't have START */
+#ifndef WIN32 /* Cygwin doesn't have START */
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
DEVNULL, SYSTEMQUOTE);
@@ -544,11 +543,11 @@ do_start(void)
if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR,
postmaster_path)) < 0)
{
- char full_path[MAXPGPATH];
-
+ char full_path[MAXPGPATH];
+
if (find_my_exec(argv0, full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH);
-
+
if (ret == -1)
write_stderr(_("The program \"postmaster\" is needed by %s "
"but was not found in the\n"
@@ -715,20 +714,20 @@ do_restart(void)
print_msg(_("waiting for postmaster to shut down..."));
- /* always wait for restart */
+ /* always wait for restart */
for (cnt = 0; cnt < wait_seconds; cnt++)
{
if ((pid = get_pgpid()) != 0)
{
print_msg(".");
- 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 */
{
print_msg(_(" failed\n"));
@@ -792,12 +791,12 @@ postmaster_is_alive(pid_t pid)
/*
* Test to see if the process is still there. Note that we do not
* consider an EPERM failure to mean that the process is still there;
- * EPERM must mean that the given PID belongs to some other userid,
- * and considering the permissions on $PGDATA, that means it's not
- * the postmaster we are after.
+ * EPERM must mean that the given PID belongs to some other userid, and
+ * considering the permissions on $PGDATA, that means it's not the
+ * postmaster we are after.
*
* Don't believe that our own PID or parent shell's PID is the postmaster,
- * either. (Windows hasn't got getppid(), though.)
+ * either. (Windows hasn't got getppid(), though.)
*/
if (pid == getpid())
return false;
@@ -828,7 +827,8 @@ do_status(void)
return;
}
}
- else /* postmaster */
+ else
+ /* postmaster */
{
if (postmaster_is_alive((pid_t) pid))
{
@@ -880,6 +880,7 @@ pgwin32_CommandLine(bool registration)
{
static char cmdLine[MAXPGPATH];
int ret;
+
#ifdef __CYGWIN__
char buf[MAXPGPATH];
#endif
@@ -963,10 +964,10 @@ pgwin32_doRegister(void)
}
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(_("%s: could not register service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError());
@@ -1036,9 +1037,9 @@ pgwin32_ServiceHandler(DWORD request)
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;
pgwin32_SetServiceStatus(SERVICE_STOP_PENDING);
@@ -1294,9 +1295,8 @@ main(int argc, char **argv)
set_pglocale_pgservice(argv[0], "pg_ctl");
/*
- * save argv[0] so do_start() can look for the postmaster if
- * necessary. we don't look for postmaster here because in many cases
- * we won't need it.
+ * save argv[0] so do_start() can look for the postmaster if necessary. we
+ * don't look for postmaster here because in many cases we won't need it.
*/
argv0 = argv[0];
@@ -1337,9 +1337,9 @@ 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.
+ * 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;
@@ -1362,9 +1362,9 @@ main(int argc, char **argv)
putenv(env_var);
/*
- * We could pass PGDATA just in an environment
- * variable but we do -D too for clearer
- * postmaster 'ps' display
+ * We could pass PGDATA just in an environment
+ * variable but we do -D too for clearer postmaster
+ * 'ps' display
*/
pgdata_opt = pg_malloc(strlen(pgdata_D) + 7);
snprintf(pgdata_opt, strlen(pgdata_D) + 7,
@@ -1397,7 +1397,7 @@ main(int argc, char **argv)
if (strchr(optarg, '\\'))
register_username = xstrdup(optarg);
else
- /* Prepend .\ for local accounts */
+ /* Prepend .\ for local accounts */
{
register_username = malloc(strlen(optarg) + 3);
if (!register_username)
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 56f7665f5f..08497f3562 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.86 2005/06/27 02:17:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.87 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -292,8 +292,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
{
foundAttr = true;
foundNotNull |= parent->notnull[inhAttrInd];
- if (attrDef != NULL) /* If we have a default,
- * check parent */
+ if (attrDef != NULL) /* If we have a default, check
+ * parent */
{
AttrDefInfo *inhDef;
@@ -302,15 +302,15 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
{
defaultsFound = true;
defaultsMatch &= (strcmp(attrDef->adef_expr,
- inhDef->adef_expr) == 0);
+ inhDef->adef_expr) == 0);
}
}
}
}
/*
- * Based on the scan of the parents, decide if we can rely on
- * the inherited attr
+ * Based on the scan of the parents, decide if we can rely on the
+ * inherited attr
*/
if (foundAttr) /* Attr was inherited */
{
@@ -330,8 +330,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
}
/*
- * Clear it if NOT NULL and none of the parents were NOT
- * NULL
+ * Clear it if NOT NULL and none of the parents were NOT NULL
*/
if (tbinfo->notnull[j] && !foundNotNull)
{
@@ -346,9 +345,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
}
/*
- * Check for inherited CHECK constraints. We assume a constraint
- * is inherited if its name matches the name of any constraint in
- * the parent. Originally this code tried to compare the expression
+ * Check for inherited CHECK constraints. We assume a constraint is
+ * inherited if its name matches the name of any constraint in the
+ * parent. Originally this code tried to compare the expression
* texts, but that can fail if the parent and child tables are in
* different schemas, because reverse-listing of function calls may
* produce different text (schema-qualified or not) depending on
@@ -528,8 +527,8 @@ DOCatalogIdCompare(const void *p1, const void *p2)
int cmpval;
/*
- * Compare OID first since it's usually unique, whereas there will
- * only be a few distinct values of tableoid.
+ * Compare OID first since it's usually unique, whereas there will only be
+ * a few distinct values of tableoid.
*/
cmpval = oidcmp(obj1->catId.oid, obj2->catId.oid);
if (cmpval == 0)
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 267a8573ac..aa999173b2 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.19 2005/07/02 17:01:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.20 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,8 +49,8 @@ fmtId(const char *rawid)
id_return = createPQExpBuffer();
/*
- * These checks need to match the identifier production in scan.l.
- * Don't use islower() etc.
+ * These checks need to match the identifier production in scan.l. Don't
+ * use islower() etc.
*/
if (ScanKeywordLookup(rawid))
@@ -111,14 +111,14 @@ fmtId(const char *rawid)
void
appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
{
- char ch;
+ char ch;
const char *p;
for (p = str; *p; p++)
{
ch = *p;
if (ch == '\\' ||
- ((unsigned char)ch < (unsigned char)' ' &&
+ ((unsigned char) ch < (unsigned char) ' ' &&
(escapeAll ||
(ch != '\t' && ch != '\n' && ch != '\v' &&
ch != '\f' && ch != '\r'))))
@@ -127,7 +127,7 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
break;
}
}
-
+
appendPQExpBufferChar(buf, '\'');
for (p = str; *p; p++)
{
@@ -137,14 +137,13 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
appendPQExpBufferChar(buf, ch);
appendPQExpBufferChar(buf, ch);
}
- else if ((unsigned char)ch < (unsigned char)' ' &&
+ else if ((unsigned char) ch < (unsigned char) ' ' &&
(escapeAll ||
(ch != '\t' && ch != '\n' && ch != '\v' &&
ch != '\f' && ch != '\r')))
{
/*
- * generate octal escape for control chars other than
- * whitespace
+ * generate octal escape for control chars other than whitespace
*/
appendPQExpBufferChar(buf, '\\');
appendPQExpBufferChar(buf, ((ch >> 6) & 3) + '0');
@@ -179,10 +178,9 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
appendPQExpBufferStr(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
- * trailing $ because a string ending in $foo must not be quoted with
- * $foo$.
+ * 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)
{
@@ -260,15 +258,13 @@ parsePGArray(const char *atext, char ***itemarray, int *nitems)
/*
* We expect input in the form of "{item,item,item}" where any item is
- * either raw data, or surrounded by double quotes (in which case
- * embedded characters including backslashes and quotes are
- * backslashed).
+ * either raw data, or surrounded by double quotes (in which case embedded
+ * characters including backslashes and quotes are backslashed).
*
- * We build the result as an array of pointers followed by the actual
- * string data, all in one malloc block for convenience of
- * deallocation. The worst-case storage need is not more than one
- * pointer and one character for each input character (consider
- * "{,,,,,,,,,,}").
+ * We build the result as an array of pointers followed by the actual string
+ * data, all in one malloc block for convenience of deallocation. The
+ * worst-case storage need is not more than one pointer and one character
+ * for each input character (consider "{,,,,,,,,,,}").
*/
*itemarray = NULL;
*nitems = 0;
@@ -374,12 +370,11 @@ buildACLCommands(const char *name, const char *type,
privswgo = createPQExpBuffer();
/*
- * At the end, these two will be pasted together to form the result.
- * But the owner privileges need to go before the other ones to keep
- * the dependencies valid. In recent versions this is normally the
- * case, but in old versions they come after the PUBLIC privileges and
- * that results in problems if we need to run REVOKE on the owner
- * privileges.
+ * At the end, these two will be pasted together to form the result. But
+ * the owner privileges need to go before the other ones to keep the
+ * dependencies valid. In recent versions this is normally the case, but
+ * in old versions they come after the PUBLIC privileges and that results
+ * in problems if we need to run REVOKE on the owner privileges.
*/
firstsql = createPQExpBuffer();
secondsql = createPQExpBuffer();
@@ -450,7 +445,7 @@ buildACLCommands(const char *name, const char *type,
else if (strncmp(grantee->data, "group ",
strlen("group ")) == 0)
appendPQExpBuffer(secondsql, "GROUP %s;\n",
- fmtId(grantee->data + strlen("group ")));
+ fmtId(grantee->data + strlen("group ")));
else
appendPQExpBuffer(secondsql, "%s;\n", fmtId(grantee->data));
}
@@ -463,7 +458,7 @@ buildACLCommands(const char *name, const char *type,
else if (strncmp(grantee->data, "group ",
strlen("group ")) == 0)
appendPQExpBuffer(secondsql, "GROUP %s",
- fmtId(grantee->data + strlen("group ")));
+ fmtId(grantee->data + strlen("group ")));
else
appendPQExpBuffer(secondsql, "%s", fmtId(grantee->data));
appendPQExpBuffer(secondsql, " WITH GRANT OPTION;\n");
@@ -477,8 +472,7 @@ buildACLCommands(const char *name, const char *type,
}
/*
- * If we didn't find any owner privs, the owner must have revoked 'em
- * all
+ * If we didn't find any owner privs, the owner must have revoked 'em all
*/
if (!found_owner_privs && owner)
{
@@ -638,8 +632,7 @@ 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++);
@@ -654,8 +647,8 @@ copyAclUserName(PQExpBuffer output, char *input)
return input; /* really a syntax error... */
/*
- * Quoting convention is to escape " as "". Keep this
- * code in sync with putid() in backend's acl.c.
+ * Quoting convention is to escape " as "". Keep this code in
+ * sync with putid() in backend's acl.c.
*/
if (*input == '"' && *(input + 1) == '"')
input++;
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 786d427160..41541b1c0b 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.36 2005/06/21 20:45:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.37 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,10 +54,10 @@ typedef enum _archiveFormat
typedef struct _Archive
{
int verbose;
- char *remoteVersionStr; /* server's version string */
- int remoteVersion; /* same in numeric form */
+ char *remoteVersionStr; /* server's version string */
+ int remoteVersion; /* same in numeric form */
- int minRemoteVersion; /* allowable range */
+ int minRemoteVersion; /* allowable range */
int maxRemoteVersion;
/* error handling */
@@ -72,10 +72,9 @@ 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 disable_triggers; /* disable triggers during
- * data-only restore */
+ 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 */
char *superuser; /* Username to use as superuser */
@@ -114,8 +113,8 @@ typedef struct _restoreOptions
bool limitToList;
int compression;
- int suppressDumpWarnings; /* Suppress output of WARNING
- * entries to stderr */
+ int suppressDumpWarnings; /* Suppress output of WARNING entries
+ * to stderr */
} RestoreOptions;
/*
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 1818cf6288..54eb976920 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.116 2005/09/28 13:11:26 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.117 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ static char *modulename = gettext_noop("archiver");
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode);
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
- ArchiveHandle *AH);
+ ArchiveHandle *AH);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
@@ -139,10 +139,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
* Check for nonsensical option combinations.
*
* NB: create+dropSchema is useless because if you're creating the DB,
- * there's no need to drop individual items in it. Moreover, if we
- * tried to do that then we'd issue the drops in the database
- * initially connected to, not the one we will create, which is very
- * bad...
+ * there's no need to drop individual items in it. Moreover, if we tried
+ * to do that then we'd issue the drops in the database initially
+ * connected to, not the one we will create, which is very bad...
*/
if (ropt->create && ropt->dropSchema)
die_horribly(AH, modulename, "-C and -c are incompatible options\n");
@@ -165,24 +164,24 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
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;
}
/*
- * Work out if we have an implied data-only restore. This can happen
- * if the dump was data only or if the user has used a toc list to
- * exclude all of the schema data. All we do is look for schema
- * entries - if none are found then we set the dataOnly flag.
+ * Work out if we have an implied data-only restore. This can happen if
+ * the dump was data only or if the user has used a toc list to exclude
+ * all of the schema data. All we do is look for schema entries - if none
+ * are found then we set the dataOnly flag.
*
* We could scan for wanted TABLE entries, but that is not the same as
* dataOnly. At this stage, it seems unnecessary (6-Mar-2001).
*/
if (!ropt->dataOnly)
{
- int impliedDataOnly = 1;
+ int impliedDataOnly = 1;
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
@@ -227,7 +226,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
{
AH->currentTE = te;
- reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */);
+ reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */ );
if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt)
{
/* We want the schema */
@@ -283,10 +282,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
if ((reqs & REQ_DATA) != 0)
{
/*
- * hadDumper will be set if there is genuine data component
- * for this node. Otherwise, we need to check the defn field
- * for statements that need to be executed in data-only
- * restores.
+ * hadDumper will be set if there is genuine data component for
+ * this node. Otherwise, we need to check the defn field for
+ * statements that need to be executed in data-only restores.
*/
if (te->hadDumper)
{
@@ -322,15 +320,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
te->tag);
/*
- * If we have a copy statement, use it. As of
- * V1.3, these are separate to allow easy import
- * from withing a database connection. Pre 1.3
- * archives can not use DB connections and are
- * sent to output only.
+ * If we have a copy statement, use it. As of V1.3,
+ * these are separate to allow easy import from
+ * withing a database connection. Pre 1.3 archives can
+ * not use DB connections and are sent to output only.
*
- * For V1.3+, the table data MUST have a copy
- * statement so that we can go into appropriate
- * mode with libpq.
+ * For V1.3+, the table data MUST have a copy statement
+ * so that we can go into appropriate mode with libpq.
*/
if (te->copyStmt && strlen(te->copyStmt) > 0)
ahprintf(AH, "%s", te->copyStmt);
@@ -485,7 +481,7 @@ ArchiveEntry(Archive *AHX,
CatalogId catalogId, DumpId dumpId,
const char *tag,
const char *namespace,
- const char *tablespace,
+ const char *tablespace,
const char *owner, bool withOids,
const char *desc, const char *defn,
const char *dropStmt, const char *copyStmt,
@@ -808,9 +804,9 @@ archprintf(Archive *AH, const char *fmt,...)
int cnt = -1;
/*
- * 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
+ * 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
*/
while (cnt < 0 || cnt >= (bSize - 1))
{
@@ -918,13 +914,13 @@ ahprintf(ArchiveHandle *AH, const char *fmt,...)
int cnt = -1;
/*
- * This is paranoid: deal with the possibility that vsnprintf is
- * willing to ignore trailing null
+ * 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
+ * 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))
{
@@ -980,13 +976,13 @@ dump_lo_buf(ArchiveHandle *AH)
(unsigned long) AH->lo_buf_used, (unsigned long) res);
if (res != AH->lo_buf_used)
die_horribly(AH, modulename,
- "could not write to large object (result: %lu, expected: %lu)\n",
- (unsigned long) res, (unsigned long) AH->lo_buf_used);
+ "could not write to large object (result: %lu, expected: %lu)\n",
+ (unsigned long) res, (unsigned long) AH->lo_buf_used);
}
else
{
unsigned char *str;
- size_t len;
+ size_t len;
str = PQescapeBytea((const unsigned char *) AH->lo_buf,
AH->lo_buf_used, &len);
@@ -1017,7 +1013,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
if (AH->writingBlob)
{
- size_t remaining = size * nmemb;
+ size_t remaining = size * nmemb;
while (AH->lo_buf_used + remaining > AH->lo_buf_size)
{
@@ -1162,8 +1158,8 @@ warn_or_die_horribly(ArchiveHandle *AH,
{
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;
@@ -1277,11 +1273,11 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
}
/*
- * Read the flag indicating the state of the data pointer. Check if
- * valid and die if not.
+ * Read the flag indicating the state of the data pointer. Check if valid
+ * and die if not.
*
- * This used to be handled by a negative or zero pointer, now we use an
- * extra byte specifically for the state.
+ * This used to be handled by a negative or zero pointer, now we use an extra
+ * byte specifically for the state.
*/
offsetFlg = (*AH->ReadBytePtr) (AH) & 0xFF;
@@ -1320,11 +1316,11 @@ WriteInt(ArchiveHandle *AH, int i)
int b;
/*
- * This is a bit yucky, but I don't want to make the binary format
- * very dependent on representation, and not knowing much about it, I
- * write out a sign byte. If you change this, don't forget to change
- * the file version #, and modify readInt to read the new format AS
- * WELL AS the old formats.
+ * This is a bit yucky, but I don't want to make the binary format very
+ * dependent on representation, and not knowing much about it, I write out
+ * a sign byte. If you change this, don't forget to change the file
+ * version #, and modify readInt to read the new format AS WELL AS the old
+ * formats.
*/
/* SIGN byte */
@@ -1513,8 +1509,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
if (fseeko(fh, 0, SEEK_SET) != 0)
{
/*
- * NOTE: Formats that use the lookahead buffer can unset this in
- * their Init routine.
+ * NOTE: Formats that use the lookahead buffer can unset this in their
+ * Init routine.
*/
AH->readHeader = 1;
}
@@ -1570,15 +1566,15 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
/*
* Not used; maybe later....
*
- * AH->workDir = strdup(FileSpec); for(i=strlen(FileSpec) ; i > 0 ;
- * i--) if (AH->workDir[i-1] == '/')
+ * AH->workDir = strdup(FileSpec); for(i=strlen(FileSpec) ; i > 0 ; i--)
+ * if (AH->workDir[i-1] == '/')
*/
}
else
AH->fSpec = NULL;
- AH->currUser = strdup(""); /* So it's valid, but we can free() it
- * later if necessary */
+ AH->currUser = strdup(""); /* So it's valid, but we can free() it later
+ * if necessary */
AH->currSchema = strdup(""); /* ditto */
AH->currWithOids = -1; /* force SET */
@@ -1601,8 +1597,8 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
/*
* On Windows, we need to use binary mode to read/write non-text archive
- * formats. Force stdin/stdout into binary mode if that is what
- * we are using.
+ * formats. Force stdin/stdout into binary mode if that is what we are
+ * using.
*/
#ifdef WIN32
if (fmt != archNull &&
@@ -1683,8 +1679,7 @@ WriteDataChunks(ArchiveHandle *AH)
(*startPtr) (AH, te);
/*
- * printf("Dumper arg for %d is %x\n", te->id,
- * te->dataDumperArg);
+ * printf("Dumper arg for %d is %x\n", te->id, te->dataDumperArg);
*/
/*
@@ -1771,7 +1766,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);
@@ -1890,7 +1885,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
/* If no namespace is specified, it means all. */
if (!te->namespace)
return 0;
- if(strcmp(ropt->schemaNames, te->namespace) != 0)
+ if (strcmp(ropt->schemaNames, te->namespace) != 0)
return 0;
}
if ((strcmp(te->desc, "TABLE") == 0) || (strcmp(te->desc, "TABLE DATA") == 0))
@@ -1926,14 +1921,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
}
/*
- * Check if we had a dataDumper. Indicates if the entry is schema or
- * data
+ * Check if we had a dataDumper. Indicates if the entry is schema or data
*/
if (!te->hadDumper)
{
/*
- * Special Case: If 'SEQUENCE SET' then it is considered a data
- * entry
+ * Special Case: If 'SEQUENCE SET' then it is considered a data entry
*/
if (strcmp(te->desc, "SEQUENCE SET") == 0)
res = res & REQ_DATA;
@@ -1942,8 +1935,8 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
}
/*
- * Special case: <Init> type with <Max OID> tag; this is obsolete
- * and we always ignore it.
+ * Special case: <Init> type with <Max OID> tag; this is obsolete and we
+ * always ignore it.
*/
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->tag, "Max OID") == 0))
return 0;
@@ -2095,8 +2088,8 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname)
}
/*
- * NOTE: currUser keeps track of what the imaginary session user in
- * our script is. It's now effectively reset to the original userID.
+ * NOTE: currUser keeps track of what the imaginary session user in our
+ * script is. It's now effectively reset to the original userID.
*/
if (AH->currUser)
free(AH->currUser);
@@ -2130,8 +2123,8 @@ _becomeUser(ArchiveHandle *AH, const char *user)
_doSetSessionAuth(AH, user);
/*
- * NOTE: currUser keeps track of what the imaginary session user in
- * our script is
+ * NOTE: currUser keeps track of what the imaginary session user in our
+ * script is
*/
if (AH->currUser)
free(AH->currUser);
@@ -2195,8 +2188,8 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
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));
+ "could not set search_path to \"%s\": %s",
+ schemaName, PQerrorMessage(AH->connection));
PQclear(res);
}
@@ -2218,7 +2211,8 @@ static void
_selectTablespace(ArchiveHandle *AH, const char *tablespace)
{
PQExpBuffer qry;
- const char *want, *have;
+ const char *want,
+ *have;
have = AH->currTablespace;
want = tablespace;
@@ -2250,7 +2244,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
res = PQexec(AH->connection, qry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_die_horribly(AH, modulename,
+ warn_or_die_horribly(AH, modulename,
"could not set default_tablespace to %s: %s",
fmtId(want), PQerrorMessage(AH->connection));
@@ -2292,17 +2286,17 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
strcmp(type, "TYPE") == 0)
{
appendPQExpBuffer(buf, "%s ", type);
- if (te->namespace && te->namespace[0]) /* is null pre-7.3 */
+ if (te->namespace && te->namespace[0]) /* is null pre-7.3 */
appendPQExpBuffer(buf, "%s.", fmtId(te->namespace));
+
/*
- * Pre-7.3 pg_dump would sometimes (not always) put
- * a fmtId'd name into te->tag for an index.
- * This check is heuristic, so make its scope as
- * narrow as possible.
+ * Pre-7.3 pg_dump would sometimes (not always) put a fmtId'd name
+ * into te->tag for an index. This check is heuristic, so make its
+ * scope as narrow as possible.
*/
if (AH->version < K_VERS_1_7 &&
te->tag[0] == '"' &&
- te->tag[strlen(te->tag)-1] == '"' &&
+ te->tag[strlen(te->tag) - 1] == '"' &&
strcmp(type, "INDEX") == 0)
appendPQExpBuffer(buf, "%s", te->tag);
else
@@ -2319,8 +2313,8 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
}
/*
- * These object types require additional decoration. Fortunately,
- * the information needed is exactly what's in the DROP command.
+ * These object types require additional decoration. Fortunately, the
+ * information needed is exactly what's in the DROP command.
*/
if (strcmp(type, "AGGREGATE") == 0 ||
strcmp(type, "FUNCTION") == 0 ||
@@ -2366,8 +2360,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* Avoid dumping the public schema, as it will already be created ...
- * unless we are using --clean mode, in which case it's been deleted
- * and we'd better recreate it.
+ * unless we are using --clean mode, in which case it's been deleted and
+ * we'd better recreate it.
*/
if (!ropt->dropSchema &&
strcmp(te->desc, "SCHEMA") == 0 && strcmp(te->tag, "public") == 0)
@@ -2411,11 +2405,11 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-",
te->owner);
- if (te->tablespace)
+ if (te->tablespace)
ahprintf(AH, "; Tablespace: %s", te->tablespace);
ahprintf(AH, "\n");
- if (AH->PrintExtraTocPtr != NULL)
+ if (AH->PrintExtraTocPtr !=NULL)
(*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n");
}
@@ -2423,10 +2417,9 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/*
* Actually print the definition.
*
- * Really crude hack for suppressing AUTHORIZATION clause that old
- * pg_dump versions put into CREATE SCHEMA. We have to do this when
- * --no-owner mode is selected. This is ugly, but I see
- * no other good way ...
+ * Really crude hack for suppressing AUTHORIZATION clause that old pg_dump
+ * versions put into CREATE SCHEMA. We have to do this when --no-owner
+ * mode is selected. This is ugly, but I see no other good way ...
*/
if (ropt->noOwner && strcmp(te->desc, "SCHEMA") == 0)
{
@@ -2489,8 +2482,7 @@ _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)
{
@@ -2643,8 +2635,8 @@ checkSeek(FILE *fp)
else if (sizeof(off_t) > sizeof(long))
/*
- * At this point, off_t is too large for long, so we return based
- * on whether an off_t version of fseek is available.
+ * At this point, off_t is too large for long, so we return based on
+ * whether an off_t version of fseek is available.
*/
#ifdef HAVE_FSEEKO
return true;
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index e7a05283d7..ce42974c6a 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.67 2005/09/11 04:10:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.68 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -179,10 +179,10 @@ typedef struct _archiveHandle
char vrev;
int version; /* Conveniently formatted version */
- char *archiveRemoteVersion; /* When reading an archive,
- * the version of the dumped DB */
- char *archiveDumpVersion; /* When reading an archive,
- * the version of the dumper */
+ char *archiveRemoteVersion; /* When reading an archive, the
+ * version of the dumped DB */
+ char *archiveDumpVersion; /* When reading an archive, the
+ * version of the dumper */
int debugLevel; /* Used for logging (currently only by
* --verbose) */
@@ -200,14 +200,12 @@ typedef struct _archiveHandle
* Fields used when discovering header. A format can always get the
* previous read bytes from here...
*/
- int readHeader; /* Used if file header has been read
- * already */
- char *lookahead; /* Buffer used when reading header to
- * discover format */
+ int readHeader; /* Used if file header has been read already */
+ char *lookahead; /* Buffer used when reading header to discover
+ * format */
size_t lookaheadSize; /* Size of allocated buffer */
size_t lookaheadLen; /* Length of data in lookahead */
- off_t lookaheadPos; /* Current read position in lookahead
- * buffer */
+ off_t lookaheadPos; /* Current read position in lookahead buffer */
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
StartDataPtr StartDataPtr; /* Called when table data is about to be
@@ -221,8 +219,8 @@ typedef struct _archiveHandle
ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */
ClosePtr ClosePtr; /* Close the archive */
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data
- * associated with the current
- * archive format */
+ * associated with the current archive
+ * format */
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with
* archie format */
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
@@ -239,8 +237,8 @@ typedef struct _archiveHandle
char *archdbname; /* DB name *read* from archive */
bool requirePassword;
PGconn *connection;
- int connectToDB; /* Flag to indicate if direct DB
- * connection is required */
+ int connectToDB; /* Flag to indicate if direct DB connection is
+ * required */
int pgCopyIn; /* Currently in libpq 'COPY IN' mode. */
PQExpBuffer pgCopyBuf; /* Left-over data from incomplete lines in
* COPY IN */
@@ -263,13 +261,13 @@ typedef struct _archiveHandle
ArchiveMode mode; /* File mode - r or w */
void *formatData; /* Header data specific to file format */
- RestoreOptions *ropt; /* Used to check restore options in
- * ahwrite etc */
+ RestoreOptions *ropt; /* Used to check restore options in ahwrite
+ * etc */
/* these vars track state to avoid sending redundant SET commands */
char *currUser; /* current username */
char *currSchema; /* current schema */
- char *currTablespace; /* current tablespace */
+ char *currTablespace; /* current tablespace */
bool currWithOids; /* current default_with_oids setting */
void *lo_buf;
@@ -289,8 +287,8 @@ typedef struct _tocEntry
struct _tocEntry *next;
CatalogId catalogId;
DumpId dumpId;
- bool hadDumper; /* Archiver was passed a dumper routine
- * (used in restore) */
+ bool hadDumper; /* Archiver was passed a dumper routine (used
+ * in restore) */
char *tag; /* index tag */
char *namespace; /* null or empty string if not in a schema */
char *tablespace; /* null if not in a tablespace; empty string
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 115375c343..3edbb8f5c0 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.32 2005/09/24 17:53:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.33 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,10 +151,10 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
/*
* zlibOutSize is the buffer size we tell zlib it can output to. We
- * actually allocate one extra byte because some routines want to
- * append a trailing zero byte to the zlib output. The input buffer
- * is expansible and is always of size ctx->inSize; zlibInSize is just
- * the initial default size for it.
+ * actually allocate one extra byte because some routines want to append a
+ * trailing zero byte to the zlib output. The input buffer is expansible
+ * and is always of size ctx->inSize; zlibInSize is just the initial
+ * default size for it.
*/
ctx->zlibOut = (char *) malloc(zlibOutSize + 1);
ctx->zlibIn = (char *) malloc(zlibInSize);
@@ -258,8 +258,8 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
ctx->dataState = ReadOffset(AH, &(ctx->dataPos));
/*
- * Prior to V1.7 (pg7.3), we dumped the data size as an int now we
- * don't dump it at all.
+ * Prior to V1.7 (pg7.3), we dumped the data size as an int now we don't
+ * dump it at all.
*/
if (AH->version < K_VERS_1_7)
junk = ReadInt(AH);
@@ -439,7 +439,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
if ((TocIDRequired(AH, id, ropt) & REQ_DATA) != 0)
die_horribly(AH, modulename,
"Dumping a specific TOC data block out of order is not supported"
- " without ID on this input stream (fseek required)\n");
+ " without ID on this input stream (fseek required)\n");
switch (blkType)
{
@@ -541,7 +541,7 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
+ "could not read data block -- expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen;
@@ -664,7 +664,7 @@ _skipData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
+ "could not read data block -- expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen;
@@ -794,10 +794,9 @@ _CloseArchive(ArchiveHandle *AH)
WriteDataChunks(AH);
/*
- * This is not an essential operation - it is really only needed
- * if we expect to be doing seeks to read the data back - it may
- * be ok to just use the existing self-consistent block
- * formatting.
+ * This is not an essential operation - it is really only needed if we
+ * expect to be doing seeks to read the data back - it may be ok to
+ * just use the existing self-consistent block formatting.
*/
if (ctx->hasSeek)
{
@@ -882,7 +881,6 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te)
if (deflateInit(zp, AH->compression) != Z_OK)
die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg);
}
-
#else
AH->compression = 0;
@@ -920,15 +918,14 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
)
{
/*
- * Extra paranoia: avoid zero-length chunks since a zero
- * length chunk is the EOF marker. This should never happen
- * but...
+ * Extra paranoia: avoid zero-length chunks since a zero length
+ * chunk is the EOF marker. This should never happen but...
*/
if (zp->avail_out < zlibOutSize)
{
/*
- * printf("Wrote %lu byte deflated chunk\n", (unsigned
- * long) (zlibOutSize - zp->avail_out));
+ * printf("Wrote %lu byte deflated chunk\n", (unsigned long)
+ * (zlibOutSize - zp->avail_out));
*/
WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 2065f59a4d..a3f23b4cfd 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.65 2005/09/11 04:10:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.66 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -170,7 +170,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
noPwd = (strcmp(PQerrorMessage(newConn),
PQnoPasswordSupplied) == 0);
badPwd = (strncmp(PQerrorMessage(newConn),
- "Password authentication failed for user", 39) == 0);
+ "Password authentication failed for user", 39) == 0);
if (noPwd || badPwd)
{
@@ -236,8 +236,8 @@ ConnectDatabase(Archive *AHX,
AH->requirePassword = false;
/*
- * Start the connection. Loop until we have a password if requested
- * by backend.
+ * Start the connection. Loop until we have a password if requested by
+ * backend.
*/
do
{
@@ -249,7 +249,7 @@ ConnectDatabase(Archive *AHX,
die_horribly(AH, modulename, "failed to connect to database\n");
if (PQstatus(AH->connection) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(AH->connection), PQnoPasswordSupplied) == 0 &&
+ strcmp(PQerrorMessage(AH->connection), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(AH->connection);
@@ -349,8 +349,8 @@ _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
}
/*
- * fprintf(stderr, "Found cr at %d, prev char was %c, next was
- * %c\n", loc, qry[loc-1], qry[loc+1]);
+ * fprintf(stderr, "Found cr at %d, prev char was %c, next was %c\n",
+ * loc, qry[loc-1], qry[loc+1]);
*/
/* Count the number of preceding slashes */
@@ -361,8 +361,8 @@ _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
sPos = loc - sPos;
/*
- * If an odd number of preceding slashes, then \n was escaped so
- * set the next search pos, and loop (if any left).
+ * If an odd number of preceding slashes, then \n was escaped so set
+ * the next search pos, and loop (if any left).
*/
if ((sPos & 1) == 1)
{
@@ -418,14 +418,14 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
{
/*
* The following is a mini state machine to assess the end of an SQL
- * statement. It really only needs to parse good SQL, or at least
- * that's the theory... End-of-statement is assumed to be an unquoted,
+ * statement. It really only needs to parse good SQL, or at least that's
+ * the theory... End-of-statement is assumed to be an unquoted,
* un-commented semi-colon that's not within any parentheses.
*
* Note: the input can be split into bufferloads at arbitrary boundaries.
* Therefore all state must be kept in AH->sqlparse, not in local
- * variables of this routine. We assume that AH->sqlparse was
- * filled with zeroes when created.
+ * variables of this routine. We assume that AH->sqlparse was filled with
+ * zeroes when created.
*/
for (; qry < eos; qry++)
{
@@ -435,18 +435,18 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
if (*qry == ';' && AH->sqlparse.braceDepth == 0)
{
/*
- * We've found the end of a statement. Send it and
- * reset the buffer.
+ * We've found the end of a statement. Send it and reset
+ * the buffer.
*/
- appendPQExpBufferChar(AH->sqlBuf, ';'); /* inessential */
+ appendPQExpBufferChar(AH->sqlBuf, ';'); /* inessential */
ExecuteSqlCommand(AH, AH->sqlBuf,
"could not execute query");
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.
*/
qry++;
while (qry < eos && *qry == '\n')
@@ -467,11 +467,11 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
{
AH->sqlparse.state = SQL_IN_DOUBLE_QUOTE;
}
+
/*
* Look for dollar-quotes. We make the assumption that
- * $-quotes will not have an ident character just
- * before them in pg_dump output. XXX is this
- * good enough?
+ * $-quotes will not have an ident character just before them
+ * in pg_dump output. XXX is this good enough?
*/
else if (*qry == '$' && !_isIdentChar(AH->sqlparse.lastChar))
{
@@ -499,6 +499,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
break;
case SQL_IN_EXT_COMMENT:
+
/*
* This isn't fully correct, because we don't account for
* nested slash-stars, but pg_dump never emits such.
@@ -518,13 +519,14 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
break;
case SQL_IN_E_QUOTE:
+
/*
* Eventually we will need to handle '' specially, because
* after E'...''... we should still be in E_QUOTE state.
*
- * XXX problem: how do we tell whether the dump was made
- * by a version that thinks backslashes aren't special
- * in non-E literals??
+ * XXX problem: how do we tell whether the dump was made by a
+ * version that thinks backslashes aren't special in non-E
+ * literals??
*/
if (*qry == '\'' && !AH->sqlparse.backSlash)
AH->sqlparse.state = SQL_SCAN;
@@ -556,12 +558,12 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
{
/*
* Ooops, we're not really in a dollar-tag. 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 have to back up
- * the qry pointer so that the current character gets
- * rescanned in SCAN state; and then "continue" so that
- * the bottom-of-loop actions aren't done yet.
+ * 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 have to back up the qry pointer
+ * so that the current character gets rescanned in SCAN
+ * state; and then "continue" so that the bottom-of-loop
+ * actions aren't done yet.
*/
AH->sqlparse.state = SQL_SCAN;
qry--;
@@ -570,12 +572,13 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
break;
case SQL_IN_DOLLAR_QUOTE:
+
/*
* If we are at a $, see whether what precedes it matches
- * tagBuf. (Remember that the trailing $ of the tag was
- * not added to tagBuf.) However, don't compare until we
- * have enough data to be a possible match --- this is
- * needed to avoid false match on '$a$a$...'
+ * tagBuf. (Remember that the trailing $ of the tag was not
+ * added to tagBuf.) However, don't compare until we have
+ * enough data to be a possible match --- this is needed to
+ * avoid false match on '$a$a$...'
*/
if (*qry == '$' &&
AH->sqlBuf->len >= AH->sqlparse.minTagEndPos &&
@@ -605,8 +608,8 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
char *eos = qry + bufLen;
/*
- * fprintf(stderr, "\n\n*****\n
- * Buffer:\n\n%s\n*******************\n\n", qry);
+ * fprintf(stderr, "\n\n*****\n Buffer:\n\n%s\n*******************\n\n",
+ * qry);
*/
/* Could switch between command and COPY IN mode at each line */
@@ -653,8 +656,7 @@ _isIdentChar(unsigned char c)
|| (c >= '0' && c <= '9')
|| (c == '_')
|| (c == '$')
- || (c >= (unsigned char) '\200') /* no need to check <=
- * \377 */
+ || (c >= (unsigned char) '\200') /* no need to check <= \377 */
)
return true;
else
@@ -668,8 +670,7 @@ _isDQChar(unsigned char c, bool atStart)
|| (c >= 'A' && c <= 'Z')
|| (c == '_')
|| (!atStart && c >= '0' && c <= '9')
- || (c >= (unsigned char) '\200') /* no need to check <=
- * \377 */
+ || (c >= (unsigned char) '\200') /* no need to check <= \377 */
)
return true;
else
diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c
index 2f255c0c29..b36a1c8600 100644
--- a/src/bin/pg_dump/pg_backup_files.c
+++ b/src/bin/pg_dump/pg_backup_files.c
@@ -20,7 +20,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.26 2005/06/21 20:45:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.27 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -469,7 +469,7 @@ _StartBlobs(ArchiveHandle *AH, TocEntry *te)
if (ctx->blobToc == NULL)
die_horribly(AH, modulename,
- "could not open large object TOC for output: %s\n", strerror(errno));
+ "could not open large object TOC for output: %s\n", strerror(errno));
}
/*
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c
index 7e0b6ffe11..76eea19307 100644
--- a/src/bin/pg_dump/pg_backup_null.c
+++ b/src/bin/pg_dump/pg_backup_null.c
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.15 2005/06/21 20:45:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.16 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -100,7 +100,7 @@ _WriteBlobData(ArchiveHandle *AH, const void *data, size_t dLen)
if (dLen > 0)
{
unsigned char *str;
- size_t len;
+ size_t len;
str = PQescapeBytea((const unsigned char *) data, dLen, &len);
if (!str)
@@ -161,6 +161,7 @@ static void
_EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
{
AH->WriteDataPtr = _WriteData;
+
ahprintf(AH, "SELECT lo_close(0);\n\n");
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 5b38d4615b..cbd9f66865 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.48 2005/06/22 02:00:47 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,7 +54,6 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
#ifdef HAVE_LIBZ
/* typedef gzFile ThingFile; */
typedef FILE ThingFile;
-
#else
typedef FILE ThingFile;
#endif
@@ -180,13 +179,13 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
if (ctx->tarFH == NULL)
die_horribly(NULL, modulename,
- "could not open TOC file for output: %s\n", strerror(errno));
+ "could not open TOC file for output: %s\n", strerror(errno));
ctx->tarFHpos = 0;
/*
- * Make unbuffered since we will dup() it, and the buffers screw
- * each other
+ * Make unbuffered since we will dup() it, and the buffers screw each
+ * other
*/
/* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */
@@ -200,9 +199,9 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
AH->compression = 0;
/*
- * We don't support compression because reading the files back is
- * not possible since gzdopen uses buffered IO which totally
- * screws file positioning.
+ * We don't support compression because reading the files back is not
+ * possible since gzdopen uses buffered IO which totally screws file
+ * positioning.
*/
if (AH->compression != 0)
die_horribly(NULL, modulename, "compression not supported by tar output format\n");
@@ -220,8 +219,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
die_horribly(NULL, modulename, "could not open TOC file for input: %s\n", strerror(errno));
/*
- * Make unbuffered since we will dup() it, and the buffers screw
- * each other
+ * Make unbuffered since we will dup() it, and the buffers screw each
+ * other
*/
/* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */
@@ -336,8 +335,8 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
tm = _tarPositionTo(AH, filename);
if (!tm) /* Not found */
{
- if (filename) /* Couldn't find the requested file.
- * Future: DO SEEK(0) and retry. */
+ if (filename) /* Couldn't find the requested file. Future:
+ * DO SEEK(0) and retry. */
die_horribly(AH, modulename, "could not find file %s in archive\n", filename);
else
/* Any file OK, non left, so return NULL */
@@ -351,7 +350,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
else
die_horribly(AH, modulename, "compression support is disabled in this format\n");
/* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */
-
#else
tm->nFH = ctx->tarFH;
#endif
@@ -378,7 +376,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
}
else
tm->nFH = tm->tmpFH;
-
#else
tm->nFH = tm->tmpFH;
@@ -546,7 +543,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
if (res != len)
die_horribly(th->AH, modulename,
- "could not write to tar member (wrote %lu, attempted %lu)\n",
+ "could not write to tar member (wrote %lu, attempted %lu)\n",
(unsigned long) res, (unsigned long) len);
th->pos += res;
@@ -630,8 +627,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
tmpCopy[i] = pg_tolower((unsigned char) tmpCopy[i]);
/*
- * This is very nasty; we don't know if the archive used WITH
- * OIDS, so we search the string for it in a paranoid sort of way.
+ * This is very nasty; we don't know if the archive used WITH OIDS, so
+ * we search the string for it in a paranoid sort of way.
*/
if (strncmp(tmpCopy, "copy ", 5) != 0)
die_horribly(AH, modulename,
@@ -784,16 +781,16 @@ _CloseArchive(ArchiveHandle *AH)
WriteDataChunks(AH);
/*
- * Now this format wants to append a script which does a full
- * restore if the files have been extracted.
+ * Now this format wants to append a script which does a full restore
+ * if the files have been extracted.
*/
th = tarOpen(AH, "restore.sql", 'w');
tarPrintf(AH, th, "create temporary table pgdump_restore_path(p text);\n");
tarPrintf(AH, th, "--\n"
"-- NOTE:\n"
"--\n"
- "-- File paths need to be edited. Search for $$PATH$$ and\n"
- "-- replace it with the path to the directory containing\n"
+ "-- File paths need to be edited. Search for $$PATH$$ and\n"
+ "-- replace it with the path to the directory containing\n"
"-- the extracted data files.\n"
"--\n"
"-- Edit the following to match the path where the\n"
@@ -826,7 +823,7 @@ _CloseArchive(ArchiveHandle *AH)
{
if (fputc(0, ctx->tarFH) == EOF)
die_horribly(AH, modulename,
- "could not write null block at end of tar archive\n");
+ "could not write null block at end of tar archive\n");
}
}
@@ -942,13 +939,13 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...)
int cnt = -1;
/*
- * This is paranoid: deal with the possibility that vsnprintf is
- * willing to ignore trailing null
+ * 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
+ * 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))
{
@@ -1019,9 +1016,10 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
*/
fseeko(tmp, 0, SEEK_END);
th->fileLen = ftello(tmp);
+
/*
- * Some compilers with throw a warning knowing this test can never be
- * true because off_t can't exceed the compared maximum.
+ * Some compilers with throw a warning knowing this test can never be true
+ * because off_t can't exceed the compared maximum.
*/
if (th->fileLen > MAX_TAR_MEMBER_FILELEN)
die_horribly(AH, modulename, "archive member too large for tar format\n");
@@ -1108,7 +1106,11 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
if (filename)
die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename);
else
- /* We're just scanning the archibe for the next file, so return null */
+
+ /*
+ * We're just scanning the archibe for the next file, so return
+ * null
+ */
{
free(th);
return NULL;
@@ -1122,7 +1124,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
id = atoi(th->targetFile);
if ((TocIDRequired(AH, id, AH->ropt) & REQ_DATA) != 0)
die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: "
- "%s is required, but comes before %s in the archive file.\n",
+ "%s is required, but comes before %s in the archive file.\n",
th->targetFile, filename);
/* Header doesn't match, so read to next header */
@@ -1168,7 +1170,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ftello(ctx->tarFH));
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
die_horribly(AH, modulename,
- "mismatch in actual vs. predicted file position (%s vs. %s)\n",
+ "mismatch in actual vs. predicted file position (%s vs. %s)\n",
buf1, buf2);
}
#endif
@@ -1191,8 +1193,8 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
sscanf(&h[148], "%8o", &sum);
/*
- * If the checksum failed, see if it is a null block. If so,
- * silently continue to the next block.
+ * If the checksum failed, see if it is a null block. If so, silently
+ * continue to the next block.
*/
if (chk == sum)
gotBlock = true;
@@ -1301,12 +1303,12 @@ _tarWriteHeader(TAR_MEMBER *th)
#if 0
/* User 32 */
- sprintf(&h[265], "%.31s", ""); /* How do I get username reliably?
- * Do I need to? */
+ sprintf(&h[265], "%.31s", ""); /* How do I get username reliably? Do
+ * I need to? */
/* Group 32 */
- sprintf(&h[297], "%.31s", ""); /* How do I get group reliably? Do
- * I need to? */
+ sprintf(&h[297], "%.31s", ""); /* How do I get group reliably? Do I
+ * need to? */
/* Maj Dev 8 */
sprintf(&h[329], "%6o ", 0);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c08999642f..895d156317 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.421 2005/09/21 19:58:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.422 2005/10/15 02:49:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -239,8 +239,8 @@ main(int argc, char **argv)
{"version", no_argument, NULL, 'V'},
/*
- * the following options don't have an equivalent short option
- * letter, but are available as '-X long-name'
+ * the following options don't have an equivalent short option letter,
+ * but are available as '-X long-name'
*/
{"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
@@ -293,8 +293,7 @@ main(int argc, char **argv)
/* this is now default, so just ignore the switch */
break;
- case 'c': /* clean (i.e., drop) schema prior to
- * create */
+ case 'c': /* clean (i.e., drop) schema prior to create */
outputClean = 1;
break;
@@ -357,8 +356,7 @@ main(int argc, char **argv)
outputBlobs = false;
break;
- case 'S': /* Username for superuser in plain text
- * output */
+ case 'S': /* Username for superuser in plain text output */
outputSuperuser = strdup(optarg);
break;
@@ -388,11 +386,11 @@ main(int argc, char **argv)
break;
/*
- * Option letters were getting scarce, so I invented this
- * new scheme: '-X feature' turns on some feature. Compare
- * to the -f option in GCC. You should also add an
- * equivalent GNU-style option --feature. Features that
- * require arguments should use '-X feature=foo'.
+ * Option letters were getting scarce, so I invented this new
+ * scheme: '-X feature' turns on some feature. Compare to the
+ * -f option in GCC. You should also add an equivalent
+ * GNU-style option --feature. Features that require
+ * arguments should use '-X feature=foo'.
*/
case 'X':
if (strcmp(optarg, "disable-dollar-quoting") == 0)
@@ -507,8 +505,8 @@ main(int argc, char **argv)
}
/*
- * Open the database using the Archiver, so it knows about it. Errors
- * mean death.
+ * Open the database using the Archiver, so it knows about it. Errors mean
+ * death.
*/
g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport,
username, force_password, ignore_version);
@@ -526,8 +524,9 @@ main(int argc, char **argv)
/* Set the client encoding */
if (dumpencoding)
{
- char *cmd = malloc(strlen(dumpencoding) + 32);
- sprintf(cmd,"SET client_encoding='%s'", dumpencoding);
+ char *cmd = malloc(strlen(dumpencoding) + 32);
+
+ sprintf(cmd, "SET client_encoding='%s'", dumpencoding);
do_sql_command(g_conn, cmd);
free(cmd);
}
@@ -595,10 +594,9 @@ 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);
@@ -610,8 +608,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.
*/
/* First the special encoding entry. */
@@ -646,8 +644,7 @@ main(int argc, char **argv)
else
ropt->compression = compressLevel;
- ropt->suppressDumpWarnings = true; /* We've already shown
- * them */
+ ropt->suppressDumpWarnings = true; /* We've already shown them */
RestoreArchive(g_fout, ropt);
}
@@ -730,8 +727,8 @@ selectDumpableNamespace(NamespaceInfo *nsinfo)
{
/*
* If a specific table is being dumped, do not dump any complete
- * namespaces. If a specific namespace is being dumped, dump just
- * that namespace. Otherwise, dump all non-system namespaces.
+ * namespaces. If a specific namespace is being dumped, dump just that
+ * namespace. Otherwise, dump all non-system namespaces.
*/
if (selectTableName != NULL)
nsinfo->dump = false;
@@ -758,8 +755,8 @@ selectDumpableTable(TableInfo *tbinfo)
{
/*
* Always dump if dumping parent namespace; else, if a particular
- * tablename has been specified, dump matching table name; else, do
- * not dump.
+ * tablename has been specified, dump matching table name; else, do not
+ * dump.
*/
tbinfo->dump = false;
if (tbinfo->dobj.namespace->dump)
@@ -803,17 +800,17 @@ dumpTableData_copy(Archive *fout, void *dcontext)
/*
* Make sure we are in proper schema. We will qualify the table name
- * below anyway (in case its name conflicts with a pg_catalog table);
- * but this ensures reproducible results in case the table contains
- * regproc, regclass, etc columns.
+ * below anyway (in case its name conflicts with a pg_catalog table); but
+ * this ensures reproducible results in case the table contains regproc,
+ * regclass, etc columns.
*/
selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/*
* If possible, specify the column list explicitly so that we have no
- * possibility of retrieving data in the wrong column order. (The
- * default column ordering of COPY will not be what we want in certain
- * corner cases involving ADD COLUMN and inheritance.)
+ * possibility of retrieving data in the wrong column order. (The default
+ * column ordering of COPY will not be what we want in certain corner
+ * cases involving ADD COLUMN and inheritance.)
*/
if (g_fout->remoteVersion >= 70300)
column_list = fmtCopyColumnList(tbinfo);
@@ -823,15 +820,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);
@@ -868,42 +865,41 @@ dumpTableData_copy(Archive *fout, void *dcontext)
/*
* THROTTLE:
*
- * There was considerable discussion in late July, 2000 regarding
- * slowing down pg_dump when backing up large tables. Users with
- * both slow & fast (muti-processor) machines experienced
- * performance degradation when doing a backup.
+ * There was considerable discussion in late July, 2000 regarding slowing
+ * down pg_dump when backing up large tables. Users with both slow &
+ * fast (muti-processor) machines experienced performance degradation
+ * when doing a backup.
*
- * Initial attempts based on sleeping for a number of ms for each ms
- * of work were deemed too complex, then a simple 'sleep in each
- * loop' implementation was suggested. The latter failed because
- * the loop was too tight. Finally, the following was implemented:
+ * Initial attempts based on sleeping for a number of ms for each ms of
+ * work were deemed too complex, then a simple 'sleep in each loop'
+ * implementation was suggested. The latter failed because the loop
+ * was too tight. Finally, the following was implemented:
*
- * If throttle is non-zero, then See how long since the last sleep.
- * Work out how long to sleep (based on ratio). If sleep is more
- * than 100ms, then sleep reset timer EndIf EndIf
+ * If throttle is non-zero, then See how long since the last sleep. Work
+ * out how long to sleep (based on ratio). If sleep is more than
+ * 100ms, then sleep reset timer EndIf EndIf
*
- * where the throttle value was the number of ms to sleep per ms of
- * work. The calculation was done in each loop.
+ * where the throttle value was the number of ms to sleep per ms of work.
+ * The calculation was done in each loop.
*
- * Most of the hard work is done in the backend, and this solution
- * still did not work particularly well: on slow machines, the
- * ratio was 50:1, and on medium paced machines, 1:1, and on fast
- * multi-processor machines, it had little or no effect, for
- * reasons that were unclear.
+ * Most of the hard work is done in the backend, and this solution still
+ * did not work particularly well: on slow machines, the ratio was
+ * 50:1, and on medium paced machines, 1:1, and on fast
+ * multi-processor machines, it had little or no effect, for reasons
+ * that were unclear.
*
* Further discussion ensued, and the proposal was dropped.
*
- * For those people who want this feature, it can be implemented
- * using gettimeofday in each loop, calculating the time since
- * last sleep, multiplying that by the sleep ratio, then if the
- * result is more than a preset 'minimum sleep time' (say 100ms),
- * call the 'select' function to sleep for a subsecond period ie.
+ * For those people who want this feature, it can be implemented using
+ * gettimeofday in each loop, calculating the time since last sleep,
+ * multiplying that by the sleep ratio, then if the result is more
+ * than a preset 'minimum sleep time' (say 100ms), call the 'select'
+ * function to sleep for a subsecond period ie.
*
* select(0, NULL, NULL, NULL, &tvi);
*
- * This will return after the interval specified in the structure
- * tvi. Finally, call gettimeofday again to save the 'last sleep
- * time'.
+ * This will return after the interval specified in the structure tvi.
+ * Finally, call gettimeofday again to save the 'last sleep time'.
*/
}
archprintf(fout, "\\.\n\n\n");
@@ -936,9 +932,9 @@ dumpTableData_insert(Archive *fout, void *dcontext)
/*
* Make sure we are in proper schema. We will qualify the table name
- * below anyway (in case its name conflicts with a pg_catalog table);
- * but this ensures reproducible results in case the table contains
- * regproc, regclass, etc columns.
+ * below anyway (in case its name conflicts with a pg_catalog table); but
+ * this ensures reproducible results in case the table contains regproc,
+ * regclass, etc columns.
*/
selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
@@ -946,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);
@@ -1013,16 +1009,15 @@ dumpTableData_insert(Archive *fout, void *dcontext)
case NUMERICOID:
{
/*
- * These types are printed without quotes
- * unless they contain values that aren't
- * accepted by the scanner unquoted (e.g.,
- * 'NaN'). Note that strtod() and friends
- * might accept NaN, so we can't use that to
- * test.
+ * These types are printed without quotes unless
+ * they contain values that aren't accepted by the
+ * scanner unquoted (e.g., 'NaN'). Note that
+ * strtod() and friends might accept NaN, so we
+ * can't use that to test.
*
- * In reality we only need to defend against
- * infinity and NaN, so we need not get too
- * crazy about pattern matching here.
+ * In reality we only need to defend against infinity
+ * and NaN, so we need not get too crazy about
+ * pattern matching here.
*/
const char *s = PQgetvalue(res, tuple, field);
@@ -1092,7 +1087,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
@@ -1141,8 +1136,8 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
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.
+ * Note: use tableoid 0 so that this object won't be mistaken for
+ * something that pg_depend entries apply to.
*/
tdinfo->dobj.catId.tableoid = 0;
tdinfo->dobj.catId.oid = tblinfo[i].dobj.catId.oid;
@@ -1279,7 +1274,7 @@ dumpDatabase(Archive *AH)
dbDumpId, /* dump ID */
datname, /* Name */
NULL, /* Namespace */
- NULL, /* Tablespace */
+ NULL, /* Tablespace */
dba, /* Owner */
false, /* with oids */
"DATABASE", /* Desc */
@@ -1508,8 +1503,8 @@ dumpBlobComments(Archive *AH, void *arg)
/* Process the tuples, if any */
for (i = 0; i < PQntuples(res); i++)
{
- Oid blobOid;
- char *comment;
+ Oid blobOid;
+ char *comment;
/* ignore blobs without comments */
if (PQgetisnull(res, i, 1))
@@ -1558,8 +1553,8 @@ getNamespaces(int *numNamespaces)
int i_nspacl;
/*
- * Before 7.3, there are no real namespaces; create two dummy entries,
- * one for user stuff and one for system stuff.
+ * Before 7.3, there are no real namespaces; create two dummy entries, one
+ * for user stuff and one for system stuff.
*/
if (g_fout->remoteVersion < 70300)
{
@@ -1597,8 +1592,8 @@ getNamespaces(int *numNamespaces)
selectSourceSchema("pg_catalog");
/*
- * we fetch all namespaces including system ones, so that every object
- * we read in can be linked to a containing namespace.
+ * we fetch all namespaces including system ones, so that every object we
+ * read in can be linked to a containing namespace.
*/
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
"(%s nspowner) as rolname, "
@@ -1734,8 +1729,8 @@ getTypes(int *numTypes)
int i_typisdefined;
/*
- * we include even the built-in types because those may be used as
- * array elements by user-defined types
+ * we include even the built-in types because those may be used as array
+ * elements by user-defined types
*
* we filter out the built-in types when we dump out the types
*
@@ -1751,7 +1746,7 @@ getTypes(int *numTypes)
"typnamespace, "
"(%s typowner) as rolname, "
"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 "
@@ -1764,7 +1759,7 @@ getTypes(int *numTypes)
"0::oid as typnamespace, "
"(%s typowner) as rolname, "
"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 "
@@ -1774,12 +1769,12 @@ getTypes(int *numTypes)
else
{
appendPQExpBuffer(query, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, "
+ "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, "
"oid, typname, "
"0::oid as typnamespace, "
"(%s typowner) as rolname, "
"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 "
@@ -1829,8 +1824,8 @@ 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
- * an ordinary type because that would bring the table up into the
+ * 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.)
*/
if (OidIsValid(tinfo[i].typrelid) && tinfo[i].typrelkind != 'c')
@@ -1860,9 +1855,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)
@@ -1970,7 +1965,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].rolname = strdup(PQgetvalue(res, i, i_rolname));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
@@ -2050,7 +2045,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].rolname = strdup(PQgetvalue(res, i, i_rolname));
}
@@ -2137,7 +2132,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].rolname = strdup(PQgetvalue(res, i, i_rolname));
if (g_fout->remoteVersion >= 70300)
@@ -2193,7 +2188,7 @@ getAggregates(int *numAggs)
"FROM pg_proc "
"WHERE proisagg "
"AND pronamespace != "
- "(select oid from pg_namespace where nspname = 'pg_catalog')",
+ "(select oid from pg_namespace where nspname = 'pg_catalog')",
username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
@@ -2247,13 +2242,12 @@ 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.rolname = strdup(PQgetvalue(res, i, i_rolname));
if (strlen(agginfo[i].aggfn.rolname) == 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));
@@ -2372,9 +2366,9 @@ getFuncs(int *numFuncs)
finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&finfo[i].dobj);
finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname));
- finfo[i].dobj.namespace =
+ finfo[i].dobj.namespace =
findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
- finfo[i].dobj.catId.oid);
+ finfo[i].dobj.catId.oid);
finfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype));
@@ -2390,8 +2384,8 @@ getFuncs(int *numFuncs)
}
if (strlen(finfo[i].rolname) == 0)
- write_msg(NULL,
- "WARNING: owner of function \"%s\" appears to be invalid\n",
+ write_msg(NULL,
+ "WARNING: owner of function \"%s\" appears to be invalid\n",
finfo[i].dobj.name);
}
@@ -2441,22 +2435,21 @@ getTables(int *numTables)
/*
* Find all the tables (including views and sequences).
*
- * We include system catalogs, so that we can work if a user table is
- * defined to inherit from a system catalog (pretty weird, but...)
+ * We include system catalogs, so that we can work if a user table is defined
+ * to inherit from a system catalog (pretty weird, but...)
*
* We ignore tables that are not type 'r' (ordinary relation), 'S'
* (sequence), 'v' (view), or 'c' (composite type).
*
- * Composite-type table entries won't be dumped as such, but we have
- * to make a DumpableObject for them so that we can track dependencies
- * of the composite type (pg_depend entries for columns of the composite
- * type link to the pg_class entry not the pg_type entry).
+ * Composite-type table entries won't be dumped as such, but we have to make
+ * a DumpableObject for them so that we can track dependencies of the
+ * composite type (pg_depend entries for columns of the composite type
+ * link to the pg_class entry not the pg_type entry).
*
- * Note: in this phase we should collect only a minimal amount of
- * information about each table, basically just enough to decide if it
- * is interesting. We must fetch all tables in this phase because
- * otherwise we cannot correctly identify inherited columns, serial
- * columns, etc.
+ * Note: in this phase we should collect only a minimal amount of information
+ * about each table, basically just enough to decide if it is interesting.
+ * We must fetch all tables in this phase because otherwise we cannot
+ * correctly identify inherited columns, serial columns, etc.
*/
if (g_fout->remoteVersion >= 80000)
@@ -2477,9 +2470,9 @@ getTables(int *numTables)
"from pg_class c "
"left join pg_depend d on "
"(c.relkind = '%c' and "
- "d.classid = c.tableoid and d.objid = c.oid and "
+ "d.classid = c.tableoid and d.objid = c.oid and "
"d.objsubid = 0 and "
- "d.refclassid = c.tableoid and d.deptype = 'i') "
+ "d.refclassid = c.tableoid and d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
username_subquery,
@@ -2505,9 +2498,9 @@ getTables(int *numTables)
"from pg_class c "
"left join pg_depend d on "
"(c.relkind = '%c' and "
- "d.classid = c.tableoid and d.objid = c.oid and "
+ "d.classid = c.tableoid and d.objid = c.oid and "
"d.objsubid = 0 and "
- "d.refclassid = c.tableoid and d.deptype = 'i') "
+ "d.refclassid = c.tableoid and d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
username_subquery,
@@ -2518,7 +2511,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, "
"(%s relowner) as rolname, "
"relchecks, reltriggers, "
@@ -2536,7 +2529,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, "
"(%s relowner) as rolname, "
"relchecks, reltriggers, "
@@ -2554,16 +2547,16 @@ getTables(int *numTables)
else
{
/*
- * Before 7.1, view relkind was not set to 'v', so we must check
- * if we have a view by looking for a rule in pg_rewrite.
+ * Before 7.1, view relkind was not set to 'v', so we must check if we
+ * have a view by looking for a rule in pg_rewrite.
*/
appendPQExpBuffer(query,
"SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
+ "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
"oid, relname, relacl, "
"CASE WHEN relhasrules and relkind = 'r' "
- " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
- " r.ev_class = c.oid AND r.ev_type = '1') "
+ " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
+ " r.ev_class = c.oid AND r.ev_type = '1') "
"THEN '%c'::\"char\" "
"ELSE relkind END AS relkind,"
"0::oid as relnamespace, "
@@ -2590,13 +2583,13 @@ getTables(int *numTables)
*numTables = ntups;
/*
- * Extract data from result and lock dumpable tables. We do the
- * locking before anything else, to minimize the window wherein a
- * table could disappear under us.
+ * Extract data from result and lock dumpable tables. We do the locking
+ * before anything else, to minimize the window wherein a table could
+ * disappear under us.
*
- * Note that we have to save info about all tables here, even when
- * dumping only one, because we don't yet know which tables might be
- * inheritance ancestors of the target table.
+ * Note that we have to save info about all tables here, even when dumping
+ * only one, because we don't yet know which tables might be inheritance
+ * ancestors of the target table.
*/
tblinfo = (TableInfo *) calloc(ntups, sizeof(TableInfo));
@@ -2624,7 +2617,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].rolname = strdup(PQgetvalue(res, i, i_rolname));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
@@ -2649,8 +2642,8 @@ getTables(int *numTables)
/*
* Decide whether we want to dump this table. Sequences owned by
- * serial columns are never dumpable on their own; we will
- * transpose their owning table's dump flag to them below.
+ * serial columns are never dumpable on their own; we will transpose
+ * their owning table's dump flag to them below.
*/
if (tblinfo[i].relkind == RELKIND_COMPOSITE_TYPE)
tblinfo[i].dump = false;
@@ -2661,11 +2654,11 @@ getTables(int *numTables)
tblinfo[i].interesting = tblinfo[i].dump;
/*
- * Read-lock target tables to make sure they aren't DROPPED or
- * altered in schema before we get around to dumping them.
+ * Read-lock target tables to make sure they aren't DROPPED or altered
+ * in schema before we get around to dumping them.
*
- * Note that we don't explicitly lock parents of the target tables;
- * we assume our lock on the child is enough to prevent schema
+ * Note that we don't explicitly lock parents of the target tables; we
+ * assume our lock on the child is enough to prevent schema
* alterations to parent tables.
*
* NOTE: it'd be kinda nice to lock views and sequences too, not only
@@ -2676,8 +2669,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);
}
@@ -2689,9 +2682,8 @@ 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)
{
@@ -2816,11 +2808,10 @@ getIndexes(TableInfo tblinfo[], int numTables)
selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
/*
- * 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 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.
*/
resetPQExpBuffer(query);
if (g_fout->remoteVersion >= 80000)
@@ -2828,7 +2819,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, "
"t.relname as indexname, "
- "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, i.indisclustered, "
"c.contype, c.conname, "
@@ -2836,7 +2827,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"c.oid as conoid, "
"(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) "
+ "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d "
"ON (d.classid = t.tableoid "
"AND d.objid = t.oid "
@@ -2853,7 +2844,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, "
"t.relname as indexname, "
- "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, "
+ "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, "
"t.relnatts as indnkeys, "
"i.indkey, i.indisclustered, "
"c.contype, c.conname, "
@@ -2861,7 +2852,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
"c.oid as conoid, "
"NULL as tablespace "
"FROM pg_catalog.pg_index i "
- "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
+ "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d "
"ON (d.classid = t.tableoid "
"AND d.objid = t.oid "
@@ -2878,7 +2869,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 "
@@ -2900,7 +2891,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 "
@@ -2955,11 +2946,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),
@@ -3058,7 +3049,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'",
@@ -3121,8 +3112,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);
@@ -3130,7 +3121,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",
@@ -3269,10 +3260,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)
@@ -3343,8 +3334,7 @@ getTriggers(TableInfo tblinfo[], int numTables)
tbinfo->dobj.name);
/*
- * select table schema to ensure regproc name is qualified if
- * needed
+ * select table schema to ensure regproc name is qualified if needed
*/
selectSourceSchema(tbinfo->dobj.namespace->dobj.name);
@@ -3352,16 +3342,15 @@ getTriggers(TableInfo tblinfo[], int numTables)
if (g_fout->remoteVersion >= 70300)
{
/*
- * We ignore triggers that are tied to a foreign-key
- * constraint
+ * We ignore triggers that are tied to a foreign-key constraint
*/
appendPQExpBuffer(query,
"SELECT tgname, "
"tgfoid::pg_catalog.regproc as tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, "
- "tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
- "tgconstrrelid::pg_catalog.regclass as tgconstrrelname "
+ "tgisconstraint, tgconstrname, tgdeferrable, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "tgconstrrelid::pg_catalog.regclass as tgconstrrelname "
"from pg_catalog.pg_trigger t "
"where tgrelid = '%u'::pg_catalog.oid "
"and (not tgisconstraint "
@@ -3374,11 +3363,11 @@ getTriggers(TableInfo tblinfo[], int numTables)
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query,
- "SELECT tgname, tgfoid::regproc as tgfname, "
+ "SELECT tgname, tgfoid::regproc as tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, "
- "tgisconstraint, tgconstrname, tgdeferrable, "
- "tgconstrrelid, tginitdeferred, tableoid, oid, "
- "(select relname from pg_class where oid = tgconstrrelid) "
+ "tgisconstraint, tgconstrname, tgdeferrable, "
+ "tgconstrrelid, tginitdeferred, tableoid, oid, "
+ "(select relname from pg_class where oid = tgconstrrelid) "
" as tgconstrrelname "
"from pg_trigger "
"where tgrelid = '%u'::oid",
@@ -3387,14 +3376,14 @@ getTriggers(TableInfo tblinfo[], int numTables)
else
{
appendPQExpBuffer(query,
- "SELECT tgname, tgfoid::regproc as tgfname, "
+ "SELECT tgname, tgfoid::regproc as tgfname, "
"tgtype, tgnargs, tgargs, tgenabled, "
- "tgisconstraint, tgconstrname, tgdeferrable, "
+ "tgisconstraint, tgconstrname, tgdeferrable, "
"tgconstrrelid, tginitdeferred, "
"(SELECT oid FROM pg_class WHERE relname = 'pg_trigger') AS tableoid, "
"oid, "
- "(select relname from pg_class where oid = tgconstrrelid) "
+ "(select relname from pg_class where oid = tgconstrrelid) "
" as tgconstrrelname "
"from pg_trigger "
"where tgrelid = '%u'::oid",
@@ -3624,7 +3613,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");
}
@@ -3660,9 +3649,9 @@ getCasts(int *numCasts)
castinfo[i].castcontext = *(PQgetvalue(res, i, i_castcontext));
/*
- * Try to name cast as concatenation of typnames. This is only
- * used for purposes of sorting. If we fail to find either type,
- * the name will be an empty string.
+ * Try to name cast as concatenation of typnames. This is only used
+ * for purposes of sorting. If we fail to find either type, the name
+ * will be an empty string.
*/
initPQExpBuffer(&namebuf);
sTypeInfo = findTypeByOid(castinfo[i].castsource);
@@ -3751,12 +3740,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/* find all the user attributes and their types */
/*
- * we must read the attribute names in attribute number order!
- * because we will use the attnum to index into the attnames array
- * later. We actually ask to order by "attrelid, attnum" because
- * (at least up to 7.3) the planner is not smart enough to realize
- * it needn't re-sort the output of an indexscan on
- * pg_attribute_relid_attnum_index.
+ * we must read the attribute names in attribute number order! because
+ * we will use the attnum to index into the attnames array later. We
+ * actually ask to order by "attrelid, attnum" because (at least up to
+ * 7.3) the planner is not smart enough to realize it needn't re-sort
+ * the output of an indexscan on pg_attribute_relid_attnum_index.
*/
if (g_verbose)
write_msg(NULL, "finding the columns and types of table \"%s\"\n",
@@ -3768,9 +3756,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{
/* need left join here to not fail on dropped columns ... */
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, "
- "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, "
- "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname "
- "from pg_catalog.pg_attribute a left join pg_catalog.pg_type t "
+ "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, "
+ "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname "
+ "from pg_catalog.pg_attribute a left join pg_catalog.pg_type t "
"on a.atttypid = t.oid "
"where a.attrelid = '%u'::pg_catalog.oid "
"and a.attnum > 0::pg_catalog.int2 "
@@ -3780,13 +3768,13 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
else if (g_fout->remoteVersion >= 70100)
{
/*
- * attstattarget doesn't exist in 7.1. It does exist in 7.2,
- * but we don't dump it because we can't tell whether it's
- * been explicitly set or was just a default.
+ * attstattarget doesn't exist in 7.1. It does exist in 7.2, but
+ * we don't dump it because we can't tell whether it's been
+ * explicitly set or was just a default.
*/
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 as attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, false as attisdropped, false as attislocal, "
- "format_type(t.oid,a.atttypmod) as atttypname "
+ "format_type(t.oid,a.atttypmod) as atttypname "
"from pg_attribute a left join pg_type t "
"on a.atttypid = t.oid "
"where a.attrelid = '%u'::oid "
@@ -3886,7 +3874,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_fout->remoteVersion >= 70300)
{
appendPQExpBuffer(q, "SELECT tableoid, oid, adnum, "
- "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc "
+ "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc "
"FROM pg_catalog.pg_attrdef "
"WHERE adrelid = '%u'::pg_catalog.oid",
tbinfo->dobj.catId.oid);
@@ -3940,11 +3928,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
attrdefs[j].dobj.namespace = tbinfo->dobj.namespace;
/*
- * 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.
+ * 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.
*/
if (tbinfo->relkind == RELKIND_VIEW)
{
@@ -3987,7 +3975,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' "
@@ -4068,11 +4056,12 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
constrs[j].conindex = 0;
constrs[j].coninherited = false;
constrs[j].separate = false;
+
/*
- * Mark the constraint as needing to appear before the
- * table --- this is so that any other dependencies of
- * the constraint will be emitted before we try to create
- * the table.
+ * Mark the constraint as needing to appear before the table
+ * --- this is so that any other dependencies of the
+ * constraint will be emitted before we try to create the
+ * table.
*/
addObjectDependency(&tbinfo->dobj,
constrs[j].dobj.dumpId);
@@ -4087,18 +4076,17 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
}
/*
- * Check to see if any columns are serial columns. Our first
- * quick filter is that it must be integer or bigint with a
- * default. If so, we scan to see if we found a sequence linked
- * to this column. If we did, mark the column and sequence
- * appropriately.
+ * Check to see if any columns are serial columns. Our first quick
+ * filter is that it must be integer or bigint with a default. If so,
+ * we scan to see if we found a sequence linked to this column. If we
+ * did, mark the column and sequence appropriately.
*/
for (j = 0; j < ntups; j++)
{
/*
* Note assumption that format_type will show these types as
- * exactly "integer" and "bigint" regardless of schema path.
- * This is correct in 7.3 but needs to be watched.
+ * exactly "integer" and "bigint" regardless of schema path. This
+ * is correct in 7.3 but needs to be watched.
*/
if (strcmp(tbinfo->atttypnames[j], "integer") != 0 &&
strcmp(tbinfo->atttypnames[j], "bigint") != 0)
@@ -4305,9 +4293,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;
@@ -4341,8 +4329,8 @@ findComments(Archive *fout, Oid classoid, Oid objoid,
/*
* Now determine how many items match the object. The search loop
- * invariant still holds: only items between low and high inclusive
- * could match.
+ * invariant still holds: only items between low and high inclusive could
+ * match.
*/
nmatch = 1;
while (middle > low)
@@ -4560,7 +4548,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
nspinfo->dobj.name,
- NULL, NULL,
+ NULL, NULL,
nspinfo->rolname,
false, "SCHEMA", q->data, delq->data, NULL,
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
@@ -4768,8 +4756,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
typstorage = PQgetvalue(res, 0, PQfnumber(res, "typstorage"));
/*
- * 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 TYPE %s.",
fmtId(tinfo->dobj.namespace->dobj.name));
@@ -4895,7 +4882,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
/* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(query, "SELECT typnotnull, "
- "pg_catalog.format_type(typbasetype, typtypmod) as typdefn, "
+ "pg_catalog.format_type(typbasetype, typtypmod) as typdefn, "
"typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
@@ -4942,14 +4929,13 @@ 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");
/*
- * 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 DOMAIN %s.",
fmtId(tinfo->dobj.namespace->dobj.name));
@@ -5002,8 +4988,8 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
/* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(query, "SELECT a.attname, "
- "pg_catalog.format_type(a.atttypid, a.atttypmod) as atttypdefn "
- "FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a "
+ "pg_catalog.format_type(a.atttypid, a.atttypmod) as atttypdefn "
+ "FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a "
"WHERE t.oid = '%u'::pg_catalog.oid "
"AND a.attrelid = t.typrelid "
"AND NOT a.attisdropped "
@@ -5042,8 +5028,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer(q, "\n);\n");
/*
- * 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 TYPE %s.",
fmtId(tinfo->dobj.namespace->dobj.name));
@@ -5084,7 +5069,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
*
* For some backwards compatibility with the older behavior, we forcibly
* dump a PL if its handler function (and validator if any) are in a
- * dumpable namespace. That case is not checked here.
+ * dumpable namespace. That case is not checked here.
*/
static bool
shouldDumpProcLangs(void)
@@ -5117,11 +5102,11 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
return;
/*
- * Try to find the support function(s). It is not an error if we
- * don't find them --- if the functions are in the pg_catalog schema,
- * as is standard in 8.1 and up, then we won't have loaded them.
- * (In this case we will emit a parameterless CREATE LANGUAGE command,
- * which will require PL template knowledge in the backend to reload.)
+ * Try to find the support function(s). It is not an error if we don't
+ * find them --- if the functions are in the pg_catalog schema, as is
+ * standard in 8.1 and up, then we won't have loaded them. (In this case
+ * we will emit a parameterless CREATE LANGUAGE command, which will
+ * require PL template knowledge in the backend to reload.)
*/
funcInfo = findFuncByOid(plang->lanplcallfoid);
@@ -5137,8 +5122,8 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
/*
* If the functions are dumpable then emit a traditional CREATE LANGUAGE
- * with parameters. Otherwise, dump only if shouldDumpProcLangs() says
- * to dump it.
+ * with parameters. Otherwise, dump only if shouldDumpProcLangs() says to
+ * dump it.
*/
useParams = (funcInfo != NULL &&
(validatorInfo != NULL || !OidIsValid(plang->lanvalidator)));
@@ -5152,9 +5137,9 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
qlanname = strdup(fmtId(plang->dobj.name));
/*
- * If dumping a HANDLER clause, treat the language as being in the
- * handler function's schema; this avoids cluttering the HANDLER clause.
- * Otherwise it doesn't really have a schema.
+ * If dumping a HANDLER clause, treat the language as being in the handler
+ * function's schema; this avoids cluttering the HANDLER clause. Otherwise
+ * it doesn't really have a schema.
*/
if (useParams)
lanschema = funcInfo->dobj.namespace->dobj.name;
@@ -5177,7 +5162,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));
}
@@ -5403,10 +5388,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
"null as proallargtypes, "
"null as proargmodes, "
"null as proargnames, "
- "case when proiscachable then 'i' else 'v' end as provolatile, "
+ "case when proiscachable then 'i' else 'v' end as provolatile, "
"proisstrict, "
"'f'::boolean as prosecdef, "
- "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname "
+ "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname "
"FROM pg_proc "
"WHERE oid = '%u'::oid",
finfo->dobj.catId.oid);
@@ -5418,10 +5403,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
"null as proallargtypes, "
"null as proargmodes, "
"null as proargnames, "
- "case when proiscachable then 'i' else 'v' end as provolatile, "
+ "case when proiscachable then 'i' else 'v' end as provolatile, "
"'f'::boolean as proisstrict, "
"'f'::boolean as prosecdef, "
- "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname "
+ "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname "
"FROM pg_proc "
"WHERE oid = '%u'::oid",
finfo->dobj.catId.oid);
@@ -5536,8 +5521,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
funcsig_tag = format_function_signature(finfo, false);
/*
- * 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(delqry, "DROP FUNCTION %s.%s;\n",
fmtId(finfo->dobj.namespace->dobj.name),
@@ -5640,9 +5624,9 @@ 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_".
+ * 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_".
*/
sourceInfo = findTypeByOid(cast->castsource);
targetInfo = findTypeByOid(cast->casttarget);
@@ -5660,8 +5644,7 @@ 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 &&
@@ -5702,8 +5685,8 @@ 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));
@@ -5827,9 +5810,9 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
{
appendPQExpBuffer(query, "SELECT oprkind, oprcode, "
"CASE WHEN oprleft = 0 THEN '-' "
- "ELSE format_type(oprleft, NULL) END as oprleft, "
+ "ELSE format_type(oprleft, NULL) END as oprleft, "
"CASE WHEN oprright = 0 THEN '-' "
- "ELSE format_type(oprright, NULL) END as oprright, "
+ "ELSE format_type(oprright, NULL) END as oprright, "
"oprcom, oprnegate, oprrest, oprjoin, "
"oprcanhash, oprlsortop, oprrsortop, "
"0 as oprltcmpop, 0 as oprgtcmpop "
@@ -5964,8 +5947,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
appendPQExpBuffer(details, ",\n GTCMP = %s", name);
/*
- * 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 OPERATOR %s.%s;\n",
fmtId(oprinfo->dobj.namespace->dobj.name),
@@ -5976,7 +5958,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
oprinfo->dobj.name,
- oprinfo->dobj.namespace->dobj.name,
+ oprinfo->dobj.namespace->dobj.name,
NULL,
oprinfo->rolname,
false, "OPERATOR", q->data, delq->data, NULL,
@@ -6146,7 +6128,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, "
"opckeytype::pg_catalog.regtype, "
"opcdefault, "
- "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcamid) AS amname "
+ "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcamid) AS amname "
"FROM pg_catalog.pg_opclass "
"WHERE oid = '%u'::pg_catalog.oid",
opcinfo->dobj.catId.oid);
@@ -6175,8 +6157,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
amname = strdup(PQgetvalue(res, 0, i_amname));
/*
- * 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 OPERATOR CLASS %s",
fmtId(opcinfo->dobj.namespace->dobj.name));
@@ -6285,7 +6266,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
opcinfo->dobj.name,
- opcinfo->dobj.namespace->dobj.name,
+ opcinfo->dobj.namespace->dobj.name,
NULL,
opcinfo->rolname,
false, "OPERATOR CLASS", q->data, delq->data, NULL,
@@ -6346,8 +6327,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",
@@ -6378,8 +6359,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
condefault = (PQgetvalue(res, 0, i_condefault)[0] == 't');
/*
- * 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 CONVERSION %s",
fmtId(convinfo->dobj.namespace->dobj.name));
@@ -6397,8 +6377,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
convinfo->dobj.name,
- convinfo->dobj.namespace->dobj.name,
- NULL,
+ convinfo->dobj.namespace->dobj.name,
+ NULL,
convinfo->rolname,
false, "CONVERSION", q->data, delq->data, NULL,
convinfo->dobj.dependencies, convinfo->dobj.nDeps,
@@ -6507,9 +6487,9 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
"aggsortop::pg_catalog.regoperator, "
"agginitval, "
"proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, "
- "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
+ "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
"'t'::boolean as convertok "
- "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
+ "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
"where a.aggfnoid = p.oid "
"and p.oid = '%u'::pg_catalog.oid",
agginfo->aggfn.dobj.catId.oid);
@@ -6521,9 +6501,9 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
"0 as aggsortop, "
"agginitval, "
"proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, "
- "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
+ "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
"'t'::boolean as convertok "
- "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
+ "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
"where a.aggfnoid = p.oid "
"and p.oid = '%u'::pg_catalog.oid",
agginfo->aggfn.dobj.catId.oid);
@@ -6531,12 +6511,12 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, "
- "format_type(aggtranstype, NULL) as aggtranstype, "
+ "format_type(aggtranstype, NULL) as aggtranstype, "
"0 as aggsortop, "
"agginitval, "
"aggbasetype = 0 as anybasetype, "
"CASE WHEN aggbasetype = 0 THEN '-' "
- "ELSE format_type(aggbasetype, NULL) END as fmtbasetype, "
+ "ELSE format_type(aggbasetype, NULL) END as fmtbasetype, "
"'t'::boolean as convertok "
"from pg_aggregate "
"where oid = '%u'::oid",
@@ -6649,8 +6629,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
}
/*
- * 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 AGGREGATE %s.%s;\n",
fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
@@ -6673,13 +6652,13 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
dumpComment(fout, q->data,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
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.
+ * 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.
*/
free(aggsig);
free(aggsig_tag);
@@ -6743,7 +6722,7 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
if (sql->len > 0)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag, nspname,
- NULL,
+ NULL,
owner ? owner : "",
false, "ACL", sql->data, "", NULL,
&(objDumpId), 1,
@@ -6915,8 +6894,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] &&
@@ -6928,8 +6907,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
/*
* Not Null constraint --- suppress if inherited
*
- * Note: we could suppress this for serial columns since
- * SERIAL implies NOT NULL. We choose not to for forward
+ * Note: we could suppress this for serial columns since SERIAL
+ * implies NOT NULL. We choose not to for forward
* compatibility, since there has been some talk of making
* SERIAL not imply NOT NULL, in which case the explicit
* specification would be needed.
@@ -6974,7 +6953,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));
}
@@ -6987,9 +6966,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
for (j = 0; j < tbinfo->numatts; j++)
{
/*
- * Dump per-column statistics information. We only issue an
- * ALTER TABLE statement if the attstattarget entry for this
- * column is non-negative (i.e. it's not the default value)
+ * Dump per-column statistics information. We only issue an ALTER
+ * TABLE statement if the attstattarget entry for this column is
+ * non-negative (i.e. it's not the default value)
*/
if (tbinfo->attstattarget[j] >= 0 &&
!tbinfo->attisdropped[j])
@@ -7004,8 +6983,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
/*
* Dump per-column storage information. The statement is only
- * dumped if the storage has been changed from the type's
- * default.
+ * dumped if the storage has been changed from the type's default.
*/
if (!tbinfo->attisdropped[j] && tbinfo->attstorage[j] != tbinfo->typstorage[j])
{
@@ -7028,8 +7006,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
/*
- * Only dump the statement if it's a storage type we
- * recognize
+ * Only dump the statement if it's a storage type we recognize
*/
if (storage != NULL)
{
@@ -7047,9 +7024,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
- (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
+ (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
tbinfo->rolname,
- (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);
@@ -7102,8 +7079,7 @@ 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));
@@ -7114,7 +7090,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tbinfo->attnames[adnum - 1],
- tbinfo->dobj.namespace->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
false, "DEFAULT", q->data, delq->data, NULL,
@@ -7178,9 +7154,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
delq = createPQExpBuffer();
/*
- * If there's an associated constraint, don't dump the index per se,
- * but do dump any comment for it. (This is safe because dependency
- * ordering will have ensured the constraint is emitted first.)
+ * If there's an associated constraint, don't dump the index per se, but
+ * do dump any comment for it. (This is safe because dependency ordering
+ * will have ensured the constraint is emitted first.)
*/
if (indxinfo->indexconstraint == 0)
{
@@ -7266,7 +7242,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++)
{
@@ -7316,8 +7292,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
else if (coninfo->contype == 'f')
{
/*
- * XXX Potentially wrap in a 'SET CONSTRAINTS OFF' block so that
- * the current table data is not processed
+ * XXX Potentially wrap in a 'SET CONSTRAINTS OFF' block so that the
+ * current table data is not processed
*/
appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n",
fmtId(tbinfo->dobj.name));
@@ -7450,7 +7426,7 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
- coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId);
+ coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId);
destroyPQExpBuffer(q);
}
@@ -7512,7 +7488,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)
@@ -7554,12 +7530,12 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query,
"SELECT sequence_name, last_value, increment_by, "
- "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
- " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
+ "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
+ " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value "
"END AS max_value, "
- "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
- " WHEN increment_by < 0 AND min_value = %s THEN NULL "
+ "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
+ " WHEN increment_by < 0 AND min_value = %s THEN NULL "
" ELSE min_value "
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
@@ -7599,12 +7575,12 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
/*
* The logic we use for restoring sequences is as follows:
*
- * Add a basic CREATE SEQUENCE statement (use last_val for start if
- * called is false, else use min_val for start_val). Skip this if the
- * sequence came from a SERIAL column.
+ * Add a basic CREATE SEQUENCE statement (use last_val for start if called is
+ * false, else use min_val for start_val). Skip this if the sequence came
+ * from a SERIAL column.
*
- * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load
- * data. We do this for serial sequences too.
+ * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load data.
+ * We do this for serial sequences too.
*/
if (!dataOnly && !OidIsValid(tbinfo->owning_tab))
@@ -7648,7 +7624,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
- tbinfo->dobj.namespace->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
false, "SEQUENCE", query->data, delqry->data, NULL,
@@ -7664,11 +7640,10 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
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)
@@ -7726,8 +7701,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
delqry = createPQExpBuffer();
/*
- * 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(delqry, "DROP TRIGGER %s ",
fmtId(tginfo->dobj.name));
@@ -7814,7 +7788,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
p = tginfo->tgargs;
for (findx = 0; findx < tginfo->tgnargs; findx++)
{
- const char *s = p, *s2 = p;
+ const char *s = p,
+ *s2 = p;
/* Set 'p' to end of arg string. marked by '\000' */
for (;;)
@@ -7834,7 +7809,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
p++;
continue;
}
- if (p[0] == '0' && p[1] == '0' && p[2] == '0') /* is it '\000'? */
+ if (p[0] == '0' && p[1] == '0' && p[2] == '0') /* is it '\000'? */
break;
}
p--;
@@ -7953,8 +7928,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
printfPQExpBuffer(cmd, "%s\n", PQgetvalue(res, 0, 0));
/*
- * 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(delcmd, "DROP RULE %s ",
fmtId(rinfo->dobj.name));
@@ -8039,8 +8013,8 @@ getDependencies(void)
/*
* Since we ordered the SELECT by referencing ID, we can expect that
- * multiple entries for the same object will appear together; this
- * saves on searches.
+ * multiple entries for the same object will appear together; this saves
+ * on searches.
*/
dobj = NULL;
@@ -8062,9 +8036,8 @@ 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)
{
@@ -8088,16 +8061,17 @@ getDependencies(void)
/*
* Ordinarily, table rowtypes have implicit dependencies on their
- * tables. However, for a composite type the implicit dependency
- * goes the other way in pg_depend; which is the right thing for
- * DROP but it doesn't produce the dependency ordering we need.
- * So in that one case, we reverse the direction of the dependency.
+ * tables. However, for a composite type the implicit dependency goes
+ * the other way in pg_depend; which is the right thing for DROP but
+ * it doesn't produce the dependency ordering we need. So in that one
+ * case, we reverse the direction of the dependency.
*/
if (deptype == 'i' &&
dobj->objType == DO_TABLE &&
refdobj->objType == DO_TYPE)
addObjectDependency(refdobj, dobj->dumpId);
- else /* normal case */
+ else
+ /* normal case */
addObjectDependency(dobj, refdobj->dumpId);
}
@@ -8276,8 +8250,8 @@ myFormatType(const char *typname, int32 typmod)
}
/*
- * char is an internal single-byte data type; Let's make sure we force
- * it through with quotes. - thomas 1998-12-13
+ * char is an internal single-byte data type; Let's make sure we force it
+ * through with quotes. - thomas 1998-12-13
*/
else if (strcmp(typname, "char") == 0)
appendPQExpBuffer(buf, "\"char\"");
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 1537fc3a39..a3d694d04f 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-2005, 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.121 2005/09/05 23:50:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.122 2005/10/15 02:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,9 +184,8 @@ typedef struct _tableInfo
bool dump; /* true if we want to dump it */
/*
- * These fields are computed only if we decide the table is
- * interesting (it's either a table to dump, or a direct parent of a
- * dumpable table).
+ * These fields are computed only if we decide the table is interesting
+ * (it's either a table to dump, or a direct parent of a dumpable table).
*/
int numatts; /* number of attributes */
char **attnames; /* the attribute names */
@@ -200,9 +199,9 @@ 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 */
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index b3029988a4..7e91d9bb79 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.10 2005/06/30 03:03:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.11 2005/10/15 02:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -128,8 +128,8 @@ DOTypeNameCompare(const void *p1, const void *p2)
/*
* Sort by namespace. Note that all objects of the same type should
- * either have or not have a namespace link, so we needn't be fancy
- * about cases where one link is null and the other not.
+ * either have or not have a namespace link, so we needn't be fancy about
+ * cases where one link is null and the other not.
*/
if (obj1->namespace && obj2->namespace)
{
@@ -248,17 +248,16 @@ TopoSort(DumpableObject **objs,
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 */
@@ -273,11 +272,11 @@ TopoSort(DumpableObject **objs,
exit_horribly(NULL, modulename, "out of memory\n");
/*
- * 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.
+ * 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.
*/
beforeConstraints = (int *) malloc((maxDumpId + 1) * sizeof(int));
if (beforeConstraints == NULL)
@@ -303,16 +302,15 @@ TopoSort(DumpableObject **objs,
}
/*
- * Now initialize the heap of items-ready-to-output by filling it with
- * the indexes of items that already have beforeConstraints[id] == 0.
+ * Now initialize the heap of items-ready-to-output by filling it with 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.
+ * 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.
*/
heapLength = 0;
for (i = numObjs; --i >= 0;)
@@ -355,8 +353,8 @@ TopoSort(DumpableObject **objs,
}
/*
- * If we failed, report the objects that couldn't be output; these are
- * the ones with beforeConstraints[] still nonzero.
+ * If we failed, report the objects that couldn't be output; these are the
+ * ones with beforeConstraints[] still nonzero.
*/
if (i != 0)
{
@@ -389,8 +387,8 @@ addHeapElement(int val, int *heap, int heapLength)
int j;
/*
- * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth
- * is using 1-based array indexes, not 0-based.
+ * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth is
+ * using 1-based array indexes, not 0-based.
*/
j = heapLength;
while (j > 0)
@@ -464,22 +462,20 @@ 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.
+ * 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
- * findLoop() from uselessly chasing references to such an object.
+ * 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...
+ * universe. This is probably overkill, but it's provably enough space...
*/
DumpableObject **workspace;
int initiallen;
@@ -510,10 +506,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++;
@@ -553,8 +549,8 @@ findLoop(DumpableObject *obj,
int i;
/*
- * Reject if obj is already present in workspace. This test serves
- * three purposes: it prevents us from finding loops that overlap
+ * Reject if obj is already present in workspace. This test serves three
+ * purposes: it prevents us from finding loops that overlap
* previously-processed loops, it prevents us from going into infinite
* recursion if we are given a startPoint object that links to a cycle
* it's not a member of, and it guarantees that we can't overflow the
@@ -572,8 +568,7 @@ findLoop(DumpableObject *obj,
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++)
{
@@ -630,10 +625,10 @@ repairTypeFuncLoop(DumpableObject *typeobj, DumpableObject *funcobj)
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
- * type and two or more functions, which repairDependencyLoop() is not
- * smart enough to handle.
+ * 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 type and
+ * two or more functions, which repairDependencyLoop() is not smart enough
+ * to handle.
*/
removeObjectDependency(&inputFuncInfo->dobj, typeobj->dumpId);
}
@@ -951,8 +946,8 @@ repairDependencyLoop(DumpableObject **loop,
}
/*
- * If we can't find a principled way to break the loop, complain and
- * break it in an arbitrary fashion.
+ * If we can't find a principled way to break the loop, complain and break
+ * it in an arbitrary fashion.
*/
write_msg(modulename, "WARNING: could not resolve dependency loop among these items:\n");
for (i = 0; i < nLoop; i++)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 1c55d5e0c1..d74e42fba5 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.68 2005/10/10 22:29:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.69 2005/10/15 02:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -55,21 +55,22 @@ static void dumpTimestamp(char *msg);
static int runPgDump(const char *dbname);
static PGconn *connectDatabase(const char *dbname, const char *pghost, const char *pgport,
- const char *pguser, bool require_password, bool fail_on_error);
+ const char *pguser, bool require_password, bool fail_on_error);
static PGresult *executeQuery(PGconn *conn, const char *query);
static void executeCommand(PGconn *conn, const char *query);
-static char pg_dump_bin[MAXPGPATH];
+static char pg_dump_bin[MAXPGPATH];
static PQExpBuffer pgdumpopts;
-static bool output_clean = false;
-static bool skip_acls = false;
-static bool verbose = false;
-static bool ignoreVersion = false;
+static bool output_clean = false;
+static bool skip_acls = false;
+static bool verbose = false;
+static bool ignoreVersion = false;
+
/* flags for -X long options */
-static int disable_dollar_quoting = 0;
-static int disable_triggers = 0;
-static int use_setsessauth = 0;
-static int server_version;
+static int disable_dollar_quoting = 0;
+static int disable_triggers = 0;
+static int use_setsessauth = 0;
+static int server_version;
int
@@ -107,8 +108,8 @@ main(int argc, char *argv[])
{"no-acl", no_argument, NULL, 'x'},
/*
- * the following options don't have an equivalent short option
- * letter, but are available as '-X long-name'
+ * the following options don't have an equivalent short option letter,
+ * but are available as '-X long-name'
*/
{"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
@@ -140,7 +141,7 @@ main(int argc, char *argv[])
if ((ret = find_other_exec(argv[0], "pg_dump", PG_VERSIONSTR,
pg_dump_bin)) < 0)
{
- char full_path[MAXPGPATH];
+ char full_path[MAXPGPATH];
if (find_my_exec(argv[0], full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH);
@@ -190,7 +191,7 @@ main(int argc, char *argv[])
#ifndef WIN32
appendPQExpBuffer(pgdumpopts, " -h '%s'", pghost);
#else
- appendPQExpBuffer(pgdumpopts, " -h \"%s\"", pghost);
+ appendPQExpBuffer(pgdumpopts, " -h \"%s\"", pghost);
#endif
break;
@@ -213,7 +214,7 @@ main(int argc, char *argv[])
#ifndef WIN32
appendPQExpBuffer(pgdumpopts, " -p '%s'", pgport);
#else
- appendPQExpBuffer(pgdumpopts, " -p \"%s\"", pgport);
+ appendPQExpBuffer(pgdumpopts, " -p \"%s\"", pgport);
#endif
break;
@@ -226,7 +227,7 @@ main(int argc, char *argv[])
#ifndef WIN32
appendPQExpBuffer(pgdumpopts, " -S '%s'", optarg);
#else
- appendPQExpBuffer(pgdumpopts, " -S \"%s\"", optarg);
+ appendPQExpBuffer(pgdumpopts, " -S \"%s\"", optarg);
#endif
break;
@@ -235,7 +236,7 @@ main(int argc, char *argv[])
#ifndef WIN32
appendPQExpBuffer(pgdumpopts, " -U '%s'", pguser);
#else
- appendPQExpBuffer(pgdumpopts, " -U \"%s\"", pguser);
+ appendPQExpBuffer(pgdumpopts, " -U \"%s\"", pguser);
#endif
break;
@@ -473,9 +474,9 @@ dumpRoles(PGconn *conn)
appendPQExpBuffer(buf, "DROP ROLE %s;\n", fmtId(rolename));
/*
- * We dump CREATE ROLE followed by ALTER ROLE to ensure that the
- * role will acquire the right properties even if it already exists.
- * (The above DROP may therefore seem redundant, but it isn't really,
+ * We dump CREATE ROLE followed by ALTER ROLE to ensure that the role
+ * will acquire the right properties even if it already exists. (The
+ * above DROP may therefore seem redundant, but it isn't really,
* because this technique doesn't get rid of role memberships.)
*/
appendPQExpBuffer(buf, "CREATE ROLE %s;\n", fmtId(rolename));
@@ -614,7 +615,7 @@ dumpGroups(PGconn *conn)
int j;
printfPQExpBuffer(buf,
- "SELECT usename FROM pg_shadow WHERE usesysid = %s",
+ "SELECT usename FROM pg_shadow WHERE usesysid = %s",
tok);
res2 = executeQuery(conn, buf->data);
@@ -729,7 +730,7 @@ dumpCreateDB(PGconn *conn)
"pg_encoding_to_char(d.encoding), "
"datistemplate, datacl, datconnlimit, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) "
+ "FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) "
"WHERE datallowconn ORDER BY 1");
else if (server_version >= 80000)
res = executeQuery(conn,
@@ -738,7 +739,7 @@ dumpCreateDB(PGconn *conn)
"pg_encoding_to_char(d.encoding), "
"datistemplate, datacl, -1 as datconnlimit, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
+ "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
"WHERE datallowconn ORDER BY 1");
else if (server_version >= 70300)
res = executeQuery(conn,
@@ -747,13 +748,13 @@ dumpCreateDB(PGconn *conn)
"pg_encoding_to_char(d.encoding), "
"datistemplate, datacl, -1 as datconnlimit, "
"'pg_default' AS dattablespace "
- "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
+ "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
"WHERE datallowconn ORDER BY 1");
else if (server_version >= 70100)
res = executeQuery(conn,
"SELECT datname, "
"coalesce("
- "(select usename from pg_shadow where usesysid=datdba), "
+ "(select usename from pg_shadow where usesysid=datdba), "
"(select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"datistemplate, '' as datacl, -1 as datconnlimit, "
@@ -763,12 +764,12 @@ dumpCreateDB(PGconn *conn)
else
{
/*
- * Note: 7.0 fails to cope with sub-select in COALESCE, so just
- * deal with getting a NULL by not printing any OWNER clause.
+ * Note: 7.0 fails to cope with sub-select in COALESCE, so just deal
+ * with getting a NULL by not printing any OWNER clause.
*/
res = executeQuery(conn,
"SELECT datname, "
- "(select usename from pg_shadow where usesysid=datdba), "
+ "(select usename from pg_shadow where usesysid=datdba), "
"pg_encoding_to_char(d.encoding), "
"'f' as datistemplate, "
"'' as datacl, -1 as datconnlimit, "
@@ -953,8 +954,7 @@ makeAlterConfigCommand(const char *arrayitem, const char *type, const char *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 (pg_strcasecmp(mine, "DateStyle") == 0
|| pg_strcasecmp(mine, "search_path") == 0)
@@ -1019,8 +1019,8 @@ runPgDump(const char *dbname)
/*
* 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 "postgres" which doesn't need quoting.
+ * Strangely enough, this is the only place we pass a database name on the
+ * command line, except "postgres" which doesn't need quoting.
*/
#ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
@@ -1087,8 +1087,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
password = simple_prompt("Password: ", 100, false);
/*
- * Start the connection. Loop until we have a password if requested
- * by backend.
+ * Start the connection. Loop until we have a password if requested by
+ * backend.
*/
do
{
@@ -1155,7 +1155,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
}
if (my_version != server_version
- && (server_version < 70000 /* we can handle back to 7.0 */
+ && (server_version < 70000 /* we can handle back to 7.0 */
|| server_version > my_version))
{
fprintf(stderr, _("server version: %s; %s version: %s\n"),
@@ -1170,8 +1170,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
}
/*
- * On 7.3 and later, make sure we are not fooled by non-system schemas
- * in the search path.
+ * On 7.3 and later, make sure we are not fooled by non-system schemas in
+ * the search path.
*/
if (server_version >= 70300)
executeCommand(conn, "SET search_path = pg_catalog");
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 85eca07ee7..c40ee7bbec 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.72 2005/09/28 13:11:26 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.73 2005/10/15 02:49:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,8 +113,8 @@ main(int argc, char **argv)
{"verbose", 0, NULL, 'v'},
/*
- * the following options don't have an equivalent short option
- * letter, but are available as '-X long-name'
+ * the following options don't have an equivalent short option letter,
+ * but are available as '-X long-name'
*/
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
@@ -150,8 +150,7 @@ main(int argc, char **argv)
case 'a': /* Dump data only */
opts->dataOnly = 1;
break;
- case 'c': /* clean (i.e., drop) schema prior to
- * create */
+ case 'c': /* clean (i.e., drop) schema prior to create */
opts->dropSchema = 1;
break;
case 'C':
@@ -331,8 +330,7 @@ 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;
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 5ee0a2749a..d70b0bb95e 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-2005, 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.37 2005/10/03 00:28:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.38 2005/10/15 02:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -73,7 +73,7 @@ main(int argc, char *argv[])
bool noupdate = false;
TransactionId set_xid = 0;
Oid set_oid = 0;
- MultiXactId set_mxid = 0;
+ MultiXactId set_mxid = 0;
MultiXactOffset set_mxoff = -1;
uint32 minXlogTli = 0,
minXlogId = 0,
@@ -213,11 +213,11 @@ main(int argc, char *argv[])
exit(1);
}
- /*
- * Don't allow pg_resetxlog to be run as root, to avoid
- * overwriting the ownership of files in the data directory. We
- * need only check for root -- any other user won't have
- * sufficient permissions to modify files in the data directory.
+ /*
+ * Don't allow pg_resetxlog to be run as root, to avoid overwriting the
+ * ownership of files in the data directory. We need only check for root
+ * -- any other user won't have sufficient permissions to modify files in
+ * the data directory.
*/
#ifndef WIN32
#ifndef __BEOS__ /* no root check on BeOS */
@@ -243,8 +243,7 @@ main(int argc, char *argv[])
/*
* Check for a postmaster lock file --- if there is one, refuse to
- * proceed, on grounds we might be interfering with a live
- * installation.
+ * proceed, on grounds we might be interfering with a live installation.
*/
snprintf(path, MAXPGPATH, "%s/postmaster.pid", DataDir);
@@ -271,8 +270,8 @@ main(int argc, char *argv[])
GuessControlValues();
/*
- * Adjust fields if required by switches. (Do this now so that
- * printout, if any, includes these values.)
+ * Adjust fields if required by switches. (Do this now so that printout,
+ * if any, includes these values.)
*/
if (set_xid != 0)
ControlFile.checkPointCopy.nextXid = set_xid;
@@ -319,8 +318,8 @@ main(int argc, char *argv[])
if (ControlFile.state != DB_SHUTDOWNED && !force)
{
printf(_("The database server was not shut down cleanly.\n"
- "Resetting the transaction log may cause data to be lost.\n"
- "If you want to proceed anyway, use -f to force reset.\n"));
+ "Resetting the transaction log may cause data to be lost.\n"
+ "If you want to proceed anyway, use -f to force reset.\n"));
exit(1);
}
@@ -353,9 +352,9 @@ ReadControlFile(void)
if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY)) < 0)
{
/*
- * If pg_control is not there at all, or we can't read it, the
- * odds are we've been handed a bad DataDir path, so give up. User
- * can do "touch pg_control" to force us to proceed.
+ * If pg_control is not there at all, or we can't read it, the odds
+ * are we've been handed a bad DataDir path, so give up. User can do
+ * "touch pg_control" to force us to proceed.
*/
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
progname, XLOG_CONTROL_FILE, strerror(errno));
@@ -380,7 +379,7 @@ ReadControlFile(void)
close(fd);
if (len >= sizeof(ControlFileData) &&
- ((ControlFileData *) buffer)->pg_control_version == PG_CONTROL_VERSION)
+ ((ControlFileData *) buffer)->pg_control_version == PG_CONTROL_VERSION)
{
/* Check the CRC. */
INIT_CRC32(crc);
@@ -431,8 +430,8 @@ GuessControlValues(void)
ControlFile.catalog_version_no = CATALOG_VERSION_NO;
/*
- * Create a new unique installation identifier, since we can no longer
- * use any old XLOG records. See notes in xlog.c about the algorithm.
+ * Create a new unique installation identifier, since we can no longer use
+ * any old XLOG records. See notes in xlog.c about the algorithm.
*/
gettimeofday(&tv, NULL);
sysidentifier = ((uint64) tv.tv_sec) << 32;
@@ -486,8 +485,8 @@ GuessControlValues(void)
StrNCpy(ControlFile.lc_ctype, localeptr, LOCALE_NAME_BUFLEN);
/*
- * XXX eventually, should try to grovel through old XLOG to develop
- * more accurate values for TimeLineID, nextXID, etc.
+ * XXX eventually, should try to grovel through old XLOG to develop more
+ * accurate values for TimeLineID, nextXID, etc.
*/
}
@@ -509,8 +508,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);
@@ -587,11 +586,11 @@ RewriteControlFile(void)
FIN_CRC32(ControlFile.crc);
/*
- * We write out BLCKSZ bytes into pg_control, zero-padding the excess
- * over sizeof(ControlFileData). This reduces the odds of
- * premature-EOF errors when reading pg_control. We'll still fail
- * when we check the contents of the file, but hopefully with a more
- * specific error than "couldn't read pg_control".
+ * We write out BLCKSZ bytes into pg_control, zero-padding the excess over
+ * sizeof(ControlFileData). This reduces the odds of premature-EOF errors
+ * when reading pg_control. We'll still fail when we check the contents
+ * of the file, but hopefully with a more specific error than "couldn't
+ * read pg_control".
*/
if (sizeof(ControlFileData) > BLCKSZ)
{
@@ -674,8 +673,8 @@ KillExistingXLOG(void)
#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;
diff --git a/src/bin/pgevent/pgevent.c b/src/bin/pgevent/pgevent.c
index d91840f99f..6ad93e55fd 100644
--- a/src/bin/pgevent/pgevent.c
+++ b/src/bin/pgevent/pgevent.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.4 2004/09/27 19:16:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.5 2005/10/15 02:49:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,8 +44,8 @@ DllRegisterServer(void)
}
/*
- * Add PostgreSQL source name as a subkey under the Application key in
- * the EventLog registry 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))
{
@@ -91,8 +91,8 @@ STDAPI
DllUnregisterServer(void)
{
/*
- * Remove PostgreSQL source name as a subkey under the Application key
- * in the EventLog registry key.
+ * 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"))
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c9a9e966d2..d9f8dda595 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,12 +3,12 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.153 2005/09/20 18:59:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.154 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
-#ifdef WIN32_CLIENT_ONLY /* needed for BCC */
+#ifdef WIN32_CLIENT_ONLY /* needed for BCC */
#undef mkdir
#endif
@@ -96,9 +96,9 @@ HandleSlashCmds(PsqlScanState scan_state,
if (status == CMD_UNKNOWN && strlen(cmd) > 1)
{
/*
- * If the command was not recognized, try to parse it as a
- * one-letter command with immediately following argument (a
- * still-supported, but no longer encouraged, syntax).
+ * If the command was not recognized, try to parse it as a one-letter
+ * command with immediately following argument (a still-supported, but
+ * no longer encouraged, syntax).
*/
char new_cmd[2];
@@ -205,13 +205,13 @@ exec_command(const char *cmd,
opt2q;
/*
- * Ideally we should treat the arguments as SQL identifiers. But
- * for backwards compatibility with 7.2 and older pg_dump files,
- * we have to take unquoted arguments verbatim (don't downcase
- * them). For now, double-quoted arguments may be stripped of
- * double quotes (as if SQL identifiers). By 7.4 or so, pg_dump
- * files can be expected to double-quote all mixed-case \connect
- * arguments, and then we can get rid of OT_SQLIDHACK.
+ * Ideally we should treat the arguments as SQL identifiers. But for
+ * backwards compatibility with 7.2 and older pg_dump files, we have
+ * to take unquoted arguments verbatim (don't downcase them). For now,
+ * double-quoted arguments may be stripped of double quotes (as if SQL
+ * identifiers). By 7.4 or so, pg_dump files can be expected to
+ * double-quote all mixed-case \connect arguments, and then we can get
+ * rid of OT_SQLIDHACK.
*/
opt1 = psql_scan_slash_option(scan_state,
OT_SQLIDHACK, &opt1q, true);
@@ -284,7 +284,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);
@@ -377,8 +377,8 @@ exec_command(const char *cmd,
/*
- * \e or \edit -- edit the current query buffer (or a file and make it
- * the query buffer
+ * \e or \edit -- edit the current query buffer (or a file and make it the
+ * query buffer
*/
else if (strcmp(cmd, "e") == 0 || strcmp(cmd, "edit") == 0)
{
@@ -416,7 +416,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;
@@ -438,7 +438,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)
{
@@ -466,7 +466,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);
@@ -476,7 +476,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;
@@ -493,7 +493,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);
@@ -601,7 +601,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);
@@ -732,7 +732,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);
@@ -843,7 +843,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)
@@ -854,7 +854,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);
@@ -867,8 +867,7 @@ exec_command(const char *cmd,
#if 0
/*
- * These commands don't do anything. I just use them to test the
- * parser.
+ * These commands don't do anything. I just use them to test the parser.
*/
else if (strcmp(cmd, "void") == 0 || strcmp(cmd, "#") == 0)
{
@@ -912,7 +911,7 @@ do_connect(const char *new_dbname, const char *new_user)
const char *dbparam = NULL;
const char *userparam = NULL;
const char *pwparam = NULL;
- char *password_prompt = NULL;
+ char *password_prompt = NULL;
char *prompted_password = NULL;
bool need_pass;
bool success = false;
@@ -932,13 +931,13 @@ do_connect(const char *new_dbname, const char *new_user)
else
userparam = new_user;
- if (userparam == NULL)
+ if (userparam == NULL)
password_prompt = strdup("Password: ");
else
{
password_prompt = malloc(strlen("Password for user %s: ") - 2 +
strlen(userparam) + 1);
- sprintf(password_prompt,"Password for user %s: ", userparam);
+ sprintf(password_prompt, "Password for user %s: ", userparam);
}
/* need to prompt for password? */
@@ -946,8 +945,8 @@ do_connect(const char *new_dbname, const char *new_user)
pwparam = prompted_password = simple_prompt(password_prompt, 100, false);
/*
- * Use old password (if any) if no new one given and we are
- * reconnecting as same user
+ * Use old password (if any) if no new one given and we are reconnecting
+ * as same user
*/
if (!pwparam && oldconn && PQuser(oldconn) && userparam &&
strcmp(PQuser(oldconn), userparam) == 0)
@@ -975,8 +974,8 @@ do_connect(const char *new_dbname, const char *new_user)
free(password_prompt);
/*
- * If connection failed, try at least keep the old one. That's
- * probably more convenient than just kicking you out of the program.
+ * If connection failed, try at least keep the old one. That's probably
+ * more convenient than just kicking you out of the program.
*/
if (!pset.db || PQstatus(pset.db) == CONNECTION_BAD)
{
@@ -995,8 +994,7 @@ do_connect(const char *new_dbname, const char *new_user)
else
{
/*
- * we don't want unpredictable things to happen in scripting
- * mode
+ * we don't want unpredictable things to happen in scripting mode
*/
psql_error("\\connect: %s", PQerrorMessage(pset.db));
PQfinish(pset.db);
@@ -1175,28 +1173,29 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
if (!tmpdir)
tmpdir = "/tmp";
#else
- char tmpdir[MAXPGPATH];
- int ret;
+ char tmpdir[MAXPGPATH];
+ int ret;
ret = GetTempPath(MAXPGPATH, tmpdir);
if (ret == 0 || ret > MAXPGPATH)
{
psql_error("cannot locate temporary directory: %s",
- !ret ? strerror(errno) : "");
+ !ret ? strerror(errno) : "");
return false;
}
+
/*
- * No canonicalize_path() here.
- * EDIT.EXE run from CMD.EXE prepends the current directory to the
- * supplied path unless we use only backslashes, so we do that.
+ * No canonicalize_path() here. EDIT.EXE run from CMD.EXE prepends the
+ * current directory to the supplied path unless we use only
+ * backslashes, so we do that.
*/
#endif
#ifndef WIN32
snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir,
- "/", (int)getpid());
+ "/", (int) getpid());
#else
snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir,
- "" /* trailing separator already present */, (int)getpid());
+ "" /* trailing separator already present */ , (int) getpid());
#endif
fname = (const char *) fnametmp;
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 886bcde178..2999c169ef 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.107 2005/10/13 20:58:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.108 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -48,7 +48,6 @@ typedef struct timeval TimevalStruct;
#define DIFF_MSEC(T, U) \
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
-
#else
typedef struct _timeb TimevalStruct;
@@ -188,7 +187,7 @@ setQFout(const char *fname)
*
*/
void
-psql_error(const char *fmt, ...)
+psql_error(const char *fmt,...)
{
va_list ap;
@@ -233,6 +232,7 @@ NoticeProcessor(void *arg, const char *message)
* thread is using it.
*/
static PGcancel *cancelConn = NULL;
+
#ifdef WIN32
static CRITICAL_SECTION cancelConnLock;
#endif
@@ -248,7 +248,7 @@ void
handle_sigint(SIGNAL_ARGS)
{
int save_errno = errno;
- char errbuf[256];
+ char errbuf[256];
/* Don't muck around if prompting for a password. */
if (prompt_state)
@@ -268,13 +268,12 @@ handle_sigint(SIGNAL_ARGS)
}
errno = save_errno; /* just in case the write changed it */
}
-
-#else /* WIN32 */
+#else /* WIN32 */
static BOOL WINAPI
consoleHandler(DWORD dwCtrlType)
{
- char errbuf[256];
+ char errbuf[256];
if (dwCtrlType == CTRL_C_EVENT ||
dwCtrlType == CTRL_BREAK_EVENT)
@@ -316,8 +315,7 @@ setup_cancel_handler(void)
{
SetConsoleCtrlHandler(consoleHandler, TRUE);
}
-
-#endif /* WIN32 */
+#endif /* WIN32 */
/* ConnectionUp
@@ -478,12 +476,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
initPQExpBuffer(&msg);
/*
- * The returned cursor position is measured in logical characters.
- * Each character might occupy multiple physical bytes in the string,
- * and in some Far Eastern character sets it might take more than one
- * screen column as well. We compute the starting byte offset and
- * starting screen column of each logical character, and store these
- * in qidx[] and scridx[] respectively.
+ * The returned cursor position is measured in logical characters. Each
+ * character might occupy multiple physical bytes in the string, and in
+ * some Far Eastern character sets it might take more than one screen
+ * column as well. We compute the starting byte offset and starting
+ * screen column of each logical character, and store these in qidx[] and
+ * scridx[] respectively.
*/
/* we need a safe allocation size... */
@@ -521,12 +519,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
/*
* Replace tabs with spaces in the writable copy. (Later we might
- * want to think about coping with their variable screen width,
- * but not today.)
+ * want to think about coping with their variable screen width, but
+ * not today.)
*
- * Extract line number and begin and end indexes of line containing
- * error location. There will not be any newlines or carriage
- * returns in the selected extract.
+ * Extract line number and begin and end indexes of line containing error
+ * location. There will not be any newlines or carriage returns in
+ * the selected extract.
*/
for (i = 0; i < clen; i++)
{
@@ -540,8 +538,8 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
if (i < loc)
{
/*
- * count lines before loc. Each \r or \n counts
- * as a line except when \r \n appear together.
+ * 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 ||
@@ -568,9 +566,9 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
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.
+ * 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)
{
@@ -682,6 +680,7 @@ AcceptResult(const PGresult *result, const char *query)
if (!OK)
{
const char *error = PQerrorMessage(pset.db);
+
if (strlen(error))
psql_error("%s", error);
@@ -957,13 +956,15 @@ PrintQueryResults(PGresult *results)
bool
SendQuery(const char *query)
{
- PGresult *results;
- TimevalStruct before, after;
- bool OK, on_error_rollback_savepoint = false;
+ PGresult *results;
+ TimevalStruct before,
+ after;
+ bool OK,
+ on_error_rollback_savepoint = false;
PGTransactionStatusType transaction_status;
- static bool on_error_rollback_warning = false;
+ static bool on_error_rollback_warning = false;
const char *rollback_str;
-
+
if (!pset.db)
{
psql_error("You are currently not connected to a database.\n");
@@ -975,8 +976,8 @@ SendQuery(const char *query)
char buf[3];
printf(_("***(Single step mode: verify command)*******************************************\n"
- "%s\n"
- "***(press return to proceed or enter x and return to cancel)********************\n"),
+ "%s\n"
+ "***(press return to proceed or enter x and return to cancel)********************\n"),
query);
fflush(stdout);
if (fgets(buf, sizeof(buf), stdin) != NULL)
@@ -1019,8 +1020,8 @@ SendQuery(const char *query)
}
if (transaction_status == PQTRANS_INTRANS &&
- (rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL &&
- /* !off and !interactive is 'on' */
+ (rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL &&
+ /* !off and !interactive is 'on' */
pg_strcasecmp(rollback_str, "off") != 0 &&
(pset.cur_cmd_interactive ||
pg_strcasecmp(rollback_str, "interactive") != 0))
@@ -1076,14 +1077,14 @@ SendQuery(const char *query)
results = NULL;
else
{
- /*
- * Do nothing if they are messing with savepoints themselves:
- * If the user did RELEASE or ROLLBACK, our savepoint is gone.
- * If they issued a SAVEPOINT, releasing ours would remove theirs.
+ /*
+ * Do nothing if they are messing with savepoints themselves: If
+ * the user did RELEASE or ROLLBACK, our savepoint is gone. If
+ * they issued a SAVEPOINT, releasing ours would remove theirs.
*/
if (strcmp(PQcmdStatus(results), "SAVEPOINT") == 0 ||
strcmp(PQcmdStatus(results), "RELEASE") == 0 ||
- strcmp(PQcmdStatus(results), "ROLLBACK") ==0)
+ strcmp(PQcmdStatus(results), "ROLLBACK") == 0)
results = NULL;
else
results = PQexec(pset.db, "RELEASE pg_psql_temporary_savepoint");
@@ -1126,19 +1127,19 @@ SendQuery(const char *query)
static const char *
skip_white_space(const char *query)
{
- int cnestlevel = 0; /* slash-star comment nest level */
+ int cnestlevel = 0; /* slash-star comment nest level */
while (*query)
{
- int mblen = PQmblen(query, pset.encoding);
+ int mblen = PQmblen(query, pset.encoding);
/*
- * Note: we assume the encoding is a superset of ASCII, so that
- * for example "query[0] == '/'" is meaningful. However, we do NOT
- * assume that the second and subsequent bytes of a multibyte
- * character couldn't look like ASCII characters; so it is critical
- * to advance by mblen, not 1, whenever we haven't exactly identified
- * the character we are skipping over.
+ * Note: we assume the encoding is a superset of ASCII, so that for
+ * example "query[0] == '/'" is meaningful. However, we do NOT assume
+ * that the second and subsequent bytes of a multibyte character
+ * couldn't look like ASCII characters; so it is critical to advance
+ * by mblen, not 1, whenever we haven't exactly identified the
+ * character we are skipping over.
*/
if (isspace((unsigned char) *query))
query += mblen;
@@ -1155,9 +1156,10 @@ skip_white_space(const char *query)
else if (cnestlevel == 0 && query[0] == '-' && query[1] == '-')
{
query += 2;
+
/*
- * We have to skip to end of line since any slash-star inside
- * the -- comment does NOT start a slash-star comment.
+ * We have to skip to end of line since any slash-star inside the
+ * -- comment does NOT start a slash-star comment.
*/
while (*query)
{
@@ -1204,12 +1206,12 @@ command_no_begin(const char *query)
wordlen += PQmblen(&query[wordlen], pset.encoding);
/*
- * Transaction control commands. These should include every keyword
- * that gives rise to a TransactionStmt in the backend grammar, except
- * for the savepoint-related commands.
+ * Transaction control commands. These should include every keyword that
+ * gives rise to a TransactionStmt in the backend grammar, except for the
+ * savepoint-related commands.
*
- * (We assume that START must be START TRANSACTION, since there is
- * presently no other "START foo" command.)
+ * (We assume that START must be START TRANSACTION, since there is presently
+ * no other "START foo" command.)
*/
if (wordlen == 5 && pg_strncasecmp(query, "abort", 5) == 0)
return true;
@@ -1240,12 +1242,12 @@ command_no_begin(const char *query)
}
/*
- * Commands not allowed within transactions. The statements checked
- * for here should be exactly those that call PreventTransactionChain()
- * in the backend.
+ * Commands not allowed within transactions. The statements checked for
+ * here should be exactly those that call PreventTransactionChain() in the
+ * backend.
*
- * Note: we are a bit sloppy about CLUSTER, which is transactional in
- * some variants but not others.
+ * Note: we are a bit sloppy about CLUSTER, which is transactional in some
+ * variants but not others.
*/
if (wordlen == 6 && pg_strncasecmp(query, "vacuum", 6) == 0)
return true;
@@ -1253,9 +1255,9 @@ command_no_begin(const char *query)
return true;
/*
- * Note: these tests will match CREATE SYSTEM, DROP SYSTEM, and
- * REINDEX TABLESPACE, which aren't really valid commands so we don't
- * care much. The other six possible matches are correct.
+ * Note: these tests will match CREATE SYSTEM, DROP SYSTEM, and REINDEX
+ * TABLESPACE, which aren't really valid commands so we don't care much.
+ * The other six possible matches are correct.
*/
if ((wordlen == 6 && pg_strncasecmp(query, "create", 6) == 0) ||
(wordlen == 4 && pg_strncasecmp(query, "drop", 4) == 0) ||
@@ -1339,9 +1341,9 @@ expand_tilde(char **filename)
return NULL;
/*
- * WIN32 doesn't use tilde expansion for file names.
- * Also, it uses tilde for short versions of long file names,
- * though the tilde is usually toward the end, not at the beginning.
+ * WIN32 doesn't use tilde expansion for file names. Also, it uses tilde
+ * for short versions of long file names, though the tilde is usually
+ * toward the end, not at the beginning.
*/
#ifndef WIN32
@@ -1367,7 +1369,7 @@ expand_tilde(char **filename)
if (*(fn + 1) == '\0')
get_home_path(home); /* ~ or ~/ only */
else if ((pw = getpwnam(fn + 1)) != NULL)
- StrNCpy(home, pw->pw_dir, MAXPGPATH); /* ~user */
+ StrNCpy(home, pw->pw_dir, MAXPGPATH); /* ~user */
*p = oldp;
if (strlen(home) != 0)
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index e819a23409..413dcce0c1 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.44 2005/06/13 06:36:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.45 2005/10/15 02:49:40 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
@@ -35,7 +35,7 @@ extern void *pg_calloc(size_t nmemb, size_t size);
extern bool setQFout(const char *fname);
extern void
-psql_error(const char *fmt, ...)
+psql_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 1, 2)));
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 0ebe248b0c..bd1763c5ac 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.57 2005/05/07 02:22:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.58 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -66,7 +66,7 @@ struct copy_options
bool binary;
bool oids;
bool csv_mode;
- bool header;
+ bool header;
char *delim;
char *null;
char *quote;
@@ -151,9 +151,8 @@ parse_slash_copy(const char *args)
goto error;
/*
- * strtokx() will not have returned a multi-character token starting
- * with '.', so we don't need strcmp() here. Likewise for '(', etc,
- * below.
+ * strtokx() will not have returned a multi-character token starting with
+ * '.', so we don't need strcmp() here. Likewise for '(', etc, below.
*/
if (token[0] == '.')
{
@@ -272,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,
@@ -672,7 +671,7 @@ handleCopyIn(PGconn *conn, FILE *copystream)
{
if (!QUIET())
puts(_("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
@@ -714,8 +713,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 9cd9858a71..d146b441f7 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.126 2005/10/04 19:01:18 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.127 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -37,8 +37,8 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
const char *schemavar, const char *namevar,
const char *altnamevar, const char *visibilityrule);
-static bool add_tablespace_footer(char relkind, Oid tablespace, char **footers,
- int *count, PQExpBufferData buf, bool newline);
+static bool add_tablespace_footer(char relkind, Oid tablespace, char **footers,
+ int *count, PQExpBufferData buf, bool newline);
/*----------------
* Handlers for various slash commands displaying some sort of list
@@ -62,20 +62,20 @@ describeAggregates(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
/*
- * There are two kinds of aggregates: ones that work on particular
- * types and ones that work on all (denoted by input type = "any")
+ * There are two kinds of aggregates: ones that work on particular types
+ * and ones that work on all (denoted by input type = "any")
*/
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" p.proname AS \"%s\",\n"
" CASE p.proargtypes[0]\n"
- " WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype\n"
+ " WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype\n"
" THEN CAST('%s' AS pg_catalog.text)\n"
- " ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n"
+ " ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n"
" END AS \"%s\",\n"
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
+ " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
"FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
"WHERE p.proisagg\n",
_("Schema"), _("Name"), _("(all types)"),
_("Data type"), _("Description"));
@@ -121,7 +121,7 @@ describeTablespaces(const char *pattern, bool verbose)
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"));
@@ -170,9 +170,9 @@ describeFunctions(const char *pattern, bool verbose)
"SELECT n.nspname as \"%s\",\n"
" p.proname as \"%s\",\n"
" CASE WHEN p.proretset THEN 'setof ' ELSE '' END ||\n"
- " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
+ " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\"",
- _("Schema"), _("Name"), _("Result data type"),
+ _("Schema"), _("Name"), _("Result data type"),
_("Argument data types"));
if (verbose)
@@ -180,7 +180,7 @@ describeFunctions(const char *pattern, bool verbose)
",\n r.rolname as \"%s\",\n"
" l.lanname as \"%s\",\n"
" p.prosrc as \"%s\",\n"
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
+ " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
_("Owner"), _("Language"),
_("Source code"), _("Description"));
@@ -191,16 +191,15 @@ describeFunctions(const char *pattern, bool verbose)
else
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_proc p"
- "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace"
- "\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang"
- "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n");
+ "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace"
+ "\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang"
+ "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n");
/*
- * we skip in/out funcs by excluding functions that take or return
- * cstring
+ * we skip in/out funcs by excluding functions that take or return cstring
*/
appendPQExpBuffer(&buf,
- "WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
+ "WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND (p.proargtypes[0] IS NULL\n"
" OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n"
" AND NOT p.proisagg\n");
@@ -242,7 +241,7 @@ describeTypes(const char *pattern, bool verbose)
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
- " pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n",
+ " pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n",
_("Schema"), _("Name"));
if (verbose)
appendPQExpBuffer(&buf,
@@ -255,16 +254,15 @@ describeTypes(const char *pattern, bool verbose)
" END AS \"%s\",\n",
_("Internal name"), _("Size"));
appendPQExpBuffer(&buf,
- " pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n",
+ " pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n",
_("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
/*
* do not include array types (start with underscore); do not include
- * complex types (typrelid!=0) unless they are standalone composite
- * types
+ * complex types (typrelid!=0) unless they are standalone composite types
*/
appendPQExpBuffer(&buf, "WHERE (t.typrelid = 0 ");
appendPQExpBuffer(&buf, "OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c "
@@ -311,11 +309,11 @@ describeOperators(const char *pattern)
" o.oprname AS \"%s\",\n"
" CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
" CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
- " pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
- " coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
- " pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
+ " pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
+ " coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
+ " pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
"FROM pg_catalog.pg_operator o\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
_("Schema"), _("Name"),
_("Left arg type"), _("Right arg type"),
_("Result type"), _("Description"));
@@ -360,7 +358,7 @@ listAllDbs(bool verbose)
" r.rolname as \"%s\"",
_("Name"), _("Owner"));
appendPQExpBuffer(&buf,
- ",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
+ ",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
_("Encoding"));
if (verbose)
appendPQExpBuffer(&buf,
@@ -368,7 +366,7 @@ listAllDbs(bool verbose)
_("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_database d"
- "\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n"
+ "\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n"
"ORDER BY 1;");
res = PSQLexec(buf.data, false);
@@ -400,8 +398,7 @@ permissionsList(const char *pattern)
initPQExpBuffer(&buf);
/*
- * we ignore indexes and toast tables since they have no meaningful
- * rights
+ * we ignore indexes and toast tables since they have no meaningful rights
*/
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
@@ -409,19 +406,19 @@ permissionsList(const char *pattern)
" CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'S' THEN '%s' END as \"%s\",\n"
" c.relacl as \"%s\"\n"
"FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
"WHERE c.relkind IN ('r', 'v', 'S')\n",
_("Schema"), _("Name"), _("table"), _("view"), _("sequence"), _("Type"), _("Access privileges"));
/*
* Unless a schema pattern is specified, we suppress system and temp
- * tables, since they normally aren't very interesting from a
- * permissions point of view. You can see 'em by explicit request
- * though, eg with \z pg_catalog.*
+ * tables, since they normally aren't very interesting from a permissions
+ * point of view. You can see 'em by explicit request though, eg with \z
+ * pg_catalog.*
*/
processNamePattern(&buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
- "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
+ "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
@@ -465,7 +462,7 @@ objectDescription(const char *pattern)
appendPQExpBuffer(&buf,
"SELECT DISTINCT tt.nspname AS \"%s\", tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n"
"FROM (\n",
- _("Schema"), _("Name"), _("Object"), _("Description"));
+ _("Schema"), _("Name"), _("Object"), _("Description"));
/* Aggregate descriptions */
appendPQExpBuffer(&buf,
@@ -474,7 +471,7 @@ objectDescription(const char *pattern)
" CAST(p.proname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
" WHERE p.proisagg\n",
_("aggregate"));
processNamePattern(&buf, pattern, true, false,
@@ -489,9 +486,9 @@ objectDescription(const char *pattern)
" CAST(p.proname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
- " WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
+ " WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND (p.proargtypes[0] IS NULL\n"
" OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n"
" AND NOT p.proisagg\n",
@@ -508,7 +505,7 @@ objectDescription(const char *pattern)
" CAST(o.oprname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_operator o\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
_("operator"));
processNamePattern(&buf, pattern, false, false,
"n.nspname", "o.oprname", NULL,
@@ -522,10 +519,10 @@ objectDescription(const char *pattern)
" pg_catalog.format_type(t.oid, NULL) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n",
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n",
_("data type"));
processNamePattern(&buf, pattern, false, false,
- "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL,
+ "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL,
"pg_catalog.pg_type_is_visible(t.oid)");
/* Relation (tables, views, indexes, sequences) descriptions */
@@ -538,7 +535,7 @@ objectDescription(const char *pattern)
" CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' END"
" AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
" WHERE c.relkind IN ('r', 'v', 'i', 'S')\n",
_("table"), _("view"), _("index"), _("sequence"));
processNamePattern(&buf, pattern, true, false,
@@ -553,8 +550,8 @@ objectDescription(const char *pattern)
" CAST(r.rulename AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_rewrite r\n"
- " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
" WHERE r.rulename != '_RETURN'\n",
_("rule"));
/* XXX not sure what to do about visibility rule here? */
@@ -570,8 +567,8 @@ objectDescription(const char *pattern)
" CAST(t.tgname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_trigger t\n"
- " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n",
+ " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n",
_("trigger"));
/* XXX not sure what to do about visibility rule here? */
processNamePattern(&buf, pattern, false, false,
@@ -622,7 +619,7 @@ describeTableDetails(const char *pattern, bool verbose)
" n.nspname,\n"
" c.relname\n"
"FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
processNamePattern(&buf, pattern, false, false,
"n.nspname", "c.relname", NULL,
@@ -712,7 +709,7 @@ describeOneTableDetails(const char *schemaname,
/* Get general table info */
printfPQExpBuffer(&buf,
- "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
+ "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
"relhasoids %s \n"
"FROM pg_catalog.pg_class WHERE oid = '%s'",
pset.sversion >= 80000 ? ", reltablespace" : "",
@@ -886,7 +883,7 @@ describeOneTableDetails(const char *schemaname,
break;
default:
printfPQExpBuffer(&title, _("?%c? \"%s.%s\""),
- tableinfo.relkind, schemaname, relationname);
+ tableinfo.relkind, schemaname, relationname);
break;
}
@@ -898,9 +895,9 @@ describeOneTableDetails(const char *schemaname,
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"
+ " 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"
+ "WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
"AND i.indrelid = c2.oid",
oid);
@@ -962,7 +959,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n"
"FROM pg_catalog.pg_rewrite r\n"
- "WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1",
+ "WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1",
oid);
result = PSQLexec(buf.data, false);
if (!result)
@@ -1023,10 +1020,10 @@ describeOneTableDetails(const char *schemaname,
{
printfPQExpBuffer(&buf,
"SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, "
- "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true), c2.reltablespace\n"
+ "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true), c2.reltablespace\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",
+ "ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname",
oid);
result1 = PSQLexec(buf.data, false);
if (!result1)
@@ -1040,10 +1037,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' ORDER BY 1",
+ "WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1",
oid);
result2 = PSQLexec(buf.data, false);
if (!result2)
@@ -1078,7 +1075,7 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.triggers)
{
printfPQExpBuffer(&buf,
- "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n"
+ "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n"
"FROM pg_catalog.pg_trigger t\n"
"WHERE t.tgrelid = '%s' "
"AND (not tgisconstraint "
@@ -1105,9 +1102,9 @@ 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' ORDER BY 1",
+ "WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1",
oid);
result5 = PSQLexec(buf.data, false);
if (!result5)
@@ -1143,7 +1140,7 @@ describeOneTableDetails(const char *schemaname,
{
const char *indexdef;
const char *usingpos;
- PQExpBufferData tmpbuf;
+ PQExpBufferData tmpbuf;
/* Output index name */
printfPQExpBuffer(&buf, _(" \"%s\""),
@@ -1151,11 +1148,11 @@ describeOneTableDetails(const char *schemaname,
/* Label as primary key or unique (but not both) */
appendPQExpBuffer(&buf,
- strcmp(PQgetvalue(result1, i, 1), "t") == 0
+ strcmp(PQgetvalue(result1, i, 1), "t") == 0
? " PRIMARY KEY," :
- (strcmp(PQgetvalue(result1, i, 2), "t") == 0
- ? " UNIQUE,"
- : ""));
+ (strcmp(PQgetvalue(result1, i, 2), "t") == 0
+ ? " UNIQUE,"
+ : ""));
/* Everything after "USING" is echoed verbatim */
indexdef = PQgetvalue(result1, i, 4);
usingpos = strstr(indexdef, " USING ");
@@ -1170,9 +1167,9 @@ describeOneTableDetails(const char *schemaname,
/* Print tablespace of the index on the same line */
count_footers += 1;
initPQExpBuffer(&tmpbuf);
- if (add_tablespace_footer('i',
- atooid(PQgetvalue(result1, i, 5)),
- footers, &count_footers, tmpbuf, false))
+ if (add_tablespace_footer('i',
+ atooid(PQgetvalue(result1, i, 5)),
+ footers, &count_footers, tmpbuf, false))
{
appendPQExpBuffer(&buf, ", ");
appendPQExpBuffer(&buf, tmpbuf.data);
@@ -1335,9 +1332,9 @@ error_return:
}
-/*
- * Return true if the relation uses non default tablespace;
- * otherwise return false
+/*
+ * Return true if the relation uses non default tablespace;
+ * otherwise return false
*/
static bool
add_tablespace_footer(char relkind, Oid tablespace, char **footers,
@@ -1347,8 +1344,8 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers,
if (relkind == 'r' || relkind == 'i')
{
/*
- * We ignore the database default tablespace so that users not
- * using tablespaces don't need to know about them.
+ * We ignore the database default tablespace so that users not using
+ * tablespaces don't need to know about them.
*/
if (tablespace != 0)
{
@@ -1362,9 +1359,9 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers,
/* Should always be the case, but.... */
if (PQntuples(result1) > 0)
{
- printfPQExpBuffer(&buf,
- newline?_("Tablespace: \"%s\""):_("tablespace \"%s\""),
- PQgetvalue(result1, 0, 0));
+ printfPQExpBuffer(&buf,
+ newline ? _("Tablespace: \"%s\"") : _("tablespace \"%s\""),
+ PQgetvalue(result1, 0, 0));
footers[(*count)++] = pg_strdup(buf.data);
}
@@ -1393,19 +1390,19 @@ describeRoles(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT r.rolname AS \"%s\",\n"
- " CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n"
+ " CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n"
" ELSE CAST(r.rolconnlimit AS pg_catalog.text)\n"
" END AS \"%s\", \n"
" ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as \"%s\"\n"
"FROM pg_catalog.pg_roles r\n",
_("Role name"),
- _("yes"),_("no"),_("Superuser"),
- _("yes"),_("no"),_("Create role"),
- _("yes"),_("no"),_("Create DB"),
- _("no limit"),_("Connections"),
+ _("yes"), _("no"), _("Superuser"),
+ _("yes"), _("no"), _("Create role"),
+ _("yes"), _("no"), _("Create DB"),
+ _("no limit"), _("Connections"),
_("Member of"));
processNamePattern(&buf, pattern, false, false,
@@ -1475,17 +1472,17 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
if (verbose)
appendPQExpBuffer(&buf,
- ",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
+ ",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
_("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_class c"
- "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner"
- "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
+ "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner"
+ "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
if (showIndexes)
appendPQExpBuffer(&buf,
- "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
- "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid");
+ "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
+ "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid");
appendPQExpBuffer(&buf, "\nWHERE c.relkind IN (");
if (showTables)
@@ -1503,9 +1500,8 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
/*
* If showSystem is specified, show only system objects (those in
- * pg_catalog). Otherwise, suppress system objects, including those
- * in pg_catalog and pg_toast. (We don't want to hide temp tables
- * though.)
+ * pg_catalog). Otherwise, suppress system objects, including those in
+ * pg_catalog and pg_toast. (We don't want to hide temp tables though.)
*/
if (showSystem)
appendPQExpBuffer(&buf, " AND n.nspname = 'pg_catalog'\n");
@@ -1560,16 +1556,16 @@ listDomains(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
- " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n"
+ " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n"
" CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault\n"
- " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n"
+ " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n"
" WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n"
" ELSE ''\n"
" END as \"%s\",\n"
- " pg_catalog.pg_get_constraintdef(r.oid, true) as \"%s\"\n"
+ " pg_catalog.pg_get_constraintdef(r.oid, true) as \"%s\"\n"
"FROM pg_catalog.pg_type t\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"
- " LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"
+ " LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid\n"
"WHERE t.typtype = 'd'\n",
_("Schema"),
_("Name"),
@@ -1614,11 +1610,11 @@ listConversions(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.conname AS \"%s\",\n"
- " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n"
- " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n"
+ " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n"
+ " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n"
" CASE WHEN c.condefault THEN '%s'\n"
" ELSE '%s' END AS \"%s\"\n"
- "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n"
+ "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n"
"WHERE n.oid = c.connamespace\n",
_("Schema"),
_("Name"),
@@ -1663,8 +1659,8 @@ listCasts(const char *pattern)
initPQExpBuffer(&buf);
/* NEED LEFT JOIN FOR BINARY CASTS */
printfPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
- " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
+ "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
+ " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
" CASE WHEN castfunc = 0 THEN '%s'\n"
" ELSE p.proname\n"
" END as \"%s\",\n"
@@ -1672,7 +1668,7 @@ listCasts(const char *pattern)
" WHEN c.castcontext = 'a' THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"\n"
- "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
+ "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
" ON c.castfunc = p.oid\n"
"ORDER BY 1, 2",
_("Source type"),
@@ -1719,14 +1715,14 @@ listSchemas(const char *pattern, bool verbose)
if (verbose)
appendPQExpBuffer(&buf,
",\n n.nspacl as \"%s\","
- " pg_catalog.obj_description(n.oid, 'pg_namespace') 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_roles r\n"
+ "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_roles r\n"
" ON n.nspowner=r.oid\n"
"WHERE (n.nspname !~ '^pg_temp_' OR\n"
- " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
+ " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
processNamePattern(&buf, pattern, true, false,
NULL, "n.nspname", NULL,
@@ -1796,9 +1792,9 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
initPQExpBuffer(&namebuf);
/*
- * Parse the pattern, converting quotes and lower-casing unquoted
- * letters; we assume this was NOT done by scan_option. Also, adjust
- * shell-style wildcard characters into regexp notation.
+ * Parse the pattern, converting quotes and lower-casing unquoted letters;
+ * we assume this was NOT done by scan_option. Also, adjust shell-style
+ * wildcard characters into regexp notation.
*/
inquotes = false;
cp = pattern;
@@ -1845,12 +1841,11 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
/*
* Ordinary data character, transfer to pattern
*
- * Inside double quotes, or at all times if parsing an operator
- * name, quote regexp special characters with a backslash to
- * avoid regexp errors. Outside quotes, however, let them
- * pass through as-is; this lets knowledgeable users build
- * regexp expressions that are more powerful than shell-style
- * patterns.
+ * Inside double quotes, or at all times if parsing an operator name,
+ * quote regexp special characters with a backslash to avoid
+ * regexp errors. Outside quotes, however, let them pass through
+ * as-is; this lets knowledgeable users build regexp expressions
+ * that are more powerful than shell-style patterns.
*/
if ((inquotes || force_escape) &&
strchr("|*+?()[]{}.^$\\", *cp))
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 7d6cc7e4a0..879cdecd0e 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.105 2005/07/18 20:57:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.106 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -138,7 +138,7 @@ usage(void)
puts(_(
"\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n"
- "(for SQL commands) from within psql, or consult the psql section in\n"
+ "(for SQL commands) from within psql, or consult the psql section in\n"
"the PostgreSQL documentation.\n\n"
"Report bugs to <pgsql-bugs@postgresql.org>."));
}
@@ -168,12 +168,12 @@ slashUsage(unsigned short int pager)
/* if you add/remove a line here, change the row count above */
/*
- * if this " is the start of the string then it ought to end there to
- * fit in 80 columns >> "
+ * if this " is the start of the string then it ought to end there to fit
+ * in 80 columns >> "
*/
fprintf(output, _("General\n"));
fprintf(output, _(" \\c[onnect] [DBNAME|- [USER]]\n"
- " connect to new database (currently \"%s\")\n"),
+ " connect to new database (currently \"%s\")\n"),
PQdb(pset.db));
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n"));
@@ -205,13 +205,13 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\i FILE execute commands from file\n"));
fprintf(output, _(" \\o [FILE] send all query results to file or |pipe\n"));
fprintf(output, _(" \\qecho [STRING]\n"
- " write string to query output stream (see \\o)\n"));
+ " write string to query output stream (see \\o)\n"));
fprintf(output, "\n");
fprintf(output, _("Informational\n"));
fprintf(output, _(" \\d [NAME] describe table, index, sequence, or view\n"));
fprintf(output, _(" \\d{t|i|s|v|S} [PATTERN] (add \"+\" for more detail)\n"
- " list tables/indexes/sequences/views/system tables\n"));
+ " list tables/indexes/sequences/views/system tables\n"));
fprintf(output, _(" \\da [PATTERN] list aggregate functions\n"));
fprintf(output, _(" \\db [PATTERN] list tablespaces (add \"+\" for more detail)\n"));
fprintf(output, _(" \\dc [PATTERN] list conversions\n"));
@@ -239,7 +239,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"
- " numericlocale|recordsep|tuples_only|title|tableattr|pager})\n"));
+ " numericlocale|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"));
@@ -252,7 +252,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)
{
@@ -291,7 +291,7 @@ helpSQL(const char *topic, unsigned short int pager)
VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd));
if (i + 2 * items_per_column < QL_HELP_COUNT)
fprintf(output, "%-26s",
- VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd));
+ VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd));
fputc('\n', output);
}
/* Only close if we used the pager */
@@ -305,78 +305,82 @@ helpSQL(const char *topic, unsigned short int pager)
}
else
{
- int i,j,x=0;
+ int i,
+ j,
+ x = 0;
bool help_found = false;
FILE *output;
- size_t len, wordlen;
+ size_t len,
+ wordlen;
int nl_count = 0;
char *ch;
/* User gets two chances: exact match, then the first word */
-
+
/* First pass : strip trailing spaces and semicolons */
len = strlen(topic);
while (topic[len - 1] == ' ' || topic[len - 1] == ';')
- len--;
+ len--;
- for (x=1; x<=3; x++) /* Three chances to guess that word... */
+ for (x = 1; x <= 3; x++) /* Three chances to guess that word... */
{
- if (x>1) /* Nothing on first pass - try the opening words */
+ if (x > 1) /* Nothing on first pass - try the opening
+ * words */
+ {
+ wordlen = j = 1;
+ while (topic[j] != ' ' && j++ < len)
+ wordlen++;
+ if (x == 2)
{
- wordlen=j=1;
- while (topic[j] != ' ' && j++<len)
- wordlen++;
- if (x==2)
- {
- j++;
- while (topic[j] != ' ' && j++<=len)
- wordlen++;
- }
- if (wordlen >= len) /* Don't try again if the same word */
- {
- output = PageOutput(nl_count, pager);
- break;
- }
- len = wordlen;
+ j++;
+ while (topic[j] != ' ' && j++ <= len)
+ wordlen++;
}
-
- /* Count newlines for pager */
- for (i = 0; QL_HELP[i].cmd; i++)
+ if (wordlen >= len) /* Don't try again if the same word */
{
- if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
- strcmp(topic, "*") == 0)
- {
- nl_count += 5;
- for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++)
- if (*ch == '\n')
- nl_count++;
- /* If we have an exact match, exit. Fixes \h SELECT */
- if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
- break;
- }
+ output = PageOutput(nl_count, pager);
+ break;
}
-
- output = PageOutput(nl_count, pager);
-
- for (i = 0; QL_HELP[i].cmd; i++)
+ len = wordlen;
+ }
+
+ /* Count newlines for pager */
+ for (i = 0; QL_HELP[i].cmd; i++)
+ {
+ if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
+ strcmp(topic, "*") == 0)
{
- if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
- strcmp(topic, "*") == 0)
- {
- help_found = true;
- fprintf(output, _("Command: %s\n"
- "Description: %s\n"
- "Syntax:\n%s\n\n"),
- QL_HELP[i].cmd,
- _(QL_HELP[i].help),
- _(QL_HELP[i].syntax));
- /* If we have an exact match, exit. Fixes \h SELECT */
- if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
- break;
- }
+ nl_count += 5;
+ for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++)
+ if (*ch == '\n')
+ nl_count++;
+ /* If we have an exact match, exit. Fixes \h SELECT */
+ if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
+ break;
}
- if (help_found) /* Don't keep trying if we got a match */
+ }
+
+ output = PageOutput(nl_count, pager);
+
+ for (i = 0; QL_HELP[i].cmd; i++)
+ {
+ if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
+ strcmp(topic, "*") == 0)
+ {
+ help_found = true;
+ fprintf(output, _("Command: %s\n"
+ "Description: %s\n"
+ "Syntax:\n%s\n\n"),
+ QL_HELP[i].cmd,
+ _(QL_HELP[i].help),
+ _(QL_HELP[i].syntax));
+ /* If we have an exact match, exit. Fixes \h SELECT */
+ if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break;
+ }
+ }
+ if (help_found) /* Don't keep trying if we got a match */
+ break;
}
if (!help_found)
@@ -403,8 +407,8 @@ print_copyright(void)
"Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group\n\n"
"This software is based on Postgres95, formerly known as Postgres, which\n"
"contains the following notice:\n\n"
- "Portions Copyright(c) 1994, Regents of the University of California\n\n"
- "Permission to use, copy, modify, and distribute this software and its\n"
+ "Portions Copyright(c) 1994, Regents of the University of California\n\n"
+ "Permission to use, copy, modify, and distribute this software and its\n"
"documentation for any purpose, without fee, and without a written agreement\n"
"is hereby granted, provided that the above copyright notice and this paragraph\n"
"and the following two paragraphs appear in all copies.\n\n"
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 2da977612c..4272fcb2e5 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.45 2005/06/10 15:40:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.46 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
@@ -24,7 +24,7 @@
#ifdef USE_READLINE
static bool useReadline;
static bool useHistory;
-char *psql_history;
+char *psql_history;
enum histcontrol
@@ -105,7 +105,7 @@ gets_interactive(const char *prompt)
HC = GetHistControlConfig();
if (((HC & hctl_ignorespace) && s[0] == ' ') ||
- ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0))
+ ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0))
{
/* Ignore this line as far as history is concerned */
}
@@ -221,7 +221,7 @@ saveHistory(char *fname)
psql_error("could not save history to file \"%s\": %s\n", fname, strerror(errno));
}
#else
- psql_error("history is not supported by this installation\n");
+ psql_error("history is not supported by this installation\n");
#endif
return false;
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c
index 8bdcdc3682..b4c9027a63 100644
--- a/src/bin/psql/large_obj.c
+++ b/src/bin/psql/large_obj.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.39 2005/07/02 17:01:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.40 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
@@ -122,8 +122,8 @@ do_lo_export(const char *loid_arg, const char *filename_arg)
status = lo_export(pset.db, atooid(loid_arg), filename_arg);
if (status != 1)
- { /* of course this status is documented
- * nowhere :( */
+ { /* of course this status is documented nowhere
+ * :( */
fputs(PQerrorMessage(pset.db), stderr);
return fail_lo_xact("\\lo_export", own_transaction);
}
@@ -254,7 +254,7 @@ do_lo_list(void)
snprintf(buf, sizeof(buf),
"SELECT loid as \"ID\",\n"
- " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n"
+ " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n"
"FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n"
"ORDER BY 1",
_("Description"));
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index fad71c1120..775701a010 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.67 2005/02/22 04:40:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.68 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -35,8 +35,8 @@ MainLoop(FILE *source)
{
PsqlScanState scan_state; /* lexer working state */
PQExpBuffer query_buf; /* buffer for query being accumulated */
- PQExpBuffer previous_buf; /* if there isn't anything in the new
- * buffer yet, use this one for \e, etc. */
+ PQExpBuffer previous_buf; /* if there isn't anything in the new buffer
+ * yet, use this one for \e, etc. */
char *line; /* current line of input */
int added_nl_pos;
bool success;
@@ -117,12 +117,10 @@ MainLoop(FILE *source)
}
/*
- * establish the control-C handler only after main_loop_jmp is
- * ready
+ * establish the control-C handler only after main_loop_jmp is ready
*/
pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
-
-#else /* WIN32 */
+#else /* WIN32 */
setup_cancel_handler();
#endif
@@ -156,9 +154,8 @@ MainLoop(FILE *source)
line = gets_fromFile(source);
/*
- * query_buf holds query already accumulated. line is the
- * malloc'd new line of input (note it must be freed before
- * looping around!)
+ * query_buf holds query already accumulated. line is the malloc'd
+ * new line of input (note it must be freed before looping around!)
*/
/* No more input. Time to quit, or \i done */
@@ -225,8 +222,8 @@ MainLoop(FILE *source)
prompt_status = prompt_tmp;
/*
- * Send command if semicolon found, or if end of line and
- * we're in single-line mode.
+ * Send command if semicolon found, or if end of line and we're in
+ * single-line mode.
*/
if (scan_result == PSCAN_SEMICOLON ||
(scan_result == PSCAN_EOL &&
@@ -247,11 +244,10 @@ 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';
@@ -259,7 +255,7 @@ MainLoop(FILE *source)
slashCmdStatus = HandleSlashCmds(scan_state,
query_buf->len > 0 ?
- query_buf : previous_buf);
+ query_buf : previous_buf);
success = slashCmdStatus != CMD_ERROR;
@@ -326,10 +322,10 @@ MainLoop(FILE *source)
}
/*
- * Reset SIGINT handler because main_loop_jmp will be invalid as soon
- * as we exit this routine. If there is an outer MainLoop instance,
- * it will re-enable ^C catching as soon as it gets back to the top of
- * its loop and resets main_loop_jmp to point to itself.
+ * Reset SIGINT handler because main_loop_jmp will be invalid as soon as
+ * we exit this routine. If there is an outer MainLoop instance, it will
+ * re-enable ^C catching as soon as it gets back to the top of its loop
+ * and resets main_loop_jmp to point to itself.
*/
#ifndef WIN32
pqsignal(SIGINT, SIG_DFL);
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
index dd4bfca211..7bced92a6d 100644
--- a/src/bin/psql/mbprint.c
+++ b/src/bin/psql/mbprint.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.17 2005/09/24 17:53:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.18 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
@@ -140,8 +140,7 @@ ucs_wcwidth(pg_wchar ucs)
return 0;
/*
- * if we arrive here, ucs is not a combining or C0/C1 control
- * character
+ * if we arrive here, ucs is not a combining or C0/C1 control character
*/
return 1 +
@@ -217,10 +216,9 @@ utf_charcheck(const unsigned char *c)
{
/*
* Unicode 3.1 compliant validation : for each category, it checks the
- * combination of each byte to make sur it maps to a valid range. It
- * also returns -1 for the following UCS values: ucs > 0x10ffff ucs &
- * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800
- * (surrogates)
+ * combination of each byte to make sur it maps to a valid range. It also
+ * returns -1 for the following UCS values: ucs > 0x10ffff ucs & 0xfffe =
+ * 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 (surrogates)
*/
if ((*c & 0x80) == 0)
return 1;
@@ -245,7 +243,7 @@ utf_charcheck(const unsigned char *c)
/* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */
if (((z == 0x0f) &&
(((yx & 0xffe) == 0xffe) ||
- (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
+ (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) ||
((z == 0x0d) && ((yx & 0xb00) == 0x800)))
return -1;
return 3;
@@ -318,8 +316,8 @@ pg_wcswidth(const char *pwcs, size_t len, int encoding)
else
{
/*
- * obviously, other encodings may want to fix this, but I don't
- * know them myself, unfortunately.
+ * obviously, other encodings may want to fix this, but I don't know
+ * them myself, unfortunately.
*/
return len;
}
@@ -333,8 +331,8 @@ mbvalidate(char *pwcs, int encoding)
else
{
/*
- * other encodings needing validation should add their own
- * routines here
+ * other encodings needing validation should add their own routines
+ * here
*/
}
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 9c8000d7b7..3d2a1fa175 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.77 2005/10/04 19:01:18 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.78 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -52,11 +52,11 @@ pg_local_malloc(size_t size)
static int
integer_digits(const char *my_str)
{
- int frac_len;
+ int frac_len;
if (my_str[0] == '-')
my_str++;
-
+
frac_len = strchr(my_str, '.') ? strlen(strchr(my_str, '.')) : 0;
return strlen(my_str) - frac_len;
@@ -66,17 +66,18 @@ integer_digits(const char *my_str)
static int
additional_numeric_locale_len(const char *my_str)
{
- int int_len = integer_digits(my_str), len = 0;
- int groupdigits = atoi(grouping);
+ int int_len = integer_digits(my_str),
+ len = 0;
+ int groupdigits = atoi(grouping);
if (int_len > 0)
/* Don't count a leading separator */
len = (int_len / groupdigits - (int_len % groupdigits == 0)) *
- strlen(thousands_sep);
+ strlen(thousands_sep);
if (strchr(my_str, '.') != NULL)
len += strlen(decimal_point) - strlen(".");
-
+
return len;
}
@@ -89,23 +90,27 @@ strlen_with_numeric_locale(const char *my_str)
static char *
format_numeric_locale(const char *my_str)
{
- int i, j, int_len = integer_digits(my_str), leading_digits;
- int groupdigits = atoi(grouping);
- int new_str_start = 0;
- char *new_str = new_str = pg_local_malloc(
- strlen_with_numeric_locale(my_str) + 1);
+ int i,
+ j,
+ int_len = integer_digits(my_str),
+ leading_digits;
+ int groupdigits = atoi(grouping);
+ int new_str_start = 0;
+ char *new_str = new_str = pg_local_malloc(
+ strlen_with_numeric_locale(my_str) + 1);
leading_digits = (int_len % groupdigits != 0) ?
- int_len % groupdigits : groupdigits;
+ int_len % groupdigits : groupdigits;
- if (my_str[0] == '-') /* skip over sign, affects grouping calculations */
+ if (my_str[0] == '-') /* skip over sign, affects grouping
+ * calculations */
{
new_str[0] = my_str[0];
my_str++;
new_str_start = 1;
}
- for (i=0, j=new_str_start; ; i++, j++)
+ for (i = 0, j = new_str_start;; i++, j++)
{
/* Hit decimal point? */
if (my_str[i] == '.')
@@ -123,7 +128,7 @@ format_numeric_locale(const char *my_str)
new_str[j] = '\0';
break;
}
-
+
/* Add separator? */
if (i != 0 && (i - leading_digits) % groupdigits == 0)
{
@@ -133,7 +138,7 @@ format_numeric_locale(const char *my_str)
new_str[j] = my_str[i];
}
-
+
return new_str;
}
@@ -143,15 +148,15 @@ format_numeric_locale(const char *my_str)
static void
-print_unaligned_text(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
+print_unaligned_text(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
const char *opt_align, const char *opt_fieldsep,
const char *opt_recordsep, bool opt_tuples_only,
bool opt_numeric_locale, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
bool need_recordsep = false;
if (!opt_fieldsep)
@@ -188,14 +193,14 @@ print_unaligned_text(const char *title, const char *const *headers,
}
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
fputs(my_cell, fout);
free(my_cell);
}
else
fputs(*ptr, fout);
-
+
if ((i + 1) % col_count)
fputs(opt_fieldsep, fout);
else
@@ -225,15 +230,15 @@ print_unaligned_text(const char *title, const char *const *headers,
static void
-print_unaligned_vertical(const char *title, const char *const *headers,
- const char *const *cells,
- const char *const *footers, const char *opt_align,
+print_unaligned_vertical(const char *title, const char *const * headers,
+ const char *const * cells,
+ const char *const * footers, const char *opt_align,
const char *opt_fieldsep, const char *opt_recordsep,
- bool opt_tuples_only, bool opt_numeric_locale, FILE *fout)
+ bool opt_tuples_only, bool opt_numeric_locale, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
if (!opt_fieldsep)
opt_fieldsep = "";
@@ -262,7 +267,7 @@ print_unaligned_vertical(const char *title, const char *const *headers,
fputs(opt_fieldsep, fout);
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
fputs(my_cell, fout);
free(my_cell);
@@ -329,9 +334,9 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
static void
-print_aligned_text(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale,
+print_aligned_text(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
+ const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale,
unsigned short int opt_border, int encoding,
FILE *fout)
{
@@ -343,7 +348,7 @@ print_aligned_text(const char *title, const char *const *headers,
tmp;
unsigned int *widths,
total_w;
- const char *const *ptr;
+ const char *const * ptr;
/* count columns */
for (ptr = headers; *ptr; ptr++)
@@ -398,13 +403,13 @@ print_aligned_text(const char *title, const char *const *headers,
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
- int add_numeric_locale_len;
+ int add_numeric_locale_len;
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
- add_numeric_locale_len = additional_numeric_locale_len(*ptr);
- else
- add_numeric_locale_len = 0;
-
+ add_numeric_locale_len = additional_numeric_locale_len(*ptr);
+ else
+ add_numeric_locale_len = 0;
+
tmp = pg_wcswidth(*ptr, strlen(*ptr), encoding) + add_numeric_locale_len;
if (tmp > widths[i % col_count])
widths[i % col_count] = tmp;
@@ -485,9 +490,9 @@ print_aligned_text(const char *title, const char *const *headers,
/* content */
if (opt_align[i % col_count] == 'r')
{
- if (opt_numeric_locale)
- {
- char *my_cell = format_numeric_locale(*ptr);
+ if (opt_numeric_locale)
+ {
+ char *my_cell = format_numeric_locale(*ptr);
fprintf(fout, "%*s%s", widths[i % col_count] - cell_w[i], "", my_cell);
free(my_cell);
@@ -532,8 +537,7 @@ print_aligned_text(const char *title, const char *const *headers,
#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
@@ -547,15 +551,15 @@ print_aligned_text(const char *title, const char *const *headers,
static void
-print_aligned_vertical(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
+print_aligned_vertical(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_tuples_only,
bool opt_numeric_locale, unsigned short int opt_border,
int encoding, FILE *fout)
{
unsigned int col_count = 0;
unsigned int record = 1;
- const char *const *ptr;
+ const char *const * ptr;
unsigned int i,
tmp = 0,
hwidth = 0,
@@ -613,11 +617,11 @@ print_aligned_vertical(const char *title, const char *const *headers,
/* find longest data cell */
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
- int add_numeric_locale_len;
+ int add_numeric_locale_len;
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
add_numeric_locale_len = additional_numeric_locale_len(*ptr);
- else
+ else
add_numeric_locale_len = 0;
tmp = pg_wcswidth(*ptr, strlen(*ptr), encoding) + add_numeric_locale_len;
@@ -696,8 +700,8 @@ print_aligned_vertical(const char *title, const char *const *headers,
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
-
+ char *my_cell = format_numeric_locale(*ptr);
+
if (opt_border < 2)
fprintf(fout, "%s\n", my_cell);
else
@@ -746,8 +750,8 @@ void
html_escaped_print(const char *in, FILE *fout)
{
const char *p;
- bool leading_space = true;
-
+ bool leading_space = true;
+
for (p = in; *p; p++)
{
switch (*p)
@@ -788,15 +792,15 @@ html_escaped_print(const char *in, FILE *fout)
static void
-print_html_text(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
+print_html_text(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_tuples_only,
bool opt_numeric_locale, unsigned short int opt_border,
const char *opt_table_attr, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
fprintf(fout, "<table border=\"%d\"", opt_border);
if (opt_table_attr)
@@ -835,14 +839,14 @@ print_html_text(const char *title, const char *const *headers,
fprintf(fout, " <td align=\"%s\">", opt_align[(i) % col_count] == 'r' ? "right" : "left");
/* is string only whitespace? */
- if ((*ptr)[strspn(*ptr, " \t")] == '\0')
+ if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs("&nbsp; ", fout);
else if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
- html_escaped_print(my_cell, fout);
- free(my_cell);
+ html_escaped_print(my_cell, fout);
+ free(my_cell);
}
else
html_escaped_print(*ptr, fout);
@@ -873,16 +877,16 @@ print_html_text(const char *title, const char *const *headers,
static void
-print_html_vertical(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only,
- bool opt_numeric_locale, unsigned short int opt_border,
- const char *opt_table_attr, FILE *fout)
+print_html_vertical(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
+ const char *opt_align, bool opt_tuples_only,
+ bool opt_numeric_locale, unsigned short int opt_border,
+ const char *opt_table_attr, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
unsigned int record = 1;
- const char *const *ptr;
+ const char *const * ptr;
fprintf(fout, "<table border=\"%d\"", opt_border);
if (opt_table_attr)
@@ -918,14 +922,14 @@ print_html_vertical(const char *title, const char *const *headers,
fprintf(fout, " <td align=\"%s\">", opt_align[i % col_count] == 'r' ? "right" : "left");
/* is string only whitespace? */
- if ((*ptr)[strspn(*ptr, " \t")] == '\0')
+ if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs("&nbsp; ", fout);
else if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
- html_escaped_print(my_cell, fout);
- free(my_cell);
+ html_escaped_print(my_cell, fout);
+ free(my_cell);
}
else
html_escaped_print(*ptr, fout);
@@ -996,15 +1000,15 @@ latex_escaped_print(const char *in, FILE *fout)
static void
-print_latex_text(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
+print_latex_text(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_tuples_only,
bool opt_numeric_locale, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
/* print title */
@@ -1062,7 +1066,7 @@ print_latex_text(const char *title, const char *const *headers,
{
if (opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
latex_escaped_print(my_cell, fout);
free(my_cell);
@@ -1097,15 +1101,15 @@ print_latex_text(const char *title, const char *const *headers,
static void
-print_latex_vertical(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only,
- bool opt_numeric_locale, unsigned short int opt_border,
- FILE *fout)
+print_latex_vertical(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
+ const char *opt_align, bool opt_tuples_only,
+ bool opt_numeric_locale, unsigned short int opt_border,
+ FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
unsigned int record = 1;
(void) opt_align; /* currently unused parameter */
@@ -1173,7 +1177,7 @@ print_latex_vertical(const char *title, const char *const *headers,
{
if (opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
latex_escaped_print(my_cell, fout);
free(my_cell);
@@ -1212,15 +1216,15 @@ troff_ms_escaped_print(const char *in, FILE *fout)
static void
-print_troff_ms_text(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only,
- bool opt_numeric_locale, unsigned short int opt_border,
- FILE *fout)
+print_troff_ms_text(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
+ const char *opt_align, bool opt_tuples_only,
+ bool opt_numeric_locale, unsigned short int opt_border,
+ FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
/* print title */
@@ -1271,7 +1275,7 @@ print_troff_ms_text(const char *title, const char *const *headers,
{
if (opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
troff_ms_escaped_print(my_cell, fout);
free(my_cell);
@@ -1303,17 +1307,17 @@ print_troff_ms_text(const char *title, const char *const *headers,
static void
-print_troff_ms_vertical(const char *title, const char *const *headers,
- const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only,
- bool opt_numeric_locale, unsigned short int opt_border,
- FILE *fout)
+print_troff_ms_vertical(const char *title, const char *const * headers,
+ const char *const * cells, const char *const * footers,
+ const char *opt_align, bool opt_tuples_only,
+ bool opt_numeric_locale, unsigned short int opt_border,
+ FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
- const char *const *ptr;
+ const char *const * ptr;
unsigned int record = 1;
- unsigned short current_format = 0; /* 0=none, 1=header, 2=body */
+ unsigned short current_format = 0; /* 0=none, 1=header, 2=body */
(void) opt_align; /* currently unused parameter */
@@ -1333,8 +1337,8 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
fputs("center;\n", fout);
/* basic format */
- if (opt_tuples_only)
- fputs("c l;\n", fout);
+ if (opt_tuples_only)
+ fputs("c l;\n", fout);
/* count columns */
for (ptr = headers; *ptr; ptr++)
@@ -1381,7 +1385,7 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
fputc('\t', fout);
if (opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(*ptr);
+ char *my_cell = format_numeric_locale(*ptr);
troff_ms_escaped_print(my_cell, fout);
free(my_cell);
@@ -1462,16 +1466,16 @@ PageOutput(int lines, unsigned short int pager)
void
printTable(const char *title,
- const char *const *headers,
- const char *const *cells,
- const char *const *footers,
+ const char *const * headers,
+ const char *const * cells,
+ const char *const * footers,
const char *align,
const printTableOpt *opt, FILE *fout, FILE *flog)
{
const char *default_footer[] = {NULL};
unsigned short int border = opt->border;
FILE *output;
- bool use_expanded;
+ bool use_expanded;
if (opt->format == PRINT_NOTHING)
return;
@@ -1483,9 +1487,9 @@ printTable(const char *title,
border = 2;
/*
- * We only want to display the results in "expanded" format if
- * this is a normal (user-submitted) query, not a table we're
- * printing for a slash command.
+ * We only want to display the results in "expanded" format if this is a
+ * normal (user-submitted) query, not a table we're printing for a slash
+ * command.
*/
if (opt->expanded && opt->normal_query)
use_expanded = true;
@@ -1497,7 +1501,7 @@ printTable(const char *title,
int col_count = 0,
row_count = 0,
lines;
- const char *const *ptr;
+ const char *const * ptr;
/* rough estimate of columns and rows */
if (headers)
@@ -1532,16 +1536,16 @@ printTable(const char *title,
if (use_expanded)
print_unaligned_vertical(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, opt->numericLocale, output);
+ opt->tuples_only, opt->numericLocale, output);
else
print_unaligned_text(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, opt->numericLocale, output);
+ opt->tuples_only, opt->numericLocale, output);
break;
case PRINT_ALIGNED:
if (use_expanded)
print_aligned_vertical(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericLocale, border,
+ opt->tuples_only, opt->numericLocale, border,
opt->encoding, output);
else
print_aligned_text(title, headers, cells, footers, align,
@@ -1555,7 +1559,7 @@ printTable(const char *title,
border, opt->tableAttr, output);
else
print_html_text(title, headers, cells, footers,
- align, opt->tuples_only, opt->numericLocale, border,
+ align, opt->tuples_only, opt->numericLocale, border,
opt->tableAttr, output);
break;
case PRINT_LATEX:
@@ -1714,7 +1718,7 @@ setDecimalLocale(void)
if (*extlconv->grouping && atoi(extlconv->grouping) > 0)
grouping = strdup(extlconv->grouping);
else
- grouping = "3"; /* most common */
+ grouping = "3"; /* most common */
if (*extlconv->thousands_sep)
thousands_sep = strdup(extlconv->thousands_sep);
else if (*decimal_point != ',')
@@ -1722,5 +1726,3 @@ setDecimalLocale(void)
else
thousands_sep = ".";
}
-
-
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index a5fd549aef..5b07bfd475 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.28 2005/07/18 20:57:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.29 2005/10/15 02:49:40 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -30,23 +30,21 @@ enum printFormat
typedef struct _printTableOpt
{
enum printFormat format; /* one of the above */
- bool expanded; /* expanded/vertical output (if supported
- * by output format) */
+ bool expanded; /* expanded/vertical output (if supported by
+ * output format) */
unsigned short int pager; /* use pager for output (if to stdout and
* stdout is a tty) 0=off 1=on 2=always */
bool tuples_only; /* don't output headers, row counts, etc. */
- unsigned short int border; /* Print a border around the table.
- * 0=none, 1=dividing lines, 2=full */
+ unsigned short int border; /* Print a border around the table. 0=none,
+ * 1=dividing lines, 2=full */
char *fieldSep; /* field separator for unaligned text mode */
- char *recordSep; /* record separator for unaligned text
- * mode */
+ char *recordSep; /* record separator for unaligned text mode */
bool numericLocale; /* locale-aware numeric units separator and
- * decimal marker */
+ * decimal marker */
char *tableAttr; /* attributes for HTML <table ...> */
int encoding; /* character encoding */
- bool normal_query; /* are we presenting the results of a
- * "normal" query, or a slash
- * command? */
+ bool normal_query; /* are we presenting the results of a "normal"
+ * query, or a slash command? */
} printTableOpt;
@@ -74,8 +72,7 @@ typedef struct _printQueryOpt
char *nullPrint; /* how to print null entities */
bool quote; /* quote all values as much as possible */
char *title; /* override title */
- char **footers; /* override footer (default is "(xx
- * rows)") */
+ char **footers; /* override footer (default is "(xx rows)") */
bool default_footer; /* print default footer if footers==NULL */
} printQueryOpt;
@@ -84,10 +81,10 @@ typedef struct _printQueryOpt
*
* It calls the printTable above with all the things set straight.
*/
-void printQuery(const PGresult *result, const printQueryOpt *opt,
- FILE *fout, FILE *flog);
+void printQuery(const PGresult *result, const printQueryOpt *opt,
+ FILE *fout, FILE *flog);
-void setDecimalLocale(void);
+void setDecimalLocale(void);
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 68cc52c08e..5b5d7196eb 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.39 2005/05/30 18:28:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.40 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
@@ -175,7 +175,7 @@ get_prompt(promptStatus_t status)
case '5':
case '6':
case '7':
- *buf = (char) strtol(p, (char **)&p, 8);
+ *buf = (char) strtol(p, (char **) &p, 8);
--p;
break;
case 'R':
@@ -293,9 +293,8 @@ get_prompt(promptStatus_t status)
/*
* 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.
+ * 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;
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
index f4e78f407e..06da3194d1 100644
--- a/src/bin/psql/settings.h
+++ b/src/bin/psql/settings.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.25 2005/06/14 02:57:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.26 2005/10/15 02:49:40 momjian Exp $
*/
#ifndef SETTINGS_H
#define SETTINGS_H
@@ -39,10 +39,9 @@ typedef struct _psqlSettings
char *gfname; /* one-shot file output argument for \g */
- bool notty; /* stdin or stdout is not a tty (as
- * determined on startup) */
- bool getPassword; /* prompt the user for a username and
- * password */
+ bool notty; /* stdin or stdout is not a tty (as determined
+ * on startup) */
+ bool getPassword; /* prompt the user for a username and password */
FILE *cur_cmd_source; /* describe the status of the current main
* loop */
bool cur_cmd_interactive;
@@ -56,7 +55,7 @@ typedef struct _psqlSettings
bool timing; /* enable timing of all queries */
PGVerbosity verbosity; /* current error verbosity level */
- FILE *logfile; /* session log file handle */
+ FILE *logfile; /* session log file handle */
} PsqlSettings;
extern PsqlSettings pset;
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 89b136c8c0..5d027dd018 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.124 2005/10/04 19:01:18 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.125 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
@@ -19,7 +19,7 @@
#include "getopt_long.h"
#ifndef HAVE_INT_OPTRESET
-int optreset;
+int optreset;
#endif
#include <locale.h>
@@ -107,7 +107,7 @@ main(int argc, char *argv[])
char *username = NULL;
char *password = NULL;
- char *password_prompt = NULL;
+ char *password_prompt = NULL;
bool need_pass;
set_pglocale_pgservice(argv[0], "psql");
@@ -180,9 +180,9 @@ main(int argc, char *argv[])
if (options.username)
{
/*
- * The \001 is a hack to support the deprecated -u option which
- * issues a username prompt. The recommended option is -U followed
- * by the name on the command line.
+ * The \001 is a hack to support the deprecated -u option which issues
+ * a username prompt. The recommended option is -U followed by the
+ * name on the command line.
*/
if (strcmp(options.username, "\001") == 0)
username = simple_prompt("User name: ", 100, true);
@@ -207,7 +207,7 @@ main(int argc, char *argv[])
{
need_pass = false;
pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
- options.action == ACT_LIST_DB ? "postgres" : options.dbname,
+ options.action == ACT_LIST_DB ? "postgres" : options.dbname,
username, password);
if (PQstatus(pset.db) == CONNECTION_BAD &&
@@ -314,12 +314,12 @@ main(int argc, char *argv[])
if (!QUIET() && !pset.notty)
{
- int client_ver = parse_version(PG_VERSION);
+ int client_ver = parse_version(PG_VERSION);
if (pset.sversion != client_ver)
{
const char *server_version;
- char server_ver_str[16];
+ char server_ver_str[16];
/* Try to get full text form, might include "devel" etc */
server_version = PQparameterStatus(pset.db, "server_version");
@@ -341,18 +341,18 @@ main(int argc, char *argv[])
pset.progname, PG_VERSION);
printf(_("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"
- " \\q to quit\n\n"));
+ " \\h for help with SQL commands\n"
+ " \\? for help with psql commands\n"
+ " \\g or terminate with semicolon to execute query\n"
+ " \\q to quit\n\n"));
if (pset.sversion / 100 != client_ver / 100)
printf(_("WARNING: You are connected to a server with major version %d.%d,\n"
"but your %s client is major version %d.%d. Some backslash commands,\n"
"such as \\d, might not work properly.\n\n"),
- pset.sversion / 10000, (pset.sversion / 100) % 100,
- pset.progname,
- client_ver / 10000, (client_ver / 100) % 100);
+ pset.sversion / 10000, (pset.sversion / 100) % 100,
+ pset.progname,
+ client_ver / 10000, (client_ver / 100) % 100);
#ifdef USE_SSL
printSSLInfo();
@@ -556,8 +556,8 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
break;
case 'u':
pset.getPassword = true;
- options->username = "\001"; /* hopefully nobody has
- * that username */
+ options->username = "\001"; /* hopefully nobody has that
+ * username */
/* this option is out */
used_old_u_option = true;
break;
@@ -630,8 +630,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
}
/*
- * if we still have arguments, use it as the database name and
- * username
+ * if we still have arguments, use it as the database name and username
*/
while (argc - optind >= 1)
{
@@ -691,9 +690,9 @@ process_psqlrc_file(char *filename)
sprintf(psqlrc, "%s-%s", filename, PG_VERSION);
if (access(psqlrc, R_OK) == 0)
- (void)process_file(psqlrc);
+ (void) process_file(psqlrc);
else if (access(filename, R_OK) == 0)
- (void)process_file(filename);
+ (void) process_file(filename);
free(psqlrc);
}
@@ -755,9 +754,9 @@ checkWin32Codepage(void)
concp = GetConsoleCP();
if (wincp != concp)
{
- printf(_("Warning: Console code page (%u) differs from Windows code page (%u)\n"
- " 8-bit characters may not work correctly. See psql reference\n"
- " page \"Notes for Windows users\" for details.\n\n"),
+ printf(_("Warning: Console code page (%u) differs from Windows code page (%u)\n"
+ " 8-bit characters may not work correctly. See psql reference\n"
+ " page \"Notes for Windows users\" for details.\n\n"),
concp, wincp);
}
}
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index 0087b1a623..b60033ccc8 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.40 2005/01/01 05:43:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.41 2005/10/15 02:49:40 momjian Exp $
*/
#include "postgres_fe.h"
@@ -58,10 +58,10 @@ strtokx(const char *s,
bool del_quotes,
int encoding)
{
- static char *storage = NULL;/* store the local copy of the users
- * string here */
- static char *string = NULL; /* pointer into storage where to continue
- * on next call */
+ static char *storage = NULL;/* store the local copy of the users string
+ * here */
+ static char *string = NULL; /* pointer into storage where to continue on
+ * next call */
/* variously abused variables: */
unsigned int offset;
@@ -74,8 +74,8 @@ strtokx(const char *s,
/*
* We may need extra space to insert delimiter nulls for adjacent
- * tokens. 2X the space is a gross overestimate, but it's
- * unlikely that this code will be used on huge strings anyway.
+ * tokens. 2X the space is a gross overestimate, but it's unlikely
+ * that this code will be used on huge strings anyway.
*/
storage = pg_malloc(2 * strlen(s) + 1);
strcpy(storage, s);
@@ -103,11 +103,11 @@ strtokx(const char *s,
if (delim && strchr(delim, *start))
{
/*
- * If not at end of string, we need to insert a null to terminate
- * the returned token. We can just overwrite the next character
- * if it happens to be in the whitespace set ... otherwise move
- * over the rest of the string to make room. (This is why we
- * allocated extra space above).
+ * If not at end of string, we need to insert a null to terminate the
+ * returned token. We can just overwrite the next character if it
+ * happens to be in the whitespace set ... otherwise move over the
+ * rest of the string to make room. (This is why we allocated extra
+ * space above).
*/
p = start + 1;
if (*p != '\0')
@@ -146,8 +146,8 @@ strtokx(const char *s,
}
/*
- * If not at end of string, we need to insert a null to terminate
- * the returned token. See notes above.
+ * If not at end of string, we need to insert a null to terminate the
+ * returned token. See notes above.
*/
if (*p != '\0')
{
@@ -170,10 +170,9 @@ strtokx(const char *s,
}
/*
- * Otherwise no quoting character. Scan till next whitespace,
- * delimiter or quote. NB: at this point, *start is known not to be
- * '\0', whitespace, delim, or quote, so we will consume at least one
- * character.
+ * Otherwise no quoting character. Scan till next whitespace, delimiter
+ * or quote. NB: at this point, *start is known not to be '\0',
+ * whitespace, delim, or quote, so we will consume at least one character.
*/
offset = strcspn(start, whitespace);
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 3a5fe0ab1f..27d7469b93 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.137 2005/08/14 18:49:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.138 2005/10/15 02:49:40 momjian Exp $
*/
/*----------------------------------------------------------------------
@@ -83,30 +83,28 @@ typedef struct SchemaQuery
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)".
+ * Result --- the appropriately-quoted name to return, in the case of an
+ * unqualified name. For example, "pg_catalog.quote_ident(c.relname)".
*/
const char *result;
@@ -128,8 +126,7 @@ 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 *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 */
@@ -433,9 +430,13 @@ typedef struct
static const pgsql_thing_t words_after_create[] = {
{"AGGREGATE", NULL, &Query_for_list_of_aggregates},
- {"CAST", NULL, NULL}, /* Casts have complex structures for
- * names, so skip it */
- /* CREATE CONSTRAINT TRIGGER is not supported here because it is designed to be used only by pg_dump. */
+ {"CAST", NULL, NULL}, /* Casts have complex structures for names, so
+ * skip it */
+
+ /*
+ * CREATE CONSTRAINT TRIGGER is not supported here because it is designed
+ * to be used only by pg_dump.
+ */
{"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'"},
{"DATABASE", Query_for_list_of_databases},
{"DOMAIN", NULL, &Query_for_list_of_domains},
@@ -443,8 +444,8 @@ static const pgsql_thing_t words_after_create[] = {
{"GROUP", Query_for_list_of_roles},
{"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. */
{"ROLE", Query_for_list_of_roles},
{"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},
@@ -493,8 +494,8 @@ initialize_readline(void)
completion_max_records = 1000;
/*
- * There is a variable rl_completion_query_items for this but
- * apparently it's not defined everywhere.
+ * There is a variable rl_completion_query_items for this but apparently
+ * it's not defined everywhere.
*/
}
@@ -550,9 +551,8 @@ psql_completion(char *text, int start, int end)
/*
* Scan the input line before our current position for the last four
- * words. According to those we'll make some smart decisions on what
- * the user is probably intending to type. TODO: Use strtokx() to do
- * this.
+ * words. According to those we'll make some smart decisions on what the
+ * user is probably intending to type. TODO: Use strtokx() to do this.
*/
prev_wd = previous_word(start, 0);
prev2_wd = previous_word(start, 1);
@@ -580,8 +580,8 @@ psql_completion(char *text, int start, int end)
/* ALTER */
/*
- * complete with what you can alter (TABLE, GROUP, USER, ...) unless
- * we're in ALTER TABLE sth ALTER
+ * complete with what you can alter (TABLE, GROUP, USER, ...) unless we're
+ * in ALTER TABLE sth ALTER
*/
else if (pg_strcasecmp(prev_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "TABLE") != 0)
@@ -595,18 +595,18 @@ psql_completion(char *text, int start, int end)
}
/* ALTER AGGREGATE,FUNCTION <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
- (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||
+ (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||
pg_strcasecmp(prev2_wd, "FUNCTION") == 0))
{
static const char *const list_ALTERAGG[] =
- {"OWNER TO", "RENAME TO","SET SCHEMA", NULL};
+ {"OWNER TO", "RENAME TO", "SET SCHEMA", NULL};
- COMPLETE_WITH_LIST(list_ALTERAGG);
+ COMPLETE_WITH_LIST(list_ALTERAGG);
}
/* ALTER CONVERSION,SCHEMA <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
- (pg_strcasecmp(prev2_wd, "CONVERSION") == 0 ||
+ (pg_strcasecmp(prev2_wd, "CONVERSION") == 0 ||
pg_strcasecmp(prev2_wd, "SCHEMA") == 0))
{
static const char *const list_ALTERGEN[] =
@@ -643,23 +643,23 @@ psql_completion(char *text, int start, int end)
/* ALTER USER,ROLE <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
(pg_strcasecmp(prev2_wd, "USER") == 0 ||
- pg_strcasecmp(prev2_wd, "ROLE") == 0))
+ pg_strcasecmp(prev2_wd, "ROLE") == 0))
{
static const char *const list_ALTERUSER[] =
{"ENCRYPTED", "UNENCRYPTED", "CREATEDB", "NOCREATEDB", "CREATEUSER",
- "NOCREATEUSER","CREATEROLE","NOCREATEROLE","INHERIT","NOINHERIT",
- "LOGIN","NOLOGIN","CONNECTION LIMIT", "VALID UNTIL", "RENAME TO",
- "SUPERUSER","NOSUPERUSER", "SET", "RESET", NULL};
+ "NOCREATEUSER", "CREATEROLE", "NOCREATEROLE", "INHERIT", "NOINHERIT",
+ "LOGIN", "NOLOGIN", "CONNECTION LIMIT", "VALID UNTIL", "RENAME TO",
+ "SUPERUSER", "NOSUPERUSER", "SET", "RESET", NULL};
COMPLETE_WITH_LIST(list_ALTERUSER);
}
/* complete ALTER USER,ROLE <name> ENCRYPTED,UNENCRYPTED with PASSWORD */
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
- (pg_strcasecmp(prev3_wd, "ROLE") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
- (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0))
+ (pg_strcasecmp(prev3_wd, "ROLE") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
+ (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0))
{
- COMPLETE_WITH_CONST("PASSWORD");
+ COMPLETE_WITH_CONST("PASSWORD");
}
/* ALTER DOMAIN <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
@@ -694,21 +694,21 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
pg_strcasecmp(prev2_wd, "SEQUENCE") == 0)
{
- static const char *const list_ALTERSEQUENCE[] =
- {"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE",
- "SET SCHEMA", NULL};
+ static const char *const list_ALTERSEQUENCE[] =
+ {"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE",
+ "SET SCHEMA", NULL};
- COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
+ COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
}
/* ALTER SEQUENCE <name> NO */
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "SEQUENCE") == 0 &&
pg_strcasecmp(prev_wd, "NO") == 0)
{
- static const char *const list_ALTERSEQUENCE2[] =
- {"MINVALUE", "MAXVALUE", "CYCLE", NULL};
+ static const char *const list_ALTERSEQUENCE2[] =
+ {"MINVALUE", "MAXVALUE", "CYCLE", NULL};
- COMPLETE_WITH_LIST(list_ALTERSEQUENCE2);
+ COMPLETE_WITH_LIST(list_ALTERSEQUENCE2);
}
/* ALTER TRIGGER <name>, add ON */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
@@ -781,9 +781,9 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev2_wd, "ALTER") == 0))
{
/* DROP ... does not work well yet */
- static const char *const list_COLUMNALTER[] =
+ static const char *const list_COLUMNALTER[] =
{"TYPE", "SET DEFAULT", "DROP DEFAULT", "SET NOT NULL",
- "DROP NOT NULL", "SET STATISTICS", "SET STORAGE", NULL};
+ "DROP NOT NULL", "SET STATISTICS", "SET STORAGE", NULL};
COMPLETE_WITH_LIST(list_COLUMNALTER);
}
@@ -802,7 +802,7 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev_wd, "SET") == 0)
{
static const char *const list_TABLESET[] =
- {"WITHOUT", "TABLESPACE","SCHEMA", NULL};
+ {"WITHOUT", "TABLESPACE", "SCHEMA", NULL};
COMPLETE_WITH_LIST(list_TABLESET);
}
@@ -836,6 +836,7 @@ psql_completion(char *text, int start, int end)
{
static const char *const list_ALTERTYPE[] =
{"OWNER TO", "SET SCHEMA", NULL};
+
COMPLETE_WITH_LIST(list_ALTERTYPE);
}
/* complete ALTER GROUP <foo> */
@@ -869,9 +870,9 @@ psql_completion(char *text, int start, int end)
{"WORK", "TRANSACTION", NULL};
COMPLETE_WITH_LIST(list_TRANS);
- }
+ }
/* COMMIT */
- else if(pg_strcasecmp(prev_wd, "COMMIT") == 0)
+ else if (pg_strcasecmp(prev_wd, "COMMIT") == 0)
{
static const char *const list_COMMIT[] =
{"WORK", "TRANSACTION", "PREPARED", NULL};
@@ -904,8 +905,7 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("ON");
/*
- * If we have CLUSTER <sth> ON, then add the correct tablename as
- * well.
+ * If we have CLUSTER <sth> ON, then add the correct tablename as well.
*/
else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0)
@@ -923,7 +923,7 @@ 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","LARGE OBJECT", NULL};
+ "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", "LARGE OBJECT", NULL};
COMPLETE_WITH_LIST(list_COMMENT);
}
@@ -946,12 +946,12 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev2_wd, "COPY") == 0 ||
pg_strcasecmp(prev2_wd, "\\copy") == 0 ||
pg_strcasecmp(prev2_wd, "BINARY") == 0)
- {
- static const char *const list_FROMTO[] =
- {"FROM", "TO", NULL};
+ {
+ static const char *const list_FROMTO[] =
+ {"FROM", "TO", NULL};
- COMPLETE_WITH_LIST(list_FROMTO);
- }
+ COMPLETE_WITH_LIST(list_FROMTO);
+ }
/* If we have COPY|BINARY <sth> FROM|TO, complete with filename */
else if ((pg_strcasecmp(prev3_wd, "COPY") == 0 ||
pg_strcasecmp(prev3_wd, "\\copy") == 0 ||
@@ -966,22 +966,22 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev4_wd, "BINARY") == 0) &&
(pg_strcasecmp(prev2_wd, "FROM") == 0 ||
pg_strcasecmp(prev2_wd, "TO") == 0))
- {
- static const char *const list_COPY[] =
- {"BINARY", "OIDS", "DELIMITER", "NULL", "CSV", NULL};
+ {
+ static const char *const list_COPY[] =
+ {"BINARY", "OIDS", "DELIMITER", "NULL", "CSV", NULL};
- COMPLETE_WITH_LIST(list_COPY);
- }
+ COMPLETE_WITH_LIST(list_COPY);
+ }
/* Handle COPY|BINARY <sth> FROM|TO filename CSV */
- else if (pg_strcasecmp(prev_wd, "CSV") == 0 &&
+ else if (pg_strcasecmp(prev_wd, "CSV") == 0 &&
(pg_strcasecmp(prev3_wd, "FROM") == 0 ||
pg_strcasecmp(prev3_wd, "TO") == 0))
{
- static const char *const list_CSV[] =
- {"HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE", NULL};
+ static const char *const list_CSV[] =
+ {"HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE", NULL};
- COMPLETE_WITH_LIST(list_CSV);
+ COMPLETE_WITH_LIST(list_CSV);
}
/* CREATE DATABASE */
@@ -990,7 +990,7 @@ psql_completion(char *text, int start, int end)
{
static const char *const list_DATABASE[] =
{"OWNER", "TEMPLATE", "ENCODING", "TABLESPACE", "CONNECTION LIMIT",
- NULL};
+ NULL};
COMPLETE_WITH_LIST(list_DATABASE);
}
@@ -1011,8 +1011,8 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/*
- * Complete INDEX <name> ON <table> with a list of table columns
- * (which should really be in parens)
+ * Complete INDEX <name> ON <table> with a list of table columns (which
+ * should really be in parens)
*/
else if (pg_strcasecmp(prev4_wd, "INDEX") == 0 &&
pg_strcasecmp(prev2_wd, "ON") == 0)
@@ -1088,20 +1088,22 @@ psql_completion(char *text, int start, int end)
/* CREATE TRIGGER */
/* complete CREATE TRIGGER <name> with BEFORE,AFTER */
else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&
- pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
+ pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
{
static const char *const list_CREATETRIGGER[] =
- {"BEFORE", "AFTER", NULL};
- COMPLETE_WITH_LIST(list_CREATETRIGGER);
+ {"BEFORE", "AFTER", NULL};
+
+ COMPLETE_WITH_LIST(list_CREATETRIGGER);
}
/* complete CREATE TRIGGER <name> BEFORE,AFTER sth with OR,ON */
else if (pg_strcasecmp(prev5_wd, "CREATE") == 0 &&
- pg_strcasecmp(prev4_wd, "TRIGGER") == 0 &&
- (pg_strcasecmp(prev2_wd, "BEFORE") == 0 ||
- pg_strcasecmp(prev2_wd, "AFTER") == 0))
+ pg_strcasecmp(prev4_wd, "TRIGGER") == 0 &&
+ (pg_strcasecmp(prev2_wd, "BEFORE") == 0 ||
+ pg_strcasecmp(prev2_wd, "AFTER") == 0))
{
static const char *const list_CREATETRIGGER2[] =
- {"ON","OR",NULL};
+ {"ON", "OR", NULL};
+
COMPLETE_WITH_LIST(list_CREATETRIGGER2);
}
@@ -1111,29 +1113,35 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev2_wd, "GROUP") == 0 || pg_strcasecmp(prev2_wd, "USER") == 0))
{
static const char *const list_CREATEROLE[] =
- {"ADMIN","CONNECTION LIMIT","CREATEDB","CREATEROLE","CREATEUSER",
- "ENCRYPTED", "IN", "INHERIT", "LOGIN", "NOINHERIT", "NOLOGIN", "NOCREATEDB",
- "NOCREATEROLE", "NOCREATEUSER", "NOSUPERUSER", "ROLE", "SUPERUSER", "SYSID",
- "UNENCRYPTED",NULL};
- COMPLETE_WITH_LIST(list_CREATEROLE);
+ {"ADMIN", "CONNECTION LIMIT", "CREATEDB", "CREATEROLE", "CREATEUSER",
+ "ENCRYPTED", "IN", "INHERIT", "LOGIN", "NOINHERIT", "NOLOGIN", "NOCREATEDB",
+ "NOCREATEROLE", "NOCREATEUSER", "NOSUPERUSER", "ROLE", "SUPERUSER", "SYSID",
+ "UNENCRYPTED", NULL};
+
+ COMPLETE_WITH_LIST(list_CREATEROLE);
}
- /* complete CREATE ROLE,USER,GROUP <name> ENCRYPTED,UNENCRYPTED with PASSWORD */
+
+ /*
+ * complete CREATE ROLE,USER,GROUP <name> ENCRYPTED,UNENCRYPTED with
+ * PASSWORD
+ */
else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
- (pg_strcasecmp(prev3_wd, "ROLE") == 0 ||
- pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
- (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0))
+ (pg_strcasecmp(prev3_wd, "ROLE") == 0 ||
+ pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
+ (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0))
{
- COMPLETE_WITH_CONST("PASSWORD");
+ COMPLETE_WITH_CONST("PASSWORD");
}
/* complete CREATE ROLE,USER,GROUP <name> IN with ROLE,GROUP */
else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
- (pg_strcasecmp(prev3_wd, "ROLE") == 0 ||
- pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
- pg_strcasecmp(prev_wd, "IN") == 0)
+ (pg_strcasecmp(prev3_wd, "ROLE") == 0 ||
+ pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) &&
+ pg_strcasecmp(prev_wd, "IN") == 0)
{
static const char *const list_CREATEROLE3[] =
- {"GROUP","ROLE",NULL};
- COMPLETE_WITH_LIST(list_CREATEROLE3);
+ {"GROUP", "ROLE", NULL};
+
+ COMPLETE_WITH_LIST(list_CREATEROLE3);
}
/* CREATE VIEW */
@@ -1150,20 +1158,23 @@ psql_completion(char *text, int start, int end)
/* DECLARE */
else if (pg_strcasecmp(prev2_wd, "DECLARE") == 0)
{
- static const char *const list_DECLARE[] =
- {"BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL", "CURSOR", NULL};
- COMPLETE_WITH_LIST(list_DECLARE);
+ static const char *const list_DECLARE[] =
+ {"BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL", "CURSOR", NULL};
+
+ COMPLETE_WITH_LIST(list_DECLARE);
}
else if (pg_strcasecmp(prev_wd, "CURSOR") == 0)
{
- static const char *const list_DECLARECURSOR[] =
- {"WITH HOLD", "WITHOUT HOLD", "FOR", NULL};
- COMPLETE_WITH_LIST(list_DECLARECURSOR);
+ static const char *const list_DECLARECURSOR[] =
+ {"WITH HOLD", "WITHOUT HOLD", "FOR", NULL};
+
+ COMPLETE_WITH_LIST(list_DECLARECURSOR);
}
/* DELETE */
+
/*
* Complete DELETE with FROM (only if the word before that is not "ON"
* (cf. rules) or "BEFORE" or "AFTER" (cf. triggers) or GRANT)
@@ -1211,27 +1222,31 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev3_wd, "AGGREGATE") == 0 &&
prev_wd[strlen(prev_wd) - 1] == ')'))
{
- static const char *const list_DROPCR[] =
- {"CASCADE", "RESTRICT", NULL};
- COMPLETE_WITH_LIST(list_DROPCR);
+ static const char *const list_DROPCR[] =
+ {"CASCADE", "RESTRICT", NULL};
+
+ COMPLETE_WITH_LIST(list_DROPCR);
}
/* EXPLAIN */
+
/*
* Complete EXPLAIN [ANALYZE] [VERBOSE] with list of EXPLAIN-able commands
*/
else if (pg_strcasecmp(prev_wd, "EXPLAIN") == 0)
{
- static const char *const list_EXPLAIN[] =
- {"SELECT","INSERT","DELETE","UPDATE","DECLARE","ANALYZE","VERBOSE",NULL};
- COMPLETE_WITH_LIST(list_EXPLAIN);
+ static const char *const list_EXPLAIN[] =
+ {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", "ANALYZE", "VERBOSE", NULL};
+
+ COMPLETE_WITH_LIST(list_EXPLAIN);
}
else if (pg_strcasecmp(prev2_wd, "EXPLAIN") == 0 &&
- pg_strcasecmp(prev_wd, "ANALYZE") == 0)
+ pg_strcasecmp(prev_wd, "ANALYZE") == 0)
{
- static const char *const list_EXPLAIN[] =
- {"SELECT","INSERT","DELETE","UPDATE","DECLARE","VERBOSE",NULL};
- COMPLETE_WITH_LIST(list_EXPLAIN);
+ static const char *const list_EXPLAIN[] =
+ {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", "VERBOSE", NULL};
+
+ COMPLETE_WITH_LIST(list_EXPLAIN);
}
else if (pg_strcasecmp(prev_wd, "VERBOSE") == 0 &&
pg_strcasecmp(prev3_wd, "VACUUM") != 0 &&
@@ -1239,9 +1254,10 @@ psql_completion(char *text, int start, int end)
(pg_strcasecmp(prev2_wd, "ANALYZE") == 0 ||
pg_strcasecmp(prev2_wd, "EXPLAIN") == 0))
{
- static const char *const list_EXPLAIN[] =
- {"SELECT","INSERT","DELETE","UPDATE","DECLARE",NULL};
- COMPLETE_WITH_LIST(list_EXPLAIN);
+ static const char *const list_EXPLAIN[] =
+ {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", NULL};
+
+ COMPLETE_WITH_LIST(list_EXPLAIN);
}
/* FETCH && MOVE */
@@ -1265,9 +1281,9 @@ psql_completion(char *text, int start, int end)
}
/*
- * Complete FETCH <sth1> <sth2> with "FROM" or "IN". These are
- * equivalent, but we may as well tab-complete both: perhaps some
- * users prefer one variant or the other.
+ * Complete FETCH <sth1> <sth2> with "FROM" or "IN". These are equivalent,
+ * but we may as well tab-complete both: perhaps some users prefer one
+ * variant or the other.
*/
else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
pg_strcasecmp(prev3_wd, "MOVE") == 0)
@@ -1295,15 +1311,15 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("ON");
/*
- * Complete GRANT/REVOKE <sth> ON with a list of tables, views,
- * sequences, and indexes
+ * Complete GRANT/REVOKE <sth> ON with a list of tables, views, sequences,
+ * and indexes
*
- * keywords DATABASE, FUNCTION, LANGUAGE, SCHEMA added to query result
- * via UNION; seems to work intuitively
+ * keywords DATABASE, FUNCTION, LANGUAGE, SCHEMA added to query result via
+ * UNION; seems to work intuitively
*
- * Note: GRANT/REVOKE can get quite complex; tab-completion as
- * implemented here will only work if the privilege list contains
- * exactly one privilege
+ * Note: GRANT/REVOKE can get quite complex; tab-completion as implemented
+ * here will only work if the privilege list contains exactly one
+ * privilege
*/
else if ((pg_strcasecmp(prev3_wd, "GRANT") == 0 ||
pg_strcasecmp(prev3_wd, "REVOKE") == 0) &&
@@ -1564,7 +1580,7 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(constraint_list);
}
/* Complete SET ROLE */
- else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
+ else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
pg_strcasecmp(prev_wd, "ROLE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
@@ -1589,14 +1605,14 @@ 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[] =
{"ISO", "SQL", "Postgres", "German",
- "YMD", "DMY", "MDY",
- "US", "European", "NonEuropean",
+ "YMD", "DMY", "MDY",
+ "US", "European", "NonEuropean",
"DEFAULT", NULL};
COMPLETE_WITH_LIST(my_list);
@@ -1638,16 +1654,16 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("SET");
/*
- * If the previous word is SET (and it wasn't caught above as the
- * _first_ word) the word before it was (hopefully) a table name and
- * we'll now make a list of attributes.
+ * If the previous word is SET (and it wasn't caught above as the _first_
+ * word) the word before it was (hopefully) a table name and we'll now
+ * make a list of attributes.
*/
else if (pg_strcasecmp(prev_wd, "SET") == 0)
COMPLETE_WITH_ATTR(prev2_wd);
/* UPDATE xx SET yy = */
else if (pg_strcasecmp(prev2_wd, "SET") == 0 &&
- pg_strcasecmp(prev4_wd, "UPDATE") == 0)
+ pg_strcasecmp(prev4_wd, "UPDATE") == 0)
COMPLETE_WITH_CONST("=");
/*
@@ -1756,21 +1772,144 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(my_list);
}
else if (strcmp(prev_wd, "\\cd") == 0 ||
- strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
+ strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
strcmp(prev_wd, "\\g") == 0 ||
- strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
- strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
+ strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
+ strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
strcmp(prev_wd, "\\s") == 0 ||
- strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
+ strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
)
matches = completion_matches(text, filename_completion_function);
- /*
- * Finally, we look through the list of "things", such as TABLE, INDEX
- * and check if that was the previous word. If so, execute the query
- * to get a list of them.
- */
+ /*
+ *
+ * Fi
+ * n
+ * a
+ * l
+ * l
+ * y
+ * ,
+ *
+ * we
+ *
+ * lo
+ * o
+ * k
+ *
+ * th
+ * r
+ * o
+ * u
+ * g
+ * h
+ *
+ * th
+ * e
+ *
+ * li
+ * s
+ * t
+ *
+ * of
+ *
+ * "t
+ * h
+ * i
+ * n
+ * g
+ * s
+ * "
+ * ,
+ *
+ * su
+ * c
+ * h
+ *
+ * as
+ *
+ * TA
+ * B
+ * L
+ * E
+ * ,
+ *
+ * IN
+ * D
+ * E
+ * X
+ *
+ * an
+ * d
+ *
+ * ch
+ * e
+ * c
+ * k
+ *
+ * if
+ *
+ * th
+ * a
+ * t
+ *
+ * wa
+ * s
+ *
+ * th
+ * e
+ *
+ * pr
+ * e
+ * v
+ * i
+ * o
+ * u
+ * s
+ *
+ * wo
+ * r
+ * d
+ * .
+ *
+ * If
+ *
+ * so
+ * ,
+ *
+ * ex
+ * e
+ * c
+ * u
+ * t
+ * e
+ *
+ * th
+ * e
+ *
+ * qu
+ * e
+ * r
+ * y
+ *
+ * to
+ *
+ * ge
+ * t
+ *
+ * a
+ * li
+ * s
+ * t
+ *
+ * of
+ *
+ * th
+ * e
+ * m
+ * .
+ * */
else
{
int i;
@@ -1789,30 +1928,236 @@ psql_completion(char *text, int start, int end)
}
}
- /*
- * If we still don't have anything to match we have to fabricate some
- * sort of default list. If we were to just return NULL, readline
- * automatically attempts filename completion, and that's usually no
- * good.
- */
- if (matches == NULL)
- {
- COMPLETE_WITH_CONST("");
+ /*
+ *
+ * If
+ *
+ * we
+ *
+ * st
+ * i
+ * l
+ * l
+ *
+ * do
+ * n
+ * '
+ * t
+ *
+ * ha
+ * v
+ * e
+ *
+ * an
+ * y
+ * t
+ * h
+ * i
+ * n
+ * g
+ *
+ * to
+ *
+ * ma
+ * t
+ * c
+ * h
+ *
+ * we
+ *
+ * ha
+ * v
+ * e
+ *
+ * to
+ *
+ * fa
+ * b
+ * r
+ * i
+ * c
+ * a
+ * t
+ * e
+ *
+ * so
+ * m
+ * e
+ *
+ * so
+ * r
+ * t
+ *
+ * of
+ *
+ * de
+ * f
+ * a
+ * u
+ * l
+ * t
+ *
+ * li
+ * s
+ * t
+ * .
+ *
+ * If
+ *
+ * we
+ *
+ * we
+ * r
+ * e
+ *
+ * to
+ *
+ * ju
+ * s
+ * t
+ *
+ * re
+ * t
+ * u
+ * r
+ * n
+ *
+ * NU
+ * L
+ * L
+ * ,
+ *
+ * re
+ * a
+ * d
+ * l
+ * i
+ * n
+ * e
+ *
+ * au
+ * t
+ * o
+ * m
+ * a
+ * t
+ * i
+ * c
+ * a
+ * l
+ * l
+ * y
+ *
+ * at
+ * t
+ * e
+ * m
+ * p
+ * t
+ * s
+ *
+ * fi
+ * l
+ * e
+ * n
+ * a
+ * m
+ * e
+ *
+ * co
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ * ,
+ *
+ * an
+ * d
+ *
+ * th
+ * a
+ * t
+ * '
+ * s
+ *
+ * us
+ * u
+ * a
+ * l
+ * l
+ * y
+ *
+ * no
+ *
+ * go
+ * o
+ * d
+ * .
+ * */
+ if (matches == NULL)
+ {
+ COMPLETE_WITH_CONST("");
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
- rl_completion_append_character = '\0';
+ rl_completion_append_character = '\0';
#endif
- }
-
- /* free storage */
- free(prev_wd);
- free(prev2_wd);
- free(prev3_wd);
- free(prev4_wd);
- free(prev5_wd);
-
- /* Return our Grand List O' Matches */
- return matches;
-}
+ }
+
+ /*
+ * f
+ * r
+ * e
+ * e
+ *
+ * st
+ * o
+ * r
+ * a
+ * g
+ * e
+ *
+ */
+ free(prev_wd);
+ free(prev2_wd);
+ free(prev3_wd);
+ free(prev4_wd);
+ free(prev5_wd);
+
+ /*
+ * R
+ * e
+ * t
+ * u
+ * r
+ * n
+ *
+ * ou
+ * r
+ *
+ * Gr
+ * a
+ * n
+ * d
+ *
+ * Li
+ * s
+ * t
+ *
+ * O'
+ *
+ * Ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ *
+ */
+ return matches;
+ }
@@ -1832,43 +2177,152 @@ psql_completion(char *text, int start, int end)
/* This one gives you one from a list of things you can put after CREATE or DROP
as defined above.
*/
-static char *
-create_command_generator(const char *text, int state)
-{
- static int list_index,
- string_length;
- const char *name;
-
- /* If this is the first time for this completion, init some values */
- if (state == 0)
- {
- list_index = 0;
- string_length = strlen(text);
- }
-
- /* find something that matches */
- while ((name = words_after_create[list_index++].name))
- if (pg_strncasecmp(name, text, string_length) == 0)
- return pg_strdup(name);
-
- /* if nothing matches, return NULL */
- return NULL;
-}
+ static char *
+ create_command_generator(const char *text, int state)
+ {
+ static int list_index,
+ string_length;
+ const char *name;
+
+ /*
+ * I
+ * f
+ *
+ * th
+ * i
+ * s
+ *
+ * is
+ *
+ * th
+ * e
+ *
+ * fi
+ * r
+ * s
+ * t
+ *
+ * ti
+ * m
+ * e
+ *
+ * fo
+ * r
+ *
+ * th
+ * i
+ * s
+ *
+ * co
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ * ,
+ *
+ * in
+ * i
+ * t
+ *
+ * so
+ * m
+ * e
+ *
+ * va
+ * l
+ * u
+ * e
+ * s
+ *
+ */
+ if (state == 0)
+ {
+ list_index = 0;
+ string_length = strlen(text);
+ }
+
+ /*
+ * f
+ * i
+ * n
+ * d
+ *
+ * so
+ * m
+ * e
+ * t
+ * h
+ * i
+ * n
+ * g
+ *
+ * th
+ * a
+ * t
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ *
+ */
+ while ((name = words_after_create[list_index++].name))
+ if (pg_strncasecmp(name, text, string_length) == 0)
+ return pg_strdup(name);
+
+ /*
+ * i
+ * f
+ *
+ * no
+ * t
+ * h
+ * i
+ * n
+ * g
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ * ,
+ *
+ * re
+ * t
+ * u
+ * r
+ * n
+ *
+ * NU
+ * L
+ * L
+ *
+ */
+ return NULL;
+ }
/* The following two functions are wrappers for _complete_from_query */
-static char *
-complete_from_query(const char *text, int state)
-{
- return _complete_from_query(0, text, state);
-}
+ static char *
+ complete_from_query(const char *text, int state)
+ {
+ return _complete_from_query(0, text, state);
+ }
-static char *
-complete_from_schema_query(const char *text, int state)
-{
- return _complete_from_query(1, text, state);
-}
+ static char *
+ complete_from_schema_query(const char *text, int state)
+ {
+ return _complete_from_query(1, text, state);
+ }
/* This creates a list of matching things, according to a query pointed to
@@ -1890,229 +2344,1308 @@ complete_from_schema_query(const char *text, int state)
See top of file for examples of both kinds of query.
*/
-static char *
-_complete_from_query(int is_schema_query, const char *text, int state)
-{
- static int list_index,
- string_length;
- static PGresult *result = NULL;
-
- /*
- * If this is the first time for this completion, we fetch a list of
- * our "things" from the backend.
- */
- if (state == 0)
- {
- PQExpBufferData query_buffer;
- char *e_text;
- char *e_info_charp;
-
- list_index = 0;
- string_length = strlen(text);
-
- /* Free any prior result */
- PQclear(result);
- result = NULL;
-
- /* Set up suitably-escaped copies of textual inputs */
- e_text = pg_malloc(string_length * 2 + 1);
- PQescapeString(e_text, text, string_length);
-
- if (completion_info_charp)
- {
- size_t charp_len;
-
- charp_len = strlen(completion_info_charp);
- e_info_charp = pg_malloc(charp_len * 2 + 1);
- PQescapeString(e_info_charp, completion_info_charp,
- charp_len);
- }
- else
- e_info_charp = NULL;
-
- initPQExpBuffer(&query_buffer);
-
- if (is_schema_query)
- {
- /* completion_squery gives us the pieces to assemble */
- const char *qualresult = completion_squery->qualresult;
-
- if (qualresult == NULL)
- qualresult = completion_squery->result;
-
- /* Get unqualified names matching the input-so-far */
- appendPQExpBuffer(&query_buffer, "SELECT %s FROM %s WHERE ",
- completion_squery->result,
- completion_squery->catname);
- if (completion_squery->selcondition)
- appendPQExpBuffer(&query_buffer, "%s AND ",
- completion_squery->selcondition);
- appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'",
- completion_squery->result,
- string_length, e_text);
- appendPQExpBuffer(&query_buffer, " AND %s",
- completion_squery->viscondition);
-
- /*
- * 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)
- {
- appendPQExpBuffer(&query_buffer,
- " 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.
- */
- appendPQExpBuffer(&query_buffer, "\nUNION\n"
- "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);
- appendPQExpBuffer(&query_buffer,
- " AND (SELECT pg_catalog.count(*)"
- " FROM pg_catalog.pg_namespace"
- " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
- " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1",
- string_length, e_text);
-
- /*
- * 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 "
- "FROM %s, pg_catalog.pg_namespace n "
- "WHERE %s = n.oid AND ",
- qualresult,
- completion_squery->catname,
- completion_squery->namespace);
- if (completion_squery->selcondition)
- appendPQExpBuffer(&query_buffer, "%s AND ",
- completion_squery->selcondition);
- 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
- */
- 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)",
- string_length, e_text);
- appendPQExpBuffer(&query_buffer,
- " AND (SELECT pg_catalog.count(*)"
- " FROM pg_catalog.pg_namespace"
- " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
- " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1",
- string_length, e_text);
-
- /* If an addon query was provided, use it */
- if (completion_charp)
- appendPQExpBuffer(&query_buffer, "\n%s", completion_charp);
- }
- else
- {
- /* completion_charp is an sprintf-style format string */
- appendPQExpBuffer(&query_buffer, completion_charp,
- string_length, e_text, e_info_charp);
- }
-
- /* Limit the number of records in the result */
- appendPQExpBuffer(&query_buffer, "\nLIMIT %d",
- completion_max_records);
-
- result = exec_query(query_buffer.data);
-
- termPQExpBuffer(&query_buffer);
- free(e_text);
- if (e_info_charp)
- free(e_info_charp);
- }
-
- /* Find something that matches */
- if (result && PQresultStatus(result) == PGRES_TUPLES_OK)
- {
- const char *item;
-
- while (list_index < PQntuples(result) &&
- (item = PQgetvalue(result, list_index++, 0)))
- if (pg_strncasecmp(text, item, string_length) == 0)
- return pg_strdup(item);
- }
-
- /* If nothing matches, free the db structure and return null */
- PQclear(result);
- result = NULL;
- return NULL;
-}
+ static char *
+ _complete_from_query(int is_schema_query, const char *text, int state)
+ {
+ static int list_index,
+ string_length;
+ static PGresult *result = NULL;
+
+ /*
+ *
+ * If
+ *
+ * th
+ * i
+ * s
+ *
+ * is
+ *
+ * th
+ * e
+ *
+ * fi
+ * r
+ * s
+ * t
+ *
+ * ti
+ * m
+ * e
+ *
+ * fo
+ * r
+ *
+ * th
+ * i
+ * s
+ *
+ * co
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ * ,
+ *
+ * we
+ *
+ * fe
+ * t
+ * c
+ * h
+ *
+ * a
+ * li
+ * s
+ * t
+ *
+ * of
+ *
+ * ou
+ * r
+ *
+ * "t
+ * h
+ * i
+ * n
+ * g
+ * s
+ * "
+ *
+ * fr
+ * o
+ * m
+ *
+ * th
+ * e
+ *
+ * ba
+ * c
+ * k
+ * e
+ * n
+ * d
+ * .
+ * */
+ if (state == 0)
+ {
+ PQExpBufferData query_buffer;
+ char *e_text;
+ char *e_info_charp;
+
+ list_index = 0;
+ string_length = strlen(text);
+
+ /*
+ * F
+ * r
+ * e
+ * e
+ *
+ * an
+ * y
+ *
+ * pr
+ * i
+ * o
+ * r
+ *
+ * re
+ * s
+ * u
+ * l
+ * t
+ *
+ */
+ PQclear(result);
+ result = NULL;
+
+ /*
+ * S
+ * e
+ * t
+ *
+ * up
+ *
+ * su
+ * i
+ * t
+ * a
+ * b
+ * l
+ * y
+ * -
+ * e
+ * s
+ * c
+ * a
+ * p
+ * e
+ * d
+ *
+ * co
+ * p
+ * i
+ * e
+ * s
+ *
+ * of
+ *
+ * te
+ * x
+ * t
+ * u
+ * a
+ * l
+ *
+ * in
+ * p
+ * u
+ * t
+ * s
+ *
+ */
+ e_text = pg_malloc(string_length * 2 + 1);
+ PQescapeString(e_text, text, string_length);
+
+ if (completion_info_charp)
+ {
+ size_t charp_len;
+
+ charp_len = strlen(completion_info_charp);
+ e_info_charp = pg_malloc(charp_len * 2 + 1);
+ PQescapeString(e_info_charp, completion_info_charp,
+ charp_len);
+ }
+ else
+ e_info_charp = NULL;
+
+ initPQExpBuffer(&query_buffer);
+
+ if (is_schema_query)
+ {
+ /*
+ * c
+ * o
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ * _
+ * s
+ * q
+ * u
+ * e
+ * r
+ * y
+ *
+ * gi
+ * v
+ * e
+ * s
+ *
+ * us
+ *
+ * th
+ * e
+ *
+ * pi
+ * e
+ * c
+ * e
+ * s
+ *
+ * to
+ *
+ * as
+ * s
+ * e
+ * m
+ * b
+ * l
+ * e
+ *
+ */
+ const char *qualresult = completion_squery->qualresult;
+
+ if (qualresult == NULL)
+ qualresult = completion_squery->result;
+
+ /*
+ * G
+ * e
+ * t
+ *
+ * un
+ * q
+ * u
+ * a
+ * l
+ * i
+ * f
+ * i
+ * e
+ * d
+ *
+ * na
+ * m
+ * e
+ * s
+ *
+ * ma
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ *
+ * th
+ * e
+ *
+ * in
+ * p
+ * u
+ * t
+ * -
+ * s
+ * o
+ * -
+ * f
+ * a
+ * r
+ *
+ */
+ appendPQExpBuffer(&query_buffer, "SELECT %s FROM %s WHERE ",
+ completion_squery->result,
+ completion_squery->catname);
+ if (completion_squery->selcondition)
+ appendPQExpBuffer(&query_buffer, "%s AND ",
+ completion_squery->selcondition);
+ appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'",
+ completion_squery->result,
+ string_length, e_text);
+ appendPQExpBuffer(&query_buffer, " AND %s",
+ completion_squery->viscondition);
+
+ /*
+ *
+ * Wh
+ * e
+ * n
+ *
+ * fe
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ *
+ * re
+ * l
+ * a
+ * t
+ * i
+ * o
+ * n
+ *
+ * na
+ * m
+ * e
+ * s
+ * ,
+ *
+ * su
+ * p
+ * p
+ * r
+ * e
+ * s
+ * s
+ *
+ * sy
+ * s
+ * t
+ * e
+ * m
+ *
+ * ca
+ * t
+ * a
+ * l
+ * o
+ * g
+ * s
+ *
+ * un
+ * l
+ * e
+ * s
+ * s
+ *
+ * th
+ * e
+ *
+ * in
+ * p
+ * u
+ * t
+ * -
+ * s
+ * o
+ * -
+ * f
+ * a
+ * r
+ *
+ * be
+ * g
+ * i
+ * n
+ * s
+ *
+ * wi
+ * t
+ * h
+ *
+ * "p
+ * g
+ * _
+ * "
+ * .
+ *
+ * Th
+ * i
+ * s
+ *
+ * is
+ *
+ * a
+ * co
+ * m
+ * p
+ * r
+ * o
+ * m
+ * i
+ * s
+ * e
+ *
+ * be
+ * t
+ * w
+ * e
+ * e
+ * n
+ *
+ * no
+ * t
+ *
+ * of
+ * f
+ * e
+ * r
+ * i
+ * n
+ * g
+ *
+ * sy
+ * s
+ * t
+ * e
+ * m
+ *
+ * ca
+ * t
+ * a
+ * l
+ * o
+ * g
+ * s
+ *
+ * fo
+ * r
+ *
+ * co
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ *
+ * at
+ *
+ * al
+ * l
+ * ,
+ *
+ * an
+ * d
+ *
+ * ha
+ * v
+ * i
+ * n
+ * g
+ *
+ * th
+ * e
+ * m
+ *
+ * sw
+ * a
+ * m
+ * p
+ *
+ * th
+ * e
+ *
+ * re
+ * s
+ * u
+ * l
+ * t
+ *
+ * wh
+ * e
+ * n
+ *
+ * th
+ * e
+ *
+ * in
+ * p
+ * u
+ * t
+ *
+ * is
+ *
+ * ju
+ * s
+ * t
+ *
+ * "p
+ * "
+ * .
+ * */
+ if (strcmp(completion_squery->catname,
+ "pg_catalog.pg_class c") == 0 &&
+ strncmp(text, "pg_", 3) !=0)
+ {
+ appendPQExpBuffer(&query_buffer,
+ " AND c.relnamespace <> (SELECT oid FROM"
+ " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')");
+ }
+
+ /*
+ *
+ * Ad
+ * d
+ *
+ * in
+ *
+ * ma
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ *
+ * sc
+ * h
+ * e
+ * m
+ * a
+ *
+ * na
+ * m
+ * e
+ * s
+ * ,
+ *
+ * bu
+ * t
+ *
+ * on
+ * l
+ * y
+ *
+ * if
+ *
+ * th
+ * e
+ * r
+ * e
+ *
+ * is
+ *
+ * mo
+ * r
+ * e
+ *
+ * th
+ * a
+ * n
+ *
+ * on
+ * e
+ *
+ * po
+ * t
+ * e
+ * n
+ * t
+ * i
+ * a
+ * l
+ *
+ * ma
+ * t
+ * c
+ * h
+ *
+ * am
+ * o
+ * n
+ * g
+ *
+ * sc
+ * h
+ * e
+ * m
+ * a
+ *
+ * na
+ * m
+ * e
+ * s
+ * .
+ * */
+ appendPQExpBuffer(&query_buffer, "\nUNION\n"
+ "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);
+ appendPQExpBuffer(&query_buffer,
+ " AND (SELECT pg_catalog.count(*)"
+ " FROM pg_catalog.pg_namespace"
+ " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
+ " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1",
+ string_length, e_text);
+
+ /*
+ *
+ * Ad
+ * d
+ *
+ * in
+ *
+ * ma
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ *
+ * qu
+ * a
+ * l
+ * i
+ * f
+ * i
+ * e
+ * d
+ *
+ * na
+ * m
+ * e
+ * s
+ * ,
+ *
+ * bu
+ * t
+ *
+ * on
+ * l
+ * y
+ *
+ * if
+ *
+ * th
+ * e
+ * r
+ * e
+ *
+ * is
+ *
+ * ex
+ * a
+ * c
+ * t
+ * l
+ * y
+ *
+ * on
+ * e
+ *
+ * sc
+ * h
+ * e
+ * m
+ * a
+ *
+ * ma
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ *
+ * th
+ * e
+ *
+ * in
+ * p
+ * u
+ * t
+ * -
+ * s
+ * o
+ * -
+ * f
+ * a
+ * r
+ * .
+ * */
+ appendPQExpBuffer(&query_buffer, "\nUNION\n"
+ "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s "
+ "FROM %s, pg_catalog.pg_namespace n "
+ "WHERE %s = n.oid AND ",
+ qualresult,
+ completion_squery->catname,
+ completion_squery->namespace);
+ if (completion_squery->selcondition)
+ appendPQExpBuffer(&query_buffer, "%s AND ",
+ completion_squery->selcondition);
+ appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) || '.' || %s,1,%d)='%s'",
+ qualresult,
+ string_length, e_text);
+
+ /*
+ *
+ * Th
+ * i
+ * s
+ *
+ * co
+ * n
+ * d
+ * i
+ * t
+ * i
+ * o
+ * n
+ *
+ * ex
+ * p
+ * l
+ * o
+ * i
+ * t
+ * s
+ *
+ * th
+ * e
+ *
+ * si
+ * n
+ * g
+ * l
+ * e
+ * -
+ * m
+ * a
+ * t
+ * c
+ * h
+ * i
+ * n
+ * g
+ * -
+ * s
+ * c
+ * h
+ * e
+ * m
+ * a
+ *
+ * ru
+ * l
+ * e
+ *
+ * to
+ *
+ * sp
+ * e
+ * e
+ * d
+ *
+ * up
+ *
+ * th
+ * e
+ *
+ * qu
+ * e
+ * r
+ * y
+ * */
+ 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)",
+ string_length, e_text);
+ appendPQExpBuffer(&query_buffer,
+ " AND (SELECT pg_catalog.count(*)"
+ " FROM pg_catalog.pg_namespace"
+ " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) ="
+ " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1",
+ string_length, e_text);
+
+ /*
+ * I
+ * f
+ *
+ * an
+ *
+ * ad
+ * d
+ * o
+ * n
+ *
+ * qu
+ * e
+ * r
+ * y
+ *
+ * wa
+ * s
+ *
+ * pr
+ * o
+ * v
+ * i
+ * d
+ * e
+ * d
+ * ,
+ *
+ * us
+ * e
+ *
+ * it
+ *
+ */
+ if (completion_charp)
+ appendPQExpBuffer(&query_buffer, "\n%s", completion_charp);
+ }
+ else
+ {
+ /*
+ * c
+ * o
+ * m
+ * p
+ * l
+ * e
+ * t
+ * i
+ * o
+ * n
+ * _
+ * c
+ * h
+ * a
+ * r
+ * p
+ *
+ * is
+ *
+ * an
+ *
+ * sp
+ * r
+ * i
+ * n
+ * t
+ * f
+ * -
+ * s
+ * t
+ * y
+ * l
+ * e
+ *
+ * fo
+ * r
+ * m
+ * a
+ * t
+ *
+ * st
+ * r
+ * i
+ * n
+ * g
+ *
+ */
+ appendPQExpBuffer(&query_buffer, completion_charp,
+ string_length, e_text, e_info_charp);
+ }
+
+ /*
+ * L
+ * i
+ * m
+ * i
+ * t
+ *
+ * th
+ * e
+ *
+ * nu
+ * m
+ * b
+ * e
+ * r
+ *
+ * of
+ *
+ * re
+ * c
+ * o
+ * r
+ * d
+ * s
+ *
+ * in
+ *
+ * th
+ * e
+ *
+ * re
+ * s
+ * u
+ * l
+ * t
+ *
+ */
+ appendPQExpBuffer(&query_buffer, "\nLIMIT %d",
+ completion_max_records);
+
+ result = exec_query(query_buffer.data);
+
+ termPQExpBuffer(&query_buffer);
+ free(e_text);
+ if (e_info_charp)
+ free(e_info_charp);
+ }
+
+ /*
+ * F
+ * i
+ * n
+ * d
+ *
+ * so
+ * m
+ * e
+ * t
+ * h
+ * i
+ * n
+ * g
+ *
+ * th
+ * a
+ * t
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ *
+ */
+ if (result && PQresultStatus(result) == PGRES_TUPLES_OK)
+ {
+ const char *item;
+
+ while (list_index < PQntuples(result) &&
+ (item = PQgetvalue(result, list_index++, 0)))
+ if (pg_strncasecmp(text, item, string_length) == 0)
+ return pg_strdup(item);
+ }
+
+ /*
+ * I
+ * f
+ *
+ * no
+ * t
+ * h
+ * i
+ * n
+ * g
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ * ,
+ *
+ * fr
+ * e
+ * e
+ *
+ * th
+ * e
+ *
+ * db
+ *
+ * st
+ * r
+ * u
+ * c
+ * t
+ * u
+ * r
+ * e
+ *
+ * an
+ * d
+ *
+ * re
+ * t
+ * u
+ * r
+ * n
+ *
+ * nu
+ * l
+ * l
+ *
+ */
+ PQclear(result);
+ result = NULL;
+ return NULL;
+ }
/* This function returns in order one of a fixed, NULL pointer terminated list
of strings (if matching). This can be used if there are only a fixed number
SQL words that can appear at certain spot.
*/
-static char *
-complete_from_list(const char *text, int state)
-{
- static int string_length,
- list_index,
- matches;
- static bool casesensitive;
- const char *item;
-
- /* need to have a list */
- psql_assert(completion_charpp);
-
- /* Initialization */
- if (state == 0)
- {
- list_index = 0;
- string_length = strlen(text);
- casesensitive = true;
- matches = 0;
- }
-
- while ((item = completion_charpp[list_index++]))
- {
- /* First pass is case sensitive */
- if (casesensitive && strncmp(text, item, string_length) == 0)
- {
- matches++;
- return pg_strdup(item);
- }
-
- /* Second pass is case insensitive, don't bother counting matches */
- if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0)
- return pg_strdup(item);
- }
-
- /*
- * No matches found. If we're not case insensitive already, lets
- * switch to being case insensitive and try again
- */
- if (casesensitive && matches == 0)
- {
- casesensitive = false;
- list_index = 0;
- state++;
- return (complete_from_list(text, state));
- }
-
- /* If no more matches, return null. */
- return NULL;
-}
+ static char *
+ complete_from_list(const char *text, int state)
+ {
+ static int string_length,
+ list_index,
+ matches;
+ static bool casesensitive;
+ const char *item;
+
+ /*
+ * n
+ * e
+ * e
+ * d
+ *
+ * to
+ *
+ * ha
+ * v
+ * e
+ *
+ * a
+ * li
+ * s
+ * t
+ *
+ */
+ psql_assert(completion_charpp);
+
+ /*
+ * I
+ * n
+ * i
+ * t
+ * i
+ * a
+ * l
+ * i
+ * z
+ * a
+ * t
+ * i
+ * o
+ * n
+ *
+ */
+ if (state == 0)
+ {
+ list_index = 0;
+ string_length = strlen(text);
+ casesensitive = true;
+ matches = 0;
+ }
+
+ while ((item = completion_charpp[list_index++]))
+ {
+ /*
+ * F
+ * i
+ * r
+ * s
+ * t
+ *
+ * pa
+ * s
+ * s
+ *
+ * is
+ *
+ * ca
+ * s
+ * e
+ *
+ * se
+ * n
+ * s
+ * i
+ * t
+ * i
+ * v
+ * e
+ *
+ */
+ if (casesensitive && strncmp(text, item, string_length) == 0)
+ {
+ matches++;
+ return pg_strdup(item);
+ }
+
+ /*
+ * S
+ * e
+ * c
+ * o
+ * n
+ * d
+ *
+ * pa
+ * s
+ * s
+ *
+ * is
+ *
+ * ca
+ * s
+ * e
+ *
+ * in
+ * s
+ * e
+ * n
+ * s
+ * i
+ * t
+ * i
+ * v
+ * e
+ * ,
+ *
+ * do
+ * n
+ * '
+ * t
+ *
+ * bo
+ * t
+ * h
+ * e
+ * r
+ *
+ * co
+ * u
+ * n
+ * t
+ * i
+ * n
+ * g
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ *
+ */
+ if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0)
+ return pg_strdup(item);
+ }
+
+ /*
+ *
+ * No
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ *
+ * fo
+ * u
+ * n
+ * d
+ * .
+ *
+ * If
+ *
+ * we
+ * '
+ * r
+ * e
+ *
+ * no
+ * t
+ *
+ * ca
+ * s
+ * e
+ *
+ * in
+ * s
+ * e
+ * n
+ * s
+ * i
+ * t
+ * i
+ * v
+ * e
+ *
+ * al
+ * r
+ * e
+ * a
+ * d
+ * y
+ * ,
+ *
+ * le
+ * t
+ * s
+ *
+ * sw
+ * i
+ * t
+ * c
+ * h
+ *
+ * to
+ *
+ * be
+ * i
+ * n
+ * g
+ *
+ * ca
+ * s
+ * e
+ *
+ * in
+ * s
+ * e
+ * n
+ * s
+ * i
+ * t
+ * i
+ * v
+ * e
+ *
+ * an
+ * d
+ *
+ * tr
+ * y
+ *
+ * ag
+ * a
+ * i
+ * n
+ * */
+ if (casesensitive && matches == 0)
+ {
+ casesensitive = false;
+ list_index = 0;
+ state++;
+ return (complete_from_list(text, state));
+ }
+
+ /*
+ * I
+ * f
+ *
+ * no
+ *
+ * mo
+ * r
+ * e
+ *
+ * ma
+ * t
+ * c
+ * h
+ * e
+ * s
+ * ,
+ *
+ * re
+ * t
+ * u
+ * r
+ * n
+ *
+ * nu
+ * l
+ * l
+ * .
+ *
+ */
+ return NULL;
+ }
/* This function returns one fixed string the first time even if it doesn't
@@ -2121,18 +3654,19 @@ complete_from_list(const char *text, int state)
will be overwritten.
The string to be passed must be in completion_charp.
*/
-static char *
-complete_from_const(const char *text, int state)
-{
- (void) text; /* We don't care about what was entered
- * already. */
+ static char *
+ complete_from_const(const char *text, int state)
+ {
+ (void) text; /* We don't care about
+ * what was entered
+ * already. */
- psql_assert(completion_charp);
- if (state == 0)
- return pg_strdup(completion_charp);
- else
- return NULL;
-}
+ psql_assert(completion_charp);
+ if (state == 0)
+ return pg_strdup(completion_charp);
+ else
+ return NULL;
+ }
@@ -2143,28 +3677,28 @@ complete_from_const(const char *text, int state)
* Execute a query and report any errors. This should be the preferred way of
* talking to the database in this file.
*/
-static PGresult *
-exec_query(const char *query)
-{
- PGresult *result;
+ static PGresult *
+ exec_query(const char *query)
+ {
+ PGresult *result;
- if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK)
- return NULL;
+ if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK)
+ return NULL;
- result = PQexec(pset.db, query);
+ result = PQexec(pset.db, query);
- if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK)
- {
+ if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK)
+ {
#if 0
- psql_error("tab completion: %s failed - %s\n",
- query, PQresStatus(PQresultStatus(result)));
+ psql_error("tab completion: %s failed - %s\n",
+ query, PQresStatus(PQresultStatus(result)));
#endif
- PQclear(result);
- result = NULL;
- }
+ PQclear(result);
+ result = NULL;
+ }
- return result;
-}
+ return result;
+ }
@@ -2173,61 +3707,344 @@ exec_query(const char *query)
* skip that many words; e.g. skip=1 finds the word before the
* previous one. Return value is NULL or a malloc'ed string.
*/
-static char *
-previous_word(int point, int skip)
-{
- int i,
- start = 0,
- end = -1,
- inquotes = 0;
- char *s;
-
- while (skip-- >= 0)
- {
- /* first we look for a space before the current word */
- for (i = point; i >= 0; i--)
- if (rl_line_buffer[i] == ' ')
- break;
-
- /* now find the first non-space which then constitutes the end */
- for (; i >= 0; i--)
- if (rl_line_buffer[i] != ' ')
- {
- end = i;
- break;
- }
-
- /*
- * If no end found we return null, because there is no word before
- * the point
- */
- if (end == -1)
- return NULL;
-
- /*
- * Otherwise we now look for the start. The start is either the
- * last character before any space going backwards from the end,
- * or it's simply character 0
- */
- for (start = end; start > 0; start--)
- {
- if (rl_line_buffer[start] == '"')
- inquotes = !inquotes;
- if ((rl_line_buffer[start - 1] == ' ') && inquotes == 0)
- break;
- }
-
- point = start;
- }
-
- /* make a copy */
- s = pg_malloc(end - start + 2);
-
- strncpy(s, &rl_line_buffer[start], end - start + 1);
- s[end - start + 1] = '\0';
-
- return s;
-}
+ static char *
+ previous_word(int point, int skip)
+ {
+ int i,
+ start = 0,
+ end = -1,
+ inquotes = 0;
+ char *s;
+
+ while (skip-- >= 0)
+ {
+ /*
+ * f
+ * i
+ * r
+ * s
+ * t
+ *
+ * we
+ *
+ * lo
+ * o
+ * k
+ *
+ * fo
+ * r
+ *
+ * a
+ * sp
+ * a
+ * c
+ * e
+ *
+ * be
+ * f
+ * o
+ * r
+ * e
+ *
+ * th
+ * e
+ *
+ * cu
+ * r
+ * r
+ * e
+ * n
+ * t
+ *
+ * wo
+ * r
+ * d
+ *
+ */
+ for (i = point; i >= 0; i--)
+ if (rl_line_buffer[i] == ' ')
+ break;
+
+ /*
+ * n
+ * o
+ * w
+ *
+ * fi
+ * n
+ * d
+ *
+ * th
+ * e
+ *
+ * fi
+ * r
+ * s
+ * t
+ *
+ * no
+ * n
+ * -
+ * s
+ * p
+ * a
+ * c
+ * e
+ *
+ * wh
+ * i
+ * c
+ * h
+ *
+ * th
+ * e
+ * n
+ *
+ * co
+ * n
+ * s
+ * t
+ * i
+ * t
+ * u
+ * t
+ * e
+ * s
+ *
+ * th
+ * e
+ *
+ * en
+ * d
+ *
+ */
+ for (; i >= 0; i--)
+ if (rl_line_buffer[i] != ' ')
+ {
+ end = i;
+ break;
+ }
+
+ /*
+ *
+ * If
+ *
+ * no
+ *
+ * en
+ * d
+ *
+ * fo
+ * u
+ * n
+ * d
+ *
+ * we
+ *
+ * re
+ * t
+ * u
+ * r
+ * n
+ *
+ * nu
+ * l
+ * l
+ * ,
+ *
+ * be
+ * c
+ * a
+ * u
+ * s
+ * e
+ *
+ * th
+ * e
+ * r
+ * e
+ *
+ * is
+ *
+ * no
+ *
+ * wo
+ * r
+ * d
+ *
+ * be
+ * f
+ * o
+ * r
+ * e
+ *
+ * th
+ * e
+ *
+ * po
+ * i
+ * n
+ * t
+ * */
+ if (end == -1)
+ return NULL;
+
+ /*
+ *
+ * Ot
+ * h
+ * e
+ * r
+ * w
+ * i
+ * s
+ * e
+ *
+ * we
+ *
+ * no
+ * w
+ *
+ * lo
+ * o
+ * k
+ *
+ * fo
+ * r
+ *
+ * th
+ * e
+ *
+ * st
+ * a
+ * r
+ * t
+ * .
+ *
+ * Th
+ * e
+ *
+ * st
+ * a
+ * r
+ * t
+ *
+ * is
+ *
+ * ei
+ * t
+ * h
+ * e
+ * r
+ *
+ * th
+ * e
+ *
+ * la
+ * s
+ * t
+ *
+ * ch
+ * a
+ * r
+ * a
+ * c
+ * t
+ * e
+ * r
+ *
+ * be
+ * f
+ * o
+ * r
+ * e
+ *
+ * an
+ * y
+ *
+ * sp
+ * a
+ * c
+ * e
+ *
+ * go
+ * i
+ * n
+ * g
+ *
+ * ba
+ * c
+ * k
+ * w
+ * a
+ * r
+ * d
+ * s
+ *
+ * fr
+ * o
+ * m
+ *
+ * th
+ * e
+ *
+ * en
+ * d
+ * ,
+ *
+ * or
+ *
+ * it
+ * '
+ * s
+ *
+ * si
+ * m
+ * p
+ * l
+ * y
+ *
+ * ch
+ * a
+ * r
+ * a
+ * c
+ * t
+ * e
+ * r
+ *
+ * 0
+ */
+ for (start = end; start > 0; start--)
+ {
+ if (rl_line_buffer[start] == '"')
+ inquotes = !inquotes;
+ if ((rl_line_buffer[start - 1] == ' ') && inquotes == 0)
+ break;
+ }
+
+ point = start;
+ }
+
+ /*
+ * m
+ * a
+ * k
+ * e
+ *
+ * a
+ * co
+ * p
+ * y
+ *
+ */
+ s = pg_malloc(end - start + 2);
+
+ strncpy(s, &rl_line_buffer[start], end - start + 1);
+ s[end - start + 1] = '\0';
+
+ return s;
+ }
@@ -2238,42 +4055,42 @@ previous_word(int point, int skip)
* psql internal. Currently disabled because it is reported not to
* cooperate with certain versions of readline.
*/
-static char *
-quote_file_name(char *text, int match_type, char *quote_pointer)
-{
- char *s;
- size_t length;
-
- (void) quote_pointer; /* not used */
-
- length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2);
- s = pg_malloc(length);
- s[0] = '\'';
- strcpy(s + 1, text);
- if (match_type == SINGLE_MATCH)
- s[length - 2] = '\'';
- s[length - 1] = '\0';
- return s;
-}
-
-
-
-static char *
-dequote_file_name(char *text, char quote_char)
-{
- char *s;
- size_t length;
-
- if (!quote_char)
- return pg_strdup(text);
-
- length = strlen(text);
- s = pg_malloc(length - 2 + 1);
- strncpy(s, text +1, length - 2);
- s[length] = '\0';
-
- return s;
-}
+ static char *
+ quote_file_name(char *text, int match_type, char *quote_pointer)
+ {
+ char *s;
+ size_t length;
+
+ (void) quote_pointer; /* not used */
+
+ length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2);
+ s = pg_malloc(length);
+ s[0] = '\'';
+ strcpy(s + 1, text);
+ if (match_type == SINGLE_MATCH)
+ s[length - 2] = '\'';
+ s[length - 1] = '\0';
+ return s;
+ }
+
+
+
+ static char *
+ dequote_file_name(char *text, char quote_char)
+ {
+ char *s;
+ size_t length;
+
+ if (!quote_char)
+ return pg_strdup(text);
+
+ length = strlen(text);
+ s = pg_malloc(length - 2 + 1);
+ strncpy(s, text +1, length - 2);
+ s[length] = '\0';
+
+ return s;
+ }
#endif /* 0 */
#endif /* USE_READLINE */
diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c
index 9763c2a9b2..3ee9701506 100644
--- a/src/bin/psql/variables.c
+++ b/src/bin/psql/variables.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.21 2005/01/01 05:43:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.22 2005/10/15 02:49:41 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -55,8 +55,8 @@ GetVariableBool(VariableSpace space, const char *name)
return false; /* accept "off" or "OFF" as true */
/*
- * for backwards compatibility, anything except "off" or "OFF" is
- * taken as "true"
+ * for backwards compatibility, anything except "off" or "OFF" is taken as
+ * "true"
*/
return true;
}
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 7036ef1b1c..c450df3c6e 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.18 2005/08/15 21:02:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.19 2005/10/15 02:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,7 +20,7 @@
#include "common.h"
#ifndef HAVE_INT_OPTRESET
-int optreset;
+int optreset;
#endif
@@ -97,8 +97,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
password = simple_prompt("Password: ", 100, false);
/*
- * Start the connection. Loop until we have a password if requested
- * by backend.
+ * Start the connection. Loop until we have a password if requested by
+ * backend.
*/
do
{
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index eac2674ea6..48b7214fde 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -4,7 +4,7 @@
*
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.11 2005/08/15 21:02:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.12 2005/10/15 02:49:41 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
@@ -14,7 +14,7 @@
#include "getopt_long.h"
#ifndef HAVE_INT_OPTRESET
-extern int optreset;
+extern int optreset;
#endif
typedef void (*help_handler) (const char *progname);
@@ -22,19 +22,19 @@ typedef void (*help_handler) (const char *progname);
extern const char *get_user_name(const char *progname);
extern void handle_help_version_opts(int argc, char *argv[],
- const char *fixed_progname,
- help_handler hlp);
+ const char *fixed_progname,
+ help_handler hlp);
extern PGconn *connectDatabase(const char *dbname, const char *pghost,
- const char *pgport, const char *pguser,
- bool require_password, const char *progname);
+ const char *pgport, const char *pguser,
+ bool require_password, const char *progname);
extern PGresult *executeQuery(PGconn *conn, const char *query,
- const char *progname, bool echo);
+ const char *progname, bool echo);
extern void executeCommand(PGconn *conn, const char *query,
- const char *progname, bool echo);
+ const char *progname, bool echo);
extern int check_yesno_response(const char *string);
-#endif /* COMMON_H */
+#endif /* COMMON_H */
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c
index 58e8a3703a..d66012a51a 100644
--- a/src/bin/scripts/createlang.c
+++ b/src/bin/scripts/createlang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.20 2005/09/05 23:50:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.21 2005/10/15 02:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -131,8 +131,8 @@ main(int argc, char *argv[])
progname);
printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", "
- "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
- "FROM pg_catalog.pg_language WHERE lanispl;",
+ "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
+ "FROM pg_catalog.pg_language WHERE lanispl;",
_("Name"), _("yes"), _("no"), _("Trusted?"));
result = executeQuery(conn, sql.data, progname, echo);
@@ -163,15 +163,15 @@ main(int argc, char *argv[])
/*
* Make sure the language isn't already installed
*/
- printfPQExpBuffer(&sql,
- "SELECT oid FROM pg_catalog.pg_language WHERE lanname = '%s';",
+ printfPQExpBuffer(&sql,
+ "SELECT oid FROM pg_catalog.pg_language WHERE lanname = '%s';",
langname);
result = executeQuery(conn, sql.data, progname, echo);
if (PQntuples(result) > 0)
{
PQfinish(conn);
fprintf(stderr,
- _("%s: language \"%s\" is already installed in database \"%s\"\n"),
+ _("%s: language \"%s\" is already installed in database \"%s\"\n"),
progname, langname, dbname);
/* separate exit status for "already installed" */
exit(2);
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index f3f906049c..a7de05a75d 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.20 2005/09/30 07:58:01 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.21 2005/10/15 02:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -313,7 +313,7 @@ help(const char *progname)
printf(_(" -l, --login role can login (default)\n"));
printf(_(" -L, --no-login role cannot login\n"));
printf(_(" -i, --inherit role inherits privileges of roles it is a\n"
- " member of (default)\n"));
+ " member of (default)\n"));
printf(_(" -I, --no-inherit role does not inherit privileges\n"));
printf(_(" -c, --connection-limit=N connection limit for role (default: no limit)\n"));
printf(_(" -P, --pwprompt assign a password to new role\n"));
@@ -329,6 +329,6 @@ help(const char *progname)
printf(_(" -U, --username=USERNAME user name to connect as (not the one to create)\n"));
printf(_(" -W, --password prompt for password to connect\n"));
printf(_("\nIf one of -s, -S, -d, -D, -r, -R and ROLENAME is not specified, you will\n"
- "be prompted interactively.\n"));
+ "be prompted interactively.\n"));
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
}
diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c
index 52eb06986e..f85c83b409 100644
--- a/src/bin/scripts/droplang.c
+++ b/src/bin/scripts/droplang.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.17 2005/08/15 21:02:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.18 2005/10/15 02:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -137,12 +137,12 @@ main(int argc, char *argv[])
{
printQueryOpt popt;
- conn = connectDatabase(dbname, host, port, username, password,
+ conn = connectDatabase(dbname, host, port, username, password,
progname);
printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", "
- "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
- "FROM pg_catalog.pg_language WHERE lanispl;",
+ "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
+ "FROM pg_catalog.pg_language WHERE lanispl;",
_("Name"), _("yes"), _("no"), _("Trusted?"));
result = executeQuery(conn, sql.data, progname, echo);
@@ -159,9 +159,9 @@ main(int argc, char *argv[])
if (langname == NULL)
{
- fprintf(stderr, _("%s: missing required argument language name\n"),
+ fprintf(stderr, _("%s: missing required argument language name\n"),
progname);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
exit(1);
}
@@ -173,18 +173,18 @@ main(int argc, char *argv[])
conn = connectDatabase(dbname, host, port, username, password, progname);
/*
- * Force schema search path to be just pg_catalog, so that we don't
- * have to be paranoid about search paths below.
+ * Force schema search path to be just pg_catalog, so that we don't have
+ * to be paranoid about search paths below.
*/
executeCommand(conn, "SET search_path = pg_catalog;",
progname, echo);
/*
- * 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;",
+ "FROM pg_language WHERE lanname = '%s' AND lanispl;",
langname);
result = executeQuery(conn, sql.data, progname, echo);
if (PQntuples(result) == 0)
@@ -221,7 +221,7 @@ main(int argc, char *argv[])
* Check that the handler function isn't used by some other language
*/
printfPQExpBuffer(&sql, "SELECT count(*) FROM pg_language "
- "WHERE lanplcallfoid = %u AND lanname <> '%s';",
+ "WHERE lanplcallfoid = %u AND lanname <> '%s';",
lanplcallfoid, langname);
result = executeQuery(conn, sql.data, progname, echo);
if (strcmp(PQgetvalue(result, 0, 0), "0") == 0)
@@ -237,7 +237,7 @@ main(int argc, char *argv[])
{
printfPQExpBuffer(&sql, "SELECT proname, (SELECT nspname "
"FROM pg_namespace ns WHERE ns.oid = pronamespace) "
- "AS prons FROM pg_proc WHERE oid = %u;",
+ "AS prons FROM pg_proc WHERE oid = %u;",
lanplcallfoid);
result = executeQuery(conn, sql.data, progname, echo);
handler = strdup(PQgetvalue(result, 0, 0));
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
if (OidIsValid(lanvalidator))
{
printfPQExpBuffer(&sql, "SELECT count(*) FROM pg_language "
- "WHERE lanvalidator = %u AND lanname <> '%s';",
+ "WHERE lanvalidator = %u AND lanname <> '%s';",
lanvalidator, langname);
result = executeQuery(conn, sql.data, progname, echo);
if (strcmp(PQgetvalue(result, 0, 0), "0") == 0)
@@ -275,7 +275,7 @@ main(int argc, char *argv[])
{
printfPQExpBuffer(&sql, "SELECT proname, (SELECT nspname "
"FROM pg_namespace ns WHERE ns.oid = pronamespace) "
- "AS prons FROM pg_proc WHERE oid = %u;",
+ "AS prons FROM pg_proc WHERE oid = %u;",
lanvalidator);
result = executeQuery(conn, sql.data, progname, echo);
validator = strdup(PQgetvalue(result, 0, 0));
@@ -293,10 +293,10 @@ main(int argc, char *argv[])
*/
printfPQExpBuffer(&sql, "DROP LANGUAGE \"%s\";\n", langname);
if (!keephandler)
- appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" ();\n",
+ appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" ();\n",
handler_ns, handler);
if (!keepvalidator)
- appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" (oid);\n",
+ appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" (oid);\n",
validator_ns, validator);
if (echo)
printf("%s", sql.data);
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index 5b4cbc79f5..b1cdb47ae3 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.3 2005/09/30 09:56:26 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.4 2005/10/15 02:49:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,19 +15,19 @@
static void reindex_one_database(const char *name, const char *dbname,
- const char *type, const char *host,
- const char *port, const char *username,
- bool password, const char *progname,
- bool echo, bool quiet);
+ const char *type, const char *host,
+ const char *port, const char *username,
+ bool password, const char *progname,
+ bool echo, bool quiet);
static void reindex_all_databases(const char *host, const char *port,
- const char *username, bool password,
- const char *progname, bool echo,
- bool quiet);
+ const char *username, bool password,
+ const char *progname, bool echo,
+ bool quiet);
static void reindex_system_catalogs(const char *dbname,
- const char *host, const char *port,
- const char *username, bool password,
- const char *progname, bool echo,
- bool quiet);
+ const char *host, const char *port,
+ const char *username, bool password,
+ const char *progname, bool echo,
+ bool quiet);
static void help(const char *progname);
int
@@ -48,22 +48,22 @@ main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
- const char *progname;
- int optindex;
- int c;
+ const char *progname;
+ int optindex;
+ int c;
- const char *dbname = NULL;
- const char *host = NULL;
- const char *port = NULL;
- const char *username = NULL;
+ const char *dbname = NULL;
+ const char *host = NULL;
+ const char *port = NULL;
+ const char *username = NULL;
bool password = false;
bool syscatalog = false;
bool alldb = false;
bool echo = false;
bool quiet = false;
- const char *table = NULL;
- const char *index = NULL;
-
+ const char *table = NULL;
+ const char *index = NULL;
+
progname = get_progname(argv[0]);
set_pglocale_pgservice(argv[0], "pgscripts");
@@ -150,7 +150,7 @@ main(int argc, char *argv[])
}
reindex_all_databases(host, port, username, password,
- progname, echo, quiet);
+ progname, echo, quiet);
}
else if (syscatalog)
{
@@ -176,7 +176,7 @@ main(int argc, char *argv[])
}
reindex_system_catalogs(dbname, host, port, username, password,
- progname, echo, quiet);
+ progname, echo, quiet);
}
else
{
@@ -192,14 +192,14 @@ main(int argc, char *argv[])
if (index)
reindex_one_database(index, dbname, "INDEX", host, port,
- username, password, progname, echo, quiet);
+ username, password, progname, echo, quiet);
if (table)
reindex_one_database(table, dbname, "TABLE", host, port,
- username, password, progname, echo, quiet);
+ username, password, progname, echo, quiet);
/* reindex database only if index or table is not specified */
if (index == NULL && table == NULL)
reindex_one_database(dbname, dbname, "DATABASE", host, port,
- username, password, progname, echo, quiet);
+ username, password, progname, echo, quiet);
}
exit(0);
@@ -207,14 +207,14 @@ main(int argc, char *argv[])
static void
reindex_one_database(const char *name, const char *dbname, const char *type,
- const char *host, const char *port, const char *username,
- bool password, const char *progname, bool echo,
- bool quiet)
+ const char *host, const char *port, const char *username,
+ bool password, const char *progname, bool echo,
+ bool quiet)
{
- PQExpBufferData sql;
+ PQExpBufferData sql;
- PGconn *conn;
- PGresult *result;
+ PGconn *conn;
+ PGresult *result;
initPQExpBuffer(&sql);
@@ -228,7 +228,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
appendPQExpBuffer(&sql, ";\n");
conn = connectDatabase(dbname, host, port, username, password, progname);
-
+
if (echo)
printf("%s", sql.data);
result = PQexec(conn, sql.data);
@@ -261,12 +261,12 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
static void
reindex_all_databases(const char *host, const char *port,
- const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+ const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
- PGconn *conn;
- PGresult *result;
- int i;
+ PGconn *conn;
+ PGresult *result;
+ int i;
conn = connectDatabase("postgres", host, port, username, password, progname);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo);
@@ -274,13 +274,13 @@ reindex_all_databases(const char *host, const char *port,
for (i = 0; i < PQntuples(result); i++)
{
- char *dbname = PQgetvalue(result, i, 0);
+ char *dbname = PQgetvalue(result, i, 0);
if (!quiet)
fprintf(stderr, _("%s: reindexing database \"%s\"\n"), progname, dbname);
reindex_one_database(dbname, dbname, "DATABASE", host, port, username,
- password, progname, echo, quiet);
+ password, progname, echo, quiet);
}
PQclear(result);
@@ -288,20 +288,20 @@ reindex_all_databases(const char *host, const char *port,
static void
reindex_system_catalogs(const char *dbname, const char *host, const char *port,
- const char *username, bool password,
- const char *progname, bool echo, bool quiet)
+ const char *username, bool password,
+ const char *progname, bool echo, bool quiet)
{
- PQExpBufferData sql;
+ PQExpBufferData sql;
- PGconn *conn;
- PGresult *result;
+ PGconn *conn;
+ PGresult *result;
initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "REINDEX SYSTEM %s;\n", dbname);
conn = connectDatabase(dbname, host, port, username, password, progname);
-
+
if (echo)
printf("%s", sql.data);
result = PQexec(conn, sql.data);
@@ -309,7 +309,7 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port,
if (PQresultStatus(result) != PGRES_COMMAND_OK)
{
fprintf(stderr, _("%s: reindexing of system catalogs failed: %s"),
- progname, PQerrorMessage(conn));
+ progname, PQerrorMessage(conn));
PQfinish(conn);
exit(1);
}