diff options
author | Monty <monty@mariadb.org> | 2017-04-23 19:39:57 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-04-23 22:35:46 +0300 |
commit | 5a759d31f766087d5e135e1d3d3d987693bc9b88 (patch) | |
tree | 93c7359e8b211e269bfa73e5f595f34b9dca575a /storage/cassandra/ha_cassandra.cc | |
parent | cba84469eb96481568a9f4ddf3f2989c49c9294c (diff) | |
download | mariadb-git-5a759d31f766087d5e135e1d3d3d987693bc9b88.tar.gz |
Changing field::field_name and Item::name to LEX_CSTRING
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)
Changes:
- This caused some ABI changes
- lex_string_set now uses LEX_CSTRING
- Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
parsing and events.
- Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
code
- Added item_empty_name and item_used_name to be able to distingush between
items that was given an empty name and items that was not given a name
This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item->name_length before some calls to
my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
give the error.
TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
(as part of lower_case_table_names)
Diffstat (limited to 'storage/cassandra/ha_cassandra.cc')
-rw-r--r-- | storage/cassandra/ha_cassandra.cc | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/storage/cassandra/ha_cassandra.cc b/storage/cassandra/ha_cassandra.cc index f95922088ff..ff758a57872 100644 --- a/storage/cassandra/ha_cassandra.cc +++ b/storage/cassandra/ha_cassandra.cc @@ -411,7 +411,7 @@ int ha_cassandra::check_field_options(Field **fields) { if (dyncol_set || (*field)->type() != MYSQL_TYPE_BLOB) { - my_error(ER_WRONG_FIELD_SPEC, MYF(0), (*field)->field_name); + my_error(ER_WRONG_FIELD_SPEC, MYF(0), (*field)->field_name.str); DBUG_RETURN(HA_WRONG_CREATE_OPTION); } dyncol_set= 1; @@ -1497,14 +1497,14 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields) for (field= field_arg + 1, i= 1; *field; field++, i++) { if ((!dyncol_set || dyncol_field != i) && - !strcmp((*field)->field_name, col_name)) + !strcmp((*field)->field_name.str, col_name)) { n_mapped++; ColumnDataConverter **conv= field_converters + (*field)->field_index; if (!(*conv= map_field_to_validator(*field, col_type))) { se->print_error("Failed to map column %s to datatype %s", - (*field)->field_name, col_type); + (*field)->field_name.str, col_type); my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str()); DBUG_RETURN(true); } @@ -1543,7 +1543,7 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields) DBUG_ASSERT(first_unmapped); se->print_error("Field `%s` could not be mapped to any field in Cassandra", - first_unmapped->field_name); + first_unmapped->field_name.str); my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str()); DBUG_RETURN(true); } @@ -1552,14 +1552,14 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields) Setup type conversion for row_key. */ se->get_rowkey_type(&col_name, &col_type); - if (col_name && strcmp(col_name, (*field_arg)->field_name)) + if (col_name && strcmp(col_name, (*field_arg)->field_name.str)) { se->print_error("PRIMARY KEY column must match Cassandra's name '%s'", col_name); my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str()); DBUG_RETURN(true); } - if (!col_name && strcmp("rowkey", (*field_arg)->field_name)) + if (!col_name && strcmp("rowkey", (*field_arg)->field_name.str)) { se->print_error("target column family has no key_alias defined, " "PRIMARY KEY column must be named 'rowkey'"); @@ -1742,14 +1742,14 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk) { uint fieldnr= (*field)->field_index; if ((!dyncol_set || dyncol_field != fieldnr) && - !strcmp((*field)->field_name, cass_name)) + !strcmp((*field)->field_name.str, cass_name)) { found= 1; (*field)->set_notnull(); if (field_converters[fieldnr]->cassandra_to_mariadb(cass_value, cass_value_len)) { - print_conversion_error((*field)->field_name, cass_value, + print_conversion_error((*field)->field_name.str, cass_value, cass_value_len); res=1; goto err; @@ -1770,7 +1770,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk) se->print_error("Unable to convert value for field `%s`" " from Cassandra's data format. Name" " length exceed limit of %u: '%s'", - table->field[dyncol_field]->field_name, + table->field[dyncol_field]->field_name.str, (uint)MAX_NAME_LENGTH, cass_name); my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str()); res=1; @@ -1782,7 +1782,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk) se->print_error("Unable to convert value for field `%s`" " from Cassandra's data format. Sum of all names" " length exceed limit of %lu", - table->field[dyncol_field]->field_name, + table->field[dyncol_field]->field_name.str, cass_name, (uint)MAX_TOTAL_NAME_LENGTH); my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str()); res=1; @@ -1841,7 +1841,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk) se->get_read_rowkey(&cass_value, &cass_value_len); if (rowkey_converter->cassandra_to_mariadb(cass_value, cass_value_len)) { - print_conversion_error((*field)->field_name, cass_value, cass_value_len); + print_conversion_error((*field)->field_name.str, cass_value, cass_value_len); res=1; goto err; } @@ -1953,7 +1953,7 @@ int ha_cassandra::write_row(uchar *buf) if (rowkey_converter->mariadb_to_cassandra(&cass_key, &cass_key_len)) { my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0), - rowkey_converter->field->field_name, insert_lineno); + rowkey_converter->field->field_name.str, insert_lineno); dbug_tmp_restore_column_map(table->read_set, old_map); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } @@ -1987,11 +1987,11 @@ int ha_cassandra::write_row(uchar *buf) &cass_data_len)) { my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0), - field_converters[i]->field->field_name, insert_lineno); + field_converters[i]->field->field_name.str, insert_lineno); dbug_tmp_restore_column_map(table->read_set, old_map); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } - se->add_insert_column(field_converters[i]->field->field_name, 0, + se->add_insert_column(field_converters[i]->field->field_name.str, 0, cass_data, cass_data_len); } } @@ -2074,7 +2074,7 @@ int ha_cassandra::rnd_init(bool scan) { se->clear_read_columns(); for (uint i= 1; i < table->s->fields; i++) - se->add_read_column(table->field[i]->field_name); + se->add_read_column(table->field[i]->field_name.str); } se->read_batch_size= THDVAR(table->in_use, rnd_batch_size); @@ -2355,7 +2355,7 @@ public: if (idx == obj->table->s->fields) return NULL; else - return obj->table->field[idx++]->field_name; + return obj->table->field[idx++]->field_name.str; } }; @@ -2386,7 +2386,7 @@ int ha_cassandra::update_row(const uchar *old_data, uchar *new_data) if (rowkey_converter->mariadb_to_cassandra(&new_key, &new_key_len)) { my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0), - rowkey_converter->field->field_name, insert_lineno); + rowkey_converter->field->field_name.str, insert_lineno); dbug_tmp_restore_column_map(table->read_set, old_map); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } @@ -2449,11 +2449,11 @@ int ha_cassandra::update_row(const uchar *old_data, uchar *new_data) if (field_converters[i]->mariadb_to_cassandra(&cass_data, &cass_data_len)) { my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0), - field_converters[i]->field->field_name, insert_lineno); + field_converters[i]->field->field_name.str, insert_lineno); dbug_tmp_restore_column_map(table->read_set, old_map); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } - se->add_insert_column(field_converters[i]->field->field_name, 0, + se->add_insert_column(field_converters[i]->field->field_name.str, 0, cass_data, cass_data_len); } } |