~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Olaf van der Spek
  • Date: 2011-10-10 17:33:19 UTC
  • mto: (2430.1.6 rf)
  • mto: This revision was merged to the branch mainline in revision 2438.
  • Revision ID: olafvdspek@gmail.com-20111010173319-k840ouy4sdrixp60
USe data() and size()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1150
1150
row_format_or_text:
1151
1151
          row_format
1152
1152
          {
1153
 
            $$.str= YYSession->mem.strdup($1.str, $1.length);
1154
 
            $$.length= $1.length;
 
1153
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
1155
1154
          }
1156
1155
        ;
1157
1156
 
2010
2009
              DRIZZLE_YYABORT;
2011
2010
            }
2012
2011
 
2013
 
            if (check_table_name($3->table.str,$3->table.length))
 
2012
            if (check_table_name($3->table.data(), $3->table.size()))
2014
2013
            {
2015
 
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
 
2014
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.data());
2016
2015
              DRIZZLE_YYABORT;
2017
2016
            }
2018
2017
 
2344
2343
            if ($4.str)
2345
2344
            {
2346
2345
              $2->is_autogenerated_name= false;
2347
 
              $2->set_name($4.str, $4.length, system_charset_info);
 
2346
              $2->set_name($4.data(), $4.size(), system_charset_info);
2348
2347
            }
2349
2348
            else if (!$2->name)
