On Fri, Nov 22, 2013 at 1:33 AM, Alvaro Herrera <alvhe...@2ndquadrant.com> wrote: > 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);
Isn't something similar already supported as mentioned in docs: One example use of this mechanism is to copy the contents of a file into a table column. First load the file into a variable and then interpolate the variable's value as a quoted string: testdb=> \set content `cat my_file.txt` testdb=> INSERT INTO my_table VALUES (:'content'); or do you prefer an alternative without any kind of quote using \ib? With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers