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

Commitdb53fa6

Browse files
committed
Remove overspecification of precision of CURRENT_TIMESTAMP, LOCALTIMESTAMP,
CURRENT_TIME, and LOCALTIME: now they just produce "timestamptz" not"timestamptz(6)", etc. This makes the behavior more consistent with ourchoice to not assign a specific default precision to column datatypes.It should also save a few cycles at runtime due to not having to invokethe round-to-given-precision functions.I also took the opportunity to translate CURRENT_TIMESTAMP into "now()"instead of an invocation of the timestamptz input converter --- this shouldsave a few cycles too.
1 parente2d088d commitdb53fa6

File tree

1 file changed

+12
-51
lines changed

1 file changed

+12
-51
lines changed

‎src/backend/parser/gram.y

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.496 2005/06/22 21:14:29 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.497 2005/06/2414:28:06 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -6002,14 +6002,6 @@ ConstDatetime:
60026002
* - thomas 2001-09-06
60036003
*/
60046004
$$->timezone =$2;
6005-
/* SQL99 specified a default precision of six
6006-
* for schema definitions. But for timestamp
6007-
* literals we don't want to throw away precision
6008-
* so leave this as unspecified for now.
6009-
* Later, we may want a different production
6010-
* for schemas. - thomas 2001-12-07
6011-
*/
6012-
$$->typmod = -1;
60136005
}
60146006
| TIME'(' Iconst')' opt_timezone
60156007
{
@@ -6039,11 +6031,6 @@ ConstDatetime:
60396031
$$ = SystemTypeName("timetz");
60406032
else
60416033
$$ = SystemTypeName("time");
6042-
/* SQL99 specified a default precision of zero.
6043-
* See comments for timestamp above on why we will
6044-
* leave this unspecified for now. - thomas 2001-12-07
6045-
*/
6046-
$$->typmod = -1;
60476034
}
60486035
;
60496036

@@ -6715,7 +6702,9 @@ func_expr:func_name '(' ')'
67156702
*
67166703
* This could be simplified if we had a way to generate
67176704
* an expression tree representing runtime application
6718-
* of type-input conversion functions...
6705+
* of type-input conversion functions. (As of PG 7.3
6706+
* that is actually possible, but not clear that we want
6707+
* to rely on it.)
67196708
*/
67206709
A_Const *s = makeNode(A_Const);
67216710
TypeName *d;
@@ -6742,12 +6731,6 @@ func_expr:func_name '(' ')'
67426731
s->typename = SystemTypeName("text");
67436732

67446733
d = SystemTypeName("timetz");
6745-
/* SQL99 mandates a default precision of zero for TIME
6746-
* fields in schemas. However, for CURRENT_TIME
6747-
* let's preserve the microsecond precision we
6748-
* might see from the system clock. - thomas 2001-12-07
6749-
*/
6750-
d->typmod =6;
67516734

67526735
$$ = (Node *)makeTypeCast((Node *)s, d);
67536736
}
@@ -6784,25 +6767,15 @@ func_expr:func_name '(' ')'
67846767
| CURRENT_TIMESTAMP
67856768
{
67866769
/*
6787-
* Translate as "'now'::text::timestamptz".
6788-
* See comments for CURRENT_DATE.
6789-
*/
6790-
A_Const *s = makeNode(A_Const);
6791-
TypeName *d;
6792-
6793-
s->val.type = T_String;
6794-
s->val.val.str ="now";
6795-
s->typename = SystemTypeName("text");
6796-
6797-
d = SystemTypeName("timestamptz");
6798-
/* SQL99 mandates a default precision of 6 for timestamp.
6799-
* Also, that is about as precise as we will get since
6800-
* we are using a microsecond time interface.
6801-
* - thomas 2001-12-07
6770+
* Translate as "now()", since we have a function that
6771+
* does exactly what is needed.
68026772
*/
6803-
d->typmod =6;
6804-
6805-
$$ = (Node *)makeTypeCast((Node *)s, d);
6773+
FuncCall *n = makeNode(FuncCall);
6774+
n->funcname = SystemFuncName("now");
6775+
n->args = NIL;
6776+
n->agg_star =FALSE;
6777+
n->agg_distinct =FALSE;
6778+
$$ = (Node *)n;
68066779
}
68076780
| CURRENT_TIMESTAMP'(' Iconst')'
68086781
{
@@ -6849,12 +6822,6 @@ func_expr:func_name '(' ')'
68496822
s->typename = SystemTypeName("text");
68506823

68516824
d = SystemTypeName("time");
6852-
/* SQL99 mandates a default precision of zero for TIME
6853-
* fields in schemas. However, for LOCALTIME
6854-
* let's preserve the microsecond precision we
6855-
* might see from the system clock. - thomas 2001-12-07
6856-
*/
6857-
d->typmod =6;
68586825

68596826
$$ = (Node *)makeTypeCast((Node *)s, d);
68606827
}
@@ -6902,12 +6869,6 @@ func_expr:func_name '(' ')'
69026869
s->typename = SystemTypeName("text");
69036870

69046871
d = SystemTypeName("timestamp");
6905-
/* SQL99 mandates a default precision of 6 for timestamp.
6906-
* Also, that is about as precise as we will get since
6907-
* we are using a microsecond time interface.
6908-
* - thomas 2001-12-07
6909-
*/
6910-
d->typmod =6;
69116872

69126873
$$ = (Node *)makeTypeCast((Node *)s, d);
69136874
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp