pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: arthur.lewis@hypermediasystems.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13897: backquotes and inserting files into columns.
Date: Thu, 28 Jan 2016 23:43:56 +0000
Message-ID: <20160128234356.2555.15307@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      13897
Logged by:          Arthur Lewis
Email address:      arthur.lewis@hypermediasystems.com
PostgreSQL version: 9.3.10
Operating system:   Ubuntu Linux 14 (32 bit)
Description:        

In the manual (http://www.postgresql.org/docs/9.3/static/app-psql.html) it
says in order to insert a file into the database all you do is the
following:

testdb=> \set content `cat my_file.txt`
testdb=> INSERT INTO my_table VALUES (:'content');

The manual also says:

Within an argument, text that is enclosed in backquotes (`) is taken as a
command line that is passed to the shell. The output of the command (with
any trailing newline removed) replaces the backquoted text.

I have a file called my_file.txt and it has 53604 bytes.  When I do this

testdb=> \set content `cat my_file.txt`
testdb=> select length(:'content');
 length 
--------------
        53603

Because of back-quotes I've just lost a byte (a trailing newline) and the
original file has been changed.

If there is a better way than using back-quotes please let me know.





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



Message-ID: <20160128234356.2555.15307@wrigleys.postgresql.org>
Permalink:  ../20160128234356.2555.15307@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20160128234356.2555.15307@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: arthur.lewis@hypermediasystems.com
  Subject: Re: BUG #13897: backquotes and inserting files into columns.
  In-Reply-To: <20160128234356.2555.15307@wrigleys.postgresql.org>
  References: <20160128234356.2555.15307@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox