~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Lee Bieber
  • Date: 2011-02-18 23:49:00 UTC
  • mfrom: (2182.1.4 build)
  • Revision ID: kalebral@gmail.com-20110218234900-7zxzvw9x7e7zwflr
Merge Brian - add safe_delete()
Merge Stewart - 720552: doStartIndexScan return code ignored in optimizer::sum_query() for MIN() optimization 
Merge Olaf - add register keyword
Merge Patrick - 720813: syntax error in dbqp that is breaking it

Show diffs side-by-side

added added

removed removed

Lines of Context:
298
298
%token  END_OF_INPUT                  /* INTERNAL */
299
299
%token  ENGINE_SYM
300
300
%token  ENUM_SYM
301
 
%token  EQ                            /* OPERATOR */
302
301
%token  EQUAL_SYM                     /* OPERATOR */
303
302
%token  ERRORS
304
303
%token  ESCAPED
325
324
%token  GLOBAL_SYM                    /* SQL-2003-R */
326
325
%token  GROUP_SYM                     /* SQL-2003-R */
327
326
%token  GROUP_CONCAT_SYM
328
 
%token  GT_SYM                        /* OPERATOR */
329
327
%token  HASH_SYM
330
328
%token  HAVING                        /* SQL-2003-R */
331
329
%token  HEX_NUM
375
373
%token  LOGS_SYM
376
374
%token  LONG_NUM
377
375
%token  LONG_SYM
378
 
%token  LT                            /* OPERATOR */
379
376
%token  MATCH                         /* SQL-2003-R */
380
377
%token  MAX_SYM                       /* SQL-2003-N */
381
378
%token  MAX_VALUE_SYM                 /* SQL-2003-N */
396
393
%token  NATIONAL_SYM                  /* SQL-2003-R */
397
394
%token  NATURAL                       /* SQL-2003-R */
398
395
%token  NE                            /* OPERATOR */
399
 
%token  NEG
400
396
%token  NEW_SYM                       /* SQL-2003-R */
401
397
%token  NEXT_SYM                      /* SQL-2003-N */
402
398
%token  NONE_SYM                      /* SQL-2003-R */
556
552
%token  YEAR_SYM                      /* SQL-2003-R */
557
553
%token  ZEROFILL_SYM
558
554
 
 
555
/* Lowest to highest */
559
556
%left   JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT
560
557
/* A dummy token to force the priority of table_ref production in a join. */
561
 
%left   TABLE_REF_PRIORITY
562
 
%left   SET_VAR
563
 
%left   OR_SYM
564
 
%left   XOR
565
 
%left   AND_SYM
566
 
%left   BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
567
 
%left   EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP_SYM IN_SYM
 
558
%left  TABLE_REF_PRIORITY
 
559
%left  SET_VAR
 
560
%left  OR_SYM
 
561
%left  XOR
 
562
%left  AND_SYM
 
563
%right NOT_SYM
 
564
%right '='
 
565
%nonassoc EQUAL_SYM GE '>' LE '<' NE
 
566
%nonassoc LIKE REGEXP_SYM
 
567
%nonassoc BETWEEN_SYM
 
568
%nonassoc IN_SYM
 
569
%nonassoc IS NULL_SYM TRUE_SYM FALSE_SYM
568
570
%left   '-' '+'
569
571
%left   '*' '/' '%' DIV_SYM MOD_SYM
570
 
%left   NEG
571
 
%right  NOT_SYM
572
572
%right  BINARY COLLATE_SYM
573
573
%left  INTERVAL_SYM
 
574
%right UMINUS
 
575
%left  '(' ')'
 
576
%left  '{' '}'
574
577
 
575
578
%type <lex_str>
576
579
        IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
725
728
        opt_precision opt_ignore opt_column
726
729
        set unlock string_list
727
730
        ref_list opt_match_clause opt_on_update_delete use
728
 
        opt_delete_options opt_delete_option varchar
 
731
        opt_delete_option varchar
729
732
        opt_outer table_list table_name
730
733
        opt_option opt_place
731
734
        opt_attribute opt_attribute_list attribute
733
736
        equal optional_braces
734
737
        normal_join
735
738
        table_to_table_list table_to_table opt_table_list
736
 
        single_multi
737
739
        union_clause union_list
738
740
        precision subselect_start
739
741
        subselect_end select_var_list select_var_list_init opt_len
748
750
%type <num> index_hint_clause
749
751
%type <filetype> data_file
750
752
 
751
 
%type <NONE>
752
 
        '-' '+' '*' '/' '%' '(' ')'
753
 
        ',' '!' '{' '}' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
754
 
        THEN_SYM WHEN_SYM DIV_SYM MOD_SYM DELETE_SYM
755
753
%%
756
754
 
757
755
/*
1489
1487
        ;
1490
1488
 
1491
1489
references:
1492
 
          REFERENCES
1493
 
          table_ident
1494
 
          opt_ref_list
1495
 
          opt_match_clause
1496
 
          opt_on_update_delete
 
1490
          REFERENCES table_ident opt_ref_list opt_match_clause opt_on_update_delete
1497
1491
          {
1498
1492
            $$=$2;
1499
1493
          }
1921
1915
opt_to:
1922
1916
          /* empty */ {}
1923
1917
        | TO_SYM {}
1924
 
        | EQ {}
1925
1918
        | AS {}
1926
1919
        ;
1927
1920
 
2349
2342
          { $$= new Item_func_isnotnull($1); }
2350
2343
        | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
2351
2344
          { $$= new Item_func_equal($1,$3); }
2352
 
        | bool_pri comp_op predicate %prec EQ
 
2345
        | bool_pri comp_op predicate %prec '='
2353
2346
          { $$= (*$2)(0)->create($1,$3); }
2354
 
        | bool_pri comp_op all_or_any '(' subselect ')' %prec EQ
 
2347
        | bool_pri comp_op all_or_any '(' subselect ')' %prec '='
2355
2348
          { $$= all_any_subquery_creator($1, $2, $3, $5); }
2356
2349
        | predicate
2357
2350
        ;
2465
2458
        ;
2466
2459
 
2467
2460
comp_op:
2468
 
          EQ     { $$ = &comp_eq_creator; }
 
2461
          '='     { $$ = &comp_eq_creator; }
2469
2462
        | GE     { $$ = &comp_ge_creator; }
2470
 
        | GT_SYM { $$ = &comp_gt_creator; }
 
2463
        | '>' { $$ = &comp_gt_creator; }
2471
2464
        | LE     { $$ = &comp_le_creator; }
2472
 
        | LT     { $$ = &comp_lt_creator; }
 
2465
        | '<'     { $$ = &comp_lt_creator; }
2473
2466
        | NE     { $$ = &comp_ne_creator; }
2474
2467
        ;
2475
2468
 
2484
2477
        | function_call_nonkeyword
2485
2478
        | function_call_generic
2486
2479
        | function_call_conflict
2487
 
        | simple_expr COLLATE_SYM ident_or_text %prec NEG
 
2480
        | simple_expr COLLATE_SYM ident_or_text %prec UMINUS
2488
2481
          {
2489
2482
            Item *i1= new (YYSession->mem_root) Item_string($3.str,
2490
2483
                                                      $3.length,
2497
2490
          {
2498
2491
            Lex->setSumExprUsed();
2499
2492
          }
2500
 
        | '+' simple_expr %prec NEG { $$= $2; }
2501
 
        | '-' simple_expr %prec NEG
 
2493
        | '+' simple_expr %prec UMINUS { $$= $2; }
 
2494
        | '-' simple_expr %prec UMINUS
2502
2495
          { $$= new (YYSession->mem_root) Item_func_neg($2); }
2503
2496
        | '(' subselect ')'
2504
2497
          {
2520
2513
            $$= new (YYSession->mem_root) Item_exists_subselect($3);
2521
2514
          }
2522
2515
        | '{' ident expr '}' { $$= $3; }
2523
 
        | BINARY simple_expr %prec NEG
 
2516
        | BINARY simple_expr %prec UMINUS
2524
2517
          {
2525
2518
            $$= create_func_cast(YYSession, $2, ITEM_CAST_CHAR, NULL, NULL,
2526
2519
                                 &my_charset_bin);
3681
3674
table_alias:
3682
3675
          /* empty */
3683
3676
        | AS
3684
 
        | EQ
3685
3677
        ;
3686
3678
 
3687
3679
opt_table_alias:
4178
4170
        ;
4179
4171
 
4180
4172
equal:
4181
 
          EQ {}
 
4173
          '=' {}
4182
4174
        | SET_VAR {}
4183
4175
        ;
4184
4176
 
4232
4224
/* Update rows in a table */
4233
4225
 
4234
4226
update:
4235
 
          UPDATE_SYM opt_ignore table_ident
 
4227
          UPDATE_SYM opt_ignore table_ident SET_SYM update_list
4236
4228
          {
4237
4229
            init_select(Lex);
4238
4230
            Lex->statement= new statement::Update(YYSession);
4240
4232
            Lex->duplicates= DUP_ERROR;
4241
4233
            if (not Lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4242
4234
              DRIZZLE_YYABORT;
4243
 
          }
4244
 
          SET_SYM update_list
4245
 
          {
 
4235
 
4246
4236
            if (Lex->select_lex.get_table_list()->derived)
4247
4237
            {
4248
4238
              /* it is single table update and it is update of derived table */
4290
4280
/* Delete rows from a table */
4291
4281
 
4292
4282
delete:
4293
 
          DELETE_SYM
 
4283
          DELETE_SYM opt_delete_option FROM table_ident
4294
4284
          {
4295
4285
            Lex->statement= new statement::Delete(YYSession);
4296
4286
            init_select(Lex);
4297
4287
            Lex->lock_option= TL_WRITE_DEFAULT;
4298
 
            Lex->ignore= 0;
4299
4288
            Lex->select_lex.init_order();
4300
 
          }
4301
 
          opt_delete_options single_multi
4302
 
        ;
4303
4289
 
4304
 
single_multi:
4305
 
          FROM table_ident
4306
 
          {
4307
 
            if (!Lex->current_select->add_table_to_list(YYSession, $2, NULL, TL_OPTION_UPDATING,
 
4290
            if (!Lex->current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING,
4308
4291
                                           Lex->lock_option))
4309
4292
              DRIZZLE_YYABORT;
4310
4293
          }
4312
4295
          delete_limit_clause {}
4313
4296
        ;
4314
4297
 
4315
 
opt_delete_options:
4316
 
          /* empty */ {}
4317
 
        | opt_delete_option opt_delete_options {}
4318
 
        ;
4319
 
 
4320
4298
opt_delete_option:
4321
 
         IGNORE_SYM   { Lex->ignore= 1; }
 
4299
           /* empty */ { Lex->ignore= 0; }
 
4300
         | IGNORE_SYM  { Lex->ignore= 1; }
4322
4301
        ;
4323
4302
 
4324
4303
truncate: