Reputation: 1
What will be the result of quote_ident(table_name::text)
and what is the difference if we pass it rather than table in a pipeline statement?
For e.g is there difference between
CREATE TRIGGER audit_trigger_stm AFTER ' || stm_targets || ' ON ' || quote_ident(table_name::text) ...
and this
CREATE TRIGGER audit_trigger_stm AFTER ' || stm_targets || ' ON ' || table_name ...
Upvotes: 0
Views: 37
Reputation: 247123
The difference is that without using quote_ident
your composed statement becomes invalid if table_name
contains spaces, double quotes or other niceties (or is a reserved SQL keyword).
Moreover, using quote_ident
saves you from SQL injection if table_name
comes from an untrusted source.
Upvotes: 2