From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Allan Kamau <kamauallan(at)gmail(dot)com> |
Cc: | Postgres General Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Avoiding SQL injection in Dynamic Queries (in plpgsql) |
Date: | 2010-03-17 10:53:36 |
Message-ID: | 162867791003170353l309ffcd1l707174ed45fb35da@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2010/3/17 Allan Kamau <kamauallan(at)gmail(dot)com>:
> When writing dynamic commands (those having "EXECUTE 'some SQL
> query';), is there a way to prevent interpretation of input parameters
> as pieces of SQL commands? Does quote_literal() function implicitly
> protect against this unwanted behaviour.
quote_literal, quote_identif are enough, but USING clause is better
and faster. Sometimes you have to use a combination:
execute 'select foo from ' || tabname::regclass || ' WHERE a = $1' USING value;
Pavel
>
> Allan.
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | zhong ming wu | 2010-03-17 11:07:09 | Re: return row from plpgsql? |
Previous Message | Herouth Maoz | 2010-03-17 10:32:21 | Re: stopping processes, preventing connections |