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

Commiteda5126

Browse files
author
Thomas G. Lockhart
committed
Allow variable (unrestricted) precision for TIME and TIMESTAMP types in parser.
1 parentcd8b354 commiteda5126

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

‎src/backend/parser/gram.y

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
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
{
889889
A_Const *n = (A_Const *) makeStringConst($2,$1);
890890
if ($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')'Sconstopt_interval
895899
{
896900
A_Const *n = (A_Const *) makeStringConst($5,$1);
897901
if ($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+
}
899907
else
908+
{
900909
n->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
43534367
else
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

50105025
d->name = xlateSqlType("timetz");
50115026
d->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
50585078
t->setof =FALSE;
50595079
t->typmod = -1;
50605080

5061-
/* SQL99 mandates a default precision of 6
5062-
* for timestamp. - thomas 2001-10-04
5063-
*/
50645081
d->name = xlateSqlType("timestamptz");
50655082
d->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+
*/
50665088
d->typmod =6;
50675089

50685090
$$ = (Node *)makeTypeCast((Node *)s, d);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp