Postgres - nonstandard use of \\ in a string error

If you see

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

Changing all '\\' to E'\\' is a good solution.

However, it will be very tedious if you have a bunch of data. Worst case is when this happen to \n in Linux machine.

A faster fix will be as follow

1. Open postgresql.conf
2. Find #standard_conforming_strings=off. By default, it is commented out by # and set to off
3. Change it to standard_conforming_strings=on
4. Restart postgres

This will cause postgres to treat backslashes as normal character.

If you want postgres to treat backslashes as escape character after turning stardard_conforming_string to on, you must put an E in front. IE, E'this is \\n a string'

Comments

Popular posts from this blog

FFMPEG - Creating timelapse with FFMPEG with JPEG

MP4 File Format Part 1

RTSP - RTP over TCP