[Commits] 1e9857c: more postreview changes

Oleksandr Byelkin sanja at mariadb.com
Mon Oct 24 22:11:06 EEST 2016


revision-id: 1e9857cb13e4da647ddf32285c1c16771f6aded4 (mariadb-10.2.2-51-g1e9857c)
parent(s): 071d92c3ee768106fde5028e2996b4a0da30d4c2
committer: Oleksandr Byelkin
timestamp: 2016-10-24 21:11:06 +0200
message:

more postreview changes

---
 sql/item.cc        | 34 ++++++++++++++++------------------
 sql/sql_base.cc    | 20 +++++++++++---------
 sql/sql_class.h    |  2 +-
 sql/sql_error.cc   |  6 ++++--
 sql/sql_prepare.cc | 22 +++++++++++-----------
 5 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/sql/item.cc b/sql/item.cc
index 7fe0585..217f1cc 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -8504,38 +8504,36 @@ bool Item_default_value::eq(const Item *item, bool binary_cmp) const
 bool Item_default_value::fix_fields(THD *thd, Item **items)
 {
   Item *real_arg;
+  Item_field *field_arg;
   Field *def_field;
   DBUG_ASSERT(fixed == 0);
 
-  if (!arg && !arg_fld)
+  if (!arg)
   {
     fixed= 1;
     return FALSE;
   }
-  if (arg)
-  {
-    if (!arg->fixed && arg->fix_fields(thd, &arg))
-      goto error;
-
+  if (!arg->fixed && arg->fix_fields(thd, &arg))
+    goto error;
 
-    real_arg= arg->real_item();
-    if (real_arg->type() != FIELD_ITEM)
-    {
-      my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->name);
-      goto error;
-    }
 
-    arg_fld= ((Item_field *)real_arg)->field;
+  real_arg= arg->real_item();
+  if (real_arg->type() != FIELD_ITEM)
+  {
+    my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->name);
+    goto error;
   }
-  if ((arg_fld->flags & NO_DEFAULT_VALUE_FLAG))
+
+  field_arg= (Item_field *)real_arg;
+  if ((field_arg->field->flags & NO_DEFAULT_VALUE_FLAG))
   {
-    my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg_fld->field_name);
+    my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->field_name);
     goto error;
   }
-  if (!(def_field= (Field*) thd->alloc(arg_fld->size_of())))
+  if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of())))
     goto error;
-  memcpy((void *)def_field, (void *)arg_fld,
-         arg_fld->size_of());
+  memcpy((void *)def_field, (void *)field_arg->field,
+         field_arg->field->size_of());
   def_field->move_field_offset((my_ptrdiff_t)
                                (def_field->table->s->default_values -
                                 def_field->table->record[0]));
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 78220f8..2d40631 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8061,16 +8061,18 @@ 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;
-    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)
+    if (field->vcol_info)
     {
-      push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
-                          ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
-                          ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
-                          field->field_name, table->s->table_name.str);
+      Item::Type type= value->type();
+      if (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,
+                            ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
+                            ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
+                            field->field_name, table->s->table_name.str);
+      }
     }
 
     if (use_value)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d6dd45c..93d3a4a 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3445,7 +3445,7 @@ class THD :public Statement,
     bulk_param= bulk;
     m_stmt_da->set_bulk_execution(MY_TEST(bulk));
   }
-  bool is_bulk_op() const { return m_stmt_da->is_bulk_op(); }
+  bool is_bulk_op() const { return MY_TEST(bulk_param); }
 
   /// Returns Diagnostics-area for the current statement.
   Diagnostics_area *get_stmt_da()
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 34d608f..d14c7b8 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -384,10 +384,12 @@ Diagnostics_area::set_ok_status(ulonglong affected_rows,
   */
   if (is_error() || is_disabled())
     return;
-
+  /*
+    When running a bulk operation, m_status will be DA_OK for the first
+    operation and set to DA_OK_BULK for all following operations.
+  */
   if (m_status == DA_OK_BULK)
   {
-    DBUG_ASSERT(is_bulk_op());
     m_statement_warn_count+= current_statement_warn_count();
     m_affected_rows+= affected_rows;
   }
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9332da9..80e6f8f 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -997,7 +997,8 @@ static bool insert_bulk_params(Prepared_statement *stmt,
         param->indicator= STMT_INDICATOR_NONE;
       if ((*read_pos) > data_end)
         DBUG_RETURN(1);
-      switch (param->indicator) {
+      switch (param->indicator)
+      {
       case STMT_INDICATOR_NONE:
         if ((*read_pos) >= data_end)
           DBUG_RETURN(1);
@@ -1013,12 +1014,6 @@ static bool insert_bulk_params(Prepared_statement *stmt,
         break;
       }
     }
-    /*
-      A long data stream was supplied for this parameter marker.
-      This was done after prepare, prior to providing a placeholder
-      type (the types are supplied at execute). Check that the
-      supplied type of placeholder can accept a data stream.
-    */
     else
       DBUG_RETURN(1); // long is not supported here
   }
@@ -3094,7 +3089,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
   thd->profiling.set_query_source(stmt->query(), stmt->query_length());
 #endif
   DBUG_PRINT("exec_query", ("%s", stmt->query()));
-  DBUG_PRINT("info",("stmt: 0x%lx iterations: %lu", (long) stmt, iterations));
+  DBUG_PRINT("info",("stmt: 0x%p iterations: %lu", stmt, iterations));
 
   open_cursor= MY_TEST(flags & (ulong) CURSOR_TYPE_READ_ONLY);
 
@@ -4151,7 +4146,7 @@ my_bool Prepared_statement::set_bulk_parameters(bool reset)
 #ifndef EMBEDDED_LIBRARY
     if ((*set_bulk_params)(this, &packet, packet_end, reset))
 #else
-      DBUG_ASSERT(0); //TODO: support bulk parameters for embedded server
+    // bulk parameters are not supported for embedded, so it will an error
 #endif
     {
       my_error(ER_WRONG_ARGUMENTS, MYF(0),
@@ -4208,7 +4203,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
 #ifndef EMBEDDED_LIBRARY
   if (setup_conversion_functions(this, &packet, packet_end, TRUE))
 #else
-  DBUG_ASSERT(0); //TODO: support bulk parameters for embedded server
+  // bulk parameters are not supported for embedded, so it will an error
 #endif
   {
     my_error(ER_WRONG_ARGUMENTS, MYF(0),
@@ -4228,10 +4223,15 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
   }
 #endif
 
-  while((iterations || start_param) && !error && !thd->is_error())
+  // iterations changed by set_bulk_parameters
+  while ((iterations || start_param) && !error && !thd->is_error())
   {
     int reprepare_attempt= 0;
 
+    /*
+      Here we set parameters for not optimized commands,
+      optimized commands do it inside thier internal loop.
+    */
     if (!(sql_command_flags[lex->sql_command] & CF_SP_BULK_OPTIMIZED))
     {
       if (set_bulk_parameters(TRUE))


More information about the commits mailing list