From: | Arthur Lewis <arthur(dot)lewis(at)hypermediasystems(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: insert a text file into a variable in order to insert into a bytea column |
Date: | 2016-01-28 21:08:18 |
Message-ID: | 1887855942.7187391.1454015298202.JavaMail.root@hypermediasystems.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
----- Original Message -----
From: "Adrian Klaver" <adrian(dot)klaver(at)aklaver(dot)com>
To: "Arthur Lewis" <arthur(dot)lewis(at)hypermediasystems(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Sent: Thursday, January 28, 2016 12:08:03 PM
Subject: Re: [SQL] insert a text file into a variable in order to insert into a bytea column
On 01/28/2016 10:46 AM, Arthur Lewis wrote:
> Hi,
> In my shell I did the following
>
> $ cat file > file.temp
> $ ls -l file file.temp
> -rw-rw-r-- 1 alewis alewis 53604 Jan 27 08:30 file
> -rw-rw-r-- 1 alewis alewis 53604 Jan 28 10:28 file.temp
> $ diff file file.temp
> $
>
> So at least in the shell the cat command isn't losing a byte at the end of the file like in psql \set x `cat file`.
Hmm, well there went that theory;)
What happens if you do?:
select octet_length(:'stext');
>
> Arthur Lewis
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2016-01-28 21:57:38 | Re: insert a text file into a variable in order to insert into a bytea column |
Previous Message | Adrian Klaver | 2016-01-28 20:08:03 | Re: insert a text file into a variable in order to insert into a bytea column |