agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Arthur Lewis <arthur.lewis@hypermediasystems.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: insert a text file into a variable in order to insert into a bytea column
Date: Thu, 28 Jan 2016 14:36:02 -0800 (PST)
Message-ID: <1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com> (raw)
In-Reply-To: <CAKFQuwY8hGODYwA9eEp4dAUo3VtpVie8He4J9ZdJ22CskzJ22w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
Hi David,
Yes you're correct. The problem is caused by the back-ticks (`) Here is what I found in the docs about back-ticks
"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."
Arthur Lewis
----- Original Message -----
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: "Arthur Lewis" <arthur.lewis@hypermediasystems.com>
Cc: "Adrian Klaver" <adrian.klaver@aklaver.com>, pgsql-sql@postgresql.org
Sent: Thursday, January 28, 2016 1:57:38 PM
Subject: Re: [SQL] insert a text file into a variable in order to insert into a bytea column
On Thu, Jan 28, 2016 at 2:08 PM, Arthur Lewis < arthur.lewis@hypermediasystems.com > wrote:
postgres=> \set stext `cat file.txt`
postgres=> select octet_length(:'stext');
octet_length
--------------
53603
in my shell I did the following:
$ ls -l file.txt
-rw-rw-r-- 1 alewis alewis 53604 Jan 27 08:30 file.txt
I'm still one byte short. So the problem has to be either the \set command chomping it or cat. I just tested cat and that seems to be working.
Or the "back-ticks" implementation...
David J.
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (8+ messages) latest in thread
Message-ID: <1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com>
Permalink: ../1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com/
Also on: postgresql.org/message-id/1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: arthur.lewis@hypermediasystems.com, david.g.johnston@gmail.com, adrian.klaver@aklaver.com
Subject: Re: insert a text file into a variable in order to insert into a bytea column
In-Reply-To: <1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox