~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Lee Bieber
  • Date: 2011-01-28 02:32:26 UTC
  • mfrom: (2114.4.10 alter-table)
  • mto: This revision was merged to the branch mainline in revision 2124.
  • Revision ID: kalebral@gmail.com-20110128023226-11i88kemmdygtz0d
Merge Brian - more parser rework

Show diffs side-by-side

added added

removed removed

Lines of Context:
647
647
        table_wild simple_expr udf_expr
648
648
        expr_or_default set_expr_or_default
649
649
        signed_literal now_or_signed_literal opt_escape
650
 
        simple_ident_nospvar simple_ident_q
 
650
        simple_ident_q
651
651
        field_or_var limit_option
652
652
        function_call_keyword
653
653
        function_call_nonkeyword
977
977
          }
978
978
        | ident_or_text equal ident_or_text
979
979
          {
980
 
            parser::buildSchemaOption(YYSession, $1.str, $3);
 
980
            parser::buildSchemaOption(Lex, $1.str, $3);
981
981
          }
982
982
        | ident_or_text equal ulonglong_num
983
983
          {
984
 
            parser::buildSchemaOption(YYSession, $1.str, $3);
 
984
            parser::buildSchemaOption(Lex, $1.str, $3);
985
985
          }
986
986
        ;
987
987
 
1028
1028
          }
1029
1029
        |  ROW_FORMAT_SYM equal row_format_or_text
1030
1030
          {
1031
 
            parser::buildEngineOption(YYSession, "ROW_FORMAT", $3);
 
1031
            parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
1032
1032
          }
1033
1033
        |  FILE_SYM equal TEXT_STRING_sys
1034
1034
          {
1035
 
            parser::buildEngineOption(YYSession, "FILE", $3);
 
1035
            parser::buildEngineOption(Lex, "FILE", $3);
1036
1036
          }
1037
1037
        |  ident_or_text equal engine_option_value
1038
1038
          {
1039
 
            parser::buildEngineOption(YYSession, $1.str, $3);
 
1039
            parser::buildEngineOption(Lex, $1.str, $3);
1040
1040
          }
1041
1041
        | ident_or_text equal ulonglong_num
1042
1042
          {
1043
 
            parser::buildEngineOption(YYSession, $1.str, $3);
 
1043
            parser::buildEngineOption(Lex, $1.str, $3);
1044
1044
          }
1045
1045
        | default_collation
1046
1046
        ;
1182
1182
field_spec:
1183
1183
          field_ident
