diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-05 08:09:49 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-05 08:09:49 +0300 |
commit | 444c380ceb26895748ce50c50be3f839393ebfd7 (patch) | |
tree | 65b1fbf3b7caec3de48c1f76de4614a2d9793a8d /sql/table.cc | |
parent | 55dd0776566000c5ea12e177df0c784b500ab7c1 (diff) | |
parent | 941ca92a2ca3990020b23bcc92e7ca98dcc8f814 (diff) | |
download | mariadb-git-444c380ceb26895748ce50c50be3f839393ebfd7.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/table.cc b/sql/table.cc index 58adb94cc17..08b71114310 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -325,7 +325,8 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, share->can_do_row_logging= 1; if (share->table_category == TABLE_CATEGORY_LOG) share->no_replicate= 1; - if (my_strnncoll(table_alias_charset, (uchar*) db, 6, + if (key_length > 6 && + my_strnncoll(table_alias_charset, (const uchar*) key, 6, (const uchar*) "mysql", 6) == 0) share->not_usable_by_query_cache= 1; @@ -432,6 +433,7 @@ void TABLE_SHARE::destroy() ha_share= NULL; // Safety } + delete_stat_values_for_table_share(this); delete sequence; free_root(&stats_cb.mem_root, MYF(0)); stats_cb.stats_can_be_read= FALSE; @@ -3163,6 +3165,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, { enum open_frm_error error; uint records, i, bitmap_size, bitmap_count; + const char *tmp_alias; bool error_reported= FALSE; uchar *record, *bitmaps; Field **field_ptr; @@ -3190,8 +3193,14 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, init_sql_alloc(&outparam->mem_root, "table", TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); - if (outparam->alias.copy(alias->str, alias->length, table_alias_charset)) + /* + We have to store the original alias in mem_root as constraints and virtual + functions may store pointers to it + */ + if (!(tmp_alias= strmake_root(&outparam->mem_root, alias->str, alias->length))) goto err; + + outparam->alias.set(tmp_alias, alias->length, table_alias_charset); outparam->quick_keys.init(); outparam->covering_keys.init(); outparam->intersect_keys.init(); @@ -4615,7 +4624,7 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) s->table_name.str, tl->alias.str); /* Fix alias if table name changes. */ - if (strcmp(alias.c_ptr(), tl->alias.str)) + if (!alias.alloced_length() || strcmp(alias.c_ptr(), tl->alias.str)) alias.copy(tl->alias.str, tl->alias.length, alias.charset()); tablenr= thd->current_tablenr++; @@ -8561,6 +8570,7 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id) return true; store(FLD_BEGIN_TS, thd->transaction_time()); + thd->set_time(); timeval end_time= {thd->query_start(), int(thd->query_start_sec_part())}; store(FLD_TRX_ID, start_id); store(FLD_COMMIT_ID, end_id); |