Commit ffed20c5 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

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.
parent e174b134
......@@ -795,6 +795,9 @@ class Frame_cursor : public Sql_alloc
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 @@ class Frame_range_n_top : public Frame_cursor
walk_till_non_peer();
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
private:
void walk_till_non_peer()
{
......@@ -1110,6 +1118,11 @@ class Frame_range_n_bottom: public Frame_cursor
walk_till_non_peer();
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
private:
void walk_till_non_peer()
{
......@@ -1200,6 +1213,11 @@ class Frame_range_current_row_bottom: public Frame_cursor
walk_till_non_peer();
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
private:
void walk_till_non_peer()
{
......@@ -1299,6 +1317,11 @@ class Frame_range_current_row_top : public Frame_cursor
while (1);
}
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
};
......@@ -1322,15 +1345,25 @@ class Frame_unbounded_preceding : public Frame_cursor
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 @@ class Frame_unbounded_following : public Frame_cursor
{
/* Do nothing, UNBOUNDED FOLLOWING frame end doesn't move */
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
};
......@@ -1415,6 +1453,11 @@ class Frame_unbounded_following_set_count : public Frame_unbounded_following
item_with_row_count->set_row_count(num_rows_in_partition);
}
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
};
/////////////////////////////////////////////////////////////////////////////
......@@ -1492,6 +1535,11 @@ class Frame_n_rows_preceding : public Frame_cursor
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 @@ class Frame_n_rows_following : public Frame_cursor
next_row_intern();
}
ha_rows get_curr_rownum()
{
return cursor.get_rownum();
}
private:
bool next_row_intern()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment