How to programmatically check if row is deletable?
Say we have a PostgreSQL table like so: CREATE TABLE master ( id INT PRIMARY KEY, ... ); and many other tables referencing it with foreign keys: CREATE TABLE other ( id INT PRIMARY KEY, id_master INT NOT NULL, ... CONSTRAINT other_id_master_fkey FOREIGN KEY (id_master) REFERENCES master (id) ON DELETE RESTRICT ); Is there a way to check (from within trigger function) if a master row is deletable without actually trying to delete it? The obvious way is to do a SELECT on all referencing tables one by one, but I would like to know if there is an easier way. The reason I need this is that I have a