diff options
| author | Tomas Vondra | 2022-01-23 01:49:41 +0000 |
|---|---|---|
| committer | Tomas Vondra | 2022-01-23 02:20:32 +0000 |
| commit | 267ccc38ba6a95889d98959f183de64ceff23087 (patch) | |
| tree | fa9421079bfab9300744308e603d203b27658603 /src/backend/commands | |
| parent | 31b7b4d26e10086d4a79d49a28fd161da52da49a (diff) | |
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
Diffstat (limited to 'src/backend/commands')
| -rw-r--r-- | src/backend/commands/statscmds.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index 2f46180407a..d073d9b7c13 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -493,6 +493,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())) |
