Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aOtnk-0008Fb-9A for pgsql-sql@arkaria.postgresql.org; Thu, 28 Jan 2016 21:08:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aOtni-0005dk-Px for pgsql-sql@arkaria.postgresql.org; Thu, 28 Jan 2016 21:08:22 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aOtni-0005c0-3k for pgsql-sql@postgresql.org; Thu, 28 Jan 2016 21:08:22 +0000 Received: from outbound003.hypermediasystems.com ([66.162.38.157] helo=outbound003.inf) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aOtnf-0007Wk-Dn for pgsql-sql@postgresql.org; Thu, 28 Jan 2016 21:08:20 +0000 Received: from mail021.dti ([10.5.4.195]) by outbound003.inf with ESMTP; 28 Jan 2016 21:08:19 +0000 Received: from mail021.dti (mail021.dti [10.5.4.195]) by mail021.dti (Postfix) with ESMTP id 4571C15410518; Thu, 28 Jan 2016 13:08:18 -0800 (PST) Date: Thu, 28 Jan 2016 13:08:18 -0800 (PST) From: Arthur Lewis To: Adrian Klaver Cc: pgsql-sql@postgresql.org Message-ID: <1887855942.7187391.1454015298202.JavaMail.root@hypermediasystems.com> In-Reply-To: <56AA7523.4020806@aklaver.com> Subject: Re: insert a text file into a variable in order to insert into a bytea column MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.10.119] X-Mailer: Zimbra 7.2.2_GA_2852 (ZimbraWebClient - FF3.0 (Linux)/7.2.2_GA_2852) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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" To: "Arthur Lewis" Cc: pgsql-sql@postgresql.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.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql