Skip to content

G2 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 85 commits into from
Closed

G2 #8

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ea8e1bb
Improve error detection capability in proclists.
tglsfdc Jan 8, 2018
e35dba4
Cosmetic improvements in condition_variable.[hc].
tglsfdc Jan 8, 2018
d25ee30
pg_upgrade: prevent check on live cluster from generating error
bmomjian Jan 9, 2018
63008b1
Fix comment.
robertmhaas Jan 9, 2018
bc7fa0c
Improve scripting language in pgbench
feodor Jan 9, 2018
921059b
Don't allow VACUUM VERBOSE ANALYZE VERBOSE.
robertmhaas Jan 9, 2018
13db3b9
Allow ConditionVariable[PrepareTo]Sleep to auto-switch between CVs.
tglsfdc Jan 9, 2018
8a90620
Fix race condition during replication origin drop.
tglsfdc Jan 9, 2018
c3d41cc
Fix ssl tests for when tls-server-end-point is not supported
petere Jan 9, 2018
80259d4
While waiting for a condition variable, detect postmaster death.
tglsfdc Jan 9, 2018
624e440
Improve the heuristic for ordering child paths of a parallel append.
tglsfdc Jan 9, 2018
3cb1b2a
Rewrite list_qsort() to avoid trashing its input list.
tglsfdc Jan 9, 2018
0f7c49e
Update portal-related memory context names and API
petere Dec 16, 2017
a77dd53
Remove PortalGetQueryDesc()
petere Dec 16, 2017
11b623d
Implement TZH and TZM timestamp format patterns
adunstan Jan 9, 2018
272c2ab
Change some bogus PageGetLSN calls to BufferGetLSNAtomic
alvherre Jan 9, 2018
69c3936
Expression evaluation based aggregate transition invocation.
anarazel Jan 9, 2018
fccaea4
Remove outdated/removed Win32 URLs in C comments
bmomjian Jan 9, 2018
d16c2de
Fix allowing of leading zero on exponents in pgbench test results
feodor Jan 10, 2018
acc67ff
Give more accurate error message for dropping pinned portal
petere Jan 10, 2018
b3617cd
Move portal pinning from PL/pgSQL to SPI
petere Dec 15, 2017
2fd5809
Add missing "return" statement to accumulate_append_subpath.
robertmhaas Jan 10, 2018
3afd75e
Remove dubious micro-optimization in ckpt_buforder_comparator().
tglsfdc Jan 10, 2018
b48b2f8
Revert "Move portal pinning from PL/pgSQL to SPI"
petere Jan 10, 2018
5115854
Add tests for PL/pgSQL returning unnamed portals as refcursor
petere Jan 10, 2018
70d6226
Use portal pinning in PL/Perl and PL/Python
petere Dec 12, 2017
3c1e9fd
Fix sample INSTR() functions in the plpgsql documentation.
tglsfdc Jan 10, 2018
563a053
Fix behavior of ~> (cube, int) operator
feodor Jan 11, 2018
f50c80d
llow negative coordinate for ~> (cube, int) operator
feodor Jan 11, 2018
9e945f8
Fix Latin spelling
petere Jan 11, 2018
ca454b9
doc: add JSON acronym
bmomjian Jan 11, 2018
9ff4f75
Cosmetic fix in postgres_fdw.c.
tglsfdc Jan 11, 2018
4d41b2e
Add QueryEnvironment to ExplainOneQuery_hook's parameter list.
tglsfdc Jan 11, 2018
bbd3363
Refactor subscription tests to use PostgresNode's wait_for_catchup
petere Jan 8, 2018
bdb70c1
C comment: fix "the the" mentions in C comments
bmomjian Jan 12, 2018
49c784e
Remove hard-coded schema knowledge about pg_attribute from genbki.pl
alvherre Jan 12, 2018
ca4587f
Fix parsing of compatibility mode argument.
Jan 12, 2018
9094767
Fix incorrect handling of subquery pullup in the presence of grouping…
tglsfdc Jan 12, 2018
680d540
Avoid unnecessary failure in SELECT concurrent with ALTER NO INHERIT.
tglsfdc Jan 12, 2018
e9f2703
Fix postgres_fdw to cope with duplicate GROUP BY entries.
tglsfdc Jan 12, 2018
255f141
docs: replace dblink() mention with foreign data mention
bmomjian Jan 12, 2018
649aeb1
Cope with indicator arrays that do not have the correct length.
Jan 13, 2018
d91da5e
Remove useless use of bit-masking macros
petere Jan 16, 2018
cc4fede
Centralize json and jsonb handling of datetime types
adunstan Jan 17, 2018
585e166
Fix compiler warnings due to commit cc4feded
adunstan Jan 17, 2018
9c7d06d
Ability to advance replication slots
simonat2ndQuadrant Jan 17, 2018
dca48d1
Remove useless lookup of root partitioned rel in ExecInitModifyTable().
tglsfdc Jan 17, 2018
4bbf6ed
postgres_fdw: Avoid 'outer pathkeys do not match mergeclauses' error.
robertmhaas Jan 17, 2018
f033462
Reorder C includes
bmomjian Jan 17, 2018
a063d84
doc: Expand documentation of session_replication_role
petere Jan 18, 2018
2082b37
Extend configure's __int128 test to check for a known gcc bug.
tglsfdc Jan 18, 2018
77216ca
Add tests for session_replication_role
petere Jan 18, 2018
958c7ae
Fix typo and improve punctuation
petere Jan 18, 2018
a228e44
Update comment
petere Jan 19, 2018
4e54dd2
Fix typo in recent commit
simonat2ndQuadrant Jan 19, 2018
29d58fd
Transfer state pertaining to pending REINDEX operations to workers.
robertmhaas Jan 19, 2018
1ef61dd
Fix StoreCatalogInheritance1 to use 32bit inhseqno
alvherre Jan 19, 2018
8b08f7d
Local partitioned indexes
alvherre Jan 19, 2018
189d0ff
Fix regression tests for better stability
alvherre Jan 19, 2018
42b5856
Fix pg_dump version comparison
alvherre Jan 19, 2018
2c6f37e
Replace GrantObjectType with ObjectType
petere Oct 11, 2017
8b9e964
Replace AclObjectKind with ObjectType
petere Dec 2, 2017
7f17fd6
Fix CompareIndexInfo's attnum comparisons
alvherre Jan 19, 2018
2f17844
Allow UPDATE to move rows between partitions.
robertmhaas Jan 19, 2018
eee50a8
PL/Python: Simplify PLyLong_FromInt64
petere Jan 19, 2018
96102a3
Suppress possibly-uninitialized-variable warnings.
tglsfdc Jan 20, 2018
918e02a
Improve type conversion of SPI_processed in Python
petere Jan 20, 2018
22d94a3
Step 0
x4m Jan 20, 2018
5fbf14d
Step 1
x4m Jan 27, 2018
2097158
Step 2
x4m Jan 28, 2018
65ca60b
Step 3
x4m Jan 28, 2018
617f8bd
Step 4
x4m Jan 30, 2018
85d0b15
Step 5
x4m Jan 30, 2018
c62795e
Step 6
x4m Jan 31, 2018
72db60a
Step 7
x4m Feb 1, 2018
4cef75c
Step 8
x4m Feb 1, 2018
f5e6fa2
Step 9
x4m Feb 1, 2018
1997428
small fix
x4m Feb 1, 2018
fb46000
Step scan
x4m Feb 1, 2018
c87c426
Step 0
x4m Feb 2, 2018
8245285
Step 1
x4m Feb 3, 2018
e926826
fix vacuum
x4m Feb 4, 2018
5c4e1de
xlog stuff
x4m Feb 4, 2018
4b2c16a
Step HZ
x4m Feb 5, 2018
126bd42
xlog actually fixed
x4m Feb 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions config/c-compiler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,61 @@ AC_DEFUN([PGAC_TYPE_128BIT_INT],
[AC_CACHE_CHECK([for __int128], [pgac_cv__128bit_int],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
/*
* We don't actually run this test, just link it to verify that any support
* functions needed for __int128 are present.
*
* These are globals to discourage the compiler from folding all the
* arithmetic tests down to compile-time constants. We do not have
* convenient support for 64bit literals at this point...
* convenient support for 128bit literals at this point...
*/
__int128 a = 48828125;
__int128 b = 97656255;
__int128 b = 97656250;
],[
__int128 c,d;
a = (a << 12) + 1; /* 200000000001 */
b = (b << 12) + 5; /* 400000000005 */
/* use the most relevant arithmetic ops */
/* try the most relevant arithmetic ops */
c = a * b;
d = (c + b) / b;
/* return different values, to prevent optimizations */
/* must use the results, else compiler may optimize arithmetic away */
if (d != a+1)
return 0;
return 1;
return 1;
])],
[pgac_cv__128bit_int=yes],
[pgac_cv__128bit_int=no])])
if test x"$pgac_cv__128bit_int" = xyes ; then
AC_DEFINE(PG_INT128_TYPE, __int128, [Define to the name of a signed 128-bit integer type.])
AC_CHECK_ALIGNOF(PG_INT128_TYPE)
# Use of non-default alignment with __int128 tickles bugs in some compilers.
# If not cross-compiling, we can test for bugs and disable use of __int128
# with buggy compilers. If cross-compiling, hope for the best.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83925
AC_CACHE_CHECK([for __int128 alignment bug], [pgac_cv__128bit_int_bug],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([
/* This must match the corresponding code in c.h: */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#endif
typedef __int128 int128a
#if defined(pg_attribute_aligned)
pg_attribute_aligned(8)
#endif
;
int128a holder;
void pass_by_val(void *buffer, int128a par) { holder = par; }
],[
long int i64 = 97656225L << 12;
int128a q;
pass_by_val(main, (int128a) i64);
q = (int128a) i64;
if (q != holder)
return 1;
])],
[pgac_cv__128bit_int_bug=ok],
[pgac_cv__128bit_int_bug=broken],
[pgac_cv__128bit_int_bug="assuming ok"])])
if test x"$pgac_cv__128bit_int_bug" != xbroken ; then
AC_DEFINE(PG_INT128_TYPE, __int128, [Define to the name of a signed 128-bit integer type.])
AC_CHECK_ALIGNOF(PG_INT128_TYPE)
fi
fi])# PGAC_TYPE_128BIT_INT


Expand Down
72 changes: 65 additions & 7 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -14996,12 +14996,15 @@ else
/* end confdefs.h. */
/*
* We don't actually run this test, just link it to verify that any support
* functions needed for __int128 are present.
*
* These are globals to discourage the compiler from folding all the
* arithmetic tests down to compile-time constants. We do not have
* convenient support for 64bit literals at this point...
* convenient support for 128bit literals at this point...
*/
__int128 a = 48828125;
__int128 b = 97656255;
__int128 b = 97656250;
int
main ()
Expand All @@ -15010,13 +15013,12 @@ main ()
__int128 c,d;
a = (a << 12) + 1; /* 200000000001 */
b = (b << 12) + 5; /* 400000000005 */
/* use the most relevant arithmetic ops */
/* try the most relevant arithmetic ops */
c = a * b;
d = (c + b) / b;
/* return different values, to prevent optimizations */
/* must use the results, else compiler may optimize arithmetic away */
if (d != a+1)
return 0;
return 1;
return 1;
;
return 0;
Expand All @@ -15033,10 +15035,65 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__128bit_int" >&5
$as_echo "$pgac_cv__128bit_int" >&6; }
if test x"$pgac_cv__128bit_int" = xyes ; then
# Use of non-default alignment with __int128 tickles bugs in some compilers.
# If not cross-compiling, we can test for bugs and disable use of __int128
# with buggy compilers. If cross-compiling, hope for the best.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83925
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __int128 alignment bug" >&5
$as_echo_n "checking for __int128 alignment bug... " >&6; }
if ${pgac_cv__128bit_int_bug+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
pgac_cv__128bit_int_bug="assuming ok"
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* This must match the corresponding code in c.h: */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#endif
typedef __int128 int128a
#if defined(pg_attribute_aligned)
pg_attribute_aligned(8)
#endif
;
int128a holder;
void pass_by_val(void *buffer, int128a par) { holder = par; }
int
main ()
{
long int i64 = 97656225L << 12;
int128a q;
pass_by_val(main, (int128a) i64);
q = (int128a) i64;
if (q != holder)
return 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv__128bit_int_bug=ok
else
pgac_cv__128bit_int_bug=broken
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__128bit_int_bug" >&5
$as_echo "$pgac_cv__128bit_int_bug" >&6; }
if test x"$pgac_cv__128bit_int_bug" != xbroken ; then

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

# The cast to long int works around a bug in the HP C Compiler,
# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of PG_INT128_TYPE" >&5
$as_echo_n "checking alignment of PG_INT128_TYPE... " >&6; }
Expand Down Expand Up @@ -15071,6 +15128,7 @@ cat >>confdefs.h <<_ACEOF
_ACEOF


fi
fi

# Check for various atomic operations now that we have checked how to declare
Expand Down
150 changes: 124 additions & 26 deletions contrib/cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,15 +1337,72 @@ g_cube_distance(PG_FUNCTION_ARGS)

if (strategy == CubeKNNDistanceCoord)
{
/*
* Handle ordering by ~> operator. See comments of cube_coord_llur()
* for details
*/
int coord = PG_GETARG_INT32(1);
bool isLeaf = GistPageIsLeaf(entry->page);
bool inverse = false;

if (DIM(cube) == 0)
retval = 0.0;
else if (IS_POINT(cube))
retval = cube->x[(coord - 1) % DIM(cube)];
/* 0 is the only unsupported coordinate value */
if (coord == 0)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
errmsg("zero cube index is not defined")));

/* Return inversed value for negative coordinate */
if (coord < 0)
{
coord = -coord;
inverse = true;
}

if (coord <= 2 * DIM(cube))
{
/* dimension index */
int index = (coord - 1) / 2;
/* whether this is upper bound (lower bound otherwise) */
bool upper = ((coord - 1) % 2 == 1);

if (IS_POINT(cube))
{
retval = cube->x[index];
}
else
{
if (isLeaf)
{
/* For leaf just return required upper/lower bound */
if (upper)
retval = Max(cube->x[index], cube->x[index + DIM(cube)]);
else
retval = Min(cube->x[index], cube->x[index + DIM(cube)]);
}
else
{
/*
* For non-leaf we should always return lower bound,
* because even upper bound of a child in the subtree can
* be as small as our lower bound. For inversed case we
* return upper bound because it becomes lower bound for
* inversed value.
*/
if (!inverse)
retval = Min(cube->x[index], cube->x[index + DIM(cube)]);
else
retval = Max(cube->x[index], cube->x[index + DIM(cube)]);
}
}
}
else
retval = Min(cube->x[(coord - 1) % DIM(cube)],
cube->x[(coord - 1) % DIM(cube) + DIM(cube)]);
{
retval = 0.0;
}

