aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-05-05 21:09:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-05-05 21:09:23 +0000
commit1bbbcb04f06ff119bdf696a5228181b7136f20b9 (patch)
treee90576bb2eeb0802ebfdd09b6fb4b2791958005d /src
parent249a899f73b88061809547f24284d54edba52698 (diff)
downloadpostgresql-1bbbcb04f06ff119bdf696a5228181b7136f20b9.tar.gz
postgresql-1bbbcb04f06ff119bdf696a5228181b7136f20b9.zip
Make new complaint about unsafe Unicode literals include an error location.
Every other ereport in scan.l has one, this should too.
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/scan.l7
-rw-r--r--src/test/regress/expected/strings.out12
2 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index eb0fc10c8f3..6e18a41db1e 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.152 2009/05/05 18:32:17 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.153 2009/05/05 21:09:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -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 831fb9e2037..be8eb919fa3 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;
--