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

Commit 458a977

Browse files
committed
Merge branch 'REL_10_STABLE' into PGPRO10
2 parents bb9b0ed + b8279a7 commit 458a977

File tree

180 files changed

+7256
-17719
lines changed

Some content is hidden

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

180 files changed

+7256
-17719
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-2017, PostgreSQL Global Development Group
4+
Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
55

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

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# GNUmakefile won't exist yet, so we catch that case as well.
1212

1313

14+
# AIX make defaults to building *every* target of the first rule. Start with
15+
# a single-target, empty rule to make the other targets non-default.
16+
all:
17+
1418
all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
1519
@if [ ! -f GNUmakefile ] ; then \
1620
echo "You need to run the 'configure' program first. See the file"; \

config/c-compiler.m4

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ undefine([Ac_cachevar])dnl
9696
# PGAC_TYPE_128BIT_INT
9797
# ---------------------
9898
# Check if __int128 is a working 128 bit integer type, and if so
99-
# define PG_INT128_TYPE to that typename. This currently only detects
100-
# a GCC/clang extension, but support for different environments may be
101-
# added in the future.
99+
# define PG_INT128_TYPE to that typename, and define ALIGNOF_PG_INT128_TYPE
100+
# as its alignment requirement.
101+
#
102+
# This currently only detects a GCC/clang extension, but support for other
103+
# environments may be added in the future.
102104
#
103105
# For the moment we only test for support for 128bit math; support for
104106
# 128bit literals and snprintf is not required.
@@ -128,6 +130,7 @@ return 1;
128130
[pgac_cv__128bit_int=no])])
129131
if test x"$pgac_cv__128bit_int" = xyes ; then
130132
AC_DEFINE(PG_INT128_TYPE, __int128, [Define to the name of a signed 128-bit integer type.])
133+
AC_CHECK_ALIGNOF(PG_INT128_TYPE)
131134
fi])# PGAC_TYPE_128BIT_INT
132135

133136

config/perl.m4

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,19 @@ AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
8787
[AC_REQUIRE([PGAC_PATH_PERL])
8888
AC_MSG_CHECKING(for flags to link embedded Perl)
8989
if test "$PORTNAME" = "win32" ; then
90-
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
91-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
90+
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
91+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
92+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
93+
else
94+
perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
95+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
96+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
97+
fi
98+
fi
9299
else
93-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
94-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
95-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
100+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
101+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
102+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
96103
fi
97104
AC_SUBST(perl_embed_ldflags)dnl
98105
if test -z "$perl_embed_ldflags" ; then

configure

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7987,12 +7987,19 @@ $as_echo "$perl_embed_ccflags" >&6; }
79877987
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
79887988
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
79897989
if test "$PORTNAME" = "win32" ; then
7990-
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7991-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7990+
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7991+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
7992+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7993+
else
7994+
perl_lib=`basename $perl_archlibexp/CORE/libperl[5-9]*.a .a | sed 's/^lib//'`
7995+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
7996+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7997+
fi
7998+
fi
79927999
else
7993-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
7994-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
7995-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
8000+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
8001+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
8002+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
79968003
fi
79978004
if test -z "$perl_embed_ldflags" ; then
79988005
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -14919,7 +14926,10 @@ _ACEOF
1491914926

1492014927
# Compute maximum alignment of any basic type.
1492114928
# We assume long's alignment is at least as strong as char, short, or int;
14922-
# but we must check long long (if it exists) and double.
14929+
# but we must check long long (if it is being used for int64) and double.
14930+
# Note that we intentionally do not consider any types wider than 64 bits,
14931+
# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
14932+
# for disk and memory space.
1492314933

1492414934
MAX_ALIGNOF=$ac_cv_alignof_long
1492514935
if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
@@ -14979,7 +14989,7 @@ _ACEOF
1497914989
fi
1498014990

1498114991

14982-
# Check for extensions offering the integer scalar type __int128.
14992+
# Some compilers offer a 128-bit integer scalar type.
1498314993
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __int128" >&5
1498414994
$as_echo_n "checking for __int128... " >&6; }
1498514995
if ${pgac_cv__128bit_int+:} false; then :
@@ -15029,6 +15039,41 @@ if test x"$pgac_cv__128bit_int" = xyes ; then
1502915039

