I created a small function and small trigger. When I run the simplest DELETE query, I only see a notice and a context message in the console (no warning and no error messages), but still this DELETE query has no effect (the record stays in table and is not deleted). The function and trigger look like this:
CREATE FUNCTION trigger_layers_before_del () RETURNS trigger
AS $$
DECLARE
table_name text := (SELECT concat ('layer_', OLD.id::text, '_'));
BEGIN
EXECUTE '
DROP TABLE IF EXISTS ' || quote_ident(table_name) || ' CASCADE
';
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER tr_layers_del_befor
BEFORE DELETE ON layers FOR EACH ROW
EXECUTE PROCEDURE trigger_layers_before_del();
And this how DELETE command looks like:
DELETE FROM layers where id = 31
So, if I run:
DELETE FROM layers WHERE id = 31;
SELECT * FROM layers WHERE id = 31;
then it returns a record with id = 31.
The notice says, that "table "layer_31_" does not exist, skips ...". The context message simply prints EXECUTE statement. So, if there are no errors, why DELETE command is not commited?