Address stats import review comments.

Reported-by: jian he <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CACJufxHG9MBQozbJQ4JRBcRbUO+t+sx4qLZX092rS_9b4SR_EA@mail.gmail.com
pull/207/head
Jeff Davis 6 months ago
parent 39de4f157d
commit 298944e8d8
  1. 8
      src/backend/statistics/relation_stats.c
  2. 10
      src/backend/statistics/stat_utils.c

@ -127,13 +127,7 @@ relation_statistics_update(FunctionCallInfo fcinfo)
ctup = SearchSysCache1(RELOID, ObjectIdGetDatum(reloid)); ctup = SearchSysCache1(RELOID, ObjectIdGetDatum(reloid));
if (!HeapTupleIsValid(ctup)) if (!HeapTupleIsValid(ctup))
{ elog(ERROR, "pg_class entry for relid %u not found", reloid);
ereport(WARNING,
(errcode(ERRCODE_OBJECT_IN_USE),
errmsg("pg_class entry for relid %u not found", reloid)));
table_close(crel, RowExclusiveLock);
return false;
}
pgcform = (Form_pg_class) GETSTRUCT(ctup); pgcform = (Form_pg_class) GETSTRUCT(ctup);

@ -136,12 +136,14 @@ stats_lock_check_privileges(Oid reloid)
/* /*
* For indexes, we follow the locking behavior in do_analyze_rel() and * For indexes, we follow the locking behavior in do_analyze_rel() and
* check_inplace_rel_lock(), which is to lock the table first in * check_lock_if_inplace_updateable_rel(), which is to lock the table
* ShareUpdateExclusive mode and then the index in AccessShare mode. * first in ShareUpdateExclusive mode and then the index in AccessShare
* mode.
* *
* Partitioned indexes are treated differently than normal indexes in * Partitioned indexes are treated differently than normal indexes in
* check_inplace_rel_lock(), so we take a ShareUpdateExclusive lock on * check_lock_if_inplace_updateable_rel(), so we take a
* both the partitioned table and the partitioned index. * ShareUpdateExclusive lock on both the partitioned table and the
* partitioned index.
*/ */
switch (get_rel_relkind(reloid)) switch (get_rel_relkind(reloid))
{ {

Loading…
Cancel
Save