11
11
*
12
12
*
13
13
* 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/24 14:28:06 tgl Exp $
15
15
*
16
16
* HISTORY
17
17
* AUTHOR DATE MAJOR EVENT
@@ -6002,14 +6002,6 @@ ConstDatetime:
6002
6002
* - thomas 2001-09-06
6003
6003
*/
6004
6004
$$ ->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 ;
6013
6005
}
6014
6006
| TIME ' (' Iconst ' )' opt_timezone
6015
6007
{
@@ -6039,11 +6031,6 @@ ConstDatetime:
6039
6031
$$ = SystemTypeName(" timetz" );
6040
6032
else
6041
6033
$$ = 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 ;
6047
6034
}
6048
6035
;
6049
6036
@@ -6715,7 +6702,9 @@ func_expr: func_name '(' ')'
6715
6702
*
6716
6703
* This could be simplified if we had a way to generate
6717
6704
* 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.)
6719
6708
*/
6720
6709
A_Const *s = makeNode(A_Const);
6721
6710
TypeName *d;
@@ -6742,12 +6731,6 @@ func_expr: func_name '(' ')'
6742
6731
s->typename = SystemTypeName(" text" );
6743
6732
6744
6733
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 ;
6751
6734
6752
6735
$$ = (Node *)makeTypeCast((Node *)s, d);
6753
6736
}
@@ -6784,25 +6767,15 @@ func_expr: func_name '(' ')'
6784
6767
| CURRENT_TIMESTAMP
6785
6768
{
6786
6769
/*
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.
6802
6772
*/
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;
6806
6779
}
6807
6780
| CURRENT_TIMESTAMP ' (' Iconst ' )'
6808
6781
{
@@ -6849,12 +6822,6 @@ func_expr: func_name '(' ')'
6849
6822
s->typename = SystemTypeName(" text" );
6850
6823
6851
6824
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 ;
6858
6825
6859
6826
$$ = (Node *)makeTypeCast((Node *)s, d);
6860
6827
}
@@ -6902,12 +6869,6 @@ func_expr: func_name '(' ')'
6902
6869
s->typename = SystemTypeName(" text" );
6903
6870
6904
6871
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 ;
6911
6872
6912
6873
$$ = (Node *)makeTypeCast((Node *)s, d);
6913
6874
}
0 commit comments