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