Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dcdcada

Browse files
author
Thomas G. Lockhart
committed
Add syntax for BIT() and BIT VARYING(), but no underlying implementation
is available yet. Remove redundant call to xlateSqlType() in the character type handling code.
1 parent 3c7ca8d commit dcdcada

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

src/backend/parser/gram.y

+47-7
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.161 2000/03/20 05:20:34 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.162 2000/03/21 06:00:40 thomas Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -249,8 +249,8 @@ static void doNegateFloat(Value *v);
249249
%type <paramno> ParamNo
250250

251251
%type <typnam> Typename, opt_type, SimpleTypename,
252-
Generic, Numeric, Character, Datetime
253-
%type <str> generic, numeric, character, datetime
252+
Generic, Numeric, Character, Datetime, Bit
253+
%type <str> generic, numeric, character, datetime, bit
254254
%type <str> extract_arg
255255
%type <str> opt_charset, opt_collate
256256
%type <str> opt_float
@@ -334,7 +334,7 @@ static void doNegateFloat(Value *v);
334334
* - Todd A. Brandys 1998-01-01?
335335
*/
336336
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE,
337-
BACKWARD, BEFORE, BINARY,
337+
BACKWARD, BEFORE, BINARY, BIT,
338338
CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
339339
DATABASE, DELIMITERS, DO,
340340
EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND,
@@ -3766,6 +3766,7 @@ Typename: SimpleTypename opt_array_bounds
37663766

37673767
SimpleTypename: Generic
37683768
| Numeric
3769+
| Bit
37693770
| Character
37703771
| Datetime
37713772
;
@@ -3901,19 +3902,53 @@ opt_decimal: '(' Iconst ',' Iconst ')'
39013902
;
39023903

39033904

3905+
/*
3906+
* SQL92 bit-field data types
3907+
* The following implements BIT() and BIT VARYING().
3908+
*/
3909+
Bit: bit '(' Iconst ')'
3910+
{
3911+
$$ = makeNode(TypeName);
3912+
$$->name = $1;
3913+
if ($3 < 1)
3914+
elog(ERROR,"length for type '%s' must be at least 1",$1);
3915+
else if ($3 > (MaxAttrSize * sizeof(char)))
3916+
elog(ERROR,"length for type '%s' cannot exceed %ld",$1,
3917+
(MaxAttrSize * sizeof(char)));
3918+
$$->typmod = $3;
3919+
}
3920+
| bit
3921+
{
3922+
$$ = makeNode(TypeName);
3923+
$$->name = $1;
3924+
/* default length, if needed, will be inserted later */
3925+
$$->typmod = -1;
3926+
}
3927+
;
3928+
3929+
bit: BIT opt_varying
3930+
{
3931+
char *type;
3932+
3933+
if ($2) type = xlateSqlType("varbit");
3934+
else type = xlateSqlType("bit");
3935+
$$ = type;
3936+
}
3937+
3938+
39043939
/*
39053940
* SQL92 character data types
39063941
* The following implements CHAR() and VARCHAR().
39073942
*/
39083943
Character: character '(' Iconst ')'
39093944
{
39103945
$$ = makeNode(TypeName);
3911-
$$->name = xlateSqlType($1);
3946+
$$->name = $1;
39123947
if ($3 < 1)
39133948
elog(ERROR,"length for type '%s' must be at least 1",$1);
39143949
else if ($3 > MaxAttrSize)
39153950
elog(ERROR,"length for type '%s' cannot exceed %ld",$1,
3916-
MaxAttrSize);
3951+
MaxAttrSize);
39173952

39183953
/* we actually implement these like a varlen, so
39193954
* the first 4 bytes is the length. (the difference
@@ -3925,7 +3960,7 @@ Character: character '(' Iconst ')'
39253960
| character
39263961
{
39273962
$$ = makeNode(TypeName);
3928-
$$->name = xlateSqlType($1);
3963+
$$->name = $1;
39293964
/* default length, if needed, will be inserted later */
39303965
$$->typmod = -1;
39313966
}
@@ -5198,9 +5233,12 @@ TypeId: ColId
51985233
{ $$ = xlateSqlType($1); }
51995234
| numeric
52005235
{ $$ = xlateSqlType($1); }
5236+
| bit
5237+
{ $$ = xlateSqlType($1); }
52015238
| character
52025239
{ $$ = xlateSqlType($1); }
52035240
;
5241+
52045242
/* Column identifier
52055243
* Include date/time keywords as SQL92 extension.
52065244
* Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05
@@ -5316,7 +5354,9 @@ ColLabel: ColId { $$ = $1; }
53165354
| ABORT_TRANS { $$ = "abort"; }
53175355
| ANALYZE { $$ = "analyze"; }
53185356
| BINARY { $$ = "binary"; }
5357+
| BIT { $$ = "bit"; }
53195358
| CASE { $$ = "case"; }
5359+
| CHARACTER { $$ = "character"; }
53205360
| CLUSTER { $$ = "cluster"; }
53215361
| COALESCE { $$ = "coalesce"; }
53225362
| CONSTRAINT { $$ = "constraint"; }

src/backend/parser/keywords.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.68 2000/03/14 23:06:32 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.69 2000/03/21 06:00:41 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -47,6 +47,7 @@ static ScanKeyword ScanKeywords[] = {
4747
{"begin", BEGIN_TRANS},
4848
{"between", BETWEEN},
4949
{"binary", BINARY},
50+
{"bit", BIT},
5051
{"both", BOTH},
5152
{"by", BY},
5253
{"cache", CACHE},

0 commit comments

Comments
 (0)