Skip to content

Commit 6d554e3

Browse files
committed
Check syscache result in AlterStatistics
The syscache lookup may return NULL even for valid OID, for example due to a concurrent DROP STATISTICS, so a HeapTupleIsValid is necessary. Without it, it may fail with a segfault. Reported by Alexander Lakhin, patch by me. Backpatch to 13, where ALTER STATISTICS ... SET STATISTICS was introduced. Backpatch-through: 13 Discussion: https://postgr.es/m/17372-bf3b6e947e35ae77%40postgresql.org
1 parent 62e2809 commit 6d554e3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/commands/statscmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,8 @@ AlterStatistics(AlterStatsStmt *stmt)
657657
rel = table_open(StatisticExtRelationId, RowExclusiveLock);
658658

659659
oldtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(stxoid));
660+
if (!HeapTupleIsValid(oldtup))
661+
elog(ERROR, "cache lookup failed for extended statistics object %u", stxoid);
660662

661663
/* Must be owner of the existing statistics object */
662664
if (!pg_statistics_object_ownercheck(stxoid, GetUserId()))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy