Escaping Data with PgSqlLoader

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
lalbin
Posts: 15
Joined: Thu 06 Aug 2009 23:29
Location: Seattle

Escaping Data with PgSqlLoader

Post by lalbin » Wed 17 Apr 2013 01:13

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.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Escaping Data with PgSqlLoader

Post by Pinturiccio » Thu 18 Apr 2013 14:31

We have reproduced the issue. We will investigate it and notify you about the results as soon as possible.

lalbin
Posts: 15
Joined: Thu 06 Aug 2009 23:29
Location: Seattle

Re: Escaping Data with PgSqlLoader

Post by lalbin » Fri 19 Apr 2013 01:09

The problem also exists when using protocol 3 and mode text.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Escaping Data with PgSqlLoader

Post by Pinturiccio » Thu 16 May 2013 12:07

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.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Escaping Data with PgSqlLoader

Post by Pinturiccio » Mon 20 May 2013 08:27

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

Post Reply