Skip to content

Commit 6ba9acc

Browse files
committed
Merge branch 'master' into fast2pc
2 parents 367399b + 9449c4b commit 6ba9acc

File tree

233 files changed

+13987
-5344
lines changed

Some content is hidden

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

233 files changed

+13987
-5344
lines changed

configure

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ with_libxml
709709
XML2_CONFIG
710710
UUID_EXTRA_OBJS
711711
with_uuid
712+
with_systemd
712713
with_selinux
713714
with_openssl
714715
krb_srvtab
@@ -830,6 +831,7 @@ with_ldap
830831
with_bonjour
831832
with_openssl
832833
with_selinux
834+
with_systemd
833835
with_readline
834836
with_libedit_preferred
835837
with_uuid
@@ -1518,6 +1520,7 @@ Optional Packages:
15181520
--with-bonjour build with Bonjour support
15191521
--with-openssl build with OpenSSL support
15201522
--with-selinux build with SELinux support
1523+
--with-systemd build with systemd support
15211524
--without-readline do not use GNU Readline nor BSD Libedit for editing
15221525
--with-libedit-preferred
15231526
prefer BSD Libedit over GNU Readline
@@ -5694,6 +5697,41 @@ fi
56945697
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_selinux" >&5
56955698
$as_echo "$with_selinux" >&6; }
56965699

5700+
#
5701+
# Systemd
5702+
#
5703+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with systemd support" >&5
5704+
$as_echo_n "checking whether to build with systemd support... " >&6; }
5705+
5706+
5707+
5708+
# Check whether --with-systemd was given.
5709+
if test "${with_systemd+set}" = set; then :
5710+
withval=$with_systemd;
5711+
case $withval in
5712+
yes)
5713+
5714+
$as_echo "#define USE_SYSTEMD 1" >>confdefs.h
5715+
5716+
;;
5717+
no)
5718+
:
5719+
;;
5720+
*)
5721+
as_fn_error $? "no argument expected for --with-systemd option" "$LINENO" 5
5722+
;;
5723+
esac
5724+
5725+
else
5726+
with_systemd=no
5727+
5728+
fi
5729+
5730+
5731+
5732+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_systemd" >&5
5733+
$as_echo "$with_systemd" >&6; }
5734+
56975735
#
56985736
# Readline
56995737
#
@@ -10473,6 +10511,17 @@ fi
1047310511

1047410512
done
1047510513

10514+
fi
10515+
10516+
if test "$with_systemd" = yes ; then
10517+
ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default"
10518+
if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes; then :
10519+
10520+
else
10521+
as_fn_error $? "header file <systemd/sd-daemon.h> is required for systemd support" "$LINENO" 5
10522+
fi
10523+
10524+
1047610525
fi
1047710526

1047810527
if test "$with_libxml" = yes ; then

configure.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,15 @@ PGAC_ARG_BOOL(with, selinux, no, [build with SELinux support])
699699
AC_SUBST(with_selinux)
700700
AC_MSG_RESULT([$with_selinux])
701701

702+
#
703+
# Systemd
704+
#
705+
AC_MSG_CHECKING([whether to build with systemd support])
706+
PGAC_ARG_BOOL(with, systemd, no, [build with systemd support],
707+
[AC_DEFINE([USE_SYSTEMD], 1, [Define to build with systemd support. (--with-systemd)])])
708+
AC_SUBST(with_systemd)
709+
AC_MSG_RESULT([$with_systemd])
710+
702711
#
703712
# Readline
704713
#
@@ -1249,6 +1258,10 @@ if test "$with_pam" = yes ; then
12491258
[AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
12501259
fi
12511260

1261+
if test "$with_systemd" = yes ; then
1262+
AC_CHECK_HEADER(systemd/sd-daemon.h, [], [AC_MSG_ERROR([header file <systemd/sd-daemon.h> is required for systemd support])])
1263+
fi
1264+
12521265
if test "$with_libxml" = yes ; then
12531266
AC_CHECK_HEADER(libxml/parser.h, [], [AC_MSG_ERROR([header file <libxml/parser.h> is required for XML support])])
12541267
fi

contrib/fuzzystrmatch/fuzzystrmatch.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ levenshtein_with_costs(PG_FUNCTION_ARGS)
171171
/* Extract a pointer to the actual character data */
172172
s_data = VARDATA_ANY(src);
173173
t_data = VARDATA_ANY(dst);
174-
/* Determine length of each string in bytes and characters */
174+
/* Determine length of each string in bytes */
175175
s_bytes = VARSIZE_ANY_EXHDR(src);
176176
t_bytes = VARSIZE_ANY_EXHDR(dst);
177177

178-
PG_RETURN_INT32(varstr_levenshtein(s_data, s_bytes, t_data, t_bytes, ins_c,
179-
del_c, sub_c));
178+
PG_RETURN_INT32(varstr_levenshtein(s_data, s_bytes, t_data, t_bytes,
179+
ins_c, del_c, sub_c, false));
180180
}
181181

182182

@@ -194,12 +194,12 @@ levenshtein(PG_FUNCTION_ARGS)
194194
/* Extract a pointer to the actual character data */
195195
s_data = VARDATA_ANY(src);
196196
t_data = VARDATA_ANY(dst);
197-
/* Determine length of each string in bytes and characters */
197+
/* Determine length of each string in bytes */
198198
s_bytes = VARSIZE_ANY_EXHDR(src);
199199
t_bytes = VARSIZE_ANY_EXHDR(dst);
200200

201-
PG_RETURN_INT32(varstr_levenshtein(s_data, s_bytes, t_data, t_bytes, 1, 1,
202-
1));
201+
PG_RETURN_INT32(varstr_levenshtein(s_data, s_bytes, t_data, t_bytes,
202+
1, 1, 1, false));
203203
}
204204

205205

@@ -221,13 +221,14 @@ levenshtein_less_equal_with_costs(PG_FUNCTION_ARGS)
221221
/* Extract a pointer to the actual character data */
222222
s_data = VARDATA_ANY(src);
223223
t_data = VARDATA_ANY(dst);
224-
/* Determine length of each string in bytes and characters */
224+
/* Determine length of each string in bytes */
225225
s_bytes = VARSIZE_ANY_EXHDR(src);
226226
t_bytes = VARSIZE_ANY_EXHDR(dst);
227227

228-
PG_RETURN_INT32(varstr_levenshtein_less_equal(s_data, s_bytes, t_data,
229-
t_bytes, ins_c, del_c,
230-
sub_c, max_d));
228+
PG_RETURN_INT32(varstr_levenshtein_less_equal(s_data, s_bytes,
229+
t_data, t_bytes,
230+
ins_c, del_c, sub_c,
231+
max_d, false));
231232
}
232233

233234

@@ -246,12 +247,14 @@ levenshtein_less_equal(PG_FUNCTION_ARGS)
246247
/* Extract a pointer to the actual character data */
247248
s_data = VARDATA_ANY(src);
248249
t_data = VARDATA_ANY(dst);
249-
/* Determine length of each string in bytes and characters */
250+
/* Determine length of each string in bytes */
250251
s_bytes = VARSIZE_ANY_EXHDR(src);
251252
t_bytes = VARSIZE_ANY_EXHDR(dst);
252253

253-
PG_RETURN_INT32(varstr_levenshtein_less_equal(s_data, s_bytes, t_data,
254-
t_bytes, 1, 1, 1, max_d));
254+
PG_RETURN_INT32(varstr_levenshtein_less_equal(s_data, s_bytes,
255+
t_data, t_bytes,
256+
1, 1, 1,
257+
max_d, false));
255258
}
256259

257260

