Skip to content

Commit a094b17

Browse files
committed
Merge branch 'xtm' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into xtm
2 parents 998b60b + 96f465c commit a094b17

File tree

319 files changed

+14842
-7674
lines changed

Some content is hidden

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

319 files changed

+14842
-7674
lines changed

config/c-compiler.m4

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ fi])# PGAC_C_BUILTIN_BSWAP32
214214

215215

216216

217+
# PGAC_C_BUILTIN_BSWAP64
218+
# -------------------------
219+
# Check if the C compiler understands __builtin_bswap64(),
220+
# and define HAVE__BUILTIN_BSWAP64 if so.
221+
AC_DEFUN([PGAC_C_BUILTIN_BSWAP64],
222+
[AC_CACHE_CHECK(for __builtin_bswap64, pgac_cv__builtin_bswap64,
223+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE(
224+
[static unsigned long int x = __builtin_bswap64(0xaabbccddeeff0011);]
225+
)],
226+
[pgac_cv__builtin_bswap64=yes],
227+
[pgac_cv__builtin_bswap64=no])])
228+
if test x"$pgac_cv__builtin_bswap64" = xyes ; then
229+
AC_DEFINE(HAVE__BUILTIN_BSWAP64, 1,
230+
[Define to 1 if your compiler understands __builtin_bswap64.])
231+
fi])# PGAC_C_BUILTIN_BSWAP64
232+
233+
234+
217235
# PGAC_C_BUILTIN_CONSTANT_P
218236
# -------------------------
219237
# Check if the C compiler understands __builtin_constant_p(),

configure

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11258,6 +11258,30 @@ if test x"$pgac_cv__builtin_bswap32" = xyes ; then
1125811258

1125911259
$as_echo "#define HAVE__BUILTIN_BSWAP32 1" >>confdefs.h
1126011260

11261+
fi
11262+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_bswap64" >&5
11263+
$as_echo_n "checking for __builtin_bswap64... " >&6; }
11264+
if ${pgac_cv__builtin_bswap64+:} false; then :
11265+
$as_echo_n "(cached) " >&6
11266+
else
11267+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11268+
/* end confdefs.h. */
11269+
static unsigned long int x = __builtin_bswap64(0xaabbccddeeff0011);
11270+
11271+
_ACEOF
11272+
if ac_fn_c_try_compile "$LINENO"; then :
11273+
pgac_cv__builtin_bswap64=yes
11274+
else
11275+
pgac_cv__builtin_bswap64=no
11276+
fi
11277+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11278+
fi
11279+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_bswap64" >&5
11280+
$as_echo "$pgac_cv__builtin_bswap64" >&6; }
11281+
if test x"$pgac_cv__builtin_bswap64" = xyes ; then
11282+
11283+
$as_echo "#define HAVE__BUILTIN_BSWAP64 1" >>confdefs.h
11284+
1126111285
fi
1126211286
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_constant_p" >&5
1126311287
$as_echo_n "checking for __builtin_constant_p... " >&6; }

configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,7 @@ PGAC_C_FUNCNAME_SUPPORT
13171317
PGAC_C_STATIC_ASSERT
13181318
PGAC_C_TYPES_COMPATIBLE
13191319
PGAC_C_BUILTIN_BSWAP32
1320+
PGAC_C_BUILTIN_BSWAP64
13201321
PGAC_C_BUILTIN_CONSTANT_P
13211322
PGAC_C_BUILTIN_UNREACHABLE
13221323
PGAC_C_VA_ARGS

contrib/earthdistance/expected/earthdistance.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
--
1010
CREATE EXTENSION earthdistance; -- fail, must install cube first
1111
ERROR: required extension "cube" is not installed
12+
HINT: Use CREATE EXTENSION CASCADE to install required extensions too.
1213
CREATE EXTENSION cube;
1314
CREATE EXTENSION earthdistance;
1415
--

contrib/hstore_plperl/expected/hstore_plperl.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CREATE EXTENSION hstore;
2-
CREATE EXTENSION plperl;
3-
CREATE EXTENSION hstore_plperl;
1+
CREATE EXTENSION hstore_plperl CASCADE;
2+
NOTICE: installing required extension "hstore"
3+
NOTICE: installing required extension "plperl"
44
SELECT transforms.udt_schema, transforms.udt_name,
55
routine_schema, routine_name,
66
group_name, transform_type

contrib/hstore_plperl/expected/hstore_plperlu.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CREATE EXTENSION hstore;
2-
CREATE EXTENSION plperlu;
3-
CREATE EXTENSION hstore_plperlu;
1+
CREATE EXTENSION hstore_plperlu CASCADE;
2+
NOTICE: installing required extension "hstore"
3+
NOTICE: installing required extension "plperlu"
44
SELECT transforms.udt_schema, transforms.udt_name,
55
routine_schema, routine_name,
66
group_name, transform_type

contrib/hstore_plperl/sql/hstore_plperl.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
CREATE EXTENSION hstore;
2-
CREATE EXTENSION plperl;
3-
CREATE EXTENSION hstore_plperl;
1+
CREATE EXTENSION hstore_plperl CASCADE;
42

53
SELECT transforms.udt_schema, transforms.udt_name,
64
routine_schema, routine_name,

contrib/hstore_plperl/sql/hstore_plperlu.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
CREATE EXTENSION hstore;
2-
CREATE EXTENSION plperlu;
3-
CREATE EXTENSION hstore_plperlu;
1+
CREATE EXTENSION hstore_plperlu CASCADE;
42

53
SELECT transforms.udt_schema, transforms.udt_name,
64
routine_schema, routine_name,

contrib/hstore_plpython/expected/hstore_plpython.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CREATE EXTENSION plpython2u;
2-
CREATE EXTENSION hstore_plpython2u;
1+
CREATE EXTENSION hstore_plpython2u CASCADE;
2+
NOTICE: installing required extension "plpython2u"
33
-- test hstore -> python
44
CREATE FUNCTION test1(val hstore) RETURNS int
55
LANGUAGE plpythonu

contrib/hstore_plpython/sql/hstore_plpython.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
CREATE EXTENSION plpython2u;
2-
CREATE EXTENSION hstore_plpython2u;
1+
CREATE EXTENSION hstore_plpython2u CASCADE;
32

43

54
-- test hstore -> python

