There are two tables, one is referenced by another with foreign key constraint.
CREATE TABLE record
(
id UUID PRIMARY KEY NOT NULL
);
CREATE TABLE task
(
id UUID PRIMARY KEY NOT NULL,
record_id UUID,
CONSTRAINT fk_task_record_id FOREIGN KEY (record_id)
REFERENCES record (id)
);
The question is : if lock on record row is aquired by
SELECT * FROM record where id = 'A' FOR UPDATE OF record
Could I create new foreign key in task table and reference this very record row
?
INSERT INTO task VALUES ('someId', 'A');
Does Postgres prevent creating new foreign key references on tables locked by SELECT FOR UPDATE OF?