Skip to content

Commit de6ba77

Browse files
committed
Merge branch 'master' into logical_twophase
2 parents c0980d0 + 1148e22 commit de6ba77

File tree

351 files changed

+15073
-3020
lines changed

Some content is hidden

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

351 files changed

+15073
-3020
lines changed

config/c-compiler.m4

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,30 @@ fi])# PGAC_C_BUILTIN_UNREACHABLE
273273

274274

275275

276+
# PGAC_C_COMPUTED_GOTO
277+
# -----------------------
278+
# Check if the C compiler knows computed gotos (gcc extension, also
279+
# available in at least clang). If so, define HAVE_COMPUTED_GOTO.
280+
#
281+
# Checking whether computed gotos are supported syntax-wise ought to
282+
# be enough, as the syntax is otherwise illegal.
283+
AC_DEFUN([PGAC_C_COMPUTED_GOTO],
284+
[AC_CACHE_CHECK(for computed goto support, pgac_cv_computed_goto,
285+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
286+
[[void *labeladdrs[] = {&&my_label};
287+
goto *labeladdrs[0];
288+
my_label:
289+
return 1;
290+
]])],
291+
[pgac_cv_computed_goto=yes],
292+
[pgac_cv_computed_goto=no])])
293+
if test x"$pgac_cv_computed_goto" = xyes ; then
294+
AC_DEFINE(HAVE_COMPUTED_GOTO, 1,
295+
[Define to 1 if your compiler handles computed gotos.])
296+
fi])# PGAC_C_COMPUTED_GOTO
297+
298+
299+
276300
# PGAC_C_VA_ARGS
277301
# --------------
278302
# Check if the C compiler understands C99-style variadic macros,

configure

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11531,6 +11531,40 @@ if test x"$pgac_cv__builtin_unreachable" = xyes ; then
1153111531

1153211532
$as_echo "#define HAVE__BUILTIN_UNREACHABLE 1" >>confdefs.h
1153311533

11534+
fi
11535+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for computed goto support" >&5
11536+
$as_echo_n "checking for computed goto support... " >&6; }
11537+
if ${pgac_cv_computed_goto+:} false; then :
11538+
$as_echo_n "(cached) " >&6
11539+
else
11540+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11541+
/* end confdefs.h. */
11542+
11543+
int
11544+
main ()
11545+
{
11546+
void *labeladdrs[] = {&&my_label};
11547+
goto *labeladdrs[0];
11548+
my_label:
11549+
return 1;
11550+
11551+
;
11552+
return 0;
11553+
}
11554+
_ACEOF
11555+
if ac_fn_c_try_compile "$LINENO"; then :
11556+
pgac_cv_computed_goto=yes
11557+
else
11558+
pgac_cv_computed_goto=no
11559+
fi
11560+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11561+
fi
11562+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_computed_goto" >&5
11563+
$as_echo "$pgac_cv_computed_goto" >&6; }
11564+
if test x"$pgac_cv_computed_goto" = xyes ; then
11565+
11566+
$as_echo "#define HAVE_COMPUTED_GOTO 1" >>confdefs.h
11567+
1153411568
fi
1153511569
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __VA_ARGS__" >&5
1153611570
$as_echo_n "checking for __VA_ARGS__... " >&6; }

configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@ PGAC_C_BUILTIN_BSWAP32
13221322
PGAC_C_BUILTIN_BSWAP64
13231323
PGAC_C_BUILTIN_CONSTANT_P
13241324
PGAC_C_BUILTIN_UNREACHABLE
1325+
PGAC_C_COMPUTED_GOTO
13251326
PGAC_C_VA_ARGS
13261327
PGAC_STRUCT_TIMEZONE
13271328
PGAC_UNION_SEMUN

contrib/amcheck/expected/check_btree.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ SELECT bt_index_parent_check('bttest_b_idx');
7777
(1 row)
7878

7979
-- make sure we don't have any leftover locks
80-
SELECT * FROM pg_locks WHERE relation IN ('bttest_a_idx'::regclass, 'bttest_b_idx'::regclass);
80+
SELECT * FROM pg_locks
81+
WHERE relation = ANY(ARRAY['bttest_a', 'bttest_a_idx', 'bttest_b', 'bttest_b_idx']::regclass[])
82+
AND pid = pg_backend_pid();
8183
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
8284
----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-----+------+---------+----------
8385
(0 rows)

contrib/amcheck/sql/check_btree.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ BEGIN;
4949
SELECT bt_index_check('bttest_a_idx');
5050
SELECT bt_index_parent_check('bttest_b_idx');
5151
-- make sure we don't have any leftover locks
52-
SELECT * FROM pg_locks WHERE relation IN ('bttest_a_idx'::regclass, 'bttest_b_idx'::regclass);
52+
SELECT * FROM pg_locks
53+
WHERE relation = ANY(ARRAY['bttest_a', 'bttest_a_idx', 'bttest_b', 'bttest_b_idx']::regclass[])
54+
AND pid = pg_backend_pid();
5355
COMMIT;
5456

5557
-- cleanup

contrib/btree_gin/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ MODULE_big = btree_gin
44
OBJS = btree_gin.o $(WIN32RES)
55

66
EXTENSION = btree_gin
7-
DATA = btree_gin--1.0.sql btree_gin--unpackaged--1.0.sql
7+
DATA = btree_gin--1.0.sql btree_gin--1.0--1.1.sql btree_gin--1.1--1.2.sql \
8+
btree_gin--unpackaged--1.0.sql
89
PGFILEDESC = "btree_gin - B-tree equivalent GIN operator classes"
910

1011
REGRESS = install_btree_gin int2 int4 int8 float4 float8 money oid \
1112
timestamp timestamptz time timetz date interval \
12-
macaddr inet cidr text varchar char bytea bit varbit \
13-
numeric
13+
macaddr macaddr8 inet cidr text varchar char bytea bit varbit \
14+
numeric enum
1415

1516
ifdef USE_PGXS
1617
PG_CONFIG = pg_config
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* contrib/btree_gin/btree_gin--1.0--1.1.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "ALTER EXTENSION btree_gin UPDATE TO '1.1'" to load this file. \quit
5+
6+
-- macaddr8 datatype support new in 10.0.
7+
CREATE FUNCTION gin_extract_value_macaddr8(macaddr8, internal)
8+
RETURNS internal
9+
AS 'MODULE_PATHNAME'
10+
LANGUAGE C STRICT IMMUTABLE;
11+
12+
CREATE FUNCTION gin_compare_prefix_macaddr8(macaddr8, macaddr8, int2, internal)
13+
RETURNS int4
14+
AS 'MODULE_PATHNAME'
15+
LANGUAGE C STRICT IMMUTABLE;
16+
17+
CREATE FUNCTION gin_extract_query_macaddr8(macaddr8, internal, int2, internal, internal)
18+
RETURNS internal
19+
AS 'MODULE_PATHNAME'
20+
LANGUAGE C STRICT IMMUTABLE;
21+
22+
CREATE OPERATOR CLASS macaddr8_ops
23+
DEFAULT FOR TYPE macaddr8 USING gin
24+
AS
25+
OPERATOR 1 <,
26+
OPERATOR 2 <=,
27+
OPERATOR 3 =,
28+
OPERATOR 4 >=,
29+
OPERATOR 5 >,
30+
FUNCTION 1 macaddr8_cmp(macaddr8, macaddr8),
31+
FUNCTION 2 gin_extract_value_macaddr8(macaddr8, internal),
32+
FUNCTION 3 gin_extract_query_macaddr8(macaddr8, internal, int2, internal, internal),
33+
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
34+
FUNCTION 5 gin_compare_prefix_macaddr8(macaddr8, macaddr8, int2, internal),
35+
STORAGE macaddr8;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* contrib/btree_gin/btree_gin--1.1--1.2.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "ALTER EXTENSION btree_gin UPDATE TO '1.1'" to load this file. \quit
5+
6+
--
7+
--
8+
--
9+
-- enum ops
10+
--
11+
--
12+
13+
14+
CREATE FUNCTION gin_extract_value_anyenum(anyenum, internal)
15+
RETURNS internal
16+
AS 'MODULE_PATHNAME'
17+
LANGUAGE C STRICT IMMUTABLE;
18+
19+
CREATE FUNCTION gin_compare_prefix_anyenum(anyenum, anyenum, int2, internal)
20+
RETURNS int4
21+
AS 'MODULE_PATHNAME'
22+
LANGUAGE C STRICT IMMUTABLE;
23+
24+
CREATE FUNCTION gin_extract_query_anyenum(anyenum, internal, int2, internal, internal)
25+
RETURNS internal
26+
AS 'MODULE_PATHNAME'
27+
LANGUAGE C STRICT IMMUTABLE;
28+
29+
CREATE FUNCTION gin_enum_cmp(anyenum, anyenum)
30+
RETURNS int4
31+
AS 'MODULE_PATHNAME'
32+
LANGUAGE C STRICT IMMUTABLE;
33+
34+
CREATE OPERATOR CLASS enum_ops
35+
DEFAULT FOR TYPE anyenum USING gin
36+
AS
37+
OPERATOR 1 <,
38+
OPERATOR 2 <=,
39+
OPERATOR 3 =,
40+
OPERATOR 4 >=,
41+
OPERATOR 5 >,
42+
FUNCTION 1 gin_enum_cmp(anyenum,anyenum),
43+
FUNCTION 2 gin_extract_value_anyenum(anyenum, internal),
44+
FUNCTION 3 gin_extract_query_anyenum(anyenum, internal, int2, internal, internal),
45+
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
46+
FUNCTION 5 gin_compare_prefix_anyenum(anyenum,anyenum,int2, internal),
47+
STORAGE anyenum;

