Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
9dd067b
Fix range for commit_siblings in sample conf
danielgustafsson Nov 12, 2025
f756045
doc: Document effects of ownership change on privileges
danielgustafsson Nov 12, 2025
0402dde
Escalate ERRORs during async notify processing to FATAL
hlinnaka Nov 12, 2025
c03deb9
Fix bug where we truncated CLOG that was still needed by LISTEN/NOTIFY
hlinnaka Nov 12, 2025
868a047
Fix remaining race condition with CLOG truncation and LISTEN/NOTIFY
hlinnaka Nov 12, 2025
c2cbb8d
Clear 'xid' in dummy async notify entries written to fill up pages
hlinnaka Nov 12, 2025
76c8bba
doc: Improve description of RLS policies applied by command type.
deanrasheed Nov 13, 2025
a333cd5
Add note about CreateStatistics()'s selective use of check_rights.
nathan-bossart Nov 14, 2025
f83c2ba
Update .abi-compliance-history for change to CreateStatistics().
nathan-bossart Nov 17, 2025
5f3aae0
Define PS_USE_CLOBBER_ARGV on GNU/Hurd.
macdice Nov 17, 2025
62302cf
Don't allow CTEs to determine semantic levels of aggregates.
tglsfdc Nov 18, 2025
010128d
Print new OldestXID value in pg_resetwal when it's being changed
hlinnaka Nov 19, 2025
11c344b
jit: Adjust AArch64-only code for LLVM 21.
macdice Nov 22, 2025
6e75628
Fix incorrect IndexOptInfo header comment
david-rowley Nov 24, 2025
730d47f
lwlock: Fix, currently harmless, bug in LWLockWakeup()
anarazel Nov 24, 2025
905ea19
doc: Clarify passphrase command reloading on Windows
danielgustafsson Nov 26, 2025
9c7c256
Allow indexscans on partial hash indexes with implied quals.
tglsfdc Nov 27, 2025
cf16bcd
Avoid rewriting data-modifying CTEs more than once.
deanrasheed Nov 29, 2025
6f6c91c
Fix amcheck's handling of incomplete root splits in B-tree
hlinnaka Dec 2, 2025
c67b9e0
Fix amcheck's handling of half-dead B-tree pages
hlinnaka Dec 2, 2025
f576718
Set next multixid's offset when creating a new multixid
hlinnaka Dec 3, 2025
19d7016
Fix setting next multixid's offset at offset wraparound
hlinnaka Dec 5, 2025
5db0d4b
doc: Fix statement about ON CONFLICT and deferrable constraints.
deanrasheed Dec 9, 2025
87348cf
Fix allocation formula in llvmjit_expr.c
michaelpq Dec 11, 2025
6adf633
tests: Rename conflicting role names
anarazel Oct 5, 2022
e8164f6
Clarify comment on multixid offset wraparound check
hlinnaka Dec 15, 2025
91f5096
Fail recovery when missing redo checkpoint record without backup_label
michaelpq Dec 16, 2025
a8ce4b9
Switch memory contexts in ReinitializeParallelDSM.
robertmhaas Dec 16, 2025
f3c3f2b
Fix multibyte issue in ltree_strncasecmp().
jeff-davis Dec 16, 2025
5f8dc4f
For inplace update, send nontransactional invalidations.
nmisch Dec 17, 2025
f358f4e
WAL-log inplace update before revealing it to other sessions.
nmisch Dec 17, 2025
2aac753
Assert lack of hazardous buffer locks before possible catalog read.
nmisch Dec 17, 2025
46f4d51
Update .abi-compliance-history for PrepareToInvalidateCacheTuple().
nmisch Dec 17, 2025
c694816
Do not emit WAL for unlogged BRIN indexes
hlinnaka Dec 18, 2025
d55a2b0
Add guard to prevent recursive memory context logging.
MasaoFujii Dec 19, 2025
ac19bc9
Fix printf format string warning on MinGW.
macdice Dec 5, 2024
acd6225
Fix orphaned origin in shared memory after DROP SUBSCRIPTION
michaelpq Dec 23, 2025
b075de2
Fix bug in following update chain when locking a heap tuple
hlinnaka Dec 23, 2025
9e2c83a
doc: Remove duplicate word in ECPG description
michaelpq Dec 26, 2025
c8f7bfd
Fix pg_stat_get_backend_activity() to use multi-byte truncated result
michaelpq Dec 27, 2025
b56b103
jit: Remove -Wno-deprecated-declarations in 18+.
macdice Dec 30, 2025
7645c9b
Fix a race condition in updating procArray->replication_slot_xmin.
MasahikoSawada Dec 30, 2025
7048733
jit: Fix jit_profiling_support when unavailable.
macdice Dec 31, 2025
c228ea1
Update copyright for 2026
bmomjian Jan 1, 2026
67e480a
Fix selectivity estimation integer overflow in contrib/intarray
david-rowley Jan 4, 2026
e36c543
Doc: add missing punctuation
david-rowley Jan 4, 2026
4934d92
Fix issue with EVENT TRIGGERS and ALTER PUBLICATION
david-rowley Jan 6, 2026
ea26fc3
createuser: Update docs to reflect defaults
j-naylor Jan 7, 2026
810d695
Prevent invalidation of newly created replication slots.
Jan 8, 2026
e2427aa
Fix possible incorrect column reference in ERROR message
david-rowley Jan 8, 2026
d61cd8d
doc: Improve description of publish_via_partition_root
jchampio Jan 9, 2026
295b13b
Add check for invalid offset at multixid truncation
hlinnaka Jan 15, 2026
d8b194c
Fix 'unexpected data beyond EOF' on replica restart
hlinnaka Jan 15, 2026
27b66b2
Fix segfault from releasing locks in detached DSM segments
amitlan Jan 16, 2026
f0ed7fe
Fix error message related to end TLI in backup manifest
michaelpq Jan 18, 2026
f9a24ab
Update time zone data files to tzdata release 2025c.
tglsfdc Jan 18, 2026
d66e9b2
amcheck: Fix snapshot usage in bt_index_parent_check
alvherre Jan 21, 2026
dffcbb4
jit: Add missing inline pass for LLVM >= 17.
macdice Jan 22, 2026
566cef3
doc: Mention pg_get_partition_constraintdef()
michaelpq Jan 22, 2026
1a97a5b
Remove faulty Assert in partitioned INSERT...ON CONFLICT DO UPDATE.
tglsfdc Jan 22, 2026
67c80b4
Fix bogus ctid requirement for dummy-root partitioned targets
amitlan Jan 23, 2026
d14a13c
Improve guards against false regex matches in BackgroundPsql.pm.
tglsfdc Jan 30, 2026
74f8653
Fix various instances of undefined behavior
j-naylor Feb 4, 2026
acacafc
Fix some error message inconsistencies
michaelpq Feb 6, 2026
0d87380
Protect against small overread in SASLprep validation
jchampio Feb 6, 2026
1ae40b4
Further error message fix
petere Feb 7, 2026
7a750f9
Translation updates
petere Feb 8, 2026
11796ce
Release notes for 18.2, 17.8, 16.12, 15.16, 14.21.
tglsfdc Feb 8, 2026
119c990
pgcrypto: Fix buffer overflow in pgp_pub_decrypt_bytea()
michaelpq Feb 8, 2026
955b705
Fix encoding length for EUC_CN.
macdice Feb 4, 2026
970cf9a
Fix mb2wchar functions on short input.
macdice Jan 25, 2026
bf8829e
Replace pg_mblen() with bounds-checked versions.
macdice Jan 7, 2026
69b65c2
Code coverage for most pg_mblen* calls.
macdice Jan 11, 2026
695aea3
Require PGP-decrypted text to pass encoding validation.
nmisch Feb 9, 2026
e4ca229
Guard against unexpected dimensions of oidvector/int2vector.
tglsfdc Feb 9, 2026
3424f60
Add a syscache on pg_extension.oid.
tglsfdc Feb 9, 2026
dec30a7
Require superuser to install a non-built-in selectivity estimator.
tglsfdc Feb 9, 2026
423b427
Harden _int_matchsel() against being attached to the wrong operator.
tglsfdc Feb 9, 2026
3834b0f
Fix test "NUL byte in text decrypt" for --without-zlib builds.
nmisch Feb 9, 2026
4139000
Last-minute updates for release notes.
tglsfdc Feb 9, 2026
8ef47cb
Stamp 14.21.
tglsfdc Feb 9, 2026
285754f
doc: Clarify RLS policies applied for ON CONFLICT DO NOTHING.
deanrasheed Feb 11, 2026
8f8eee2
doc: Mention all SELECT privileges required by INSERT ... ON CONFLICT.
deanrasheed Feb 11, 2026
ef24024
Further stabilize a postgres_fdw test case.
tglsfdc Feb 11, 2026
59420f9
Fix pg_stat_get_backend_wait_event() for aux processes
hlinnaka Feb 11, 2026
4577c3f
Fix plpgsql's handling of "return simple_record_variable".
tglsfdc Feb 11, 2026
49db0e2
pg_mblen_range, pg_mblen_with_len: Valgrind after encoding ereport.
nmisch Feb 14, 2026
1fe20f0
Fix SUBSTRING() for toasted multibyte characters.
nmisch Feb 14, 2026
83071a9
pgcrypto: Tweak error message for incorrect session key length
michaelpq Feb 16, 2026
7695bb8
Don't reset 'latest_page_number' when replaying multixid truncation
hlinnaka Feb 16, 2026
de9135b
hstore: Fix NULL pointer dereference with receive function
michaelpq Feb 16, 2026
33aebee
Suppress new "may be used uninitialized" warning.
nmisch Feb 17, 2026
5702a96
Fix test_valid_server_encoding helper function.
macdice Feb 17, 2026
3f45cce
Release notes for 18.3, 17.9, 16.13, 15.17, 14.22.
tglsfdc Feb 22, 2026
c18df0b
Translation updates
petere Feb 23, 2026
b688398
Stamp 14.22.
tglsfdc Feb 23, 2026
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
16 changes: 16 additions & 0 deletions .abi-compliance-history
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
# Be sure to replace "<ADD JUSTIFICATION HERE>" with details of your change and
# why it is deemed acceptable.

8114224719401da8e30131310f1a227781cac6eb
#
# For inplace update, send nontransactional invalidations.
# 2025-12-16 16:13:56 -0800
#
# This changed PrepareToInvalidateCacheTuple() parameters. PGXN contained no
# calls to that function.

95cce56696867c7629d12c3ba1da8edd5bedaa8e
#
# Check for CREATE privilege on the schema in CREATE STATISTICS.
# 2025-11-10 09:00:00 -0600
#
# This commit added a parameter to CreateStatistics(). We are unaware of any
# impacted third-party code.

983b3636259b1502121cbae99d8a2f0d0515d87d
#
# Fix re-distributing previously distributed invalidation messages during logical decoding.
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PostgreSQL Database Management System
(also known as Postgres, formerly known as Postgres95)

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

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

Expand Down
18 changes: 9 additions & 9 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for PostgreSQL 14.20.
# Generated by GNU Autoconf 2.69 for PostgreSQL 14.22.
#
# Report bugs to <pgsql-bugs@lists.postgresql.org>.
#
Expand Down Expand Up @@ -582,8 +582,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='PostgreSQL'
PACKAGE_TARNAME='postgresql'
PACKAGE_VERSION='14.20'
PACKAGE_STRING='PostgreSQL 14.20'
PACKAGE_VERSION='14.22'
PACKAGE_STRING='PostgreSQL 14.22'
PACKAGE_BUGREPORT='pgsql-bugs@lists.postgresql.org'
PACKAGE_URL='https://www.postgresql.org/'

