Re: Cross-datatype Comparisons and Indexes

Поиск
Список
Период
Сортировка
От Joshua D. Drake
Тема Re: Cross-datatype Comparisons and Indexes
Дата
Msg-id 41266CDF.4000701@commandprompt.com
обсуждение исходный текст
Ответ на Re: Cross-datatype Comparisons and Indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
>
>
> I can think of at least three workarounds in 7.4:
>
> 1. Always quote your constants:
>
>     ... WHERE bigintcol = '42';

You can also

      WHERE bigintcol = 42::bigint

Sincerely,

Joshua D. Drake



>
> 2. Use a prepared statement:
>
>     PREPARE foo(bigint) AS ... WHERE bigintcol = $1;
>
>     EXECUTE foo(42);
>
> 3. Use parameterized statements in extended-query mode (essentially the
>    same idea as #2, but at the protocol level).  This doesn't help for
>    pure SQL scripts, but is very workable when coding against libpq or
>    JDBC.  Among other things it gets you out of worrying about SQL
>    injection attacks when your parameter values come from untrusted
>    sources.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Cross-datatype Comparisons and Indexes
Следующее
От: Mike Mascari
Дата:
Сообщение: Re: Cross-datatype Comparisons and Indexes