summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-05-05 21:09:23 +0000
committerTom Lane2009-05-05 21:09:23 +0000
commit0d31fb6d1a5f95f27884a25c1d72503730918152 (patch)
tree077bc11822e974ea9addef4abf21b8ed1fcf9efa
parentc263edea3cac054d03fd2d0f17cef6ea7bd07348 (diff)
Make new complaint about unsafe Unicode literals include an error location.
Every other ereport in scan.l has one, this should too.
-rw-r--r--src/backend/parser/scan.l5
-rw-r--r--src/test/regress/expected/strings.out12
2 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 9a495e84e9..6448cf2bcf 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -469,12 +469,13 @@ other .
startlit();
}
{xusstart} {
+ SET_YYLLOC();
if (!standard_conforming_strings)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("unsafe use of string constant with Unicode escapes"),
- errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off.")));
- SET_YYLLOC();
+ errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off."),
+ lexer_errposition()));
BEGIN(xus);
startlit();
}
diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out
index 831fb9e203..be8eb919fa 100644
--- a/src/test/regress/expected/strings.out
+++ b/src/test/regress/expected/strings.out
@@ -62,12 +62,18 @@ LINE 1: SELECT U&'wrong: +0061' UESCAPE '+';
SET standard_conforming_strings TO off;
SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*';
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061...
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&' \' UESCAPE '!' AS "tricky";
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&' \' UESCAPE '!' AS "tricky";
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT 'tricky' AS U&"\" UESCAPE '!';
\
@@ -77,12 +83,18 @@ SELECT 'tricky' AS U&"\" UESCAPE '!';
SELECT U&'wrong: \061';
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&'wrong: \061';
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&'wrong: \+0061';
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&'wrong: \+0061';
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&'wrong: +0061' UESCAPE '+';
ERROR: unsafe use of string constant with Unicode escapes
+LINE 1: SELECT U&'wrong: +0061' UESCAPE '+';
+ ^
DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
RESET standard_conforming_strings;
--