@@ -52,6 +52,7 @@ static void append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
52
52
static Node * wrapper_make_expression (WrapperNode * wrap , int index , bool * alwaysTrue );
53
53
static void set_pathkeys (PlannerInfo * root , RelOptInfo * childrel , Path * path );
54
54
static void disable_inheritance (Query * parse );
55
+ bool inheritance_disabled ;
55
56
56
57
static WrapperNode * walk_expr_tree (Expr * expr , const PartRelationInfo * prel );
57
58
static int make_hash (const PartRelationInfo * prel , int value );
@@ -127,6 +128,7 @@ my_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
127
128
if (initialization_needed )
128
129
init ();
129
130
131
+ inheritance_disabled = false;
130
132
disable_inheritance (parse );
131
133
result = standard_planner (parse , cursorOptions , boundParams );
132
134
return result ;
@@ -157,7 +159,16 @@ disable_inheritance(Query *parse)
157
159
prel = (PartRelationInfo * )
158
160
hash_search (relations , (const void * ) & rte -> relid , HASH_FIND , 0 );
159
161
if (prel != NULL )
162
+ {
160
163
rte -> inh = false;
164
+ /*
165
+ * Sometimes user uses the ONLY statement and in this case
166
+ * rte->inh is also false. We should differ the case
167
+ * when user uses ONLY statement from case when we
168
+ * make rte->inh false intentionally.
169
+ */
170
+ inheritance_disabled = true;
171
+ }
161
172
}
162
173
break ;
163
174
case RTE_SUBQUERY :
@@ -198,7 +209,7 @@ my_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
198
209
PartRelationInfo * prel = NULL ;
199
210
200
211
/* This works on for SELECT queries */
201
- if (root -> parse -> commandType != CMD_SELECT )
212
+ if (root -> parse -> commandType != CMD_SELECT || ! inheritance_disabled )
202
213
return ;
203
214
204
215
/* Lookup partitioning information for parent relation */
0 commit comments