Skip to content

Commit a192243

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 3839e29 commit a192243

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
@@ -677,6 +677,8 @@ AlterStatistics(AlterStatsStmt *stmt)
677677
rel = table_open(StatisticExtRelationId, RowExclusiveLock);
678678

679679
oldtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(stxoid));
680+
if (!HeapTupleIsValid(oldtup))
681+
elog(ERROR, "cache lookup failed for extended statistics object %u", stxoid);
680682

681683
/* Must be owner of the existing statistics object */
682684
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