DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Version and Platform Compatibility / Previous PostgreSQL Versions

standard_conforming_strings

Causes '...' strings to treat backslashes literally.

  • Default: on
  • Type: bool
  • Applies: Session (any user)

In plain words

Decides what a backslash means inside an ordinary string literal. With on (default since PostgreSQL 9.1, as the SQL standard requires), 'a\nb' is four characters: a, backslash, n, b. With off (old PostgreSQL behaviour), the backslash is an escape and 'a\nb' contains a newline. To use escapes regardless of the setting, write E'a\nb'.

For DBAs and operators

Verified on 18.6: SELECT 'a\nb' returns a\nb with the default, and a two-line value (plus a warning, see escape_string_warning) with off.

The value is reported to the client at connect time and on change (it is a GUC_REPORT parameter), because client libraries must know it to escape strings correctly: libpq's PQescapeStringConn and JDBC rely on it. Turning it off for a session while a driver assumes "on" can open SQL-injection holes, which is why backslash_quote exists.

Support pitfalls: very old applications or dumps from < 9.1 that assume backslash escapes (Windows paths, regex patterns) produce different data; regex patterns like '\d+' work as intended only with the default. Prefer fixing the SQL (E-strings, parameters) over turning this off.

How to change it

Any user can change it for their session with SET.

See it in context

Wire protocol

Related parameters

escape_string_warning backslash_quote client_encoding

All Version and Platform Compatibility parameters