Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c95c9d5

Browse files
committed
Do not miss relkind check
1 parent f007135 commit c95c9d5

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

online_analyze.c

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
323323
{
324324
PgStat_StatTabEntry *tabentry;
325325
TimestampTz now = GetCurrentTimestamp();
326+
Relation rel;
327+
OnlineAnalyzeTableType reltype;
326328

327329
if (relOid == InvalidOid)
328330
return;
@@ -334,6 +336,23 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
334336
/* number if affected rows is unknown */
335337
naffected = 0;
336338

339+
rel = RelationIdGetRelation(relOid);
340+
if (rel->rd_rel->relkind != RELKIND_RELATION)
341+
{
342+
RelationClose(rel);
343+
return;
344+
}
345+
346+
reltype =
347+
#if PG_VERSION_NUM >= 90100
348+
(rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
349+
#else
350+
(rel->rd_istemp || rel->rd_islocaltemp)
351+
#endif
352+
? OATT_TEMPORARY : OATT_PERSISTENT;
353+
354+
RelationClose(rel);
355+
337356
/*
338357
* includeTables overwrites excludeTables
339358
*/
@@ -353,39 +372,17 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
353372
case OATT_TEMPORARY:
354373
case OATT_PERSISTENT:
355374
default:
375+
/*
376+
* skip analyze if relation's type doesn't not match
377+
* online_analyze_table_type
378+
*/
379+
if ((online_analyze_table_type & reltype) == 0 ||
380+
matchOid(&excludeTables, relOid) == true)
356381
{
357-
Relation rel;
358-
OnlineAnalyzeTableType reltype;
359-
360-
rel = RelationIdGetRelation(relOid);
361-
362-
if (rel->rd_rel->relkind != RELKIND_RELATION)
363-
{
364-
RelationClose(rel);
382+
if (matchOid(&includeTables, relOid) == false)
365383
return;
366-
}
367-
368-
reltype =
369-
#if PG_VERSION_NUM >= 90100
370-
(rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
371-
#else
372-
(rel->rd_istemp || rel->rd_islocaltemp)
373-
#endif
374-
? OATT_TEMPORARY : OATT_PERSISTENT;
375-
RelationClose(rel);
376-
377-
/*
378-
* skip analyze if relation's type doesn't not match
379-
* online_analyze_table_type
380-
*/
381-
if ((online_analyze_table_type & reltype) == 0 ||
382-
matchOid(&excludeTables, relOid) == true)
383-
{
384-
if (matchOid(&includeTables, relOid) == false)
385-
return;
386-
}
387-
break;
388384
}
385+
break;
389386
}
390387

391388
tabentry = pgstat_fetch_stat_tabentry(relOid);

0 commit comments

Comments
 (0)