~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-14 10:07:18 UTC
  • mto: This revision was merged to the branch mainline in revision 2438.
  • Revision ID: olafvdspek@gmail.com-20111014100718-n1i5vtysh1gajn70
Use assign(), data() and size()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1000
1000
          ident_or_text
1001
1001
          {
1002
1002
            statement::CreateSchema *statement= (statement::CreateSchema *)Lex.statement;
1003
 
            statement->schema_message.mutable_engine()->add_options()->set_name($1.str);
 
1003
            statement->schema_message.mutable_engine()->add_options()->set_name($1.data());
1004
1004
          }
1005
1005
        | REPLICATE '=' TRUE_SYM
1006
1006
          {
1020
1020
          }
1021
1021
        | ident_or_text '=' ident_or_text
1022
1022
          {
1023
 
            parser::buildSchemaOption(&Lex, $1.str, $3);
 
1023
            parser::buildSchemaOption(&Lex, $1.data(), $3);
1024
1024
          }
1025
1025
        | ident_or_text '=' ulonglong_num
1026
1026
          {
1027
 
            parser::buildSchemaOption(&Lex, $1.str, $3);
 
1027
            parser::buildSchemaOption(&Lex, $1.data(), $3);
1028
1028
          }
1029
1029
        ;
1030
1030
 
1059
1059
custom_engine_option:
1060
1060
        ENGINE_SYM '=' ident_or_text
1061
1061
          {
1062
 
            Lex.table()->mutable_engine()->set_name($3.str);
 
1062
            Lex.table()->mutable_engine()->set_name($3.data());
1063
1063
          }
1064
1064
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1065
1065
          {
1066
 
            Lex.table()->mutable_options()->set_comment($3.str);
 
1066
            Lex.table()->mutable_options()->set_comment($3.data());
1067
1067
          }
1068
1068
        | AUTO_INC opt_equal ulonglong_num
1069
1069
          {
1079
1079
          }
1080
1080
        | DEFINER TEXT_STRING_sys
1081
1081
          {
1082
 
            drizzled::identifier::User user($2.str);
 
1082
            drizzled::identifier::User user($2.data());
1083
1083
            message::set_definer(*Lex.table(), user);
1084
1084
          }
1085
1085
        | DEFINER CURRENT_USER optional_braces
1096
1096
          }
1097
1097
        |  ident_or_text '=' engine_option_value
1098
1098
          {
1099
 
            parser::buildEngineOption(&Lex, $1.str, $3);
 
1099
            parser::buildEngineOption(&Lex, $1.data(), $3);
1100
1100
          }
1101
1101
        | ident_or_text '=' ulonglong_num
1102
1102
          {
1103
 
            parser::buildEngineOption(&Lex, $1.str, $3);
 
1103
            parser::buildEngineOption(&Lex, $1.data(), $3);
1104
1104
          }
1105
1105
        | default_charset
1106
1106
        | default_collation
1150
1150
row_format_or_text:
1151
1151
          row_format
1152
1152
          {
1153
 
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
 
1153
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
1154
1154
          }
1155
1155
        ;
1156
1156
 
1185
1185
        | opt_constraint constraint_key_type opt_ident key_alg
1186
1186
          '(' key_list ')' key_options
1187
1187
          {
1188
 
            parser::buildKey(&Lex, $2, $3.str ? $3 : $1);
 
1188
            parser::buildKey(&Lex, $2, $3.data() ? $3 : $1);
1189
1189
          }
1190
1190
        | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1191
1191
          {
1192
 
            parser::buildForeignKey(&Lex, $1.str ? $1 : $4, $8);
 
1192
            parser::buildForeignKey(&Lex, $1.data() ? $1 : $4, $8);
1193
1193
          }
1194
1194
        | constraint opt_check_constraint
