mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-32013 Add Field::val_lex_string_strmake()
There are two functions to extract a Field::val_str() value as a LEX_STRING or LEX_CSTRING pointing to the data allocated on a MEM_ROOT: char *get_field(MEM_ROOT *mem, Field *field); bool get_field(MEM_ROOT *mem, Field *field, class String *res); The first function requires strlen() calls to make a LEX_CSTRING/LEX_STRING. The second function requires a redundant String buffer, which is used only as a temporary proxy value pointing to a MEM_ROOT fragment (and does not use any String dynamic allocation methods). This patch add a native way to extract a Field::val_str() value as a LEX_STRING or LEX_CSTRING pointing to a MEM_ROOT fragment. It helps to remove redundant strlen() calls and redundant String buffers. - Adding a new method: LEX_STRING Field::val_lex_string_strmake(MEM_ROOT *mem); - Reusing the new method Field::val_lex_string_strmake() in; bool get_field(MEM_ROOT *mem, Field *field, String *res); Also, moving it from table.cc to a static function in sql_help.cc. It is used in sql_help.cc only, and we don't want it to be reused in other parts of the code (to avoid redundant String buffers). - Reusing the new method Field::val_lex_string_strmake() in this function: char *get_field(MEM_ROOT *mem, Field *field); - Replacing get_field() to Field::val_lex_string_strmake() in these files: sql_plugin.cc (redundant String buffers were removed) sql_udf.cc (redundant strlen() calls were removed) Note, this function: char *get_field(MEM_ROOT *mem, Field *field); is still used in a number of files: event_data_objects.cc event_db_repository.cc sql_acl.cc sql_servers.cc These remaining calls will be removed by separate patches, and get_field() will be removed after that.
This commit is contained in:
@@ -3404,7 +3404,6 @@ bool check_period_name(const char *name);
|
||||
bool check_table_name(const char *name, size_t length, bool check_for_path_chars);
|
||||
int rename_file_ext(const char * from,const char * to,const char * ext);
|
||||
char *get_field(MEM_ROOT *mem, Field *field);
|
||||
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
|
||||
|
||||
bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len,
|
||||
uint err_code, const char *name);
|
||||
|
Reference in New Issue
Block a user