diff options
author | Cédric Villemain | 2011-05-13 20:55:39 +0000 |
---|---|---|
committer | Cédric Villemain | 2011-05-13 20:55:39 +0000 |
commit | e0c3b474d5436c7874aef36988f2646bdb890249 (patch) | |
tree | 49c41d2b8abbd9bae4096643d840859f3a02a08c | |
parent | 40cefa392974c73ec20deb3c15fb5111ed7fad17 (diff) | |
parent | 9bb6d9795253bb521f81c626fea49a704a369ca9 (diff) |
Merge branch 'master' into analyze_cacheanalyze_cache
122 files changed, 724 insertions, 545 deletions
@@ -29704,7 +29704,8 @@ $as_echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;} # Create compiler version string if test x"$GCC" = x"yes" ; then - cc_string="GCC `${CC} --version | sed q`" + cc_string=`${CC} --version | sed q` + case $cc_string in [A-Za-z]*) ;; *) cc_string="GCC $cc_string";; esac elif test x"$SUN_STUDIO_CC" = x"yes" ; then cc_string=`${CC} -V 2>&1 | sed q` else diff --git a/configure.in b/configure.in index fa6d9e5d7c..0a85a05641 100644 --- a/configure.in +++ b/configure.in @@ -1849,7 +1849,8 @@ AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS]) # Create compiler version string if test x"$GCC" = x"yes" ; then - cc_string="GCC `${CC} --version | sed q`" + cc_string=`${CC} --version | sed q` + case $cc_string in [[A-Za-z]]*) ;; *) cc_string="GCC $cc_string";; esac elif test x"$SUN_STUDIO_CC" = x"yes" ; then cc_string=`${CC} -V 2>&1 | sed q` else diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/contrib/pg_archivecleanup/pg_archivecleanup.c index d96eef2c5a..dd8a45133c 100644 --- a/contrib/pg_archivecleanup/pg_archivecleanup.c +++ b/contrib/pg_archivecleanup/pg_archivecleanup.c @@ -203,19 +203,19 @@ usage(void) printf("%s removes older WAL files from PostgreSQL archives.\n\n", progname); printf("Usage:\n"); printf(" %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n", progname); + printf("\nOptions:\n"); + printf(" -d generates debug output (verbose mode)\n"); + printf(" --help show this help, then exit\n"); + printf(" --version output version information, then exit\n"); printf("\n" - "for use as an archive_cleanup_command in the recovery.conf when standby_mode = on:\n" + "For use as archive_cleanup_command in recovery.conf when standby_mode = on:\n" " archive_cleanup_command = 'pg_archivecleanup [OPTION]... ARCHIVELOCATION %%r'\n" "e.g.\n" " archive_cleanup_command = 'pg_archivecleanup /mnt/server/archiverdir %%r'\n"); printf("\n" - "or for use as a standalone archive cleaner:\n" + "Or for use as a standalone archive cleaner:\n" "e.g.\n" " pg_archivecleanup /mnt/server/archiverdir 000000010000000000000010.00000020.backup\n"); - printf("\nOptions:\n"); - printf(" -d generates debug output (verbose mode)\n"); - printf(" --help show this help, then exit\n"); - printf(" --version output version information, then exit\n"); printf("\nReport bugs to <[email protected]>.\n"); } diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index f25015fd14..7204b447da 100644 --- a/contrib/pg_standby/pg_standby.c +++ b/contrib/pg_standby/pg_standby.c @@ -119,7 +119,7 @@ struct stat stat_buf; * accessible directory. If you want to make other assumptions, * such as using a vendor-specific archive and access API, these * routines are the ones you'll need to change. You're - * enouraged to submit any changes to [email protected] + * encouraged to submit any changes to [email protected] * or personally to the current maintainer. Those changes may be * folded in to later versions of this program. */ @@ -252,7 +252,7 @@ CustomizableCleanupPriorWALFiles(void) /* * Assume it's OK to keep failing. The failure situation may change * over time, so we'd rather keep going on the main processing than - * fail because we couldnt clean up yet. + * fail because we couldn't clean up yet. */ if ((xldir = opendir(archiveLocation)) != NULL) { @@ -515,11 +515,6 @@ usage(void) printf("%s allows PostgreSQL warm standby servers to be configured.\n\n", progname); printf("Usage:\n"); printf(" %s [OPTION]... ARCHIVELOCATION NEXTWALFILE XLOGFILEPATH [RESTARTWALFILE]\n", progname); - printf("\n" - "with main intended use as a restore_command in the recovery.conf:\n" - " restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n" - "e.g.\n" - " restore_command = 'pg_standby -l /mnt/server/archiverdir %%f %%p %%r'\n"); printf("\nOptions:\n"); printf(" -c copies file from archive (default)\n"); printf(" -d generate lots of debugging output (testing only)\n"); @@ -534,6 +529,11 @@ usage(void) printf(" -w MAXWAITTIME max seconds to wait for a file (0=no limit) (default=0)\n"); printf(" --help show this help, then exit\n"); printf(" --version output version information, then exit\n"); + printf("\n" + "Main intended use as restore_command in recovery.conf:\n" + " restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n" + "e.g.\n" + " restore_command = 'pg_standby /mnt/server/archiverdir %%f %%p %%r'\n"); printf("\nReport bugs to <[email protected]>.\n"); } diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/contrib/pg_test_fsync/pg_test_fsync.c index 2b2e292022..3791f5a071 100644 --- a/contrib/pg_test_fsync/pg_test_fsync.c +++ b/contrib/pg_test_fsync/pg_test_fsync.c @@ -96,12 +96,12 @@ handle_args(int argc, char *argv[]) if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-?") == 0) { - fprintf(stderr, "%s [-f filename] [-o ops-per-test]\n", progname); + printf("Usage: %s [-f FILENAME] [-o OPS-PER-TEST]\n", progname); exit(0); } if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) { - fprintf(stderr, "%s %s\n", progname, PG_VERSION); + puts("pg_test_fsync (PostgreSQL) " PG_VERSION); exit(0); } } diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c index a9436ce5b2..ebdc34e188 100644 --- a/contrib/pg_upgrade/check.c +++ b/contrib/pg_upgrade/check.c @@ -15,6 +15,7 @@ static void check_new_cluster_is_empty(void); static void check_old_cluster_has_new_cluster_dbs(void); static void check_locale_and_encoding(ControlData *oldctrl, ControlData *newctrl); +static void check_is_super_user(ClusterInfo *cluster); static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster); static void check_for_reg_data_type_usage(ClusterInfo *cluster); @@ -63,7 +64,7 @@ check_old_cluster(bool live_check, /* * Check for various failure cases */ - + check_is_super_user(&old_cluster); check_for_reg_data_type_usage(&old_cluster); check_for_isn_and_int8_passing_mismatch(&old_cluster); @@ -253,7 +254,7 @@ check_cluster_compatibility(bool live_check) if ((lib_test = fopen(libfile, "r")) == NULL) pg_log(PG_FATAL, - "\npg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile); + "pg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile); else fclose(lib_test); @@ -473,6 +474,37 @@ create_script_for_old_cluster_deletion( /* + * check_is_super_user() + * + * Make sure we are the super-user. + */ +static void +check_is_super_user(ClusterInfo *cluster) +{ + PGresult *res; + PGconn *conn = connectToServer(cluster, "template1"); + + prep_status("Checking database user is a superuser"); + + /* Can't use pg_authid because only superusers can view it. */ + res = executeQueryOrDie(conn, + "SELECT rolsuper " + "FROM pg_catalog.pg_roles " + "WHERE rolname = current_user"); + + if (PQntuples(res) != 1 || strcmp(PQgetvalue(res, 0, 0), "t") != 0) + pg_log(PG_FATAL, "database user \"%s\" is not a superuser\n", + os_info.user); + + PQclear(res); + + PQfinish(conn); + + check_ok(); +} + + +/* * check_for_isn_and_int8_passing_mismatch() * * /contrib/isn relies on data type int8, and in 8.4 int8 can now be passed diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c index 59a76bc8ae..71e84394e6 100644 --- a/contrib/pg_upgrade/exec.c +++ b/contrib/pg_upgrade/exec.c @@ -46,7 +46,7 @@ exec_prog(bool throw_error, const char *fmt,...) if (result != 0) { pg_log(throw_error ? PG_FATAL : PG_INFO, - "\nThere were problems executing %s\n", cmd); + "There were problems executing %s\n", cmd); return 1; } @@ -71,7 +71,7 @@ is_server_running(const char *datadir) if ((fd = open(path, O_RDONLY, 0)) < 0) { if (errno != ENOENT) - pg_log(PG_FATAL, "\ncould not open file \"%s\" for reading\n", + pg_log(PG_FATAL, "could not open file \"%s\" for reading\n", path); return false; @@ -139,10 +139,10 @@ check_data_dir(const char *pg_data) requiredSubdirs[subdirnum]); if (stat(subDirName, &statBuf) != 0) - report_status(PG_FATAL, "check for %s failed: %s", + report_status(PG_FATAL, "check for %s failed: %s\n", requiredSubdirs[subdirnum], getErrorText(errno)); else if (!S_ISDIR(statBuf.st_mode)) - report_status(PG_FATAL, "%s is not a directory", + report_status(PG_FATAL, "%s is not a directory\n", requiredSubdirs[subdirnum]); } } diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c index 0552541c24..a7e40090e2 100644 --- a/contrib/pg_upgrade/file.c +++ b/contrib/pg_upgrade/file.c @@ -287,7 +287,7 @@ pg_scandir_internal(const char *dirname, size_t entrysize; if ((dirdesc = opendir(dirname)) == NULL) - pg_log(PG_FATAL, "Could not open directory \"%s\": %m\n", dirname); + pg_log(PG_FATAL, "could not open directory \"%s\": %m\n", dirname); *namelist = NULL; diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c index 857d6528c8..36561b9b4c 100644 --- a/contrib/pg_upgrade/option.c +++ b/contrib/pg_upgrade/option.c @@ -81,7 +81,7 @@ parseCommandLine(int argc, char *argv[]) } if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) { - pg_log(PG_REPORT, "pg_upgrade " PG_VERSION "\n"); + puts("pg_upgrade (PostgreSQL) " PG_VERSION); exit(0); } } @@ -180,10 +180,10 @@ parseCommandLine(int argc, char *argv[]) */ /* truncate */ if ((log_opts.fd = fopen(log_opts.filename, "w")) == NULL) - pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename); + pg_log(PG_FATAL, "cannot write to log file %s\n", log_opts.filename); fclose(log_opts.fd); if ((log_opts.fd = fopen(log_opts.filename, "a")) == NULL) - pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename); + pg_log(PG_FATAL, "cannot write to log file %s\n", log_opts.filename); } else log_opts.filename = strdup(DEVNULL); @@ -193,7 +193,7 @@ parseCommandLine(int argc, char *argv[]) { log_opts.debug_fd = fopen(DEVTTY, "w"); if (!log_opts.debug_fd) - pg_log(PG_FATAL, "Cannot write to terminal\n"); + pg_log(PG_FATAL, "cannot write to terminal\n"); } /* Get values from env if not already set */ @@ -213,24 +213,26 @@ parseCommandLine(int argc, char *argv[]) static void usage(void) { - printf(_("\nUsage: pg_upgrade [OPTIONS]...\n\ + printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\ +\nUsage:\n\ + pg_upgrade [OPTIONS]...\n\ \n\ Options:\n\ - -b, --old-bindir=old_bindir old cluster executable directory\n\ - -B, --new-bindir=new_bindir new cluster executable directory\n\ - -c, --check check clusters only, don't change any data\n\ - -d, --old-datadir=old_datadir old cluster data directory\n\ - -D, --new-datadir=new_datadir new cluster data directory\n\ - -g, --debug enable debugging\n\ - -G, --debugfile=debug_filename output debugging activity to file\n\ - -k, --link link instead of copying files to new cluster\n\ - -l, --logfile=log_filename log session activity to file\n\ - -p, --old-port=old_portnum old cluster port number (default %d)\n\ - -P, --new-port=new_portnum new cluster port number (default %d)\n\ - -u, --user=username clusters superuser (default \"%s\")\n\ - -v, --verbose enable verbose output\n\ - -V, --version display version information, then exit\n\ - -h, --help show this help, then exit\n\ + -b, --old-bindir=OLDBINDIR old cluster executable directory\n\ + -B, --new-bindir=NEWBINDIR new cluster executable directory\n\ + -c, --check check clusters only, don't change any data\n\ + -d, --old-datadir=OLDDATADIR old cluster data directory\n\ + -D, --new-datadir=NEWDATADIR new cluster data directory\n\ + -g, --debug enable debugging\n\ + -G, --debugfile=FILENAME output debugging activity to file\n\ + -k, --link link instead of copying files to new cluster\n\ + -l, --logfile=FILENAME log session activity to file\n\ + -p, --old-port=OLDPORT old cluster port number (default %d)\n\ + -P, --new-port=NEWPORT new cluster port number (default %d)\n\ + -u, --user=NAME clusters superuser (default \"%s\")\n\ + -v, --verbose enable verbose output\n\ + -V, --version display version information, then exit\n\ + -h, --help show this help, then exit\n\ \n\ Before running pg_upgrade you must:\n\ create a new database cluster (using the new version of initdb)\n\ @@ -240,8 +242,8 @@ Before running pg_upgrade you must:\n\ When you run pg_upgrade, you must provide the following information:\n\ the data directory for the old cluster (-d OLDDATADIR)\n\ the data directory for the new cluster (-D NEWDATADIR)\n\ - the 'bin' directory for the old version (-b OLDBINDIR)\n\ - the 'bin' directory for the new version (-B NEWBINDIR)\n\ + the \"bin\" directory for the old version (-b OLDBINDIR)\n\ + the \"bin\" directory for the new version (-B NEWBINDIR)\n\ \n\ For example:\n\ pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n\ @@ -261,6 +263,7 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user); C:\\> set NEWBINDIR=newCluster/bin\n\ C:\\> pg_upgrade\n")); #endif + printf(_("\nReport bugs to <[email protected]>.\n")); } diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index 9f7a538765..857e82901b 100644 --- a/contrib/pg_upgrade/pg_upgrade.c +++ b/contrib/pg_upgrade/pg_upgrade.c @@ -302,7 +302,7 @@ copy_clog_xlog_xid(void) snprintf(old_clog_path, sizeof(old_clog_path), "%s/pg_clog", old_cluster.pgdata); snprintf(new_clog_path, sizeof(new_clog_path), "%s/pg_clog", new_cluster.pgdata); if (!rmtree(new_clog_path, true)) - pg_log(PG_FATAL, "Unable to delete directory %s\n", new_clog_path); + pg_log(PG_FATAL, "unable to delete directory %s\n", new_clog_path); check_ok(); prep_status("Copying old commit clogs to new server"); diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c index 935ce32a61..8fce305d2e 100644 --- a/contrib/pg_upgrade/server.c +++ b/contrib/pg_upgrade/server.c @@ -27,7 +27,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name) if (conn == NULL || PQstatus(conn) != CONNECTION_OK) { - pg_log(PG_REPORT, "Connection to database failed: %s\n", + pg_log(PG_REPORT, "connection to database failed: %s\n", PQerrorMessage(conn)); if (conn) @@ -189,10 +189,11 @@ start_postmaster(ClusterInfo *cluster) if ((conn = get_db_conn(cluster, "template1")) == NULL || PQstatus(conn) != CONNECTION_OK) { - if (conn) + pg_log(PG_REPORT, "\nconnection to database failed: %s\n", + PQerrorMessage(conn)); + if (conn) PQfinish(conn); - pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n" - "Perhaps pg_hba.conf was not set to \"trust\".", + pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n", CLUSTER_NAME(cluster), cmd); } PQfinish(conn); @@ -265,6 +266,7 @@ check_for_libpq_envvars(void) { const char *value; + /* This allows us to see error messages in the local encoding */ if (strcmp(option->envvar, "PGCLIENTENCODING") == 0) continue; diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c index 9a6691ce75..9b0bf0f82a 100644 --- a/contrib/pg_upgrade/util.c +++ b/contrib/pg_upgrade/util.c @@ -46,7 +46,7 @@ report_status(eLogType type, const char *fmt,...) * if(( message = flarbFiles(fileCount)) == NULL) * report_status(PG_REPORT, "ok" ); * else - * pg_log(PG_FATAL, "failed - %s", message ); + * pg_log(PG_FATAL, "failed - %s\n", message ); */ void prep_status(const char *fmt,...) @@ -97,8 +97,7 @@ pg_log(eLogType type, char *fmt,...) break; case PG_FATAL: - printf("%s", "\n"); - printf("%s", _(message)); + printf("\n%s", _(message)); printf("Failure, exiting\n"); exit(1); break; diff --git a/contrib/pg_upgrade/version.c b/contrib/pg_upgrade/version.c index 8ba7e98d92..958bcbb80f 100644 --- a/contrib/pg_upgrade/version.c +++ b/contrib/pg_upgrade/version.c @@ -49,7 +49,7 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) if (!check_mode) { if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); fprintf(script, "\\connect %s\n", quote_identifier(active_db->db_name)); fprintf(script, diff --git a/contrib/pg_upgrade/version_old_8_3.c b/contrib/pg_upgrade/version_old_8_3.c index 0a60eec926..1a31f8d683 100644 --- a/contrib/pg_upgrade/version_old_8_3.c +++ b/contrib/pg_upgrade/version_old_8_3.c @@ -70,7 +70,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) { found = true; if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); @@ -160,7 +160,7 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster) { found = true; if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); @@ -278,7 +278,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode) if (!check_mode) { if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "\\connect %s\n\n", @@ -398,7 +398,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) if (!check_mode) { if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "\\connect %s\n", @@ -523,7 +523,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster, if (!check_mode) { if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "\\connect %s\n", @@ -648,7 +648,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster) found = true; if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); + pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); if (!db_used) { fprintf(script, "\\connect %s\n\n", diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 0a3e5fd928..bb18c8907d 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -341,12 +341,12 @@ usage(const char *progname) " define variable for use by custom script\n" " -f FILENAME read transaction script from FILENAME\n" " -j NUM number of threads (default: 1)\n" - " -r report average latency per command\n" " -l write transaction times to log file\n" " -M {simple|extended|prepared}\n" " protocol for submitting queries to server (default: simple)\n" " -n do not run VACUUM before tests\n" " -N do not update tables \"pgbench_tellers\" and \"pgbench_branches\"\n" + " -r report average latency per command\n" " -s NUM report this scale factor in output\n" " -S perform SELECT-only transactions\n" " -t NUM number of transactions each client runs (default: 10)\n" diff --git a/doc/src/sgml/README.links b/doc/src/sgml/README.links index 8608859eac..2668b00d7f 100644 --- a/doc/src/sgml/README.links +++ b/doc/src/sgml/README.links @@ -7,8 +7,8 @@ Intra-document Linking ---------------------- <xref> - use to get link text from the title of the target link; has no - close tag + use to get chapter/section # from the title of the target + link, or xreflabel if defined at the target; has no close tag http://www.oasis-open.org/docbook/documentation/reference/html/xref.html <link> @@ -28,7 +28,8 @@ External Linking <ulink> like <link>, but uses a URL (not a document target); requires - </ulink>; if no text is specified, the URL appears as the link text + </ulink>; if no text is specified, the URL appears as the link + text http://www.oasis-open.org/docbook/documentation/reference/html/ulink.html url= @@ -40,4 +41,5 @@ Guidelines o If you want to supply text, use <link>, else <xref> o Do not use text with <ulink> so the URL appears in printed output -o You can supply text at the target location with 'xreflabel' +o Specific nouns like GUC variables, SQL commands, and contrib modules + usually have xreflabels diff --git a/doc/src/sgml/adminpack.sgml b/doc/src/sgml/adminpack.sgml index 27d0034329..9b72f34ead 100644 --- a/doc/src/sgml/adminpack.sgml +++ b/doc/src/sgml/adminpack.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/adminpack.sgml --> -<sect1 id="adminpack"> +<sect1 id="adminpack" xreflabel="adminpack"> <title>adminpack</title> <indexterm zone="adminpack"> diff --git a/doc/src/sgml/auth-delay.sgml b/doc/src/sgml/auth-delay.sgml index 9f1f3f645a..b91a7ecda7 100644 --- a/doc/src/sgml/auth-delay.sgml +++ b/doc/src/sgml/auth-delay.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/auth-delay.sgml --> -<sect1 id="auth-delay"> +<sect1 id="auth-delay" xreflabel="auth_delay"> <title>auth_delay</title> <indexterm zone="auth-delay"> diff --git a/doc/src/sgml/auto-explain.sgml b/doc/src/sgml/auto-explain.sgml index 405e3f72b4..b16f9064ff 100644 --- a/doc/src/sgml/auto-explain.sgml +++ b/doc/src/sgml/auto-explain.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/auto-explain.sgml --> -<sect1 id="auto-explain"> +<sect1 id="auto-explain" xreflabel="auto_explain"> <title>auto_explain</title> <indexterm zone="auto-explain"> diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 0fbf1225aa..2a1c2939e2 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -401,7 +401,7 @@ tar -cf backup.tar /usr/local/pgsql/data <para> If simultaneous snapshots are not possible, one option is to shut down the database server long enough to establish all the frozen snapshots. - Another option is perform a continuous archiving base backup (<xref + Another option is to perform a continuous archiving base backup (<xref linkend="backup-base-backup">) because such backups are immune to file system changes during the backup. This requires enabling continuous archiving just during the backup process; restore is done using diff --git a/doc/src/sgml/btree-gin.sgml b/doc/src/sgml/btree-gin.sgml index 632bd1e53a..42b9e97b72 100644 --- a/doc/src/sgml/btree-gin.sgml +++ b/doc/src/sgml/btree-gin.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/btree-gin.sgml --> -<sect1 id="btree-gin"> +<sect1 id="btree-gin" xreflabel="btree_gin"> <title>btree_gin</title> <indexterm zone="btree-gin"> diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml index af3f707bb9..e52971f3d9 100644 --- a/doc/src/sgml/btree-gist.sgml +++ b/doc/src/sgml/btree-gist.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/btree-gist.sgml --> -<sect1 id="btree-gist"> +<sect1 id="btree-gist" xreflabel="btree_gist"> <title>btree_gist</title> <indexterm zone="btree-gist"> diff --git a/doc/src/sgml/chkpass.sgml b/doc/src/sgml/chkpass.sgml index b9b3c08c25..9f682d8981 100644 --- a/doc/src/sgml/chkpass.sgml +++ b/doc/src/sgml/chkpass.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/chkpass.sgml --> -<sect1 id="chkpass"> +<sect1 id="chkpass" xreflabel="chkpass"> <title>chkpass</title> <indexterm zone="chkpass"> diff --git a/doc/src/sgml/citext.sgml b/doc/src/sgml/citext.sgml index 68a2aa4cd3..8cbde88a3e 100644 --- a/doc/src/sgml/citext.sgml +++ b/doc/src/sgml/citext.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/citext.sgml --> -<sect1 id="citext"> +<sect1 id="citext" xreflabel="citext"> <title>citext</title> <indexterm zone="citext"> diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml index afbd9feb37..cb577e6112 100644 --- a/doc/src/sgml/client-auth.sgml +++ b/doc/src/sgml/client-auth.sgml @@ -889,7 +889,7 @@ omicron bryanh guest1 each database user is stored in the <literal>pg_authid</> system catalog. Passwords can be managed with the SQL commands <xref linkend="sql-createuser"> and - <xref linkend="sql-alteruser">, + <xref linkend="sql-alterrole">, e.g., <userinput>CREATE USER foo WITH PASSWORD 'secret'</userinput>. If no password has been set up for a user, the stored password is null and password authentication will always fail for that user. diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index e9de964a65..5d37065626 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -135,7 +135,7 @@ env PGOPTIONS='-c geqo=off' psql Furthermore, it is possible to assign a set of parameter settings to a user or a database. Whenever a session is started, the default settings for the user and database involved are loaded. The - commands <xref linkend="sql-alteruser"> + commands <xref linkend="sql-alterrole"> and <xref linkend="sql-alterdatabase">, respectively, are used to configure these settings. Per-database settings override anything received from the @@ -705,7 +705,7 @@ SET ENABLE_SEQSCAN TO OFF; <para> When a password is specified in <xref linkend="sql-createuser"> or - <xref linkend="sql-alteruser"> + <xref linkend="sql-alterrole"> without writing either <literal>ENCRYPTED</> or <literal>UNENCRYPTED</>, this parameter determines whether the password is to be encrypted. The default is <literal>on</> @@ -3869,11 +3869,11 @@ FROM pg_stat_activity; </indexterm> <listitem> <para> - Sets the time zone used for timestamps written in the log. + Sets the time zone used for timestamps written in the server log. Unlike <xref linkend="guc-timezone">, this value is cluster-wide, so that all sessions will report timestamps consistently. - The default is <literal>unknown</>, which means use whatever - the system environment specifies as the time zone. See <xref + If not explicitly set, the server initializes this variable to the + time zone specified by its system environment. See <xref linkend="datatype-timezones"> for more information. This parameter can only be set in the <filename>postgresql.conf</> file or on the server command line. @@ -4918,10 +4918,9 @@ SET XML OPTION { DOCUMENT | CONTENT }; <listitem> <para> Sets the time zone for displaying and interpreting time stamps. - The default is <literal>unknown</>, which means to use whatever - the system environment specifies as the time zone. See <xref - linkend="datatype-timezones"> for more - information. + If not explicitly set, the server initializes this variable to the + time zone specified by its system environment. See <xref + linkend="datatype-timezones"> for more information. </para> </listitem> </varlistentry> @@ -5205,7 +5204,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' libraries to be loaded into specific sessions without an explicit <command>LOAD</> command being given. For example, debugging could be enabled for all sessions under a given user name by setting - this parameter with <command>ALTER USER SET</>. + this parameter with <command>ALTER ROLE SET</>. </para> <para> diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml index 55e5ce2649..3287c18d27 100644 --- a/doc/src/sgml/contrib-spi.sgml +++ b/doc/src/sgml/contrib-spi.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/contrib-spi.sgml --> -<sect1 id="contrib-spi"> +<sect1 id="contrib-spi" xreflabel="spi"> <title>spi</title> <indexterm zone="contrib-spi"> diff --git a/doc/src/sgml/cube.sgml b/doc/src/sgml/cube.sgml index 0fcbf21be6..e2da68556d 100644 --- a/doc/src/sgml/cube.sgml +++ b/doc/src/sgml/cube.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/cube.sgml --> -<sect1 id="cube"> +<sect1 id="cube" xreflabel="cube"> <title>cube</title> <indexterm zone="cube"> diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index bc1ec3f821..ab8eb2d30b 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -2784,9 +2784,9 @@ P <optional> <replaceable>years</>-<replaceable>months</>-<replaceable>days</> < <productname>PostgreSQL</productname> provides the standard <acronym>SQL</acronym> type <type>boolean</type>; see <xref linkend="datatype-boolean-table">. - The <type>boolean</type> type can have one of only two states: - <quote>true</quote> or <quote>false</quote>. A third state, - <quote>unknown</quote>, is represented by the + The <type>boolean</type> type can have several states: + <quote>true</quote>, <quote>false</quote>, and a third state, + <quote>unknown</quote>, which is represented by the <acronym>SQL</acronym> null value. </para> diff --git a/doc/src/sgml/dblink.sgml b/doc/src/sgml/dblink.sgml index 295544e54e..22551402e3 100644 --- a/doc/src/sgml/dblink.sgml +++ b/doc/src/sgml/dblink.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/dblink.sgml --> -<sect1 id="dblink"> +<sect1 id="dblink" xreflabel="dblink"> <title>dblink</title> <indexterm zone="dblink"> diff --git a/doc/src/sgml/dict-int.sgml b/doc/src/sgml/dict-int.sgml index 17f98c05fa..d49f3e2a3a 100644 --- a/doc/src/sgml/dict-int.sgml +++ b/doc/src/sgml/dict-int.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/dict-int.sgml --> -<sect1 id="dict-int"> +<sect1 id="dict-int" xreflabel="dict_int"> <title>dict_int</title> <indexterm zone="dict-int"> diff --git a/doc/src/sgml/dict-xsyn.sgml b/doc/src/sgml/dict-xsyn.sgml index 23c5d983c1..42362ffbc8 100644 --- a/doc/src/sgml/dict-xsyn.sgml +++ b/doc/src/sgml/dict-xsyn.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/dict-xsyn.sgml --> -<sect1 id="dict-xsyn"> +<sect1 id="dict-xsyn" xreflabel="dict_xsyn"> <title>dict_xsyn</title> <indexterm zone="dict-xsyn"> diff --git a/doc/src/sgml/dummy-seclabel.sgml b/doc/src/sgml/dummy-seclabel.sgml index 30d58198fb..28d19d2409 100644 --- a/doc/src/sgml/dummy-seclabel.sgml +++ b/doc/src/sgml/dummy-seclabel.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/dummy_seclabel.sgml --> -<sect1 id="dummy-seclabel"> +<sect1 id="dummy-seclabel" xreflabel="dummy_seclabel"> <title>dummy_seclabel</title> <indexterm zone="dummy-seclabel"> diff --git a/doc/src/sgml/earthdistance.sgml b/doc/src/sgml/earthdistance.sgml index 5b50da0510..f9002b235b 100644 --- a/doc/src/sgml/earthdistance.sgml +++ b/doc/src/sgml/earthdistance.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/earthdistance.sgml --> -<sect1 id="earthdistance"> +<sect1 id="earthdistance" xreflabel="earthdistance"> <title>earthdistance</title> <indexterm zone="earthdistance"> @@ -55,7 +55,8 @@ </para> <para> - The following functions are provided: + The provided functions are shown + in <xref linkend="earthdistance-cube-functions">. </para> <table id="earthdistance-cube-functions"> @@ -148,7 +149,8 @@ </para> <para> - A single operator is provided: + A single operator is provided, shown + in <xref linkend="earthdistance-point-operators">. </para> <table id="earthdistance-point-operators"> diff --git a/doc/src/sgml/file-fdw.sgml b/doc/src/sgml/file-fdw.sgml index 003c415b43..e6ccdada2c 100644 --- a/doc/src/sgml/file-fdw.sgml +++ b/doc/src/sgml/file-fdw.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/file-fdw.sgml --> -<sect1 id="file-fdw"> +<sect1 id="file-fdw" xreflabel="file_fdw"> <title>file_fdw</title> <indexterm zone="file-fdw"> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 633f21583e..c1a34fb169 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -82,8 +82,9 @@ <member><literal>NOT</></member> </simplelist> - <acronym>SQL</acronym> uses a three-valued Boolean logic where the null value represents - <quote>unknown</quote>. Observe the following truth tables: + <acronym>SQL</acronym> uses a three-valued logic system with true, + false, and <literal>null</>, which represents <quote>unknown</quote>. + Observe the following truth tables: <informaltable> <tgroup cols="4"> @@ -8717,7 +8718,7 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple with <command>configure --with-libxml</>. </para> - <sect2> + <sect2 id="functions-producing-xml"> <title>Producing XML Content</title> <para> @@ -9093,7 +9094,7 @@ SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab; </sect3> </sect2> - <sect2> + <sect2 id="functions-xml-predicates"> <title>XML Predicates</title> <para> @@ -9854,7 +9855,7 @@ SELECT setval('foo', 42, false); <lineannotation>Next <function>nextval</> wi </para> </tip> - <sect2> + <sect2 id="functions-case"> <title><literal>CASE</></title> <para> @@ -9966,7 +9967,7 @@ SELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END; </para> </sect2> - <sect2> + <sect2 id="functions-coalesce-nvl-ifnull"> <title><literal>COALESCE</></title> <indexterm> @@ -10005,7 +10006,7 @@ SELECT COALESCE(description, short_description, '(none)') ... </para> </sect2> - <sect2> + <sect2 id="functions-nullif"> <title><literal>NULLIF</></title> <indexterm> @@ -10034,7 +10035,7 @@ SELECT NULLIF(value, '(none)') ... </sect2> - <sect2> + <sect2 id="functions-greatest-least"> <title><literal>GREATEST</literal> and <literal>LEAST</literal></title> <indexterm> @@ -11492,7 +11493,7 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab; Boolean (true/false) results. </para> - <sect2> + <sect2 id="functions-subquery-exists"> <title><literal>EXISTS</literal></title> <synopsis> @@ -11542,7 +11543,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); </para> </sect2> - <sect2> + <sect2 id="functions-subquery-in"> <title><literal>IN</literal></title> <synopsis> @@ -11598,7 +11599,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); </para> </sect2> - <sect2> + <sect2 id="functions-subquery-notin"> <title><literal>NOT IN</literal></title> <synopsis> @@ -11654,7 +11655,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); </para> </sect2> - <sect2> + <sect2 id="functions-subquery-any-some"> <title><literal>ANY</literal>/<literal>SOME</literal></title> <synopsis> @@ -11719,7 +11720,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); </para> </sect2> - <sect2> + <sect2 id="functions-subquery-all"> <title><literal>ALL</literal></title> <synopsis> diff --git a/doc/src/sgml/fuzzystrmatch.sgml b/doc/src/sgml/fuzzystrmatch.sgml index cec3363193..5078bf82da 100644 --- a/doc/src/sgml/fuzzystrmatch.sgml +++ b/doc/src/sgml/fuzzystrmatch.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/fuzzystrmatch.sgml --> -<sect1 id="fuzzystrmatch"> +<sect1 id="fuzzystrmatch" xreflabel="fuzzystrmatch"> <title>fuzzystrmatch</title> <indexterm zone="fuzzystrmatch"> diff --git a/doc/src/sgml/generate_history.pl b/doc/src/sgml/generate_history.pl index 2b81569b9a..a6c0bd77c2 100644 --- a/doc/src/sgml/generate_history.pl +++ b/doc/src/sgml/generate_history.pl @@ -13,10 +13,10 @@ use strict; -my($srcdir) = shift; -defined($srcdir) || die "$0: missing required argument: srcdir\n"; -my($infile) = shift; -defined($infile) || die "$0: missing required argument: inputfile\n"; +my $srcdir = shift; +die "$0: missing required argument: srcdir\n" if !defined($srcdir); +my $infile = shift; +die "$0: missing required argument: inputfile\n" if !defined($infile); # Emit DOCTYPE header so that the output is a self-contained SGML document print "<!DOCTYPE appendix PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\">\n"; @@ -26,11 +26,11 @@ process_file($infile); exit 0; sub process_file { - my($filename) = @_; + my $filename = shift; local *FILE; # need a local filehandle so we can recurse - my($f) = $srcdir . '/' . $filename; + my $f = $srcdir . '/' . $filename; open(FILE, $f) || die "could not read $f: $!\n"; while (<FILE>) { diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 5972a45555..0283a1c867 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -188,9 +188,10 @@ protocol to make nodes agree on a serializable transactional order. <para> With statement-based replication middleware, a program intercepts every SQL query and sends it to one or all servers. Each server - operates independently. Read-write queries are sent to all servers, - while read-only queries can be sent to just one server, allowing - the read workload to be distributed. + operates independently. Read-write queries must be sent to all servers, + so that every server receives any changes. But read-only queries can be + sent to just one server, allowing the read workload to be distributed + among them. </para> <para> @@ -209,8 +210,8 @@ protocol to make nodes agree on a serializable transactional order. transactions either commit or abort on all servers, perhaps using two-phase commit (<xref linkend="sql-prepare-transaction"> and <xref linkend="sql-commit-prepared">. - <productname>Pgpool-II</> and <productname>Sequoia</> are examples of - this type of replication. + <productname>Pgpool-II</> and <productname>Continuent Tungsten</> + are examples of this type of replication. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml index f00b06aa7a..aa21295265 100644 --- a/doc/src/sgml/hstore.sgml +++ b/doc/src/sgml/hstore.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/hstore.sgml --> -<sect1 id="hstore"> +<sect1 id="hstore" xreflabel="hstore"> <title>hstore</title> <indexterm zone="hstore"> @@ -85,6 +85,12 @@ key => NULL <sect2> <title><type>hstore</> Operators and Functions</title> + <para> + The operators provided by the <literal>hstore</literal> module are + shown in <xref linkend="hstore-op-table">, the functions + in <xref linkend="hstore-func-table">. + </para> + <table id="hstore-op-table"> <title><type>hstore</> Operators</title> diff --git a/doc/src/sgml/intagg.sgml b/doc/src/sgml/intagg.sgml index 43e36fb348..ea5acbe91f 100644 --- a/doc/src/sgml/intagg.sgml +++ b/doc/src/sgml/intagg.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/intagg.sgml --> -<sect1 id="intagg"> +<sect1 id="intagg" xreflabel="intagg"> <title>intagg</title> <indexterm zone="intagg"> diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml index 449878d671..2bbd98ae37 100644 --- a/doc/src/sgml/intarray.sgml +++ b/doc/src/sgml/intarray.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/intarray.sgml --> -<sect1 id="intarray"> +<sect1 id="intarray" xreflabel="intarray"> <title>intarray</title> <indexterm zone="intarray"> @@ -27,6 +27,12 @@ <sect2> <title><filename>intarray</> Functions and Operators</title> + <para> + The functions provided by the <filename>intarray</filename> module + are shown in <xref linkend="intarray-func-table">, the operators + in <xref linkend="intarray-op-table">. + </para> + <table id="intarray-func-table"> <title><filename>intarray</> Functions</title> diff --git a/doc/src/sgml/isn.sgml b/doc/src/sgml/isn.sgml index 38c98641b2..79ca3acd1b 100644 --- a/doc/src/sgml/isn.sgml +++ b/doc/src/sgml/isn.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/isn.sgml --> -<sect1 id="isn"> +<sect1 id="isn" xreflabel="isn"> <title>isn</title> <indexterm zone="isn"> diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 2ba441aa36..ba0cfc99cd 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -385,63 +385,70 @@ PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand This option determines whether or with what priority a secure <acronym>SSL</> TCP/IP connection will be negotiated with the server. There are six modes: - </para> - <table id="libpq-connect-sslmode-options"> - <title><literal>sslmode</literal> Options</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Option</entry> - <entry>Description</entry> - </row> - </thead> - - <tbody> - - <row> - <entry><literal>disable</></entry> - <entry>only try a non-<acronym>SSL</> connection</entry> - </row> - - <row> - <entry><literal>allow</></entry> - <entry>first try a non-<acronym>SSL</> - connection; if that fails, try an <acronym>SSL</> - connection</entry> - </row> - - <row> - <entry><literal>prefer</> (default)</entry> - <entry>first try an <acronym>SSL</> connection; if - that fails, try a non-<acronym>SSL</> - connection</entry> - </row> - - <row> - <entry><literal>require</></entry> - <entry>only try an <acronym>SSL</> connection</entry> - </row> - - <row> - <entry><literal>verify-ca</></entry> - <entry>only try an <acronym>SSL</> connection, and verify that - the server certificate is issued by a trusted certificate - authority (<acronym>CA</>)</entry> - </row> - - <row> - <entry><literal>verify-full</></entry> - <entry>only try an <acronym>SSL</> connection, verify that - the server certificate is issued by a trusted <acronym>CA</> and - that the server host name matches that in the certificate</entry> - </row> - - </tbody> - </tgroup> - </table> + <variablelist> + <varlistentry> + <term><literal>disable</literal></term> + <listitem> + <para> + only try a non-<acronym>SSL</> connection + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>allow</literal></term> + <listitem> + <para> + first try a non-<acronym>SSL</> connection; if that + fails, try an <acronym>SSL</> connection + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>prefer</literal> (default)</term> + <listitem> + <para> + first try an <acronym>SSL</> connection; if that fails, + try a non-<acronym>SSL</> connection + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>require</literal></term> + <listitem> + <para> + only try an <acronym>SSL</> connection + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>verify-ca</literal></term> + <listitem> + <para> + only try an <acronym>SSL</> connection, and verify that + the server certificate is issued by a trusted + certificate authority (<acronym>CA</>) + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>verify-full</literal></term> + <listitem> + <para> + only try an <acronym>SSL</> connection, verify that the + server certificate is issued by a + trusted <acronym>CA</> and that the server host name + matches that in the certificate + </para> + </listitem> + </varlistentry> + </variablelist> - <para> See <xref linkend="libpq-ssl"> for a detailed description of how these options work. </para> @@ -6387,7 +6394,7 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) <para> The following environment variables can be used to specify default behavior for each <productname>PostgreSQL</productname> session. (See - also the <xref linkend="sql-alteruser"> + also the <xref linkend="sql-alterrole"> and <xref linkend="sql-alterdatabase"> commands for ways to set default behavior on a per-user or per-database basis.) @@ -6773,30 +6780,23 @@ ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) The different values for the <literal>sslmode</> parameter provide different levels of protection. SSL can provide protection against three types of attacks: - </para> - <table id="libpq-ssl-protect-attacks"> - <title>SSL Attacks</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Type</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>Eavesdropping</entry> - <entry>If a third party can examine the network traffic between the + <variablelist> + <varlistentry> + <term>Eavesdropping</term> + <listitem> + <para>If a third party can examine the network traffic between the client and the server, it can read both connection information (including the user name and password) and the data that is passed. <acronym>SSL</> uses encryption to prevent this. - </entry> - </row> + </para> + </listitem> + </varlistentry> - <row> - <entry>Man in the middle (<acronym>MITM</>)</entry> - <entry>If a third party can modify the data while passing between the + <varlistentry> + <term>Man in the middle (<acronym>MITM</>)</term> + <listitem> + <para>If a third party can modify the data while passing between the client and server, it can pretend to be the server and therefore see and modify data <emphasis>even if it is encrypted</>. The third party can then forward the connection information and data to the original server, @@ -6805,21 +6805,23 @@ ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) to a different server than intended. There are also several other attack methods that can accomplish this. <acronym>SSL</> uses certificate verification to prevent this, by authenticating the server to the client. - </entry> - </row> + </para> + </listitem> + </varlistentry> - <row> - <entry>Impersonation</entry> - <entry>If a third party can pretend to be an authorized client, it can + <varlistentry> + <term>Impersonation</term> + <listitem> + <para>If a third party can pretend to be an authorized client, it can simply access data it should not have access to. Typically this can happen through insecure password management. <acronym>SSL</> uses client certificates to prevent this, by making sure that only holders of valid certificates can access the server. - </entry> - </row> - </tbody> - </tgroup> - </table> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> <para> For a connection to be known secure, SSL usage must be configured @@ -6844,9 +6846,9 @@ ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) <para> All <acronym>SSL</> options carry overhead in the form of encryption and key-exchange, so there is a tradeoff that has to be made between performance - and security. The following table illustrates the risks the different - <literal>sslmode</> values protect against, and what statement they make - about security and overhead: + and security. <xref linkend="libpq-ssl-sslmode-statements"> + illustrates the risks the different <literal>sslmode</> values + protect against, and what statement they make about security and overhead. </para> <table id="libpq-ssl-sslmode-statements"> @@ -6942,6 +6944,12 @@ ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) <sect2 id="libpq-ssl-fileusage"> <title>SSL Client File Usage</title> + + <para> + <xref linkend="libpq-ssl-file-usage"> summarizes the files that are + relevant to the SSL setup on the client. + </para> + <table id="libpq-ssl-file-usage"> <title>Libpq/Client SSL File Usage</title> <tgroup cols="3"> diff --git a/doc/src/sgml/lo.sgml b/doc/src/sgml/lo.sgml index 33124f9920..3d56ba3f70 100644 --- a/doc/src/sgml/lo.sgml +++ b/doc/src/sgml/lo.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/lo.sgml --> -<sect1 id="lo"> +<sect1 id="lo" xreflabel="lo"> <title>lo</title> <indexterm zone="lo"> diff --git a/doc/src/sgml/ltree.sgml b/doc/src/sgml/ltree.sgml index d6b58c17d7..0a91cd79d1 100644 --- a/doc/src/sgml/ltree.sgml +++ b/doc/src/sgml/ltree.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/ltree.sgml --> -<sect1 id="ltree"> +<sect1 id="ltree" xreflabel="ltree"> <title>ltree</title> <indexterm zone="ltree"> @@ -182,8 +182,8 @@ Europe & Russia*@ & !Transportation <literal>=</>, <literal><></literal>, <literal><</>, <literal>></>, <literal><=</>, <literal>>=</>. Comparison sorts in the order of a tree traversal, with the children - of a node sorted by label text. In addition, there are the following - specialized operators: + of a node sorted by label text. In addition, the specialized + operators shown in <xref linkend="ltree-op-table"> are available. </para> <table id="ltree-op-table"> @@ -362,7 +362,7 @@ Europe & Russia*@ & !Transportation </para> <para> - The following functions are available: + The available functions are shown in <xref linkend="ltree-func-table">. </para> <table id="ltree-func-table"> diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 319a57c6e2..7d8b77e27e 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1357,9 +1357,10 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, <para> A number of standard probes are provided in the source code, - as shown in <xref linkend="dtrace-probe-point-table">. - More can certainly be added to enhance <productname>PostgreSQL</>'s - observability. + as shown in <xref linkend="dtrace-probe-point-table">; + <xref linkend="typedefs-table"> + shows the types used in the probes. More probes can certainly be + added to enhance <productname>PostgreSQL</>'s observability. </para> <table id="dtrace-probe-point-table"> diff --git a/doc/src/sgml/oid2name.sgml b/doc/src/sgml/oid2name.sgml index 36fcfd5cda..3e4fe24a49 100644 --- a/doc/src/sgml/oid2name.sgml +++ b/doc/src/sgml/oid2name.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/oid2name.sgml --> -<sect1 id="oid2name"> +<sect1 id="oid2name" xreflabel="oid2name"> <title>oid2name</title> <indexterm zone="oid2name"> diff --git a/doc/src/sgml/pageinspect.sgml b/doc/src/sgml/pageinspect.sgml index a5fbadb731..acbb05bc9c 100644 --- a/doc/src/sgml/pageinspect.sgml +++ b/doc/src/sgml/pageinspect.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pageinspect.sgml --> -<sect1 id="pageinspect"> +<sect1 id="pageinspect" xreflabel="pageinspect"> <title>pageinspect</title> <indexterm zone="pageinspect"> diff --git a/doc/src/sgml/passwordcheck.sgml b/doc/src/sgml/passwordcheck.sgml index 11107fb6dd..0050e65824 100644 --- a/doc/src/sgml/passwordcheck.sgml +++ b/doc/src/sgml/passwordcheck.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/passwordcheck.sgml --> -<sect1 id="passwordcheck"> +<sect1 id="passwordcheck" xreflabel="passwordcheck"> <title>passwordcheck</title> <indexterm zone="passwordcheck"> diff --git a/doc/src/sgml/pgarchivecleanup.sgml b/doc/src/sgml/pgarchivecleanup.sgml index 725f3ed07c..ddffa321f6 100644 --- a/doc/src/sgml/pgarchivecleanup.sgml +++ b/doc/src/sgml/pgarchivecleanup.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgarchivecleanup.sgml --> -<sect1 id="pgarchivecleanup"> +<sect1 id="pgarchivecleanup" xreflabel="pg_archivecleanup"> <title>pg_archivecleanup</title> <indexterm zone="pgarchivecleanup"> diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml index 5a10e93a40..e7b78605ec 100644 --- a/doc/src/sgml/pgbench.sgml +++ b/doc/src/sgml/pgbench.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgbench.sgml --> -<sect1 id="pgbench"> +<sect1 id="pgbench" xreflabel="pgbench"> <title>pgbench</title> <indexterm zone="pgbench"> diff --git a/doc/src/sgml/pgbuffercache.sgml b/doc/src/sgml/pgbuffercache.sgml index fa7a78dfcd..1d7d95f9d7 100644 --- a/doc/src/sgml/pgbuffercache.sgml +++ b/doc/src/sgml/pgbuffercache.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgbuffercache.sgml --> -<sect1 id="pgbuffercache"> +<sect1 id="pgbuffercache" xreflabel="pg_buffercache"> <title>pg_buffercache</title> <indexterm zone="pgbuffercache"> diff --git a/doc/src/sgml/pgcrypto.sgml b/doc/src/sgml/pgcrypto.sgml index 60bc0a2046..6b78f2c1c6 100644 --- a/doc/src/sgml/pgcrypto.sgml +++ b/doc/src/sgml/pgcrypto.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgcrypto.sgml --> -<sect1 id="pgcrypto"> +<sect1 id="pgcrypto" xreflabel="pgcrypto"> <title>pgcrypto</title> <indexterm zone="pgcrypto"> diff --git a/doc/src/sgml/pgfreespacemap.sgml b/doc/src/sgml/pgfreespacemap.sgml index bdacbaf0e5..51f772a397 100644 --- a/doc/src/sgml/pgfreespacemap.sgml +++ b/doc/src/sgml/pgfreespacemap.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgfreespacemap.sgml --> -<sect1 id="pgfreespacemap"> +<sect1 id="pgfreespacemap" xreflabel="pg_freespacemap"> <title>pg_freespacemap</title> <indexterm zone="pgfreespacemap"> diff --git a/doc/src/sgml/pgrowlocks.sgml b/doc/src/sgml/pgrowlocks.sgml index b2c2590ad7..db1cf5e863 100644 --- a/doc/src/sgml/pgrowlocks.sgml +++ b/doc/src/sgml/pgrowlocks.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgrowlocks.sgml --> -<sect1 id="pgrowlocks"> +<sect1 id="pgrowlocks" xreflabel="pgrowlocks"> <title>pgrowlocks</title> <indexterm zone="pgrowlocks"> diff --git a/doc/src/sgml/pgstandby.sgml b/doc/src/sgml/pgstandby.sgml index 7f0a8744fa..e698cb73e6 100644 --- a/doc/src/sgml/pgstandby.sgml +++ b/doc/src/sgml/pgstandby.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgstandby.sgml --> -<sect1 id="pgstandby"> +<sect1 id="pgstandby" xreflabel="pg_standby"> <title>pg_standby</title> <indexterm zone="pgstandby"> diff --git a/doc/src/sgml/pgstatstatements.sgml b/doc/src/sgml/pgstatstatements.sgml index 8cff1020bb..52268c545d 100644 --- a/doc/src/sgml/pgstatstatements.sgml +++ b/doc/src/sgml/pgstatstatements.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgstatstatements.sgml --> -<sect1 id="pgstatstatements"> +<sect1 id="pgstatstatements" xreflabel="pg_stat_statements"> <title>pg_stat_statements</title> <indexterm zone="pgstatstatements"> diff --git a/doc/src/sgml/pgstattuple.sgml b/doc/src/sgml/pgstattuple.sgml index cc2849b5e6..a55b35cb3f 100644 --- a/doc/src/sgml/pgstattuple.sgml +++ b/doc/src/sgml/pgstattuple.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgstattuple.sgml --> -<sect1 id="pgstattuple"> +<sect1 id="pgstattuple" xreflabel="pgstattuple"> <title>pgstattuple</title> <indexterm zone="pgstattuple"> diff --git a/doc/src/sgml/pgtestfsync.sgml b/doc/src/sgml/pgtestfsync.sgml index 5ad7b73ed0..4015eb51d8 100644 --- a/doc/src/sgml/pgtestfsync.sgml +++ b/doc/src/sgml/pgtestfsync.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgtestfsync.sgml --> -<sect1 id="pgtestfsync"> +<sect1 id="pgtestfsync" xreflabel="pg_test_fsync"> <title>pg_test_fsync</title> <indexterm zone="pgtestfsync"> diff --git a/doc/src/sgml/pgtrgm.sgml b/doc/src/sgml/pgtrgm.sgml index 9210899ec2..18f0f3eba0 100644 --- a/doc/src/sgml/pgtrgm.sgml +++ b/doc/src/sgml/pgtrgm.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgtrgm.sgml --> -<sect1 id="pgtrgm"> +<sect1 id="pgtrgm" xreflabel="pg_trgm"> <title>pg_trgm</title> <indexterm zone="pgtrgm"> @@ -43,6 +43,12 @@ <sect2> <title>Functions and Operators</title> + <para> + The functions provided by the <filename>pg_trgm</filename> module + are shown in <xref linkend="pgtrgm-func-table">, the operators + in <xref linkend="pgtrgm-op-table">. + </para> + <table id="pgtrgm-func-table"> <title><filename>pg_trgm</filename> Functions</title> <tgroup cols="3"> diff --git a/doc/src/sgml/pgupgrade.sgml b/doc/src/sgml/pgupgrade.sgml index c41068f074..1713bf0272 100644 --- a/doc/src/sgml/pgupgrade.sgml +++ b/doc/src/sgml/pgupgrade.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/pgupgrade.sgml --> -<sect1 id="pgupgrade"> +<sect1 id="pgupgrade" xreflabel="pg_upgrade"> <title>pg_upgrade</title> <indexterm zone="pgupgrade"> diff --git a/doc/src/sgml/recovery-config.sgml b/doc/src/sgml/recovery-config.sgml index 144b880f42..de6090520d 100644 --- a/doc/src/sgml/recovery-config.sgml +++ b/doc/src/sgml/recovery-config.sgml @@ -95,7 +95,7 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows The <xref linkend="pgarchivecleanup"> module is often used in <varname>archive_cleanup_command</> for single-standby configurations, for example: -<programlisting> archive_cleanup_command = 'pg_archivecleanup /mnt/server/archivedir %r' </programlisting> +<programlisting>archive_cleanup_command = 'pg_archivecleanup /mnt/server/archivedir %r'</programlisting> Note however that if multiple standby servers are restoring from the same archive directory, you will need to ensure that you do not delete WAL files until they are no longer needed by any of the servers. diff --git a/doc/src/sgml/ref/createdb.sgml b/doc/src/sgml/ref/createdb.sgml index 7cbf56506d..9c8171d049 100644 --- a/doc/src/sgml/ref/createdb.sgml +++ b/doc/src/sgml/ref/createdb.sgml @@ -107,6 +107,19 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>-E <replaceable class="parameter">encoding</replaceable></></term> + <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></></term> + <listitem> + <para> + Specifies the character encoding scheme to be used in this + database. The character sets supported by the + <productname>PostgreSQL</productname> server are described in + <xref linkend="multibyte-charset-supported">. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>-l <replaceable class="parameter">locale</replaceable></></term> <term><option>--locale=<replaceable class="parameter">locale</replaceable></></term> <listitem> @@ -136,19 +149,6 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>-E <replaceable class="parameter">encoding</replaceable></></term> - <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></></term> - <listitem> - <para> - Specifies the character encoding scheme to be used in this - database. The character sets supported by the - <productname>PostgreSQL</productname> server are described in - <xref linkend="multibyte-charset-supported">. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>-O <replaceable class="parameter">owner</replaceable></></term> <term><option>--owner=<replaceable class="parameter">owner</replaceable></></term> <listitem> diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml index 93e83320cc..689aba5104 100644 --- a/doc/src/sgml/ref/grant.sgml +++ b/doc/src/sgml/ref/grant.sgml @@ -101,7 +101,7 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace There is also an option to grant privileges on all objects of the same type within one or more schemas. This functionality is currently supported only for tables, sequences, and functions (but note that <literal>ALL - TABLES</> is considered to include views). + TABLES</> is considered to include views and foreign tables). </para> <para> diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 382effdaa3..29c885e93d 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -388,28 +388,28 @@ PostgreSQL documentation To create a base backup of the server at <literal>mydbserver</literal> and store it in the local directory <filename>/usr/local/pgsql/data</filename>: - <screen> - <prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput> - </screen> +<screen> +<prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput> +</screen> </para> <para> To create a backup of the local server with one maximum compressed tar file for each tablespace, and store it in the directory <filename>backup</filename>, showing a progress report while running: - <screen> - <prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -Z9 -P</userinput> - </screen> +<screen> +<prompt>$</prompt> <userinput>pg_basebackup -D backup -Ft -Z9 -P</userinput> +</screen> </para> <para> To create a backup of a single-tablespace local database and compress this with <productname>bzip2</productname>: - <screen> - <prompt>$</prompt> <userinput>pg_basebackup -D - -Ft | bzip2 > backup.tar.bz2</userinput> - </screen> - (this command will fail if there are multiple tablespaces in the - database) +<screen> +<prompt>$</prompt> <userinput>pg_basebackup -D - -Ft | bzip2 > backup.tar.bz2</userinput> +</screen> + (This command will fail if there are multiple tablespaces in the + database.) </para> </refsect1> diff --git a/doc/src/sgml/ref/security_label.sgml b/doc/src/sgml/ref/security_label.sgml index 40ce3317b9..8a01b940de 100644 --- a/doc/src/sgml/ref/security_label.sgml +++ b/doc/src/sgml/ref/security_label.sgml @@ -82,7 +82,7 @@ SECURITY LABEL [ FOR <replaceable class="PARAMETER">provider</replaceable> ] ON <term><replaceable class="parameter">function_name</replaceable></term> <listitem> <para> - The name of the object to be commented. Names of tables, + The name of the object to be labeled. Names of tables, aggregates, domains, foreign tables, functions, sequences, types, and views can be schema-qualified. </para> @@ -120,8 +120,8 @@ SECURITY LABEL [ FOR <replaceable class="PARAMETER">provider</replaceable> ] ON The mode of a function argument: <literal>IN</>, <literal>OUT</>, <literal>INOUT</>, or <literal>VARIADIC</>. If omitted, the default is <literal>IN</>. - Note that <command>COMMENT ON FUNCTION</command> does not actually pay - any attention to <literal>OUT</> arguments, since only the input + Note that <command>SECURITY LABEL ON FUNCTION</command> does not actually + pay any attention to <literal>OUT</> arguments, since only the input arguments are needed to determine the function's identity. So it is sufficient to list the <literal>IN</>, <literal>INOUT</>, and <literal>VARIADIC</> arguments. @@ -135,8 +135,8 @@ SECURITY LABEL [ FOR <replaceable class="PARAMETER">provider</replaceable> ] ON <listitem> <para> The name of a function argument. - Note that <command>COMMENT ON FUNCTION</command> does not actually pay - any attention to argument names, since only the argument data + Note that <command>SECURITY LABEL ON FUNCTION</command> does not actually + pay any attention to argument names, since only the argument data types are needed to determine the function's identity. </para> </listitem> diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml index d70c806fda..280e0bb142 100644 --- a/doc/src/sgml/release-9.1.sgml +++ b/doc/src/sgml/release-9.1.sgml @@ -58,11 +58,12 @@ </para> <para> - This removes a long-standing incompatibility with the SQL - standard; <link + By default, backslashes are now ordinary characters in string literals, + not escape characters. This change removes a long-standing + incompatibility with the SQL standard. <link linkend="guc-escape-string-warning"><varname>escape_string_warning</></link> has produced warnings about this usage for years. <literal>E''</> - strings are the proper way to embed escapes in strings and are + strings are the proper way to embed backslash escapes in strings and are unaffected by this change. </para> </listitem> diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 143090e99a..d18ba79f40 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -2097,12 +2097,11 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433 <sect2 id="ssl-server-files"> <title>SSL Server File Usage</title> - <para> - The files <filename>server.key</>, <filename>server.crt</>, - <filename>root.crt</filename>, and <filename>root.crl</filename> - are only examined during server start; so you must restart - the server for changes in them to take effect. - </para> + + <para> + <xref linkend="ssl-file-usage"> summarizes the files that are + relevant to the SSL setup on the server. + </para> <table id="ssl-file-usage"> <title>SSL Server File Usage</title> @@ -2146,6 +2145,13 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433 </tbody> </tgroup> </table> + + <para> + The files <filename>server.key</>, <filename>server.crt</>, + <filename>root.crt</filename>, and <filename>root.crl</filename> + are only examined during server start; so you must restart + the server for changes in them to take effect. + </para> </sect2> <sect2 id="ssl-certificate-creation"> diff --git a/doc/src/sgml/seg.sgml b/doc/src/sgml/seg.sgml index a726ca127f..00bd71dcb6 100644 --- a/doc/src/sgml/seg.sgml +++ b/doc/src/sgml/seg.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/seg.sgml --> -<sect1 id="seg"> +<sect1 id="seg" xreflabel="seg"> <title>seg</title> <indexterm zone="seg"> diff --git a/doc/src/sgml/sepgsql.sgml b/doc/src/sgml/sepgsql.sgml index 589fe79d51..f35ab97be1 100644 --- a/doc/src/sgml/sepgsql.sgml +++ b/doc/src/sgml/sepgsql.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/sepgsql.sgml --> -<sect1 id="sepgsql"> +<sect1 id="sepgsql" xreflabel="sepgsql"> <title>sepgsql</title> <indexterm zone="sepgsql"> diff --git a/doc/src/sgml/sslinfo.sgml b/doc/src/sgml/sslinfo.sgml index f7ccb8c56c..618182458a 100644 --- a/doc/src/sgml/sslinfo.sgml +++ b/doc/src/sgml/sslinfo.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/sslinfo.sgml --> -<sect1 id="sslinfo"> +<sect1 id="sslinfo" xreflabel="sslinfo"> <title>sslinfo</title> <indexterm zone="sslinfo"> diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 40a87aabc7..f6c4a4defa 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -972,7 +972,7 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> ) </sect2> <sect2 id="sql-precedence"> - <title>Lexical Precedence</title> + <title>Operator Precedence</title> <indexterm zone="sql-precedence"> <primary>operator</primary> @@ -1039,9 +1039,9 @@ SELECT (5 !) - 6; </row> <row> - <entry><token>-</token></entry> + <entry><token>+</token> <token>-</token></entry> <entry>right</entry> - <entry>unary minus</entry> + <entry>unary plus, unary minus</entry> </row> <row> @@ -1065,7 +1065,7 @@ SELECT (5 !) - 6; <row> <entry><token>IS</token></entry> <entry></entry> - <entry><literal>IS TRUE</>, <literal>IS FALSE</>, <literal>IS UNKNOWN</>, <literal>IS NULL</></entry> + <entry><literal>IS TRUE</>, <literal>IS FALSE</>, <literal>IS NULL</>, etc</entry> </row> <row> diff --git a/doc/src/sgml/tablefunc.sgml b/doc/src/sgml/tablefunc.sgml index dfb932f501..cfa20e2a70 100644 --- a/doc/src/sgml/tablefunc.sgml +++ b/doc/src/sgml/tablefunc.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/tablefunc.sgml --> -<sect1 id="tablefunc"> +<sect1 id="tablefunc" xreflabel="tablefunc"> <title>tablefunc</title> <indexterm zone="tablefunc"> @@ -431,17 +431,17 @@ crosstab(text source_sql, text category_sql) For example, <parameter>source_sql</parameter> might produce a set something like: <programlisting> - SELECT row_name, extra_col, cat, value FROM foo ORDER BY 1; - - row_name extra_col cat value - ----------+------------+-----+--------- - row1 extra1 cat1 val1 - row1 extra1 cat2 val2 - row1 extra1 cat4 val4 - row2 extra2 cat1 val5 - row2 extra2 cat2 val6 - row2 extra2 cat3 val7 - row2 extra2 cat4 val8 +SELECT row_name, extra_col, cat, value FROM foo ORDER BY 1; + + row_name extra_col cat value +----------+------------+-----+--------- + row1 extra1 cat1 val1 + row1 extra1 cat2 val2 + row1 extra1 cat4 val4 + row2 extra2 cat1 val5 + row2 extra2 cat2 val6 + row2 extra2 cat3 val7 + row2 extra2 cat4 val8 </programlisting> </para> diff --git a/doc/src/sgml/test-parser.sgml b/doc/src/sgml/test-parser.sgml index 0f2008cbe6..28b1e91c58 100644 --- a/doc/src/sgml/test-parser.sgml +++ b/doc/src/sgml/test-parser.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/test-parser.sgml --> -<sect1 id="test-parser"> +<sect1 id="test-parser" xreflabel="test_parser"> <title>test_parser</title> <indexterm zone="test-parser"> diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml index 1beebd21ee..dba5bd6603 100644 --- a/doc/src/sgml/textsearch.sgml +++ b/doc/src/sgml/textsearch.sgml @@ -1799,7 +1799,7 @@ LIMIT 10; <para> The built-in parser is named <literal>pg_catalog.default</>. - It recognizes 23 token types: + It recognizes 23 token types, shown in <xref linkend="textsearch-default-parser">. </para> <table id="textsearch-default-parser"> diff --git a/doc/src/sgml/tsearch2.sgml b/doc/src/sgml/tsearch2.sgml index 8321c1efb4..192eccd732 100644 --- a/doc/src/sgml/tsearch2.sgml +++ b/doc/src/sgml/tsearch2.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/tsearch2.sgml --> -<sect1 id="tsearch2"> +<sect1 id="tsearch2" xreflabel="tsearch2"> <title>tsearch2</title> <indexterm zone="tsearch2"> diff --git a/doc/src/sgml/unaccent.sgml b/doc/src/sgml/unaccent.sgml index 9c34c0bbd2..af9cad5d8c 100644 --- a/doc/src/sgml/unaccent.sgml +++ b/doc/src/sgml/unaccent.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/unaccent.sgml --> -<sect1 id="unaccent"> +<sect1 id="unaccent" xreflabel="unaccent"> <title>unaccent</title> <indexterm zone="unaccent"> diff --git a/doc/src/sgml/uuid-ossp.sgml b/doc/src/sgml/uuid-ossp.sgml index 3dd89903fa..7446b8be5c 100644 --- a/doc/src/sgml/uuid-ossp.sgml +++ b/doc/src/sgml/uuid-ossp.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/uuid-ossp.sgml --> -<sect1 id="uuid-ossp"> +<sect1 id="uuid-ossp" xreflabel="uuid-ossp"> <title>uuid-ossp</title> <indexterm zone="uuid-ossp"> diff --git a/doc/src/sgml/vacuumlo.sgml b/doc/src/sgml/vacuumlo.sgml index fbb6815a44..471a6ca32b 100644 --- a/doc/src/sgml/vacuumlo.sgml +++ b/doc/src/sgml/vacuumlo.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/vacuumlo.sgml --> -<sect1 id="vacuumlo"> +<sect1 id="vacuumlo" xreflabel="vacuumlo"> <title>vacuumlo</title> <indexterm zone="vacuumlo"> diff --git a/doc/src/sgml/xml2.sgml b/doc/src/sgml/xml2.sgml index 8ce7351a7c..90b5ac0785 100644 --- a/doc/src/sgml/xml2.sgml +++ b/doc/src/sgml/xml2.sgml @@ -1,6 +1,6 @@ <!-- doc/src/sgml/xml2.sgml --> -<sect1 id="xml2"> +<sect1 id="xml2" xreflabel="xml2"> <title>xml2</title> <indexterm zone="xml2"> diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index df0f15679f..d3de8934ee 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -431,8 +431,8 @@ CLOGShmemInit(void) /* * This func must be called ONCE on system install. It creates * the initial CLOG segment. (The CLOG directory is assumed to - * have been created by the initdb shell script, and CLOGShmemInit - * must have been called already.) + * have been created by initdb, and CLOGShmemInit must have been + * called already.) */ void BootStrapCLOG(void) diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 500335bd6f..555bb134f5 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -21,7 +21,6 @@ #include "miscadmin.h" #include "postmaster/autovacuum.h" #include "storage/pmsignal.h" -#include "storage/predicate.h" #include "storage/proc.h" #include "utils/builtins.h" #include "utils/syscache.h" @@ -162,10 +161,6 @@ GetNewTransactionId(bool isSubXact) ExtendCLOG(xid); ExtendSUBTRANS(xid); - /* If it's top level, the predicate locking system also needs to know. */ - if (!isSubXact) - RegisterPredicateLockingXid(xid); - /* * Now advance the nextXid counter. This must not happen until after we * have successfully completed ExtendCLOG() --- if that routine fails, we diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 8a4c4eccd7..2ca1c14549 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -455,6 +455,13 @@ AssignTransactionId(TransactionState s) SubTransSetParent(s->transactionId, s->parent->transactionId, false); /* + * If it's a top-level transaction, the predicate locking system needs to + * be told about it too. + */ + if (!isSubXact) + RegisterPredicateLockingXid(s->transactionId); + + /* * Acquire lock on the transaction XID. (We assume this cannot block.) We * have to ensure that the lock is assigned to the transaction's own * ResourceOwner. diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b0e4c41d6f..e71090f71b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6611,12 +6611,11 @@ StartupXLOG(void) } /* - * If we launched a WAL receiver, it should be gone by now. It will trump - * over the startup checkpoint and subsequent records if it's still alive, - * so be extra sure that it's gone. + * Kill WAL receiver, if it's still running, before we continue to write + * the startup checkpoint record. It will trump over the checkpoint and + * subsequent records if it's still alive when we start writing WAL. */ - if (WalRcvInProgress()) - elog(PANIC, "wal receiver still active"); + ShutdownWalRcv(); /* * We don't need the latch anymore. It's not strictly necessary to disown diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index c623fb7e75..452a0ead44 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -2557,8 +2557,8 @@ CREATE VIEW _pg_foreign_tables AS WHERE w.oid = s.srvfdw AND u.oid = c.relowner AND (pg_has_role(c.relowner, 'USAGE') - OR has_table_privilege(c.oid, 'SELECT') - OR has_any_column_privilege(c.oid, 'SELECT')) + OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER') + OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES')) AND n.oid = c.relnamespace AND c.oid = t.ftrelid AND c.relkind = 'f' diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 191ef543cd..dc0f6059b0 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -38,6 +38,7 @@ #include "miscadmin.h" #include "optimizer/planner.h" #include "storage/bufmgr.h" +#include "storage/lmgr.h" #include "storage/procarray.h" #include "storage/smgr.h" #include "utils/acl.h" @@ -751,8 +752,24 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, isnull = (bool *) palloc(natts * sizeof(bool)); /* + * If the OldHeap has a toast table, get lock on the toast table to keep + * it from being vacuumed. This is needed because autovacuum processes + * toast tables independently of their main tables, with no lock on the + * latter. If an autovacuum were to start on the toast table after we + * compute our OldestXmin below, it would use a later OldestXmin, and then + * possibly remove as DEAD toast tuples belonging to main tuples we think + * are only RECENTLY_DEAD. Then we'd fail while trying to copy those + * tuples. + * + * We don't need to open the toast relation here, just lock it. The lock + * will be held till end of transaction. + */ + if (OldHeap->rd_rel->reltoastrelid) + LockRelationOid(OldHeap->rd_rel->reltoastrelid, AccessExclusiveLock); + + /* * We need to log the copied data in WAL iff WAL archiving/streaming is - * enabled AND it's not a WAL-logged rel. + * enabled AND it's a WAL-logged rel. */ use_wal = XLogIsNeeded() && RelationNeedsWAL(NewHeap); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ff84045d4f..b91e4a4bd2 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -183,10 +183,22 @@ DefineIndex(RangeVar *heapRelation, /* Note: during bootstrap may see uncataloged relation */ if (rel->rd_rel->relkind != RELKIND_RELATION && rel->rd_rel->relkind != RELKIND_UNCATALOGED) - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a table", - heapRelation->relname))); + { + if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE) + /* + * Custom error message for FOREIGN TABLE since the term is + * close to a regular table and can confuse the user. + */ + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot create index on foreign table \"%s\"", + heapRelation->relname))); + else + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("\"%s\" is not a table", + heapRelation->relname))); + } /* * Don't try to CREATE INDEX on temp tables of other backends. diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 493bc86299..45eaa03fda 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -1065,6 +1065,11 @@ SS_process_ctes(PlannerInfo *root) * (Notionally, we replace the SubLink with a constant TRUE, then elide the * redundant constant from the qual.) * + * On success, the caller is also responsible for recursively applying + * pull_up_sublinks processing to the rarg and quals of the returned JoinExpr. + * (On failure, there is no need to do anything, since pull_up_sublinks will + * be applied when we recursively plan the sub-select.) + * * Side effects of a successful conversion include adding the SubLink's * subselect to the query's rangetable, so that it can be referenced in * the JoinExpr's rarg. diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index a70439cc67..5d163292c5 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -318,6 +318,7 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, { SubLink *sublink = (SubLink *) node; JoinExpr *j; + Relids child_rels; /* Is it a convertible ANY or EXISTS clause? */ if (sublink->subLinkType == ANY_SUBLINK) @@ -326,7 +327,18 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, available_rels); if (j) { - /* Yes, insert the new join node into the join tree */ + /* Yes; recursively process what we pulled up */ + j->rarg = pull_up_sublinks_jointree_recurse(root, + j->rarg, + &child_rels); + /* Pulled-up ANY/EXISTS quals can use those rels too */ + child_rels = bms_add_members(child_rels, available_rels); + /* ... and any inserted joins get stacked onto j->rarg */ + j->quals = pull_up_sublinks_qual_recurse(root, + j->quals, + child_rels, + &j->rarg); + /* Now insert the new join node into the join tree */ j->larg = *jtlink; *jtlink = (Node *) j; /* and return NULL representing constant TRUE */ @@ -339,7 +351,18 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, available_rels); if (j) { - /* Yes, insert the new join node into the join tree */ + /* Yes; recursively process what we pulled up */ + j->rarg = pull_up_sublinks_jointree_recurse(root, + j->rarg, + &child_rels); + /* Pulled-up ANY/EXISTS quals can use those rels too */ + child_rels = bms_add_members(child_rels, available_rels); + /* ... and any inserted joins get stacked onto j->rarg */ + j->quals = pull_up_sublinks_qual_recurse(root, + j->quals, + child_rels, + &j->rarg); + /* Now insert the new join node into the join tree */ j->larg = *jtlink; *jtlink = (Node *) j; /* and return NULL representing constant TRUE */ @@ -354,6 +377,7 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, /* If the immediate argument of NOT is EXISTS, try to convert */ SubLink *sublink = (SubLink *) get_notclausearg((Expr *) node); JoinExpr *j; + Relids child_rels; if (sublink && IsA(sublink, SubLink)) { @@ -363,7 +387,18 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, available_rels); if (j) { - /* Yes, insert the new join node into the join tree */ + /* Yes; recursively process what we pulled up */ + j->rarg = pull_up_sublinks_jointree_recurse(root, + j->rarg, + &child_rels); + /* Pulled-up ANY/EXISTS quals can use those rels too */ + child_rels = bms_add_members(child_rels, available_rels); + /* ... and any inserted joins get stacked onto j->rarg */ + j->quals = pull_up_sublinks_qual_recurse(root, + j->quals, + child_rels, + &j->rarg); + /* Now insert the new join node into the join tree */ j->larg = *jtlink; *jtlink = (Node *) j; /* and return NULL representing constant TRUE */ diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 34ecd292cb..cc0d6f5557 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -597,7 +597,8 @@ static void SplitColQualList(List *qualList, * have any bad effects since obviously the keywords will still behave the * same as if they weren't keywords). We need to do this for PARTITION, * RANGE, ROWS to support opt_existing_window_name; and for RANGE, ROWS - * so that they can follow a_expr without creating + * so that they can follow a_expr without creating postfix-operator problems; + * and for NULL so that it can follow b_expr in ColQualList without creating * postfix-operator problems. * * The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING @@ -610,16 +611,16 @@ static void SplitColQualList(List *qualList, * blame any funny behavior of UNBOUNDED on the SQL standard, though. */ %nonassoc UNBOUNDED /* ideally should have same precedence as IDENT */ -%nonassoc IDENT PARTITION RANGE ROWS PRECEDING FOLLOWING +%nonassoc IDENT NULL_P PARTITION RANGE ROWS PRECEDING FOLLOWING %left Op OPERATOR /* multi-character ops and user-defined operators */ %nonassoc NOTNULL %nonassoc ISNULL -%nonassoc IS NULL_P TRUE_P FALSE_P UNKNOWN /* sets precedence for IS NULL, etc */ +%nonassoc IS /* sets precedence for IS NULL, etc */ %left '+' '-' %left '*' '/' '%' %left '^' /* Unary Operators */ -%left AT ZONE /* sets precedence for AT TIME ZONE */ +%left AT /* sets precedence for AT TIME ZONE */ %left COLLATE %right UMINUS %left '[' ']' @@ -4125,9 +4126,7 @@ TriggerFuncArg: } | FCONST { $$ = makeString($1); } | Sconst { $$ = makeString($1); } - | BCONST { $$ = makeString($1); } - | XCONST { $$ = makeString($1); } - | ColId { $$ = makeString($1); } + | ColLabel { $$ = makeString($1); } ; OptConstrFromTable: @@ -9714,7 +9713,7 @@ a_expr: c_expr { $$ = $1; } n->location = @2; $$ = (Node *) n; } - | a_expr AT TIME ZONE a_expr + | a_expr AT TIME ZONE a_expr %prec AT { FuncCall *n = makeNode(FuncCall); n->funcname = SystemFuncName("timezone"); @@ -9896,7 +9895,7 @@ a_expr: c_expr { $$ = $1; } * a ISNULL * a NOTNULL */ - | a_expr IS NULL_P + | a_expr IS NULL_P %prec IS { NullTest *n = makeNode(NullTest); n->arg = (Expr *) $1; @@ -9910,7 +9909,7 @@ a_expr: c_expr { $$ = $1; } n->nulltesttype = IS_NULL; $$ = (Node *)n; } - | a_expr IS NOT NULL_P + | a_expr IS NOT NULL_P %prec IS { NullTest *n = makeNode(NullTest); n->arg = (Expr *) $1; @@ -9928,42 +9927,42 @@ a_expr: c_expr { $$ = $1; } { $$ = (Node *)makeOverlaps($1, $3, @2, yyscanner); } - | a_expr IS TRUE_P + | a_expr IS TRUE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; b->booltesttype = IS_TRUE; $$ = (Node *)b; } - | a_expr IS NOT TRUE_P + | a_expr IS NOT TRUE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; b->booltesttype = IS_NOT_TRUE; $$ = (Node *)b; } - | a_expr IS FALSE_P + | a_expr IS FALSE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; b->booltesttype = IS_FALSE; $$ = (Node *)b; } - | a_expr IS NOT FALSE_P + | a_expr IS NOT FALSE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; b->booltesttype = IS_NOT_FALSE; $$ = (Node *)b; } - | a_expr IS UNKNOWN + | a_expr IS UNKNOWN %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; b->booltesttype = IS_UNKNOWN; $$ = (Node *)b; } - | a_expr IS NOT UNKNOWN + | a_expr IS NOT UNKNOWN %prec IS { BooleanTest *b = makeNode(BooleanTest); b->arg = (Expr *) $1; diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 9fa63a4e6e..fcc912f8e3 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -1108,6 +1108,7 @@ do_start_worker(void) recentXid = ReadNewTransactionId(); xidForceLimit = recentXid - autovacuum_freeze_max_age; /* ensure it's a "normal" XID, else TransactionIdPrecedes misbehaves */ + /* this can cause the limit to go backwards by 3, but that's OK */ if (xidForceLimit < FirstNormalTransactionId) xidForceLimit -= FirstNormalTransactionId; diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 48ff9cc151..3b3158efe5 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -2283,6 +2283,9 @@ PredicateLockTupleRowVersionLink(const Relation relation, * locks. Even if a serializable transaction starts concurrently, * we know it can't take any SIREAD locks on the modified tuple * because the caller is holding the associated buffer page lock. + * Memory reordering isn't an issue; the memory barrier in the + * LWLock acquisition guarantees that this read occurs while the + * buffer page lock is held. */ if (!TransactionIdIsValid(PredXact->SxactGlobalXmin)) return; diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c index 8c0eaa78a7..be1663cd88 100644 --- a/src/backend/tsearch/spell.c +++ b/src/backend/tsearch/spell.c @@ -75,7 +75,7 @@ NIFinishBuild(IspellDict *Conf) * doesn't need that. The cpalloc and cpalloc0 macros are just documentation * to indicate which allocations actually require zeroing. */ -#define COMPACT_ALLOC_CHUNK 8192 /* must be > aset.c's allocChunkLimit */ +#define COMPACT_ALLOC_CHUNK 8192 /* amount to get from palloc at once */ #define COMPACT_MAX_REQ 1024 /* must be < COMPACT_ALLOC_CHUNK */ static void * diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index db0a6487ac..0a12a9b2e1 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -3569,24 +3569,27 @@ DateTimeParseError(int dterr, const char *str, const char *datatype) static const datetkn * datebsearch(const char *key, const datetkn *base, int nel) { - const datetkn *last = base + nel - 1, - *position; - int result; - - while (last >= base) + if (nel > 0) { - position = base + ((last - base) >> 1); - result = key[0] - position->token[0]; - if (result == 0) + const datetkn *last = base + nel - 1, + *position; + int result; + + while (last >= base) { - result = strncmp(key, position->token, TOKMAXLEN); + position = base + ((last - base) >> 1); + result = key[0] - position->token[0]; if (result == 0) - return position; + { + result = strncmp(key, position->token, TOKMAXLEN); + if (result == 0) + return position; + } + if (result < 0) + last = position - 1; + else + base = position + 1; } - if (result < 0) - last = position - 1; - else - base = position + 1; } return NULL; } diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 1f6fba5f75..3ac3254afb 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -324,7 +324,7 @@ CheckMyDatabase(const char *name, bool am_superuser) PGC_INTERNAL, PGC_S_OVERRIDE); /* If we have no other source of client_encoding, use server encoding */ SetConfigOption("client_encoding", GetDatabaseEncodingName(), - PGC_BACKEND, PGC_S_DEFAULT); + PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT); /* assign locale variables */ collate = NameStr(dbform->datcollate); diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index 10ef12eb24..78907b939d 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -14,6 +14,7 @@ #include <ctype.h> #include <unistd.h> +#include "mb/pg_wchar.h" #include "miscadmin.h" #include "storage/fd.h" #include "utils/guc.h" @@ -109,7 +110,6 @@ ProcessConfigFile(GucContext context) *tail; char *cvc = NULL; struct config_string *cvc_struct; - const char *envvar; int i; Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP); @@ -265,7 +265,7 @@ ProcessConfigFile(GucContext context) stack->source = PGC_S_DEFAULT; } - /* Now we can re-apply the wired-in default */ + /* Now we can re-apply the wired-in default (i.e., the boot_val) */ set_config_option(gconf->name, NULL, context, PGC_S_DEFAULT, GUC_ACTION_SET, true); if (context == PGC_SIGHUP) @@ -275,25 +275,28 @@ ProcessConfigFile(GucContext context) } /* - * Restore any variables determined by environment variables. This - * is a no-op except in the case where one of these had been in the - * config file and is now removed. PGC_S_ENV_VAR will override the - * wired-in default we just applied, but cannot override any other source. + * Restore any variables determined by environment variables or + * dynamically-computed defaults. This is a no-op except in the case + * where one of these had been in the config file and is now removed. * - * Keep this list in sync with InitializeGUCOptions()! - * PGPORT can be ignored, because it cannot be changed without restart. - * We assume rlimit hasn't changed, either. + * In particular, we *must not* do this during the postmaster's + * initial loading of the file, since the timezone functions in + * particular should be run only after initialization is complete. + * + * XXX this is an unmaintainable crock, because we have to know how + * to set (or at least what to call to set) every variable that could + * potentially have PGC_S_DYNAMIC_DEFAULT or PGC_S_ENV_VAR source. + * However, there's no time to redesign it for 9.1. */ - envvar = getenv("PGDATESTYLE"); - if (envvar != NULL) - set_config_option("datestyle", envvar, PGC_POSTMASTER, - PGC_S_ENV_VAR, GUC_ACTION_SET, true); - - envvar = getenv("PGCLIENTENCODING"); - if (envvar != NULL) - set_config_option("client_encoding", envvar, PGC_POSTMASTER, - PGC_S_ENV_VAR, GUC_ACTION_SET, true); - + if (context == PGC_SIGHUP) + { + InitializeGUCOptionsFromEnvironment(); + pg_timezone_initialize(); + pg_timezone_abbrev_initialize(); + /* this selects SQL_ASCII in processes not connected to a database */ + SetConfigOption("client_encoding", GetDatabaseEncodingName(), + PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT); + } /* If we got here all the options checked out okay, so apply them. */ for (item = head; item; item = item->next) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 738e2152ba..92391eda2f 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -502,6 +502,7 @@ const char *const GucContext_Names[] = const char *const GucSource_Names[] = { /* PGC_S_DEFAULT */ "default", + /* PGC_S_DYNAMIC_DEFAULT */ "default", /* PGC_S_ENV_VAR */ "environment variable", /* PGC_S_FILE */ "configuration file", /* PGC_S_ARGV */ "command line", @@ -3269,6 +3270,7 @@ static int GUCNestLevel = 0; /* 1 when in main transaction */ static int guc_var_compare(const void *a, const void *b); static int guc_name_compare(const char *namea, const char *nameb); +static void InitializeGUCOptionsFromEnvironment(void); static void InitializeOneGUCOption(struct config_generic * gconf); static void push_old_value(struct config_generic * gconf, GucAction action); static void ReportGUCOption(struct config_generic * record); @@ -3812,8 +3814,6 @@ void InitializeGUCOptions(void) { int i; - char *env; - long stack_rlimit; /* * Before log_line_prefix could possibly receive a nonempty setting, make @@ -3852,9 +3852,25 @@ InitializeGUCOptions(void) /* * For historical reasons, some GUC parameters can receive defaults from - * environment variables. Process those settings. NB: if you add or - * remove anything here, see also ProcessConfigFile(). + * environment variables. Process those settings. */ + InitializeGUCOptionsFromEnvironment(); +} + +/* + * Assign any GUC values that can come from the server's environment. + * + * This is called from InitializeGUCOptions, and also from ProcessConfigFile + * to deal with the possibility that a setting has been removed from + * postgresql.conf and should now get a value from the environment. + * (The latter is a kludge that should probably go away someday; if so, + * fold this back into InitializeGUCOptions.) + */ +static void +InitializeGUCOptionsFromEnvironment(void) +{ + char *env; + long stack_rlimit; env = getenv("PGPORT"); if (env != NULL) @@ -6334,6 +6350,7 @@ define_custom_variable(struct config_generic * variable) switch (pHolder->gen.source) { case PGC_S_DEFAULT: + case PGC_S_DYNAMIC_DEFAULT: case PGC_S_ENV_VAR: case PGC_S_FILE: case PGC_S_ARGV: @@ -8420,15 +8437,13 @@ assign_timezone_abbreviations(const char *newval, void *extra) * * This is called after initial loading of postgresql.conf. If no * timezone_abbreviations setting was found therein, select default. + * If a non-default value is already installed, nothing will happen. */ void pg_timezone_abbrev_initialize(void) { - if (timezone_abbreviations_string == NULL) - { - SetConfigOption("timezone_abbreviations", "Default", - PGC_POSTMASTER, PGC_S_DEFAULT); - } + SetConfigOption("timezone_abbreviations", "Default", + PGC_POSTMASTER, PGC_S_DYNAMIC_DEFAULT); } static const char * diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index b8a1582eaa..655dad42c7 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -390,8 +390,7 @@ #log_temp_files = -1 # log temporary files equal or larger # than the specified size in kilobytes; # -1 disables, 0 logs all temp files -#log_timezone = unknown # actually, defaults to TZ environment - # setting +#log_timezone = '(defaults to server environment setting)' #------------------------------------------------------------------------------ @@ -471,8 +470,7 @@ #datestyle = 'iso, mdy' #intervalstyle = 'postgres' -#timezone = unknown # actually, defaults to TZ environment - # setting +#timezone = '(defaults to server environment setting)' #timezone_abbreviations = 'Default' # Select the set of available time zone # abbreviations. Currently, there are # Default diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index e95dcb6b7c..140b0c74d9 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -89,7 +89,9 @@ * * With the current parameters, request sizes up to 8K are treated as chunks, * larger requests go into dedicated blocks. Change ALLOCSET_NUM_FREELISTS - * to adjust the boundary point. + * to adjust the boundary point. (But in contexts with small maxBlockSize, + * we may set the allocChunkLimit to less than 8K, so as to avoid space + * wastage.) *-------------------- */ @@ -97,6 +99,8 @@ #define ALLOCSET_NUM_FREELISTS 11 #define ALLOC_CHUNK_LIMIT (1 << (ALLOCSET_NUM_FREELISTS-1+ALLOC_MINBITS)) /* Size of largest chunk that we use a fixed size for */ +#define ALLOC_CHUNK_FRACTION 4 +/* We allow chunks to be at most 1/4 of maxBlockSize (less overhead) */ /*-------------------- * The first block allocated for an allocset has size initBlockSize. @@ -380,15 +384,20 @@ AllocSetContextCreate(MemoryContext parent, /* * Compute the allocation chunk size limit for this context. It can't be * more than ALLOC_CHUNK_LIMIT because of the fixed number of freelists. - * If maxBlockSize is small then requests exceeding the maxBlockSize - * should be treated as large chunks, too. We have to have - * allocChunkLimit a power of two, because the requested and - * actually-allocated sizes of any chunk must be on the same side of the - * limit, else we get confused about whether the chunk is "big". + * If maxBlockSize is small then requests exceeding the maxBlockSize, or + * even a significant fraction of it, should be treated as large chunks + * too. For the typical case of maxBlockSize a power of 2, the chunk size + * limit will be at most 1/8th maxBlockSize, so that given a stream of + * requests that are all the maximum chunk size we will waste at most + * 1/8th of the allocated space. + * + * We have to have allocChunkLimit a power of two, because the requested + * and actually-allocated sizes of any chunk must be on the same side of + * the limit, else we get confused about whether the chunk is "big". */ context->allocChunkLimit = ALLOC_CHUNK_LIMIT; - while (context->allocChunkLimit > - (Size) (maxBlockSize - ALLOC_BLOCKHDRSZ - ALLOC_CHUNKHDRSZ)) + while ((Size) (context->allocChunkLimit + ALLOC_CHUNKHDRSZ) > + (Size) ((maxBlockSize - ALLOC_BLOCKHDRSZ) / ALLOC_CHUNK_FRACTION)) context->allocChunkLimit >>= 1; /* diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 3b321494e4..56a396bddd 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1595,6 +1595,7 @@ setup_collation(void) size_t len; int enc; bool skip; + char *quoted_locale; char alias[NAMEDATALEN]; len = strlen(localebuf); @@ -1645,8 +1646,10 @@ setup_collation(void) count++; - PG_CMD_PRINTF2("INSERT INTO tmp_pg_collation (locale, encoding) VALUES ('%s', %d);\n", - escape_quotes(localebuf), enc); + quoted_locale = escape_quotes(localebuf); + + PG_CMD_PRINTF3("INSERT INTO tmp_pg_collation VALUES (E'%s', E'%s', %d);\n", + quoted_locale, quoted_locale, enc); /* * Generate aliases such as "en_US" in addition to "en_US.utf8" for @@ -1654,29 +1657,33 @@ setup_collation(void) * only, so this doesn't clash with "en_US" for LATIN1, say. */ if (normalize_locale_name(alias, localebuf)) - PG_CMD_PRINTF3("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('%s', '%s', %d);\n", - escape_quotes(alias), escape_quotes(localebuf), enc); + PG_CMD_PRINTF3("INSERT INTO tmp_pg_collation VALUES (E'%s', E'%s', %d);\n", + escape_quotes(alias), quoted_locale, enc); } /* Add an SQL-standard name */ - PG_CMD_PRINTF1("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('ucs_basic', 'C', %d);\n", PG_UTF8); + PG_CMD_PRINTF1("INSERT INTO tmp_pg_collation VALUES ('ucs_basic', 'C', %d);\n", PG_UTF8); /* * When copying collations to the final location, eliminate aliases that * conflict with an existing locale name for the same encoding. For * example, "br_FR.iso88591" is normalized to "br_FR", both for encoding * LATIN1. But the unnormalized locale "br_FR" already exists for LATIN1. - * Prefer the collation that matches the OS locale name, else the first + * Prefer the alias that matches the OS locale name, else the first locale * name by sort order (arbitrary choice to be deterministic). + * + * Also, eliminate any aliases that conflict with pg_collation's + * hard-wired entries for "C" etc. */ PG_CMD_PUTS("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) " - " SELECT DISTINCT ON (final_collname, collnamespace, encoding)" - " COALESCE(collname, locale) AS final_collname, " + " SELECT DISTINCT ON (collname, encoding)" + " collname, " " (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog') AS collnamespace, " " (SELECT relowner FROM pg_class WHERE relname = 'pg_collation') AS collowner, " " encoding, locale, locale " " FROM tmp_pg_collation" - " ORDER BY final_collname, collnamespace, encoding, (collname = locale) DESC, locale;\n"); + " WHERE NOT EXISTS (SELECT 1 FROM pg_collation WHERE collname = tmp_pg_collation.collname)" + " ORDER BY collname, encoding, (collname = locale) DESC, locale;\n"); pclose(locale_a_handle); PG_CMD_CLOSE; diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index a5d9c2e652..3feb3ee548 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -118,23 +118,23 @@ xmalloc0(int size) static void usage(void) { - printf(_("%s takes base backups of running PostgreSQL servers\n\n"), + printf(_("%s takes a base backup of a running PostgreSQL server.\n\n"), progname); printf(_("Usage:\n")); printf(_(" %s [OPTION]...\n"), progname); printf(_("\nOptions controlling the output:\n")); - printf(_(" -D, --pgdata=directory receive base backup into directory\n")); - printf(_(" -F, --format=p|t output format (plain, tar)\n")); - printf(_(" -x, --xlog include required WAL files in backup\n")); - printf(_(" -Z, --compress=0-9 compress tar output\n")); + printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n")); + printf(_(" -F, --format=p|t output format (plain, tar)\n")); + printf(_(" -x, --xlog include required WAL files in backup\n")); + printf(_(" -Z, --compress=0-9 compress tar output\n")); printf(_("\nGeneral options:\n")); printf(_(" -c, --checkpoint=fast|spread\n" - " set fast or spread checkpointing\n")); - printf(_(" -l, --label=label set backup label\n")); - printf(_(" -P, --progress show progress information\n")); - printf(_(" -v, --verbose output verbose messages\n")); - printf(_(" -?, --help show this help, then exit\n")); - printf(_(" -V, --version output version information, then exit\n")); + " set fast or spread checkpointing\n")); + printf(_(" -l, --label=LABEL set backup label\n")); + printf(_(" -P, --progress show progress information\n")); + printf(_(" -v, --verbose output verbose messages\n")); + printf(_(" --help show this help, then exit\n")); + printf(_(" --version output version information, then exit\n")); printf(_("\nConnection options:\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -p, --port=PORT database server port number\n")); @@ -337,7 +337,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_COPY_OUT) { - fprintf(stderr, _("%s: could not get COPY data stream: %s\n"), + fprintf(stderr, _("%s: could not get COPY data stream: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -398,7 +398,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) } else if (r == -2) { - fprintf(stderr, _("%s: could not read COPY data: %s\n"), + fprintf(stderr, _("%s: could not read COPY data: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -467,7 +467,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_COPY_OUT) { - fprintf(stderr, _("%s: could not get COPY data stream: %s\n"), + fprintf(stderr, _("%s: could not get COPY data stream: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -496,7 +496,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) } else if (r == -2) { - fprintf(stderr, _("%s: could not read COPY data: %s\n"), + fprintf(stderr, _("%s: could not read COPY data: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -510,7 +510,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) */ if (r != 512) { - fprintf(stderr, _("%s: Invalid tar block header size: %i\n"), + fprintf(stderr, _("%s: invalid tar block header size: %i\n"), progname, r); disconnect_and_exit(1); } @@ -518,7 +518,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) if (sscanf(copybuf + 124, "%11o", ¤t_len_left) != 1) { - fprintf(stderr, _("%s: could not parse file size!\n"), + fprintf(stderr, _("%s: could not parse file size\n"), progname); disconnect_and_exit(1); } @@ -526,7 +526,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) /* Set permissions on the file */ if (sscanf(©buf[100], "%07o ", &filemode) != 1) { - fprintf(stderr, _("%s: could not parse file mode!\n"), + fprintf(stderr, _("%s: could not parse file mode\n"), progname); disconnect_and_exit(1); } @@ -581,7 +581,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) } else { - fprintf(stderr, _("%s: unknown link indicator \"%c\"\n"), + fprintf(stderr, _("%s: unrecognized link indicator \"%c\"\n"), progname, copybuf[156]); disconnect_and_exit(1); } @@ -659,7 +659,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) if (file != NULL) { - fprintf(stderr, _("%s: last file was never finished!\n"), progname); + fprintf(stderr, _("%s: last file was never finished\n"), progname); disconnect_and_exit(1); } @@ -740,7 +740,7 @@ GetConnection(void) if (PQstatus(tmpconn) != CONNECTION_OK) { - fprintf(stderr, _("%s: could not connect to server: %s\n"), + fprintf(stderr, _("%s: could not connect to server: %s"), progname, PQerrorMessage(tmpconn)); exit(1); } @@ -780,7 +780,7 @@ BaseBackup(void) if (PQsendQuery(conn, current_path) == 0) { - fprintf(stderr, _("%s: could not start base backup: %s\n"), + fprintf(stderr, _("%s: could not start base backup: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -791,13 +791,13 @@ BaseBackup(void) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) { - fprintf(stderr, _("%s: could not initiate base backup: %s\n"), + fprintf(stderr, _("%s: could not initiate base backup: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } if (PQntuples(res) != 1) { - fprintf(stderr, _("%s: no start point returned from server.\n"), + fprintf(stderr, _("%s: no start point returned from server\n"), progname); disconnect_and_exit(1); } @@ -813,13 +813,13 @@ BaseBackup(void) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) { - fprintf(stderr, _("%s: could not get backup header: %s\n"), + fprintf(stderr, _("%s: could not get backup header: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } if (PQntuples(res) < 1) { - fprintf(stderr, _("%s: no data returned from server.\n"), progname); + fprintf(stderr, _("%s: no data returned from server\n"), progname); disconnect_and_exit(1); } @@ -847,7 +847,7 @@ BaseBackup(void) */ if (format == 't' && strcmp(basedir, "-") == 0 && PQntuples(res) > 1) { - fprintf(stderr, _("%s: can only write single tablespace to stdout, database has %i.\n"), + fprintf(stderr, _("%s: can only write single tablespace to stdout, database has %i\n"), progname, PQntuples(res)); disconnect_and_exit(1); } @@ -876,13 +876,13 @@ BaseBackup(void) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) { - fprintf(stderr, _("%s: could not get end xlog position from server.\n"), + fprintf(stderr, _("%s: could not get end xlog position from server\n"), progname); disconnect_and_exit(1); } if (PQntuples(res) != 1) { - fprintf(stderr, _("%s: no end point returned from server.\n"), + fprintf(stderr, _("%s: no end point returned from server\n"), progname); disconnect_and_exit(1); } @@ -894,7 +894,7 @@ BaseBackup(void) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, _("%s: final receive failed: %s\n"), + fprintf(stderr, _("%s: final receive failed: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -905,7 +905,7 @@ BaseBackup(void) PQfinish(conn); if (verbose) - fprintf(stderr, "%s: base backup completed.\n", progname); + fprintf(stderr, "%s: base backup completed\n", progname); } @@ -1003,12 +1003,6 @@ main(int argc, char **argv) dbhost = xstrdup(optarg); break; case 'p': - if (atoi(optarg) <= 0) - { - fprintf(stderr, _("%s: invalid port number \"%s\"\n"), - progname, optarg); - exit(1); - } dbport = xstrdup(optarg); break; case 'U': diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index afc7fd7032..e474a6980d 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -863,7 +863,7 @@ help(const char *progname) printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --role=ROLENAME do SET ROLE before dump\n")); printf(_(" --no-security-label do not dump security label assignments\n")); - printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); + printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n")); @@ -11804,7 +11804,6 @@ dumpTable(Archive *fout, TableInfo *tbinfo) namecopy = strdup(fmtId(tbinfo->dobj.name)); dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : - (tbinfo->relkind == RELKIND_FOREIGN_TABLE) ? "FOREIGN TABLE" : "TABLE", namecopy, NULL, tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 963ae54aea..41a330763f 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -554,7 +554,7 @@ help(void) printf(_(" --quote-all-identifiers quote all identifiers, even if not keywords\n")); printf(_(" --role=ROLENAME do SET ROLE before dump\n")); printf(_(" --no-security-label do not dump security label assignments\n")); - printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); + printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n")); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 3ef2fa421d..9a7eca0766 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2234,7 +2234,6 @@ psql_completion(char *text, int start, int end) " UNION SELECT 'DATABASE'" " UNION SELECT 'FOREIGN DATA WRAPPER'" " UNION SELECT 'FOREIGN SERVER'" - " UNION SELECT 'FOREIGN TABLE'" " UNION SELECT 'FUNCTION'" " UNION SELECT 'LANGUAGE'" " UNION SELECT 'LARGE OBJECT'" @@ -2246,7 +2245,7 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev_wd, "FOREIGN") == 0) { static const char *const list_privilege_foreign[] = - {"DATA WRAPPER", "SERVER", "TABLE", NULL}; + {"DATA WRAPPER", "SERVER", NULL}; COMPLETE_WITH_LIST(list_privilege_foreign); } diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index 9b72eac79b..544f2f64b3 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -192,6 +192,11 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, ";\n"); + /* + * Connect to the 'postgres' database by default, except have + * the 'postgres' user use 'template1' so he can create the + * 'postgres' database. + */ conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres", host, port, username, prompt_password, progname); @@ -208,12 +213,9 @@ main(int argc, char *argv[]) } PQclear(result); - PQfinish(conn); if (comment) { - conn = connectDatabase(dbname, host, port, username, prompt_password, progname); - printfPQExpBuffer(&sql, "COMMENT ON DATABASE %s IS ", fmtId(dbname)); appendStringLiteralConn(&sql, comment, conn); appendPQExpBuffer(&sql, ";\n"); @@ -231,9 +233,10 @@ main(int argc, char *argv[]) } PQclear(result); - PQfinish(conn); } + PQfinish(conn); + exit(0); } diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c index 1cf18fd5d8..48f73ae25e 100644 --- a/src/bin/scripts/dropdb.c +++ b/src/bin/scripts/dropdb.c @@ -113,6 +113,11 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, "DROP DATABASE %s;\n", fmtId(dbname)); + /* + * Connect to the 'postgres' database by default, except have + * the 'postgres' user use 'template1' so he can drop the + * 'postgres' database. + */ conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres", host, port, username, prompt_password, progname); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 2df489f32e..49d1e7db6f 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201104251 +#define CATALOG_VERSION_NO 201105131 #endif diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 5a42d8cec3..ee52cd735e 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -82,7 +82,8 @@ typedef enum */ typedef enum { - PGC_S_DEFAULT, /* wired-in default */ + PGC_S_DEFAULT, /* hard-wired default ("boot_val") */ + PGC_S_DYNAMIC_DEFAULT, /* default computed during initialization */ PGC_S_ENV_VAR, /* postmaster environment variable */ PGC_S_FILE, /* postgresql.conf */ PGC_S_ARGV, /* postmaster command line */ diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index da3224aae3..45f1f8affd 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -512,24 +512,27 @@ char *pgtypes_date_months[] = {"January", "February", "March", "April", "May" static datetkn * datebsearch(char *key, datetkn *base, unsigned int nel) { - datetkn *last = base + nel - 1, - *position; - int result; - - while (last >= base) + if (nel > 0) { - position = base + ((last - base) >> 1); - result = key[0] - position->token[0]; - if (result == 0) + datetkn *last = base + nel - 1, + *position; + int result; + + while (last >= base) { - result = strncmp(key, position->token, TOKMAXLEN); + position = base + ((last - base) >> 1); + result = key[0] - position->token[0]; if (result == 0) - return position; + { + result = strncmp(key, position->token, TOKMAXLEN); + if (result == 0) + return position; + } + if (result < 0) + last = position - 1; + else + base = position + 1; } - if (result < 0) - last = position - 1; - else - base = position + 1; } return NULL; } diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 1b409d1e44..6648753da0 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -3596,10 +3596,11 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, return 1; } - /* concatenate values to a single string */ - for (size = 0, i = 0; values[i] != NULL; ++i) + /* concatenate values into a single string with newline terminators */ + size = 1; /* for the trailing null */ + for (i = 0; values[i] != NULL; i++) size += values[i]->bv_len + 1; - if ((result = malloc(size + 1)) == NULL) + if ((result = malloc(size)) == NULL) { printfPQExpBuffer(errorMessage, libpq_gettext("out of memory\n")); @@ -3607,14 +3608,14 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, ldap_unbind(ld); return 3; } - for (p = result, i = 0; values[i] != NULL; ++i) + p = result; + for (i = 0; values[i] != NULL; i++) { - strncpy(p, values[i]->bv_val, values[i]->bv_len); + memcpy(p, values[i]->bv_val, values[i]->bv_len); p += values[i]->bv_len; *(p++) = '\n'; - if (values[i + 1] == NULL) - *(p + 1) = '\0'; } + *p = '\0'; ldap_value_free_len(values); ldap_unbind(ld); @@ -3643,6 +3644,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, printfPQExpBuffer(errorMessage, libpq_gettext( "missing \"=\" after \"%s\" in connection info string\n"), optname); + free(result); return 3; } else if (*p == '=') @@ -3661,6 +3663,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, printfPQExpBuffer(errorMessage, libpq_gettext( "missing \"=\" after \"%s\" in connection info string\n"), optname); + free(result); return 3; } break; @@ -3724,6 +3727,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, printfPQExpBuffer(errorMessage, libpq_gettext("invalid connection option \"%s\"\n"), optname); + free(result); return 1; } optname = NULL; @@ -3732,6 +3736,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, oldstate = state; } + free(result); + if (state == 5 || state == 6) { printfPQExpBuffer(errorMessage, libpq_gettext( diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 7fb007fb1c..05ed8416a9 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -103,51 +103,30 @@ endif # MODULE_big install: all installdirs ifneq (,$(EXTENSION)) - @for file in $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))) '$(DESTDIR)$(datadir)/extension/' endif # EXTENSION ifneq (,$(DATA)$(DATA_built)) - @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) '$(DESTDIR)$(datadir)/$(datamoduledir)/' endif # DATA ifneq (,$(DATA_TSEARCH)) - @for file in $(addprefix $(srcdir)/, $(DATA_TSEARCH)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/tsearch_data'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/tsearch_data'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA_TSEARCH)) '$(DESTDIR)$(datadir)/tsearch_data/' endif # DATA_TSEARCH ifdef MODULES - @for file in $(addsuffix $(DLSUFFIX), $(MODULES)); do \ - echo "$(INSTALL_SHLIB) $$file '$(DESTDIR)$(pkglibdir)'"; \ - $(INSTALL_SHLIB) $$file '$(DESTDIR)$(pkglibdir)'; \ - done + $(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/' endif # MODULES ifdef DOCS ifdef docdir - @for file in $(addprefix $(srcdir)/, $(DOCS)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DOCS)) '$(DESTDIR)$(docdir)/$(docmoduledir)/' endif # docdir endif # DOCS ifdef PROGRAM $(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)' endif # PROGRAM ifdef SCRIPTS - @for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \ - echo "$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \ - $(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'; \ - done + $(INSTALL_SCRIPT) $(addprefix $(srcdir)/, $(SCRIPTS)) '$(DESTDIR)$(bindir)/' endif # SCRIPTS ifdef SCRIPTS_built - @for file in $(SCRIPTS_built); do \ - echo "$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \ - $(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'; \ - done + $(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/' endif # SCRIPTS_built ifdef MODULE_big diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile index 155b60f43f..79a8d5d3fa 100644 --- a/src/pl/plperl/GNUmakefile +++ b/src/pl/plperl/GNUmakefile @@ -82,10 +82,7 @@ installdirs: installdirs-lib uninstall: uninstall-lib uninstall-data install-data: installdirs - @for file in $(addprefix $(srcdir)/, $(DATA)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/' uninstall-data: rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA))) diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile index 52fbc1c41a..751a98dbb0 100644 --- a/src/pl/plpgsql/src/Makefile +++ b/src/pl/plpgsql/src/Makefile @@ -35,10 +35,7 @@ installdirs: installdirs-lib uninstall: uninstall-lib uninstall-data install-data: installdirs - @for file in $(addprefix $(srcdir)/, $(DATA)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/' uninstall-data: rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA))) diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile index 86d8741e28..2c0575501a 100644 --- a/src/pl/plpython/Makefile +++ b/src/pl/plpython/Makefile @@ -114,10 +114,7 @@ installdirs: installdirs-lib uninstall: uninstall-lib uninstall-data install-data: installdirs - @for file in $(addprefix $(srcdir)/, $(DATA)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/' uninstall-data: rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA))) @@ -141,7 +138,7 @@ prep3: -e "s/LANGUAGE plpython2u/LANGUAGE plpython3u/g" \ -e "s/EXTENSION plpythonu/EXTENSION plpython3u/g" \ -e "s/EXTENSION plpython2u/EXTENSION plpython3u/g" \ - $$file >`echo $$file | sed 's,$(srcdir),python3,'`; \ + $$file >`echo $$file | sed 's,$(srcdir),python3,'` || exit; \ done clean3: diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile index faffd09fd3..77c173bcd8 100644 --- a/src/pl/tcl/Makefile +++ b/src/pl/tcl/Makefile @@ -65,10 +65,7 @@ uninstall: uninstall-lib uninstall-data $(MAKE) -C modules $@ install-data: installdirs - @for file in $(addprefix $(srcdir)/, $(DATA)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \ - done + $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/' uninstall-data: rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA))) diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile index 0f709a1e3c..6513b5f24e 100644 --- a/src/test/isolation/Makefile +++ b/src/test/isolation/Makefile @@ -10,7 +10,7 @@ ifeq ($(PORTNAME), win32) LDLIBS += -lws2_32 endif -override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS) +override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(srcdir)/../regress $(CPPFLAGS) override LDLIBS := $(libpq_pgport) $(LDLIBS) OBJS = specparse.o isolationtester.o @@ -64,7 +64,7 @@ endif clean distclean: rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o rm -f pg_regress.o - rm -rf results + rm -rf $(pg_regress_clean_files) maintainer-clean: distclean rm -f specparse.c specscanner.c @@ -72,5 +72,10 @@ maintainer-clean: distclean installcheck: all ./pg_isolation_regress --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule -check: all - ./pg_isolation_regress --temp-install=./tmp_check --inputdir=$(srcdir) --top-builddir=$(top_builddir) --schedule=$(srcdir)/isolation_schedule +# We can't support "make check" because isolationtester requires libpq, and +# in fact (on typical platforms using shared libraries) requires libpq to +# already be installed. You could run "make install" and then run a check +# using a temp installation, but there seems little point in that. +check: + @echo "'make check' is not supported." + @echo "Install PostgreSQL, then 'make installcheck' instead." diff --git a/src/test/isolation/isolation_main.c b/src/test/isolation/isolation_main.c index 2df12f879e..18cd8ef7fd 100644 --- a/src/test/isolation/isolation_main.c +++ b/src/test/isolation/isolation_main.c @@ -10,7 +10,7 @@ *------------------------------------------------------------------------- */ -#include "../regress/pg_regress.h" +#include "pg_regress.h" /* * start an isolation tester process for specified file (including diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 44a4858c96..0f77917fb5 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -5,14 +5,12 @@ * Runs an isolation test specified by a spec file. */ +#include "postgres_fe.h" + #ifdef WIN32 #include <windows.h> #endif -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include "libpq-fe.h" #include "isolationtester.h" diff --git a/src/test/isolation/specparse.y b/src/test/isolation/specparse.y index c684780216..47bfbc4f39 100644 --- a/src/test/isolation/specparse.y +++ b/src/test/isolation/specparse.y @@ -10,10 +10,7 @@ *------------------------------------------------------------------------- */ -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string.h> +#include "postgres_fe.h" #include "isolationtester.h" diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index 0dc7d045c7..e18eed8c1c 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -670,7 +670,7 @@ Has OIDs: no (1 row) CREATE INDEX id_ft1_c2 ON ft1 (c2); -- ERROR -ERROR: "ft1" is not a table +ERROR: cannot create index on foreign table "ft1" SELECT * FROM ft1; -- ERROR ERROR: foreign-data wrapper "dummy" has no handler EXPLAIN SELECT * FROM ft1; -- ERROR diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index cb66f6380b..622cf94c5a 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -1438,6 +1438,10 @@ pg_timezone_pre_initialize(void) * This is called after initial loading of postgresql.conf. If no TimeZone * setting was found therein, we try to derive one from the environment. * Likewise for log_timezone. + * + * Note: this is also called from ProcessConfigFile, to re-establish valid + * GUC settings if the GUCs have been reset to default following their + * removal from postgresql.conf. */ void pg_timezone_initialize(void) @@ -1463,21 +1467,34 @@ pg_timezone_initialize(void) log_timezone = def_tz; } - /* Now, set the timezone GUC if it's not already set */ - if (GetConfigOption("timezone", false) == NULL) - { - /* Tell GUC about the value. Will redundantly call pg_tzset() */ + /* + * Now, set the timezone and log_timezone GUCs if they're still default. + * (This will redundantly call pg_tzset().) + * + * We choose to label these values PGC_S_ENV_VAR, rather than + * PGC_S_DYNAMIC_DEFAULT which would be functionally equivalent, because + * they came either from getenv("TZ") or from libc behavior that's + * determined by process environment of some kind. + * + * Note: in the case where a setting has just been removed from + * postgresql.conf, this code will not do what you might expect, namely + * call select_default_timezone() and install that value as the setting. + * Rather, the previously active setting --- typically the one from + * postgresql.conf --- will be reinstalled, relabeled as PGC_S_ENV_VAR. + * If we did try to install the "correct" default value, the effect would + * be that each postmaster child would independently run an extremely + * expensive search of the timezone database, bringing the database to its + * knees for possibly multiple seconds. This is so unpleasant, and could + * so easily be triggered quite unintentionally, that it seems better to + * violate the principle of least astonishment. + */ + if (GetConfigOptionResetString("timezone") == NULL) SetConfigOption("timezone", pg_get_timezone_name(session_timezone), PGC_POSTMASTER, PGC_S_ENV_VAR); - } - /* Likewise for log timezone */ - if (GetConfigOption("log_timezone", false) == NULL) - { - /* Tell GUC about the value. Will redundantly call pg_tzset() */ + if (GetConfigOptionResetString("log_timezone") == NULL) SetConfigOption("log_timezone", pg_get_timezone_name(log_timezone), PGC_POSTMASTER, PGC_S_ENV_VAR); - } } |