@@ -38,9 +38,6 @@ static uint64 PathmanCopyFrom(CopyState cstate,
38
38
Relation parent_rel ,
39
39
List * range_table ,
40
40
bool old_protocol );
41
- static ResultRelInfoHolder * select_partition_for_copy (const PartRelationInfo * prel ,
42
- ResultPartsStorage * parts_storage ,
43
- Datum value , EState * estate );
44
41
45
42
46
43
/*
@@ -376,7 +373,7 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
376
373
/* Initialize ResultPartsStorage */
377
374
init_result_parts_storage (& parts_storage , estate , false,
378
375
ResultPartsStorageStandard ,
379
- check_acl_for_partition , NULL );
376
+ NULL , NULL );
380
377
parts_storage .saved_rel_info = parent_result_rel ;
381
378
382
379
/* Set up a tuple slot too */
@@ -418,16 +415,19 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
418
415
/* Fetch PartRelationInfo for parent relation */
419
416
prel = get_pathman_relation_info (RelationGetRelid (parent_rel ));
420
417
421
- /* Switch into its memory context */
418
+ /* Switch into per tuple memory context */
422
419
MemoryContextSwitchTo (GetPerTupleMemoryContext (estate ));
423
420
424
421
if (!NextCopyFrom (cstate , econtext , values , nulls , & tuple_oid ))
425
422
break ;
426
423
424
+ if (nulls [prel -> attnum - 1 ])
425
+ elog (ERROR , ERR_PART_ATTR_NULL );
426
+
427
427
/* Search for a matching partition */
428
- rri_holder_child = select_partition_for_copy (prel , & parts_storage ,
429
- values [prel -> attnum - 1 ],
430
- estate );
428
+ rri_holder_child = select_partition_for_insert (prel , & parts_storage ,
429
+ values [prel -> attnum - 1 ],
430
+ estate , false );
431
431
child_result_rel = rri_holder_child -> result_rel_info ;
432
432
estate -> es_result_relation_info = child_result_rel ;
433
433
@@ -477,8 +477,7 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
477
477
478
478
if (child_result_rel -> ri_NumIndices > 0 )
479
479
recheckIndexes = ExecInsertIndexTuples (slot , & (tuple -> t_self ),
480
- estate , false, NULL ,
481
- NIL );
480
+ estate , false, NULL , NIL );
482
481
483
482
/* AFTER ROW INSERT Triggers */
484
483
ExecARInsertTriggers (estate , child_result_rel , tuple ,
@@ -522,39 +521,3 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
522
521
523
522
return processed ;
524
523
}
525
-
526
- /*
527
- * Smart wrapper for scan_result_parts_storage().
528
- */
529
- static ResultRelInfoHolder *
530
- select_partition_for_copy (const PartRelationInfo * prel ,
531
- ResultPartsStorage * parts_storage ,
532
- Datum value , EState * estate )
533
- {
534
- ExprContext * econtext ;
535
- ResultRelInfoHolder * rri_holder ;
536
- Oid selected_partid = InvalidOid ;
537
- Oid * parts ;
538
- int nparts ;
539
-
540
- econtext = GetPerTupleExprContext (estate );
541
-
542
- /* Search for matching partitions using partitioned column */
543
- parts = find_partitions_for_value (value , prel , econtext , & nparts );
544
-
545
- if (nparts > 1 )
546
- elog (ERROR , "PATHMAN COPY selected more than one partition" );
547
- else if (nparts == 0 )
548
- elog (ERROR ,
549
- "There is no suitable partition for key '%s'" ,
550
- datum_to_cstring (value , prel -> atttype ));
551
- else
552
- selected_partid = parts [0 ];
553
-
554
- /* Replace parent table with a suitable partition */
555
- MemoryContextSwitchTo (estate -> es_query_cxt );
556
- rri_holder = scan_result_parts_storage (selected_partid , parts_storage );
557
- MemoryContextSwitchTo (GetPerTupleMemoryContext (estate ));
558
-
559
- return rri_holder ;
560
- }
0 commit comments