The following bug has been logged online:
Bug reference: 4908
Logged by: Jack Douglas
Email address: jackpdouglas@gmail.com
PostgreSQL version: 8.3.7
Operating system: Debian Lenny
Description: escaping and dollar quotes: "ERROR: unterminated
string"
Details:
Am I missing something obvious here - I understand from the documentation no
escapes are counted in dollar quoted strings?
postgres=> create or replace function temp() returns text language plpgsql
AS $$
postgres$> begin
postgres$> return '\';
postgres$> end; $$;
ERROR: unterminated string
CONTEXT: compile of PL/pgSQL function "temp" near line 2
I use the following as a workaround:
postgres=> create or replace function temp() returns text language plpgsql
AS $$
postgres$> begin
postgres$> return rtrim('\ ');
postgres$> end; $$;
CREATE FUNCTION
obviously this is a contrived test case to demonstrate the problem, not my
real function :-)