mirror of
https://github.com/postgres/postgres.git
synced 2026-02-17 01:31:07 -05:00
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
This commit is contained in:
parent
62e28097ce
commit
6d554e3fcd
1 changed files with 2 additions and 0 deletions
|
|
@ -657,6 +657,8 @@ AlterStatistics(AlterStatsStmt *stmt)
|
|||
rel = table_open(StatisticExtRelationId, RowExclusiveLock);
|
||||
|
||||
oldtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(stxoid));
|
||||
if (!HeapTupleIsValid(oldtup))
|
||||
elog(ERROR, "cache lookup failed for extended statistics object %u", stxoid);
|
||||
|
||||
/* Must be owner of the existing statistics object */
|
||||
if (!pg_statistics_object_ownercheck(stxoid, GetUserId()))
|
||||
|
|
|
|||
Loading…
Reference in a new issue