@@ -204,11 +204,14 @@ handle_attach_partition(Oid parent_relid, AlterTableCmd *cmd)
204
204
ParseState * pstate = make_parsestate (NULL );
205
205
const PartRelationInfo * prel ;
206
206
207
- PartitionCmd * pcmd = (PartitionCmd * ) cmd -> def ;
207
+ PartitionCmd * pcmd = (PartitionCmd * ) cmd -> def ;
208
+
209
+ /* in 10beta1, PartitionCmd->bound is (Node *) */
210
+ PartitionBoundSpec * bound = (PartitionBoundSpec * ) pcmd -> bound ;
208
211
209
212
Assert (cmd -> subtype == AT_AttachPartition );
210
213
211
- if (pcmd -> bound -> strategy != PARTITION_STRATEGY_RANGE )
214
+ if (bound -> strategy != PARTITION_STRATEGY_RANGE )
212
215
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
213
216
errmsg ("pg_pathman only supports queries for range partitions" )));
214
217
@@ -224,11 +227,15 @@ handle_attach_partition(Oid parent_relid, AlterTableCmd *cmd)
224
227
proc_name = list_make2 (makeString (pathman_schema ),
225
228
makeString (CppAsString (attach_range_partition )));
226
229
227
- ldatum = (PartitionRangeDatum * ) linitial (pcmd -> bound -> lowerdatums );
230
+ if ((!list_length (bound -> lowerdatums )) ||
231
+ (!list_length (bound -> upperdatums )))
232
+ elog (ERROR , "provide start and end value for range partition" );
233
+
234
+ ldatum = (PartitionRangeDatum * ) linitial (bound -> lowerdatums );
228
235
con = castNode (A_Const , ldatum -> value );
229
236
lval = transform_bound_value (pstate , con , prel -> ev_type , prel -> ev_typmod );
230
237
231
- rdatum = (PartitionRangeDatum * ) linitial (pcmd -> bound -> upperdatums );
238
+ rdatum = (PartitionRangeDatum * ) linitial (bound -> upperdatums );
232
239
con = castNode (A_Const , rdatum -> value );
233
240
rval = transform_bound_value (pstate , con , prel -> ev_type , prel -> ev_typmod );
234
241
@@ -247,10 +254,6 @@ handle_attach_partition(Oid parent_relid, AlterTableCmd *cmd)
247
254
proc_fcinfo .flinfo -> fn_expr =
248
255
(Node * ) make_fn_expr (proc_fcinfo .flinfo -> fn_oid , fn_args );
249
256
250
- if ((!list_length (pcmd -> bound -> lowerdatums )) ||
251
- (!list_length (pcmd -> bound -> upperdatums )))
252
- elog (ERROR , "provide start and end value for range partition" );
253
-
254
257
proc_fcinfo .arg [2 ] = lval -> constvalue ;
255
258
proc_fcinfo .argnull [2 ] = ldatum -> infinite || lval -> constisnull ;
256
259
proc_fcinfo .arg [3 ] = rval -> constvalue ;
@@ -308,11 +311,14 @@ handle_create_partition_of(Oid parent_relid, CreateStmt *stmt)
308
311
* rval ;
309
312
A_Const * con ;
310
313
314
+ /* in 10beta1, PartitionCmd->bound is (Node *) */
315
+ PartitionBoundSpec * bound = (PartitionBoundSpec * ) stmt -> partbound ;
316
+
311
317
/* we show errors earlier for these asserts */
312
318
Assert (stmt -> inhRelations != NULL );
313
319
Assert (stmt -> tableElts == NIL );
314
320
315
- if (stmt -> partbound -> strategy != PARTITION_STRATEGY_RANGE )
321
+ if (bound -> strategy != PARTITION_STRATEGY_RANGE )
316
322
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
317
323
errmsg ("pg_pathman only supports queries for range partitions" )));
318
324
@@ -326,11 +332,11 @@ handle_create_partition_of(Oid parent_relid, CreateStmt *stmt)
326
332
errmsg ("table \"%s\" is not partitioned by RANGE" ,
327
333
get_rel_name_or_relid (parent_relid ))));
328
334
329
- ldatum = (PartitionRangeDatum * ) linitial (stmt -> partbound -> lowerdatums );
335
+ ldatum = (PartitionRangeDatum * ) linitial (bound -> lowerdatums );
330
336
con = castNode (A_Const , ldatum -> value );
331
337
lval = transform_bound_value (pstate , con , prel -> ev_type , prel -> ev_typmod );
332
338
333
- rdatum = (PartitionRangeDatum * ) linitial (stmt -> partbound -> upperdatums );
339
+ rdatum = (PartitionRangeDatum * ) linitial (bound -> upperdatums );
334
340
con = castNode (A_Const , rdatum -> value );
335
341
rval = transform_bound_value (pstate , con , prel -> ev_type , prel -> ev_typmod );
336
342
0 commit comments