@@ -68,12 +68,6 @@ static bool delayed_shutdown = false; /* pathman was dropped */
68
68
list = NIL; \
69
69
} while (0)
70
70
71
- struct expr_mutator_context
72
- {
73
- Oid relid ; /* partitioned table */
74
- List * rtable ; /* range table list from expression query */
75
- };
76
-
77
71
static bool try_perform_parent_refresh (Oid parent );
78
72
static Oid try_syscache_parent_search (Oid partition , PartParentSearch * status );
79
73
static Oid get_parent_of_partition_internal (Oid partition ,
@@ -92,8 +86,6 @@ static void fill_pbin_with_bounds(PartBoundInfo *pbin,
92
86
93
87
static int cmp_range_entries (const void * p1 , const void * p2 , void * arg );
94
88
95
- static Node * expression_mutator (Node * node , struct expr_mutator_context * context );
96
-
97
89
98
90
void
99
91
init_relation_info_static_data (void )
@@ -133,7 +125,6 @@ refresh_pathman_relation_info(Oid relid,
133
125
char * expr ;
134
126
HeapTuple tp ;
135
127
MemoryContext oldcontext ;
136
- Node * tmp_node ;
137
128
138
129
AssertTemporaryContext ();
139
130
@@ -191,16 +182,12 @@ refresh_pathman_relation_info(Oid relid,
191
182
prel -> atttype = DatumGetObjectId (values [Anum_pathman_config_atttype - 1 ]);
192
183
expr = TextDatumGetCString (values [Anum_pathman_config_expression_p - 1 ]);
193
184
194
- /* Restore planned expression */
195
- tmp_node = (Node * ) stringToNode (expr );
196
- fix_opfuncids (tmp_node );
197
- pfree (expr );
198
-
199
- /* expression and attname should be saved in cache context */
185
+ /* Expression and attname should be saved in cache context */
200
186
oldcontext = MemoryContextSwitchTo (PathmanRelationCacheContext );
201
187
202
- prel -> expr = expression_mutator (tmp_node , NULL );
203
188
prel -> attname = TextDatumGetCString (values [Anum_pathman_config_expression - 1 ]);
189
+ prel -> expr = (Node * ) stringToNode (expr );
190
+ fix_opfuncids (prel -> expr );
204
191
205
192
MemoryContextSwitchTo (oldcontext );
206
193
@@ -1195,47 +1182,3 @@ shout_if_prel_is_invalid(const Oid parent_oid,
1195
1182
expected_str );
1196
1183
}
1197
1184
}
1198
-
1199
-
1200
- /*
1201
- * To prevent calculation of Vars in expression, we wrap them with
1202
- * CustomConst, and later before execution we fill it with actual value
1203
- */
1204
- static Node *
1205
- expression_mutator (Node * node , struct expr_mutator_context * context )
1206
- {
1207
- const TypeCacheEntry * typcache ;
1208
-
1209
- /* TODO: add RelabelType */
1210
- /* TODO: check Vars, they should only be related with base relation */
1211
- if (IsA (node , Var ))
1212
- {
1213
- //Var *variable = (Var *) node;
1214
- Node * new_node = newNode (sizeof (CustomConst ), T_Const );
1215
- Const * new_const = (Const * )new_node ;
1216
-
1217
- /*
1218
- RangeTblEntry *entry = rt_fetch(variable->varno, context->rtable);
1219
- if (entry->relid != context->relid)
1220
- elog(ERROR, "Columns in the expression should "
1221
- "be only from partitioned relation");
1222
- */
1223
-
1224
- /* we only need varattno from original Var, for now */
1225
- ((CustomConst * )new_node )-> varattno = ((Var * )node )-> varattno ;
1226
-
1227
- new_const -> consttype = ((Var * )node )-> vartype ;
1228
- new_const -> consttypmod = ((Var * )node )-> vartypmod ;
1229
- new_const -> constcollid = ((Var * )node )-> varcollid ;
1230
- new_const -> constvalue = (Datum ) 0 ;
1231
- new_const -> constisnull = true;
1232
- new_const -> location = -2 ;
1233
-
1234
- typcache = lookup_type_cache (new_const -> consttype , 0 );
1235
- new_const -> constbyval = typcache -> typbyval ;
1236
- new_const -> constlen = typcache -> typlen ;
1237
-
1238
- return new_node ;
1239
- }
1240
- return expression_tree_mutator (node , expression_mutator , (void * ) context );
1241
- }
0 commit comments