Re: Add \i option to bring in the specified file as a quoted literal

Поиск
Список
Период
Сортировка
Искать
От
Alvaro Herrera
Тема
Re: Add \i option to bring in the specified file as a quoted literal
Дата
Msg-id
20131121200350.GB6041@eldon.alvh.no-ip.org
Ответ на
Список
Дерево обсуждения
Add \i option to bring in the specified file as a quoted literal Piotr Marcinczyk <pmarcinc@gmail.com>
Re: Add \i option to bring in the specified file as a quoted literal Amit Kapila <amit.kapila16@gmail.com>
Re: Add \i option to bring in the specified file as a quoted literal Bruce Momjian <bruce@momjian.us>
Re: Add \i option to bring in the specified file as a quoted literal Amit Kapila <amit.kapila16@gmail.com>
Re: Add \i option to bring in the specified file as a quoted literal Bruce Momjian <bruce@momjian.us>
Re: Add \i option to bring in the specified file as a quoted literal Piotr Marcinczyk <pmarcinc@gmail.com>
Re: Add \i option to bring in the specified file as a quoted literal Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Add \i option to bring in the specified file as a quoted literal Amit Kapila <amit.kapila16@gmail.com>
Re: Add \i option to bring in the specified file as a quoted literal Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Add \i option to bring in the specified file as a quoted literal Piotr Marcinczyk <pmarcinc@gmail.com>
Piotr Marcinczyk escribió:

>         
> +         \ib filename [ quote_string ] 
> +         
> +         
> +         The \ib</> command appends content of file filename 
> +         to current query buffer. If parameter quote_string 
> +         is not set, no quotation is used. If it is set, content of file will be
> +         quoted by quote_string enclosed in $.
> +         
> +         
> +       

Doesn't this quoting thing seem like a usability problem?  I mean,
there's no way you can possibly know what string to use unless you first
verify the contents of the file yourself.  I think this is something
that should be done automatically by psql.

But, really, having to read stuff and transform into a quoted literal
seems wrong to me.  I would like something that would read into a client
variable that can later be used as a positional parameter to a
parametrized query, so

\ib homer ~/photos/homer.jpg
insert into people (name, photo) values ('Homer', :homer);

and have psql turn that into 

PQexecParams("insert into people (name, photo) values ('homer', $1)",	some_array_with_homer);

so that no quoting needs to happen anywhere.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


В списке pgsql-hackers по дате отправления
От: Andres Freund
Дата:
От: Andres Freund
Дата:
Сообщение: MultiXact pessmization in 9.3
FAQ