+ Reply to Thread
Results 1 to 3 of 3

many warning in pg logs : nonstandard use of \\ in a string literalat character

  1. many warning in pg logs : nonstandard use of \\ in a string literalat character

    hi !
    I have many warnings like :

    WARNING: nonstandard use of \\ in a string literal at character 69
    HINT: Use the escape string syntax for backslashes, e.g., E'\\'.

    They are generated by an apache/php server using the db.

    Any idea how to correct that ?
    thx.
    P.

  2. Re: many warning in pg logs : nonstandard use of \\ in a string literal at character

    Patrox wrote:
    > I have many warnings like :
    >
    > WARNING: nonstandard use of \\ in a string literal at character 69
    > HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
    >
    > They are generated by an apache/php server using the db.
    >
    > Any idea how to correct that ?


    Yes.

    The first solution:

    Edit postgresql.conf, set
    standard_conforming_strings = on
    and restart the server.

    Then backslashes will be treated as normal characters, and if you
    need them as escape character, you must preceed the string with an 'E',
    as in E'string\nwith newline'.

    This solution is good because this will be the default in some future
    release.

    The second solution:

    Preceed all string literals that contain a backslash with an E as above
    and replace single backslashes with double backslashes whenever they
    should not be treated as escape character.

    This may be a little more work.

    The third solution:

    Edit postgresql.conf, set
    escape_string_warning = off
    and restret the server.

    This will get rid of the warnings; single backslashes will be treated as
    escape characters.

    I wouldn't recommend this because - as said - behaviour may change in
    a future release.

    Yours,
    Laurenz Albe

  3. Re: many warning in pg logs : nonstandard use of \\ in a string literalat character

    thx !!! :)

    Laurenz Albe a écrit :
    > Patrox wrote:
    >> I have many warnings like :
    >>
    >> WARNING: nonstandard use of \\ in a string literal at character 69
    >> HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
    >>
    >> They are generated by an apache/php server using the db.
    >>
    >> Any idea how to correct that ?

    >
    > Yes.
    >
    > The first solution:
    >
    > Edit postgresql.conf, set
    > standard_conforming_strings = on
    > and restart the server.
    >
    > Then backslashes will be treated as normal characters, and if you
    > need them as escape character, you must preceed the string with an 'E',
    > as in E'string\nwith newline'.
    >
    > This solution is good because this will be the default in some future
    > release.
    >
    > The second solution:
    >
    > Preceed all string literals that contain a backslash with an E as above
    > and replace single backslashes with double backslashes whenever they
    > should not be treated as escape character.
    >
    > This may be a little more work.
    >
    > The third solution:
    >
    > Edit postgresql.conf, set
    > escape_string_warning = off
    > and restret the server.
    >
    > This will get rid of the warnings; single backslashes will be treated as
    > escape characters.
    >
    > I wouldn't recommend this because - as said - behaviour may change in
    > a future release.
    >
    > Yours,
    > Laurenz Albe


+ Reply to Thread