mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
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)
This commit is contained in:
parent
cba84469eb
commit
5a759d31f7
233 changed files with 4155 additions and 3794 deletions
|
|
@ -419,7 +419,7 @@ static int federated_rollback(handlerton *hton, THD *thd, bool all);
|
|||
|
||||
/* Federated storage engine handlerton */
|
||||
|
||||
static handler *federated_create_handler(handlerton *hton,
|
||||
static handler *federated_create_handler(handlerton *hton,
|
||||
TABLE_SHARE *table,
|
||||
MEM_ROOT *mem_root)
|
||||
{
|
||||
|
|
@ -753,9 +753,9 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table,
|
|||
share->table_name++;
|
||||
share->table_name_length= (uint) strlen(share->table_name);
|
||||
|
||||
DBUG_PRINT("info",
|
||||
DBUG_PRINT("info",
|
||||
("internal format, parsed table_name share->connection_string \
|
||||
%s share->table_name %s",
|
||||
%s share->table_name %s",
|
||||
share->connection_string, share->table_name));
|
||||
|
||||
/*
|
||||
|
|
@ -777,9 +777,9 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table,
|
|||
*/
|
||||
share->table_name= strmake_root(mem_root, table->s->table_name.str,
|
||||
(share->table_name_length= table->s->table_name.length));
|
||||
DBUG_PRINT("info",
|
||||
DBUG_PRINT("info",
|
||||
("internal format, default table_name share->connection_string \
|
||||
%s share->table_name %s",
|
||||
%s share->table_name %s",
|
||||
share->connection_string, share->table_name));
|
||||
}
|
||||
|
||||
|
|
@ -971,8 +971,8 @@ uint ha_federated::convert_row_to_internal_format(uchar *record,
|
|||
static bool emit_key_part_name(String *to, KEY_PART_INFO *part)
|
||||
{
|
||||
DBUG_ENTER("emit_key_part_name");
|
||||
if (append_ident(to, part->field->field_name,
|
||||
strlen(part->field->field_name), ident_quote_char))
|
||||
if (append_ident(to, part->field->field_name.str,
|
||||
part->field->field_name.length, ident_quote_char))
|
||||
DBUG_RETURN(1); // Out of memory
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -1234,7 +1234,7 @@ read_range_first: start_key 3 end_key 3
|
|||
|
||||
Summary:
|
||||
|
||||
* If the start key flag is 0 the max key flag shouldn't even be set,
|
||||
* If the start key flag is 0 the max key flag shouldn't even be set,
|
||||
and if it is, the query produced would be invalid.
|
||||
* Multipart keys, even if containing some or all numeric columns,
|
||||
are treated the same as non-numeric keys
|
||||
|
|
@ -1533,8 +1533,8 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
|
|||
query.append(STRING_WITH_LEN("SELECT "));
|
||||
for (field= table->field; *field; field++)
|
||||
{
|
||||
append_ident(&query, (*field)->field_name,
|
||||
strlen((*field)->field_name), ident_quote_char);
|
||||
append_ident(&query, (*field)->field_name.str,
|
||||
(*field)->field_name.length, ident_quote_char);
|
||||
query.append(STRING_WITH_LEN(", "));
|
||||
}
|
||||
/* chops off trailing comma */
|
||||
|
|
@ -1542,7 +1542,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
|
|||
|
||||
query.append(STRING_WITH_LEN(" FROM "));
|
||||
|
||||
append_ident(&query, tmp_share.table_name,
|
||||
append_ident(&query, tmp_share.table_name,
|
||||
tmp_share.table_name_length, ident_quote_char);
|
||||
|
||||
if (!(share= (FEDERATED_SHARE *) memdup_root(&mem_root, (char*)&tmp_share, sizeof(*share))) ||
|
||||
|
|
@ -1762,7 +1762,7 @@ bool ha_federated::append_stmt_insert(String *query)
|
|||
insert_string.append(STRING_WITH_LEN("INSERT IGNORE INTO "));
|
||||
else
|
||||
insert_string.append(STRING_WITH_LEN("INSERT INTO "));
|
||||
append_ident(&insert_string, share->table_name, share->table_name_length,
|
||||
append_ident(&insert_string, share->table_name, share->table_name_length,
|
||||
ident_quote_char);
|
||||
tmp_length= insert_string.length();
|
||||
insert_string.append(STRING_WITH_LEN(" ("));
|
||||
|
|
@ -1776,8 +1776,8 @@ bool ha_federated::append_stmt_insert(String *query)
|
|||
if (bitmap_is_set(table->write_set, (*field)->field_index))
|
||||
{
|
||||
/* append the field name */
|
||||
append_ident(&insert_string, (*field)->field_name,
|
||||
strlen((*field)->field_name), ident_quote_char);
|
||||
append_ident(&insert_string, (*field)->field_name.str,
|
||||
(*field)->field_name.length, ident_quote_char);
|
||||
|
||||
/* append commas between both fields and fieldnames */
|
||||
/*
|
||||
|
|
@ -1926,11 +1926,11 @@ int ha_federated::write_row(uchar *buf)
|
|||
if (bulk_insert.length == 0)
|
||||
{
|
||||
char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE];
|
||||
String insert_string(insert_buffer, sizeof(insert_buffer),
|
||||
String insert_string(insert_buffer, sizeof(insert_buffer),
|
||||
&my_charset_bin);
|
||||
insert_string.length(0);
|
||||
append_stmt_insert(&insert_string);
|
||||
dynstr_append_mem(&bulk_insert, insert_string.ptr(),
|
||||
dynstr_append_mem(&bulk_insert, insert_string.ptr(),
|
||||
insert_string.length());
|
||||
}
|
||||
else
|
||||
|
|
@ -2068,7 +2068,7 @@ int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
|||
|
||||
query.set_charset(system_charset_info);
|
||||
query.append(STRING_WITH_LEN("OPTIMIZE TABLE "));
|
||||
append_ident(&query, share->table_name, share->table_name_length,
|
||||
append_ident(&query, share->table_name, share->table_name_length,
|
||||
ident_quote_char);
|
||||
|
||||
if (real_query(query.ptr(), query.length()))
|
||||
|
|
@ -2090,7 +2090,7 @@ int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt)
|
|||
|
||||
query.set_charset(system_charset_info);
|
||||
query.append(STRING_WITH_LEN("REPAIR TABLE "));
|
||||
append_ident(&query, share->table_name, share->table_name_length,
|
||||
append_ident(&query, share->table_name, share->table_name_length,
|
||||
ident_quote_char);
|
||||
if (check_opt->flags & T_QUICK)
|
||||
query.append(STRING_WITH_LEN(" QUICK"));
|
||||
|
|
@ -2190,8 +2190,8 @@ int ha_federated::update_row(const uchar *old_data, const uchar *new_data)
|
|||
{
|
||||
if (bitmap_is_set(table->write_set, (*field)->field_index))
|
||||
{
|
||||
size_t field_name_length= strlen((*field)->field_name);
|
||||
append_ident(&update_string, (*field)->field_name, field_name_length,
|
||||
append_ident(&update_string, (*field)->field_name.str,
|
||||
(*field)->field_name.length,
|
||||
ident_quote_char);
|
||||
update_string.append(STRING_WITH_LEN(" = "));
|
||||
|
||||
|
|
@ -2216,8 +2216,8 @@ int ha_federated::update_row(const uchar *old_data, const uchar *new_data)
|
|||
|
||||
if (bitmap_is_set(table->read_set, (*field)->field_index))
|
||||
{
|
||||
size_t field_name_length= strlen((*field)->field_name);
|
||||
append_ident(&where_string, (*field)->field_name, field_name_length,
|
||||
append_ident(&where_string, (*field)->field_name.str,
|
||||
(*field)->field_name.length,
|
||||
ident_quote_char);
|
||||
if (field_in_record_is_null(table, *field, (char*) old_data))
|
||||
where_string.append(STRING_WITH_LEN(" IS NULL "));
|
||||
|
|
@ -2299,8 +2299,8 @@ int ha_federated::delete_row(const uchar *buf)
|
|||
found++;
|
||||
if (bitmap_is_set(table->read_set, cur_field->field_index))
|
||||
{
|
||||
append_ident(&delete_string, (*field)->field_name,
|
||||
strlen((*field)->field_name), ident_quote_char);
|
||||
append_ident(&delete_string, (*field)->field_name.str,
|
||||
(*field)->field_name.length, ident_quote_char);
|
||||
data_string.length(0);
|
||||
if (cur_field->is_null())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue