[Commits] e2531a7: CCCCC

Oleksandr Byelkin sanja at mariadb.com
Mon Oct 3 22:57:20 EEST 2016


revision-id: e2531a761f88af814031e9242e92bb9ad7668222 (mariadb-10.2.2-15-ge2531a7)
parent(s): fb1c36955949aa99a76bd213113613d7b58ffb1f
committer: Oleksandr Byelkin
timestamp: 2016-10-03 21:57:19 +0200
message:

CCCCC

---
 sql/item.cc     | 19 ++++++++++++-------
 sql/item.h      | 15 +++++++++++----
 sql/sql_base.cc | 18 ++++++++++++------
 3 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/sql/item.cc b/sql/item.cc
index 12b281f..b59d35c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -820,10 +820,14 @@ bool Item_ident::collect_outer_ref_processor(void *param)
 
 void Item_ident::set_default_value_target(Item *item)
 {
+  DBUG_ENTER("Item_ident::set_default_value_target");
+  DBUG_PRINT("XXX", ("Itent: 0x%lx  Item  0x%lx", (ulong) this,
+                     (ulong) item));
   if ((default_value_target= item) && fixed &&
       type() == FIELD_ITEM)
     default_value_target->set_default_value_source(((Item_field *)this)->
                                                    field);
+  DBUG_VOID_RETURN;
 }
 
 /**
@@ -3545,6 +3549,8 @@ void Item_param::reset()
   state= NO_VALUE;
   maybe_null= 1;
   null_value= 0;
+  default_value_source= NULL;
+  default_value_ref= NULL;
   /*
     Don't reset item_type to PARAM_ITEM: it's only needed to guard
     us from item optimizations at prepare stage, when item doesn't yet
@@ -3554,9 +3560,6 @@ void Item_param::reset()
     DBUG_ASSERTS(state != NO_VALUE) in all Item_param::get_*
     methods).
   */
-
-  default_value_source= NULL;
-  default_value_ref= NULL;
   DBUG_VOID_RETURN;
 }
 
@@ -3952,13 +3955,15 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
 
 bool Item_param::set_default(bool can_be_missed)
 {
+  DBUG_ENTER("Item_param::set_default");
+  DBUG_PRINT("XXX", ("Item_param: 0x%lx", (ulong) this));
   if (!default_value_ref)
   {
     if (can_be_missed)
-      return FALSE;
+      DBUG_RETURN(FALSE);
     my_message(ER_INVALID_DEFAULT_PARAM,
                ER_THD(current_thd, ER_INVALID_DEFAULT_PARAM), MYF(0));
-    return TRUE;
+    DBUG_RETURN(TRUE);
   }
   THD *thd= default_value_ref->table->in_use;
   if (!default_value_source)
@@ -3967,11 +3972,11 @@ bool Item_param::set_default(bool can_be_missed)
       Item_default_value(thd, &thd->lex->select_lex.context, default_value_ref);
     if (!default_value_source ||
         default_value_source->fix_fields(thd, (Item **)&default_value_source))
-      return TRUE;
+      DBUG_RETURN(TRUE);
     bitmap_set_bit(default_value_ref->table->read_set,
                    default_value_ref->field_index);
   }
-  return set_value(thd, NULL, (Item**)&default_value_source);
+  DBUG_RETURN(set_value(thd, NULL, (Item**)&default_value_source));
 }
 
 /**
diff --git a/sql/item.h b/sql/item.h
index 100e77a..c37d0ef 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1874,6 +1874,7 @@ class Item: public Value_source,
   }
 
   virtual void set_default_value_source(Field *fld) {};
+  virtual bool set_default_if_needed() { return FALSE; };
 };
 
 
@@ -2802,7 +2803,13 @@ class Item_param :public Item_basic_value,
   int  save_in_field(Field *field, bool no_conversions);
 
   virtual void set_default_value_source(Field *fld)
-  { default_value_ref= fld; }
+  {
+    DBUG_ENTER("Item_param::set_default_value_source");
+    DBUG_PRINT("XXX", ("Item_param: 0x%lx  Field: 0x%lx",
+                       (ulong) this, (ulong) fld));
+    default_value_ref= fld;
+    DBUG_VOID_RETURN;
+  }
 
   bool set_default(bool can_be_missed);
   void set_null();
@@ -2872,15 +2879,15 @@ class Item_param :public Item_basic_value,
 
   virtual void set_out_param_info(Send_field *info);
 
-  bool fix_fields(THD *thd, Item **ref)
+public:
+  bool set_default_if_needed()
   {
     if (state == NO_VALUE && indicator == STMT_INDICATOR_DEFAULT &&
         set_default(FALSE))
       return TRUE;
-    return Item_basic_value::fix_fields(thd, ref);
+    return FALSE;
   }
 
-public:
   virtual const Send_field *get_out_param_info() const;
 
   virtual void make_field(THD *thd, Send_field *field);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d3832a7..fe4aec7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7810,9 +7810,10 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
     if (table->next_number_field &&
         rfield->field_index ==  table->next_number_field->field_index)
       table->auto_increment_field_not_null= TRUE;
-    if (rfield->vcol_info && 
-        value->type() != Item::DEFAULT_VALUE_ITEM && 
-        value->type() != Item::NULL_ITEM &&
+    Item::Type type= value->type();
+    if (rfield->vcol_info &&
+        type != Item::DEFAULT_VALUE_ITEM &&
+        type != Item::NULL_ITEM &&
         table->s->table_category != TABLE_CATEGORY_TEMPORARY)
     {
       push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
@@ -7820,6 +7821,8 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
                           ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
                           rfield->field_name, table->s->table_name.str);
     }
+    if (value->set_default_if_needed())
+      goto err;
     if (rfield->stored_in_db() &&
         (value->save_in_field(rfield, 0)) < 0 && !ignore_errors)
     {
@@ -8060,9 +8063,10 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
     value=v++;
     if (field->field_index == autoinc_index)
       table->auto_increment_field_not_null= TRUE;
-    if (field->vcol_info && 
-        value->type() != Item::DEFAULT_VALUE_ITEM && 
-        value->type() != Item::NULL_ITEM &&
+    Item::Type type= value->type();
+    if (field->vcol_info &&
+        type != Item::DEFAULT_VALUE_ITEM &&
+        type != Item::NULL_ITEM &&
         table->s->table_category != TABLE_CATEGORY_TEMPORARY)
     {
       push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
@@ -8070,6 +8074,8 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
                           ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
                           field->field_name, table->s->table_name.str);
     }
+    if (value->set_default_if_needed())
+      goto err;
 
     if (use_value)
       value->save_val(field);


More information about the commits mailing list