Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
74b26c8
doc: Fix incorrect synopsis for ALTER PUBLICATION ... DROP ...
MasaoFujii Nov 12, 2025
97cd4b6
Fix pg_upgrade around multixid and mxoff wraparound
hlinnaka Nov 12, 2025
bec7853
Fix range for commit_siblings in sample conf
danielgustafsson Nov 12, 2025
608566b
doc: Document effects of ownership change on privileges
danielgustafsson Nov 12, 2025
b1da37d
Escalate ERRORs during async notify processing to FATAL
hlinnaka Nov 12, 2025
1a469d7
Fix bug where we truncated CLOG that was still needed by LISTEN/NOTIFY
hlinnaka Nov 12, 2025
0c86264
Fix remaining race condition with CLOG truncation and LISTEN/NOTIFY
hlinnaka Nov 12, 2025
21a9014
Clear 'xid' in dummy async notify entries written to fill up pages
hlinnaka Nov 12, 2025
c663152
doc: Improve description of RLS policies applied by command type.
deanrasheed Nov 13, 2025
d61af52
Add note about CreateStatistics()'s selective use of check_rights.
nathan-bossart Nov 14, 2025
5d5b05c
Doc: include MERGE in variable substitution command list
david-rowley Nov 16, 2025
ad5cc3a
Update .abi-compliance-history for change to CreateStatistics().
nathan-bossart Nov 17, 2025
3995e4a
Define PS_USE_CLOBBER_ARGV on GNU/Hurd.
macdice Nov 17, 2025
9f5a58a
Don't allow CTEs to determine semantic levels of aggregates.
tglsfdc Nov 18, 2025
7c49407
Print new OldestXID value in pg_resetwal when it's being changed
hlinnaka Nov 19, 2025
5516485
jit: Adjust AArch64-only code for LLVM 21.
macdice Nov 22, 2025
ea757e8
Fix incorrect IndexOptInfo header comment
david-rowley Nov 24, 2025
da39714
lwlock: Fix, currently harmless, bug in LWLockWakeup()
anarazel Nov 24, 2025
eb7743e
doc: Clarify passphrase command reloading on Windows
danielgustafsson Nov 26, 2025
f9f9283
doc: Fix misleading synopsis for CREATE/ALTER PUBLICATION.
MasaoFujii Nov 27, 2025
f19502f
Allow indexscans on partial hash indexes with implied quals.
tglsfdc Nov 27, 2025
134a8ee
Avoid rewriting data-modifying CTEs more than once.
deanrasheed Nov 29, 2025
721b58f
Fix amcheck's handling of incomplete root splits in B-tree
hlinnaka Dec 2, 2025
7792bdc
Fix amcheck's handling of half-dead B-tree pages
hlinnaka Dec 2, 2025
8cfb174
Set next multixid's offset when creating a new multixid
hlinnaka Dec 3, 2025
7e54eac
Show version of nodes in output of TAP tests
michaelpq Dec 5, 2025
b9a02b9
Fix setting next multixid's offset at offset wraparound
hlinnaka Dec 5, 2025
52a9588
Doc: fix typo in hash index documentation
david-rowley Dec 9, 2025
f188bc5
doc: Fix statement about ON CONFLICT and deferrable constraints.
deanrasheed Dec 9, 2025
07ddf61
Fix allocation formula in llvmjit_expr.c
michaelpq Dec 11, 2025
aa2ec04
tests: Rename conflicting role names
anarazel Oct 5, 2022
b0b52b7
Clarify comment on multixid offset wraparound check
hlinnaka Dec 15, 2025
95ef6f4
Fail recovery when missing redo checkpoint record without backup_label
michaelpq Dec 16, 2025
bd2726d
Switch memory contexts in ReinitializeParallelDSM.
robertmhaas Dec 16, 2025
335b2f3
Fix multibyte issue in ltree_strncasecmp().
jeff-davis Dec 16, 2025
fa7278e
Reorder two functions in inval.c
michaelpq Nov 7, 2023
05d605b
For inplace update, send nontransactional invalidations.
nmisch Dec 17, 2025
20a48c1
WAL-log inplace update before revealing it to other sessions.
nmisch Dec 17, 2025
8609120
Assert lack of hazardous buffer locks before possible catalog read.
nmisch Dec 17, 2025
d88f453
Update .abi-compliance-history for PrepareToInvalidateCacheTuple().
nmisch Dec 17, 2025
460d970
Do not emit WAL for unlogged BRIN indexes
hlinnaka Dec 18, 2025
0fc2f53
Add guard to prevent recursive memory context logging.
MasaoFujii Dec 19, 2025
1cf4f78
Fix printf format string warning on MinGW.
macdice Dec 5, 2024
90d1bee
Fix orphaned origin in shared memory after DROP SUBSCRIPTION
michaelpq Dec 23, 2025
5d5487c
Fix bug in following update chain when locking a heap tuple
hlinnaka Dec 23, 2025
7e16074
doc: Remove duplicate word in ECPG description
michaelpq Dec 26, 2025
300575f
Fix pg_stat_get_backend_activity() to use multi-byte truncated result
michaelpq Dec 27, 2025
c38f973
jit: Remove -Wno-deprecated-declarations in 18+.
macdice Dec 30, 2025
fa557d3
Fix a race condition in updating procArray->replication_slot_xmin.
MasahikoSawada Dec 30, 2025
4c8208c
jit: Fix jit_profiling_support when unavailable.
macdice Dec 31, 2025
176fd83
Update copyright for 2026
bmomjian Jan 1, 2026
c895104
Fix selectivity estimation integer overflow in contrib/intarray
david-rowley Jan 4, 2026
4ece441
Doc: add missing punctuation
david-rowley Jan 4, 2026
f7eb44e
Honor GUC settings specified in CREATE SUBSCRIPTION CONNECTION.
MasaoFujii Jan 6, 2026
ec8d91c
Add TAP test for GUC settings passed via CONNECTION in logical replic…
MasaoFujii Jan 6, 2026
f20b790
Fix issue with EVENT TRIGGERS and ALTER PUBLICATION
david-rowley Jan 6, 2026
c813007
createuser: Update docs to reflect defaults
j-naylor Jan 7, 2026
39a6a2c
Fix typo
petere Jan 7, 2026
aae0562
Prevent invalidation of newly created replication slots.
Jan 8, 2026
3ad0564
Fix possible incorrect column reference in ERROR message
david-rowley Jan 8, 2026
988612c
doc: Improve description of publish_via_partition_root
jchampio Jan 9, 2026
a563ac6
Add check for invalid offset at multixid truncation
hlinnaka Jan 15, 2026
ef84655
Fix 'unexpected data beyond EOF' on replica restart
hlinnaka Jan 15, 2026
b926ff1
Fix segfault from releasing locks in detached DSM segments
amitlan Jan 16, 2026
fbf8df5
Fix error message related to end TLI in backup manifest
michaelpq Jan 18, 2026
00410b7
Update time zone data files to tzdata release 2025c.
tglsfdc Jan 18, 2026
dcddd69
amcheck: Fix snapshot usage in bt_index_parent_check
alvherre Jan 21, 2026
cbdd09a
jit: Add missing inline pass for LLVM >= 17.
macdice Jan 22, 2026
83172d9
doc: Mention pg_get_partition_constraintdef()
michaelpq Jan 22, 2026
7eb3422
Remove faulty Assert in partitioned INSERT...ON CONFLICT DO UPDATE.
tglsfdc Jan 22, 2026
687533b
Fix bogus ctid requirement for dummy-root partitioned targets
amitlan Jan 23, 2026
c582453
Fix trigger transition table capture for MERGE in CTE queries.
deanrasheed Jan 24, 2026
7023650
Update .abi-compliance-history for change to TransitionCaptureState.
deanrasheed Jan 30, 2026
bb6aede
Improve guards against false regex matches in BackgroundPsql.pm.
tglsfdc Jan 30, 2026
6b81a1c
Fix various instances of undefined behavior
j-naylor Feb 4, 2026
d242881
Fix logical replication TAP test to read publisher log correctly.
MasaoFujii Feb 4, 2026
4ec943f
Fix some error message inconsistencies
michaelpq Feb 6, 2026
ff1d581
Protect against small overread in SASLprep validation
jchampio Feb 6, 2026
9dcd0b3
Further error message fix
petere Feb 7, 2026
221a642
Translation updates
petere Feb 8, 2026
0a98185
Release notes for 18.2, 17.8, 16.12, 15.16, 14.21.
tglsfdc Feb 8, 2026
9a9982e
pgcrypto: Fix buffer overflow in pgp_pub_decrypt_bytea()
michaelpq Feb 8, 2026
b2c81ac
Fix encoding length for EUC_CN.
macdice Feb 4, 2026
50863be
Fix mb2wchar functions on short input.
macdice Jan 25, 2026
fd82ddb
Replace pg_mblen() with bounds-checked versions.
macdice Jan 7, 2026
757bf81
Code coverage for most pg_mblen* calls.
macdice Jan 11, 2026
8f8b1ff
Require PGP-decrypted text to pass encoding validation.
nmisch Feb 9, 2026
429aeae
Guard against unexpected dimensions of oidvector/int2vector.
tglsfdc Feb 9, 2026
3ecc84c
Add a syscache on pg_extension.oid.
tglsfdc Feb 9, 2026
b764b26
Require superuser to install a non-built-in selectivity estimator.
tglsfdc Feb 9, 2026
deb464a
Harden _int_matchsel() against being attached to the wrong operator.
tglsfdc Feb 9, 2026
6f741bc
Fix test "NUL byte in text decrypt" for --without-zlib builds.
nmisch Feb 9, 2026
749e616
Last-minute updates for release notes.
tglsfdc Feb 9, 2026
78bc85d
Stamp 15.16.
tglsfdc Feb 9, 2026
919598f
Update Postgres 15 to 15.16
thesuhas Feb 11, 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
27 changes: 27 additions & 0 deletions .abi-compliance-history
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,33 @@
# Be sure to replace "<ADD JUSTIFICATION HERE>" with details of your change and
# why it is deemed acceptable.

c5824536e7ca3c5ef5a9db59bd36c4e6beb23f51
#
# Fix trigger transition table capture for MERGE in CTE queries.
# 2026-01-24 11:30:51 +0000
#
# This commit changed the TransitionCaptureState structure, replacing
# the "tcs_private" field with 3 separate fields. This structure can
# only be built using MakeTransitionCaptureState(), and PGXN contained
# no calls to MakeTransitionCaptureState() or uses of the
# TransitionCaptureState structure.

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

2393d374ae9c0bc8327adc80fe4490edb05be167
#
# 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.

fc0fb77c550fe8289d718c33c7aacf16023d9941
#
# Fix re-distributing previously distributed invalidation messages during logical decoding.
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ task:
env:
CPUS: 4 # always get that much for cirrusci macOS instances
BUILD_JOBS: $CPUS
# Test performance regresses noticably when using all cores. 8 seems to
# Test performance regresses noticeably when using all cores. 8 seems to
# work OK. See
# https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de
TEST_JOBS: 8
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 15.15.
# Generated by GNU Autoconf 2.69 for PostgreSQL 15.16.
#
# 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='15.15'
PACKAGE_STRING='PostgreSQL 15.15'
PACKAGE_VERSION='15.16'
PACKAGE_STRING='PostgreSQL 15.16'
PACKAGE_BUGREPORT='pgsql-bugs@lists.postgresql.org'
PACKAGE_URL='https://www.postgresql.org/'

Expand Down Expand Up @@ -1454,7 +1454,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 15.15 to adapt to many kinds of systems.
\`configure' configures PostgreSQL 15.16 to adapt to many kinds of systems.

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

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

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

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

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2447,7 +2447,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 15.15, which was
It was created by PostgreSQL $as_me 15.16, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -21018,7 +21018,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 15.15, which was
This file was extended by PostgreSQL $as_me 15.16, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -21089,7 +21089,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 15.15
PostgreSQL config.status 15.16
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], [15.15], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
AC_INIT([PostgreSQL], [15.16], [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: absolute path 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
24 changes: 24 additions & 0 deletions contrib/amcheck/t/002_cic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,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();
69 changes: 31 additions & 38 deletions contrib/amcheck/verify_nbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,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 @@ -516,37 +516,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 @@ -621,8 +617,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 @@ -635,16 +630,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 @@ -668,13 +662,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
Loading