@@ -1164,7 +1164,6 @@ update_trigger_func(PG_FUNCTION_ARGS)
1164
1164
*/
1165
1165
key_name = get_attname (parent , prel -> attnum );
1166
1166
source_key = get_attnum (source_relid , key_name );
1167
- // target_key = get_attnum(target_relid, key_name);
1168
1167
key = heap_getattr (new_tuple , source_key , source_tupdesc , & isnull );
1169
1168
1170
1169
/* Find partition it should go into */
@@ -1174,18 +1173,18 @@ update_trigger_func(PG_FUNCTION_ARGS)
1174
1173
if (target_relid == source_relid )
1175
1174
PG_RETURN_POINTER (new_tuple );
1176
1175
1177
- /* TODO: probably should be another lock level */
1178
- target_rel = heap_open (target_relid , RowExclusiveLock );
1179
- target_tupdesc = target_rel -> rd_att ;
1180
-
1181
1176
/* Read tuple id */
1182
1177
ctid = heap_getsysattr (old_tuple ,
1183
1178
SelfItemPointerAttributeNumber ,
1184
1179
source_tupdesc ,
1185
1180
& isnull );
1186
1181
1182
+ /* Open partition table */
1183
+ target_rel = heap_open (target_relid , RowExclusiveLock );
1184
+ target_tupdesc = target_rel -> rd_att ;
1185
+
1187
1186
/*
1188
- * Else if it's a different partition then build a TupleConversionMap
1187
+ * As it is different partition we need to build a TupleConversionMap
1189
1188
* between original partition and new one. And then do a convertation
1190
1189
*/
1191
1190
conversion_map = convert_tuples_by_name (source_tupdesc ,
0 commit comments