Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
953c069
Add check for large files in meson.build
michaelpq Nov 12, 2025
3029955
Report better object limits in error messages for injection points
michaelpq Nov 12, 2025
85d4da5
doc: Fix incorrect synopsis for ALTER PUBLICATION ... DROP ...
MasaoFujii Nov 12, 2025
7c3c6e5
Fix pg_upgrade around multixid and mxoff wraparound
hlinnaka Nov 12, 2025
f4e1b88
Fix range for commit_siblings in sample conf
danielgustafsson Nov 12, 2025
c2b6ae4
doc: Document effects of ownership change on privileges
danielgustafsson Nov 12, 2025
fb648f6
Escalate ERRORs during async notify processing to FATAL
hlinnaka Nov 12, 2025
0dc27b9
Fix bug where we truncated CLOG that was still needed by LISTEN/NOTIFY
hlinnaka Nov 12, 2025
40768da
Fix remaining race condition with CLOG truncation and LISTEN/NOTIFY
hlinnaka Nov 12, 2025
383cc4a
Clear 'xid' in dummy async notify entries written to fill up pages
hlinnaka Nov 12, 2025
c6500a7
Teach DSM registry to ERROR if attaching to an uninitialized entry.
nathan-bossart Nov 12, 2025
8412b65
doc: Improve description of RLS policies applied by command type.
deanrasheed Nov 13, 2025
eedbad9
pgbench: Fix assertion failure with multiple \syncpipeline in pipelin…
MasaoFujii Nov 14, 2025
07f00bc
Add note about CreateStatistics()'s selective use of check_rights.
nathan-bossart Nov 14, 2025
4f23706
Doc: include MERGE in variable substitution command list
david-rowley Nov 16, 2025
b653511
Fix Assert failure in EXPLAIN ANALYZE MERGE with a concurrent update.
deanrasheed Nov 16, 2025
a2852fd
Define PS_USE_CLOBBER_ARGV on GNU/Hurd.
macdice Nov 16, 2025
9c9a258
Update .abi-compliance-history for change to CreateStatistics().
nathan-bossart Nov 17, 2025
64cb578
Don't allow CTEs to determine semantic levels of aggregates.
tglsfdc Nov 18, 2025
82b14a8
Print new OldestXID value in pg_resetwal when it's being changed
hlinnaka Nov 19, 2025
e65ad51
jit: Adjust AArch64-only code for LLVM 21.
macdice Nov 22, 2025
8dcd1bf
Fix incorrect IndexOptInfo header comment
david-rowley Nov 24, 2025
bc18f7f
lwlock: Fix, currently harmless, bug in LWLockWakeup()
anarazel Nov 24, 2025
8397a18
doc: Clarify passphrase command reloading on Windows
danielgustafsson Nov 26, 2025
61d055d
Revert "Teach DSM registry to ERROR if attaching to an uninitialized …
nathan-bossart Nov 26, 2025
8f05a79
Teach DSM registry to retry entry initialization if needed.
nathan-bossart Nov 26, 2025
140669e
Fix error reporting for SQL/JSON path type mismatches
amitlan Nov 27, 2025
c866bac
doc: Fix misleading synopsis for CREATE/ALTER PUBLICATION.
MasaoFujii Nov 27, 2025
dfb1f37
Allow indexscans on partial hash indexes with implied quals.
tglsfdc Nov 27, 2025
c6253e6
Avoid rewriting data-modifying CTEs more than once.
deanrasheed Nov 29, 2025
1260d08
Fix amcheck's handling of incomplete root splits in B-tree
hlinnaka Dec 2, 2025
f13548b
Fix amcheck's handling of half-dead B-tree pages
hlinnaka Dec 2, 2025
1939a88
Set next multixid's offset when creating a new multixid
hlinnaka Dec 3, 2025
30c7a7d
amcheck: Fix snapshot usage in bt_index_parent_check
alvherre Dec 4, 2025
3e428b8
Show version of nodes in output of TAP tests
michaelpq Dec 5, 2025
8cc8e78
Fix setting next multixid's offset at offset wraparound
hlinnaka Dec 5, 2025
1611406
Doc: fix typo in hash index documentation
david-rowley Dec 9, 2025
55f84d5
Fix LOCK_TIMEOUT handling in slotsync worker.
Dec 9, 2025
90bd60d
doc: Fix statement about ON CONFLICT and deferrable constraints.
deanrasheed Dec 9, 2025
9fd2bd5
Fix O_CLOEXEC flag handling in Windows port.
macdice Dec 9, 2025
2e09fa3
Fix failures with cross-version pg_upgrade tests
michaelpq Dec 10, 2025
b65cc89
Fix some near-bugs related to ResourceOwner function arguments
hlinnaka Dec 10, 2025
6298bd7
Fix bogus extra arguments to query_safe in test
hlinnaka Dec 10, 2025
36fe1a9
Fix allocation formula in llvmjit_expr.c
michaelpq Dec 11, 2025
73706f3
Clarify comment on multixid offset wraparound check
hlinnaka Dec 15, 2025
8f395cb
Fail recovery when missing redo checkpoint record without backup_label
michaelpq Dec 16, 2025
3f4ef38
Switch memory contexts in ReinitializeParallelDSM.
robertmhaas Dec 16, 2025
8f4a8a5
Fix multibyte issue in ltree_strncasecmp().
jeff-davis Dec 16, 2025
9ac093d
For inplace update, send nontransactional invalidations.
nmisch Dec 17, 2025
ccf1a47
WAL-log inplace update before revealing it to other sessions.
nmisch Dec 17, 2025
3a5d01e
Assert lack of hazardous buffer locks before possible catalog read.
nmisch Dec 17, 2025
4169748
Update .abi-compliance-history for PrepareToInvalidateCacheTuple().
nmisch Dec 17, 2025
e74a910
Do not emit WAL for unlogged BRIN indexes
hlinnaka Dec 18, 2025
60f39f9
Sort DO_SUBSCRIPTION_REL dump objects independent of OIDs.
nmisch Dec 18, 2025
0604ae6
Add guard to prevent recursive memory context logging.
MasaoFujii Dec 19, 2025
a0f1cbb
Clean up test_cloexec.c and Makefile.
macdice Dec 21, 2025
b924aa4
Fix printf format string warning on MinGW.
macdice Dec 5, 2024
d3cf0fd
Fix orphaned origin in shared memory after DROP SUBSCRIPTION
michaelpq Dec 23, 2025
f7bb024
Add missing .gitignore for src/test/modules/test_cloexec.
tglsfdc Dec 22, 2025
fc82eb8
Fix bug in following update chain when locking a heap tuple
hlinnaka Dec 23, 2025
ff1c1c8
Don't advance origin during apply failure.
Dec 24, 2025
364b5da
Update comments to reflect changes in 8e0d32a4a1.
Dec 24, 2025
f2cc24b
doc: Remove duplicate word in ECPG description
michaelpq Dec 26, 2025
f5b2497
doc: warn about the use of "ctid" queries beyond the examples
bmomjian Dec 26, 2025
db9174f
Fix pg_stat_get_backend_activity() to use multi-byte truncated result
michaelpq Dec 27, 2025
d0283da
Fix Mkvcbuild.pm builds of test_cloexec.c.
macdice Dec 29, 2025
9e60748
jit: Remove -Wno-deprecated-declarations in 18+.
macdice Dec 30, 2025
f1928ba
Fix a race condition in updating procArray->replication_slot_xmin.
MasahikoSawada Dec 30, 2025
cd93481
jit: Fix jit_profiling_support when unavailable.
macdice Dec 31, 2025
3c08622
Update copyright for 2026
bmomjian Jan 1, 2026
bc69a45
Fix selectivity estimation integer overflow in contrib/intarray
david-rowley Jan 4, 2026
24b02fe
Doc: add missing punctuation
david-rowley Jan 4, 2026
e3daa37
Honor GUC settings specified in CREATE SUBSCRIPTION CONNECTION.
MasaoFujii Jan 6, 2026
e7de579
Add TAP test for GUC settings passed via CONNECTION in logical replic…
MasaoFujii Jan 6, 2026
a5ef60a
Fix issue with EVENT TRIGGERS and ALTER PUBLICATION
david-rowley Jan 6, 2026
2853f79
createuser: Update docs to reflect defaults
j-naylor Jan 7, 2026
24ae0d4
Fix typo
petere Jan 7, 2026
61dbf6b
Prevent invalidation of newly created replication slots.
Jan 8, 2026
39fe18a
Fix possible incorrect column reference in ERROR message
david-rowley Jan 8, 2026
d611c49
doc: Improve description of publish_via_partition_root
jchampio Jan 9, 2026
9f53651
doc: Document DEFAULT option in file_fdw.
MasaoFujii Jan 13, 2026
c4f5b0a
pg_waldump: Relax LSN comparison check in TAP test
michaelpq Jan 14, 2026
afe731a
Add check for invalid offset at multixid truncation
hlinnaka Jan 15, 2026
8d746c9
Fix 'unexpected data beyond EOF' on replica restart
hlinnaka Jan 15, 2026
a91897f
Fix segfault from releasing locks in detached DSM segments
amitlan Jan 16, 2026
1ba34e1
Fix crash in test function on removable_cutoff(NULL)
hlinnaka Jan 16, 2026
12a4303
Fix error message related to end TLI in backup manifest
michaelpq Jan 18, 2026
3c6166e
Update time zone data files to tzdata release 2025c.
tglsfdc Jan 18, 2026
de2fbbd
Don't set the truncation block length greater than RELSEG_SIZE.
robertmhaas Jan 19, 2026
0941450
amcheck: Fix snapshot usage in bt_index_parent_check
alvherre Jan 21, 2026
c80dc61
jit: Add missing inline pass for LLVM >= 17.
macdice Jan 22, 2026
590e7e8
doc: Mention pg_get_partition_constraintdef()
michaelpq Jan 22, 2026
3e50b0d
Remove faulty Assert in partitioned INSERT...ON CONFLICT DO UPDATE.
tglsfdc Jan 22, 2026
23c4657
Fix bogus ctid requirement for dummy-root partitioned targets
amitlan Jan 23, 2026
3ac352c
Fix trigger transition table capture for MERGE in CTE queries.
deanrasheed Jan 24, 2026
8e8ecfa
Fix possible issue of a WindowFunc being in the wrong WindowClause
david-rowley Jan 26, 2026
ef348d5
Reduce length of TAP test file name.
robertmhaas Jan 26, 2026
0703a69
Prevent invalidation of newly synced replication slots.
Jan 27, 2026
3ab877d
Fix CI failure introduced in commit 851f6649cc.
Jan 29, 2026
e5d64d5
Update .abi-compliance-history for change to TransitionCaptureState.
deanrasheed Jan 30, 2026
66750dd
Improve guards against false regex matches in BackgroundPsql.pm.
tglsfdc Jan 30, 2026
51619c2
Fix build inconsistency due to the generation of wait-event code
michaelpq Feb 1, 2026
6949048
Fix error message in RemoveWalSummaryIfOlderThan()
michaelpq Feb 2, 2026
63b6326
Fix incorrect errno in OpenWalSummaryFile()
michaelpq Feb 3, 2026
14a3684
pg_resetwal: Fix incorrect error message related to pg_wal/summaries/
michaelpq Feb 4, 2026
a6684eb
Fix various instances of undefined behavior
j-naylor Feb 4, 2026
0eb9a94
Fix logical replication TAP test to read publisher log correctly.
MasaoFujii Feb 4, 2026
4543833
doc: Move synchronized_standby_slots to "Primary Server" section.
MasaoFujii Feb 6, 2026
7c9d683
Add file_extend_method=posix_fallocate,write_zeros.
macdice May 31, 2025
404843e
Fix some error message inconsistencies
michaelpq Feb 6, 2026
eba083a
Protect against small overread in SASLprep validation
jchampio Feb 6, 2026
f4e5641
Placate ABI checker.
macdice Feb 6, 2026
57efb1a
Further error message fix
petere Feb 7, 2026
173c29a
meson: host_system value for Solaris is 'sunos' not 'solaris'.
tglsfdc Feb 8, 2026
a908ca2
Translation updates
petere Feb 8, 2026
3b88734
Release notes for 18.2, 17.8, 16.12, 15.16, 14.21.
tglsfdc Feb 8, 2026
b407ba5
pgcrypto: Fix buffer overflow in pgp_pub_decrypt_bytea()
michaelpq Feb 8, 2026
6fc5eb9
Fix encoding length for EUC_CN.
macdice Feb 4, 2026
bd71c99
Fix mb2wchar functions on short input.
macdice Jan 25, 2026
42adf58
Replace pg_mblen() with bounds-checked versions.
macdice Jan 7, 2026
1c20eac
Code coverage for most pg_mblen* calls.
macdice Jan 11, 2026
ff833ed
Require PGP-decrypted text to pass encoding validation.
nmisch Feb 9, 2026
eeaa292
Guard against unexpected dimensions of oidvector/int2vector.
tglsfdc Feb 9, 2026
86bc7f9
Add a syscache on pg_extension.oid.
tglsfdc Feb 9, 2026
cf93cb2
Require superuser to install a non-built-in selectivity estimator.
tglsfdc Feb 9, 2026
703139d
Harden _int_matchsel() against being attached to the wrong operator.
tglsfdc Feb 9, 2026
73556f2
Fix test "NUL byte in text decrypt" for --without-zlib builds.
nmisch Feb 9, 2026
c12c6ac
Last-minute updates for release notes.
tglsfdc Feb 9, 2026
a0a998e
Stamp 17.8.
tglsfdc Feb 9, 2026
9343246
doc: Clarify RLS policies applied for ON CONFLICT DO NOTHING.
deanrasheed Feb 11, 2026
dc52285
doc: Mention all SELECT privileges required by INSERT ... ON CONFLICT.
deanrasheed Feb 11, 2026
62df828
Further stabilize a postgres_fdw test case.
tglsfdc Feb 11, 2026
90ada65
Fix pg_stat_get_backend_wait_event() for aux processes
hlinnaka Feb 11, 2026
e2a4416
Fix plpgsql's handling of "return simple_record_variable".
tglsfdc Feb 11, 2026
52feee3
pg_mblen_range, pg_mblen_with_len: Valgrind after encoding ereport.
nmisch Feb 14, 2026
602830e
Fix SUBSTRING() for toasted multibyte characters.
nmisch Feb 14, 2026
8ad11f9
pgcrypto: Tweak error message for incorrect session key length
michaelpq Feb 16, 2026
068ca76
Don't reset 'latest_page_number' when replaying multixid truncation
hlinnaka Feb 16, 2026
d9d5143
hstore: Fix NULL pointer dereference with receive function
michaelpq Feb 16, 2026
26a52c3
Suppress new "may be used uninitialized" warning.
nmisch Feb 17, 2026
08f9e6d
Fix test_valid_server_encoding helper function.
macdice Feb 17, 2026
abe403b
Update obsolete comment
alvherre Feb 18, 2026
5dd80cf
Fix computation of varnullingrels when translating appendrel Var
Feb 20, 2026
c957921
Release notes for 18.3, 17.9, 16.13, 15.17, 14.22.
tglsfdc Feb 22, 2026
73e0d93
Translation updates
petere Feb 23, 2026
f7e82ee
Stamp 17.9.
tglsfdc Feb 23, 2026
054df65
Updated Babelfish code for community struct/function changes
Mar 22, 2026
3e5ec3e
[BABEL] Fixes for Babelfish triggers after community commit c5fc17ddacc
ayushdsh Feb 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .abi-compliance-history
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,43 @@
# Be sure to replace "<ADD JUSTIFICATION HERE>" with details of your change and
# why it is deemed acceptable.

