1111 *
1212 *
1313 * IDENTIFICATION
14- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.275 2001/11/16 04:08:33 tgl Exp $
14+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.276 2001/12/09 04:39:39 thomas Exp $
1515 *
1616 * HISTORY
1717 * AUTHORDATEMAJOR EVENT
@@ -888,16 +888,26 @@ zone_value: Sconst
888888{
889889A_Const *n = (A_Const *) makeStringConst($2 ,$1 );
890890if ($3 != -1 )
891- n->typename ->typmod = (($3 <<16 ) |0xFFFF );
891+ {
892+ if (($3 & ~(MASK(HOUR) | MASK(MINUTE))) !=0 )
893+ elog (ERROR," Time zone interval must be HOUR or HOUR TO MINUTE" );
894+ n->typename ->typmod = ((($3 &0x7FFF ) <<16 ) |0xFFFF );
895+ }
892896$$ = (Node *)n;
893897}
894898| ConstInterval ' (' Iconst ' )' Sconst opt_interval
895899{
896900A_Const *n = (A_Const *) makeStringConst($5 ,$1 );
897901if ($6 != -1 )
898- n->typename ->typmod = (($6 <<16 ) |$3 );
902+ {
903+ if (($6 & ~(MASK(HOUR) | MASK(MINUTE))) !=0 )
904+ elog (ERROR," Time zone interval must be HOUR or HOUR TO MINUTE" );
905+ n->typename ->typmod = ((($6 &0x7FFF ) <<16 ) |$3 );
906+ }
899907else
908+ {
900909n->typename ->typmod = ((0x7FFF <<16 ) |$3 );
910+ }
901911
902912$$ = (Node *)n;
903913}
@@ -4328,10 +4338,14 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone_x
43284338 * - thomas 2001-09-06
43294339*/
43304340$$ ->timezone =$2 ;
4331- /* SQL99 specified a default precision of six.
4332- * - thomas 2001-09-30
4341+ /* SQL99 specified a default precision of six
4342+ * for schema definitions. But for timestamp
4343+ * literals we don't want to throw away precision
4344+ * so leave this as unspecified for now.
4345+ * Later, we may want a different production
4346+ * for schemas. - thomas 2001-12-07
43334347*/
4334- $$ ->typmod =6 ;
4348+ $$ ->typmod =- 1 ;
43354349}
43364350| TIME ' (' Iconst ' )' opt_timezone
43374351{
@@ -4353,9 +4367,10 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone_x
43534367else
43544368$$ ->name = xlateSqlType(" time" );
43554369/* SQL99 specified a default precision of zero.
4356- * - thomas 2001-09-30
4370+ * See comments for timestamp above on why we will
4371+ * leave this unspecified for now. - thomas 2001-12-07
43574372*/
4358- $$ ->typmod =0 ;
4373+ $$ ->typmod =- 1 ;
43594374}
43604375;
43614376
@@ -5009,7 +5024,12 @@ c_expr: attr
50095024
50105025d->name = xlateSqlType(" timetz" );
50115026d->setof =FALSE ;
5012- d->typmod =0 ;
5027+ /* SQL99 mandates a default precision of zero for TIME
5028+ * fields in schemas. However, for CURRENT_TIME
5029+ * let's preserve the microsecond precision we
5030+ * might see from the system clock. - thomas 2001-12-07
5031+ */
5032+ d->typmod =6 ;
50135033
50145034$$ = (Node *)makeTypeCast((Node *)s, d);
50155035}
@@ -5058,11 +5078,13 @@ c_expr: attr
50585078t->setof =FALSE ;
50595079t->typmod = -1 ;
50605080
5061- /* SQL99 mandates a default precision of 6
5062- * for timestamp. - thomas 2001-10-04
5063- */
50645081d->name = xlateSqlType(" timestamptz" );
50655082d->setof =FALSE ;
5083+ /* SQL99 mandates a default precision of 6 for timestamp.
5084+ * Also, that is about as precise as we will get since
5085+ * we are using a microsecond time interface.
5086+ * - thomas 2001-12-07
5087+ */
50665088d->typmod =6 ;
50675089
50685090$$ = (Node *)makeTypeCast((Node *)s, d);