/* Inverse return value if needed */
if (inverse)
retval = -retval;
}
else
{
Expand Down Expand Up @@ -1492,43 +1549,84 @@ cube_coord(PG_FUNCTION_ARGS)
}


/*
* This function works like cube_coord(),
* but rearranges coordinates of corners to get cube representation
* in the form of (lower left, upper right).
* For historical reasons that extension allows us to create cubes in form
* ((2,1),(1,2)) and instead of normalizing such cube to ((1,1),(2,2)) it
* stores cube in original way. But to get cubes ordered by one of dimensions
* directly from the index without extra sort step we need some
* representation-independent coordinate getter. This function implements it.
/*----
* This function works like cube_coord(), but rearranges coordinates in the
* way suitable to support coordinate ordering using KNN-GiST. For historical
* reasons this extension allows us to create cubes in form ((2,1),(1,2)) and
* instead of normalizing such cube to ((1,1),(2,2)) it stores cube in original
* way. But in order to get cubes ordered by one of dimensions from the index
* without explicit sort step we need this representation-independent coordinate
* getter. Moreover, indexed dataset may contain cubes of different dimensions
* number. Accordingly, this coordinate getter should be able to return
* lower/upper bound for particular dimension independently on number of cube
* dimensions. Also, KNN-GiST supports only ascending sorting. In order to
* support descending sorting, this function returns inverse of value when
* negative coordinate is given.
*
* Long story short, this function uses following meaning of coordinates:
* # (2 * N - 1) -- lower bound of Nth dimension,
* # (2 * N) -- upper bound of Nth dimension,
* # - (2 * N - 1) -- negative of lower bound of Nth dimension,
* # - (2 * N) -- negative of upper bound of Nth dimension.
*
* When given coordinate exceeds number of cube dimensions, then 0 returned
* (reproducing logic of GiST indexing of variable-length cubes).
*/
Datum
cube_coord_llur(PG_FUNCTION_ARGS)
{
NDBOX *cube = PG_GETARG_NDBOX_P(0);
int coord = PG_GETARG_INT32(1);
bool inverse = false;
float8 result;

if (coord <= 0 || coord > 2 * DIM(cube))
/* 0 is the only unsupported coordinate value */
if (coord == 0)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
errmsg("cube index %d is out of bounds", coord)));
errmsg("zero cube index is not defined")));

/* Return inversed value for negative coordinate */
if (coord < 0)
{
coord = -coord;
inverse = true;
}

if (coord <= DIM(cube))
if (coord <= 2 * DIM(cube))
{
/* dimension index */
int index = (coord - 1) / 2;
/* whether this is upper bound (lower bound otherwise) */
bool upper = ((coord - 1) % 2 == 1);

if (IS_POINT(cube))
PG_RETURN_FLOAT8(cube->x[coord - 1]);
{
result = cube->x[index];
}
else
PG_RETURN_FLOAT8(Min(cube->x[coord - 1],
cube->x[coord - 1 + DIM(cube)]));
{
if (upper)
result = Max(cube->x[index], cube->x[index + DIM(cube)]);
else
result = Min(cube->x[index], cube->x[index + DIM(cube)]);
}
}
else
{
if (IS_POINT(cube))
PG_RETURN_FLOAT8(cube->x[(coord - 1) % DIM(cube)]);
else
PG_RETURN_FLOAT8(Max(cube->x[coord - 1],
cube->x[coord - 1 - DIM(cube)]));
/*
* Return zero if coordinate is out of bound. That reproduces logic of
* how cubes with low dimension number are expanded during GiST
* indexing.
*/
result = 0.0;
}

/* Inverse value if needed */
if (inverse)
result = -result;

PG_RETURN_FLOAT8(result);
}

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