1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-29 13:56:47 +03:00

Make new complaint about unsafe Unicode literals include an error location.

Every other ereport in scan.l has one, this should too.
This commit is contained in:
Tom Lane 2009-05-05 21:09:23 +00:00
parent 249a899f73
commit 1bbbcb04f0
2 changed files with 16 additions and 3 deletions

View File

@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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(); startlit();
} }
{xusstart} { {xusstart} {
SET_YYLLOC();
if (!standard_conforming_strings) if (!standard_conforming_strings)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("unsafe use of string constant with Unicode escapes"), errmsg("unsafe use of string constant with Unicode escapes"),
errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off."))); errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off."),
SET_YYLLOC(); lexer_errposition()));
BEGIN(xus); BEGIN(xus);
startlit(); startlit();
} }

View File

@ -62,12 +62,18 @@ LINE 1: SELECT U&'wrong: +0061' UESCAPE '+';
SET standard_conforming_strings TO off; SET standard_conforming_strings TO off;
SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061"; SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061";
ERROR: unsafe use of string constant with Unicode escapes 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. 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 '*'; SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*';
ERROR: unsafe use of string constant with Unicode escapes 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. DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&' \' UESCAPE '!' AS "tricky"; SELECT U&' \' UESCAPE '!' AS "tricky";
ERROR: unsafe use of string constant with Unicode escapes 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. DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT 'tricky' AS U&"\" UESCAPE '!'; SELECT 'tricky' AS U&"\" UESCAPE '!';
\ \
@ -77,12 +83,18 @@ SELECT 'tricky' AS U&"\" UESCAPE '!';
SELECT U&'wrong: \061'; SELECT U&'wrong: \061';
ERROR: unsafe use of string constant with Unicode escapes 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. DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&'wrong: \+0061'; SELECT U&'wrong: \+0061';
ERROR: unsafe use of string constant with Unicode escapes 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. DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
SELECT U&'wrong: +0061' UESCAPE '+'; SELECT U&'wrong: +0061' UESCAPE '+';
ERROR: unsafe use of string constant with Unicode escapes 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. DETAIL: String constants with Unicode escapes cannot be used when standard_conforming_strings is off.
RESET standard_conforming_strings; RESET standard_conforming_strings;
-- --