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

Commit0950d67

Browse files
committed
Tweak parse location assignment for CURRENT_DATE and related constructs.
All these constructs generate parse trees consisting of a Const anda run-time type coercion (perhaps a FuncExpr or a CoerceViaIO). Modifythe raw parse output so that we end up with the original token's locationattached to the type coercion node while the Const has location -1;before, it was the other way around. This makes no difference in termsof what exprLocation() will say about the parse tree as a whole, so itshould not have any user-visible impact. The point of changing it is thatwe do not want contrib/pg_stat_statements to treat these constructs asreplaceable constants. It will do the right thing if the Const haslocation -1 rather than a valid location.This is a pretty ugly hack, but then this code is ugly already; we shouldsomeday replace this translation with special-purpose parse node(s) thatwould allow ruleutils.c to reconstruct the original query text.(See also commit5d3fcc4, which alsohacked location assignment rules for the benefit of pg_stat_statements.)Back-patch to 9.2 where pg_stat_statements grew the ability to recognizereplaceable constants.Kyotaro Horiguchi
1 parent3888b73 commit0950d67

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

‎src/backend/parser/gram.y

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11234,10 +11234,15 @@ func_expr:func_name '(' ')' over_clause
1123411234
* of type-input conversion functions. (As of PG 7.3
1123511235
* that is actually possible, but not clear that we want
1123611236
* to rely on it.)
11237+
*
11238+
* The token location is attached to the run-time
11239+
* typecast, not to the Const, for the convenience of
11240+
* pg_stat_statements (which doesn't want these constructs
11241+
* to appear to be replaceable constants).
1123711242
*/
1123811243
Node *n;
11239-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11240-
$$ =makeTypeCast(n,SystemTypeName("date"),-1);
11244+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
11245+
$$ =makeTypeCast(n,SystemTypeName("date"),@1);
1124111246
}
1124211247
| CURRENT_TIME
1124311248
{
@@ -11246,8 +11251,8 @@ func_expr:func_name '(' ')' over_clause
1124611251
* See comments for CURRENT_DATE.
1124711252
*/
1124811253
Node *n;
11249-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11250-
$$ =makeTypeCast(n,SystemTypeName("timetz"),-1);
11254+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
11255+
$$ =makeTypeCast(n,SystemTypeName("timetz"),@1);
1125111256
}
1125211257
| CURRENT_TIME'(' Iconst')'
1125311258
{
@@ -11257,10 +11262,10 @@ func_expr:func_name '(' ')' over_clause
1125711262
*/
1125811263
Node *n;
1125911264
TypeName *d;
11260-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11265+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
1126111266
d =SystemTypeName("timetz");
1126211267
d->typmods =list_make1(makeIntConst($3, @3));
11263-
$$ =makeTypeCast(n, d,-1);
11268+
$$ =makeTypeCast(n, d,@1);
1126411269
}
1126511270
| CURRENT_TIMESTAMP
1126611271
{
@@ -11287,10 +11292,10 @@ func_expr:func_name '(' ')' over_clause
1128711292
*/
1128811293
Node *n;
1128911294
TypeName *d;
11290-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11295+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
1129111296
d =SystemTypeName("timestamptz");
1129211297
d->typmods =list_make1(makeIntConst($3, @3));
11293-
$$ =makeTypeCast(n, d,-1);
11298+
$$ =makeTypeCast(n, d,@1);
1129411299
}
1129511300
| LOCALTIME
1129611301
{
@@ -11299,8 +11304,8 @@ func_expr:func_name '(' ')' over_clause
1129911304
* See comments for CURRENT_DATE.
1130011305
*/
1130111306
Node *n;
11302-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11303-
$$ =makeTypeCast((Node *)n,SystemTypeName("time"),-1);
11307+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
11308+
$$ =makeTypeCast((Node *)n,SystemTypeName("time"),@1);
1130411309
}
1130511310
| LOCALTIME'(' Iconst')'
1130611311
{
@@ -11310,10 +11315,10 @@ func_expr:func_name '(' ')' over_clause
1131011315
*/
1131111316
Node *n;
1131211317
TypeName *d;
11313-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11318+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
1131411319
d =SystemTypeName("time");
1131511320
d->typmods =list_make1(makeIntConst($3, @3));
11316-
$$ =makeTypeCast((Node *)n, d,-1);
11321+
$$ =makeTypeCast((Node *)n, d,@1);
1131711322
}
1131811323
| LOCALTIMESTAMP
1131911324
{
@@ -11322,8 +11327,8 @@ func_expr:func_name '(' ')' over_clause
1132211327
* See comments for CURRENT_DATE.
1132311328
*/
1132411329
Node *n;
11325-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11326-
$$ =makeTypeCast(n,SystemTypeName("timestamp"),-1);
11330+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
11331+
$$ =makeTypeCast(n,SystemTypeName("timestamp"),@1);
1132711332
}
1132811333
| LOCALTIMESTAMP'(' Iconst')'
1132911334
{
@@ -11333,10 +11338,10 @@ func_expr:func_name '(' ')' over_clause
1133311338
*/
1133411339
Node *n;
1133511340
TypeName *d;
11336-
n =makeStringConstCast("now",@1,SystemTypeName("text"));
11341+
n =makeStringConstCast("now",-1,SystemTypeName("text"));
1133711342
d =SystemTypeName("timestamp");
1133811343
d->typmods =list_make1(makeIntConst($3, @3));
11339-
$$ =makeTypeCast(n, d,-1);
11344+
$$ =makeTypeCast(n, d,@1);
1134011345
}
1134111346
| CURRENT_ROLE
1134211347
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp