summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-07 22:36:47 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-09 18:32:35 +0300
commitffed20c5635a58bc1465efd5d936650b1672da74 (patch)
treed30e898c6725e346e4e8becd30c9cdc7fcfdf7f1 /sql/sql_window.cc
parente174b13465055bdaa03929ffd2a5a5d266570f69 (diff)
downloadmariadb-git-ffed20c5635a58bc1465efd5d936650b1672da74.tar.gz
Extend Frame_cursor to report the current row it is pointing at
Added an extra virtual method to the Frame_cursor class to allow cursors to report the row number to which they are pointing.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc75
1 files changed, 72 insertions, 3 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 6a7084eebdb..a2e793f9582 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -795,6 +795,9 @@ public:
perform_no_action= true;
}
+ /* Retrieves the row number that this cursor currently points at. */
+ virtual ha_rows get_curr_rownum()= 0;
+
protected:
inline void add_value_to_items()
{
@@ -988,6 +991,11 @@ public:
walk_till_non_peer();
}
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
+
private:
void walk_till_non_peer()
{
@@ -1110,6 +1118,11 @@ public:
walk_till_non_peer();
}
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
+
private:
void walk_till_non_peer()
{
@@ -1200,6 +1213,11 @@ public:
walk_till_non_peer();
}
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
+
private:
void walk_till_non_peer()
{
@@ -1299,6 +1317,11 @@ public:
while (1);
}
}
+
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
};
@@ -1322,15 +1345,25 @@ public:
void next_partition(ha_rows rownum)
{
/*
- UNBOUNDED PRECEDING frame end just stays on the first row.
- We are top of the frame, so we don't need to update the sum function.
+ UNBOUNDED PRECEDING frame end just stays on the first row of the
+ partition. We are top of the frame, so we don't need to update the sum
+ function.
*/
+ curr_rownum= rownum;
}
void next_row()
{
/* Do nothing, UNBOUNDED PRECEDING frame end doesn't move. */
}
+
+ ha_rows get_curr_rownum()
+ {
+ return curr_rownum;
+ }
+
+private:
+ ha_rows curr_rownum;
};
@@ -1380,6 +1413,11 @@ public:
{
/* Do nothing, UNBOUNDED FOLLOWING frame end doesn't move */
}
+
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
};
@@ -1415,6 +1453,11 @@ public:
item_with_row_count->set_row_count(num_rows_in_partition);
}
}
+
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
};
/////////////////////////////////////////////////////////////////////////////
@@ -1492,6 +1535,11 @@ public:
else
add_value_to_items();
}
+
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
};
@@ -1506,17 +1554,33 @@ class Frame_rows_current_row_bottom : public Frame_cursor
{
public:
+ Frame_rows_current_row_bottom() : curr_rownum(0) {}
+
void pre_next_partition(ha_rows rownum)
{
add_value_to_items();
}
+
void next_partition(ha_rows rownum) {}
+
void pre_next_row()
{
/* Temp table's current row is current_row. Add it to the window func */
add_value_to_items();
}
- void next_row() {};
+
+ void next_row()
+ {
+ curr_rownum++;
+ };
+
+ ha_rows get_curr_rownum()
+ {
+ return curr_rownum;
+ }
+
+private:
+ ha_rows curr_rownum;
};
@@ -1611,6 +1675,11 @@ public:
next_row_intern();
}
+ ha_rows get_curr_rownum()
+ {
+ return cursor.get_rownum();
+ }
+
private:
bool next_row_intern()
{