Re: pg_execute_from_file review

Поиск
Список
Период
Сортировка
Искать
От
Dimitri Fontaine
Тема
Re: pg_execute_from_file review
Дата
Msg-id
m239qh6tm7.fsf@2ndQuadrant.fr
Ответ на
Список
Дерево обсуждения
pg_execute_from_file review Joshua Tolley <eggyknap@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Joshua Tolley <eggyknap@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Andrew Dunstan <andrew@dunslane.net>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Joshua Tolley <eggyknap@gmail.com>
Re: pg_execute_from_file review Andrew Dunstan <andrew@dunslane.net>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Andrew Dunstan <andrew@dunslane.net>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Alvaro Herrera <alvherre@commandprompt.com>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Itagaki Takahiro <itagaki.takahiro@gmail.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review "David E. Wheeler" <david@kineticode.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review "David E. Wheeler" <david@kineticode.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review "David E. Wheeler" <david@kineticode.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review "David E. Wheeler" <david@kineticode.com>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Andrew Dunstan <andrew@dunslane.net>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Robert Haas <robertmhaas@gmail.com>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review "David E. Wheeler" <david@kineticode.com>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Re: pg_execute_from_file review Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Dimitri Fontaine  writes:
> Itagaki Takahiro  writes:
>> My suggestion is to introduce pg_read_binary_file() function that can
>> read any files in the server, and make CREATE EXTENSION to use the
>> function. Of course, pg_execute_[sql|from]_file() can simplify queries
>
> It seems like all you're missing in the current patch is the encoding
> option in there. Exposing the internal functions is simple enough and
> solves it, but I much prefer the current simple-case user API. Do you
> want me to add a variant with an extra 'encoding' parameter?

Here's the result:

dim=# \df pg_exe*|replace_*|*binary*
                                     List of functions
   Schema   |         Name          | Result data type |    Argument data types    |  Type  
------------+-----------------------+------------------+---------------------------+--------
 pg_catalog | pg_execute_sql_file   | void             | text                      | normal
 pg_catalog | pg_execute_sql_file   | void             | text, name                | normal
 pg_catalog | pg_execute_sql_file   | void             | text, name, VARIADIC text | normal
 pg_catalog | pg_execute_sql_string | void             | text                      | normal
 pg_catalog | pg_execute_sql_string | void             | text, VARIADIC text       | normal
 pg_catalog | pg_read_binary_file   | bytea            | text, bigint, bigint      | normal
 pg_catalog | replace_placeholders  | text             | text, VARIADIC text       | normal
(7 rows)

I think that answers fine to your concerns, in that you can manipulate
the low-level functions in order to control each step, or you can use
the higher-level functions and just pass them the arguments you want.

Note that the "name" arguments here are the encoding.

The documentation of the pg_execute_sql_string() function should close
the gap noted by Joshua Tolley about how to format placeholder names,
because it gives examples both using '@schema@' and 's' as names.

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support

В списке pgsql-hackers по дате отправления
От: Florian Pflug
Дата:
От: Jeff Davis
Дата:
FAQ