Expand Down Expand Up @@ -1443,7 +1443,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures PostgreSQL 14.20 to adapt to many kinds of systems.
\`configure' configures PostgreSQL 14.22 to adapt to many kinds of systems.

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

Expand Down Expand Up @@ -1508,7 +1508,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of PostgreSQL 14.20:";;
short | recursive ) echo "Configuration of PostgreSQL 14.22:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1679,7 +1679,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
PostgreSQL configure 14.20
PostgreSQL configure 14.22
generated by GNU Autoconf 2.69

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

It was created by PostgreSQL $as_me 14.20, which was
It was created by PostgreSQL $as_me 14.22, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -20677,7 +20677,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by PostgreSQL $as_me 14.20, which was
This file was extended by PostgreSQL $as_me 14.22, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -20748,7 +20748,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
PostgreSQL config.status 14.20
PostgreSQL config.status 14.22
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dnl Read the Autoconf manual for details.
dnl
m4_pattern_forbid(^PGAC_)dnl to catch undefined macros

AC_INIT([PostgreSQL], [14.20], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
AC_INIT([PostgreSQL], [14.22], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])

m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
Untested combinations of 'autoconf' and PostgreSQL versions are not
Expand Down
20 changes: 10 additions & 10 deletions contrib/adminpack/expected/adminpack.out
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ SELECT pg_read_file('test_file1');

-- disallowed file paths for non-superusers and users who are
-- not members of pg_write_server_files
CREATE ROLE regress_user1;
GRANT pg_read_all_settings TO regress_user1;
GRANT EXECUTE ON FUNCTION pg_file_write(text,text,bool) TO regress_user1;
SET ROLE regress_user1;
CREATE ROLE regress_adminpack_user1;
GRANT pg_read_all_settings TO regress_adminpack_user1;
GRANT EXECUTE ON FUNCTION pg_file_write(text,text,bool) TO regress_adminpack_user1;
SET ROLE regress_adminpack_user1;
SELECT pg_file_write('../test_file0', 'test0', false);
ERROR: path must be in or below the current directory
SELECT pg_file_write('/tmp/test_file0', 'test0', false);
Expand All @@ -53,9 +53,9 @@ SELECT pg_file_write(current_setting('data_directory') || '/test_file4', 'test4'
SELECT pg_file_write(current_setting('data_directory') || '/../test_file4', 'test4', false);
ERROR: reference to parent directory ("..") not allowed
RESET ROLE;
REVOKE EXECUTE ON FUNCTION pg_file_write(text,text,bool) FROM regress_user1;
REVOKE pg_read_all_settings FROM regress_user1;
DROP ROLE regress_user1;
REVOKE EXECUTE ON FUNCTION pg_file_write(text,text,bool) FROM regress_adminpack_user1;
REVOKE pg_read_all_settings FROM regress_adminpack_user1;
DROP ROLE regress_adminpack_user1;
-- sync
SELECT pg_file_sync('test_file1'); -- sync file
pg_file_sync
Expand Down Expand Up @@ -153,8 +153,8 @@ SELECT pg_file_unlink('test_file4');
(1 row)

-- superuser checks
CREATE USER regress_user1;
SET ROLE regress_user1;
CREATE USER regress_adminpack_user1;
SET ROLE regress_adminpack_user1;
SELECT pg_file_write('test_file0', 'test0', false);
ERROR: permission denied for function pg_file_write
SELECT pg_file_sync('test_file0');
Expand All @@ -167,6 +167,6 @@ ERROR: permission denied for function pg_file_unlink
SELECT pg_logdir_ls();
ERROR: permission denied for function pg_logdir_ls
RESET ROLE;
DROP USER regress_user1;
DROP USER regress_adminpack_user1;
-- no further tests for pg_logdir_ls() because it depends on the
-- server's logging setup
20 changes: 10 additions & 10 deletions contrib/adminpack/sql/adminpack.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ SELECT pg_read_file('test_file1');

-- disallowed file paths for non-superusers and users who are
-- not members of pg_write_server_files
CREATE ROLE regress_user1;
CREATE ROLE regress_adminpack_user1;

GRANT pg_read_all_settings TO regress_user1;
GRANT EXECUTE ON FUNCTION pg_file_write(text,text,bool) TO regress_user1;
GRANT pg_read_all_settings TO regress_adminpack_user1;
GRANT EXECUTE ON FUNCTION pg_file_write(text,text,bool) TO regress_adminpack_user1;

SET ROLE regress_user1;
SET ROLE regress_adminpack_user1;
SELECT pg_file_write('../test_file0', 'test0', false);
SELECT pg_file_write('/tmp/test_file0', 'test0', false);
SELECT pg_file_write(current_setting('data_directory') || '/test_file4', 'test4', false);
SELECT pg_file_write(current_setting('data_directory') || '/../test_file4', 'test4', false);
RESET ROLE;
REVOKE EXECUTE ON FUNCTION pg_file_write(text,text,bool) FROM regress_user1;
REVOKE pg_read_all_settings FROM regress_user1;
DROP ROLE regress_user1;
REVOKE EXECUTE ON FUNCTION pg_file_write(text,text,bool) FROM regress_adminpack_user1;
REVOKE pg_read_all_settings FROM regress_adminpack_user1;
DROP ROLE regress_adminpack_user1;

-- sync
SELECT pg_file_sync('test_file1'); -- sync file
Expand Down Expand Up @@ -59,8 +59,8 @@ SELECT pg_file_unlink('test_file4');


-- superuser checks
CREATE USER regress_user1;
SET ROLE regress_user1;
CREATE USER regress_adminpack_user1;
SET ROLE regress_adminpack_user1;

SELECT pg_file_write('test_file0', 'test0', false);
SELECT pg_file_sync('test_file0');
Expand All @@ -69,7 +69,7 @@ SELECT pg_file_unlink('test_file0');
SELECT pg_logdir_ls();

RESET ROLE;
DROP USER regress_user1;
DROP USER regress_adminpack_user1;


-- no further tests for pg_logdir_ls() because it depends on the
Expand Down
26 changes: 25 additions & 1 deletion contrib/amcheck/t/002_cic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PostgresNode;
use TestLib;

use Test::More tests => 3;
use Test::More;

my ($node, $result);

Expand Down Expand Up @@ -61,5 +61,29 @@
)
});

# Test bt_index_parent_check() with indexes created with
# CREATE INDEX CONCURRENTLY.
$node->safe_psql('postgres', q(CREATE TABLE quebec(i int primary key)));
# Insert two rows into index
$node->safe_psql('postgres',
q(INSERT INTO quebec SELECT i FROM generate_series(1, 2) s(i);));

# start background transaction
my $in_progress_h = $node->background_psql('postgres');
$in_progress_h->query_safe(q(BEGIN; SELECT pg_current_xact_id();));

# delete one row from table, while background transaction is in progress
$node->safe_psql('postgres', q(DELETE FROM quebec WHERE i = 1;));
# create index concurrently, which will skip the deleted row
$node->safe_psql('postgres',
q(CREATE INDEX CONCURRENTLY oscar ON quebec(i);));

# check index using bt_index_parent_check
$result = $node->psql('postgres',
q(SELECT bt_index_parent_check('oscar', heapallindexed => true)));
is($result, '0', 'bt_index_parent_check for CIC after removed row');

$in_progress_h->quit;

$node->stop;
done_testing();
73 changes: 33 additions & 40 deletions contrib/amcheck/verify_nbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
bool readonly, bool heapallindexed, bool rootdescend)
{
BtreeCheckState *state;
Snapshot snapshot = InvalidSnapshot;
Page metapage;
BTMetaPageData *metad;
uint32 previouslevel;
BtreeLevel current;
Snapshot snapshot = SnapshotAny;

if (!readonly)
elog(DEBUG1, "verifying consistency of tree structure for index \"%s\"",
Expand Down Expand Up @@ -515,37 +515,33 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
state->heaptuplespresent = 0;

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

/*
* GetTransactionSnapshot() always acquires a new MVCC snapshot in
* READ COMMITTED mode. A new snapshot is guaranteed to have all
* the entries it requires in the index.
*
* We must defend against the possibility that an old xact
* snapshot was returned at higher isolation levels when that
* snapshot is not safe for index scans of the target index. This
* is possible when the snapshot sees tuples that are before the
* index's indcheckxmin horizon. Throwing an error here should be
* very rare. It doesn't seem worth using a secondary snapshot to
* avoid this.
*/
if (IsolationUsesXactSnapshot() && rel->rd_index->indcheckxmin &&
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(rel->rd_indextuple->t_data),
snapshot->xmin))
ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
errmsg("index \"%s\" cannot be verified using transaction snapshot",
RelationGetRelationName(rel))));
}
/*
* GetTransactionSnapshot() always acquires a new MVCC snapshot in
* READ COMMITTED mode. A new snapshot is guaranteed to have all the
* entries it requires in the index.
*
* We must defend against the possibility that an old xact snapshot
* was returned at higher isolation levels when that snapshot is not
* safe for index scans of the target index. This is possible when
* the snapshot sees tuples that are before the index's indcheckxmin
* horizon. Throwing an error here should be very rare. It doesn't
* seem worth using a secondary snapshot to avoid this.
*/
if (IsolationUsesXactSnapshot() && rel->rd_index->indcheckxmin &&
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(rel->rd_indextuple->t_data),
snapshot->xmin))
ereport(ERROR,
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
errmsg("index \"%s\" cannot be verified using transaction snapshot",
RelationGetRelationName(rel)));
}

Assert(!state->rootdescend || state->readonly);
Expand Down Expand Up @@ -620,8 +616,7 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
/*
* Create our own scan for table_index_build_scan(), rather than
* getting it to do so for us. This is required so that we can
* actually use the MVCC snapshot registered earlier in !readonly
* case.
* actually use the MVCC snapshot registered earlier.
*
* Note that table_index_build_scan() calls heap_endscan() for us.
*/
Expand All @@ -634,16 +629,15 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,

/*
* Scan will behave as the first scan of a CREATE INDEX CONCURRENTLY
* behaves in !readonly case.
* behaves.
*
* It's okay that we don't actually use the same lock strength for the
* heap relation as any other ii_Concurrent caller would in !readonly
* case. We have no reason to care about a concurrent VACUUM
* operation, since there isn't going to be a second scan of the heap
* that needs to be sure that there was no concurrent recycling of
* TIDs.
* heap relation as any other ii_Concurrent caller would. We have no
* reason to care about a concurrent VACUUM operation, since there
* isn't going to be a second scan of the heap that needs to be sure
* that there was no concurrent recycling of TIDs.
*/
indexinfo->ii_Concurrent = !state->readonly;
indexinfo->ii_Concurrent = true;

/*
* Don't wait for uncommitted tuple xact commit/abort when index is a
Expand All @@ -667,13 +661,12 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
state->heaptuplespresent, RelationGetRelationName(heaprel),
100.0 * bloom_prop_bits_set(state->filter))));

if (snapshot != SnapshotAny)
UnregisterSnapshot(snapshot);

bloom_free(state->filter);
}

/* Be tidy: */
if (snapshot != InvalidSnapshot)
UnregisterSnapshot(snapshot);
MemoryContextDelete(state->targetcontext);
}

Expand Down Expand Up @@ -784,7 +777,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
errmsg("block %u is not leftmost in index \"%s\"",
current, RelationGetRelationName(state->rel))));

if (level.istruerootlevel && !P_ISROOT(opaque))
if (level.istruerootlevel && (!P_ISROOT(opaque) && !P_INCOMPLETE_SPLIT(opaque)))
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("block %u is not true root in index \"%s\"",
Expand Down Expand Up @@ -2047,7 +2040,7 @@ bt_child_highkey_check(BtreeCheckState *state,
* If we visit page with high key, check that it is equal to the
* target key next to corresponding downlink.
*/
if (!rightsplit && !P_RIGHTMOST(opaque))
if (!rightsplit && !P_RIGHTMOST(opaque) && !P_ISHALFDEAD(opaque))
{
BTPageOpaque topaque;
IndexTuple highkey;
Expand Down
Loading
Loading