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 9494 END IF;
9595
9696 /* 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
98100 RAISE EXCEPTION ' partition must have a compatible tuple format' ;
99- END IF ;
101+ END;
100102
101103 /* Check that table is partitioned */
102104 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
639639 /* Check range overlap */
640640 PERFORM @extschema@.check_range_available(parent_relid, start_value, end_value);
641641
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
643645 RAISE EXCEPTION ' partition must have a compatible tuple format' ;
644- END IF ;
646+ END;
645647
646648 part_expr := @extschema@.get_partition_key(parent_relid);
647649 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)
661661 PG_RETURN_BOOL (is_date_type_internal (PG_GETARG_OID (0 )));
662662}
663663
664+ /*
665+ * Bail out with ERROR if rel1 tuple can't be converted to rel2 tuple.
666+ */
664667Datum
665668is_tuple_convertible (PG_FUNCTION_ARGS )
666669{
667670 Relation rel1 ,
668671 rel2 ;
669- bool res = true;
672+ void * map ; /* we don't actually need it */
670673
671674 rel1 = heap_open (PG_GETARG_OID (0 ), AccessShareLock );
672675 rel2 = heap_open (PG_GETARG_OID (1 ), AccessShareLock );
673676
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 );
682681
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 );
691684
692685 heap_close (rel1 , AccessShareLock );
693686 heap_close (rel2 , AccessShareLock );
694687
695- PG_RETURN_BOOL (res );
688+ /* still return true to avoid changing tests */
689+ PG_RETURN_BOOL (true);
696690}
697691
698692
You can’t perform that action at this time.
0 commit comments