Don't release lock on pg_constraint until the xact ends

Do not release AccessShareLock when closing pg_constraint to prevent
modifications to be done on pg_constraint to make sure that caller
will process valid foreign key constraints through the transaction.
pull/3846/head
Onur Tirtir 2020-05-20 16:15:17 +03:00
parent 79a688ffe0
commit 98a660d0b7
1 changed files with 8 additions and 2 deletions

View File

@ -437,7 +437,7 @@ ColumnAppearsInForeignKeyToReferenceTable(char *columnName, Oid relationId)
/* clean up scan and close system catalog */
systable_endscan(scanDescriptor);
heap_close(pgConstraint, AccessShareLock);
heap_close(pgConstraint, NoLock);
return foreignKeyToReferenceTableIncludesGivenColumn;
}
@ -763,7 +763,13 @@ GetForeignKeyOids(Oid relationId, int flags)
}
systable_endscan(scanDescriptor);
heap_close(pgConstraint, AccessShareLock);
/*
* Do not release AccessShareLock yet to prevent modifications to be done
* on pg_constraint to make sure that caller will process valid foreign key
* constraints through the transaction.
*/
heap_close(pgConstraint, NoLock);
return foreignKeyOids;
}