Hi, Nikita, On Jul 05, Nikita Malyavin wrote:
On Sat, 24 Jun 2023 at 18:51, Sergei Golubchik <serg@mariadb.org> wrote:
@@ -1228,6 +1228,15 @@ class Query_arena { return strdup_root(mem_root,str); } inline char *strmake(const char *str, size_t size) const { return strmake_root(mem_root,str,size); } + inline LEX_CSTRING strcat(const LEX_CSTRING &a, const LEX_CSTRING &b) const + { + char *buf= (char*)alloc(a.length + b.length + 1); + if (unlikely(!buf)) + return null_clex_str; + strncpy(buf, a.str, a.length);
memcpy both ↑ and ↓ (and then you might need to append \0 explicitly)
Ok, ↑ will be faster, but why ↓?
LEX_CSTRING defines a string by a pointer and a length. You shouldn't use functions that stop at first '\0'. In some contexts (for table names, for example) it might be ok, but here you create a generic LEX_CSTRING concatenation, let's not implicitly assume that there are not zero bytes inside.
+ strncpy(buf + a.length, b.str, b.length + 1); + return {buf, a.length + b.length}; + } inline void *memdup(const void *str, size_t size) const { return memdup_root(mem_root,str,size); } inline void *memdup_w_gap(const void *str, size_t size, size_t gap) const diff --git a/sql/sql_table.cc b/sql/sql_table.cc --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9869,26 +9869,21 @@ bool online_alter_check_autoinc(const THD *thd, const Alter_info *alter_info, */ for (uint k= 0; k < table->s->keys; k++) { - const KEY &key= table->s->key_info[k]; + const KEY &key= table->key_info[k];
This is generally incorrect. User specified keys are in table->s->key_info[] Keys in table->key_info[] can be modified to match what indexes are actually created, in particular, for long uniques table->key_info[] differs from table->s->key_info[]
Maybe, but hopefully, long unique is not HA_NOSAME. I need table->key[i].key_part[j].field to compare with copy_field.field.
can you compare indices instead? key[i].key_part[j].field->field_index == copy_field.field->field_index Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org