From: | arthur(dot)lewis(at)hypermediasystems(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #13897: backquotes and inserting files into columns. |
Date: | 2016-01-28 23:43:56 |
Message-ID: | 20160128234356.2555.15307@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 13897
Logged by: Arthur Lewis
Email address: arthur(dot)lewis(at)hypermediasystems(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | vladimir.zvagolskiy | 2016-01-29 00:22:02 | BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h |
Previous Message | Jhonathan Lugo | 2016-01-28 16:04:11 |