Re: Add \i option to bring in the specified file as a quoted literal - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Add \i option to bring in the specified file as a quoted literal
Date
Msg-id 20131122125453.GI6041@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: Add \i option to bring in the specified file as a quoted literal  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Add \i option to bring in the specified file as a quoted literal  (Piotr Marcinczyk <pmarcinc@gmail.com>)
List pgsql-hackers
Amit Kapila escribió:
> On Fri, Nov 22, 2013 at 1:33 AM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:

> > \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?

If the only use case of the feature proposed in this thread is to load
stuff from files to use as column values, then we're pretty much done,
and this patch is not needed -- except, maybe, that the `` is unlikely
to work on Windows, as already mentioned elsewhere.  But if the OP had
something else in mind, let's hear what it is.

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



pgsql-hackers by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: UNNEST with multiple args, and TABLE with multiple funcs
Next
From: roadrunner6@gmx.at
Date:
Subject: Minor patch for the uuid-ossp extension