diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index edc4c481043..59e531b55d8 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -677,6 +677,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()))