Thread: vacuumlo nonstandard use of \\ in a string literal

vacuumlo nonstandard use of \\ in a string literal

From
Michael Fuhr
Date:
In 8.1 and HEAD, if a role has escape_string_warning enabled then
vacuumlo elicits the following warning:

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

How backward compatible should vacuumlo remain?  This patch changes
the string to E'...' but other ways would be to use dollar quotes
or ESCAPE.

--
Michael Fuhr

Attachment

Re: vacuumlo nonstandard use of \\ in a string literal

From
Tom Lane
Date:
Michael Fuhr <mike@fuhr.org> writes:
> How backward compatible should vacuumlo remain?  This patch changes
> the string to E'...' but other ways would be to use dollar quotes
> or ESCAPE.

In this particular case, a far better answer is to replace

> !     strcat(buf, "      AND s.nspname NOT LIKE 'pg\\\\_%'");

with

> !     strcat(buf, "      AND s.nspname !~ '^pg_'");

which sidesteps the problem entirely and is more readable to boot.

            regards, tom lane