contrib/hstore/expected/hstore.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,10 +1466,10 @@ select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=
14661466
{"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
14671467
(1 row)
14681468

1469-
select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
1470-
hstore_to_json_loose
1471-
------------------------------------------------------------------------------------------
1472-
{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "a key": 1}
1469+
select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
1470+
hstore_to_json_loose
1471+
-------------------------------------------------------------------------------------------------------------
1472+
{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "h": "2016-01-01", "a key": 1}
14731473
(1 row)
14741474

14751475
select hstore_to_jsonb('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
@@ -1484,10 +1484,10 @@ select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=
14841484
{"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
14851485
(1 row)
14861486

1487-
select hstore_to_jsonb_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
1488-
hstore_to_jsonb_loose
1489-
---------------------------------------------------------------------------------------
1490-
{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 23450, "a key": 1}
1487+
select hstore_to_jsonb_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
1488+
hstore_to_jsonb_loose
1489+
----------------------------------------------------------------------------------------------------------
1490+
{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 23450, "h": "2016-01-01", "a key": 1}
14911491
(1 row)
14921492

14931493
create table test_json_agg (f1 text, f2 hstore);

contrib/hstore/hstore_io.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,6 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
13871387
JsonbParseState *state = NULL;
13881388
JsonbValue *res;
13891389
StringInfoData tmp;
1390-
bool is_number;
13911390

13921391
initStringInfo(&tmp);
13931392

@@ -1423,50 +1422,10 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
14231422
}
14241423
else
14251424
{
1426-
is_number = false;
14271425
resetStringInfo(&tmp);
1428-
14291426
appendBinaryStringInfo(&tmp, HSTORE_VAL(entries, base, i),
14301427
HSTORE_VALLEN(entries, i));
1431-
1432-
/*
1433-
* don't treat something with a leading zero followed by another
1434-
* digit as numeric - could be a zip code or similar
1435-
*/
1436-
if (tmp.len > 0 &&
1437-
!(tmp.data[0] == '0' &&
1438-
isdigit((unsigned char) tmp.data[1])) &&
1439-
strspn(tmp.data, "+-0123456789Ee.") == tmp.len)
1440-
{
1441-
/*
1442-
* might be a number. See if we can input it as a numeric
1443-
* value. Ignore any actual parsed value.
1444-
*/
1445-
char *endptr = "junk";
1446-
long lval;
1447-
1448-
lval = strtol(tmp.data, &endptr, 10);
1449-
(void) lval;
1450-
if (*endptr == '\0')
1451-
{
1452-
/*
1453-
* strol man page says this means the whole string is
1454-
* valid
1455-
*/
1456-
is_number = true;
1457-
}
1458-
else
1459-
{
1460-
/* not an int - try a double */
1461-
double dval;
1462-
1463-
dval = strtod(tmp.data, &endptr);
1464-
(void) dval;
1465-
if (*endptr == '\0')
1466-
is_number = true;
1467-
}
1468-
}
1469-
if (is_number)
1428+
if (IsValidJsonNumber(tmp.data, tmp.len))
14701429
{
14711430
val.type = jbvNumeric;
14721431
val.val.numeric = DatumGetNumeric(

contrib/hstore/sql/hstore.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ select count(*) from testhstore where h = 'pos=>98, line=>371, node=>CBA, indexe
334334
-- json and jsonb
335335
select hstore_to_json('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
336336
select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as json);
337-
select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
337+
select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
338338

339339
select hstore_to_jsonb('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
340340
select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as jsonb);
341-
select hstore_to_jsonb_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
341+
select hstore_to_jsonb_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
342342

343343
create table test_json_agg (f1 text, f2 hstore);
344344
insert into test_json_agg values ('rec1','"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4'),

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ _PG_init(void)
404404
* resources in pgss_shmem_startup().
405405
*/
406406
RequestAddinShmemSpace(pgss_memsize());
407-
RequestAddinLWLocks(1);
407+
RequestNamedLWLockTranche("pg_stat_statements", 1);
408408

409409
/*
410410
* Install hooks.
@@ -480,7 +480,7 @@ pgss_shmem_startup(void)
480480
if (!found)
481481
{
482482
/* First time through ... */
483-
pgss->lock = LWLockAssign();
483+
pgss->lock = &(GetNamedLWLockTranche("pg_stat_statements"))->lock;
484484
pgss->cur_median_usage = ASSUMED_MEDIAN_INIT;
485485
pgss->mean_query_len = ASSUMED_LENGTH_INIT;
486486
SpinLockInit(&pgss->mutex);

contrib/pgcrypto/fortuna.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ get_rand_pool(FState *st)
304304
unsigned rnd;
305305

306306
/*
307-
* This slightly prefers lower pools - thats OK.
307+
* This slightly prefers lower pools - that is OK.
308308
*/
309309
rnd = st->key[st->rnd_pos] % NUM_POOLS;
310310

contrib/postgres_fdw/connection.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
/*
2525
* Connection cache hash table entry
2626
*
27-
* The lookup key in this hash table is the foreign server OID plus the user
28-
* mapping OID. (We use just one connection per user per foreign server,
29-
* so that we can ensure all scans use the same snapshot during a query.)
27+
* The lookup key in this hash table is the user mapping OID. We use just one
28+
* connection per user mapping ID, which ensures that all the scans use the
29+
* same snapshot during a query. Using the user mapping OID rather than
30+
* the foreign server OID + user OID avoids creating multiple connections when
31+
* the public user mapping applies to all user OIDs.
3032
*
3133
* The "conn" pointer can be NULL if we don't currently have a live connection.
3234
* When we do have a connection, xact_depth tracks the current depth of
@@ -35,11 +37,7 @@
3537
* ourselves, so that rolling back a subtransaction will kill the right
3638
* queries and not the wrong ones.
3739
*/
38-
typedef struct ConnCacheKey
39-
{
40-
Oid serverid; /* OID of foreign server */
41-
Oid userid; /* OID of local user whose mapping we use */
42-
} ConnCacheKey;
40+
typedef Oid ConnCacheKey;
4341

4442
typedef struct ConnCacheEntry
4543
{
@@ -94,8 +92,7 @@ static void pgfdw_subxact_callback(SubXactEvent event,
9492
* mid-transaction anyway.
9593
*/
9694
PGconn *
97-
GetConnection(ForeignServer *server, UserMapping *user,
98-
bool will_prep_stmt)
95+
GetConnection(UserMapping *user, bool will_prep_stmt)
9996
{
10097
bool found;
10198
ConnCacheEntry *entry;
@@ -127,8 +124,7 @@ GetConnection(ForeignServer *server, UserMapping *user,
127124
xact_got_connection = true;
128125

129126
/* Create hash key for the entry. Assume no pad bytes in key struct */
130-
key.serverid = server->serverid;
131-
key.userid = user->userid;
127+
key = user->umid;
132128

133129
/*
134130
* Find or create cached entry for requested connection.
@@ -156,12 +152,15 @@ GetConnection(ForeignServer *server, UserMapping *user,
156152
*/
157153
if (entry->conn == NULL)
158154
{
155+
ForeignServer *server = GetForeignServer(user->serverid);
156+
159157
entry->xact_depth = 0; /* just to be sure */
160158
entry->have_prep_stmt = false;
161159
entry->have_error = false;
162160
entry->conn = connect_pg_server(server, user);
163-
elog(DEBUG3, "new postgres_fdw connection %p for server \"%s\"",
164-
entry->conn, server->servername);
161+
162+
elog(DEBUG3, "new postgres_fdw connection %p for server \"%s\" (user mapping oid %u, userid %u)",
163+
entry->conn, server->servername, user->umid, user->userid);
165164
}
166165

167166
/*

0 commit comments

Comments
 (0)