Thread: When inserting '\' the insert fails.

When inserting '\' the insert fails.

From
pgsql-bugs@postgresql.org
Date:
Kristian Knudsen (mips@mips.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
When inserting  '\' the insert fails.

Long Description
When inserting  '\' to a text field and there is a date column
the insert fails.
But only if the date insert contains time information also.
Look at the code examples below.
where 1) fails because of the time 21:18:05
2) is inserted ok because I omit the time info.
I am using pg 7.1 on red hat 6.2 and try to port an web-application
from ms-SqlServer 7.0 to pg and apache.
And I want to transfer all existing data to pg.

Kristian Knudsen - MIPS Denmark Develuping Center

Sample Code
1)
INSERT INTO t3 ( tt,date )
VALUES ( 'aaaaaaa ''\\'' bbbbbbbb','2000-10-30 21:18:05' )
Error: ERROR: Bad timestamp external representation '2000-10-30 21NULLNULL'

2)
INSERT INTO t3 ( tt,date )
VALUES ( 'eqwehqw ''\\'' dsdsa','2000-10-30')

No file was uploaded with this report

Re: When inserting '\' the insert fails.

From
Tom Lane
Date:
pgsql-bugs@postgresql.org writes:
> When inserting  '\' the insert fails.

Your examples work fine for me:

regression=# create table t3 (tt text, date timestamp);
CREATE
regression=# INSERT INTO t3 ( tt,date )
regression-# VALUES ( 'aaaaaaa ''\\'' bbbbbbbb','2000-10-30 21:18:05' );
INSERT 5814810 1
regression=# INSERT INTO t3 ( tt,date )
regression-# VALUES ( 'eqwehqw ''\\'' dsdsa','2000-10-30') ;
INSERT 5814811 1
regression=# select * from t3;
          tt          |          date
----------------------+------------------------
 aaaaaaa '\' bbbbbbbb | 2000-10-30 21:18:05-05
 eqwehqw '\' dsdsa    | 2000-10-30 00:00:00-05
(2 rows)

I suspect the problem is somewhere in your application code.  You might
try turning on query logging at the postmaster to see what's actually
being transmitted to the backend by the application.

            regards, tom lane