From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Piotr Marcinczyk <pmarcinc(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Subject: | Re: Add \i option to bring in the specified file as a quoted literal |
Date: | 2013-11-21 20:03:50 |
Message-ID: | 20131121200350.GB6041@eldon.alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2013-11-21 20:05:17 | MultiXact pessmization in 9.3 |
Previous Message | Andres Freund | 2013-11-21 19:38:47 | MultiXact truncation, startup et al. |