Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d3fcc4

Browse files
committed
Bend parse location rules for the convenience of pg_stat_statements.
Generally, the parse location assigned to a multiple-token construct isthe location of its leftmost token. This commit breaks that rule forthe syntaxes TYPENAME 'LITERAL' and CAST(CONSTANT AS TYPENAME) --- theresulting Const will have the location of the literal string, not thetypename or CAST keyword. The cases where this matters are pretty thin onthe ground (no error messages in the regression tests change, for example),and it's unlikely that any user would be confused anyway by an error cursorpointing at the literal. But still it's less than consistent. The reasonfor changing it is that contrib/pg_stat_statements wants to know the parselocation of the original literal, and it was agreed that this is the leastunpleasant way to preserve that information through parse analysis.Peter Geoghegan
1 parenta40fa61 commit5d3fcc4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎src/backend/parser/parse_coerce.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ coerce_type(ParseState *pstate, Node *node,
280280
newcon->constlen=typeLen(targetType);
281281
newcon->constbyval=typeByVal(targetType);
282282
newcon->constisnull=con->constisnull;
283-
/* Use the leftmost of the constant's and coercion's locations */
284-
if (location<0)
285-
newcon->location=con->location;
286-
elseif (con->location >=0&&con->location<location)
287-
newcon->location=con->location;
288-
else
289-
newcon->location=location;
283+
284+
/*
285+
* We use the original literal'slocation regardless of the position
286+
* of the coercion. This is a change from pre-9.2 behavior, meant to
287+
* simplify life for pg_stat_statements.
288+
*/
289+
newcon->location=con->location;
290290

291291
/*
292292
* Set up to point at the constant's text if the input routine throws

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp