summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sp_rcontext.h')
-rw-r--r--sql/sp_rcontext.h70
1 files changed, 49 insertions, 21 deletions
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index 36380952e5d..22fa4f6e865 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -58,7 +58,6 @@ class sp_rcontext : public Sql_alloc
public:
- bool in_handler;
/*
Arena used to (re) allocate items on . E.g. reallocate INOUT/OUT
SP parameters when they don't fit into prealloced items. This
@@ -169,6 +168,18 @@ class sp_rcontext : public Sql_alloc
return m_hstack[--m_hsp];
}
+ inline void
+ enter_handler(int hid)
+ {
+ m_in_handler[m_ihsp++]= hid;
+ }
+
+ inline void
+ exit_handler()
+ {
+ m_ihsp-= 1;
+ }
+
// Save variables starting at fp and up
void
save_variables(uint fp);
@@ -203,12 +214,14 @@ private:
Item *m_result; // For FUNCTIONs
- sp_handler_t *m_handler;
- uint m_hcount;
- uint *m_hstack;
- uint m_hsp;
- int m_hfound; // Set by find_handler; -1 if not found
- List<Item> m_saved; // Saved variables
+ sp_handler_t *m_handler; // Visible handlers
+ uint m_hcount; // Stack pointer for m_handler
+ uint *m_hstack; // Return stack for continue handlers
+ uint m_hsp; // Stack pointer for m_hstack
+ uint *m_in_handler; // Active handler, for recursion check
+ uint m_ihsp; // Stack pointer for m_in_handler
+ int m_hfound; // Set by find_handler; -1 if not found
+ List<Item> m_saved; // Saved variables during handler exec.
sp_cursor **m_cstack;
uint m_ccount;
@@ -216,6 +229,27 @@ private:
}; // class sp_rcontext : public Sql_alloc
+/*
+ An interceptor of cursor result set used to implement
+ FETCH <cname> INTO <varlist>.
+*/
+
+class Select_fetch_into_spvars: public select_result_interceptor
+{
+ List<struct sp_pvar> *spvar_list;
+ uint field_count;
+public:
+ uint get_field_count() { return field_count; }
+ void set_spvar_list(List<struct sp_pvar> *vars) { spvar_list= vars; }
+
+ virtual bool send_eof() { return FALSE; }
+ virtual bool send_data(List<Item> &items);
+ virtual int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
+};
+
+
+/* A mediator between stored procedures and server side cursors */
+
class sp_cursor : public Sql_alloc
{
public:
@@ -227,12 +261,11 @@ public:
destroy();
}
- // We have split this in two to make it easy for sp_instr_copen
- // to reuse the sp_instr::exec_stmt() code.
sp_lex_keeper *
- pre_open(THD *thd);
- void
- post_open(THD *thd, my_bool was_opened);
+ get_lex_keeper() { return m_lex_keeper; }
+
+ int
+ open(THD *thd);
int
close(THD *thd);
@@ -240,7 +273,7 @@ public:
inline my_bool
is_open()
{
- return m_isopen;
+ return test(server_side_cursor);
}
int
@@ -251,18 +284,13 @@ public:
{
return m_i;
}
-
+
private:
- MEM_ROOT m_mem_root; // My own mem_root
+ Select_fetch_into_spvars result;
sp_lex_keeper *m_lex_keeper;
- Protocol_cursor *m_prot;
- my_bool m_isopen;
- my_bool m_nseof; // Original no_send_eof
- Protocol *m_oprot; // Original protcol
- MYSQL_ROWS *m_current_row;
+ Server_side_cursor *server_side_cursor;
sp_instr_cpush *m_i; // My push instruction
-
void
destroy();