Re: ORDER BY in prepared statements

Поиск
Список
Период
Сортировка
От Bryn Jeffries
Тема Re: ORDER BY in prepared statements
Дата
Msg-id 7DAF466372B27747B8EA808BE5651FA57AD61B2C@ex-mbx-pro-01
обсуждение исходный текст
Ответ на Re: ORDER BY in prepared statements  (David G Johnston <david.g.johnston@gmail.com>)
Ответы Re: ORDER BY in prepared statements  (David Johnston <david.g.johnston@gmail.com>)
Re: ORDER BY in prepared statements  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Paul Jungwirth wrote
> I'm not sure how to make a prepared statement that lets you name a
> column when you execute it. Maybe someone else can chime in if that's
> possible.

David J. responded
> You cannot.  By definition parameters, in this context, are values - not
> identifiers.
> [...]
> In both situations there is no way for the planner to plan and cache a
> single query whose order by column varies.  No matter what you do at best
> you can have a single plan for each explicit order by column that you wish
> to specify.

That's what I'd figured. The motivation to use prepared statements in
application layers is not so much having a single plan but more the
insulation from SQL injection. The intent of the given ORDER BY example was
to restricts inputs to valid identifiers rather than part of the query
expression.

Maybe what we need in ODBC libs and the like is a "protected
statement" that follows the same construction as a prepared statement but
additionally checks catalogs to validate identifiers.

Bryn

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

Предыдущее
От: Bryn Jeffries
Дата:
Сообщение: Re: ORDER BY in prepared statements
Следующее
От: David Johnston
Дата:
Сообщение: Re: ORDER BY in prepared statements