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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to