[Commits] 72f4600: MDEV-12256: Fix BULK INSERT to be able to use it for single iteration

Oleksandr Byelkin sanja at mariadb.com
Wed Mar 15 17:42:48 EET 2017


revision-id: 72f460040d54d40b08857e51746b6741f15df715 (mariadb-10.2.4-64-g72f4600)
parent(s): 6ac754163c417b907ce93ce2e0dd52d8d3cd35b8
committer: Oleksandr Byelkin
timestamp: 2017-03-15 16:42:48 +0100
message:

MDEV-12256: Fix BULK INSERT to be able to use it for single iteration

(there is correspondent tests in CC and JC)

---
 sql/sql_prepare.cc | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index c8765f4..1266b55 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -3055,7 +3055,10 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
   ulong stmt_id= uint4korr(packet);
   ulong flags= (ulong) packet[4];
 #ifndef EMBEDDED_LIBRARY
-  ulong iterations= uint4korr(packet + 5);
+  ulong iterations= ((thd->client_capabilities &
+                      MARIADB_CLIENT_STMT_BULK_OPERATIONS) ?
+                     uint4korr(packet + 5) :
+                     0);
 #else
   ulong iterations= 0; // no support
 #endif
@@ -3089,7 +3092,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
   open_cursor= MY_TEST(flags & (ulong) CURSOR_TYPE_READ_ONLY);
 
   thd->protocol= &thd->protocol_binary;
-  if (iterations <= 1)
+  if (iterations == 0)
     stmt->execute_loop(&expanded_query, open_cursor, packet, packet_end);
   else
     stmt->execute_bulk_loop(&expanded_query, open_cursor, packet, packet_end,
@@ -4152,7 +4155,13 @@ my_bool Prepared_statement::set_bulk_parameters(bool reset)
       reset_stmt_params(this);
       DBUG_RETURN(true);
     }
-    iterations--;
+    if (iterations == 0xFFFFFFFF)
+    {
+      if (packet == packet_end)
+        iterations= 0;
+    }
+    else
+      iterations--;
   }
   start_param= 0;
   DBUG_RETURN(false);


More information about the commits mailing list