2350
2349
            {
2686
2685
        | function_call_conflict
2687
2686
        | simple_expr COLLATE_SYM ident_or_text %prec UMINUS
2688
2687
          {
2689
 
            Item *i1= new (YYSession->mem_root) Item_string($3.str,
2690
 
                                                      $3.length,
2691
 
                                                      YYSession->charset());
 
2688
            Item *i1= new (YYSession->mem_root) Item_string($3.data(), $3.size(), YYSession->charset());
2692
2689
            $$= new (YYSession->mem_root) Item_func_set_collation($1, i1);
2693
2690
          }
2694
2691
        | literal
3083
3080
function_call_generic:
3084
3081
          IDENT_sys '('
3085
3082
          {
3086
 
            const plugin::Function *udf= plugin::Function::get(std::string($1.str, $1.length));
 
3083
            const plugin::Function *udf= plugin::Function::get(std::string($1.data(), $1.size()));
3087
3084
 
3088
3085
            /* Temporary placing the result of getFunction in $3 */
3089
3086
            $<udf>$= udf;
3153
3150
            if ($4.str)
3154
3151
            {
3155
3152
              $2->is_autogenerated_name= false;
3156
 
              $2->set_name($4.str, $4.length, system_charset_info);
 
3153
              $2->set_name($4.data(), $4.size(), system_charset_info);
3157
3154
            }
3158
3155
            else
3159
3156
              $2->set_name($1, (uint) ($3 - $1), YYSession->charset());
3825
3822
          ident
3826
3823
          {
3827
3824
            $$= new List<String>;
3828
 
            $$->push_back(new (YYSession->mem_root) String($1.str, $1.length, system_charset_info));
 
3825
            $$->push_back(new (YYSession->mem_root) String($1.data(), $1.size(), system_charset_info));
3829
3826
          }
3830
3827
        | using_list ',' ident
3831
3828
          {
3832
 
            $1->push_back(new (YYSession->mem_root) String($3.str, $3.length, system_charset_info));
 
3829
            $1->push_back(new (YYSession->mem_root) String($3.data(), $3.size(), system_charset_info));
3833
3830
            $$= $1;
3834
3831
          }
3835
3832
        ;
4080
4077
        ;
4081
4078
 
4082
4079
limit_option:
4083
 
          ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
4084
 
        | LONG_NUM      { $$= new Item_uint($1.str, $1.length); }
4085
 
        | NUM           { $$= new Item_uint($1.str, $1.length); }
 
4080
          ULONGLONG_NUM { $$= new Item_uint($1.data(), $1.size()); }
 
4081
        | LONG_NUM      { $$= new Item_uint($1.data(), $1.size()); }
 
4082
        | NUM           { $$= new Item_uint($1.data(), $1.size()); }
4086
4083
        ;
4087
4084
 
4088
4085
delete_limit_clause:
4623
4620
          /* empty */
4624
4621
        | LIKE TEXT_STRING_sys
4625
4622
          {
4626
 
            Lex.wild= new (YYSession->mem_root) String($2.str, $2.length, system_charset_info);
 
4623
            Lex.wild= new (YYSession->mem_root) String($2.data(), $2.size(), system_charset_info);
4627
4624
          }
4628
4625
        | WHERE expr
4629
4626
          {
4666
4663
        | text_string { Lex.wild= $1; }
4667
4664
        | ident
4668
4665
          {
4669
 
            Lex.wild= new (YYSession->mem_root) String($1.str, $1.length, system_charset_info);
 
4666
            Lex.wild= new (YYSession->mem_root) String($1.data(), $1.size(), system_charset_info);
4670
4667
          }
4671
4668
        ;
4672
4669
 
4910
4907
text_literal:
4911
4908
        TEXT_STRING_literal
4912
4909
        {
4913
 
          $$ = new Item_string($1.str, $1.length, YYSession->variables.getCollation());
 
4910
          $$ = new Item_string($1.data(), $1.size(), YYSession->variables.getCollation());
4914
4911
        }
4915
4912
        | text_literal TEXT_STRING_literal
4916
4913
          {
4917
 
            ((Item_string*) $1)->append($2.str, $2.length);
 
4914
            ((Item_string*) $1)->append($2.str, $2.size());
4918
4915
          }
4919
4916
        ;
4920
4917
 
4921
4918
text_string:
4922
4919
          TEXT_STRING_literal
4923
4920
          {
4924
 
            $$= new (YYSession->mem_root) String($1.str,
4925
 
                                             $1.length,
4926
 
                                             YYSession->variables.getCollation());
 
4921
            $$= new (YYSession->mem_root) String($1.data(), $1.size(), YYSession->variables.getCollation());
4927
4922
          }
4928
4923
        | HEX_NUM
4929
4924
          {
4930
 
            Item *tmp= new Item_hex_string($1.str, $1.length);
 
4925
            Item *tmp= new Item_hex_string($1.data(), $1.size());
4931
4926
            /*
4932
4927
              it is OK only emulate fix_fields, because we need only
4933
4928
              value of constant
4938
4933
          }
4939
4934
        | BIN_NUM
4940
4935
          {
4941
 
            Item *tmp= new Item_bin_string($1.str, $1.length);
 
4936
            Item *tmp= new Item_bin_string($1.data(), $1.size());
4942
4937
            /*
4943
4938
              it is OK only emulate fix_fields, because we need only
4944
4939
              value of constant
4968
4963
          }
4969
4964
        | FALSE_SYM { $$= new drizzled::item::False(); }
4970
4965
        | TRUE_SYM { $$= new drizzled::item::True(); }
4971
 
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
4972
 
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
 
4966
        | HEX_NUM { $$ = new Item_hex_string($1.data(), $1.size());}
 
4967
        | BIN_NUM { $$= new Item_bin_string($1.data(), $1.size()); }
4973
4968
        | DATE_SYM text_literal { $$ = $2; }
4974
4969
        | TIMESTAMP_SYM text_literal { $$ = $2; }
4975
4970
        ;
4976
4971
 
4977
4972
integer_literal:
4978
4973
          text_literal { $$ = $1; }
4979
 
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
4980
 
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
 
4974
        | HEX_NUM { $$ = new Item_hex_string($1.data(), $1.size());}
 
4975
        | BIN_NUM { $$= new Item_bin_string($1.data(), $1.size()); }
4981
4976
        | NUM_literal { $$ = $1; }
4982
4977
        | NULL_SYM
4983
4978
          {
5024
5019
          NUM
5025
5020
          {
5026
5021
            int error;
5027
 
            $$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
 
5022
            $$ = new Item_int($1.data(), internal::my_strtoll10($1.data(), NULL, &error), $1.size());
5028
5023
          }
5029
5024
        | LONG_NUM
5030
5025
          {
5031
5026
            int error;
5032
 
            $$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
 
5027
            $$ = new Item_int($1.data(), internal::my_strtoll10($1.data(), NULL, &error), $1.size());
5033
5028
          }
5034
5029
        | ULONGLONG_NUM
5035
 
          { $$ = new Item_uint($1.str, $1.length); }
 
5030
          { $$ = new Item_uint($1.data(), $1.size()); }
5036
5031
        | DECIMAL_NUM
5037
5032
          {
5038
 
            $$= new Item_decimal($1.str, $1.length, YYSession->charset());
 
5033
            $$= new Item_decimal($1.data(), $1.size(), YYSession->charset());
5039
5034
            if (YYSession->is_error())
5040
5035
            {
5041
5036
              DRIZZLE_YYABORT;
5043
5038
          }
5044
5039
        | FLOAT_NUM
5045
5040
          {
5046
 
            $$ = new Item_float($1.str, $1.length);
 
5041
            $$ = new Item_float($1.data(), $1.size());
5047
5042
            if (YYSession->is_error())
5048
5043
            {
5049
5044
              DRIZZLE_YYABORT;
5155
5150
          {
5156
5151
            const charset_info_st * const cs= system_charset_info;
5157
5152
            int dummy_error;
5158
 
            uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
5159
 
                                                 $1.str+$1.length,
5160
 
                                                 $1.length, &dummy_error);
5161
 
            if (wlen < $1.length)
 
5153
            uint32_t wlen= cs->cset->well_formed_len(cs, $1.begin(), $1.end(), $1.size(), &dummy_error);
 
5154
            if (wlen < $1.size())
5162
5155
            {
5163
 
              my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
5164
 
                       cs->csname, $1.str + wlen);
 
5156
              my_error(ER_INVALID_CHARACTER_STRING, MYF(0), cs->csname, $1.data() + wlen);
5165
5157
              DRIZZLE_YYABORT;
5166
5158
            }
5167
5159
            $$= $1;
5193
5185
          IDENT_sys    { $$=$1; }
5194
5186
        | keyword
5195
5187
          {
5196
 
            $$.str= YYSession->mem.strdup($1.str, $1.length);
5197
 
            $$.length= $1.length;
 
5188
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
5198
5189
          }
5199
5190
        ;
5200
5191
 
5476
5467
internal_variable_ident:
5477
5468
          keyword_exception_for_variable
5478
5469
          {
5479
 
            $$.str= YYSession->mem.strdup($1.str, $1.length);
5480
 
            $$.length= $1.length;
 
5470
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
5481
5471
          }
5482
5472
        | IDENT_sys    { $$=$1; }
5483
5473
        ;
5488
5478
            /* We have to lookup here since local vars can shadow sysvars */
5489
5479
            {
5490
5480
              /* Not an SP local variable */
5491
 
              sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
 
5481
              sys_var *tmp= find_sys_var(std::string($1.data(), $1.size()));
5492
5482
              if (!tmp)
5493
5483
                DRIZZLE_YYABORT;
5494
5484
              $$.var= tmp;