MDEV-13446 fts_create_doc_id() unnecessarily allocates 8 bytes for every inserted row
fts_create_doc_id(): Remove. row_mysql_convert_row_to_innobase(): Implement the logic of fts_create_doc_id(). Reuse a buffer for the hidden FTS_DOC_ID. row_get_prebuilt_insert_row(): Allocate a buffer for the hidden FTS_DOC_ID at the end of prebuilt->ins_upd_rec_buff.
This commit is contained in:
parent
bc85d22bf0
commit
172cc70bf8
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2016, MariaDB Corporation. All Rights reserved.
|
Copyright (c) 2016, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -3032,53 +3032,6 @@ fts_modify(
|
|||||||
return(error);
|
return(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************//**
|
|
||||||
Create a new document id.
|
|
||||||
@return DB_SUCCESS if all went well else error */
|
|
||||||
UNIV_INTERN
|
|
||||||
dberr_t
|
|
||||||
fts_create_doc_id(
|
|
||||||
/*==============*/
|
|
||||||
dict_table_t* table, /*!< in: row is of this table. */
|
|
||||||
dtuple_t* row, /* in/out: add doc id value to this
|
|
||||||
row. This is the current row that is
|
|
||||||
being inserted. */
|
|
||||||
mem_heap_t* heap) /*!< in: heap */
|
|
||||||
{
|
|
||||||
doc_id_t doc_id;
|
|
||||||
dberr_t error = DB_SUCCESS;
|
|
||||||
|
|
||||||
ut_a(table->fts->doc_col != ULINT_UNDEFINED);
|
|
||||||
|
|
||||||
if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) {
|
|
||||||
if (table->fts->cache->first_doc_id == FTS_NULL_DOC_ID) {
|
|
||||||
error = fts_get_next_doc_id(table, &doc_id);
|
|
||||||
}
|
|
||||||
return(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
error = fts_get_next_doc_id(table, &doc_id);
|
|
||||||
|
|
||||||
if (error == DB_SUCCESS) {
|
|
||||||
dfield_t* dfield;
|
|
||||||
doc_id_t* write_doc_id;
|
|
||||||
|
|
||||||
ut_a(doc_id > 0);
|
|
||||||
|
|
||||||
dfield = dtuple_get_nth_field(row, table->fts->doc_col);
|
|
||||||
write_doc_id = static_cast<doc_id_t*>(
|
|
||||||
mem_heap_alloc(heap, sizeof(*write_doc_id)));
|
|
||||||
|
|
||||||
ut_a(doc_id != FTS_NULL_DOC_ID);
|
|
||||||
ut_a(sizeof(doc_id) == dfield->type.len);
|
|
||||||
fts_write_doc_id((byte*) write_doc_id, doc_id);
|
|
||||||
|
|
||||||
dfield_set_data(dfield, write_doc_id, sizeof(*write_doc_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
return(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************//**
|
/*********************************************************************//**
|
||||||
The given transaction is about to be committed; do whatever is necessary
|
The given transaction is about to be committed; do whatever is necessary
|
||||||
from the FTS system's POV.
|
from the FTS system's POV.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2016, MariaDB Corporation. All Rights reserved.
|
Copyright (c) 2016, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -429,21 +429,6 @@ fts_update_next_doc_id(
|
|||||||
MY_ATTRIBUTE((nonnull(2)));
|
MY_ATTRIBUTE((nonnull(2)));
|
||||||
|
|
||||||
/******************************************************************//**
|
/******************************************************************//**
|
||||||
Create a new document id .
|
|
||||||
@return DB_SUCCESS if all went well else error */
|
|
||||||
UNIV_INTERN
|
|
||||||
dberr_t
|
|
||||||
fts_create_doc_id(
|
|
||||||
/*==============*/
|
|
||||||
dict_table_t* table, /*!< in: row is of this
|
|
||||||
table. */
|
|
||||||
dtuple_t* row, /*!< in/out: add doc id
|
|
||||||
value to this row. This is the
|
|
||||||
current row that is being
|
|
||||||
inserted. */
|
|
||||||
mem_heap_t* heap) /*!< in: heap */
|
|
||||||
MY_ATTRIBUTE((nonnull));
|
|
||||||
/******************************************************************//**
|
|
||||||
Create a new fts_doc_ids_t.
|
Create a new fts_doc_ids_t.
|
||||||
@return new fts_doc_ids_t. */
|
@return new fts_doc_ids_t. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
|
@ -568,11 +568,33 @@ next_column:
|
|||||||
|
|
||||||
/* If there is a FTS doc id column and it is not user supplied (
|
/* If there is a FTS doc id column and it is not user supplied (
|
||||||
generated by server) then assign it a new doc id. */
|
generated by server) then assign it a new doc id. */
|
||||||
if (prebuilt->table->fts) {
|
if (!prebuilt->table->fts) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ut_a(prebuilt->table->fts->doc_col != ULINT_UNDEFINED);
|
ut_a(prebuilt->table->fts->doc_col != ULINT_UNDEFINED);
|
||||||
|
|
||||||
fts_create_doc_id(prebuilt->table, row, prebuilt->heap);
|
doc_id_t doc_id;
|
||||||
|
|
||||||
|
if (!DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_FTS_HAS_DOC_ID)) {
|
||||||
|
if (prebuilt->table->fts->cache->first_doc_id
|
||||||
|
== FTS_NULL_DOC_ID) {
|
||||||
|
fts_get_next_doc_id(prebuilt->table, &doc_id);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dfield_t* fts_doc_id = dtuple_get_nth_field(
|
||||||
|
row, prebuilt->table->fts->doc_col);
|
||||||
|
|
||||||
|
if (fts_get_next_doc_id(prebuilt->table, &doc_id) == DB_SUCCESS) {
|
||||||
|
ut_a(doc_id != FTS_NULL_DOC_ID);
|
||||||
|
ut_ad(sizeof(doc_id) == fts_doc_id->type.len);
|
||||||
|
dfield_set_data(fts_doc_id, prebuilt->ins_upd_rec_buff
|
||||||
|
+ prebuilt->mysql_row_len, 8);
|
||||||
|
fts_write_doc_id(fts_doc_id->data, doc_id);
|
||||||
|
} else {
|
||||||
|
dfield_set_null(fts_doc_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1046,7 +1068,10 @@ row_get_prebuilt_insert_row(
|
|||||||
prebuilt->ins_upd_rec_buff = static_cast<byte*>(
|
prebuilt->ins_upd_rec_buff = static_cast<byte*>(
|
||||||
mem_heap_alloc(
|
mem_heap_alloc(
|
||||||
prebuilt->heap,
|
prebuilt->heap,
|
||||||
prebuilt->mysql_row_len));
|
DICT_TF2_FLAG_IS_SET(prebuilt->table,
|
||||||
|
DICT_TF2_FTS_HAS_DOC_ID)
|
||||||
|
? prebuilt->mysql_row_len + 8/* FTS_DOC_ID */
|
||||||
|
: prebuilt->mysql_row_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
dtuple_t* row;
|
dtuple_t* row;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2016, MariaDB Corporation. All Rights reserved.
|
Copyright (c) 2016, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -3032,53 +3032,6 @@ fts_modify(
|
|||||||
return(error);
|
return(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************//**
|
|
||||||
Create a new document id.
|
|
||||||
@return DB_SUCCESS if all went well else error */
|
|
||||||
UNIV_INTERN
|
|
||||||
dberr_t
|
|
||||||
fts_create_doc_id(
|
|
||||||
/*==============*/
|
|
||||||
dict_table_t* table, /*!< in: row is of this table. */
|
|
||||||
dtuple_t* row, /* in/out: add doc id value to this
|
|
||||||
row. This is the current row that is
|
|
||||||
being inserted. */
|
|
||||||
mem_heap_t* heap) /*!< in: heap */
|
|
||||||
{
|
|
||||||
doc_id_t doc_id;
|
|
||||||
dberr_t error = DB_SUCCESS;
|
|
||||||
|
|
||||||
ut_a(table->fts->doc_col != ULINT_UNDEFINED);
|
|
||||||
|
|
||||||
if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) {
|
|
||||||
if (table->fts->cache->first_doc_id == FTS_NULL_DOC_ID) {
|
|
||||||
error = fts_get_next_doc_id(table, &doc_id);
|
|
||||||
}
|
|
||||||
return(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
error = fts_get_next_doc_id(table, &doc_id);
|
|
||||||
|
|
||||||
if (error == DB_SUCCESS) {
|
|
||||||
dfield_t* dfield;
|
|
||||||
doc_id_t* write_doc_id;
|
|
||||||
|
|
||||||
ut_a(doc_id > 0);
|
|
||||||
|
|
||||||
dfield = dtuple_get_nth_field(row, table->fts->doc_col);
|
|
||||||
write_doc_id = static_cast<doc_id_t*>(
|
|
||||||
mem_heap_alloc(heap, sizeof(*write_doc_id)));
|
|
||||||
|
|
||||||
ut_a(doc_id != FTS_NULL_DOC_ID);
|
|
||||||
ut_a(sizeof(doc_id) == dfield->type.len);
|
|
||||||
fts_write_doc_id((byte*) write_doc_id, doc_id);
|
|
||||||
|
|
||||||
dfield_set_data(dfield, write_doc_id, sizeof(*write_doc_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
return(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************//**
|
/*********************************************************************//**
|
||||||
The given transaction is about to be committed; do whatever is necessary
|
The given transaction is about to be committed; do whatever is necessary
|
||||||
from the FTS system's POV.
|
from the FTS system's POV.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2016, MariaDB Corporation. All Rights reserved.
|
Copyright (c) 2016, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -429,21 +429,6 @@ fts_update_next_doc_id(
|
|||||||
MY_ATTRIBUTE((nonnull(2)));
|
MY_ATTRIBUTE((nonnull(2)));
|
||||||
|
|
||||||
/******************************************************************//**
|
/******************************************************************//**
|
||||||
Create a new document id .
|
|
||||||
@return DB_SUCCESS if all went well else error */
|
|
||||||
UNIV_INTERN
|
|
||||||
dberr_t
|
|
||||||
fts_create_doc_id(
|
|
||||||
/*==============*/
|
|
||||||
dict_table_t* table, /*!< in: row is of this
|
|
||||||
table. */
|
|
||||||
dtuple_t* row, /*!< in/out: add doc id
|
|
||||||
value to this row. This is the
|
|
||||||
current row that is being
|
|
||||||
inserted. */
|
|
||||||
mem_heap_t* heap) /*!< in: heap */
|
|
||||||
MY_ATTRIBUTE((nonnull));
|
|
||||||
/******************************************************************//**
|
|
||||||
Create a new fts_doc_ids_t.
|
Create a new fts_doc_ids_t.
|
||||||
@return new fts_doc_ids_t. */
|
@return new fts_doc_ids_t. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
|
@ -567,11 +567,33 @@ next_column:
|
|||||||
|
|
||||||
/* If there is a FTS doc id column and it is not user supplied (
|
/* If there is a FTS doc id column and it is not user supplied (
|
||||||
generated by server) then assign it a new doc id. */
|
generated by server) then assign it a new doc id. */
|
||||||
if (prebuilt->table->fts) {
|
if (!prebuilt->table->fts) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ut_a(prebuilt->table->fts->doc_col != ULINT_UNDEFINED);
|
ut_a(prebuilt->table->fts->doc_col != ULINT_UNDEFINED);
|
||||||
|
|
||||||
fts_create_doc_id(prebuilt->table, row, prebuilt->heap);
|
doc_id_t doc_id;
|
||||||
|
|
||||||
|
if (!DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_FTS_HAS_DOC_ID)) {
|
||||||
|
if (prebuilt->table->fts->cache->first_doc_id
|
||||||
|
== FTS_NULL_DOC_ID) {
|
||||||
|
fts_get_next_doc_id(prebuilt->table, &doc_id);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dfield_t* fts_doc_id = dtuple_get_nth_field(
|
||||||
|
row, prebuilt->table->fts->doc_col);
|
||||||
|
|
||||||
|
if (fts_get_next_doc_id(prebuilt->table, &doc_id) == DB_SUCCESS) {
|
||||||
|
ut_a(doc_id != FTS_NULL_DOC_ID);
|
||||||
|
ut_ad(sizeof(doc_id) == fts_doc_id->type.len);
|
||||||
|
dfield_set_data(fts_doc_id, prebuilt->ins_upd_rec_buff
|
||||||
|
+ prebuilt->mysql_row_len, 8);
|
||||||
|
fts_write_doc_id(fts_doc_id->data, doc_id);
|
||||||
|
} else {
|
||||||
|
dfield_set_null(fts_doc_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1045,7 +1067,10 @@ row_get_prebuilt_insert_row(
|
|||||||
prebuilt->ins_upd_rec_buff = static_cast<byte*>(
|
prebuilt->ins_upd_rec_buff = static_cast<byte*>(
|
||||||
mem_heap_alloc(
|
mem_heap_alloc(
|
||||||
prebuilt->heap,
|
prebuilt->heap,
|
||||||
prebuilt->mysql_row_len));
|
DICT_TF2_FLAG_IS_SET(prebuilt->table,
|
||||||
|
DICT_TF2_FTS_HAS_DOC_ID)
|
||||||
|
? prebuilt->mysql_row_len + 8/* FTS_DOC_ID */
|
||||||
|
: prebuilt->mysql_row_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
dtuple_t* row;
|
dtuple_t* row;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user