contrib/intarray/_int_bool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ typedef struct
564564
static void
565565
infix(INFIX *in, bool first)
566566
{
567+
/* since this function recurses, it could be driven to stack overflow. */
568+
check_stack_depth();
569+
567570
if (in->curpol->type == VAL)
568571
{
569572
RESIZEBUF(in, 11);

contrib/ltree/ltxtquery_io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
416416
static void
417417
infix(INFIX *in, bool first)
418418
{
419+
/* since this function recurses, it could be driven to stack overflow. */
420+
check_stack_depth();
421+
419422
if (in->curpol->type == VAL)
420423
{
421424
char *op = in->op + in->curpol->distance;

contrib/ltree/ltxtquery_op.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <ctype.h>
99

1010
#include "ltree.h"
11+
#include "miscadmin.h"
1112

1213
PG_FUNCTION_INFO_V1(ltxtq_exec);
1314
PG_FUNCTION_INFO_V1(ltxtq_rexec);
@@ -18,6 +19,9 @@ PG_FUNCTION_INFO_V1(ltxtq_rexec);
1819
bool
1920
ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM *val))
2021
{
22+
/* since this function recurses, it could be driven to stack overflow */
23+
check_stack_depth();
24+
2125
if (curitem->type == VAL)
2226
return (*chkcond) (checkval, curitem);
2327
else if (curitem->val == (int32) '!')

contrib/ltree_plpython/expected/ltree_plpython.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CREATE EXTENSION plpython2u;
2-
CREATE EXTENSION ltree_plpython2u;
1+
CREATE EXTENSION ltree_plpython2u CASCADE;
2+
NOTICE: installing required extension "plpython2u"
33
CREATE FUNCTION test1(val ltree) RETURNS int
44
LANGUAGE plpythonu
55
TRANSFORM FOR TYPE ltree

contrib/ltree_plpython/sql/ltree_plpython.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
CREATE EXTENSION plpython2u;
2-
CREATE EXTENSION ltree_plpython2u;
1+
CREATE EXTENSION ltree_plpython2u CASCADE;
32

43

54
CREATE FUNCTION test1(val ltree) RETURNS int

contrib/pg_dtm/docs/DTM.odp

1000 KB
Binary file not shown.

contrib/pg_dtm/docs/dtm.pdf

1.15 MB
Binary file not shown.
916 KB
Loading
7.05 KB
Binary file not shown.

contrib/pg_dtm/docs/pgpro-logo-title.svg

Lines changed: 39 additions & 0 deletions
Loading

contrib/pg_dtm/dtmd/src/main.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
#define DEFAULT_LISTENHOST "0.0.0.0"
1919
#define DEFAULT_LISTENPORT 5431
2020

21+
static xid_t get_global_xmin();
22+
2123
L2List active_transactions = {&active_transactions, &active_transactions};
2224
L2List* free_transactions;
2325

2426
// We reserve the local xids if they fit between (prev, next) range, and
2527
// reserve something in (next, x) range otherwise, moving 'next' after 'x'.
2628
xid_t prev_gxid, next_gxid;
29+
xid_t global_xmin = INVALID_XID;
2730

2831
typedef struct client_userdata_t {
2932
int id;
@@ -54,6 +57,9 @@ inline static void free_transaction(Transaction* t) {
5457
l2_list_unlink(&t->elem);
5558
t->elem.next = free_transactions;
5659
free_transactions = &t->elem;
60+
if (t->xmin == global_xmin) {
61+
global_xmin = get_global_xmin();
62+
}
5763
}
5864

5965

@@ -274,6 +280,7 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
274280
free_transactions = t->elem.next;
275281
}
276282
transaction_clear(t);
283+
l2_list_link(&active_transactions, &t->elem);
277284

278285
prev_gxid = t->xid = next_gxid++;
279286
t->snapshots_count = 0;
@@ -292,18 +299,19 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
292299
free_transaction(t);
293300
return;
294301
}
295-
xid_t gxmin = get_global_xmin();
302+
296303
Snapshot *snap = transaction_next_snapshot(t);
297304
gen_snapshot(snap); // FIXME: increase 'times_sent' here? see also 4765234987
298-
299305
t->xmin = snap->xmin;
300-
l2_list_link(&active_transactions, &t->elem);
306+
if (global_xmin == INVALID_XID) {
307+
global_xmin = snap->xmin;
308+
}
301309

302310
xid_t ok = RES_OK;
303311
client_message_start(client); {
304312
client_message_append(client, sizeof(xid_t), &ok);
305313
client_message_append(client, sizeof(xid_t), &t->xid);
306-
client_message_append(client, sizeof(xid_t), &gxmin);
314+
client_message_append(client, sizeof(xid_t), &global_xmin);
307315
client_message_append(client, sizeof(xid_t), &snap->xmin);
308316
client_message_append(client, sizeof(xid_t), &snap->xmax);
309317
client_message_append(client, sizeof(xid_t) * snap->nactive, snap->active);
@@ -452,22 +460,16 @@ static void onsnapshot(client_t client, int argc, xid_t *argv) {
452460

453461
if (CLIENT_SNAPSENT(client) == t->snapshots_count) {
454462
// a fresh snapshot is needed
455-
Snapshot* snap = transaction_next_snapshot(t);
456-
gen_snapshot(snap);
457-
if (snap->xmin < t->xmin) {
458-
t->xmin = snap->xmin;
459-
}
463+
gen_snapshot(transaction_next_snapshot(t));
460464
}
461465

462-
xid_t gxmin = get_global_xmin();
463-
464466
Snapshot *snap = transaction_snapshot(t, CLIENT_SNAPSENT(client)++);
465467
snap->times_sent += 1; // FIXME: does times_sent get used anywhere? see also 4765234987
466468

467469
xid_t ok = RES_OK;
468470
client_message_start(client); {
469471
client_message_append(client, sizeof(xid_t), &ok);
470-
client_message_append(client, sizeof(xid_t), &gxmin);
472+
client_message_append(client, sizeof(xid_t), &global_xmin);
471473
client_message_append(client, sizeof(xid_t), &snap->xmin);
472474
client_message_append(client, sizeof(xid_t), &snap->xmax);
473475
client_message_append(client, sizeof(xid_t) * snap->nactive, snap->active);

contrib/pg_dtm/dtmd/src/transaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void transaction_clear(Transaction *t) {
2727
int i;
2828

2929
t->xid = INVALID_XID;
30-
t->xmin = INVALID_XID;
30+
t->xmin = INVALID_XID;
3131
t->size = 0;
3232
t->votes_for = 0;
3333
t->votes_against = 0;

contrib/pg_dtm/pg_dtm.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,11 @@ DtmGetNewTransactionId(bool isSubXact)
359359
TransactionId xid;
360360

361361
XTM_INFO("%d: GetNewTransactionId\n", getpid());
362-
Assert(!DtmGlobalXidAssigned); /* We should not assign new Xid if we do not use previous one */
363-
362+
if (DtmGlobalXidAssigned)
363+
{
364+
/* We should not assign new Xid if we do not use previous one */
365+
elog(ERROR, "dtm_begin/join_transaction should be called prior to begin of global transaction");
366+
}
364367
/*
365368
* Workers synchronize transaction state at the beginning of each parallel
366369
* operation, so we can't account for new XIDs after that point.
@@ -887,11 +890,13 @@ dtm_get_current_snapshot_xcnt(PG_FUNCTION_ARGS)
887890
Datum
888891
dtm_begin_transaction(PG_FUNCTION_ARGS)
889892
{
890-
Assert(!TransactionIdIsValid(DtmNextXid));
893+
if (TransactionIdIsValid(DtmNextXid))
894+
elog(ERROR, "dtm_begin/join_transaction should be called only once for global transaction");
891895
if (dtm == NULL)
892896
elog(ERROR, "DTM is not properly initialized, please check that pg_dtm plugin was added to shared_preload_libraries list in postgresql.conf");
893897
DtmNextXid = DtmGlobalStartTransaction(&DtmSnapshot, &dtm->minXid);
894-
Assert(TransactionIdIsValid(DtmNextXid));
898+
if (!TransactionIdIsValid(DtmNextXid))
899+
elog(ERROR, "Arbiter was not able to assign XID");
895900
XTM_INFO("%d: Start global transaction %d, dtm->minXid=%d\n", getpid(), DtmNextXid, dtm->minXid);
896901

897902
DtmHasGlobalSnapshot = true;
@@ -903,9 +908,11 @@ dtm_begin_transaction(PG_FUNCTION_ARGS)
903908

904909
Datum dtm_join_transaction(PG_FUNCTION_ARGS)
905910
{
906-
Assert(!TransactionIdIsValid(DtmNextXid));
911+
if (TransactionIdIsValid(DtmNextXid))
912+
elog(ERROR, "dtm_begin/join_transaction should be called only once for global transaction");
907913
DtmNextXid = PG_GETARG_INT32(0);
908-
Assert(TransactionIdIsValid(DtmNextXid));
914+
if (!TransactionIdIsValid(DtmNextXid))
915+
elog(ERROR, "Arbiter was not able to assign XID");
909916

910917
DtmGlobalGetSnapshot(DtmNextXid, &DtmSnapshot, &dtm->minXid);
911918
XTM_INFO("%d: Join global transaction %d, dtm->minXid=%d\n", getpid(), DtmNextXid, dtm->minXid);

contrib/pg_dtm/sockhub/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CC = gcc
2-
CFLAGS = -c -I. -Wall -O2 -g -fPIC
2+
CFLAGS = -c -I. -Wall -O3 -g -fPIC
33
LD = $(CC)
44
LDFLAGS = -g
55
AR = ar
@@ -9,7 +9,7 @@ all: sockhub library tests
99

1010
library: libsockhub.a
1111

12-
tests: test-client test-server
12+
tests: test-client test-async-client test-server
1313

1414
sockhup.o: sockhub.c sockhub.h
1515
$(CC) $(CFLAGS) sockhub.c
@@ -30,6 +30,12 @@ test-client.o: test-client.c sockhub.h
3030
test-client: test-client.o libsockhub.a
3131
$(LD) $(LDFLAGS) -o test-client test-client.o libsockhub.a
3232

33+
test-async-client.o: test-async-client.c sockhub.h
34+
$(CC) $(CFLAGS) test-async-client.c
35+
36+
test-async-client: test-async-client.o libsockhub.a
37+
$(LD) $(LDFLAGS) -o test-async-client test-async-client.o libsockhub.a
38+
3339
test-server.o: test-server.c sockhub.h
3440
$(CC) $(CFLAGS) test-server.c
3541

0 commit comments

Comments
 (0)