0

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!

3
  • WHERE "tagname" = E'Lift_Stations\08\ETMs\Generator_ETM' could help. Commented Jul 10, 2013 at 22:24
  • If do not work wildplasser's solution, please try add another backslashes, for more information read this link. Commented Jul 10, 2013 at 23:24
  • @wildplasser I think that's a path, and they don't want it to be interpreted as escape sequences. Commented Jul 10, 2013 at 23:53

1 Answer 1

2

It should work if you enable standard_conforming_strings.

Sign up to request clarification or add additional context in comments.

4 Comments

To elaborate on this correct but brief answer: Older PostgreSQL versions used to let you write C-style escapes like \n in strings. This has been turned off by default in newer versions; this warning tells you that you're on a version where it still happens.
Thanks for the help @CraigRinger, always nice to see another 2ndQ member here ;)
I didn't realise you were on the team. Stealthy. Amsterdam... wonder who that could be ;-) . Really supposed to have mention of 2ndQ in your profile if doing Pg related community stuff IIRC.
Yes... I suppose I should really write a little bio ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.