Commit 7c5511ef authored by marko's avatar marko

branches/zip: dict_table_copy_types(): Initialize all fields to the SQL NULL

value.  Document this change in behaviour, and make all callers invoke
the function right after dtuple_create().

dict_create_sys_fields_tuple(): Add a missing "break" statement to the loop
that checks if there are any column prefixes in the index.

row_get_prebuilt_insert_row(): Do not set the fields to the SQL NULL value,
now that dict_table_copy_types() takes care of it.
parent a65020d2
......@@ -49,6 +49,8 @@ dict_create_sys_tables_tuple(
entry = dtuple_create(heap, 8 + DATA_N_SYS_COLS);
dict_table_copy_types(entry, sys_tables);
/* 0: NAME -----------------------------*/
dfield = dtuple_get_nth_field(entry, 0);
......@@ -111,8 +113,6 @@ dict_create_sys_tables_tuple(
dfield_set_data(dfield, ptr, 4);
/*----------------------------------*/
dict_table_copy_types(entry, sys_tables);
return(entry);
}
......@@ -144,6 +144,8 @@ dict_create_sys_columns_tuple(
entry = dtuple_create(heap, 7 + DATA_N_SYS_COLS);
dict_table_copy_types(entry, sys_columns);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, 0);
......@@ -193,8 +195,6 @@ dict_create_sys_columns_tuple(
dfield_set_data(dfield, ptr, 4);
/*---------------------------------*/
dict_table_copy_types(entry, sys_columns);
return(entry);
}
......@@ -330,6 +330,8 @@ dict_create_sys_indexes_tuple(
entry = dtuple_create(heap, 7 + DATA_N_SYS_COLS);
dict_table_copy_types(entry, sys_indexes);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, 0);
......@@ -388,8 +390,6 @@ dict_create_sys_indexes_tuple(
dfield_set_data(dfield, ptr, 4);
/*--------------------------------*/
dict_table_copy_types(entry, sys_indexes);
return(entry);
}
......@@ -419,6 +419,7 @@ dict_create_sys_fields_tuple(
for (j = 0; j < index->n_fields; j++) {
if (dict_index_get_nth_field(index, j)->prefix_len > 0) {
index_contains_column_prefix_field = TRUE;
break;
}
}
......@@ -428,6 +429,8 @@ dict_create_sys_fields_tuple(
entry = dtuple_create(heap, 3 + DATA_N_SYS_COLS);
dict_table_copy_types(entry, sys_fields);
/* 0: INDEX_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, 0);
......@@ -463,8 +466,6 @@ dict_create_sys_fields_tuple(
ut_strlen(field->name));
/*---------------------------------*/
dict_table_copy_types(entry, sys_fields);
return(entry);
}
......
......@@ -1487,7 +1487,9 @@ dict_index_copy_types(
}
/***********************************************************************
Copies types of columns contained in table to tuple. */
Copies types of columns contained in table to tuple and sets all
fields of the tuple to the SQL NULL value. This function should
be called right after dtuple_create(). */
void
dict_table_copy_types(
......@@ -1495,14 +1497,15 @@ dict_table_copy_types(
dtuple_t* tuple, /* in/out: data tuple */
const dict_table_t* table) /* in: table */
{
dtype_t* dfield_type;
ulint i;
for (i = 0; i < dtuple_get_n_fields(tuple); i++) {
dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
dict_col_copy_type(dict_table_get_nth_col(table, i),
dfield_type);
dfield_t* dfield = dtuple_get_nth_field(tuple, i);
dtype_t* dtype = dfield_get_type(dfield);
dfield_set_null(dfield);
dict_col_copy_type(dict_table_get_nth_col(table, i), dtype);
}
}
......
......@@ -639,7 +639,9 @@ dict_table_col_in_clustered_key(
const dict_table_t* table, /* in: table */
ulint n); /* in: column number */
/***********************************************************************
Copies types of columns contained in table to tuple. */
Copies types of columns contained in table to tuple and sets all
fields of the tuple to the SQL NULL value. This function should
be called right after dtuple_create(). */
void
dict_table_copy_types(
......
......@@ -854,7 +854,6 @@ row_get_prebuilt_insert_row(
ins_node_t* node;
dtuple_t* row;
dict_table_t* table = prebuilt->table;
ulint i;
ut_ad(prebuilt && table && prebuilt->trx);
......@@ -877,14 +876,6 @@ row_get_prebuilt_insert_row(
dict_table_copy_types(row, table);
/* We init the value of every field to the SQL NULL to avoid
a debug assertion from failing */
for (i = 0; i < dtuple_get_n_fields(row); i++) {
dfield_set_null(dtuple_get_nth_field(row, i));
}
ins_node_set_new_row(node, row);
prebuilt->ins_graph = que_node_get_parent(
......
......@@ -232,6 +232,8 @@ row_build(
row = dtuple_create(heap, row_len);
dict_table_copy_types(row, table);
dtuple_set_info_bits(row, rec_get_info_bits(
rec, dict_table_is_comp(table)));
......@@ -241,8 +243,6 @@ row_build(
ext_cols = mem_heap_alloc(heap, n_ext_cols * sizeof *ext_cols);
}
dict_table_copy_types(row, table);
for (i = j = 0; i < n_fields; i++) {
dict_field_t* ind_field
= dict_index_get_nth_field(index, i);
......
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