10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.131 2000/01/18 23:30:20 petere Exp $
13
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.132 2000/01/20 02:24:50 tgl Exp $
14
14
*
15
15
* HISTORY
16
16
* AUTHOR DATE MAJOR EVENT
@@ -1032,6 +1032,7 @@ columnDef: ColId Typename ColConstraintList
1032
1032
n->colname = $1 ;
1033
1033
n->typename = makeNode(TypeName);
1034
1034
n->typename ->name = xlateSqlType(" integer" );
1035
+ n->typename ->typmod = -1 ;
1035
1036
n->raw_default = NULL ;
1036
1037
n->cooked_default = NULL ;
1037
1038
n->is_not_null = TRUE ;
@@ -2280,6 +2281,7 @@ func_return: set_opt TypeId
2280
2281
n->name = $2 ;
2281
2282
n->setof = $1 ;
2282
2283
n->arrayBounds = NULL ;
2284
+ n->typmod = -1 ;
2283
2285
$$ = (Node *)n;
2284
2286
}
2285
2287
;
@@ -3643,12 +3645,13 @@ Numeric: FLOAT opt_float
3643
3645
| DOUBLE PRECISION
3644
3646
{
3645
3647
$$ = makeNode(TypeName);
3646
- $$ ->name = xlateSqlType(" float" );
3648
+ $$ ->name = xlateSqlType(" float8" );
3649
+ $$ ->typmod = -1 ;
3647
3650
}
3648
3651
| DECIMAL opt_decimal
3649
3652
{
3650
3653
$$ = makeNode(TypeName);
3651
- $$ ->name = xlateSqlType(" numeric " );
3654
+ $$ ->name = xlateSqlType(" decimal " );
3652
3655
$$ ->typmod = $2 ;
3653
3656
}
3654
3657
| NUMERIC opt_numeric
@@ -3664,7 +3667,7 @@ numeric: FLOAT
3664
3667
| DOUBLE PRECISION
3665
3668
{ $$ = xlateSqlType(" float8" ); }
3666
3669
| DECIMAL
3667
- { $$ = xlateSqlType(" numeric " ); }
3670
+ { $$ = xlateSqlType(" decimal " ); }
3668
3671
| NUMERIC
3669
3672
{ $$ = xlateSqlType(" numeric" ); }
3670
3673
;
@@ -3707,7 +3710,8 @@ opt_numeric: '(' Iconst ',' Iconst ')'
3707
3710
}
3708
3711
| /* EMPTY*/
3709
3712
{
3710
- $$ = ((NUMERIC_DEFAULT_PRECISION << 16 ) | NUMERIC_DEFAULT_SCALE) + VARHDRSZ;
3713
+ /* Insert "-1" meaning "default"; may be replaced later */
3714
+ $$ = -1 ;
3711
3715
}
3712
3716
;
3713
3717
@@ -3732,53 +3736,39 @@ opt_decimal: '(' Iconst ',' Iconst ')'
3732
3736
}
3733
3737
| /* EMPTY*/
3734
3738
{
3735
- $$ = ((NUMERIC_DEFAULT_PRECISION << 16 ) | NUMERIC_DEFAULT_SCALE) + VARHDRSZ;
3739
+ /* Insert "-1" meaning "default"; may be replaced later */
3740
+ $$ = -1 ;
3736
3741
}
3737
3742
;
3738
3743
3739
3744
3740
- /* SQL92 character data types
3745
+ /*
3746
+ * SQL92 character data types
3741
3747
* The following implements CHAR() and VARCHAR().
3742
3748
*/
3743
3749
Character : character ' (' Iconst ' )'
3744
3750
{
3745
3751
$$ = makeNode(TypeName);
3746
- if (strcasecmp($1 , " char" ) == 0 )
3747
- $$ ->name = xlateSqlType(" bpchar" );
3748
- else if (strcasecmp($1 , " varchar" ) == 0 )
3749
- $$ ->name = xlateSqlType(" varchar" );
3750
- else
3751
- yyerror (" internal parsing error; unrecognized character type" );
3752
-
3752
+ $$ ->name = xlateSqlType($1 );
3753
3753
if ($3 < 1 )
3754
- elog (ERROR," length for '%s' type must be at least 1" ,$1 );
3754
+ elog (ERROR," length for type '%s' must be at least 1" ,$1 );
3755
3755
else if ($3 > MaxAttrSize)
3756
3756
elog (ERROR," length for type '%s' cannot exceed %ld" ,$1 ,
3757
3757
MaxAttrSize);
3758
3758
3759
- /* we actually implement this sort of like a varlen, so
3759
+ /* we actually implement these like a varlen, so
3760
3760
* the first 4 bytes is the length. (the difference
3761
- * between this and "text" is that we blank-pad and
3762
- * truncate where necessary
3761
+ * between these and "text" is that we blank-pad and
3762
+ * truncate where necessary)
3763
3763
*/
3764
3764
$$ ->typmod = VARHDRSZ + $3 ;
3765
3765
}
3766
3766
| character
3767
3767
{
3768
3768
$$ = makeNode(TypeName);
3769
- /* Let's try to make all single-character types into bpchar(1)
3770
- * - thomas 1998-05-07
3771
- */
3772
- if (strcasecmp($1 , " char" ) == 0 )
3773
- {
3774
- $$ ->name = xlateSqlType(" bpchar" );
3775
- $$ ->typmod = VARHDRSZ + 1 ;
3776
- }
3777
- else
3778
- {
3779
- $$ ->name = xlateSqlType($1 );
3780
- $$ ->typmod = -1 ;
3781
- }
3769
+ $$ ->name = xlateSqlType($1 );
3770
+ /* default length, if needed, will be inserted later */
3771
+ $$ ->typmod = -1 ;
3782
3772
}
3783
3773
;
3784
3774
@@ -5131,6 +5121,7 @@ ColLabel: ColId { $$ = $1; }
5131
5121
| EXPLAIN { $$ = " explain" ; }
5132
5122
| EXTEND { $$ = " extend" ; }
5133
5123
| FALSE_P { $$ = " false" ; }
5124
+ | FLOAT { $$ = " float" ; }
5134
5125
| FOREIGN { $$ = " foreign" ; }
5135
5126
| GLOBAL { $$ = " global" ; }
5136
5127
| GROUP { $$ = " group" ; }
@@ -5314,6 +5305,10 @@ xlateSqlType(char *name)
5314
5305
else if (!strcasecmp (name, " real" )
5315
5306
|| !strcasecmp (name, " float" ))
5316
5307
return " float8" ;
5308
+ else if (!strcasecmp (name, " decimal" ))
5309
+ return " numeric" ;
5310
+ else if (!strcasecmp (name, " char" ))
5311
+ return " bpchar" ;
5317
5312
else if (!strcasecmp (name, " interval" ))
5318
5313
return " timespan" ;
5319
5314
else if (!strcasecmp (name, " boolean" ))
0 commit comments