File tree Expand file tree Collapse file tree 3 files changed +20
-22
lines changed Expand file tree Collapse file tree 3 files changed +20
-22
lines changed Original file line number Diff line number Diff line change 94
94
END IF;
95
95
96
96
/* Check that new partition has an equal structure as parent does */
97
- IF NOT @extschema@.is_tuple_convertible(parent_relid, new_partition) THEN
97
+ BEGIN
98
+ PERFORM @extschema@.is_tuple_convertible(parent_relid, new_partition);
99
+ EXCEPTION WHEN OTHERS THEN
98
100
RAISE EXCEPTION ' partition must have a compatible tuple format' ;
99
- END IF ;
101
+ END;
100
102
101
103
/* Check that table is partitioned */
102
104
IF @extschema@.get_partition_key(parent_relid) IS NULL THEN
Original file line number Diff line number Diff line change @@ -639,9 +639,11 @@ BEGIN
639
639
/* Check range overlap */
640
640
PERFORM @extschema@.check_range_available(parent_relid, start_value, end_value);
641
641
642
- IF NOT @extschema@.is_tuple_convertible(parent_relid, partition_relid) THEN
642
+ BEGIN
643
+ PERFORM @extschema@.is_tuple_convertible(parent_relid, partition_relid);
644
+ EXCEPTION WHEN OTHERS THEN
643
645
RAISE EXCEPTION ' partition must have a compatible tuple format' ;
644
- END IF ;
646
+ END;
645
647
646
648
part_expr := @extschema@.get_partition_key(parent_relid);
647
649
part_type := @extschema@.get_partition_type(parent_relid);
Original file line number Diff line number Diff line change @@ -661,38 +661,32 @@ is_date_type(PG_FUNCTION_ARGS)
661
661
PG_RETURN_BOOL (is_date_type_internal (PG_GETARG_OID (0 )));
662
662
}
663
663
664
+ /*
665
+ * Bail out with ERROR if rel1 tuple can't be converted to rel2 tuple.
666
+ */
664
667
Datum
665
668
is_tuple_convertible (PG_FUNCTION_ARGS )
666
669
{
667
670
Relation rel1 ,
668
671
rel2 ;
669
- bool res = true;
672
+ void * map ; /* we don't actually need it */
670
673
671
674
rel1 = heap_open (PG_GETARG_OID (0 ), AccessShareLock );
672
675
rel2 = heap_open (PG_GETARG_OID (1 ), AccessShareLock );
673
676
674
- PG_TRY ();
675
- {
676
- void * map ; /* we don't actually need it */
677
-
678
- /* Try to build a conversion map */
679
- map = convert_tuples_by_name_map (RelationGetDescr (rel1 ),
680
- RelationGetDescr (rel2 ),
681
- ERR_PART_DESC_CONVERT );
677
+ /* Try to build a conversion map */
678
+ map = convert_tuples_by_name_map (RelationGetDescr (rel1 ),
679
+ RelationGetDescr (rel2 ),
680
+ ERR_PART_DESC_CONVERT );
682
681
683
- /* Now free map */
684
- pfree (map );
685
- }
686
- PG_CATCH ();
687
- {
688
- res = false;
689
- }
690
- PG_END_TRY ();
682
+ /* Now free map */
683
+ pfree (map );
691
684
692
685
heap_close (rel1 , AccessShareLock );
693
686
heap_close (rel2 , AccessShareLock );
694
687
695
- PG_RETURN_BOOL (res );
688
+ /* still return true to avoid changing tests */
689
+ PG_RETURN_BOOL (true);
696
690
}
697
691
698
692
You can’t perform that action at this time.
0 commit comments