@@ -696,13 +696,15 @@ variable_insert(PG_FUNCTION_ARGS)
696696tupTypmod = HeapTupleHeaderGetTypMod (rec );
697697
698698record = & (GetActualValue (variable ).record );
699- if (!record -> tupdesc )
699+ tupdesc = lookup_rowtype_tupdesc (tupType ,tupTypmod );
700+
701+ if (!record -> tupdesc || variable -> is_deleted )
700702{
701703/*
702704 * This is the first record for the var_name. Initialize record.
703705 */
704- tupdesc = lookup_rowtype_tupdesc (tupType ,tupTypmod );
705706init_record (record ,tupdesc ,variable );
707+ variable -> is_deleted = false;
706708}
707709else if (LastTypeId == RECORDOID || !OidIsValid (LastTypeId )||
708710LastTypeId != tupType )
@@ -711,16 +713,7 @@ variable_insert(PG_FUNCTION_ARGS)
711713 * We need to check attributes of the new row if this is a transient
712714 * record type or if last record has different id.
713715 */
714- tupdesc = lookup_rowtype_tupdesc (tupType ,tupTypmod );
715- if (variable -> is_deleted )
716- {
717- init_record (record ,tupdesc ,variable );
718- variable -> is_deleted = false;
719- }
720- else
721- {
722- check_attributes (variable ,tupdesc );
723- }
716+ check_attributes (variable ,tupdesc );
724717}
725718
726719LastTypeId = tupType ;