4dac22aa10d2882c2e6fb465d7c314cc2d8fb754
#
# Add file_extend_method=posix_fallocate,write_zeros.
# 2026-02-06 17:41:42 +1300
#
# Modifying GUC tables isn't really an ABI break: the relevant object has
# incomplete type so its layout is inaccessible from other C translation units.
#
# Discussion: https://www.postgresql.org/message-id/flat/e1f0cd3b-0164-45f5-9705-e922e59df90f%40dunslane.net#8a350b54012c0042f9869d288e978cfe

c5fc17ddaccff14bc22217df2b06ed43a5af16ba
#
# Fix trigger transition table capture for MERGE in CTE queries.
# 2026-01-24 11:30:49 +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.

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

e2fb3dfa817fbe89494a62c100e9cb442f4d6b15
#
# 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.

24f6c1bd41d0631a04cc956cc8cafa0b117ab625
#
# Fix the handling of two GUCs during upgrade.
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,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 17.7.
# Generated by GNU Autoconf 2.69 for PostgreSQL 17.9.
#
# 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='17.7'
PACKAGE_STRING='PostgreSQL 17.7'
PACKAGE_VERSION='17.9'
PACKAGE_STRING='PostgreSQL 17.9'
PACKAGE_BUGREPORT='pgsql-bugs@lists.postgresql.org'
PACKAGE_URL='https://www.postgresql.org/'

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

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

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

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

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

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

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

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -19937,7 +19937,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 17.7
PostgreSQL config.status 17.9
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], [17.7], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
AC_INIT([PostgreSQL], [17.9], [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
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();
94 changes: 41 additions & 53 deletions contrib/amcheck/verify_nbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ typedef struct BtreeCheckState
BufferAccessStrategy checkstrategy;

/*
* Info for uniqueness checking. Fill these fields once per index check.
* Info for uniqueness checking. Fill this field and the one below once
* per index check.
*/
IndexInfo *indexinfo;
/* Table scan snapshot for heapallindexed and checkunique */
Snapshot snapshot;

/*
Expand Down Expand Up @@ -508,7 +510,6 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
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 @@ -559,54 +560,46 @@ 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());
state->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),
state->snapshot->xmin))
ereport(ERROR,
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
errmsg("index \"%s\" cannot be verified using transaction snapshot",
RelationGetRelationName(rel)));
}

/*
* We need a snapshot to check the uniqueness of the index. For better
* performance take it once per index check. If snapshot already taken
* reuse it.
* We need a snapshot to check the uniqueness of the index. For better
* performance, take it once per index check. If one was already taken
* above, use that.
*/
if (state->checkunique)
{
state->indexinfo = BuildIndexInfo(state->rel);
if (state->indexinfo->ii_Unique)
{
if (snapshot != SnapshotAny)
state->snapshot = snapshot;
else
state->snapshot = RegisterSnapshot(GetTransactionSnapshot());
}

if (state->indexinfo->ii_Unique && state->snapshot == InvalidSnapshot)
state->snapshot = RegisterSnapshot(GetTransactionSnapshot());
}

Assert(!state->rootdescend || state->readonly);
Expand Down Expand Up @@ -681,30 +674,28 @@ 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.
*/
scan = table_beginscan_strat(state->heaprel, /* relation */
snapshot, /* snapshot */
state->snapshot, /* snapshot */
0, /* number of keys */
NULL, /* scan key */
true, /* buffer access strategy OK */
true); /* syncscan OK? */

/*
* 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 @@ -728,14 +719,11 @@ 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 == SnapshotAny && state->snapshot != InvalidSnapshot)
if (state->snapshot != InvalidSnapshot)
UnregisterSnapshot(state->snapshot);
MemoryContextDelete(state->targetcontext);
}
Expand Down Expand Up @@ -847,7 +835,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 @@ -2367,7 +2355,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