Kevin Garman
Kevin Garman

Reputation: 395

PostgreSQL: nonstandard use of escape string

I have a PostgreSQL 8.4 database that is being queried by an application that is outside of my control. Queries such as the following are throwing warnings but are working...

SELECT "tagname","tagindex","tagtype","tagdatatype"  FROM "tagtable" WHERE "tagname" = 'Lift_Stations\07\ETMs\Generator_ETM'

However, the same query for stations 08 and 09 are failing...

SELECT "tagname","tagindex","tagtype","tagdatatype"  FROM "tagtable" WHERE "tagname" = 'Lift_Stations\08\ETMs\Generator_ETM'

WARNING: nonstandard use of escape in a string literal LINE 2: ...,"tagdatatype" FROM "tagtable" WHERE "tagname" = 'Lift_Stat... ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.

ERROR: invalid byte sequence for encoding "UTF8": 0x00 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

*** Error ***

ERROR: invalid byte sequence for encoding "UTF8": 0x00 SQL state: 22021 Hint: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

I know the problem is incorrect escaping, but given the fact that 08 and 09 are the only ones not working, I'm hoping someone might have a bright idea on how to work around this.

Thanks!

Upvotes: 0

Views: 2791

Answers (1)

Wolph
Wolph

Reputation: 80111

It should work if you enable standard_conforming_strings.

Upvotes: 2

Related Questions