summaryrefslogtreecommitdiff
path: root/sql/structs.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-11-13 18:02:08 +0400
committerAlexander Barkov <bar@mariadb.com>2018-11-13 18:03:14 +0400
commit2a0b6de41bfd6cbd2ab2c02381ea89bb6bb612a4 (patch)
treedf942bce36e637e8f52a225a791f69d0013c4df0 /sql/structs.h
parent573c4db57a9b9fc5998bd2a2f1311873ca78ab9f (diff)
downloadmariadb-git-2a0b6de41bfd6cbd2ab2c02381ea89bb6bb612a4.tar.gz
MDEV-17253 Oracle compatibility: The REVERSE key word for FOR loop behaves incorrectly
Diffstat (limited to 'sql/structs.h')
-rw-r--r--sql/structs.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/sql/structs.h b/sql/structs.h
index d8b95a3509a..be9abbf4613 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -692,26 +692,41 @@ public:
struct Lex_for_loop_bounds_st
{
public:
- class sp_assignment_lex *m_index;
- class sp_assignment_lex *m_upper_bound;
+ class sp_assignment_lex *m_index; // The first iteration value (or cursor)
+ class sp_assignment_lex *m_target_bound; // The last iteration value
int8 m_direction;
bool m_implicit_cursor;
- bool is_for_loop_cursor() const { return m_upper_bound == NULL; }
+ bool is_for_loop_cursor() const { return m_target_bound == NULL; }
+};
+
+
+class Lex_for_loop_bounds_intrange: public Lex_for_loop_bounds_st
+{
+public:
+ Lex_for_loop_bounds_intrange(int8 direction,
+ class sp_assignment_lex *left_expr,
+ class sp_assignment_lex *right_expr)
+ {
+ m_direction= direction;
+ m_index= direction > 0 ? left_expr : right_expr;
+ m_target_bound= direction > 0 ? right_expr : left_expr;
+ m_implicit_cursor= false;
+ }
};
struct Lex_for_loop_st
{
public:
- class sp_variable *m_index;
- class sp_variable *m_upper_bound;
+ class sp_variable *m_index; // The first iteration value (or cursor)
+ class sp_variable *m_target_bound; // The last iteration value
int m_cursor_offset;
int8 m_direction;
bool m_implicit_cursor;
void init()
{
m_index= 0;
- m_upper_bound= 0;
+ m_target_bound= 0;
m_direction= 0;
m_implicit_cursor= false;
}
@@ -719,7 +734,7 @@ public:
{
*this= other;
}
- bool is_for_loop_cursor() const { return m_upper_bound == NULL; }
+ bool is_for_loop_cursor() const { return m_target_bound == NULL; }
bool is_for_loop_explicit_cursor() const
{
return is_for_loop_cursor() && !m_implicit_cursor;