summaryrefslogtreecommitdiff
path: root/storage/innobase/include/row0upd.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/row0upd.ic')
-rw-r--r--storage/innobase/include/row0upd.ic67
1 files changed, 51 insertions, 16 deletions
diff --git a/storage/innobase/include/row0upd.ic b/storage/innobase/include/row0upd.ic
index 618a77fa4bf..ab1dc5c7076 100644
--- a/storage/innobase/include/row0upd.ic
+++ b/storage/innobase/include/row0upd.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
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
@@ -34,7 +34,7 @@ Created 12/27/1996 Heikki Tuuri
/*********************************************************************//**
Creates an update vector object.
-@return own: update vector object */
+@return own: update vector object */
UNIV_INLINE
upd_t*
upd_create(
@@ -44,11 +44,12 @@ upd_create(
{
upd_t* update;
- update = (upd_t*) mem_heap_zalloc(heap, sizeof(upd_t));
+ update = static_cast<upd_t*>(mem_heap_zalloc(
+ heap, sizeof(upd_t) + sizeof(upd_field_t) * n));
update->n_fields = n;
- update->fields = (upd_field_t*)
- mem_heap_zalloc(heap, sizeof(upd_field_t) * n);
+ update->fields = reinterpret_cast<upd_field_t*>(&update[1]);
+ update->heap = heap;
return(update);
}
@@ -56,7 +57,7 @@ upd_create(
/*********************************************************************//**
Returns the number of fields in the update vector == number of columns
to be updated by an update vector.
-@return number of fields */
+@return number of fields */
UNIV_INLINE
ulint
upd_get_n_fields(
@@ -71,7 +72,7 @@ upd_get_n_fields(
#ifdef UNIV_DEBUG
/*********************************************************************//**
Returns the nth field of an update vector.
-@return update vector field */
+@return update vector field */
UNIV_INLINE
upd_field_t*
upd_get_nth_field(
@@ -103,13 +104,12 @@ upd_field_set_field_no(
upd_field->orig_len = 0;
if (field_no >= dict_index_get_n_fields(index)) {
- fprintf(stderr,
- "InnoDB: Error: trying to access field %lu in ",
- (ulong) field_no);
- dict_index_name_print(stderr, trx, index);
- fprintf(stderr, "\n"
- "InnoDB: but index only has %lu fields\n",
- (ulong) dict_index_get_n_fields(index));
+ ib::error()
+ << " trying to access field " << field_no
+ << " in " << index->name
+ << " of table " << index->table->name
+ << " which contains only " << index->n_fields
+ << " fields";
ut_ad(0);
}
@@ -117,20 +117,55 @@ upd_field_set_field_no(
dfield_get_type(&upd_field->new_val));
}
+/** set field number to a update vector field, marks this field is updated.
+@param[in,out] upd_field update vector field
+@param[in] field_no virtual column sequence num
+@param[in] index index */
+UNIV_INLINE
+void
+upd_field_set_v_field_no(
+ upd_field_t* upd_field,
+ ulint field_no,
+ dict_index_t* index)
+{
+ upd_field->field_no = field_no;
+ upd_field->orig_len = 0;
+
+ if (field_no >= dict_table_get_n_v_cols(index->table)) {
+ ib::error()
+ << " trying to access virtual field " << field_no
+ << " in " << index->name
+ << " of table " << index->table->name
+ << " which contains only " << index->table->n_v_cols
+ << " virutal columns";
+ ut_ad(0);
+ }
+
+ dict_col_copy_type(&dict_table_get_nth_v_col(
+ index->table, field_no)->m_col,
+ dfield_get_type(&upd_field->new_val));
+}
+
/*********************************************************************//**
Returns a field of an update vector by field_no.
-@return update vector field, or NULL */
+@return update vector field, or NULL */
UNIV_INLINE
const upd_field_t*
upd_get_field_by_field_no(
/*======================*/
const upd_t* update, /*!< in: update vector */
- ulint no) /*!< in: field_no */
+ ulint no, /*!< in: field_no */
+ bool is_virtual) /*!< in: if it is virtual column */
{
ulint i;
for (i = 0; i < upd_get_n_fields(update); i++) {
const upd_field_t* uf = upd_get_nth_field(update, i);
+ /* matches only if the field matches that of is_virtual */
+ if ((!is_virtual) != (!upd_fld_is_virtual_col(uf))) {
+ continue;
+ }
+
if (uf->field_no == no) {
return(uf);