summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-09-27 10:13:08 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-05 15:02:51 +0400
commit76714a5c9a4c05fa7084f2c562a9eb50a0b7bd17 (patch)
treefc0e93ef9195d89d4079c8608e102012deb3b5e7 /sql/item_func.cc
parent4bb87996b915a9383c7bf33c8683f128d3791014 (diff)
downloadmariadb-git-76714a5c9a4c05fa7084f2c562a9eb50a0b7bd17.tar.gz
MDEV-10582 sql_mode=ORACLE: explicit cursor attributes %ISOPEN, %ROWCOUNT, %FOUND, %NOTFOUND
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 4dd3a1e7da4..ad3a863fa57 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6862,4 +6862,52 @@ void Item_func_last_value::fix_length_and_dec()
}
+void Item_func_cursor_int_attr::print(String *str, enum_query_type query_type)
+{
+ append_identifier(current_thd, str, m_cursor_name.str, m_cursor_name.length);
+ str->append(func_name());
+}
+
+
+sp_cursor *Item_func_cursor_int_attr::get_open_cursor_or_error()
+{
+ THD *thd= current_thd;
+ sp_cursor *c= thd->spcont->get_cursor(m_cursor_offset);
+ DBUG_ASSERT(c);
+ if (!c/*safety*/ || !c->is_open())
+ {
+ my_message(ER_SP_CURSOR_NOT_OPEN, ER_THD(thd, ER_SP_CURSOR_NOT_OPEN),
+ MYF(0));
+ return NULL;
+ }
+ return c;
+}
+
+
+longlong Item_func_cursor_isopen::val_int()
+{
+ sp_cursor *c= current_thd->spcont->get_cursor(m_cursor_offset);
+ DBUG_ASSERT(c != NULL);
+ return c ? c->is_open() : 0;
+}
+
+
+longlong Item_func_cursor_found::val_int()
+{
+ sp_cursor *c= get_open_cursor_or_error();
+ return !(null_value= (!c || c->fetch_count() == 0)) && c->found();
+}
+
+longlong Item_func_cursor_notfound::val_int()
+{
+ sp_cursor *c= get_open_cursor_or_error();
+ return !(null_value= (!c || c->fetch_count() == 0)) && !c->found();
+}
+
+
+longlong Item_func_cursor_rowcount::val_int()
+{
+ sp_cursor *c= get_open_cursor_or_error();
+ return !(null_value= !c) ? c->row_count() : 0;
+}