~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Padraig
  • Date: 2009-03-01 04:15:34 UTC
  • mfrom: (908 drizzle)
  • mto: (934.3.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 938.
  • Revision ID: posulliv@linux-lap-20090301041534-3p2c1l2l2436cczq
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
#include <drizzled/function/str/user.h>
56
56
#include <drizzled/function/str/weight_string.h>
57
57
 
58
 
#include <drizzled/function/time/add_time.h>
59
58
#include <drizzled/function/time/curdate.h>
60
 
#include <drizzled/function/time/curtime.h>
61
59
#include <drizzled/function/time/date_add_interval.h>
62
60
#include <drizzled/function/time/dayofmonth.h>
63
61
#include <drizzled/function/time/extract.h>
64
 
#include <drizzled/function/time/get_format.h>
65
62
#include <drizzled/function/time/hour.h>
66
63
#include <drizzled/function/time/microsecond.h>
67
64
#include <drizzled/function/time/minute.h>
413
410
 
414
411
%pure_parser                                    /* We have threads */
415
412
/*
416
 
  Currently there are 92 shift/reduce conflicts.
 
413
  Currently there are 90 shift/reduce conflicts.
417
414
  We should not introduce new conflicts any more.
418
415
*/
419
 
%expect 92
 
416
%expect 90
420
417
 
421
418
/*
422
419
   Comments for TOKENS.
515
512
%token  CURDATE                       /* MYSQL-FUNC */
516
513
%token  CURRENT_USER                  /* SQL-2003-R */
517
514
%token  CURSOR_SYM                    /* SQL-2003-R */
518
 
%token  CURTIME                       /* MYSQL-FUNC */
519
515
%token  DATABASE
520
516
%token  DATABASES
521
517
%token  DATAFILE_SYM
589
585
%token  FROM
590
586
%token  FULL                          /* SQL-2003-R */
591
587
%token  GE
592
 
%token  GET_FORMAT                    /* MYSQL-FUNC */
593
588
%token  GLOBAL_SYM                    /* SQL-2003-R */
594
589
%token  GROUP_SYM                     /* SQL-2003-R */
595
590
%token  GROUP_CONCAT_SYM
841
836
%token  TIMESTAMP                     /* SQL-2003-R */
842
837
%token  TIMESTAMP_ADD
843
838
%token  TIMESTAMP_DIFF
844
 
%token  TIME_SYM                      /* SQL-2003-R */
845
839
%token  TO_SYM                        /* SQL-2003-R */
846
840
%token  TRAILING                      /* SQL-2003-R */
847
841
%token  TRANSACTION_SYM
869
863
%token  USING                         /* SQL-2003-R */
870
864
%token  UTC_DATE_SYM
871
865
%token  UTC_TIMESTAMP_SYM
872
 
%token  UTC_TIME_SYM
873
866
%token  VALUES                        /* SQL-2003-R */
874
867
%token  VALUE_SYM                     /* SQL-2003-R */
875
868
%token  VARBINARY
1002
995
        select_derived derived_table_list
1003
996
        select_derived_union
1004
997
 
1005
 
%type <date_time_type> date_time_type;
1006
998
%type <interval> interval
1007
999
 
1008
1000
%type <interval_time_st> interval_time_st
1740
1732
          }
1741
1733
        | DATE_SYM
1742
1734
          { $$=DRIZZLE_TYPE_DATE; }
1743
 
        | TIME_SYM
1744
 
          { $$=DRIZZLE_TYPE_TIME; }
1745
1735
        | TIMESTAMP
1746
 
          {
1747
 
            /* Unlike other types TIMESTAMP fields are NOT NULL by default */
1748
 
            Lex->type|= NOT_NULL_FLAG;
1749
 
            $$=DRIZZLE_TYPE_TIMESTAMP;
1750
 
          }
 
1736
          { $$=DRIZZLE_TYPE_TIMESTAMP; }
1751
1737
        | DATETIME
1752
1738
          { $$=DRIZZLE_TYPE_DATETIME; }
1753
1739
        | BLOB_SYM
3203
3189
          { $$= new (YYSession->mem_root) Item_func_right($3,$5); }
3204
3190
        | SECOND_SYM '(' expr ')'
3205
3191
          { $$= new (YYSession->mem_root) Item_func_second($3); }
3206
 
        | TIME_SYM '(' expr ')'
3207
 
          { $$= new (YYSession->mem_root) Item_time_typecast($3); }
3208
3192
        | TIMESTAMP '(' expr ')'
3209
3193
          { $$= new (YYSession->mem_root) Item_datetime_typecast($3); }
