| 10111 | */ |
| 10112 | |
| 10113 | int TABLE::hlindex_open(uint nr) |
| 10114 | { |
| 10115 | DBUG_ASSERT(s->hlindexes() == 1); |
| 10116 | DBUG_ASSERT(nr == s->keys); |
| 10117 | if (!hlindex) |
| 10118 | { |
| 10119 | s->lock_share(); |
| 10120 | if (!s->hlindex) |
| 10121 | { |
| 10122 | size_t path_len= s->normalized_path.length + HLINDEX_BUF_LEN; |
| 10123 | TABLE_SHARE *share= (TABLE_SHARE*)alloc_root(&s->mem_root, sizeof *share); |
| 10124 | char *path= (char*)alloc_root(&s->mem_root, path_len); |
| 10125 | s->unlock_share(); |
| 10126 | if (!share || !path) |
| 10127 | return 1; |
| 10128 | |
| 10129 | my_snprintf(path, path_len, "%s" HLINDEX_TEMPLATE, |
| 10130 | s->normalized_path.str, nr); |
| 10131 | init_tmp_table_share(in_use, share, s->db.str, 0, s->table_name.str, |
| 10132 | path, false); |
| 10133 | share->db_plugin= s->db_plugin; |
| 10134 | |
| 10135 | LEX_CSTRING sql= mhnsw_hlindex_table_def(in_use, file->ref_length); |
| 10136 | if (share->init_from_sql_statement_string(in_use, false, |
| 10137 | sql.str, sql.length)) |
| 10138 | { |
| 10139 | if (share->db_plugin == s->db_plugin) |
| 10140 | share->db_plugin= NULL; |
| 10141 | free_table_share(share); |
| 10142 | return 1; |
| 10143 | } |
| 10144 | |
| 10145 | s->lock_share(); |
| 10146 | if (!s->hlindex) |
| 10147 | { |
| 10148 | s->hlindex= share; |
| 10149 | s->unlock_share(); |
| 10150 | } |
| 10151 | else |
| 10152 | { |
| 10153 | s->unlock_share(); |
| 10154 | free_table_share(share); |
| 10155 | } |
| 10156 | } |
| 10157 | else |
| 10158 | s->unlock_share(); |
| 10159 | TABLE *table= (TABLE*)alloc_root(&mem_root, sizeof(*table)); |
| 10160 | if (!table || open_table_from_share(in_use, s->hlindex, &empty_clex_str, |
| 10161 | db_stat, EXTRA_RECORD, in_use->open_options, table, 0)) |
| 10162 | return 1; |
| 10163 | hlindex= table; |
| 10164 | hlindex->in_use= NULL; |
| 10165 | } |
| 10166 | return 0; |
| 10167 | } |
| 10168 | |
| 10169 | int TABLE::hlindex_lock(uint nr) |
| 10170 | { |
no test coverage detected