6958
6958
ut_a(prebuilt->trx == session_to_trx(getTable()->in_use));
6960
prebuilt->trx->op_info = (char*)"estimating records in index range";
6960
prebuilt->trx->op_info = "estimating records in index range";
6962
6962
/* In case MySQL calls this in the middle of a SELECT query, release
6963
6963
possible adaptive hash latch to avoid deadlocks of threads */
7090
7090
estimate = 2 * local_data_file_length /
7091
7091
dict_index_calc_min_rec_len(index);
7093
prebuilt->trx->op_info = (char*)"";
7093
prebuilt->trx->op_info = "";
7095
7095
return((ha_rows) estimate);
7280
7280
/* In case MySQL calls this in the middle of a SELECT query, release
7281
7281
possible adaptive hash latch to avoid deadlocks of threads */
7283
prebuilt->trx->op_info = (char*)"returning various info to MySQL";
7283
prebuilt->trx->op_info = "returning various info to MySQL";
7285
7285
trx_search_latch_release_if_reserved(prebuilt->trx);
7739
7739
update_session(getTable()->in_use);
7741
prebuilt->trx->op_info = (char*)"returning table comment";
7741
prebuilt->trx->op_info = "returning table comment";
7743
7743
/* In case MySQL calls this in the middle of a SELECT query, release
7744
7744
possible adaptive hash latch to avoid deadlocks of threads */
7810
7810
update_session(getTable()->in_use);
7812
prebuilt->trx->op_info = (char*)"getting info on foreign keys";
7812
prebuilt->trx->op_info = "getting info on foreign keys";
7814
7814
/* In case MySQL calls this in the middle of a SELECT query,
7815
7815
release possible adaptive hash latch to avoid
7823
7823
/* output the data to a temporary file */
7824
7824
dict_print_info_on_foreign_keys(TRUE, srv_dict_tmpfile,
7825
7825
prebuilt->trx, prebuilt->table);
7826
prebuilt->trx->op_info = (char*)"";
7826
prebuilt->trx->op_info = "";
7828
7828
flen = ftell(srv_dict_tmpfile);
7829
7829
if (flen < 0) {
7852
7852
ha_innobase::get_foreign_key_list(Session *session, List<ForeignKeyInfo> *f_key_list)
7854
dict_foreign_t* foreign;
7856
7854
ut_a(prebuilt != NULL);
7857
7855
update_session(getTable()->in_use);
7858
prebuilt->trx->op_info = (char*)"getting list of foreign keys";
7856
prebuilt->trx->op_info = "getting list of foreign keys";
7859
7857
trx_search_latch_release_if_reserved(prebuilt->trx);
7860
7858
mutex_enter(&(dict_sys->mutex));
7861
foreign = UT_LIST_GET_FIRST(prebuilt->table->foreign_list);
7859
dict_foreign_t* foreign = UT_LIST_GET_FIRST(prebuilt->table->foreign_list);
7863
7861
while (foreign != NULL) {
7866
lex_string_t *name = 0;
7868
7864
char uname[NAME_LEN + 1]; /* Unencoded name */
7869
7865
char db_name[NAME_LEN + 1];
7872
7868
/** Foreign id **/
7873
7869
tmp_buff = foreign->id;
7875
7871
while (tmp_buff[i] != '/')
7877
7873
tmp_buff += i + 1;
7878
lex_string_t *tmp_foreign_id = session->make_lex_string(NULL, tmp_buff, strlen(tmp_buff), true);
7874
lex_string_t *tmp_foreign_id = session->make_lex_string(NULL, str_ref(tmp_buff));
7880
7876
/* Database name */
7881
7877
tmp_buff = foreign->referenced_table_name;
7889
7885
db_name[i] = 0;
7890
7886
ulen= identifier::Table::filename_to_tablename(db_name, uname, sizeof(uname));
7891
lex_string_t *tmp_referenced_db = session->make_lex_string(NULL, uname, ulen, true);
7887
lex_string_t *tmp_referenced_db = session->make_lex_string(NULL, str_ref(uname, ulen));
7893
7889
/* Table name */
7894
7890
tmp_buff += i + 1;
7895
7891
ulen= identifier::Table::filename_to_tablename(tmp_buff, uname, sizeof(uname));
7896
lex_string_t *tmp_referenced_table = session->make_lex_string(NULL, uname, ulen, true);
7892
lex_string_t *tmp_referenced_table = session->make_lex_string(NULL, str_ref(uname, ulen));
7898
7894
/** Foreign Fields **/
7899
7895
List<lex_string_t> tmp_foreign_fields;
7900
7896
List<lex_string_t> tmp_referenced_fields;
7902
tmp_buff= foreign->foreign_col_names[i];
7903
name = session->make_lex_string(name, tmp_buff, strlen(tmp_buff), true);
7904
tmp_foreign_fields.push_back(name);
7905
tmp_buff= foreign->referenced_col_names[i];
7906
name = session->make_lex_string(name, tmp_buff, strlen(tmp_buff), true);
7907
tmp_referenced_fields.push_back(name);
7899
tmp_foreign_fields.push_back(session->make_lex_string(NULL, str_ref(foreign->foreign_col_names[i])));
7900
tmp_referenced_fields.push_back(session->make_lex_string(NULL, str_ref(foreign->referenced_col_names[i])));
7908
7901
if (++i >= foreign->n_fields)
7931
7924
tmp_buff= "RESTRICT";
7933
lex_string_t *tmp_delete_method = session->make_lex_string(NULL, tmp_buff, length, true);
7926
lex_string_t *tmp_delete_method = session->make_lex_string(NULL, str_ref(tmp_buff, length));
7936
7929
if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)
7954
7947
tmp_buff= "RESTRICT";
7956
lex_string_t *tmp_update_method = session->make_lex_string(NULL, tmp_buff, length, true);
7949
lex_string_t *tmp_update_method = session->make_lex_string(NULL, str_ref(tmp_buff, length));
7958
7951
lex_string_t *tmp_referenced_key_name = NULL;
7960
if (foreign->referenced_index &&
7961
foreign->referenced_index->name)
7953
if (foreign->referenced_index && foreign->referenced_index->name)
7963
tmp_referenced_key_name = session->make_lex_string(NULL,
7964
foreign->referenced_index->name, strlen(foreign->referenced_index->name), true);
7955
tmp_referenced_key_name = session->make_lex_string(NULL, str_ref(foreign->referenced_index->name));
7967
7958
ForeignKeyInfo f_key_info(
7969
7960
tmp_update_method, tmp_delete_method, tmp_referenced_key_name,
7970
7961
tmp_foreign_fields, tmp_referenced_fields);
7972
ForeignKeyInfo *pf_key_info = (ForeignKeyInfo*)session->mem.memdup(&f_key_info, sizeof(ForeignKeyInfo));
7973
f_key_list->push_back(pf_key_info);
7963
f_key_list->push_back((ForeignKeyInfo*)session->mem.memdup(&f_key_info, sizeof(ForeignKeyInfo)));
7974
7964
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
7976
7966
mutex_exit(&(dict_sys->mutex));
7977
prebuilt->trx->op_info = (char*)"";
7967
prebuilt->trx->op_info = "";
8550
8540
HASH_DELETE(INNOBASE_SHARE, table_name_hash,
8551
8541
innobase_open_tables, fold, share);
8552
share->lock.deinit();
8554
8543
/* Free any memory from index translation table */
8555
8544
free(share->idx_trans_tbl.index_mapping);