OSDN Git Service

Fix a crash bug related to non-baserel RTEs and function indexes
[pgdbmsstats/pg_dbms_stats.git] / pg_dbms_stats.c
index 51e8414..417fe77 100644 (file)
@@ -1038,8 +1038,13 @@ dbms_stats_get_index_stats(PlannerInfo *root,
                for (i = 1 ; i < root->simple_rel_array_size ; i++)
                {
                        ListCell *lc;
+                       RelOptInfo *rel = root->simple_rel_array[i];
 
-                       foreach (lc, root->simple_rel_array[i]->indexlist)
+                       /* there may be empty slots corresponding to non-baserel RTEs  */
+                       if (rel == NULL)
+                               continue;
+
+                       foreach (lc, rel->indexlist)
                        {
                                IndexOptInfo *index = (IndexOptInfo *) lfirst(lc);
                                RangeTblEntry *rte;