Page 1 of 1

Escaping Data with PgSqlLoader

Posted: Wed 17 Apr 2013 01:13
by lalbin
I recently upgraded to 6.6.217 and have found that the escaping of CrLf no longer work properly. Here is what I used to do.

Code: Select all

                loader.Connection = conn
                loader.CreateColumns()
                loader.Open()

                ret = Me.TextBox1.Text
                ret = ret.Replace("'", "''") ' ' -> ''
                ret = ret.Replace("\", "\\") ' \ -> \\
                ret = ret.Replace(vbLf, "\" & vbLf) ' Lf -> \Lf
                ret = ret.Replace(vbCr, "\" & vbCr) ' Cr -> \Cr
                ret = ret.Replace(vbCrLf, "\" & vbCr & "\" & vbLf) ' CrLf -> \Cr\Lf
                pg_escape_string = ret

                loader.SetValue("field1", pg_escape_string)
                loader.NextRow()
                loader.Close()
When I read the data back, it would read perfectly. Now it will fail with 'literal newline found in data'. I have found that if I change from protocol 2 to 3 and then change to binary mode, I can write the data properly without doing any escaping. I would still like to know how to escape the data properly with protocol 2.

I have tried changing to \n\r and \012\015 but these are written into the data as is instead of being written as CrLf. I also tries various combinations trying E'string' but to no avail.

I do have a test program that will show off this issue if you would like it.

Re: Escaping Data with PgSqlLoader

Posted: Thu 18 Apr 2013 14:31
by Pinturiccio
We have reproduced the issue. We will investigate it and notify you about the results as soon as possible.

Re: Escaping Data with PgSqlLoader

Posted: Fri 19 Apr 2013 01:09
by lalbin
The problem also exists when using protocol 3 and mode text.

Re: Escaping Data with PgSqlLoader

Posted: Thu 16 May 2013 12:07
by Pinturiccio
We have fixed the bug with processing newline string characters in PgSqlLoader. We will post here when the corresponding build of dotConnect for PostgreSQL is available for download.

Re: Escaping Data with PgSqlLoader

Posted: Mon 20 May 2013 08:27
by Pinturiccio
The new build of dotConnect for PostgreSQL 6.6.242 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=27134