Skip to content

Commit 4a226f7

Browse files
authored
Merge pull request IvorySQL#1195 from hs-liuxh/merge/pg1802-into-v502
Sync IvorySQL v5.2 with PostgreSQL 18.2
2 parents 30527cc + 97ba68c commit 4a226f7

File tree

501 files changed

+49739
-33904
lines changed

Some content is hidden

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

501 files changed

+49739
-33904
lines changed

.abi-compliance-history

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,52 @@
1818
# Be sure to replace "<ADD JUSTIFICATION HERE>" with details of your change and
1919
# why it is deemed acceptable.
2020

21+
33e3de6d77e87d6c3c6f8f878dd8de42d37c3b8f
22+
#
23+
# Add file_extend_method=posix_fallocate,write_zeros.
24+
# 2026-02-06 17:38:39 +1300
25+
#
26+
# Modifying GUC tables isn't really an ABI break: the relevant object has
27+
# incomplete type so its layout is unknown to other C translation units.
28+
#
29+
# Discussion: https://www.postgresql.org/message-id/flat/e1f0cd3b-0164-45f5-9705-e922e59df90f%40dunslane.net#8a350b54012c0042f9869d288e978cfe
30+
31+
492a69e1407029f8c673484f44aa719a63323d77
32+
#
33+
# Reject ADD CONSTRAINT NOT NULL if name mismatches existing constraint
34+
# 2026-02-03 12:33:29 +0100
35+
#
36+
# This commit added the constraint name as a parameter to
37+
# AdjustNotNullInheritance(), which it needed to verify that the new name
38+
# matches the existing one. PGXN contained no calls to that function.
39+
40+
c6ce4dcf9d3b7a8a89aca386124c473f98fc329e
41+
#
42+
# Fix trigger transition table capture for MERGE in CTE queries.
43+
# 2026-01-24 11:30:48 +0000
44+
#
45+
# This commit changed the TransitionCaptureState structure, replacing
46+
# the "tcs_private" field with 3 separate fields. This structure can
47+
# only be built using MakeTransitionCaptureState(), and PGXN contained
48+
# no calls to MakeTransitionCaptureState() or uses of the
49+
# TransitionCaptureState structure.
50+
51+
bae8ca82fd00603ebafa0658640d6e4dfe20af92
52+
#
53+
# Revisit cosmetics of "For inplace update, send nontransactional invalidations."
54+
# 2025-12-15 12:19:53 -0800
55+
#
56+
# This removed a CacheInvalidateHeapTupleInplace() parameter. PGXN contained
57+
# no calls to that function.
58+
59+
00eb646ea43410e5df77fed96f4a981e66811796
60+
#
61+
# Check for CREATE privilege on the schema in CREATE STATISTICS.
62+
# 2025-11-10 09:00:00 -0600
63+
#
64+
# This commit added a parameter to CreateStatistics(). We are unaware of any
65+
# impacted third-party code.
66+
2167
c8af5019bee5c57502db830f8005a01cba60fee0
2268
#
2369
# Fix lookups in pg_{clear,restore}_{attribute,relation}_stats().

.cirrus.tasks.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,6 @@ task:
340340
su postgres <<-EOF
341341
set -e
342342
ulimit -c unlimited
343-
# Otherwise tests will fail on OpenBSD, due to inability to start enough
344-
# processes.
345-
ulimit -p 256
346343
meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
347344
EOF
348345
@@ -596,7 +593,7 @@ task:
596593
env:
597594
CPUS: 4 # always get that much for cirrusci macOS instances
598595
BUILD_JOBS: $CPUS
599-
# Test performance regresses noticably when using all cores. 8 seems to
596+
# Test performance regresses noticeably when using all cores. 8 seems to
600597
# work OK. See
601598
# https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de
602599
TEST_JOBS: 8

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
(also known as Postgres, formerly known as Postgres95)
33

