11
11
*
12
12
*
13
13
* IDENTIFICATION
14
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.164 2000/03/27 17:12:06 thomas Exp $
14
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.165 2000/03/30 06:02:36 thomas Exp $
15
15
*
16
16
* HISTORY
17
17
* AUTHOR DATE MAJOR EVENT
@@ -297,7 +297,8 @@ static void doNegateFloat(Value *v);
297
297
COALESCE , COLLATE , COLUMN , COMMIT ,
298
298
CONSTRAINT , CONSTRAINTS , CREATE , CROSS , CURRENT , CURRENT_DATE ,
299
299
CURRENT_TIME , CURRENT_TIMESTAMP , CURRENT_USER , CURSOR ,
300
- DAY_P , DEC , DECIMAL , DECLARE , DEFAULT , DELETE , DESC , DISTINCT , DOUBLE , DROP ,
300
+ DAY_P , DEC , DECIMAL , DECLARE , DEFAULT , DELETE , DESC ,
301
+ DISTINCT , DOUBLE , DROP ,
301
302
ELSE , END_TRANS , EXCEPT , EXECUTE , EXISTS , EXTRACT ,
302
303
FALSE_P , FETCH , FLOAT , FOR , FOREIGN , FROM , FULL ,
303
304
GLOBAL , GRANT , GROUP , HAVING , HOUR_P ,
@@ -712,8 +713,71 @@ opt_level: READ COMMITTED { $$ = "committed"; }
712
713
| SERIALIZABLE { $$ = " serializable" ; }
713
714
;
714
715
715
- var_value : Sconst { $$ = $1 ; }
716
- | DEFAULT { $$ = NULL ; }
716
+ var_value : Sconst
717
+ {
718
+ /* Plain old string (pointer to char) */
719
+ $$ = $1 ;
720
+ }
721
+ | FCONST
722
+ {
723
+ /* Floating pumeric argument?
724
+ * This recently changed to preserve "stringiness" until here,
725
+ * so we don't have any work to do at all. Nice.
726
+ * - thomas 2000-03-29
727
+ */
728
+ $$ = $1 ;
729
+ }
730
+ | Iconst
731
+ {
732
+ char *result;
733
+ char buf[64 ];
734
+
735
+ /* Integer pumeric argument?
736
+ */
737
+ if (sprintf(buf, " %d" , $1 ) != 1 )
738
+ {
739
+ result = pstrdup(buf);
740
+ }
741
+ else
742
+ elog (ERROR, " Unable to convert constant to string (internal error)" );
743
+
744
+ $$ = result;
745
+ }
746
+ | name_list
747
+ {
748
+ List *n;
749
+ int llen, slen = 0 ;
750
+ char *result;
751
+
752
+ llen = length($1 );
753
+
754
+ /* List of words? Then concatenate together */
755
+ if (llen < 1 )
756
+ elog (ERROR, " SET must have at least one argument" );
757
+
758
+ foreach (n, $1 )
759
+ {
760
+ Value *p = (Value *) lfirst (n);
761
+ Assert (IsA (p, String));
762
+ /* keep track of room for string and trailing comma */
763
+ slen += (strlen (p->val .str ) + 1 );
764
+ }
765
+ result = palloc(slen + 1 );
766
+ *result = ' \0 ' ;
767
+ foreach (n, $1 )
768
+ {
769
+ Value *p = (Value *) lfirst (n);
770
+ strcat (result, p->val .str );
771
+ strcat (result, " ," );
772
+ }
773
+ /* remove the trailing comma from the last element */
774
+ *(result+strlen(result)-1 ) = ' \0 ' ;
775
+ $$ = result;
776
+ }
777
+ | DEFAULT
778
+ {
779
+ $$ = NULL ;
780
+ }
717
781
;
718
782
719
783
zone_value : Sconst { $$ = $1 ; }
@@ -1609,9 +1673,9 @@ TriggerFuncArgs: TriggerFuncArg
1609
1673
1610
1674
TriggerFuncArg : ICONST
1611
1675
{
1612
- char *s = ( char *) palloc( 64 ) ;
1613
- sprintf (s , " %d" , $1 );
1614
- $$ = s ;
1676
+ char buf[ 64 ] ;
1677
+ sprintf (buf , " %d" , $1 );
1678
+ $$ = pstrdup(buf) ;
1615
1679
}
1616
1680
| FCONST { $$ = $1 ; }
1617
1681
| Sconst { $$ = $1 ; }
@@ -3396,7 +3460,7 @@ opt_select_limit: LIMIT select_limit_value ',' select_offset_value
3396
3460
{ $$ = lappend(lappend(NIL, NULL ), NULL ); }
3397
3461
;
3398
3462
3399
- select_limit_value : Iconst
3463
+ select_limit_value : Iconst
3400
3464
{
3401
3465
Const *n = makeNode(Const);
3402
3466
@@ -5236,6 +5300,15 @@ UserId: IDENT { $$ = $1; };
5236
5300
* some of these keywords will have to be removed from this
5237
5301
* list due to shift/reduce conflicts in yacc. If so, move
5238
5302
* down to the ColLabel entity. - thomas 1997-11-06
5303
+ * These show up as operators, ans will screw up the parsing if
5304
+ * allowed as identifiers or labels.
5305
+ * Thanks to Tom Lane for pointing this out. - thomas 2000-03-29
5306
+ | BETWEEN { $$ = "between"; }
5307
+ | IN { $$ = "in"; }
5308
+ | IS { $$ = "is"; }
5309
+ | ISNULL { $$ = "isnull"; }
5310
+ | NOTNULL { $$ = "notnull"; }
5311
+ | OVERLAPS { $$ = "overlaps"; }
5239
5312
*/
5240
5313
ColId : IDENT { $$ = $1 ; }
5241
5314
| datetime { $$ = $1 ; }
@@ -5249,7 +5322,6 @@ ColId: IDENT { $$ = $1; }
5249
5322
| BACKWARD { $$ = " backward" ; }
5250
5323
| BEFORE { $$ = " before" ; }
5251
5324
| BEGIN_TRANS { $$ = " begin" ; }
5252
- | BETWEEN { $$ = " between" ; }
5253
5325
| BY { $$ = " by" ; }
5254
5326
| CACHE { $$ = " cache" ; }
5255
5327
| CASCADE { $$ = " cascade" ; }
@@ -5281,16 +5353,13 @@ ColId: IDENT { $$ = $1; }
5281
5353
| GRANT { $$ = " grant" ; }
5282
5354
| HANDLER { $$ = " handler" ; }
5283
5355
| IMMEDIATE { $$ = " immediate" ; }
5284
- | IN { $$ = " in" ; }
5285
5356
| INCREMENT { $$ = " increment" ; }
5286
5357
| INDEX { $$ = " index" ; }
5287
5358
| INHERITS { $$ = " inherits" ; }
5288
5359
| INSENSITIVE { $$ = " insensitive" ; }
5289
5360
| INSERT { $$ = " insert" ; }
5290
5361
| INSTEAD { $$ = " instead" ; }
5291
5362
| INTERVAL { $$ = " interval" ; }
5292
- | IS { $$ = " is" ; }
5293
- | ISNULL { $$ = " isnull" ; }
5294
5363
| ISOLATION { $$ = " isolation" ; }
5295
5364
| KEY { $$ = " key" ; }
5296
5365
| LANGUAGE { $$ = " language" ; }
@@ -5309,13 +5378,11 @@ ColId: IDENT { $$ = $1; }
5309
5378
| NOCREATEUSER { $$ = " nocreateuser" ; }
5310
5379
| NOTHING { $$ = " nothing" ; }
5311
5380
| NOTIFY { $$ = " notify" ; }
5312
- | NOTNULL { $$ = " notnull" ; }
5313
5381
| OF { $$ = " of" ; }
5314
5382
| OIDS { $$ = " oids" ; }
5315
5383
| ONLY { $$ = " only" ; }
5316
5384
| OPERATOR { $$ = " operator" ; }
5317
5385
| OPTION { $$ = " option" ; }
5318
- | OVERLAPS { $$ = " overlaps" ; }
5319
5386
| PARTIAL { $$ = " partial" ; }
5320
5387
| PASSWORD { $$ = " password" ; }
5321
5388
| PENDANT { $$ = " pendant" ; }
@@ -5375,12 +5442,23 @@ ColId: IDENT { $$ = $1; }
5375
5442
* Add other keywords to this list. Note that they appear here
5376
5443
* rather than in ColId if there was a shift/reduce conflict
5377
5444
* when used as a full identifier. - thomas 1997-11-06
5445
+ * These show up as operators, ans will screw up the parsing if
5446
+ * allowed as identifiers or labels.
5447
+ * Thanks to Tom Lane for pointing this out. - thomas 2000-03-29
5448
+ | ALL { $$ = "all"; }
5449
+ | ANY { $$ = "any"; }
5450
+ | EXCEPT { $$ = "except"; }
5451
+ | INTERSECT { $$ = "intersect"; }
5452
+ | LIKE { $$ = "like"; }
5453
+ | NOT { $$ = "not"; }
5454
+ | NULLIF { $$ = "nullif"; }
5455
+ | NULL_P { $$ = "null_p"; }
5456
+ | OR { $$ = "or"; }
5457
+ | UNION { $$ = "union"; }
5378
5458
*/
5379
5459
ColLabel : ColId { $$ = $1 ; }
5380
5460
| ABORT_TRANS { $$ = " abort" ; }
5381
- | ALL { $$ = " all" ; }
5382
5461
| ANALYZE { $$ = " analyze" ; }
5383
- | ANY { $$ = " any" ; }
5384
5462
| ASC { $$ = " asc" ; }
5385
5463
| BINARY { $$ = " binary" ; }
5386
5464
| BIT { $$ = " bit" ; }
@@ -5411,7 +5489,6 @@ ColLabel: ColId { $$ = $1; }
5411
5489
| DO { $$ = " do" ; }
5412
5490
| ELSE { $$ = " else" ; }
5413
5491
| END_TRANS { $$ = " end" ; }
5414
- | EXCEPT { $$ = " except" ; }
5415
5492
| EXISTS { $$ = " exists" ; }
5416
5493
| EXPLAIN { $$ = " explain" ; }
5417
5494
| EXTEND { $$ = " extend" ; }
@@ -5427,12 +5504,10 @@ ColLabel: ColId { $$ = $1; }
5427
5504
| HAVING { $$ = " having" ; }
5428
5505
| INITIALLY { $$ = " initially" ; }
5429
5506
| INNER_P { $$ = " inner" ; }
5430
- | INTERSECT { $$ = " intersect" ; }
5431
5507
| INTO { $$ = " into" ; }
5432
5508
| JOIN { $$ = " join" ; }
5433
5509
| LEADING { $$ = " leading" ; }
5434
5510
| LEFT { $$ = " left" ; }
5435
- | LIKE { $$ = " like" ; }
5436
5511
| LISTEN { $$ = " listen" ; }
5437
5512
| LOAD { $$ = " load" ; }
5438
5513
| LOCAL { $$ = " local" ; }
@@ -5442,13 +5517,9 @@ ColLabel: ColId { $$ = $1; }
5442
5517
| NCHAR { $$ = " nchar" ; }
5443
5518
| NEW { $$ = " new" ; }
5444
5519
| NONE { $$ = " none" ; }
5445
- | NOT { $$ = " not" ; }
5446
- | NULLIF { $$ = " nullif" ; }
5447
- | NULL_P { $$ = " null_p" ; }
5448
5520
| NUMERIC { $$ = " numeric" ; }
5449
5521
| OFFSET { $$ = " offset" ; }
5450
5522
| ON { $$ = " on" ; }
5451
- | OR { $$ = " or" ; }
5452
5523
| ORDER { $$ = " order" ; }
5453
5524
| OUTER_P { $$ = " outer" ; }
5454
5525
| POSITION { $$ = " position" ; }
@@ -5470,7 +5541,6 @@ ColLabel: ColId { $$ = $1; }
5470
5541
| TRANSACTION { $$ = " transaction" ; }
5471
5542
| TRIM { $$ = " trim" ; }
5472
5543
| TRUE_P { $$ = " true" ; }
5473
- | UNION { $$ = " union" ; }
5474
5544
| UNIQUE { $$ = " unique" ; }
5475
5545
| USER { $$ = " user" ; }
5476
5546
| USING { $$ = " using" ; }
0 commit comments