Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9244a6b

Browse files
committed
Merge branch 'PGPRO9_6' into PGPROEE9_6
To incorporate upstream patches
2 parents 05c7c27 + ff5466a commit 9244a6b

File tree

101 files changed

+2378
-1130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2378
-1130
lines changed

COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PostgreSQL Database Management System
22
(formerly known as Postgres, then as Postgres95)
33

4-
Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
4+
Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
55

66
Portions Copyright (c) 1994, The Regents of the University of California
77

configure

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ else
27542754
fi
27552755

27562756

2757-
PGPRO_VERSION="$PACKAGE_VERSION.2"
2757+
PGPRO_VERSION="$PACKAGE_VERSION.3"
27582758
PGPRO_PACKAGE_NAME="PostgresPro"
27592759
PGPRO_EDITION="enterprise"
27602760

@@ -9898,6 +9898,62 @@ done
98989898
fi
98999899

99009900
if test "$with_icu" = yes ; then
9901+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ucol_open_58" >&5
9902+
$as_echo_n "checking for library containing ucol_open_58... " >&6; }
9903+
if ${ac_cv_search_ucol_open_58+:} false; then :
9904+
$as_echo_n "(cached) " >&6
9905+
else
9906+
ac_func_search_save_LIBS=$LIBS
9907+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9908+
/* end confdefs.h. */
9909+
9910+
/* Override any GCC internal prototype to avoid an error.
9911+
Use char because int might match the return type of a GCC
9912+
builtin and then its argument prototype would still apply. */
9913+
#ifdef __cplusplus
9914+
extern "C"
9915+
#endif
9916+
char ucol_open_58 ();
9917+
int
9918+
main ()
9919+
{
9920+
return ucol_open_58 ();
9921+
;
9922+
return 0;
9923+
}
9924+
_ACEOF
9925+
for ac_lib in '' icui18n icuin; do
9926+
if test -z "$ac_lib"; then
9927+
ac_res="none required"
9928+
else
9929+
ac_res=-l$ac_lib
9930+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
9931+
fi
9932+
if ac_fn_c_try_link "$LINENO"; then :
9933+
ac_cv_search_ucol_open_58=$ac_res
9934+
fi
9935+
rm -f core conftest.err conftest.$ac_objext \
9936+
conftest$ac_exeext
9937+
if ${ac_cv_search_ucol_open_58+:} false; then :
9938+
break
9939+
fi
9940+
done
9941+
if ${ac_cv_search_ucol_open_58+:} false; then :
9942+
9943+
else
9944+
ac_cv_search_ucol_open_58=no
9945+
fi
9946+
rm conftest.$ac_ext
9947+
LIBS=$ac_func_search_save_LIBS
9948+
fi
9949+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ucol_open_58" >&5
9950+
$as_echo "$ac_cv_search_ucol_open_58" >&6; }
9951+
ac_res=$ac_cv_search_ucol_open_58
9952+
if test "$ac_res" != no; then :
9953+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
9954+
9955+
else
9956+
99019957
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ucol_open_57" >&5
99029958
$as_echo_n "checking for library containing ucol_open_57... " >&6; }
99039959
if ${ac_cv_search_ucol_open_57+:} false; then :
@@ -10900,6 +10956,54 @@ fi
1090010956

1090110957
fi
1090210958

10959+
10960+
fi
10961+
10962+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucnv_fromUChars_58 in -licuuc" >&5
10963+
$as_echo_n "checking for ucnv_fromUChars_58 in -licuuc... " >&6; }
10964+
if ${ac_cv_lib_icuuc_ucnv_fromUChars_58+:} false; then :
10965+
$as_echo_n "(cached) " >&6
10966+
else
10967+
ac_check_lib_save_LIBS=$LIBS
10968+
LIBS="-licuuc $LIBS"
10969+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10970+
/* end confdefs.h. */
10971+
10972+
/* Override any GCC internal prototype to avoid an error.
10973+
Use char because int might match the return type of a GCC
10974+
builtin and then its argument prototype would still apply. */
10975+
#ifdef __cplusplus
10976+
extern "C"
10977+
#endif
10978+
char ucnv_fromUChars_58 ();
10979+
int
10980+
main ()
10981+
{
10982+
return ucnv_fromUChars_58 ();
10983+
;
10984+
return 0;
10985+
}
10986+
_ACEOF
10987+
if ac_fn_c_try_link "$LINENO"; then :
10988+
ac_cv_lib_icuuc_ucnv_fromUChars_58=yes
10989+
else
10990+
ac_cv_lib_icuuc_ucnv_fromUChars_58=no
10991+
fi
10992+
rm -f core conftest.err conftest.$ac_objext \
10993+
conftest$ac_exeext conftest.$ac_ext
10994+
LIBS=$ac_check_lib_save_LIBS
10995+
fi
10996+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_icuuc_ucnv_fromUChars_58" >&5
10997+
$as_echo "$ac_cv_lib_icuuc_ucnv_fromUChars_58" >&6; }
10998+
if test "x$ac_cv_lib_icuuc_ucnv_fromUChars_58" = xyes; then :
10999+
cat >>confdefs.h <<_ACEOF
11000+
#define HAVE_LIBICUUC 1
11001+
_ACEOF
11002+
11003+
LIBS="-licuuc $LIBS"
11004+
11005+
else
11006+
1090311007
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucnv_fromUChars_57 in -licuuc" >&5
1090411008
$as_echo_n "checking for ucnv_fromUChars_57 in -licuuc... " >&6; }
1090511009
if ${ac_cv_lib_icuuc_ucnv_fromUChars_57+:} false; then :
@@ -11713,6 +11817,9 @@ fi
1171311817
fi
1171411818

1171511819

11820+
fi
11821+
11822+
1171611823
fi
1171711824

1171811825
fi

configure.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major versio
3838
PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
3939
[PG_VERSION="$PACKAGE_VERSION$withval"],
4040
[PG_VERSION="$PACKAGE_VERSION"])
41-
PGPRO_VERSION="$PACKAGE_VERSION.2"
41+
PGPRO_VERSION="$PACKAGE_VERSION.3"
4242
PGPRO_PACKAGE_NAME="PostgresPro"
4343
PGPRO_EDITION="enterprise"
4444
AC_SUBST(PGPRO_PACKAGE_NAME)
@@ -1162,6 +1162,7 @@ if test "$with_openssl" = yes ; then
11621162
fi
11631163

11641164
if test "$with_icu" = yes ; then
1165+
AC_SEARCH_LIBS(ucol_open_58, [icui18n icuin], [], [
11651166
AC_SEARCH_LIBS(ucol_open_57, [icui18n icuin], [], [
11661167
AC_SEARCH_LIBS(ucol_open_56, [icui18n icuin], [], [
11671168
AC_SEARCH_LIBS(ucol_open_55, [icui18n icuin], [], [
@@ -1195,6 +1196,8 @@ if test "$with_icu" = yes ; then
11951196
])
11961197
])
11971198
])
1199+
])
1200+
AC_CHECK_LIB(icuuc, ucnv_fromUChars_58, [], [
11981201
AC_CHECK_LIB(icuuc, ucnv_fromUChars_57, [], [
11991202
AC_CHECK_LIB(icuuc, ucnv_fromUChars_56, [], [
12001203
AC_CHECK_LIB(icuuc, ucnv_fromUChars_55, [], [
@@ -1228,6 +1231,7 @@ if test "$with_icu" = yes ; then
12281231
])
12291232
])
12301233
])
1234+
])
12311235
fi
12321236

12331237
if test "$with_pam" = yes ; then

contrib/dblink/dblink.c

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "access/reloptions.h"
4141
#include "catalog/indexing.h"
4242
#include "catalog/namespace.h"
43+
#include "catalog/pg_foreign_data_wrapper.h"
4344
#include "catalog/pg_foreign_server.h"
4445
#include "catalog/pg_type.h"
4546
#include "catalog/pg_user_mapping.h"
@@ -112,7 +113,8 @@ static Relation get_rel_from_relname(text *relname_text, LOCKMODE lockmode, AclM
112113
static char *generate_relation_name(Relation rel);
113114
static void dblink_connstr_check(const char *connstr);
114115
static void dblink_security_check(PGconn *conn, remoteConn *rconn);
115-
static void dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_msg, bool fail);
116+
static void dblink_res_error(PGconn *conn, const char *conname, PGresult *res,
117+
const char *dblink_context_msg, bool fail);
116118
static char *get_connect_string(const char *servername);
117119
static char *escape_param_str(const char *from);
118120
static void validate_pkattnums(Relation rel,
@@ -427,7 +429,7 @@ dblink_open(PG_FUNCTION_ARGS)
427429
res = PQexec(conn, buf.data);
428430
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
429431
{
430-
dblink_res_error(conname, res, "could not open cursor", fail);
432+
dblink_res_error(conn, conname, res, "could not open cursor", fail);
431433
PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
432434
}
433435

@@ -496,7 +498,7 @@ dblink_close(PG_FUNCTION_ARGS)
496498
res = PQexec(conn, buf.data);
497499
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
498500
{
499-
dblink_res_error(conname, res, "could not close cursor", fail);
501+
dblink_res_error(conn, conname, res, "could not close cursor", fail);
500502
PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
501503
}
502504

@@ -599,7 +601,8 @@ dblink_fetch(PG_FUNCTION_ARGS)
599601
(PQresultStatus(res) != PGRES_COMMAND_OK &&
600602
PQresultStatus(res) != PGRES_TUPLES_OK))
601603
{
602-
dblink_res_error(conname, res, "could not fetch from cursor", fail);
604+
dblink_res_error(conn, conname, res,
605+
"could not fetch from cursor", fail);
603606
return (Datum) 0;
604607
}
605608
else if (PQresultStatus(res) == PGRES_COMMAND_OK)
@@ -750,8 +753,8 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
750753
if (PQresultStatus(res) != PGRES_COMMAND_OK &&
751754
PQresultStatus(res) != PGRES_TUPLES_OK)
752755
{
753-
dblink_res_error(conname, res, "could not execute query",
754-
fail);
756+
dblink_res_error(conn, conname, res,
757+
"could not execute query", fail);
755758
/* if fail isn't set, we'll return an empty query result */
756759
}
757760
else
@@ -996,7 +999,8 @@ materializeQueryResult(FunctionCallInfo fcinfo,
996999
PGresult *res1 = res;
9971000

9981001
res = NULL;
999-
dblink_res_error(conname, res1, "could not execute query", fail);
1002+
dblink_res_error(conn, conname, res1,
1003+
"could not execute query", fail);
10001004
/* if fail isn't set, we'll return an empty query result */
10011005
}
10021006
else if (PQresultStatus(res) == PGRES_COMMAND_OK)
@@ -1431,7 +1435,8 @@ dblink_exec(PG_FUNCTION_ARGS)
14311435
(PQresultStatus(res) != PGRES_COMMAND_OK &&
14321436
PQresultStatus(res) != PGRES_TUPLES_OK))
14331437
{
1434-
dblink_res_error(conname, res, "could not execute command", fail);
1438+
dblink_res_error(conn, conname, res,
1439+
"could not execute command", fail);
14351440

14361441
/*
14371442
* and save a copy of the command status string to return as our
@@ -2662,7 +2667,8 @@ dblink_connstr_check(const char *connstr)
26622667
}
26632668

26642669
static void
2665-
dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_msg, bool fail)
2670+
dblink_res_error(PGconn *conn, const char *conname, PGresult *res,
2671+
const char *dblink_context_msg, bool fail)
26662672
{
26672673
int level;
26682674
char *pg_diag_sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
@@ -2696,6 +2702,14 @@ dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_
26962702
xpstrdup(message_hint, pg_diag_message_hint);
26972703
xpstrdup(message_context, pg_diag_context);
26982704

2705+
/*
2706+
* If we don't get a message from the PGresult, try the PGconn. This
2707+
* is needed because for connection-level failures, PQexec may just
2708+
* return NULL, not a PGresult at all.
2709+
*/
2710+
if (message_primary == NULL)
2711+
message_primary = PQerrorMessage(conn);
2712+
26992713
if (res)
27002714
PQclear(res);
27012715

@@ -2705,7 +2719,7 @@ dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_
27052719
ereport(level,
27062720
(errcode(sqlstate),
27072721
message_primary ? errmsg_internal("%s", message_primary) :
2708-
errmsg("unknown error"),
2722+
errmsg("could not obtain message string for remote error"),
27092723
message_detail ? errdetail_internal("%s", message_detail) : 0,
27102724
message_hint ? errhint("%s", message_hint) : 0,
27112725
message_context ? errcontext("%s", message_context) : 0,
@@ -2727,6 +2741,25 @@ get_connect_string(const char *servername)
27272741
AclResult aclresult;
27282742
char *srvname;
27292743

2744+
static const PQconninfoOption *options = NULL;
2745+
2746+
/*
2747+
* Get list of valid libpq options.
2748+
*
2749+
* To avoid unnecessary work, we get the list once and use it throughout
2750+
* the lifetime of this backend process. We don't need to care about
2751+
* memory context issues, because PQconndefaults allocates with malloc.
2752+
*/
2753+
if (!options)
2754+
{
2755+
options = PQconndefaults();
2756+
if (!options) /* assume reason for failure is OOM */
2757+
ereport(ERROR,
2758+
(errcode(ERRCODE_FDW_OUT_OF_MEMORY),
2759+
errmsg("out of memory"),
2760+
errdetail("could not get libpq's default connection options")));
2761+
}
2762+
27302763
/* first gather the server connstr options */
27312764
srvname = pstrdup(servername);
27322765
truncate_identifier(srvname, strlen(srvname), false);
@@ -2750,25 +2783,28 @@ get_connect_string(const char *servername)
27502783
{
27512784
DefElem *def = lfirst(cell);
27522785

2753-
appendStringInfo(buf, "%s='%s' ", def->defname,
2754-
escape_param_str(strVal(def->arg)));
2786+
if (is_valid_dblink_option(options, def->defname, ForeignDataWrapperRelationId))
2787+
appendStringInfo(buf, "%s='%s' ", def->defname,
2788+
escape_param_str(strVal(def->arg)));
27552789
}
27562790

27572791
foreach(cell, foreign_server->options)
27582792
{
27592793
DefElem *def = lfirst(cell);
27602794

2761-
appendStringInfo(buf, "%s='%s' ", def->defname,
2762-
escape_param_str(strVal(def->arg)));
2795+
if (is_valid_dblink_option(options, def->defname, ForeignServerRelationId))
2796+
appendStringInfo(buf, "%s='%s' ", def->defname,
2797+
escape_param_str(strVal(def->arg)));
27632798
}
27642799

27652800
foreach(cell, user_mapping->options)
27662801
{
27672802

27682803
DefElem *def = lfirst(cell);
27692804

2770-
appendStringInfo(buf, "%s='%s' ", def->defname,
2771-
escape_param_str(strVal(def->arg)));
2805+
if (is_valid_dblink_option(options, def->defname, UserMappingRelationId))
2806+
appendStringInfo(buf, "%s='%s' ", def->defname,
2807+
escape_param_str(strVal(def->arg)));
27722808
}
27732809

27742810
return buf->data;

contrib/postgres_fdw/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pgfdw_report_error(int elevel, PGresult *res, PGconn *conn,
567567
ereport(elevel,
568568
(errcode(sqlstate),
569569
message_primary ? errmsg_internal("%s", message_primary) :
570-
errmsg("unknown error"),
570+
errmsg("could not obtain message string for remote error"),
571571
message_detail ? errdetail_internal("%s", message_detail) : 0,
572572
message_hint ? errhint("%s", message_hint) : 0,
573573
message_context ? errcontext("%s", message_context) : 0,

0 commit comments

Comments
 (0)