Parameter · Version and Platform Compatibility / Previous PostgreSQL Versions
escape_string_warning
Warn about backslash escapes in ordinary string literals.
- Default:
on - Type: bool
- Applies: Session (any user)
In plain words
Long ago, PostgreSQL treated backslashes in normal strings as escape characters ('\n' was a newline). The SQL standard says they are just characters. When standard_conforming_strings is off (old behaviour), this setting warns each time a backslash is used in a plain '…' string, so you can find code that relies on it.
For DBAs and operators
Has an effect only while standard_conforming_strings is off; with the default on backslashes are literal and nothing is warned. Verified on 18.6:
WARNING: nonstandard use of escape in a string literal
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
Variants: nonstandard use of \\ in a string literal and nonstandard use of \' in a string literal. The fix is to write such strings as E'…' (escape string syntax), which behaves the same regardless of settings. Warnings are sent to the client and, depending on log_min_messages, to the server log, where they can be used to locate legacy code before switching to standard strings.
How to change it
Any user can change it for their session with SET.