#410 ✓resolved
Ana Nelson

Postgres Escape Strings

Reported by Ana Nelson | June 23rd, 2008 @ 04:31 PM

When I try to run the attached script, I get:

WARNING: nonstandard use of \\ in a string literal

LINE 1: INSERT INTO "examples" ("example") VALUES ('xx\\xx') RETURNI...

^

HINT: Use the escape string syntax for backslashes, e.g., E'\\'.

This is just a warning, not an error. The code does run properly and the record is added to the database

Postgres seems to have its own escape-string notation.

http://www.postgresql.org/docs/8...

Comments and changes to this ticket

  • Sam Smoot

    Sam Smoot June 23rd, 2008 @ 04:49 PM

    • Assigned user changed from “Sam Smoot” to “Bernerd Schaefer”

    That's odd. I swear we're using the Postgres C-API string escaping to avoid these exact issues. :-/

    Maybe it's just that the C-API wasn't updated to match the new E'\\' syntax? (It's new in 8.3 right?)

    Bernerd? Can you confirm? If we are, then I'd say probably just ignore the warning and as the Postgres team updates the client libs, it'll go away. If we aren't using the C-API for escaping, we should be, but let me know first because it's going to be a busy week so we'll need to schedule the fix.

  • Jonathan Stott (namelessjon)

    Jonathan Stott (namelessjon) November 30th, 2008 @ 08:07 AM

    • Assigned user cleared.
    • Tag set to bug, do_postgres
    • State changed from “new” to “open”

    Confirmed as of do_postgres 0.9.9

  • Dirkjan Bussink

    Dirkjan Bussink December 7th, 2008 @ 08:56 AM

    • State changed from “open” to “resolved”

    We do escape properly with Postgres methods. You get these warnings because some backwards compatibility options are enabled. For my Postgres installs I usually specify the following:

    backslash_quote = off standard_conforming_strings = on

    For what these options mean, please see http://www.postgresql.org/docs/8...

    I'm closing this for now.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 7th, 2008 @ 09:34 AM

    Dirkjan, is there a way to specify the backwards compatibility option should be off when connecting to the DB, or is it something that has to be set in the global config?

  • Dirkjan Bussink

    Dirkjan Bussink December 7th, 2008 @ 11:38 AM

    I've just tested this, and it's possible to run queries that change these options run time. Should we include these by default?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages