Commit 3b49ab38 authored by marko's avatar marko

Remove dict_col_t::clust_pos.

dict_col_get_clust_pos(): Add parameter clust_index.  Replace the
look-up with a linear search of all columns in the clustered index.

row_upd_index_replace_new_col_vals(): Compute clust_index outside
the loops.  Compute clust_pos outside the inner loop.

row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary():
Compute clust_index outside the loops.  Declare the auxiliary variables
inside the loop scope.
parent f1cc5233
......@@ -528,7 +528,7 @@ dict_index_get_nth_col_pos(
if (index->type & DICT_CLUSTERED) {
return(dict_col_get_clust_pos(col));
return(dict_col_get_clust_pos(col, index));
}
n_fields = dict_index_get_n_fields(index);
......@@ -1756,18 +1756,6 @@ dict_index_build_internal_clust(
ut_ad((index->type & DICT_IBUF)
|| (UT_LIST_GET_LEN(table->indexes) == 0));
/* Store to the column structs the position of the table columns
in the clustered index */
for (i = 0; i < new_index->n_def; i++) {
field = dict_index_get_nth_field(new_index, i);
if (field->prefix_len == 0) {
field->col->clust_pos = i;
}
}
new_index->cached = TRUE;
return(new_index);
......
......@@ -136,8 +136,6 @@ dict_mem_table_add_col(
col->name = mem_heap_strdup(table->heap, name);
col->ord_part = 0;
col->clust_pos = REC_MAX_N_FIELDS;
type = dict_col_get_type(col);
dtype_set(type, mtype, prtype, len);
......
......@@ -3165,7 +3165,7 @@ ha_innobase::build_template(
if (index == clust_index) {
templ->rec_field_no = dict_col_get_clust_pos
(&index->table->cols[i]);
(&index->table->cols[i], index);
} else {
templ->rec_field_no = dict_index_get_nth_col_pos(
index, i);
......@@ -3225,7 +3225,8 @@ ha_innobase::build_template(
templ = prebuilt->mysql_template + i;
templ->rec_field_no = dict_col_get_clust_pos
(&index->table->cols[templ->col_no]);
(&index->table->cols[templ->col_no],
clust_index);
}
}
}
......@@ -3491,9 +3492,11 @@ calc_row_difference(
ulint col_type;
ulint n_changed = 0;
dfield_t dfield;
dict_index_t* clust_index;
uint i;
n_fields = table->s->fields;
clust_index = dict_table_get_first_index_noninline(prebuilt->table);
/* We use upd_buff to convert changed fields */
buf = (byte*) upd_buff;
......@@ -3599,7 +3602,7 @@ calc_row_difference(
ufield->exp = NULL;
ufield->field_no = dict_col_get_clust_pos
(&prebuilt->table->cols[i]);
(&prebuilt->table->cols[i], clust_index);
n_changed++;
}
}
......
......@@ -96,7 +96,8 @@ UNIV_INLINE
ulint
dict_col_get_clust_pos(
/*===================*/
dict_col_t* col);
const dict_col_t* col, /* in: table column */
const dict_index_t* clust_index); /* in: clustered index */
/********************************************************************
If the given column name is reserved for InnoDB system columns, return
TRUE. */
......
......@@ -43,13 +43,23 @@ UNIV_INLINE
ulint
dict_col_get_clust_pos(
/*===================*/
dict_col_t* col)
const dict_col_t* col, /* in: table column */
const dict_index_t* clust_index) /* in: clustered index */
{
ulint i;
ut_ad(col);
ut_ad(clust_index && clust_index->type & DICT_CLUSTERED);
for (i = 0; i < clust_index->n_def; i++) {
const dict_field_t* field = &clust_index->fields[i];
if (!field->prefix_len && field->col == col) {
return(i);
}
}
return(col->clust_pos == REC_MAX_N_FIELDS
? ULINT_UNDEFINED
: col->clust_pos);
return(ULINT_UNDEFINED);
}
/************************************************************************
......@@ -324,7 +334,7 @@ dict_index_get_sys_col_pos(
if (index->type & DICT_CLUSTERED) {
return(dict_col_get_clust_pos(col));
return(dict_col_get_clust_pos(col, index));
}
return(dict_index_get_nth_col_pos
......
......@@ -123,8 +123,6 @@ dict_mem_foreign_create(void);
struct dict_col_struct{
ulint ind:10; /* table column position (they are numbered
starting from 0) */
ulint clust_pos:10;/* position of the column in the
clustered index */
ulint ord_part:1;/* nonzero if this column appears
in ordering fields of an index */
const char* name; /* name */
......
......@@ -102,8 +102,9 @@ row_sel_sec_rec_is_for_clust_rec(
ifield = dict_index_get_nth_field(sec_index, i);
col = dict_field_get_col(ifield);
clust_field = rec_get_nth_field(clust_rec, clust_offs,
dict_col_get_clust_pos(col),
clust_field = rec_get_nth_field
(clust_rec, clust_offs,
dict_col_get_clust_pos(col, clust_index),
&clust_len);
sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len);
......
......@@ -952,28 +952,32 @@ row_upd_index_replace_new_col_vals(
copy the new values, set this as NULL if you
do not want allocation */
{
dict_field_t* field;
upd_field_t* upd_field;
dfield_t* dfield;
dfield_t* new_val;
ulint j;
ulint i;
dtype_t* cur_type;
dict_index_t* clust_index;
ut_ad(index);
clust_index = dict_table_get_first_index(index->table);
dtuple_set_info_bits(entry, update->info_bits);
for (j = 0; j < dict_index_get_n_fields(index); j++) {
field = dict_index_get_nth_field(index, j);
ulint clust_pos;
dict_field_t* field = dict_index_get_nth_field(index, j);
clust_pos = dict_col_get_clust_pos(field->col, clust_index);
for (i = 0; i < upd_get_n_fields(update); i++) {
upd_field = upd_get_nth_field(update, i);
if (upd_field->field_no
== dict_col_get_clust_pos(field->col)) {
if (upd_field->field_no == clust_pos) {
dfield = dtuple_get_nth_field(entry, j);
......@@ -1026,30 +1030,33 @@ row_upd_changes_ord_field_binary(
field numbers in this MUST be clustered index
positions! */
{
upd_field_t* upd_field;
dict_field_t* ind_field;
dict_col_t* col;
ulint n_unique;
ulint n_upd_fields;
ulint col_pos;
ulint col_no;
ulint i, j;
dict_index_t* clust_index;
ut_ad(update && index);
n_unique = dict_index_get_n_unique(index);
n_upd_fields = upd_get_n_fields(update);
clust_index = dict_table_get_first_index(index->table);
for (i = 0; i < n_unique; i++) {
ind_field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(ind_field);
col_pos = dict_col_get_clust_pos(col);
col_no = dict_col_get_no(col);
dict_field_t* ind_field
= dict_index_get_nth_field(index, i);
dict_col_t* col
= dict_field_get_col(ind_field);
ulint col_pos
= dict_col_get_clust_pos(col, clust_index);
ulint col_no
= dict_col_get_no(col);
for (j = 0; j < n_upd_fields; j++) {
upd_field = upd_get_nth_field(update, j);
upd_field_t* upd_field
= upd_get_nth_field(update, j);
/* Note that if the index field is a column prefix
then it may be that row does not contain an externally
......@@ -1118,29 +1125,31 @@ row_upd_changes_first_fields_binary(
upd_t* update, /* in: update vector for the row */
ulint n) /* in: how many first fields to check */
{
upd_field_t* upd_field;
dict_field_t* ind_field;
dict_col_t* col;
ulint n_upd_fields;
ulint col_pos;
ulint i, j;
dict_index_t* clust_index;
ut_a(update && index);
ut_a(n <= dict_index_get_n_fields(index));
ut_ad(update && index);
ut_ad(n <= dict_index_get_n_fields(index));
n_upd_fields = upd_get_n_fields(update);
clust_index = dict_table_get_first_index(index->table);
for (i = 0; i < n; i++) {
ind_field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(ind_field);
col_pos = dict_col_get_clust_pos(col);
dict_field_t* ind_field
= dict_index_get_nth_field(index, i);
dict_col_t* col
= dict_field_get_col(ind_field);
ulint col_pos
= dict_col_get_clust_pos(col, clust_index);
ut_a(ind_field->prefix_len == 0);
for (j = 0; j < n_upd_fields; j++) {
upd_field = upd_get_nth_field(update, j);
upd_field_t* upd_field
= upd_get_nth_field(update, j);
if (col_pos == upd_field->field_no
&& !dfield_datas_are_binary_equal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment