check relation type
[online_analyze.git] / online_analyze.c
index 50ee68b..8273673 100644 (file)
@@ -125,11 +125,13 @@ tableListAssign(const char * newval, bool doit, TableList *tbl)
        foreach(l, namelist)
        {
                char        *curname = (char *) lfirst(l);
-               Oid         relOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)), 
 #if PG_VERSION_NUM >= 90200
-                                                                                               NoLock,
-#endif
+               Oid         relOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)), 
+                                                                                               NoLock, true);
+#else
+               Oid         relOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)), 
                                                                                                true);
+#endif
 
                if (relOid == InvalidOid)
                {
@@ -308,6 +310,9 @@ makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
        if (relOid == InvalidOid)
                return;
 
+       if (get_rel_relkind(relOid) != RELKIND_RELATION)
+               return;
+
        tabentry = pgstat_fetch_stat_tabentry(relOid);
 
 #if PG_VERSION_NUM >= 90000
@@ -442,11 +447,9 @@ onlineAnalyzeHooker(QueryDesc *queryDesc)
        if (online_analyze_enable && queryDesc->plannedstmt &&
                        (queryDesc->operation == CMD_INSERT || 
                         queryDesc->operation == CMD_UPDATE ||
-                        queryDesc->operation == CMD_DELETE ||
-#if PG_VERSION_NUM >= 90200
-                        0 /* (queryDesc->operation == CMD_SELECT && queryDesc->dest && queryDesc->dest == DestIntoRel) */
-#else
-                        (queryDesc->operation == CMD_SELECT && queryDesc->plannedstmt->intoClause)
+                        queryDesc->operation == CMD_DELETE
+#if PG_VERSION_NUM < 90200
+                        || (queryDesc->operation == CMD_SELECT && queryDesc->plannedstmt->intoClause)
 #endif
                         ))
        {