summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile9
-rw-r--r--contrib/dblink/dblink.c10
-rw-r--r--contrib/dummy_seclabel/dummy_seclabel.c1
-rw-r--r--contrib/file_fdw/file_fdw.c19
-rw-r--r--contrib/file_fdw/input/file_fdw.source1
-rw-r--r--contrib/file_fdw/output/file_fdw.source2
-rw-r--r--contrib/lo/lo.c7
-rw-r--r--contrib/pageinspect/btreefuncs.c1
-rw-r--r--contrib/pageinspect/rawpage.c1
-rw-r--r--contrib/pg_upgrade/check.c117
-rw-r--r--contrib/pg_upgrade/controldata.c4
-rw-r--r--contrib/pg_upgrade/option.c81
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h5
-rw-r--r--contrib/pgcrypto/crypt-blowfish.c26
-rw-r--r--contrib/pgcrypto/px-crypt.c1
-rw-r--r--contrib/pgrowlocks/pgrowlocks.c1
-rw-r--r--contrib/pgstattuple/pgstatindex.c1
-rw-r--r--contrib/spi/autoinc.c1
-rw-r--r--contrib/spi/insert_username.c1
-rw-r--r--contrib/spi/moddatetime.c1
-rw-r--r--contrib/spi/refint.c1
-rw-r--r--contrib/spi/timetravel.c1
22 files changed, 181 insertions, 111 deletions
diff --git a/contrib/Makefile b/contrib/Makefile
index 62811bb987..6daf8684ac 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -53,18 +53,26 @@ SUBDIRS = \
ifeq ($(with_openssl),yes)
SUBDIRS += sslinfo
+else
+ALWAYS_SUBDIRS += sslinfo
endif
ifeq ($(with_ossp_uuid),yes)
SUBDIRS += uuid-ossp
+else
+ALWAYS_SUBDIRS += uuid-ossp
endif
ifeq ($(with_libxml),yes)
SUBDIRS += xml2
+else
+ALWAYS_SUBDIRS += xml2
endif
ifeq ($(with_selinux),yes)
SUBDIRS += sepgsql
+else
+ALWAYS_SUBDIRS += sepgsql
endif
# Missing:
@@ -72,3 +80,4 @@ endif
$(recurse)
+$(recurse_always)
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 19b98fb73d..76617e3f36 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -63,6 +63,7 @@
#include "utils/hsearch.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
+#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
@@ -613,16 +614,13 @@ Datum
dblink_send_query(PG_FUNCTION_ARGS)
{
PGconn *conn = NULL;
- char *connstr = NULL;
char *sql = NULL;
remoteConn *rconn = NULL;
- char *msg;
- bool freeconn = false;
int retval;
if (PG_NARGS() == 2)
{
- DBLINK_GET_CONN;
+ DBLINK_GET_NAMED_CONN;
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
}
else
@@ -711,13 +709,13 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
if (PG_NARGS() == 2)
{
/* text,bool */
- DBLINK_GET_CONN;
+ DBLINK_GET_NAMED_CONN;
fail = PG_GETARG_BOOL(1);
}
else if (PG_NARGS() == 1)
{
/* text */
- DBLINK_GET_CONN;
+ DBLINK_GET_NAMED_CONN;
}
else
/* shouldn't happen */
diff --git a/contrib/dummy_seclabel/dummy_seclabel.c b/contrib/dummy_seclabel/dummy_seclabel.c
index 5deb43fa9b..2979fecd06 100644
--- a/contrib/dummy_seclabel/dummy_seclabel.c
+++ b/contrib/dummy_seclabel/dummy_seclabel.c
@@ -14,6 +14,7 @@
#include "commands/seclabel.h"
#include "miscadmin.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 466c015107..224e74ff32 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -24,6 +24,7 @@
#include "foreign/foreign.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
@@ -215,6 +216,14 @@ file_fdw_validator(PG_FUNCTION_ARGS)
*/
ProcessCopyOptions(NULL, true, other_options);
+ /*
+ * Filename option is required for file_fdw foreign tables.
+ */
+ if (catalog == ForeignTableRelationId && filename == NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED),
+ errmsg("filename is required for file_fdw foreign tables")));
+
PG_RETURN_VOID();
}
@@ -286,10 +295,14 @@ fileGetOptions(Oid foreigntableid,
}
prev = lc;
}
+
+ /*
+ * The validator should have checked that a filename was included in the
+ * options, but check again, just in case.
+ */
if (*filename == NULL)
- ereport(ERROR,
- (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_REPLY),
- errmsg("filename is required for file_fdw foreign tables")));
+ elog(ERROR, "filename is required for file_fdw foreign tables");
+
*other_options = options;
}
diff --git a/contrib/file_fdw/input/file_fdw.source b/contrib/file_fdw/input/file_fdw.source
index 9ff7235a12..1405752819 100644
--- a/contrib/file_fdw/input/file_fdw.source
+++ b/contrib/file_fdw/input/file_fdw.source
@@ -59,6 +59,7 @@ CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter
'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
'); -- ERROR
+CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
CREATE FOREIGN TABLE agg_text (
a int2,
diff --git a/contrib/file_fdw/output/file_fdw.source b/contrib/file_fdw/output/file_fdw.source
index 2ba36c9368..6dd2653d0a 100644
--- a/contrib/file_fdw/output/file_fdw.source
+++ b/contrib/file_fdw/output/file_fdw.source
@@ -75,6 +75,8 @@ ERROR: COPY delimiter cannot be newline or carriage return
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
'); -- ERROR
ERROR: COPY null representation cannot use newline or carriage return
+CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
+ERROR: filename is required for file_fdw foreign tables
CREATE FOREIGN TABLE agg_text (
a int2,
b float4
diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c
index 0e3559c020..6946150fed 100644
--- a/contrib/lo/lo.c
+++ b/contrib/lo/lo.c
@@ -7,15 +7,12 @@
#include "postgres.h"
-/* Required for SPI */
+#include "commands/trigger.h"
#include "executor/spi.h"
-
-/* Required for largeobjects */
#include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h"
+#include "utils/rel.h"
-/* Required for triggers */
-#include "commands/trigger.h"
PG_MODULE_MAGIC;
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index ef27cd4080..514406a67a 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -35,6 +35,7 @@
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
extern Datum bt_metap(PG_FUNCTION_ARGS);
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
index 2607576c37..8fc3a48d56 100644
--- a/contrib/pageinspect/rawpage.c
+++ b/contrib/pageinspect/rawpage.c
@@ -25,6 +25,7 @@
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index 376d25a09a..5c5ce72294 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -19,6 +19,8 @@ static void check_is_super_user(ClusterInfo *cluster);
static void check_for_prepared_transactions(ClusterInfo *cluster);
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
+static void check_for_support_lib(ClusterInfo *cluster);
+static void get_bin_version(ClusterInfo *cluster);
void
@@ -27,10 +29,13 @@ output_check_banner(bool *live_check)
if (user_opts.check && is_server_running(old_cluster.pgdata))
{
*live_check = true;
+ if (old_cluster.port == DEF_PGUPORT)
+ pg_log(PG_FATAL, "When checking a live old server, "
+ "you must specify the old server's port number.\n");
if (old_cluster.port == new_cluster.port)
pg_log(PG_FATAL, "When checking a live server, "
"the old and new port numbers must be different.\n");
- pg_log(PG_REPORT, "PerForming Consistency Checks on Old Live Server\n");
+ pg_log(PG_REPORT, "Performing Consistency Checks on Old Live Server\n");
pg_log(PG_REPORT, "------------------------------------------------\n");
}
else
@@ -42,8 +47,7 @@ output_check_banner(bool *live_check)
void
-check_old_cluster(bool live_check,
- char **sequence_script_file_name)
+check_old_cluster(bool live_check, char **sequence_script_file_name)
{
/* -- OLD -- */
@@ -216,6 +220,8 @@ output_completion_banner(char *deletion_script_file_name)
void
check_cluster_versions(void)
{
+ prep_status("Checking cluster versions");
+
/* get old and new cluster versions */
old_cluster.major_version = get_major_server_version(&old_cluster);
new_cluster.major_version = get_major_server_version(&new_cluster);
@@ -235,31 +241,33 @@ check_cluster_versions(void)
/*
* We can't allow downgrading because we use the target pg_dumpall, and
- * pg_dumpall cannot operate on new datbase versions, only older versions.
+ * pg_dumpall cannot operate on new database versions, only older versions.
*/
if (old_cluster.major_version > new_cluster.major_version)
pg_log(PG_FATAL, "This utility cannot be used to downgrade to older major PostgreSQL versions.\n");
+
+ /* get old and new binary versions */
+ get_bin_version(&old_cluster);
+ get_bin_version(&new_cluster);
+
+ /* Ensure binaries match the designated data directories */
+ if (GET_MAJOR_VERSION(old_cluster.major_version) !=
+ GET_MAJOR_VERSION(old_cluster.bin_version))
+ pg_log(PG_FATAL,
+ "Old cluster data and binary directories are from different major versions.\n");
+ if (GET_MAJOR_VERSION(new_cluster.major_version) !=
+ GET_MAJOR_VERSION(new_cluster.bin_version))
+ pg_log(PG_FATAL,
+ "New cluster data and binary directories are from different major versions.\n");
+
+ check_ok();
}
void
check_cluster_compatibility(bool live_check)
{
- char libfile[MAXPGPATH];
- FILE *lib_test;
-
- /*
- * Test pg_upgrade_support.so is in the proper place. We cannot copy it
- * ourselves because install directories are typically root-owned.
- */
- snprintf(libfile, sizeof(libfile), "%s/pg_upgrade_support%s", new_cluster.libpath,
- DLSUFFIX);
-
- if ((lib_test = fopen(libfile, "r")) == NULL)
- pg_log(PG_FATAL,
- "pg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile);
- else
- fclose(lib_test);
+ check_for_support_lib(&new_cluster);
/* get/check pg_control data of servers */
get_control_data(&old_cluster, live_check);
@@ -406,8 +414,7 @@ check_old_cluster_has_new_cluster_dbs(void)
* This is particularly useful for tablespace deletion.
*/
void
-create_script_for_old_cluster_deletion(
- char **deletion_script_file_name)
+create_script_for_old_cluster_deletion(char **deletion_script_file_name)
{
FILE *script = NULL;
int tblnum;
@@ -730,3 +737,71 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
else
check_ok();
}
+
+
+/*
+ * Test pg_upgrade_support.so is in the proper place. We cannot copy it
+ * ourselves because install directories are typically root-owned.
+ */
+static void
+check_for_support_lib(ClusterInfo *cluster)
+{
+ char cmd[MAXPGPATH];
+ char libdir[MAX_STRING];
+ char libfile[MAXPGPATH];
+ FILE *lib_test;
+ FILE *output;
+
+ snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
+
+ if ((output = popen(cmd, "r")) == NULL)
+ pg_log(PG_FATAL, "Could not get pkglibdir data: %s\n",
+ getErrorText(errno));
+
+ fgets(libdir, sizeof(libdir), output);
+
+ pclose(output);
+
+ /* Remove trailing newline */
+ if (strchr(libdir, '\n') != NULL)
+ *strchr(libdir, '\n') = '\0';
+
+ snprintf(libfile, sizeof(libfile), "%s/pg_upgrade_support%s", libdir,
+ DLSUFFIX);
+
+ if ((lib_test = fopen(libfile, "r")) == NULL)
+ pg_log(PG_FATAL,
+ "The pg_upgrade_support module must be created and installed in the %s cluster.\n",
+ CLUSTER_NAME(cluster));
+
+ fclose(lib_test);
+}
+
+
+static void
+get_bin_version(ClusterInfo *cluster)
+{
+ char cmd[MAXPGPATH], cmd_output[MAX_STRING];
+ FILE *output;
+ int pre_dot, post_dot;
+
+ snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
+
+ if ((output = popen(cmd, "r")) == NULL)
+ pg_log(PG_FATAL, "Could not get pg_ctl version data: %s\n",
+ getErrorText(errno));
+
+ fgets(cmd_output, sizeof(cmd_output), output);
+
+ pclose(output);
+
+ /* Remove trailing newline */
+ if (strchr(cmd_output, '\n') != NULL)
+ *strchr(cmd_output, '\n') = '\0';
+
+ if (sscanf(cmd_output, "%*s %*s %d.%d", &pre_dot, &post_dot) != 2)
+ pg_log(PG_FATAL, "could not get version from %s\n", cmd);
+
+ cluster->bin_version = (pre_dot * 100 + post_dot) * 100;
+}
+
diff --git a/contrib/pg_upgrade/controldata.c b/contrib/pg_upgrade/controldata.c
index 25ee81f2a0..8e0db7750f 100644
--- a/contrib/pg_upgrade/controldata.c
+++ b/contrib/pg_upgrade/controldata.c
@@ -140,8 +140,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
if (!isascii(*p))
pg_log(PG_FATAL,
"The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n"
- "with LANG=C. You must upgrade this cluster to a newer version of Postgres\n"
- "8.3 to fix this bug. Postgres 8.3.7 and later are known to work properly.\n");
+ "with LANG=C. You must upgrade this cluster to a newer version of PostgreSQL\n"
+ "8.3 to fix this bug. PostgreSQL 8.3.7 and later are known to work properly.\n");
}
#endif
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index 8153e3087a..d29aad0e1d 100644
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -17,10 +17,8 @@
static void usage(void);
-static void validateDirectoryOption(char **dirpath,
+static void check_required_directory(char **dirpath,
char *envVarName, char *cmdLineOption, char *description);
-static void get_pkglibdirs(void);
-static char *get_pkglibdir(const char *bindir);
UserOpts user_opts;
@@ -60,8 +58,8 @@ parseCommandLine(int argc, char *argv[])
os_info.progname = get_progname(argv[0]);
/* Process libpq env. variables; load values here for usage() output */
- old_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;
- new_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;
+ old_cluster.port = getenv("PGPORTOLD") ? atoi(getenv("PGPORTOLD")) : DEF_PGUPORT;
+ new_cluster.port = getenv("PGPORTNEW") ? atoi(getenv("PGPORTNEW")) : DEF_PGUPORT;
os_user_effective_id = get_user_info(&os_info.user);
/* we override just the database user name; we got the OS id above */
@@ -205,16 +203,14 @@ parseCommandLine(int argc, char *argv[])
}
/* Get values from env if not already set */
- validateDirectoryOption(&old_cluster.bindir, "OLDBINDIR", "-b",
+ check_required_directory(&old_cluster.bindir, "PGBINOLD", "-b",
"old cluster binaries reside");
- validateDirectoryOption(&new_cluster.bindir, "NEWBINDIR", "-B",
+ check_required_directory(&new_cluster.bindir, "PGBINNEW", "-B",
"new cluster binaries reside");
- validateDirectoryOption(&old_cluster.pgdata, "OLDDATADIR", "-d",
+ check_required_directory(&old_cluster.pgdata, "PGDATAOLD", "-d",
"old cluster data resides");
- validateDirectoryOption(&new_cluster.pgdata, "NEWDATADIR", "-D",
+ check_required_directory(&new_cluster.pgdata, "PGDATANEW", "-D",
"new cluster data resides");
-
- get_pkglibdirs();
}
@@ -258,17 +254,17 @@ For example:\n\
or\n"), old_cluster.port, new_cluster.port, os_info.user);
#ifndef WIN32
printf(_("\
- $ export OLDDATADIR=oldCluster/data\n\
- $ export NEWDATADIR=newCluster/data\n\
- $ export OLDBINDIR=oldCluster/bin\n\
- $ export NEWBINDIR=newCluster/bin\n\
+ $ export PGDATAOLD=oldCluster/data\n\
+ $ export PGDATANEW=newCluster/data\n\
+ $ export PGBINOLD=oldCluster/bin\n\
+ $ export PGBINNEW=newCluster/bin\n\
$ pg_upgrade\n"));
#else
printf(_("\
- C:\\> set OLDDATADIR=oldCluster/data\n\
- C:\\> set NEWDATADIR=newCluster/data\n\
- C:\\> set OLDBINDIR=oldCluster/bin\n\
- C:\\> set NEWBINDIR=newCluster/bin\n\
+ C:\\> set PGDATAOLD=oldCluster/data\n\
+ C:\\> set PGDATANEW=newCluster/data\n\
+ C:\\> set PGBINOLD=oldCluster/bin\n\
+ C:\\> set PGBINNEW=newCluster/bin\n\
C:\\> pg_upgrade\n"));
#endif
printf(_("\nReport bugs to <[email protected]>.\n"));
@@ -276,9 +272,9 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user);
/*
- * validateDirectoryOption()
+ * check_required_directory()
*
- * Validates a directory option.
+ * Checks a directory option.
* dirpath - the directory name supplied on the command line
* envVarName - the name of an environment variable to get if dirpath is NULL
* cmdLineOption - the command line option corresponds to this directory (-o, -O, -n, -N)
@@ -288,7 +284,7 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user);
* user hasn't provided the required directory name.
*/
static void
-validateDirectoryOption(char **dirpath, char *envVarName,
+check_required_directory(char **dirpath, char *envVarName,
char *cmdLineOption, char *description)
{
if (*dirpath == NULL || strlen(*dirpath) == 0)
@@ -314,44 +310,3 @@ validateDirectoryOption(char **dirpath, char *envVarName,
#endif
(*dirpath)[strlen(*dirpath) - 1] = 0;
}
-
-
-static void
-get_pkglibdirs(void)
-{
- /*
- * we do not need to know the libpath in the old cluster, and might not
- * have a working pg_config to ask for it anyway.
- */
- old_cluster.libpath = NULL;
- new_cluster.libpath = get_pkglibdir(new_cluster.bindir);
-}
-
-
-static char *
-get_pkglibdir(const char *bindir)
-{
- char cmd[MAXPGPATH];
- char bufin[MAX_STRING];
- FILE *output;
- int i;
-
- snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", bindir);
-
- if ((output = popen(cmd, "r")) == NULL)
- pg_log(PG_FATAL, "Could not get pkglibdir data: %s\n",
- getErrorText(errno));
-
- fgets(bufin, sizeof(bufin), output);
-
- if (output)
- pclose(output);
-
- /* Remove trailing newline */
- i = strlen(bufin) - 1;
-
- if (bufin[i] == '\n')
- bufin[i] = '\0';
-
- return pg_strdup(bufin);
-}
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index a3a0856309..4729ac39d9 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -15,6 +15,9 @@
#include "libpq-fe.h"
+/* Use port in the private/dynamic port number range */
+#define DEF_PGUPORT 50432
+
/* Allocate for null byte */
#define USER_NAME_SIZE 128
@@ -184,8 +187,8 @@ typedef struct
unsigned short port; /* port number where postmaster is waiting */
uint32 major_version; /* PG_VERSION of cluster */
char major_version_str[64]; /* string PG_VERSION of cluster */
+ uint32 bin_version; /* version returned from pg_ctl */
Oid pg_database_oid; /* OID of pg_database relation */
- char *libpath; /* pathname for cluster's pkglibdir */
char *tablespace_suffix; /* directory specification */
} ClusterInfo;
diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
index a7b7e758ff..eebf1877cf 100644
--- a/contrib/pgcrypto/crypt-blowfish.c
+++ b/contrib/pgcrypto/crypt-blowfish.c
@@ -5,8 +5,8 @@
* and crypt(3) interfaces added, but optimizations specific to password
* cracking removed.
*
- * Written by Solar Designer <[email protected]> in 1998-2001, and placed
- * in the public domain.
+ * Written by Solar Designer <solar at openwall.com> in 1998-2002 and
+ * placed in the public domain.
*
* There's absolutely no warranty.
*
@@ -19,9 +19,9 @@
* of your choice.
*
* This implementation is compatible with OpenBSD bcrypt.c (version 2a)
- * by Niels Provos <[email protected]>, and uses some of his
- * ideas. The password hashing algorithm was designed by David Mazieres
+ * by Niels Provos <provos at citi.umich.edu>, and uses some of his
+ * ideas. The password hashing algorithm was designed by David Mazieres
+ * <dm at lcs.mit.edu>.
*
* There's a paper on the algorithm that explains its design decisions:
*
@@ -40,7 +40,7 @@
#ifdef __i386__
#define BF_ASM 0 /* 1 */
#define BF_SCALE 1
-#elif defined(__alpha__)
+#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
#define BF_ASM 0
#define BF_SCALE 1
#else
@@ -49,6 +49,7 @@
#endif
typedef unsigned int BF_word;
+typedef signed int BF_word_signed;
/* Number of Blowfish rounds, this is also hardcoded into a few places */
#define BF_N 16
@@ -544,7 +545,8 @@ extern void _BF_body_r(BF_ctx *ctx);
#endif
static void
-BF_set_key(const char *key, BF_key expanded, BF_key initial)
+BF_set_key(const char *key, BF_key expanded, BF_key initial,
+ int sign_extension_bug)
{
const char *ptr = key;
int i,
@@ -557,7 +559,10 @@ BF_set_key(const char *key, BF_key expanded, BF_key initial)
for (j = 0; j < 4; j++)
{
tmp <<= 8;
- tmp |= *ptr;
+ if (sign_extension_bug)
+ tmp |= (BF_word_signed) (signed char) *ptr;
+ else
+ tmp |= (unsigned char) *ptr;
if (!*ptr)
ptr = key;
@@ -599,10 +604,11 @@ _crypt_blowfish_rn(const char *key, const char *setting,
if (setting[0] != '$' ||
setting[1] != '2' ||
- setting[2] != 'a' ||
+ (setting[2] != 'a' && setting[2] != 'x') ||
setting[3] != '$' ||
setting[4] < '0' || setting[4] > '3' ||
setting[5] < '0' || setting[5] > '9' ||
+ (setting[4] == '3' && setting[5] > '1') ||
setting[6] != '$')
{
return NULL;
@@ -616,7 +622,7 @@ _crypt_blowfish_rn(const char *key, const char *setting,
}
BF_swap(data.binary.salt, 4);
- BF_set_key(key, data.expanded_key, data.ctx.P);
+ BF_set_key(key, data.expanded_key, data.ctx.P, setting[2] == 'x');
memcpy(data.ctx.S, BF_init_state.S, sizeof(data.ctx.S));
diff --git a/contrib/pgcrypto/px-crypt.c b/contrib/pgcrypto/px-crypt.c
index ab12e2a6e7..d2e1682e15 100644
--- a/contrib/pgcrypto/px-crypt.c
+++ b/contrib/pgcrypto/px-crypt.c
@@ -79,6 +79,7 @@ struct px_crypt_algo
static const struct px_crypt_algo
px_crypt_list[] = {
{"$2a$", 4, run_crypt_bf},
+ {"$2x$", 4, run_crypt_bf},
{"$2$", 3, NULL}, /* N/A */
{"$1$", 3, run_crypt_md5},
{"_", 1, run_crypt_des},
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 302bb5c39c..4a49ee342f 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -35,6 +35,7 @@
#include "storage/procarray.h"
#include "utils/acl.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
#include "utils/tqual.h"
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index fd2cc9246b..f0d6341bd1 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -34,6 +34,7 @@
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
extern Datum pgstatindex(PG_FUNCTION_ARGS);
diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c
index 9b38493a33..54bbc4345c 100644
--- a/contrib/spi/autoinc.c
+++ b/contrib/spi/autoinc.c
@@ -8,6 +8,7 @@
#include "commands/trigger.h"
#include "executor/spi.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c
index 18a13344cf..3bc51c7f02 100644
--- a/contrib/spi/insert_username.c
+++ b/contrib/spi/insert_username.c
@@ -13,6 +13,7 @@
#include "executor/spi.h"
#include "miscadmin.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c
index d02560c298..d0bc4078f9 100644
--- a/contrib/spi/moddatetime.c
+++ b/contrib/spi/moddatetime.c
@@ -18,6 +18,7 @@ OH, me, I'm Terry Mackintosh <[email protected]>
#include "catalog/pg_type.h"
#include "executor/spi.h"
#include "commands/trigger.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index 36f9ee421e..ed7e00782b 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -12,6 +12,7 @@
#include "commands/trigger.h"
#include "executor/spi.h"
#include "utils/builtins.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c
index 3d05cc505c..69ec627868 100644
--- a/contrib/spi/timetravel.c
+++ b/contrib/spi/timetravel.c
@@ -17,6 +17,7 @@
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/nabstime.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;