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 обсуждение исходный текст |
Ответ на | 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
|
Список | pgsql-hackers |
Piotr Marcinczyk escribió: > <varlistentry> > + <term><literal>\ib <replaceable class="parameter">filename</replaceable> [ <replaceable class="parameter">quote_string</replaceable>] </literal></term> > + <listitem> > + <para> > + The <literal>\ib</> command appends content of file <literal>filename</literal> > + to current query buffer. If parameter <literal>quote_string</literal> > + is not set, no quotation is used. If it is set, content of file will be > + quoted by <literal>quote_string</literal> enclosed in <literal>$</literal>. > + </para> > + </listitem> > + </varlistentry> 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 по дате отправления: