@@ -436,6 +436,7 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
436436 int nparts ;
437437 bool isnull ;
438438 Datum value ;
439+ Oid parent = PrelParentRelid (prel );
439440
440441 /* Execute expression */
441442 value = ExecEvalExprCompat (expr_state , econtext , & isnull ,
@@ -453,11 +454,11 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
453454 elog (ERROR , ERR_PART_ATTR_MULTIPLE );
454455 else if (nparts == 0 )
455456 {
456- selected_partid = create_partitions_for_value (PrelParentRelid ( prel ) ,
457+ selected_partid = create_partitions_for_value (parent ,
457458 value , prel -> ev_type );
458459
459460 /* get_pathman_relation_info() will refresh this entry */
460- invalidate_pathman_relation_info (PrelParentRelid ( prel ) , NULL );
461+ invalidate_pathman_relation_info (parent , NULL );
461462 }
462463 else selected_partid = parts [0 ];
463464
@@ -469,15 +470,15 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
469470 if (rri_holder == NULL )
470471 {
471472 /* get_pathman_relation_info() will refresh this entry */
472- invalidate_pathman_relation_info (PrelParentRelid ( prel ) , NULL );
473+ invalidate_pathman_relation_info (parent , NULL );
473474
474475 /* Get a fresh PartRelationInfo */
475- prel = get_pathman_relation_info (PrelParentRelid ( prel ) );
476+ prel = get_pathman_relation_info (parent );
476477
477478 /* Paranoid check (all partitions have vanished) */
478479 if (!prel )
479480 elog (ERROR , "table \"%s\" is not partitioned" ,
480- get_rel_name_or_relid (PrelParentRelid ( prel ) ));
481+ get_rel_name_or_relid (parent ));
481482 }
482483 /* If partition has subpartitions */
483484 else if (rri_holder -> has_subpartitions )
0 commit comments