[Commits] e165627: CCC

Oleksandr Byelkin sanja at mariadb.com
Tue Sep 6 14:44:32 EEST 2016


revision-id: e165627f812b54902e48e2317da9ff20560aab3c (mariadb-10.1.8-239-ge165627)
parent(s): ce2bbe1d99835def7337c24d5cb8f27561944135
committer: Oleksandr Byelkin
timestamp: 2016-09-06 13:44:32 +0200
message:

CCC

---
 sql/item.cc        |  6 ++++--
 sql/item.h         | 11 ++++++++++-
 sql/sql_insert.cc  |  1 -
 sql/sql_prepare.cc |  9 ++++-----
 sql/sql_update.cc  |  4 ++++
 5 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/sql/item.cc b/sql/item.cc
index 7604758..df1c50b 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3132,7 +3132,7 @@ Item_param::Item_param(THD *thd, uint pos_in_query_arg):
   Rewritable_query_parameter(pos_in_query_arg, 1),
   Type_handler_hybrid_field_type(MYSQL_TYPE_VARCHAR),
   state(NO_VALUE), default_value_ref(NULL), default_value_source(NULL),
-  indicators(0),
+  indicators(0), indicator(STMT_INDICATOR_NONE),
   /* Don't pretend to be a literal unless value for this item is set. */
   item_type(PARAM_ITEM),
   set_param_func(default_set_param_func),
@@ -3838,10 +3838,12 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
 }
 
 
-bool Item_param::set_default()
+bool Item_param::set_default(bool can_be_missed)
 {
   if (!default_value_ref)
   {
+    if (can_be_missed)
+      return FALSE;
     my_message(ER_INVALID_DEFAULT_PARAM,
                ER_THD(current_thd, ER_INVALID_DEFAULT_PARAM), MYF(0));
     return TRUE;
diff --git a/sql/item.h b/sql/item.h
index ce2a2e5..5131582 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2678,6 +2678,7 @@ class Item_param :public Item_basic_value,
     indicators byte before value of the parameter
   */
   my_bool indicators;
+  uint indicator;
 
   /*
     A buffer for string and long data values. Historically all allocated
@@ -2739,7 +2740,7 @@ class Item_param :public Item_basic_value,
   virtual void set_default_value_source(Field *fld)
   { default_value_ref= fld; }
 
-  bool set_default();
+  bool set_default(bool can_be_missed);
   void set_null();
   void set_int(longlong i, uint32 max_length_arg);
   void set_double(double i);
@@ -2805,6 +2806,14 @@ class Item_param :public Item_basic_value,
 
   virtual void set_out_param_info(Send_field *info);
 
+  bool fix_fields(THD *thd, Item **ref)
+  {
+    if (state == NO_VALUE && indicator == STMT_INDICATOR_DEFAULT &&
+        set_default(FALSE))
+      return TRUE;
+    return Item_basic_value::fix_fields(thd, ref);
+  }
+
 public:
   virtual const Send_field *get_out_param_info() const;
 
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 2e53579..9d79bc3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -637,7 +637,6 @@ static void save_insert_query_plan(THD* thd, TABLE_LIST *table_list)
   }
 }
 
-static
 void setup_deault_parameters(TABLE_LIST *table, List<Item> *fields,
                              List<Item> *values)
 {
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index e3b14e7..fb4628f 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -986,14 +986,13 @@ static bool insert_bulk_params(Prepared_statement *stmt,
     Item_param *param= *it;
     if (param->state != Item_param::LONG_DATA_VALUE)
     {
-      uint indicators;
       if (param->indicators)
-        indicators= *((*read_pos)++);
+        param->indicator= *((*read_pos)++);
       else
-        indicators= STMT_INDICATOR_NONE;
+        param->indicator= STMT_INDICATOR_NONE;
       if ((*read_pos) > data_end)
         DBUG_RETURN(1);
-      switch (indicators) {
+      switch (param->indicator) {
       case STMT_INDICATOR_NONE:
         if ((*read_pos) >= data_end)
           DBUG_RETURN(1);
@@ -1005,7 +1004,7 @@ static bool insert_bulk_params(Prepared_statement *stmt,
         param->set_null();
         break;
       case STMT_INDICATOR_DEFAULT:
-        if (param->set_default())
+        if (param->set_default(TRUE))
           DBUG_RETURN(1);
         break;
       }
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index d59b8b7..52abdb5 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -221,6 +221,8 @@ static void prepare_record_for_error_message(int error, TABLE *table)
   DBUG_VOID_RETURN;
 }
 
+void setup_deault_parameters(TABLE_LIST *table, List<Item> *fields,
+                             List<Item> *values);
 
 /*
   Process usual UPDATE
@@ -354,6 +356,8 @@ int mysql_update(THD *thd,
     DBUG_RETURN(1);
   }
 
+  setup_deault_parameters(NULL, &fields, &values);
+
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   /* Check values */
   table_list->grant.want_privilege= table->grant.want_privilege=


More information about the commits mailing list