Skip to content

Commit 2c44b07

Browse files
committed
init
1 parent 6defa5d commit 2c44b07

5 files changed

Lines changed: 53 additions & 10 deletions

File tree

sql/sql_base.cc

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10145,11 +10145,15 @@ int TABLE::unlock_hlindexes()
1014510145

1014610146
int TABLE::hlindexes_on_insert()
1014710147
{
10148-
DBUG_ASSERT(s->hlindexes() == (hlindex != NULL));
10149-
if (hlindex && hlindex->in_use)
10150-
if (int err= mhnsw_insert(this, key_info + s->keys))
10151-
return err;
10152-
return 0;
10148+
DBUG_ASSERT(s->hlindexes() == (hlindex != NULL));
10149+
if (hlindex && hlindex->in_use)
10150+
{
10151+
if (hlindex->bulk_insert_active)
10152+
return mhnsw_bulk_insert_row(this, key_info + s->keys);
10153+
else
10154+
return mhnsw_insert(this, key_info + s->keys);
10155+
}
10156+
return 0;
1015310157
}
1015410158

1015510159
int TABLE::hlindexes_on_update()
@@ -10208,3 +10212,23 @@ int TABLE::hlindex_read_end()
1020810212
{
1020910213
return mhnsw_read_end(this);
1021010214
}
10215+
10216+
int TABLE::hlindexes_bulk_insert_begin(ha_rows rows)
10217+
{
10218+
if (hlindex && hlindex->in_use)
10219+
{
10220+
hlindex->bulk_insert_active= true;
10221+
return mhnsw_bulk_insert_begin(this, key_info + s->keys, rows);
10222+
}
10223+
return 0;
10224+
}
10225+
10226+
int TABLE::hlindexes_bulk_insert_end()
10227+
{
10228+
if (hlindex && hlindex->in_use)
10229+
{
10230+
hlindex->bulk_insert_active= false;
10231+
return mhnsw_bulk_insert_end(this, key_info + s->keys);
10232+
}
10233+
return 0;
10234+
}

sql/sql_table.cc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12616,6 +12616,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1261612616
bool make_unversioned= from->versioned() && !to->versioned();
1261712617
bool keep_versioned= from->versioned() && to->versioned();
1261812618
bool bulk_insert_started= 0;
12619+
bool hlindex_bulk_started= 0;
1261912620
Field *to_row_start= NULL, *to_row_end= NULL, *from_row_end= NULL;
1262012621
MYSQL_TIME query_start;
1262112622
DBUG_ENTER("copy_data_between_tables");
@@ -12662,11 +12663,17 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1266212663

1266312664
from->file->info(HA_STATUS_VARIABLE);
1266412665
to->file->extra(HA_EXTRA_PREPARE_FOR_ALTER_TABLE);
12665-
if (!to->s->long_unique_table && !to->s->hlindexes())
12666+
if (!to->s->long_unique_table)
1266612667
{
12667-
to->file->ha_start_bulk_insert(from->file->stats.records,
12668-
ignore ? 0 : HA_CREATE_UNIQUE_INDEX_BY_SORT);
12669-
bulk_insert_started= 1;
12668+
to->file->ha_start_bulk_insert(from->file->stats.records,
12669+
ignore ? 0 : HA_CREATE_UNIQUE_INDEX_BY_SORT);
12670+
bulk_insert_started= 1;
12671+
12672+
if (to->s->hlindexes())
12673+
{
12674+
to->hlindexes_bulk_insert_begin(from->file->stats.records);
12675+
hlindex_bulk_started= 1;
12676+
}
1267012677
}
1267112678
mysql_stage_set_work_estimated(thd->m_stage_progress_psi, from->file->stats.records);
1267212679
List_iterator<Create_field> it(alter_info->create_list);
@@ -12999,6 +13006,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1299913006
}
1300013007

1300113008
bulk_insert_started= 0;
13009+
if (hlindex_bulk_started && to->hlindexes_bulk_insert_end() && error <= 0)
13010+
{
13011+
if (!thd->is_error())
13012+
to->file->print_error(my_errno, MYF(0));
13013+
error= 1;
13014+
}
13015+
hlindex_bulk_started=0;
13016+
1300213017
if (error <= 0 && !to->s->hlindexes())
1300313018
{
1300413019
Abort_on_warning_instant_set save_abort_on_warning(thd, false);

sql/table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,7 @@ struct TABLE
16321632
*/
16331633
bool alias_name_used; /* true if table_name is alias */
16341634
bool get_fields_in_item_tree; /* Signal to fix_field */
1635+
bool bulk_insert_active; /* mhnsw bulk_insert_started flag */
16351636
private:
16361637
bool m_needs_reopen;
16371638
bool created; /* For tmp tables. TRUE <=> tmp table was actually created.*/

sql/vector_mhnsw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo);
3434
int mhnsw_delete_all(TABLE *table, KEY *keyinfo, bool truncate);
3535
void mhnsw_free(TABLE_SHARE *share);
3636
Item_func_vec_distance::distance_kind mhnsw_uses_distance(const TABLE *table, KEY *keyinfo);
37+
int mhnsw_bulk_insert_begin(TABLE *table, KEY *keyinfo, ha_rows rows);
38+
int mhnsw_bulk_insert_end(TABLE *table, KEY *keyinfo);
39+
int mhnsw_bulk_insert_row(TABLE *table, KEY *keyinfo);
3740

3841
extern ha_create_table_option mhnsw_index_options[];
3942
extern st_plugin_int *mhnsw_plugin;

storage/columnstore/columnstore

Submodule columnstore updated 97 files

0 commit comments

Comments
 (0)