[Commits] 967b22a: Add a method to disable the automatic adding of values from cursors

vicentiu vicentiu at mariadb.org
Wed Sep 7 22:39:06 EEST 2016


revision-id: 967b22a7a46688f25194ba29844e01ab9c253565 (mariadb-10.2.1-24-g967b22a)
parent(s): 18107a59dd82823b10df05671b5a4584ffd0acc2
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2016-09-07 22:32:48 +0300
message:

Add a method to disable the automatic adding of values from cursors

Currently cursors automatically add values to the sum functions they
manage. There are use cases when we just want to figure out the frame
boundaries, without actually adding/removing values from them.

---
 sql/sql_window.cc | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index c970b13..6a7084e 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -748,6 +748,8 @@ class Partition_read_cursor : public Table_read_cursor
 class Frame_cursor : public Sql_alloc
 {
 public:
+  Frame_cursor() : sum_functions(), perform_no_action(false) {}
+
   virtual void init(READ_RECORD *info) {};
 
   bool add_sum_func(Item_sum* item)
@@ -783,9 +785,22 @@ class Frame_cursor : public Sql_alloc
 
   virtual ~Frame_cursor() {}
 
+  /*
+     Regular frame cursors add or remove values from the sum functions they
+     manage. By calling this method, they will only perform the required
+     movement within the table, but no adding/removing will happen.
+  */
+  void set_no_action()
+  {
+    perform_no_action= true;
+  }
+
 protected:
   inline void add_value_to_items()
   {
+    if (perform_no_action)
+      return;
+
     List_iterator_fast<Item_sum> it(sum_functions);
     Item_sum *item_sum;
     while ((item_sum= it++))
@@ -793,8 +808,12 @@ class Frame_cursor : public Sql_alloc
       item_sum->add();
     }
   }
+
   inline void remove_value_from_items()
   {
+    if (perform_no_action)
+      return;
+
     List_iterator_fast<Item_sum> it(sum_functions);
     Item_sum *item_sum;
     while ((item_sum= it++))
@@ -805,6 +824,9 @@ class Frame_cursor : public Sql_alloc
 
   /* Sum functions that this cursor handles. */
   List<Item_sum> sum_functions;
+
+private:
+  bool perform_no_action;
 };
 
 /*


More information about the commits mailing list