3210
 
        | TIMESTAMP '(' expr ',' expr ')'
3211
 
          { $$= new (YYSession->mem_root) Item_func_add_time($3, $5, 1, 0); }
3212
3194
        | TRIM '(' expr ')'
3213
3195
          { $$= new (YYSession->mem_root) Item_func_trim($3); }
3214
3196
        | TRIM '(' LEADING expr FROM expr ')'
3241
3223
  MAINTAINER:
3242
3224
  The only reasons a function should be added here are:
3243
3225
  - for compatibility reasons with another SQL syntax (CURDATE),
3244
 
  - for typing reasons (GET_FORMAT)
3245
3226
  Any other 'Syntaxic sugar' enhancements should be *STRONGLY*
3246
3227
  discouraged.
3247
3228
*/
3257
3238
          {
3258
3239
            $$= new (YYSession->mem_root) Item_func_curdate_local();
3259
3240
          }
3260
 
        | CURTIME optional_braces
3261
 
          {
3262
 
            $$= new (YYSession->mem_root) Item_func_curtime_local();
3263
 
          }
3264
 
        | CURTIME '(' expr ')'
3265
 
          {
3266
 
            $$= new (YYSession->mem_root) Item_func_curtime_local($3);
3267
 
          }
3268
3241
        | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3269
3242
          { $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3270
3243
        | DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3271
3244
          { $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,1); }
3272
3245
        | EXTRACT_SYM '(' interval FROM expr ')'
3273
3246
          { $$=new (YYSession->mem_root) Item_extract( $3, $5); }
3274
 
        | GET_FORMAT '(' date_time_type  ',' expr ')'
3275
 
          { $$= new (YYSession->mem_root) Item_func_get_format($3, $5); }
3276
3247
        | NOW_SYM optional_braces
3277
3248
          {
3278
3249
            $$= new (YYSession->mem_root) Item_func_now_local();
3320
3291
          {
3321
3292
            $$= new (YYSession->mem_root) Item_func_curdate_utc();
3322
3293
          }
3323
 
        | UTC_TIME_SYM optional_braces
3324
 
          {
3325
 
            $$= new (YYSession->mem_root) Item_func_curtime_utc();
3326
 
          }
3327
3294
        | UTC_TIMESTAMP_SYM optional_braces
3328
3295
          {
3329
3296
            $$= new (YYSession->mem_root) Item_func_now_utc();
3610
3577
          { $$=ITEM_CAST_CHAR; Lex->dec= 0; }
3611
3578
        | DATE_SYM
3612
3579
          { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3613
 
        | TIME_SYM
3614
 
          { $$=ITEM_CAST_TIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3615
3580
        | DATETIME
3616
3581
          { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3617
3582
        | DECIMAL_SYM float_options
4198
4163
        | YEAR_SYM        { $$=INTERVAL_YEAR; }
4199
4164
        ;
4200
4165
 
4201
 
date_time_type:
4202
 
          DATE_SYM  {$$=DRIZZLE_TIMESTAMP_DATE;}
4203
 
        | TIME_SYM  {$$=DRIZZLE_TIMESTAMP_TIME;}
4204
 
        | DATETIME  {$$=DRIZZLE_TIMESTAMP_DATETIME;}
4205
 
        | TIMESTAMP {$$=DRIZZLE_TIMESTAMP_DATETIME;}
4206
 
        ;
4207
 
 
4208
4166
table_alias:
4209
4167
          /* empty */
4210
4168
        | AS
5517
5475
            $$= item_str;
5518
5476
          }
5519
5477
        | DATE_SYM text_literal { $$ = $2; }
5520
 
        | TIME_SYM text_literal { $$ = $2; }
5521
5478
        | TIMESTAMP text_literal { $$ = $2; }
5522
5479
        ;
5523
5480
 
5899
5856
        | FIRST_SYM                {}
5900
5857
        | FIXED_SYM                {}
5901
5858
        | FRAC_SECOND_SYM          {}
5902
 
        | GET_FORMAT               {}
5903
5859
        | GLOBAL_SYM               {}
5904
5860
        | HASH_SYM                 {}
5905
5861
        | HOSTS_SYM                {}
6013
5969
        | TIMESTAMP                {}
6014
5970
        | TIMESTAMP_ADD            {}
6015
5971
        | TIMESTAMP_DIFF           {}
6016
 
        | TIME_SYM                 {}
6017
5972
        | TYPES_SYM                {}
6018
5973
        | TYPE_SYM                 {}
6019
5974
        | UNCOMMITTED_SYM          {}