1195
1195
          {
1230
1230
 
1231
1231
            if (Lex.field())
1232
1232
            {
1233
 
              Lex.field()->set_name($1.str);
 
1233
              Lex.field()->set_name($1.data());
1234
1234
            }
1235
1235
 
1236
1236
            if (add_field_to_list(Lex.session, &$1, (enum enum_field_types) $3,
1252
1252
          }
1253
1253
        | TIMESTAMP_SYM '(' NUM ')' opt_attribute_timestamp
1254
1254
          {
1255
 
            $$=parser::buildTimestampColumn(&Lex, $3.str);
 
1255
            $$=parser::buildTimestampColumn(&Lex, $3.data());
1256
1256
          }
1257
1257
        | DATETIME_SYM opt_attribute_timestamp
1258
1258
          {
1271
1271
          }
1272
1272
        | varchar '(' NUM ')' opt_attribute_string
1273
1273
          {
1274
 
            $$= parser::buildVarcharColumn(&Lex, $3.str);
 
1274
            $$= parser::buildVarcharColumn(&Lex, $3.data());
1275
1275
          }
1276
1276
        | TEXT_SYM opt_attribute_string
1277
1277
          {
1294
1294
          }
1295
1295
        | VARBINARY '(' NUM ')' opt_attribute
1296
1296
          {
1297
 
            $$= parser::buildVarbinaryColumn(&Lex, $3.str);
 
1297
            $$= parser::buildVarbinaryColumn(&Lex, $3.data());
1298
1298
          }
1299
1299
        | real_type opt_attribute_number
1300
1300
          {
1388
1388
          /* empty */
1389
1389
          { Lex.dec=Lex.length= NULL; }
1390
1390
        | '(' NUM ')'
1391
 
          { Lex.length=$2.str; Lex.dec= NULL; }
 
1391
          { Lex.length=$2.data(); Lex.dec= NULL; }
1392
1392
        | precision
1393
1393
          {}
1394
1394
        ;
1396
1396
precision:
1397
1397
          '(' NUM ',' NUM ')'
1398
1398
          {
1399
 
            Lex.length= $2.str;
1400
 
            Lex.dec= $4.str;
 
1399
            Lex.length= $2.data();
 
1400
            Lex.dec= $4.data();
1401
1401
          }
1402
1402
        ;
1403
1403
 
1404
1404
opt_len:
1405
1405
          /* empty */ { Lex.length= NULL; /* use default length */ }
1406
 
        | '(' NUM ')' { Lex.length= $2.str; }
 
1406
        | '(' NUM ')' { Lex.length= $2.data(); }
1407
1407
        ;
1408
1408
 
1409
1409
opt_field_number_signed:
1604
1604
            statement->comment= $2;
1605
1605
 
1606
1606
            if (Lex.field())
1607
 
              Lex.field()->set_comment($2.str);
 
1607
              Lex.field()->set_comment($2.data());
1608
1608
          }
1609
1609
        ;
1610
1610
 
1611
1611
collation_name:
1612
1612
          ident_or_text
1613
1613
          {
1614
 
            if (!($$=get_charset_by_name($1.str)))
 
1614
            if (!($$=get_charset_by_name($1.data())))
1615
1615
            {
1616
 
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str);
 
1616
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.data());
1617
1617
              DRIZZLE_YYABORT;
1618
1618
            }
1619
1619
          }
1789
1789
          ident { $$=new Key_part_spec($1, 0); }
1790
1790
        | ident '(' NUM ')'
1791
1791
          {
1792
 
            int key_part_len= atoi($3.str);
 
1792
            int key_part_len= atoi($3.data());
1793
1793
            if (!key_part_len)
1794
1794
            {
1795
 
              my_error(ER_KEY_PART_0, MYF(0), $1.str);
 
1795
              my_error(ER_KEY_PART_0, MYF(0), $1.data());
1796
1796
            }
1797
1797
            $$=new Key_part_spec($1, (uint) key_part_len);
1798
1798
          }
1916
1916
        | CHANGE_SYM opt_column field_ident
1917
1917
          {
1918
1918
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1919
 
            statement->change= $3.str;
 
1919
            statement->change= (char*)$3.data();
1920
1920
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1921
1921
          }
1922
1922
          field_spec opt_place
1944
1944
                                  statement->default_value,
1945
1945
                                  statement->on_update_value,
1946
1946
                                  &statement->comment,
1947
 
                                  $3.str, &Lex.interval_list, Lex.charset))
 
1947
                                  $3.data(), &Lex.interval_list, Lex.charset))
1948
1948
              DRIZZLE_YYABORT;
1949
1949
          }
1950
1950
          opt_place
1956
1956
            message::AlterTable::AlterTableOperation *operation;
1957
1957
            operation= Lex.alter_table()->add_operations();
1958
1958
            operation->set_operation(message::AlterTable::AlterTableOperation::DROP_COLUMN);
1959
 
            operation->set_drop_name($3.str);
 
1959
            operation->set_drop_name($3.data());
1960
1960
          }
1961
1961
        | DROP FOREIGN KEY_SYM opt_ident
1962
1962
          {
1963
 
            parser::buildAddAlterDropIndex(&Lex, $4.str, true);
 
1963
            parser::buildAddAlterDropIndex(&Lex, $4.data(), true);
1964
1964
          }
1965
1965
        | DROP PRIMARY_SYM KEY_SYM
1966
1966
          {
1968
1968
          }
1969
1969
        | DROP key_or_index field_ident
1970
1970
          {
1971
 
            parser::buildAddAlterDropIndex(&Lex, $3.str);
 
1971
            parser::buildAddAlterDropIndex(&Lex, $3.data());
1972
1972
          }
1973
1973
        | DISABLE_SYM KEYS
1974
1974
          {
1993
1993
          {
1994
1994
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1995
1995
 
1996
 
            statement->alter_info.alter_list.push_back(AlterColumn($3.str,$6));
 
1996
            statement->alter_info.alter_list.push_back(AlterColumn($3.data(),$6));
1997
1997
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1998
1998
          }
1999
1999
        | ALTER_SYM opt_column field_ident DROP DEFAULT
2000
2000
          {
2001
2001
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
2002
2002
 
2003
 
            statement->alter_info.alter_list.push_back(AlterColumn($3.str, (Item*) 0));
 
2003
            statement->alter_info.alter_list.push_back(AlterColumn($3.data(), NULL));
2004
2004
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2005
2005
          }
2006
2006
        | RENAME opt_to table_ident
2008
2008
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
2009
2009
            size_t dummy;
2010
2010
 
2011
 
            Lex.select_lex.db=$3->db.str;
 
2011
            Lex.select_lex.db= (char*)$3->db.data();
2012
2012
            if (Lex.select_lex.db == NULL &&
2013
2013
                Lex.session->copy_db_to(Lex.select_lex.db, dummy))
2014
2014
            {
2027
2027
            message::AlterTable::RenameTable *rename_operation;
2028
2028
            rename_operation= Lex.alter_table()->mutable_rename();
2029
2029
            rename_operation->set_to_schema(Lex.select_lex.db);
2030
 
            rename_operation->set_to_name(Lex.name.str);
 
2030
            rename_operation->set_to_name(Lex.name.data());
2031
2031
          }
2032
2032
        | CONVERT_SYM TO_SYM collation_name_or_default
2033
2033
          {
2073
2073
          /* empty */ {}
2074
2074
        | AFTER_SYM ident
2075
2075
          {
2076
 
            parser::storeAlterColumnPosition(&Lex, $2.str);
 
2076
            parser::storeAlterColumnPosition(&Lex, $2.data());
2077
2077
          }
2078
2078
        | FIRST_SYM
2079
2079
          {
2346
2346
 
2347
2347
            YYSession->add_item_to_list($2);
2348
2348
 
2349
 
            if ($4.str)
 
2349
            if ($4.data())
2350
2350
            {
2351
2351
              $2->is_autogenerated_name= false;
2352
2352
              $2->set_name($4.data(), $4.size(), system_charset_info);
3086
3086
function_call_generic:
3087
3087
          IDENT_sys '('
3088
3088
          {
3089
 
            const plugin::Function *udf= plugin::Function::get(std::string($1.data(), $1.size()));
 
3089
            const plugin::Function *udf= plugin::Function::get(to_string($1));
3090
3090
 
3091
3091
            /* Temporary placing the result of getFunction in $3 */
3092
3092
            $<udf>$= udf;
3115
3115
                        else 
3116
3116
                        {
3117
3117
              /* fix for bug 250065, from Andrew Garner <muzazzi@gmail.com> */
3118
 
              my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", $1.str);
 
3118
              my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", $1.data());
3119
3119
            }
3120
3120
 
3121
3121
            if (not ($$= item))
3153
3153
             because the syntax will not allow having an explicit name here.
3154
3154
             See WL#1017 re. udf attributes.
3155
3155
            */
3156
 
            if ($4.str)
 
3156
            if ($4.data())
3157
3157
            {
3158
3158
              $2->is_autogenerated_name= false;
3159
3159
              $2->set_name($4.data(), $4.size(), system_charset_info);
3241
3241
        | '@' opt_var_ident_type user_variable_ident opt_component
3242
3242
          {
3243
3243
            /* disallow "SELECT @@global.global.variable" */
3244
 
            if ($3.str && $4.str && parser::check_reserved_words(&$3))
 
3244
            if ($3.data() && $4.data() && parser::check_reserved_words(&$3))
3245
3245
            {
3246
3246
              parser::my_parse_error(YYSession->m_lip);
3247
3247
              DRIZZLE_YYABORT;
3814
3814
 
3815
3815
key_usage_element:
3816
3816
          ident
3817
 
          { Lex.current_select->add_index_hint(YYSession, $1.str); }
 
3817
          { Lex.current_select->add_index_hint(YYSession, $1.data()); }
3818
3818
        | PRIMARY_SYM
3819
3819
          { Lex.current_select->add_index_hint(YYSession, "PRIMARY"); }
3820
3820
        ;
4102
4102
        ;
4103
4103
 
4104
4104
ulong_num:
4105
 
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
4106
 
        | HEX_NUM       { $$= (unsigned long) strtol($1.str, NULL, 16); }
4107
 
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
4108
 
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
4109
 
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
4110
 
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
 
4105
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4106
        | HEX_NUM       { $$= (unsigned long) strtol($1.data(), NULL, 16); }
 
4107
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4108
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4109
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4110
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
4111
4111
        ;
4112
4112
 
4113
4113
ulonglong_num:
4114
 
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
4115
 
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
4116
 
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
4117
 
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
4118
 
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
 
4114
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4115
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4116
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4117
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4118
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
4119
4119
        ;
4120
4120
 
4121
4121
select_var_list_init:
4160
4160
          OUTFILE TEXT_STRING_filesystem
4161
4161
          {
4162
4162
            Lex.setCacheable(false);
4163
 
            Lex.exchange= new file_exchange($2.str, 0);
 
4163
            Lex.exchange= new file_exchange((char*)$2.data(), 0);
4164
4164
            Lex.result= new select_export(Lex.exchange);
4165
4165
          }
4166
4166
          opt_field_term opt_line_term
4169
4169
            if (not Lex.describe)
4170
4170
            {
4171
4171
              Lex.setCacheable(false);
4172
 
              Lex.exchange= new file_exchange($2.str,1);
 
4172
              Lex.exchange= new file_exchange((char*)$2.data(),1);
4173
4173
              Lex.result= new select_dump(Lex.exchange);
4174
4174
            }
4175
4175
          }
4206
4206
            message::AlterTable::AlterTableOperation *operation;
4207
4207
            operation= Lex.alter_table()->add_operations();
4208
4208
            operation->set_operation(message::AlterTable::AlterTableOperation::DROP_KEY);
4209
 
            operation->set_drop_name($4.str);
 
4209
            operation->set_drop_name($4.data());
4210
4210
 
4211
4211
          }
4212
4212
        | DROP DATABASE if_exists schema_name
4614
4614
 
4615
4615
opt_db:
4616
4616
          /* empty */  { $$= 0; }
4617
 
        | from_or_in ident { $$= $2.str; }
 
4617
        | from_or_in ident { $$= $2.data(); }
4618
4618
        ;
4619
4619
 
4620
4620
from_or_in:
4745
4745
          USE_SYM schema_name
4746
4746
          {
4747
4747
            Lex.statement= new statement::ChangeSchema(YYSession);
4748
 
            Lex.select_lex.db= $2.str;
 
4748
            Lex.select_lex.db= (char*)$2.data();
4749
4749
          }
4750
4750
        ;
4751
4751
 
4765
4765
            Lex.lock_option= $4;
4766
4766
            Lex.duplicates= DUP_ERROR;
4767
4767
            Lex.ignore= 0;
4768
 
            Lex.exchange= new file_exchange($6.str, 0, $2);
 
4768
            Lex.exchange= new file_exchange((char*)$6.data(), 0, $2);
4769
4769
          }
4770
4770
          opt_duplicate INTO
4771
4771
          {
4875
4875
        | IGNORE_SYM NUM lines_or_rows
4876
4876
          {
4877
4877
            assert(Lex.exchange != 0);
4878
 
            Lex.exchange->skip_lines= atol($2.str);
 
4878
            Lex.exchange->skip_lines= atol($2.data());
4879
4879
          }
4880
4880
        ;
4881
4881
 
4917
4917
        }
4918
4918
        | text_literal TEXT_STRING_literal
4919
4919
          {
4920
 
            ((Item_string*) $1)->append($2.str, $2.size());
 
4920
            ((Item_string*) $1)->append((char*)$2.data(), $2.size());
4921
4921
          }
4922
4922
        ;
4923
4923
 
5191
5191
          IDENT_sys    { $$=$1; }
5192
5192
        | keyword
5193
5193
          {
5194
 
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
 
5194
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
5195
5195
          }
5196
5196
        ;
5197
5197
 
5473
5473
internal_variable_ident:
5474
5474
          keyword_exception_for_variable
5475
5475
          {
5476
 
            $$.assign(YYSession->mem.strdup($1.str, $1.length), $1.length);
 
5476
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
5477
5477
          }
5478
5478
        | IDENT_sys    { $$=$1; }
5479
5479
        ;
5484
5484
            /* We have to lookup here since local vars can shadow sysvars */
5485
5485
            {
5486
5486
              /* Not an SP local variable */
5487
 
              sys_var *tmp= find_sys_var(std::string($1.data(), $1.size()));
 
5487
              sys_var *tmp= find_sys_var(to_string($1));
5488
5488
              if (!tmp)
5489
5489
                DRIZZLE_YYABORT;
5490
5490
              $$.var= tmp;