PostgreSQL 8.1.9
According to the release notes, PostgreSQL still handles escape characters =
in strings as it has in the past, yet PL/pgSQL functions that use escape ch=
aracters within the string definition for RAISE EXCEPTION are ignored, unle=
ss the function is created using the old style quote definition (not $$).
Observe the following four test functions using PL/pgSQL.
CREATE OR REPLACE FUNCTION test_func_exception() RETURNS void AS '
BEGIN=20
RAISE EXCEPTION \'This is an error message.\nThis is a message on a ne=
w line\';
RETURN;
END '=20
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;
CREATE OR REPLACE FUNCTION test_func_exception2() RETURNS void AS
$BODY$
BEGIN=20
RAISE EXCEPTION 'This is an error message.\nThis is a message on a new=
line';
RETURN;
END $BODY$
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;
CREATE OR REPLACE FUNCTION test_func_exception3() RETURNS void AS
$BODY$
BEGIN=20
RAISE EXCEPTION E'This is an error message.\nThis is a message on a ne=
w line';
RETURN;
END $BODY$
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;
CREATE OR REPLACE FUNCTION test_func_exception4() RETURNS void AS
$BODY$
DECLARE=20
smessage text;
BEGIN=20
smessage :=3D 'This is an error message.\nThis is a message on a new l=
ine';
RAISE EXCEPTION '%',smessage;
RETURN;
END $BODY$
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;
Out put from the four test functions are as follows:
1)
select test_func_exception();
ERROR: This is an error message.
This is a message on a new line
2)
select test_func_exception2();
ERROR: This is an error message.nThis is a message on a new line
3)
select test_func_exception3();
ERROR: This is an error message.nThis is a message on a new line
4)
select test_func_exception4();
ERROR: This is an error message.
This is a message on a new line
You will note that even using the new E'' string format syntax for the RAIS=
E EXCEPTION appears to be broken (test_func_exception3()).
I can't find anything in the documentation that suggests this should be the=
observed behaviour.
Regards
Donald Fraser=