summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-07 22:32:48 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-09 18:32:35 +0300
commite174b13465055bdaa03929ffd2a5a5d266570f69 (patch)
treeb223b7b30cb9fb55b21ce1c012e8781da4cf19b7 /sql/sql_window.cc
parent3ba867be891d741de60055c614502d7e66770d7f (diff)
downloadmariadb-git-e174b13465055bdaa03929ffd2a5a5d266570f69.tar.gz
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.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index c970b13f069..6a7084eebdb 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -748,6 +748,8 @@ private:
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 @@ public:
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 @@ protected:
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 @@ protected:
/* Sum functions that this cursor handles. */
List<Item_sum> sum_functions;
+
+private:
+ bool perform_no_action;
};
/*