diff options
author | Monty <monty@mariadb.org> | 2020-08-14 21:11:30 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:27:53 +0200 |
commit | 53b43f30781fb26bf8a9764e4d852ac581edd964 (patch) | |
tree | dc6e8e3b70a7ddb5864fd1f058e694dc5c72caea /sql/item.cc | |
parent | b6ff139aa3457949a5bff10070f5b0e9ac0b43d7 (diff) | |
download | mariadb-git-53b43f30781fb26bf8a9764e4d852ac581edd964.tar.gz |
Added full_name_cstring()
This returns a LEX_CSTRING and allows one to avoid strlen() calls.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/sql/item.cc b/sql/item.cc index 5afad7eef14..d90747bb12c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -501,8 +501,7 @@ void Item::print_parenthesised(String *str, enum_query_type query_type, void Item::print(String *str, enum_query_type query_type) { - const char *name= full_name(); - str->append(name, strlen(name)); + str->append(full_name_cstring()); } @@ -3146,32 +3145,37 @@ bool Item_field::switch_to_nullable_fields_processor(void *arg) return 0; } -const char *Item_ident::full_name() const +LEX_CSTRING Item_ident::full_name_cstring() const { char *tmp; + size_t length; if (!table_name.str || !field_name.str) - return field_name.str ? field_name.str : name.str ? name.str : "tmp_field"; - + { + if (field_name.str) + return field_name; + if (name.str) + return name; + return { STRING_WITH_LEN("tmp_field") }; + } if (db_name.str && db_name.str[0]) { THD *thd= current_thd; tmp=(char*) thd->alloc((uint) db_name.length+ (uint) table_name.length + (uint) field_name.length+3); - strxmov(tmp,db_name.str,".",table_name.str,".",field_name.str,NullS); + length= (strxmov(tmp,db_name.str,".",table_name.str,".",field_name.str, + NullS) - tmp); } else { - if (table_name.str[0]) - { - THD *thd= current_thd; - tmp= (char*) thd->alloc((uint) table_name.length + - field_name.length + 2); - strxmov(tmp, table_name.str, ".", field_name.str, NullS); - } - else - return field_name.str; + if (!table_name.str[0]) + return field_name; + + THD *thd= current_thd; + tmp= (char*) thd->alloc((uint) table_name.length + + field_name.length + 2); + length= (strxmov(tmp, table_name.str, ".", field_name.str, NullS) - tmp); } - return tmp; + return {tmp, length}; } void Item_ident::print(String *str, enum_query_type query_type) |