4-
Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
4+
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
55

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

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.69 for PostgreSQL 18.1.
3+
# Generated by GNU Autoconf 2.69 for PostgreSQL 18.2.
44
#
55
# Report bugs to <pgsql-bugs@lists.postgresql.org>.
66
#
@@ -583,8 +583,8 @@ MAKEFLAGS=
583583
# Identity of this package.
584584
PACKAGE_NAME='PostgreSQL'
585585
PACKAGE_TARNAME='postgresql'
586-
PACKAGE_VERSION='18.1'
587-
PACKAGE_STRING='PostgreSQL 18.1'
586+
PACKAGE_VERSION='18.2'
587+
PACKAGE_STRING='PostgreSQL 18.2'
588588
PACKAGE_BUGREPORT='pgsql-bugs@lists.postgresql.org'
589589
PACKAGE_URL='https://www.postgresql.org/'
590590

@@ -1473,7 +1473,7 @@ if test "$ac_init_help" = "long"; then
14731473
# Omit some internal or obsolete options to make the list less imposing.
14741474
# This message is too long to be a string in the A/UX 3.1 sh.
14751475
cat <<_ACEOF
1476-
\`configure' configures PostgreSQL 18.1 to adapt to many kinds of systems.
1476+
\`configure' configures PostgreSQL 18.2 to adapt to many kinds of systems.
14771477

14781478
Usage: $0 [OPTION]... [VAR=VALUE]...
14791479

@@ -1538,7 +1538,7 @@ fi
15381538

15391539
if test -n "$ac_init_help"; then
15401540
case $ac_init_help in
1541-
short | recursive ) echo "Configuration of PostgreSQL 18.1:";;
1541+
short | recursive ) echo "Configuration of PostgreSQL 18.2:";;
15421542
esac
15431543
cat <<\_ACEOF
15441544

@@ -1733,7 +1733,7 @@ fi
17331733
test -n "$ac_init_help" && exit $ac_status
17341734
if $ac_init_version; then
17351735
cat <<\_ACEOF
1736-
PostgreSQL configure 18.1
1736+
PostgreSQL configure 18.2
17371737
generated by GNU Autoconf 2.69
17381738

17391739
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2486,7 +2486,7 @@ cat >config.log <<_ACEOF
24862486
This file contains any messages produced by compilers while
24872487
running configure, to aid debugging if configure makes a mistake.
24882488

2489-
It was created by PostgreSQL $as_me 18.1, which was
2489+
It was created by PostgreSQL $as_me 18.2, which was
24902490
generated by GNU Autoconf 2.69. Invocation command line was
24912491

24922492
$ $0 $@
@@ -20246,7 +20246,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
2024620246
# report actual input values of CONFIG_FILES etc. instead of their
2024720247
# values after options handling.
2024820248
ac_log="
20249-
This file was extended by PostgreSQL $as_me 18.1, which was
20249+
This file was extended by PostgreSQL $as_me 18.2, which was
2025020250
generated by GNU Autoconf 2.69. Invocation command line was
2025120251

2025220252
CONFIG_FILES = $CONFIG_FILES
@@ -20317,7 +20317,7 @@ _ACEOF
2031720317
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
2031820318
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
2031920319
ac_cs_version="\\
20320-
PostgreSQL config.status 18.1
20320+
PostgreSQL config.status 18.2
2032120321
configured by $0, generated by GNU Autoconf 2.69,
2032220322
with options \\"\$ac_cs_config\\"
2032320323

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dnl Read the Autoconf manual for details.
1717
dnl
1818
m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
1919

20-
AC_INIT([PostgreSQL], [18.1], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
20+
AC_INIT([PostgreSQL], [18.2], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
2121

2222
m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
2323
Untested combinations of 'autoconf' and PostgreSQL versions are not

contrib/amcheck/t/002_cic.pl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,29 @@
6464
)
6565
});
6666

67+
# Test bt_index_parent_check() with indexes created with
68+
# CREATE INDEX CONCURRENTLY.
69+
$node->safe_psql('postgres', q(CREATE TABLE quebec(i int primary key)));
70+
# Insert two rows into index
71+
$node->safe_psql('postgres',
72+
q(INSERT INTO quebec SELECT i FROM generate_series(1, 2) s(i);));
73+
74+
# start background transaction
75+
my $in_progress_h = $node->background_psql('postgres');
76+
$in_progress_h->query_safe(q(BEGIN; SELECT pg_current_xact_id();));
77+
78+
# delete one row from table, while background transaction is in progress
79+
$node->safe_psql('postgres', q(DELETE FROM quebec WHERE i = 1;));
80+
# create index concurrently, which will skip the deleted row
81+
$node->safe_psql('postgres',
82+
q(CREATE INDEX CONCURRENTLY oscar ON quebec(i);));
83+
84+
# check index using bt_index_parent_check
85+
my $result = $node->psql('postgres',
86+
q(SELECT bt_index_parent_check('oscar', heapallindexed => true)));
87+
is($result, '0', 'bt_index_parent_check for CIC after removed row');
88+
89+
$in_progress_h->quit;
90+
6791
$node->stop;
6892
done_testing();

contrib/amcheck/verify_nbtree.c

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ typedef struct BtreeCheckState
9292
BufferAccessStrategy checkstrategy;
9393

9494
/*
95-
* Info for uniqueness checking. Fill these fields once per index check.
95+
* Info for uniqueness checking. Fill this field and the one below once
96+
* per index check.
9697
*/
9798
IndexInfo *indexinfo;
99+
/* Table scan snapshot for heapallindexed and checkunique */
98100
Snapshot snapshot;
99101

100102
/*
@@ -382,7 +384,6 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
382384
BTMetaPageData *metad;
383385
uint32 previouslevel;
384386
BtreeLevel current;
385-
Snapshot snapshot = SnapshotAny;
386387

387388
if (!readonly)
388389
elog(DEBUG1, "verifying consistency of tree structure for index \"%s\"",
@@ -433,54 +434,46 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
433434
state->heaptuplespresent = 0;
434435

435436
/*
436-
* Register our own snapshot in !readonly case, rather than asking
437+
* Register our own snapshot for heapallindexed, rather than asking
437438
* table_index_build_scan() to do this for us later. This needs to
438439
* happen before index fingerprinting begins, so we can later be
439440
* certain that index fingerprinting should have reached all tuples
440441
* returned by table_index_build_scan().
441442
*/
442-
if (!state->readonly)
443-
{
444-
snapshot = RegisterSnapshot(GetTransactionSnapshot());
443+
state->snapshot = RegisterSnapshot(GetTransactionSnapshot());
445444

446-
/*
447-
* GetTransactionSnapshot() always acquires a new MVCC snapshot in
448-
* READ COMMITTED mode. A new snapshot is guaranteed to have all
449-
* the entries it requires in the index.
450-
*
451-
* We must defend against the possibility that an old xact
452-
* snapshot was returned at higher isolation levels when that
453-
* snapshot is not safe for index scans of the target index. This
454-
* is possible when the snapshot sees tuples that are before the
455-
* index's indcheckxmin horizon. Throwing an error here should be
456-
* very rare. It doesn't seem worth using a secondary snapshot to
457-
* avoid this.
458-
*/
459-
if (IsolationUsesXactSnapshot() && rel->rd_index->indcheckxmin &&
460-
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(rel->rd_indextuple->t_data),
461-
snapshot->xmin))
462-
ereport(ERROR,
463-
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
464-
errmsg("index \"%s\" cannot be verified using transaction snapshot",
465-
RelationGetRelationName(rel))));
466-
}
445+
/*
446+
* GetTransactionSnapshot() always acquires a new MVCC snapshot in
447+
* READ COMMITTED mode. A new snapshot is guaranteed to have all the
448+
* entries it requires in the index.
449+
*
450+
* We must defend against the possibility that an old xact snapshot
451+
* was returned at higher isolation levels when that snapshot is not
452+
* safe for index scans of the target index. This is possible when
453+
* the snapshot sees tuples that are before the index's indcheckxmin
454+
* horizon. Throwing an error here should be very rare. It doesn't
455+
* seem worth using a secondary snapshot to avoid this.
456+
*/
457+
if (IsolationUsesXactSnapshot() && rel->rd_index->indcheckxmin &&
458+
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(rel->rd_indextuple->t_data),
459+
state->snapshot->xmin))
460+
ereport(ERROR,
461+
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
462+
errmsg("index \"%s\" cannot be verified using transaction snapshot",
463+
RelationGetRelationName(rel)));
467464
}
468465

469466
/*
470-
* We need a snapshot to check the uniqueness of the index. For better
471-
* performance take it once per index check. If snapshot already taken
472-
* reuse it.
467+
* We need a snapshot to check the uniqueness of the index. For better
468+
* performance, take it once per index check. If one was already taken
469+
* above, use that.
473470
*/
474471
if (state->checkunique)
475472
{
476473
state->indexinfo = BuildIndexInfo(state->rel);
477-
if (state->indexinfo->ii_Unique)
478-
{
479-
if (snapshot != SnapshotAny)
480-
state->snapshot = snapshot;
481-
else
482-
state->snapshot = RegisterSnapshot(GetTransactionSnapshot());
483-
}
474+
475+
if (state->indexinfo->ii_Unique && state->snapshot == InvalidSnapshot)
476+
state->snapshot = RegisterSnapshot(GetTransactionSnapshot());
484477
}
485478

486479
Assert(!state->rootdescend || state->readonly);
@@ -555,30 +548,28 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
555548
/*
556549
* Create our own scan for table_index_build_scan(), rather than
557550
* getting it to do so for us. This is required so that we can
558-
* actually use the MVCC snapshot registered earlier in !readonly
559-
* case.
551+
* actually use the MVCC snapshot registered earlier.
560552
*
561553
* Note that table_index_build_scan() calls heap_endscan() for us.
562554
*/
563555
scan = table_beginscan_strat(state->heaprel, /* relation */
564-
snapshot, /* snapshot */
556+
state->snapshot, /* snapshot */
565557
0, /* number of keys */
566558
NULL, /* scan key */
567559
true, /* buffer access strategy OK */
568560
true); /* syncscan OK? */
569561

570562
/*
571563
* Scan will behave as the first scan of a CREATE INDEX CONCURRENTLY
572-
* behaves in !readonly case.
564+
* behaves.
573565
*
574566
* It's okay that we don't actually use the same lock strength for the
575-
* heap relation as any other ii_Concurrent caller would in !readonly
576-
* case. We have no reason to care about a concurrent VACUUM
577-
* operation, since there isn't going to be a second scan of the heap
578-
* that needs to be sure that there was no concurrent recycling of
579-
* TIDs.
567+
* heap relation as any other ii_Concurrent caller would. We have no
568+
* reason to care about a concurrent VACUUM operation, since there
569+
* isn't going to be a second scan of the heap that needs to be sure
570+
* that there was no concurrent recycling of TIDs.
580571
*/
581-
indexinfo->ii_Concurrent = !state->readonly;
572+
indexinfo->ii_Concurrent = true;
582573

583574
/*
584575
* Don't wait for uncommitted tuple xact commit/abort when index is a
@@ -602,14 +593,11 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
602593
state->heaptuplespresent, RelationGetRelationName(heaprel),
603594
100.0 * bloom_prop_bits_set(state->filter))));
604595

605-
if (snapshot != SnapshotAny)
606-
UnregisterSnapshot(snapshot);
607-
608596
bloom_free(state->filter);
609597
}
610598

611599
/* Be tidy: */
612-
if (snapshot == SnapshotAny && state->snapshot != InvalidSnapshot)
600+
if (state->snapshot != InvalidSnapshot)
613601
UnregisterSnapshot(state->snapshot);
614602
MemoryContextDelete(state->targetcontext);
615603
}
@@ -721,7 +709,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
721709
errmsg("block %u is not leftmost in index \"%s\"",
722710
current, RelationGetRelationName(state->rel))));
723711

724-
if (level.istruerootlevel && !P_ISROOT(opaque))
712+
if (level.istruerootlevel && (!P_ISROOT(opaque) && !P_INCOMPLETE_SPLIT(opaque)))
725713
ereport(ERROR,
726714
(errcode(ERRCODE_INDEX_CORRUPTED),
727715
errmsg("block %u is not true root in index \"%s\"",
@@ -2270,7 +2258,7 @@ bt_child_highkey_check(BtreeCheckState *state,
22702258
* If we visit page with high key, check that it is equal to the
22712259
* target key next to corresponding downlink.
22722260
*/
2273-
if (!rightsplit && !P_RIGHTMOST(opaque))
2261+
if (!rightsplit && !P_RIGHTMOST(opaque) && !P_ISHALFDEAD(opaque))
22742262
{
22752263
BTPageOpaque topaque;
22762264
IndexTuple highkey;

0 commit comments

Comments
 (0)