From: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | tgl(at)sss(dot)pgh(dot)pa(dot)us |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Funny representation in pg_stat_statements.query. |
Date: | 2014-01-21 08:30:16 |
Message-ID: | 20140121.173016.223496951.horiguchi.kyotaro@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello, I found it would be reasonably fixed by small
modifications.
> - CURRENT_TIME and the like are parsed into the nodes directly
> represents the node specs in gram.y
<blah, blah>
> Since this becomes more than a simple bug fix, I think it is too
> late for 9.4 now. I'll work on this in the longer term.
The fundamental cause of this issue is Const node which conveys
the location of other than constant tokens. Any other nodes, for
instance TypeCasts, are safe.
So this is fixed by quite simple way like following getting rid
of the referred difficulties of keeping the code sane and total
loss of token locations. (white spaces are collapsed for readability)
| --- a/src/backend/parser/gram.y
| +++ b/src/backend/parser/gram.y
| @@ -11355,8 +11355,8 @@ func_expr_common_subexpr:
| * to rely on it.)
| */
| Node *n;
| - n = makeStringConstCast("now", @1, SystemTypeName("text"));
| - $$ = makeTypeCast(n, SystemTypeName("date"), -1);
| + n = makeStringConstCast("now", -1, SystemTypeName("text"));
| + $$ = makeTypeCast(n, SystemTypeName("date"), @1);
Any suggestions? Attached is the complete patch.
As of 9.4dev, transformTypeCast passes the locations retrieved
from the source TypeCast node itself or its TypeName subnode to
the newly created CoerceViaIO node but leaves that of the inner
expressions (the "now", I mean) as it is, so I think this fits to
what transformTypeCast does more than before. The query tree
after the transformation sees like follows. I think this is
preferable to that -1 to CoerceViaIO and 7 to Const.
...
{
type = TargetEtnry
expr = {
type = CoerceViaIO, location = 7,
arg = {
type = Const, location = -1
}
}
}
In addition, the location stored in StringConstCast seems
currently not having no route to users' sight, even any step out
the node - in short 'useless'. And yet the location of
CoerceViaIO is also not used...
| | CURRENT_DATE
..
|- n = makeStringConstCast("now", @1, SystemTypeName("text")
|+ n = makeStringConstCast("nowe", @1, SystemTypeName("text")
yields only this, including logs.
| =# select CURRENT_DATE;
| ERROR: invalid input syntax for type date: "nowe"
regards,
--
Kyotaro Horiguchi
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
20140121_move_location_setting_for_CURRENT_DATE.patch | text/x-patch | 3.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2014-01-21 08:31:20 | Re: proposal: hide application_name from other users |
Previous Message | Jeevan Chalke | 2014-01-21 08:21:41 | Re: patch: option --if-exists for pg_dump |