1503015040
$as_echo "#define PG_INT128_TYPE __int128" >>confdefs.h
1503115041

15042+
# The cast to long int works around a bug in the HP C Compiler,
15043+
# see AC_CHECK_SIZEOF for more information.
15044+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of PG_INT128_TYPE" >&5
15045+
$as_echo_n "checking alignment of PG_INT128_TYPE... " >&6; }
15046+
if ${ac_cv_alignof_PG_INT128_TYPE+:} false; then :
15047+
$as_echo_n "(cached) " >&6
15048+
else
15049+
if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_PG_INT128_TYPE" "$ac_includes_default
15050+
#ifndef offsetof
15051+
# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
15052+
#endif
15053+
typedef struct { char x; PG_INT128_TYPE y; } ac__type_alignof_;"; then :
15054+
15055+
else
15056+
if test "$ac_cv_type_PG_INT128_TYPE" = yes; then
15057+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
15058+
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
15059+
as_fn_error 77 "cannot compute alignment of PG_INT128_TYPE
15060+
See \`config.log' for more details" "$LINENO" 5; }
15061+
else
15062+
ac_cv_alignof_PG_INT128_TYPE=0
15063+
fi
15064+
fi
15065+
15066+
fi
15067+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_PG_INT128_TYPE" >&5
15068+
$as_echo "$ac_cv_alignof_PG_INT128_TYPE" >&6; }
15069+
15070+
15071+
15072+
cat >>confdefs.h <<_ACEOF
15073+
#define ALIGNOF_PG_INT128_TYPE $ac_cv_alignof_PG_INT128_TYPE
15074+
_ACEOF
15075+
15076+
1503215077
fi
1503315078

1503415079
# Check for various atomic operations now that we have checked how to declare

configure.in

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ if test "$with_openssl" = yes ; then
11071107
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
11081108
AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
11091109
else
1110-
AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
1111-
AC_SEARCH_LIBS(SSL_new, ssleay32 ssl, [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
1110+
AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
1111+
AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
11121112
fi
11131113
AC_CHECK_FUNCS([SSL_get_current_compression])
11141114
# Functions introduced in OpenSSL 1.1.0. We used to check for
@@ -1308,6 +1308,12 @@ fi
13081308

13091309
if test "$with_bonjour" = yes ; then
13101310
AC_CHECK_HEADER(dns_sd.h, [], [AC_MSG_ERROR([header file <dns_sd.h> is required for Bonjour])])
1311+
dnl At some point we might add something like
1312+
dnl AC_SEARCH_LIBS(DNSServiceRegister, dns_sd)
1313+
dnl but right now, what that would mainly accomplish is to encourage
1314+
dnl people to try to use the avahi implementation, which does not work.
1315+
dnl If you want to use Apple's own Bonjour code on another platform,
1316+
dnl just add -ldns_sd to LIBS manually.
13111317
fi
13121318

13131319
# for contrib/uuid-ossp
@@ -1841,7 +1847,10 @@ AC_CHECK_ALIGNOF(double)
18411847

18421848
# Compute maximum alignment of any basic type.
18431849
# We assume long's alignment is at least as strong as char, short, or int;
1844-
# but we must check long long (if it exists) and double.
1850+
# but we must check long long (if it is being used for int64) and double.
1851+
# Note that we intentionally do not consider any types wider than 64 bits,
1852+
# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
1853+
# for disk and memory space.
18451854

18461855
MAX_ALIGNOF=$ac_cv_alignof_long
18471856
if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
@@ -1858,7 +1867,7 @@ AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignme
18581867
AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
18591868
[#include <stdio.h>])
18601869

1861-
# Check for extensions offering the integer scalar type __int128.
1870+
# Some compilers offer a 128-bit integer scalar type.
18621871
PGAC_TYPE_128BIT_INT
18631872

18641873
# Check for various atomic operations now that we have checked how to declare

contrib/bloom/t/001_wal.pl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ sub test_index_replay
3232
);
3333

3434
# Run test queries and compare their result
35-
my $master_result = $node_master->psql("postgres", $queries);
36-
my $standby_result = $node_standby->psql("postgres", $queries);
35+
my $master_result = $node_master->safe_psql("postgres", $queries);
36+
my $standby_result = $node_standby->safe_psql("postgres", $queries);
3737

3838
is($master_result, $standby_result, "$test_name: query result matches");
3939
}
@@ -54,12 +54,12 @@ sub test_index_replay
5454
$node_standby->start;
5555

5656
# Create some bloom index on master
57-
$node_master->psql("postgres", "CREATE EXTENSION bloom;");
58-
$node_master->psql("postgres", "CREATE TABLE tst (i int4, t text);");
59-
$node_master->psql("postgres",
57+
$node_master->safe_psql("postgres", "CREATE EXTENSION bloom;");
58+
$node_master->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
59+
$node_master->safe_psql("postgres",
6060
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;"
6161
);
62-
$node_master->psql("postgres",
62+
$node_master->safe_psql("postgres",
6363
"CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
6464

6565
# Test that queries give same result
@@ -68,12 +68,12 @@ sub test_index_replay
6868
# Run 10 cycles of table modification. Run test queries after each modification.
6969
for my $i (1 .. 10)
7070
{
71-
$node_master->psql("postgres", "DELETE FROM tst WHERE i = $i;");
71+
$node_master->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
7272
test_index_replay("delete $i");
73-
$node_master->psql("postgres", "VACUUM tst;");
73+
$node_master->safe_psql("postgres", "VACUUM tst;");
7474
test_index_replay("vacuum $i");
7575
my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
76-
$node_master->psql("postgres",
76+
$node_master->safe_psql("postgres",
7777
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series($start,$end) i;"
7878
);
7979
test_index_replay("insert $i");

contrib/cube/cube.c

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,15 +1336,55 @@ g_cube_distance(PG_FUNCTION_ARGS)
13361336

13371337
if (strategy == CubeKNNDistanceCoord)
13381338
{
1339+
/*
1340+
* Handle ordering by ~> operator. See comments of cube_coord_llur()
1341+
* for details
1342+
*/
13391343
int coord = PG_GETARG_INT32(1);
1344+
bool isLeaf = GistPageIsLeaf(entry->page);
13401345

1341-
if (DIM(cube) == 0)
1342-
retval = 0.0;
1343-
else if (IS_POINT(cube))
1344-
retval = cube->x[(coord - 1) % DIM(cube)];
1346+
/* 0 is the only unsupported coordinate value */
1347+
if (coord <= 0)
1348+
ereport(ERROR,
1349+
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1350+
errmsg("cube index %d is out of bounds", coord)));
1351+
1352+
if (coord <= 2 * DIM(cube))
1353+
{
1354+
/* dimension index */
1355+
int index = (coord - 1) / 2;
1356+
/* whether this is upper bound (lower bound otherwise) */
1357+
bool upper = ((coord - 1) % 2 == 1);
1358+
1359+
if (IS_POINT(cube))
1360+
{
1361+
retval = cube->x[index];
1362+
}
1363+
else
1364+
{
1365+
if (isLeaf)
1366+
{
1367+
/* For leaf just return required upper/lower bound */
1368+
if (upper)
1369+
retval = Max(cube->x[index], cube->x[index + DIM(cube)]);
1370+
else
1371+
retval = Min(cube->x[index], cube->x[index + DIM(cube)]);
1372+
}
1373+
else
1374+
{
1375+
/*
1376+
* For non-leaf we should always return lower bound,
1377+
* because even upper bound of a child in the subtree can
1378+
* be as small as our lower bound.
1379+
*/
1380+
retval = Min(cube->x[index], cube->x[index + DIM(cube)]);
1381+
}
1382+
}
1383+
}
13451384
else
1346-
retval = Min(cube->x[(coord - 1) % DIM(cube)],
1347-
cube->x[(coord - 1) % DIM(cube) + DIM(cube)]);
1385+
{
1386+
retval = 0.0;
1387+
}
13481388
}
13491389
else
13501390
{
@@ -1491,43 +1531,73 @@ cube_coord(PG_FUNCTION_ARGS)
14911531
}
14921532

14931533

1494-
/*
1495-
* This function works like cube_coord(),
1496-
* but rearranges coordinates of corners to get cube representation
1497-
* in the form of (lower left, upper right).
1498-
* For historical reasons that extension allows us to create cubes in form
1499-
* ((2,1),(1,2)) and instead of normalizing such cube to ((1,1),(2,2)) it
1500-
* stores cube in original way. But to get cubes ordered by one of dimensions
1501-
* directly from the index without extra sort step we need some
1502-
* representation-independent coordinate getter. This function implements it.
1534+
/*----
1535+
* This function works like cube_coord(), but rearranges coordinates in the
1536+
* way suitable to support coordinate ordering using KNN-GiST. For historical
1537+
* reasons this extension allows us to create cubes in form ((2,1),(1,2)) and
1538+
* instead of normalizing such cube to ((1,1),(2,2)) it stores cube in original
1539+
* way. But in order to get cubes ordered by one of dimensions from the index
1540+
* without explicit sort step we need this representation-independent coordinate
1541+
* getter. Moreover, indexed dataset may contain cubes of different dimensions
1542+
* number. Accordingly, this coordinate getter should be able to return
1543+
* lower/upper bound for particular dimension independently on number of cube
1544+
* dimensions.
1545+
*
1546+
* Long story short, this function uses following meaning of coordinates:
1547+
* # (2 * N - 1) -- lower bound of Nth dimension,
1548+
* # (2 * N) -- upper bound of Nth dimension.
1549+
*
1550+
* When given coordinate exceeds number of cube dimensions, then 0 returned
1551+
* (reproducing logic of GiST indexing of variable-length cubes).
15031552
*/
15041553
Datum
15051554
cube_coord_llur(PG_FUNCTION_ARGS)
15061555
{
15071556
NDBOX *cube = PG_GETARG_NDBOX(0);
15081557
int coord = PG_GETARG_INT32(1);
1558+
bool inverse = false;
1559+
float8 result;
15091560

1510-
if (coord <= 0 || coord > 2 * DIM(cube))
1561+
/* 0 is the only unsupported coordinate value */
1562+
if (coord <= 0)
15111563
ereport(ERROR,
15121564
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
15131565
errmsg("cube index %d is out of bounds", coord)));
15141566

1515-
if (coord <= DIM(cube))
1567+
if (coord <= 2 * DIM(cube))
15161568
{
1569+
/* dimension index */
1570+
int index = (coord - 1) / 2;
1571+
/* whether this is upper bound (lower bound otherwise) */
1572+
bool upper = ((coord - 1) % 2 == 1);
1573+
15171574
if (IS_POINT(cube))
1518-
PG_RETURN_FLOAT8(cube->x[coord - 1]);
1575+
{
1576+
result = cube->x[index];
1577+
}
15191578
else
1520-
PG_RETURN_FLOAT8(Min(cube->x[coord - 1],
1521-
cube->x[coord - 1 + DIM(cube)]));
1579+
{
1580+
if (upper)
1581+
result = Max(cube->x[index], cube->x[index + DIM(cube)]);
1582+
else
1583+
result = Min(cube->x[index], cube->x[index + DIM(cube)]);
1584+
}
15221585
}
15231586
else
15241587
{
1525-
if (IS_POINT(cube))
1526-
PG_RETURN_FLOAT8(cube->x[(coord - 1) % DIM(cube)]);
1527-
else
1528-
PG_RETURN_FLOAT8(Max(cube->x[coord - 1],
1529-
cube->x[coord - 1 - DIM(cube)]));
1588+
/*
1589+
* Return zero if coordinate is out of bound. That reproduces logic of
1590+
* how cubes with low dimension number are expanded during GiST
1591+
* indexing.
1592+
*/
1593+
result = 0.0;
15301594
}
1595+
1596+
/* Inverse value if needed */
1597+
if (inverse)
1598+
result = -result;
1599+
1600+
PG_RETURN_FLOAT8(result);
15311601
}
15321602

15331603
/* Increase or decrease box size by a radius in at least n dimensions. */

0 commit comments

Comments
 (0)