contrib/btree_gin/btree_gin.c

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ typedef struct QueryInfo
2525
Datum (*typecmp) (FunctionCallInfo);
2626
} QueryInfo;
2727

28-
2928
/*** GIN support functions shared by all datatypes ***/
3029

3130
static Datum
@@ -112,13 +111,14 @@ gin_btree_compare_prefix(FunctionCallInfo fcinfo)
112111
int32 res,
113112
cmp;
114113

115-
cmp = DatumGetInt32(DirectFunctionCall2Coll(
116-
data->typecmp,
117-
PG_GET_COLLATION(),
118-
(data->strategy == BTLessStrategyNumber ||
119-
data->strategy == BTLessEqualStrategyNumber)
120-
? data->datum : a,
121-
b));
114+
cmp = DatumGetInt32(CallerFInfoFunctionCall2(
115+
data->typecmp,
116+
fcinfo->flinfo,
117+
PG_GET_COLLATION(),
118+
(data->strategy == BTLessStrategyNumber ||
119+
data->strategy == BTLessEqualStrategyNumber)
120+
? data->datum : a,
121+
b));
122122

123123
switch (data->strategy)
124124
{
@@ -322,6 +322,16 @@ leftmostvalue_macaddr(void)
322322

323323
GIN_SUPPORT(macaddr, false, leftmostvalue_macaddr, macaddr_cmp)
324324

325+
static Datum
326+
leftmostvalue_macaddr8(void)
327+
{
328+
macaddr8 *v = palloc0(sizeof(macaddr8));
329+
330+
return Macaddr8PGetDatum(v);
331+
}
332+
333+
GIN_SUPPORT(macaddr8, false, leftmostvalue_macaddr8, macaddr8_cmp)
334+
325335
static Datum
326336
leftmostvalue_inet(void)
327337
{
@@ -416,3 +426,54 @@ leftmostvalue_numeric(void)
416426
}
417427

418428
GIN_SUPPORT(numeric, true, leftmostvalue_numeric, gin_numeric_cmp)
429+
430+
/*
431+
* Use a similar trick to that used for numeric for enums, since we don't
432+
* actually know the leftmost value of any enum without knowing the concrete
433+
* type, so we use a dummy leftmost value of InvalidOid.
434+
*
435+
* Note that we use CallerFInfoFunctionCall2 here so that enum_cmp
436+
* gets a valid fn_extra to work with. Unlike most other type comparison
437+
* routines it needs it, so we can't use DirectFunctionCall2.
438+
*/
439+
440+
441+
#define ENUM_IS_LEFTMOST(x) ((x) == InvalidOid)
442+
443+
PG_FUNCTION_INFO_V1(gin_enum_cmp);
444+
445+
Datum
446+
gin_enum_cmp(PG_FUNCTION_ARGS)
447+
{
448+
Oid a = PG_GETARG_OID(0);
449+
Oid b = PG_GETARG_OID(1);
450+
int res = 0;
451+
452+
if (ENUM_IS_LEFTMOST(a))
453+
{
454+
res = (ENUM_IS_LEFTMOST(b)) ? 0 : -1;
455+
}
456+
else if (ENUM_IS_LEFTMOST(b))
457+
{
458+
res = 1;
459+
}
460+
else
461+
{
462+
res = DatumGetInt32(CallerFInfoFunctionCall2(
463+
enum_cmp,
464+
fcinfo->flinfo,
465+
PG_GET_COLLATION(),
466+
ObjectIdGetDatum(a),
467+
ObjectIdGetDatum(b)));
468+
}
469+
470+
PG_RETURN_INT32(res);
471+
}
472+
473+
static Datum
474+
leftmostvalue_enum(void)
475+
{
476+
return ObjectIdGetDatum(InvalidOid);
477+
}
478+
479+
GIN_SUPPORT(anyenum, false, leftmostvalue_enum, gin_enum_cmp)

contrib/btree_gin/btree_gin.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# btree_gin extension
22
comment = 'support for indexing common datatypes in GIN'
3-
default_version = '1.0'
3+
default_version = '1.2'
44
module_pathname = '$libdir/btree_gin'
55
relocatable = true

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy