Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aOwEW-0005uR-Py for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jan 2016 23:44:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aOwEV-0002AE-HS for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jan 2016 23:44:11 +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 1aOwEU-0002A5-2f for pgsql-bugs@postgresql.org; Thu, 28 Jan 2016 23:44:10 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aOwEP-0003Zi-1d for pgsql-bugs@postgresql.org; Thu, 28 Jan 2016 23:44:08 +0000 MIME-Version: 1.0 Subject: BUG #13897: backquotes and inserting files into columns. To: pgsql-bugs@postgresql.org From: arthur.lewis@hypermediasystems.com Date: Thu, 28 Jan 2016 23:43:56 +0000 Message-ID: <20160128234356.2555.15307@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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