Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime - Mailing list pgsql-bugs

From Rahila Syed
Subject Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime
Date
Msg-id CAH2L28uPfAbipMeAa+XTfGck4Nwo7yv8o+FwZor7f7ivDOS8vg@mail.gmail.com
Whole thread Raw
In response to BUG #19064: Trigger allows creation with invalid column references but fails at runtime  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime
List pgsql-bugs
Hi



Suggestion / Proposed Improvement
PostgreSQL should validate column references at trigger creation time, not
just at runtime.
If a column does not exist in the target table (Orders in this example),
trigger creation should fail immediately with a clear error message.


This behaviour is by design in PostgreSQL. The CreateTrigger() is responsible
for creating a dependency between trigger and its underlying pl/pgsql function. 
The pl/pgsql function is only parsed when it is executed for the first time.

This approach allows for flexibility, such as adding columns to a table after a trigger
has been created. On the other hand, if a column existing at the time of trigger creation
is later removed, validating at creation time would not offer much advantage in these
situations.

Thank you,
Rahila Syed

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime
Next
From: Álvaro Herrera
Date:
Subject: Re: TRAP: failed Assert("outerPlan != NULL") in postgres_fdw.c