BUG #19064: Trigger allows creation with invalid column references but fails at runtime
От | PG Bug reporting form |
---|---|
Тема | BUG #19064: Trigger allows creation with invalid column references but fails at runtime |
Дата | |
Msg-id | 19064-b896cfc12d4c7e75@postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime
Re: BUG #19064: Trigger allows creation with invalid column references but fails at runtime |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 19064 Logged by: Ketan Bhatiya Email address: ketan.bhatiya@lenditt.com PostgreSQL version: Unsupported/Unknown Operating system: Windows Description: Example Function & Trigger CREATE OR REPLACE FUNCTION update_order_total() RETURNS TRIGGER AS $$ BEGIN -- Wrong column reference: "wrong_column" does not exist in "Orders" UPDATE Orders SET total = NEW.wrong_column WHERE id = NEW.id; RETURN NULL; END; $$ LANGUAGE plpgsql; CREATE OR REPLACE TRIGGER trg_update_order_total AFTER UPDATE ON Orders FOR EACH ROW EXECUTE FUNCTION update_order_total(); Steps to Reproduce Run the above function and trigger creation. ✅ They are created successfully. Update a row in Orders. Expected Result If the trigger contains a reference to a non-existing column, PostgreSQL should throw an error at creation time. Actual Result The function and trigger creation succeed. ❌ At runtime, when an update happens, it fails with: ERROR: record "new" has no field "wrong_column" 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.
В списке pgsql-bugs по дате отправления: