Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aOvAj-0003Nx-Pg for pgsql-sql@arkaria.postgresql.org; Thu, 28 Jan 2016 22:36:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aOvAj-00073A-6z for pgsql-sql@arkaria.postgresql.org; Thu, 28 Jan 2016 22:36:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aOvAg-000713-Uo for pgsql-sql@postgresql.org; Thu, 28 Jan 2016 22:36:10 +0000 Received: from outbound003.hypermediasystems.com ([66.162.38.157] helo=outbound003.inf) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aOvAc-0002HE-2B for pgsql-sql@postgresql.org; Thu, 28 Jan 2016 22:36:09 +0000 Received: from mail021.dti ([10.5.4.195]) by outbound003.inf with ESMTP; 28 Jan 2016 22:36:03 +0000 Received: from mail021.dti (mail021.dti [10.5.4.195]) by mail021.dti (Postfix) with ESMTP id B3330154100BC; Thu, 28 Jan 2016 14:36:02 -0800 (PST) Date: Thu, 28 Jan 2016 14:36:02 -0800 (PST) From: Arthur Lewis To: "David G. Johnston" Cc: Adrian Klaver , pgsql-sql@postgresql.org Message-ID: <1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com> In-Reply-To: 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: quoted-printable 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 Hi David, Yes you're correct. The problem is caused by the back-ticks (`) Here is w= hat 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 a= ny trailing newline removed) replaces the backquoted text." Arthur Lewis ----- Original Message ----- From: "David G. Johnston" To: "Arthur Lewis" Cc: "Adrian Klaver" , 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 in= to a bytea column On Thu, Jan 28, 2016 at 2:08 PM, Arthur Lewis < arthur.lewis@hypermediasyst= ems.com > wrote:=20 postgres=3D> \set stext `cat file.txt`=20 postgres=3D> select octet_length(:'stext');=20 octet_length=20 --------------=20 53603=20 in my shell I did the following:=20 $ ls -l file.txt=20 -rw-rw-r-- 1 alewis alewis 53604 Jan 27 08:30 file.txt=20 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.=20 =E2=80=8BOr the "back-ticks" implementation...=20 David J.=E2=80=8B --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql