mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03: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:
@ -739,7 +739,7 @@ Type_handler::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
|
||||
Field_double(NULL, item->max_length,
|
||||
(uchar *) (item->maybe_null ? "" : 0),
|
||||
item->maybe_null ? 1 : 0, Field::NONE,
|
||||
item->name, item->decimals, 0, item->unsigned_flag);
|
||||
&item->name, item->decimals, 0, item->unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -752,7 +752,7 @@ Type_handler_float::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
|
||||
Field_float(NULL, item->max_length,
|
||||
(uchar *) (item->maybe_null ? "" : 0),
|
||||
item->maybe_null ? 1 : 0, Field::NONE,
|
||||
item->name, item->decimals, 0, item->unsigned_flag);
|
||||
&item->name, item->decimals, 0, item->unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -767,7 +767,7 @@ Type_handler_decimal_result::make_num_distinct_aggregator_field(
|
||||
Field_new_decimal(NULL, item->max_length,
|
||||
(uchar *) (item->maybe_null ? "" : 0),
|
||||
item->maybe_null ? 1 : 0, Field::NONE,
|
||||
item->name, item->decimals, 0, item->unsigned_flag);
|
||||
&item->name, item->decimals, 0, item->unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -784,14 +784,12 @@ Type_handler_int_result::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
|
||||
Field_longlong(NULL, item->max_length,
|
||||
(uchar *) (item->maybe_null ? "" : 0),
|
||||
item->maybe_null ? 1 : 0, Field::NONE,
|
||||
item->name, 0, item->unsigned_flag);
|
||||
&item->name, 0, item->unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
#define TMPNAME ""
|
||||
|
||||
Field *Type_handler_tiny::make_conversion_table_field(TABLE *table,
|
||||
uint metadata,
|
||||
const Field *target)
|
||||
@ -805,7 +803,7 @@ Field *Type_handler_tiny::make_conversion_table_field(TABLE *table,
|
||||
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
|
||||
return new (table->in_use->mem_root)
|
||||
Field_tiny(NULL, 4 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*zerofill*/, unsigned_flag);
|
||||
&empty_clex_str, 0/*zerofill*/, unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -817,7 +815,7 @@ Field *Type_handler_short::make_conversion_table_field(TABLE *table,
|
||||
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
|
||||
return new (table->in_use->mem_root)
|
||||
Field_short(NULL, 6 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*zerofill*/, unsigned_flag);
|
||||
&empty_clex_str, 0/*zerofill*/, unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -829,7 +827,7 @@ Field *Type_handler_int24::make_conversion_table_field(TABLE *table,
|
||||
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
|
||||
return new (table->in_use->mem_root)
|
||||
Field_medium(NULL, 9 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*zerofill*/, unsigned_flag);
|
||||
&empty_clex_str, 0/*zerofill*/, unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -841,7 +839,7 @@ Field *Type_handler_long::make_conversion_table_field(TABLE *table,
|
||||
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
|
||||
return new (table->in_use->mem_root)
|
||||
Field_long(NULL, 11 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*zerofill*/, unsigned_flag);
|
||||
&empty_clex_str, 0/*zerofill*/, unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -853,7 +851,7 @@ Field *Type_handler_longlong::make_conversion_table_field(TABLE *table,
|
||||
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
|
||||
return new (table->in_use->mem_root)
|
||||
Field_longlong(NULL, 20 /*max_length*/,(uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*zerofill*/, unsigned_flag);
|
||||
&empty_clex_str, 0/*zerofill*/, unsigned_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -865,7 +863,7 @@ Field *Type_handler_float::make_conversion_table_field(TABLE *table,
|
||||
{
|
||||
return new (table->in_use->mem_root)
|
||||
Field_float(NULL, 12 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
|
||||
&empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
|
||||
}
|
||||
|
||||
|
||||
@ -876,7 +874,7 @@ Field *Type_handler_double::make_conversion_table_field(TABLE *table,
|
||||
{
|
||||
return new (table->in_use->mem_root)
|
||||
Field_double(NULL, 22 /*max_length*/, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
|
||||
&empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
|
||||
}
|
||||
|
||||
|
||||
@ -891,7 +889,7 @@ Field *Type_handler_newdecimal::make_conversion_table_field(TABLE *table,
|
||||
DBUG_ASSERT(decimals <= DECIMAL_MAX_SCALE);
|
||||
return new (table->in_use->mem_root)
|
||||
Field_new_decimal(NULL, max_length, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, decimals, 0/*zerofill*/, 0/*unsigned*/);
|
||||
&empty_clex_str, decimals, 0/*zerofill*/, 0/*unsigned*/);
|
||||
}
|
||||
|
||||
|
||||
@ -907,7 +905,7 @@ Field *Type_handler_olddecimal::make_conversion_table_field(TABLE *table,
|
||||
" column Name: %s.%s.%s.",
|
||||
target->table->s->db.str,
|
||||
target->table->s->table_name.str,
|
||||
target->field_name);
|
||||
target->field_name.str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -918,7 +916,7 @@ Field *Type_handler_year::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_year(NULL, 4, (uchar *) "", 1, Field::NONE, TMPNAME);
|
||||
Field_year(NULL, 4, (uchar *) "", 1, Field::NONE, &empty_clex_str);
|
||||
}
|
||||
|
||||
|
||||
@ -928,7 +926,7 @@ Field *Type_handler_null::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_null(NULL, 0, Field::NONE, TMPNAME, target->charset());
|
||||
Field_null(NULL, 0, Field::NONE, &empty_clex_str, target->charset());
|
||||
}
|
||||
|
||||
|
||||
@ -938,7 +936,7 @@ Field *Type_handler_timestamp::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new_Field_timestamp(table->in_use->mem_root, NULL, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME, table->s, target->decimals());
|
||||
Field::NONE, &empty_clex_str, table->s, target->decimals());
|
||||
}
|
||||
|
||||
|
||||
@ -949,7 +947,7 @@ Field *Type_handler_timestamp2::make_conversion_table_field(TABLE *table,
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_timestampf(NULL, (uchar *) "", 1, Field::NONE,
|
||||
TMPNAME, table->s, metadata);
|
||||
&empty_clex_str, table->s, metadata);
|
||||
}
|
||||
|
||||
|
||||
@ -959,7 +957,7 @@ Field *Type_handler_newdate::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_newdate(NULL, (uchar *) "", 1, Field::NONE, TMPNAME);
|
||||
Field_newdate(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str);
|
||||
}
|
||||
|
||||
|
||||
@ -969,7 +967,7 @@ Field *Type_handler_date::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_date(NULL, (uchar *) "", 1, Field::NONE, TMPNAME);
|
||||
Field_date(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str);
|
||||
}
|
||||
|
||||
|
||||
@ -979,7 +977,7 @@ Field *Type_handler_time::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new_Field_time(table->in_use->mem_root, NULL, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME, target->decimals());
|
||||
Field::NONE, &empty_clex_str, target->decimals());
|
||||
}
|
||||
|
||||
|
||||
@ -989,7 +987,7 @@ Field *Type_handler_time2::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_timef(NULL, (uchar *) "", 1, Field::NONE, TMPNAME, metadata);
|
||||
Field_timef(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata);
|
||||
}
|
||||
|
||||
|
||||
@ -999,7 +997,7 @@ Field *Type_handler_datetime::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new_Field_datetime(table->in_use->mem_root, NULL, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME, target->decimals());
|
||||
Field::NONE, &empty_clex_str, target->decimals());
|
||||
}
|
||||
|
||||
|
||||
@ -1010,7 +1008,7 @@ Field *Type_handler_datetime2::make_conversion_table_field(TABLE *table,
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_datetimef(NULL, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME, metadata);
|
||||
Field::NONE, &empty_clex_str, metadata);
|
||||
}
|
||||
|
||||
|
||||
@ -1023,7 +1021,7 @@ Field *Type_handler_bit::make_conversion_table_field(TABLE *table,
|
||||
uint32 max_length= 8 * (metadata >> 8U) + (metadata & 0x00ff);
|
||||
return new(table->in_use->mem_root)
|
||||
Field_bit_as_char(NULL, max_length, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME);
|
||||
Field::NONE, &empty_clex_str);
|
||||
}
|
||||
|
||||
|
||||
@ -1036,7 +1034,7 @@ Field *Type_handler_string::make_conversion_table_field(TABLE *table,
|
||||
uint32 max_length= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff);
|
||||
return new(table->in_use->mem_root)
|
||||
Field_string(NULL, max_length, (uchar *) "", 1,
|
||||
Field::NONE, TMPNAME, target->charset());
|
||||
Field::NONE, &empty_clex_str, target->charset());
|
||||
}
|
||||
|
||||
|
||||
@ -1047,7 +1045,7 @@ Field *Type_handler_varchar::make_conversion_table_field(TABLE *table,
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_varstring(NULL, metadata, HA_VARCHAR_PACKLENGTH(metadata),
|
||||
(uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
(uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
table->s, target->charset());
|
||||
}
|
||||
|
||||
@ -1058,7 +1056,7 @@ Field *Type_handler_tiny_blob::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
table->s, 1, target->charset());
|
||||
}
|
||||
|
||||
@ -1069,7 +1067,7 @@ Field *Type_handler_blob::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
table->s, 2, target->charset());
|
||||
}
|
||||
|
||||
@ -1080,7 +1078,7 @@ Field *Type_handler_medium_blob::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
table->s, 3, target->charset());
|
||||
}
|
||||
|
||||
@ -1091,7 +1089,7 @@ Field *Type_handler_long_blob::make_conversion_table_field(TABLE *table,
|
||||
const
|
||||
{
|
||||
return new(table->in_use->mem_root)
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
table->s, 4, target->charset());
|
||||
}
|
||||
|
||||
@ -1119,7 +1117,7 @@ Field *Type_handler_geometry::make_conversion_table_field(TABLE *table,
|
||||
The statistics was already incremented when "target" was created.
|
||||
*/
|
||||
return new(table->in_use->mem_root)
|
||||
Field_geom(NULL, (uchar *) "", 1, Field::NONE, TMPNAME, table->s, 4,
|
||||
Field_geom(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, 4,
|
||||
((const Field_geom*) target)->geom_type,
|
||||
((const Field_geom*) target)->srid);
|
||||
}
|
||||
@ -1134,7 +1132,7 @@ Field *Type_handler_enum::make_conversion_table_field(TABLE *table,
|
||||
DBUG_ASSERT(target->real_type() == MYSQL_TYPE_ENUM);
|
||||
return new(table->in_use->mem_root)
|
||||
Field_enum(NULL, target->field_length,
|
||||
(uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
(uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
metadata & 0x00ff/*pack_length()*/,
|
||||
((const Field_enum*) target)->typelib, target->charset());
|
||||
}
|
||||
@ -1149,7 +1147,7 @@ Field *Type_handler_set::make_conversion_table_field(TABLE *table,
|
||||
DBUG_ASSERT(target->real_type() == MYSQL_TYPE_SET);
|
||||
return new(table->in_use->mem_root)
|
||||
Field_set(NULL, target->field_length,
|
||||
(uchar *) "", 1, Field::NONE, TMPNAME,
|
||||
(uchar *) "", 1, Field::NONE, &empty_clex_str,
|
||||
metadata & 0x00ff/*pack_length()*/,
|
||||
((const Field_enum*) target)->typelib, target->charset());
|
||||
}
|
||||
|
Reference in New Issue
Block a user