1184
1184
          {
1185
 
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1186
 
            Lex->length= Lex->dec=0;
1187
 
            Lex->type=0;
1188
 
            statement->default_value= statement->on_update_value= 0;
1189
 
            statement->comment= null_lex_str;
1190
 
            Lex->charset= NULL;
1191
 
            statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1192
 
 
1193
 
            message::AlterTable &alter_proto= ((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1194
 
            Lex->setField(alter_proto.add_added_field());
 
1185
            parser::buildCreateFieldIdent(Lex);
1195
1186
          }
1196
1187
          field_def
1197
1188
          {
1213
1204
            Lex->setField(NULL);
1214
1205
          }
1215
1206
        ;
 
1207
 
1216
1208
field_def:
1217
1209
          field_definition opt_attribute {}
1218
1210
        ;
2731
2723
            $$= new (YYSession->mem_root) Item_default_value(Lex->current_context(),
2732
2724
                                                         $3);
2733
2725
          }
2734
 
        | VALUES '(' simple_ident_nospvar ')'
 
2726
        | VALUES '(' simple_ident ')'
2735
2727
          {
2736
2728
            $$= new (YYSession->mem_root) Item_insert_value(Lex->current_context(),
2737
2729
                                                        $3);
3982
3974
        ;
3983
3975
 
3984
3976
alter_order_item:
3985
 
          simple_ident_nospvar order_dir
 
3977
          simple_ident order_dir
3986
3978
          {
3987
3979
            bool ascending= ($2 == 1) ? true : false;
3988
3980
            if (YYSession->add_order_to_list($1, ascending))
4002
3994
order_clause:
4003
3995
          ORDER_SYM BY
4004
3996
          {
4005
 
            if (not parser::buildOrderBy(YYSession))
 
3997
            if (not parser::buildOrderBy(Lex))
4006
3998
              DRIZZLE_YYABORT;
4007
3999
          }
4008
4000
          order_list
4358
4350
        ;
4359
4351
 
4360
4352
ident_eq_value:
4361
 
          simple_ident_nospvar equal expr_or_default
 
4353
          simple_ident equal expr_or_default
4362
4354
          {
4363
4355
            if (Lex->field_list.push_back($1) ||
4364
4356
                Lex->insert_list->push_back($3))
4455
4447
        ;
4456
4448
 
4457
4449
update_elem:
4458
 
          simple_ident_nospvar equal expr_or_default
 
4450
          simple_ident equal expr_or_default
4459
4451
          {
4460
4452
            if (YYSession->add_item_to_list($1) || YYSession->add_value_to_list($3))
4461
4453
              DRIZZLE_YYABORT;
4468
4460
        ;
4469
4461
 
4470
4462
insert_update_elem:
4471
 
          simple_ident_nospvar equal expr_or_default
 
4463
          simple_ident equal expr_or_default
4472
4464
          {
4473
4465
          if (Lex->update_list.push_back($1) ||
4474
4466
              Lex->value_list.push_back($3))
4912
4904
        ;
4913
4905
 
4914
4906
field_or_var:
4915
 
          simple_ident_nospvar {$$= $1;}
 
4907
          simple_ident {$$= $1;}
4916
4908
        | '@' user_variable_ident
4917
4909
          { $$= new Item_user_var_as_out_param($2); }
4918
4910
        ;
5027
5019
**********************************************************************/
5028
5020
 
5029
5021
insert_ident:
5030
 
          simple_ident_nospvar { $$=$1; }
 
5022
          simple_ident { $$=$1; }
5031
5023
        | table_wild { $$=$1; }
5032
5024
        ;
5033
5025
 
5034
5026
table_wild:
5035
5027
          ident '.' '*'
5036
5028
          {
5037
 
            Select_Lex *sel= Lex->current_select;
5038
 
            $$ = new Item_field(Lex->current_context(), NULL, $1.str, "*");
5039
 
            sel->with_wild++;
 
5029
            $$= parser::buildTableWild(Lex, NULL_LEX_STRING, $1);
5040
5030
          }
5041
5031
        | ident '.' ident '.' '*'
5042
5032
          {
5043
 
            Select_Lex *sel= Lex->current_select;
5044
 
            $$ = new Item_field(Lex->current_context(), $1.str, $3.str,"*");
5045
 
            sel->with_wild++;
 
5033
            $$= parser::buildTableWild(Lex, $1, $3);
5046
5034
          }
5047
5035
        ;
5048
5036
 
5053
5041
simple_ident:
5054
5042
          ident
5055
5043
          {
5056
 
            {
5057
 
              Select_Lex *sel=Lex->current_select;
5058
 
              $$= (sel->parsing_place != IN_HAVING ||
5059
 
                  sel->get_in_sum_expr() > 0) ?
5060
 
                  (Item*) new Item_field(Lex->current_context(),
5061
 
                                         (const char *)NULL, NULL, $1.str) :
5062
 
                  (Item*) new Item_ref(Lex->current_context(),
5063
 
                                       (const char *)NULL, NULL, $1.str);
5064
 
            }
5065
 
          }
5066
 
        | simple_ident_q { $$= $1; }
5067
 
        ;
5068
 
 
5069
 
simple_ident_nospvar:
5070
 
          ident
5071
 
          {
5072
 
            Select_Lex *sel=Lex->current_select;
5073
 
            $$= (sel->parsing_place != IN_HAVING ||
5074
 
                sel->get_in_sum_expr() > 0) ?
5075
 
                (Item*) new Item_field(Lex->current_context(),
5076
 
                                       (const char *)NULL, NULL, $1.str) :
5077
 
                (Item*) new Item_ref(Lex->current_context(),
5078
 
                                     (const char *)NULL, NULL, $1.str);
 
5044
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, NULL_LEX_STRING, $1);
5079
5045
          }
5080
5046
        | simple_ident_q { $$= $1; }
5081
5047
        ;
5083
5049
simple_ident_q:
5084
5050
          ident '.' ident
5085
5051
          {
5086
 
            $$= parser::buildIdent(YYSession, NULL_LEX_STRING, $1, $3);
 
5052
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5087
5053
          }
5088
5054
        | '.' ident '.' ident
5089
5055
          {
5090
 
            $$= parser::buildIdent(YYSession, NULL_LEX_STRING, $2, $4);
 
5056
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5091
5057
          }
5092
5058
        | ident '.' ident '.' ident
5093
5059
          {
5094
 
            $$= parser::buildIdent(YYSession, $1, $3, $5);
 
5060
            $$= parser::buildIdent(Lex, $1, $3, $5);
5095
5061
          }
5096
5062
        ;
5097
5063
 
5102
5068
          }
5103
5069
        | ident '.' ident '.' ident
5104
5070
          {
5105
 
            if (not parser::checkFieldIdent(YYSession, $1, $3))
 
5071
            if (not parser::checkFieldIdent(Lex, $1, $3))
5106
5072
              DRIZZLE_YYABORT;
5107
5073
 
5108
5074
            $$=$5;
5109
5075
          }
5110
5076
        | ident '.' ident
5111
5077
          {
5112
 
            if (not parser::checkFieldIdent(YYSession, NULL_LEX_STRING, $1))
 
5078
            if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5113
5079
              DRIZZLE_YYABORT;
5114
5080
 
5115
5081
            $$=$3;
5121
5087
        ;
5122
5088
 
5123
5089
table_ident:
5124
 
          ident { $$=new Table_ident($1); }
5125
 
        | schema_name '.' ident { $$=new Table_ident($1,$3);}
5126
 
        | '.' ident { $$=new Table_ident($2);} /* For Delphi */
 
5090
          ident
 
5091
          {
 
5092
            $$= new Table_ident($1);
 
5093
          }
 
5094
        | schema_name '.' ident
 
5095
          {
 
5096
            $$=new Table_ident($1,$3);
 
5097
          }
 
5098
        | '.' ident
 
5099
        { /* For Delphi */
 
5100
          $$= new Table_ident($2);
 
5101
        }
5127
5102
        ;
5128
5103
 
5129
5104
schema_name:
5625
5600
              fake->no_table_names_allowed= 1;
5626
5601
              Lex->current_select= fake;
5627
5602
            }
5628
 
            YYSession->where= "global ORDER clause";
 
5603
            YYSession->setWhere("global ORDER clause");
5629
5604
          }
5630
5605
          order_or_limit
5631
5606
          {
5632
5607
            YYSession->lex->current_select->no_table_names_allowed= 0;
5633
 
            YYSession->where= "";
 
5608
            YYSession->setWhere("");
5634
5609
          }
5635
5610
        ;
5636
5611