diff options
author | Igor Babaev <igor@askmonty.org> | 2009-11-11 20:31:28 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2009-11-11 20:31:28 -0800 |
commit | e4e1ae0d13da399d53bd91df791b149f3eae796b (patch) | |
tree | 850b7b3404210b6bad604ad33b5c9a7437253dbe /storage/xtradb | |
parent | 99d8d4402080270289f00465309c7c40c2e5d566 (diff) | |
parent | d749c7e60061fd328e95f74d2d77fc59312da3b1 (diff) | |
download | mariadb-git-e4e1ae0d13da399d53bd91df791b149f3eae796b.tar.gz |
Merge of the patch introducing virtual columns into maria-5.2
Diffstat (limited to 'storage/xtradb')
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 73 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.h | 1 | ||||
-rw-r--r-- | storage/xtradb/include/buf0buf.ic | 2 | ||||
-rw-r--r-- | storage/xtradb/include/srv0srv.h | 28 | ||||
-rw-r--r-- | storage/xtradb/srv/srv0srv.c | 28 |
5 files changed, 72 insertions, 60 deletions
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 4ca5bd486f6..1cd4000846a 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -3200,12 +3200,12 @@ ha_innobase::open( } /* Create buffers for packing the fields of a record. Why - table->reclength did not work here? Obviously, because char + table->stored_rec_length did not work here? Obviously, because char fields when packed actually became 1 byte longer, when we also stored the string length as the first byte. */ upd_and_key_val_buff_len = - table->s->reclength + table->s->max_key_length + table->s->stored_rec_length + table->s->max_key_length + MAX_REF_PARTS * 3; if (!(uchar*) my_multi_malloc(MYF(MY_WME), &upd_buff, upd_and_key_val_buff_len, @@ -3280,7 +3280,7 @@ retry: prebuilt = row_create_prebuilt(ib_table); - prebuilt->mysql_row_len = table->s->reclength; + prebuilt->mysql_row_len = table->s->stored_rec_length;; prebuilt->default_rec = table->s->default_values; ut_ad(prebuilt->default_rec); @@ -3996,11 +3996,11 @@ build_template( dict_index_t* clust_index; mysql_row_templ_t* templ; Field* field; - ulint n_fields; + ulint n_fields, n_stored_fields; ulint n_requested_fields = 0; ibool fetch_all_in_key = FALSE; ibool fetch_primary_key_cols = FALSE; - ulint i; + ulint i, sql_idx, innodb_idx=0; /* byte offset of the end of last requested column */ ulint mysql_prefix_len = 0; @@ -4061,10 +4061,11 @@ build_template( } n_fields = (ulint)table->s->fields; /* number of columns */ + n_stored_fields= (ulint)table->s->stored_fields; /* number of stored columns */ if (!prebuilt->mysql_template) { prebuilt->mysql_template = (mysql_row_templ_t*) - mem_alloc(n_fields * sizeof(mysql_row_templ_t)); + mem_alloc(n_stored_fields * sizeof(mysql_row_templ_t)); } prebuilt->template_type = templ_type; @@ -4074,15 +4075,17 @@ build_template( /* Note that in InnoDB, i is the column number. MySQL calls columns 'fields'. */ - for (i = 0; i < n_fields; i++) { + for (sql_idx = 0; sql_idx < n_fields; sql_idx++) { templ = prebuilt->mysql_template + n_requested_fields; - field = table->field[i]; + field = table->field[sql_idx]; + if (!field->stored_in_db) + goto skip_field; if (UNIV_LIKELY(templ_type == ROW_MYSQL_REC_FIELDS)) { /* Decide which columns we should fetch and which we can skip. */ register const ibool index_contains_field = - dict_index_contains_col_or_prefix(index, i); + dict_index_contains_col_or_prefix(index, innodb_idx); if (!index_contains_field && prebuilt->read_just_key) { /* If this is a 'key read', we do not need @@ -4097,8 +4100,8 @@ build_template( goto include_field; } - if (bitmap_is_set(table->read_set, i) || - bitmap_is_set(table->write_set, i)) { + if (bitmap_is_set(table->read_set, sql_idx) || + bitmap_is_set(table->write_set, sql_idx)) { /* This field is needed in the query */ goto include_field; @@ -4106,7 +4109,7 @@ build_template( if (fetch_primary_key_cols && dict_table_col_in_clustered_key( - index->table, i)) { + index->table, innodb_idx)) { /* This field is needed in the query */ goto include_field; @@ -4119,14 +4122,14 @@ build_template( include_field: n_requested_fields++; - templ->col_no = i; + templ->col_no = innodb_idx; if (index == clust_index) { templ->rec_field_no = dict_col_get_clust_pos( - &index->table->cols[i], index); + &index->table->cols[innodb_idx], index); } else { templ->rec_field_no = dict_index_get_nth_col_pos( - index, i); + index, innodb_idx); } if (templ->rec_field_no == ULINT_UNDEFINED) { @@ -4152,7 +4155,7 @@ include_field: mysql_prefix_len = templ->mysql_col_offset + templ->mysql_col_len; } - templ->type = index->table->cols[i].mtype; + templ->type = index->table->cols[innodb_idx].mtype; templ->mysql_type = (ulint)field->type(); if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) { @@ -4161,16 +4164,18 @@ include_field: } templ->charset = dtype_get_charset_coll( - index->table->cols[i].prtype); - templ->mbminlen = index->table->cols[i].mbminlen; - templ->mbmaxlen = index->table->cols[i].mbmaxlen; - templ->is_unsigned = index->table->cols[i].prtype + index->table->cols[innodb_idx].prtype); + templ->mbminlen = index->table->cols[innodb_idx].mbminlen; + templ->mbmaxlen = index->table->cols[innodb_idx].mbmaxlen; + templ->is_unsigned = index->table->cols[innodb_idx].prtype & DATA_UNSIGNED; if (templ->type == DATA_BLOB) { prebuilt->templ_contains_blob = TRUE; } skip_field: - ; + if (field->stored_in_db) { + innodb_idx++; + } } prebuilt->n_template = n_requested_fields; @@ -4634,7 +4639,7 @@ calc_row_difference( ulint n_changed = 0; dfield_t dfield; dict_index_t* clust_index; - uint i; + uint sql_idx, innodb_idx= 0; n_fields = table->s->fields; clust_index = dict_table_get_first_index(prebuilt->table); @@ -4642,8 +4647,10 @@ calc_row_difference( /* We use upd_buff to convert changed fields */ buf = (byte*) upd_buff; - for (i = 0; i < n_fields; i++) { - field = table->field[i]; + for (sql_idx = 0; sql_idx < n_fields; sql_idx++) { + field = table->field[sql_idx]; + if (!field->stored_in_db) + continue; o_ptr = (const byte*) old_row + get_field_offset(table, field); n_ptr = (const byte*) new_row + get_field_offset(table, field); @@ -4661,7 +4668,7 @@ calc_row_difference( field_mysql_type = field->type(); - col_type = prebuilt->table->cols[i].mtype; + col_type = prebuilt->table->cols[innodb_idx].mtype; switch (col_type) { @@ -4716,7 +4723,7 @@ calc_row_difference( /* Let us use a dummy dfield to make the conversion from the MySQL column format to the InnoDB format */ - dict_col_copy_type(prebuilt->table->cols + i, + dict_col_copy_type(prebuilt->table->cols + innodb_idx, dfield_get_type(&dfield)); if (n_len != UNIV_SQL_NULL) { @@ -4735,9 +4742,11 @@ calc_row_difference( ufield->exp = NULL; ufield->orig_len = 0; ufield->field_no = dict_col_get_clust_pos( - &prebuilt->table->cols[i], clust_index); + &prebuilt->table->cols[innodb_idx], clust_index); n_changed++; } + if (field->stored_in_db) + innodb_idx++; } uvect->n_fields = n_changed; @@ -5754,7 +5763,7 @@ create_table_def( /* We pass 0 as the space id, and determine at a lower level the space id where to store the table */ - table = dict_mem_table_create(table_name, 0, n_cols, flags); + table = dict_mem_table_create(table_name, 0, form->s->stored_fields, flags); if (path_of_temp_table) { table->dir_path_of_temp_table = @@ -5763,6 +5772,8 @@ create_table_def( for (i = 0; i < n_cols; i++) { field = form->field[i]; + if (!field->stored_in_db) + continue; col_type = get_innobase_type_from_mysql_type(&unsigned_type, field); @@ -6224,7 +6235,7 @@ ha_innobase::create( } #endif - if (form->s->fields > 1000) { + if (form->s->stored_fields > 1000) { /* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020, but we play safe here */ @@ -6890,10 +6901,10 @@ ha_innobase::records_in_range( KEY* key; dict_index_t* index; uchar* key_val_buff2 = (uchar*) my_malloc( - table->s->reclength + table->s->stored_rec_length + table->s->max_key_length + 100, MYF(MY_FAE)); - ulint buff2_len = table->s->reclength + ulint buff2_len = table->s->stored_rec_length + table->s->max_key_length + 100; dtuple_t* range_start; dtuple_t* range_end; diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index c08dd3ed173..cf58a3ed972 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -204,6 +204,7 @@ class ha_innobase: public handler /** @} */ bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); + bool check_if_supported_virtual_columns(void) { return TRUE; } }; /* Some accessor functions which the InnoDB plugin needs, but which diff --git a/storage/xtradb/include/buf0buf.ic b/storage/xtradb/include/buf0buf.ic index 2b7f643f59b..d7ac80becce 100644 --- a/storage/xtradb/include/buf0buf.ic +++ b/storage/xtradb/include/buf0buf.ic @@ -1056,7 +1056,7 @@ buf_page_release( buf_block_t* block, /* in: buffer block */ ulint rw_latch, /* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ - mtr_t* mtr) /* in: mtr */ + mtr_t* mtr __attribute__((unused))) /* in: mtr */ { ut_ad(block); diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h index 84fe71595d7..6e5e955f9a5 100644 --- a/storage/xtradb/include/srv0srv.h +++ b/storage/xtradb/include/srv0srv.h @@ -116,8 +116,8 @@ extern ulint srv_log_file_size; extern ulint srv_log_buffer_size; extern ulong srv_flush_log_at_trx_commit; -extern ulint srv_show_locks_held; -extern ulint srv_show_verbose_locks; +extern ulong srv_show_locks_held; +extern ulong srv_show_verbose_locks; /* The sort order table of the MySQL latin1_swedish_ci character set collation */ @@ -166,11 +166,11 @@ extern ulint srv_fast_shutdown; /* If this is 1, do not do a extern ibool srv_innodb_status; extern unsigned long long srv_stats_sample_pages; -extern ulint srv_stats_method; +extern ulong srv_stats_method; #define SRV_STATS_METHOD_NULLS_EQUAL 0 #define SRV_STATS_METHOD_NULLS_NOT_EQUAL 1 #define SRV_STATS_METHOD_IGNORE_NULLS 2 -extern ulint srv_stats_auto_update; +extern ulong srv_stats_auto_update; extern ibool srv_use_doublewrite_buf; extern ibool srv_use_checksums; @@ -183,19 +183,19 @@ extern ulong srv_max_purge_lag; extern ulong srv_replication_delay; -extern ulint srv_io_capacity; +extern ulong srv_io_capacity; extern long long srv_ibuf_max_size; -extern ulint srv_ibuf_active_contract; -extern ulint srv_ibuf_accel_rate; -extern ulint srv_flush_neighbor_pages; -extern ulint srv_enable_unsafe_group_commit; -extern ulint srv_read_ahead; -extern ulint srv_adaptive_checkpoint; +extern ulong srv_ibuf_active_contract; +extern ulong srv_ibuf_accel_rate; +extern ulong srv_flush_neighbor_pages; +extern ulong srv_enable_unsafe_group_commit; +extern ulong srv_read_ahead; +extern ulong srv_adaptive_checkpoint; -extern ulint srv_expand_import; +extern ulong srv_expand_import; -extern ulint srv_extra_rsegments; -extern ulint srv_dict_size_limit; +extern ulong srv_extra_rsegments; +extern ulong srv_dict_size_limit; /*-------------------------------------------*/ extern ulint srv_n_rows_inserted; diff --git a/storage/xtradb/srv/srv0srv.c b/storage/xtradb/srv/srv0srv.c index d261a69991c..35b80d72615 100644 --- a/storage/xtradb/srv/srv0srv.c +++ b/storage/xtradb/srv/srv0srv.c @@ -160,8 +160,8 @@ UNIV_INTERN ulint srv_log_file_size = ULINT_MAX; UNIV_INTERN ulint srv_log_buffer_size = ULINT_MAX; UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1; -UNIV_INTERN ulint srv_show_locks_held = 10; -UNIV_INTERN ulint srv_show_verbose_locks = 0; +UNIV_INTERN ulong srv_show_locks_held = 10; +UNIV_INTERN ulong srv_show_verbose_locks = 0; /* The sort order table of the MySQL latin1_swedish_ci character set @@ -338,8 +338,8 @@ UNIV_INTERN ibool srv_innodb_status = FALSE; /* When estimating number of different key values in an index, sample this many index pages */ UNIV_INTERN unsigned long long srv_stats_sample_pages = 8; -UNIV_INTERN ulint srv_stats_method = 0; -UNIV_INTERN ulint srv_stats_auto_update = 1; +UNIV_INTERN ulong srv_stats_method = 0; +UNIV_INTERN ulong srv_stats_auto_update = 1; UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE; UNIV_INTERN ibool srv_use_checksums = TRUE; @@ -349,7 +349,7 @@ UNIV_INTERN int srv_query_thread_priority = 0; UNIV_INTERN ulong srv_replication_delay = 0; -UNIV_INTERN ulint srv_io_capacity = 100; +UNIV_INTERN ulong srv_io_capacity = 100; /* Returns the number of IO operations that is X percent of the capacity. PCT_IO(5) -> returns the number of IO operations that is 5% of the max @@ -357,20 +357,20 @@ where max is srv_io_capacity. */ #define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0))) UNIV_INTERN long long srv_ibuf_max_size = 0; -UNIV_INTERN ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */ -UNIV_INTERN ulint srv_ibuf_accel_rate = 100; +UNIV_INTERN ulong srv_ibuf_active_contract = 0; /* 0:disable 1:enable */ +UNIV_INTERN ulong srv_ibuf_accel_rate = 100; #define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0))) -UNIV_INTERN ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */ +UNIV_INTERN ulong srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */ -UNIV_INTERN ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */ -UNIV_INTERN ulint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */ -UNIV_INTERN ulint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */ +UNIV_INTERN ulong srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */ +UNIV_INTERN ulong srv_read_ahead = 3; /* 1: random 2: linear 3: Both */ +UNIV_INTERN ulong srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */ -UNIV_INTERN ulint srv_expand_import = 0; /* 0:disable 1:enable */ +UNIV_INTERN ulong srv_expand_import = 0; /* 0:disable 1:enable */ -UNIV_INTERN ulint srv_extra_rsegments = 0; /* extra rseg for users */ -UNIV_INTERN ulint srv_dict_size_limit = 0; +UNIV_INTERN ulong srv_extra_rsegments = 0; /* extra rseg for users */ +UNIV_INTERN ulong srv_dict_size_limit = 0; /*-------------------------------------------*/ UNIV_INTERN ulong srv_n_spin_wait_rounds = 20; UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500; |