SCM

[#1011121] PostgreSQL 9.1 and standard_conforming_strings setting

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-11-18 08:20
Priority:
3
State:
Open
Submitted by:
Konstantin Shtonda (laurel)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.11
Category:
Group:
Resolution:
None
Summary:
PostgreSQL 9.1 and standard_conforming_strings setting

Detailed description
In PostgreSQL 9.1 default value of standard_conforming_strings config parameter has changed (here http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html). Escaped string literals (but without E prefix) are used as non-escaped by default now.

Query

1. update t set f = '\\'

results in setting value '\\' in table, but not '\'. Old behavour can be returned by setting standard_conforming_strings=off (not recommended in docs) or by changing query to

2. update t set f = E'\\'
or
3. update t set f = '\'

In NpgsqlTypesHelper method ConvertToBackendPlainQuery always escapes (doubles) backward slashes, which is required only when standard_conforming_strings is off.

I can fix it by changing string.Format in method NpgsqlTypesHelper.QuoteString
return String.Format("E'{0}'", S); I don't sure that this change is safe.

I think Npgsql should escape string literals only when standard_conforming_strings is off.

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge