Skip to content

Commit

Permalink
Merge pull request IvorySQL#676 from jiaoshuntian/merge_pg_master2
Browse files Browse the repository at this point in the history
Merge pg master from 2024.1.23 to  2024.2.14
  • Loading branch information
gaoxueyu authored Jul 16, 2024
2 parents 7f57daf + f9e5c3c commit fa4c4cf
Show file tree
Hide file tree
Showing 462 changed files with 21,481 additions and 6,548 deletions.
17 changes: 9 additions & 8 deletions .cirrus.tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ task:
su postgres <<-EOF
meson setup \
--buildtype=debug \
-Dcassert=true -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
-Dcassert=true -Dinjection_points=true \
-Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
-Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
build
Expand Down Expand Up @@ -327,8 +328,8 @@ task:
configure_script: |
su postgres <<-EOF
./configure \
--enable-cassert --enable-debug --enable-tap-tests \
--enable-nls \
--enable-cassert --enable-injection-points --enable-debug \
--enable-tap-tests --enable-nls \
--with-segsize-blocks=6 \
\
${LINUX_CONFIGURE_FEATURES} \
Expand Down Expand Up @@ -357,7 +358,7 @@ task:
su postgres <<-EOF
meson setup \
--buildtype=debug \
-Dcassert=true \
-Dcassert=true -Dinjection_points=true \
${LINUX_MESON_FEATURES} \
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
build
Expand All @@ -370,7 +371,7 @@ task:
export CC='ccache gcc -m32'
meson setup \
--buildtype=debug \
-Dcassert=true \
-Dcassert=true -Dinjection_points=true \
${LINUX_MESON_FEATURES} \
-Dllvm=disabled \
--pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
Expand Down Expand Up @@ -482,7 +483,7 @@ task:
--buildtype=debug \
-Dextra_include_dirs=/opt/local/include \
-Dextra_lib_dirs=/opt/local/lib \
-Dcassert=true \
-Dcassert=true -Dinjection_points=true \
-Duuid=e2fs -Ddtrace=auto \
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
build
Expand Down Expand Up @@ -556,7 +557,7 @@ task:
# Use /DEBUG:FASTLINK to avoid high memory usage during linking
configure_script: |
vcvarsall x64
meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
build_script: |
vcvarsall x64
Expand Down Expand Up @@ -616,7 +617,7 @@ task:
# disable -Dnls as the number of files it creates cause a noticable slowdown
configure_script: |
%BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
%BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Dinjection_points=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
build_script: |
%BASH% -c "ninja -C build"
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#
# $ git log --pretty=format:"%H # %cd%n# %s" $PGINDENTGITHASH -1 --date=iso

49e7c6f78ed608c5d5454080ae19c0e7f1b09a04 # 2024-02-09 11:05:01 +0900
# Fix indentation of copyto.c

96c019ffa3f883d139709ea0cfe76dc1bce0f1f8 # 2024-01-13 13:54:11 -0500
# Re-pgindent catcache.c after previous commit.

Expand Down
10 changes: 4 additions & 6 deletions config/llvm.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
AC_REQUIRE([AC_PROG_AWK])
AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config command])
PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-7 llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9)
PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10)
# no point continuing if llvm wasn't found
if test -z "$LLVM_CONFIG"; then
Expand All @@ -25,14 +25,14 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
AC_MSG_ERROR([$LLVM_CONFIG does not work])
fi
# and whether the version is supported
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 4 || ([$]1 == 3 && [$]2 >= 9)) exit 1; else exit 0;}';then
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required])
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 10) exit 1; else exit 0;}';then
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required])
fi
AC_MSG_NOTICE([using llvm $pgac_llvm_version])
# need clang to create some bitcode files
AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode])
PGAC_PATH_PROGS(CLANG, clang clang-7 clang-6.0 clang-5.0 clang-4.0 clang-3.9)
PGAC_PATH_PROGS(CLANG, clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10)
if test -z "$CLANG"; then
AC_MSG_ERROR([clang not found, but required when compiling --with-llvm, specify with CLANG=])
fi
Expand Down Expand Up @@ -115,8 +115,6 @@ AC_DEFUN([PGAC_CHECK_LLVM_FUNCTIONS],
# Check which functionality is present
SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn], [], [], [[#include <llvm-c/OrcBindings.h>]])
AC_CHECK_DECLS([LLVMGetHostCPUName, LLVMGetHostCPUFeatures], [], [], [[#include <llvm-c/TargetMachine.h>]])
AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include <llvm-c/ExecutionEngine.h>]])
CPPFLAGS="$SAVE_CPPFLAGS"
])# PGAC_CHECK_LLVM_FUNCTIONS
49 changes: 10 additions & 39 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5209,7 +5209,7 @@ if test "$with_llvm" = yes; then :


if test -z "$LLVM_CONFIG"; then
for ac_prog in llvm-config llvm-config-7 llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9
for ac_prog in llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
Expand Down Expand Up @@ -5273,16 +5273,16 @@ fi
as_fn_error $? "$LLVM_CONFIG does not work" "$LINENO" 5
fi
# and whether the version is supported
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 4 || ($1 == 3 && $2 >= 9)) exit 1; else exit 0;}';then
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required" "$LINENO" 5
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 10) exit 1; else exit 0;}';then
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: using llvm $pgac_llvm_version" >&5
$as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}

# need clang to create some bitcode files

if test -z "$CLANG"; then
for ac_prog in clang clang-7 clang-6.0 clang-5.0 clang-4.0 clang-3.9
for ac_prog in clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
Expand Down Expand Up @@ -16507,6 +16507,12 @@ esac
;;
esac

case " $LIBOBJS " in
*" win32gai_strerror.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS win32gai_strerror.$ac_objext"
;;
esac

case " $LIBOBJS " in
*" win32getrusage.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS win32getrusage.$ac_objext"
Expand Down Expand Up @@ -16665,41 +16671,6 @@ if test "$with_llvm" = yes; then
# Check which functionality is present
SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
ac_fn_c_check_decl "$LINENO" "LLVMOrcGetSymbolAddressIn" "ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" "#include <llvm-c/OrcBindings.h>
"
if test "x$ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi

cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN $ac_have_decl
_ACEOF

ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUName" "ac_cv_have_decl_LLVMGetHostCPUName" "#include <llvm-c/TargetMachine.h>
"
if test "x$ac_cv_have_decl_LLVMGetHostCPUName" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi

cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_LLVMGETHOSTCPUNAME $ac_have_decl
_ACEOF
ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUFeatures" "ac_cv_have_decl_LLVMGetHostCPUFeatures" "#include <llvm-c/TargetMachine.h>
"
if test "x$ac_cv_have_decl_LLVMGetHostCPUFeatures" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi

cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_LLVMGETHOSTCPUFEATURES $ac_have_decl
_ACEOF

ac_fn_c_check_decl "$LINENO" "LLVMCreateGDBRegistrationListener" "ac_cv_have_decl_LLVMCreateGDBRegistrationListener" "#include <llvm-c/ExecutionEngine.h>
"
if test "x$ac_cv_have_decl_LLVMCreateGDBRegistrationListener" = xyes; then :
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,7 @@ if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(win32env)
AC_LIBOBJ(win32error)
AC_LIBOBJ(win32fdatasync)
AC_LIBOBJ(win32gai_strerror)
AC_LIBOBJ(win32getrusage)
AC_LIBOBJ(win32link)
AC_LIBOBJ(win32ntdll)
Expand Down
2 changes: 2 additions & 0 deletions contrib/auto_explain/auto_explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
es->wal = (es->analyze && auto_explain_log_wal);
es->timing = (es->analyze && auto_explain_log_timing);
es->summary = es->analyze;
/* No support for MEMORY */
/* es->memory = false; */
es->format = auto_explain_log_format;
es->settings = auto_explain_log_settings;

Expand Down
2 changes: 1 addition & 1 deletion contrib/btree_gist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PGFILEDESC = "btree_gist - B-tree equivalent GiST operator classes"
REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz \
time timetz date interval macaddr macaddr8 inet cidr text varchar char \
bytea bit varbit numeric uuid not_equal enum bool partitions \
stratnum
stratnum without_overlaps

SHLIB_LINK += $(filter -lm, $(LIBS))

Expand Down
2 changes: 1 addition & 1 deletion contrib/btree_gist/btree_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ gbt_decompress(PG_FUNCTION_ARGS)
}

/*
* Returns the btree number for equals, otherwise invalid.
* Returns the btree number for supported operators, otherwise invalid.
*/
Datum
gist_stratnum_btree(PG_FUNCTION_ARGS)
Expand Down
44 changes: 44 additions & 0 deletions contrib/btree_gist/expected/without_overlaps.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Core must test WITHOUT OVERLAPS
-- with an int4range + daterange,
-- so here we do some simple tests
-- to make sure int + daterange works too,
-- since that is the expected use-case.
CREATE TABLE temporal_rng (
id integer,
valid_at daterange,
CONSTRAINT temporal_rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS)
);
\d temporal_rng
Table "public.temporal_rng"
Column | Type | Collation | Nullable | Default
----------+-----------+-----------+----------+---------
id | integer | | not null |
valid_at | daterange | | not null |
Indexes:
"temporal_rng_pk" PRIMARY KEY (id, valid_at WITHOUT OVERLAPS)

SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname = 'temporal_rng_pk';
pg_get_constraintdef
---------------------------------------------
PRIMARY KEY (id, valid_at WITHOUT OVERLAPS)
(1 row)

SELECT pg_get_indexdef(conindid, 0, true) FROM pg_constraint WHERE conname = 'temporal_rng_pk';
pg_get_indexdef
-------------------------------------------------------------------------------
CREATE UNIQUE INDEX temporal_rng_pk ON temporal_rng USING gist (id, valid_at)
(1 row)

INSERT INTO temporal_rng VALUES
(1, '[2000-01-01,2001-01-01)');
-- same key, doesn't overlap:
INSERT INTO temporal_rng VALUES
(1, '[2001-01-01,2002-01-01)');
-- overlaps but different key:
INSERT INTO temporal_rng VALUES
(2, '[2000-01-01,2001-01-01)');
-- should fail:
INSERT INTO temporal_rng VALUES
(1, '[2000-06-01,2001-01-01)');
ERROR: conflicting key value violates exclusion constraint "temporal_rng_pk"
DETAIL: Key (id, valid_at)=(1, [06-01-2000,01-01-2001)) conflicts with existing key (id, valid_at)=(1, [01-01-2000,01-01-2001)).
1 change: 1 addition & 0 deletions contrib/btree_gist/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ tests += {
'bool',
'partitions',
'stratnum',
'without_overlaps',
],
},
}
25 changes: 25 additions & 0 deletions contrib/btree_gist/sql/without_overlaps.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Core must test WITHOUT OVERLAPS
-- with an int4range + daterange,
-- so here we do some simple tests
-- to make sure int + daterange works too,
-- since that is the expected use-case.
CREATE TABLE temporal_rng (
id integer,
valid_at daterange,
CONSTRAINT temporal_rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS)
);
\d temporal_rng
SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname = 'temporal_rng_pk';
SELECT pg_get_indexdef(conindid, 0, true) FROM pg_constraint WHERE conname = 'temporal_rng_pk';

INSERT INTO temporal_rng VALUES
(1, '[2000-01-01,2001-01-01)');
-- same key, doesn't overlap:
INSERT INTO temporal_rng VALUES
(1, '[2001-01-01,2002-01-01)');
-- overlaps but different key:
INSERT INTO temporal_rng VALUES
(2, '[2000-01-01,2001-01-01)');
-- should fail:
INSERT INTO temporal_rng VALUES
(1, '[2000-06-01,2001-01-01)');
10 changes: 8 additions & 2 deletions contrib/pg_prewarm/autoprewarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ autoprewarm_main(Datum main_arg)
if (apw_init_shmem())
first_time = false;

/* Set on-detach hook so that our PID will be cleared on exit. */
on_shmem_exit(apw_detach_shmem, 0);
/*
* Set on-detach hook so that our PID will be cleared on exit.
*
* NB: Autoprewarm's state is stored in a DSM segment, and DSM segments
* are detached before calling the on_shmem_exit callbacks, so we must put
* apw_detach_shmem in the before_shmem_exit callback list.
*/
before_shmem_exit(apw_detach_shmem, 0);

/*
* Store our PID in the shared memory area --- unless there's already
Expand Down
6 changes: 6 additions & 0 deletions contrib/pg_prewarm/t/001_basic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@

$node->stop;

# control file should indicate normal shut down
command_like(
[ 'pg_controldata', $node->data_dir() ],
qr/Database cluster state:\s*shut down/,
'cluster shut down normally');

done_testing();
3 changes: 2 additions & 1 deletion contrib/pgcrypto/pgp-decrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ prefix_init(void **priv_p, void *arg, PullFilter *src)
uint8 tmpbuf[PGP_MAX_BLOCK + 2];

len = pgp_get_cipher_block_size(ctx->cipher_algo);
if (len > sizeof(tmpbuf))
/* Make sure we have space for prefix */
if (len > PGP_MAX_BLOCK)
return PXE_BUG;

res = pullf_read_max(src, len + 2, &buf, tmpbuf);
Expand Down
Loading

0 comments on commit fa4c4cf

Please sign in to comment.