Loading sql/sp_head.cc +11 −11 Original line number Diff line number Diff line Loading @@ -1214,7 +1214,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, DBUG_ENTER("sp_head::execute_function"); DBUG_PRINT("info", ("function %s", m_name.str)); params = m_pcont->context_pvars(); params = m_pcont->context_var_count(); /* Check that the function is called with all specified arguments. Loading Loading @@ -1391,7 +1391,7 @@ bool sp_head::execute_procedure(THD *thd, List<Item> *args) { bool err_status= FALSE; uint params = m_pcont->context_pvars(); uint params = m_pcont->context_var_count(); sp_rcontext *save_spcont, *octx; sp_rcontext *nctx = NULL; DBUG_ENTER("sp_head::execute_procedure"); Loading Loading @@ -1443,15 +1443,15 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) for (uint i= 0 ; i < params ; i++) { Item *arg_item= it_args++; sp_pvar_t *pvar= m_pcont->find_pvar(i); sp_variable_t *spvar= m_pcont->find_variable(i); if (!arg_item) break; if (!pvar) if (!spvar) continue; if (pvar->mode != sp_param_in) if (spvar->mode != sp_param_in) { if (!arg_item->is_splocal() && !item_is_user_var(arg_item)) { Loading @@ -1461,7 +1461,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) } } if (pvar->mode == sp_param_out) if (spvar->mode == sp_param_out) { Item_null *null_item= new Item_null(); Loading Loading @@ -1521,9 +1521,9 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (!arg_item) break; sp_pvar_t *pvar= m_pcont->find_pvar(i); sp_variable_t *spvar= m_pcont->find_variable(i); if (pvar->mode == sp_param_in) if (spvar->mode == sp_param_in) continue; if (arg_item->is_splocal()) Loading Loading @@ -2388,7 +2388,7 @@ sp_instr_set::print(String *str) { /* set name@offset ... */ int rsrv = SP_INSTR_UINT_MAXLEN+6; sp_pvar_t *var = m_ctx->find_pvar(m_offset); sp_variable_t *var = m_ctx->find_variable(m_offset); /* 'var' should always be non-null, but just in case... */ if (var) Loading Loading @@ -3004,8 +3004,8 @@ sp_instr_cfetch::execute(THD *thd, uint *nextp) void sp_instr_cfetch::print(String *str) { List_iterator_fast<struct sp_pvar> li(m_varlist); sp_pvar_t *pv; List_iterator_fast<struct sp_variable> li(m_varlist); sp_variable_t *pv; LEX_STRING n; my_bool found= m_ctx->find_cursor(m_cursor, &n); /* cfetch name@offset vars... */ Loading sql/sp_head.h +3 −3 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class sp_instr; class sp_instr_opt_meta; class sp_instr_jump_if_not; struct sp_cond_type; struct sp_pvar; struct sp_variable; class sp_name : public Sql_alloc { Loading Loading @@ -1074,7 +1074,7 @@ class sp_instr_cfetch : public sp_instr virtual void print(String *str); void add_to_varlist(struct sp_pvar *var) void add_to_varlist(struct sp_variable *var) { m_varlist.push_back(var); } Loading @@ -1082,7 +1082,7 @@ class sp_instr_cfetch : public sp_instr private: uint m_cursor; List<struct sp_pvar> m_varlist; List<struct sp_variable> m_varlist; }; // class sp_instr_cfetch : public sp_instr Loading sql/sp_pcontext.cc +81 −80 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ #include "sp_head.h" /* * Sanity check for SQLSTATEs. Will not check if it's really an existing * state (there are just too many), but will check length and bad characters. * Returns TRUE if it's ok, FALSE if it's bad. Sanity check for SQLSTATEs. Will not check if it's really an existing state (there are just too many), but will check length and bad characters. Returns TRUE if it's ok, FALSE if it's bad. */ bool sp_cond_check(LEX_STRING *sqlstate) Loading @@ -51,25 +51,25 @@ sp_cond_check(LEX_STRING *sqlstate) } sp_pcontext::sp_pcontext(sp_pcontext *prev) :Sql_alloc(), m_total_pvars(0), m_csubsize(0), m_hsubsize(0), m_handlers(0), m_parent(prev), m_pboundary(0) :Sql_alloc(), m_max_var_index(0), m_max_cursor_index(0), m_max_handler_index(0), m_context_handlers(0), m_parent(prev), m_pboundary(0) { VOID(my_init_dynamic_array(&m_pvar, sizeof(sp_pvar_t *), 16, 8)); VOID(my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *), 16, 8)); VOID(my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int), 16, 8)); VOID(my_init_dynamic_array(&m_cond, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cursor, sizeof(LEX_STRING), 16, 8)); VOID(my_init_dynamic_array(&m_handler, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING), 16, 8)); VOID(my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *), 16, 8)); m_label.empty(); m_children.empty(); if (!prev) { m_poffset= m_coffset= 0; m_var_offset= m_cursor_offset= 0; m_num_case_exprs= 0; } else { m_poffset= prev->m_poffset + prev->m_total_pvars; m_coffset= prev->current_cursors(); m_var_offset= prev->m_var_offset + prev->m_max_var_index; m_cursor_offset= prev->current_cursor_count(); m_num_case_exprs= prev->get_num_case_exprs(); } } Loading @@ -85,11 +85,11 @@ sp_pcontext::destroy() m_children.empty(); m_label.empty(); delete_dynamic(&m_pvar); delete_dynamic(&m_vars); delete_dynamic(&m_case_expr_id_lst); delete_dynamic(&m_cond); delete_dynamic(&m_cursor); delete_dynamic(&m_handler); delete_dynamic(&m_conds); delete_dynamic(&m_cursors); delete_dynamic(&m_handlers); } sp_pcontext * Loading @@ -105,15 +105,15 @@ sp_pcontext::push_context() sp_pcontext * sp_pcontext::pop_context() { m_parent->m_total_pvars= m_parent->m_total_pvars + m_total_pvars; m_parent->m_max_var_index+= m_max_var_index; uint submax= max_handlers(); if (submax > m_parent->m_hsubsize) m_parent->m_hsubsize= submax; uint submax= max_handler_index(); if (submax > m_parent->m_max_handler_index) m_parent->m_max_handler_index= submax; submax= max_cursors(); if (submax > m_parent->m_csubsize) m_parent->m_csubsize= submax; submax= max_cursor_index(); if (submax > m_parent->m_max_cursor_index) m_parent->m_max_cursor_index= submax; if (m_num_case_exprs > m_parent->m_num_case_exprs) m_parent->m_num_case_exprs= m_num_case_exprs; Loading @@ -130,12 +130,12 @@ sp_pcontext::diff_handlers(sp_pcontext *ctx, bool exclusive) while (pctx && pctx != ctx) { n+= pctx->m_handlers; n+= pctx->m_context_handlers; last_ctx= pctx; pctx= pctx->parent_context(); } if (pctx) return (exclusive && last_ctx ? n - last_ctx->m_handlers : n); return (exclusive && last_ctx ? n - last_ctx->m_context_handlers : n); return 0; // Didn't find ctx } Loading @@ -148,32 +148,33 @@ sp_pcontext::diff_cursors(sp_pcontext *ctx, bool exclusive) while (pctx && pctx != ctx) { n+= pctx->m_cursor.elements; n+= pctx->m_cursors.elements; last_ctx= pctx; pctx= pctx->parent_context(); } if (pctx) return (exclusive && last_ctx ? n - last_ctx->m_cursor.elements : n); return (exclusive && last_ctx ? n - last_ctx->m_cursors.elements : n); return 0; // Didn't find ctx } /* This does a linear search (from newer to older variables, in case ** we have shadowed names). ** It's possible to have a more efficient allocation and search method, ** but it might not be worth it. The typical number of parameters and ** variables will in most cases be low (a handfull). ** ...and, this is only called during parsing. /* This does a linear search (from newer to older variables, in case we have shadowed names). It's possible to have a more efficient allocation and search method, but it might not be worth it. The typical number of parameters and variables will in most cases be low (a handfull). ...and, this is only called during parsing. */ sp_pvar_t * sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) sp_variable_t * sp_pcontext::find_variable(LEX_STRING *name, my_bool scoped) { uint i= m_pvar.elements - m_pboundary; uint i= m_vars.elements - m_pboundary; while (i--) { sp_pvar_t *p; sp_variable_t *p; get_dynamic(&m_pvar, (gptr)&p, i); get_dynamic(&m_vars, (gptr)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) Loading @@ -182,7 +183,7 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) } } if (!scoped && m_parent) return m_parent->find_pvar(name, scoped); return m_parent->find_variable(name, scoped); return NULL; } Loading @@ -193,39 +194,39 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) at the end, of invokation. (Top frame only, so no recursion then.) - For printing of sp_instr_set. (Debug mode only.) */ sp_pvar_t * sp_pcontext::find_pvar(uint offset) sp_variable_t * sp_pcontext::find_variable(uint offset) { if (m_poffset <= offset && offset < m_poffset + m_pvar.elements) if (m_var_offset <= offset && offset < m_var_offset + m_vars.elements) { // This frame sp_pvar_t *p; sp_variable_t *p; get_dynamic(&m_pvar, (gptr)&p, offset - m_poffset); get_dynamic(&m_vars, (gptr)&p, offset - m_var_offset); return p; } if (m_parent) return m_parent->find_pvar(offset); // Some previous frame return m_parent->find_variable(offset); // Some previous frame return NULL; // index out of bounds } sp_pvar_t * sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type, sp_variable_t * sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode) { sp_pvar_t *p= (sp_pvar_t *)sql_alloc(sizeof(sp_pvar_t)); sp_variable_t *p= (sp_variable_t *)sql_alloc(sizeof(sp_variable_t)); if (!p) return NULL; ++m_total_pvars; ++m_max_var_index; p->name.str= name->str; p->name.length= name->length; p->type= type; p->mode= mode; p->offset= current_pvars(); p->offset= current_var_count(); p->dflt= NULL; insert_dynamic(&m_pvar, (gptr)&p); insert_dynamic(&m_vars, (gptr)&p); return p; } Loading Loading @@ -272,23 +273,23 @@ sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val) p->name.str= name->str; p->name.length= name->length; p->val= val; insert_dynamic(&m_cond, (gptr)&p); insert_dynamic(&m_conds, (gptr)&p); } } /* * See comment for find_pvar() above See comment for find_variable() above */ sp_cond_type_t * sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) { uint i= m_cond.elements; uint i= m_conds.elements; while (i--) { sp_cond_t *p; get_dynamic(&m_cond, (gptr)&p, i); get_dynamic(&m_conds, (gptr)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) Loading @@ -302,20 +303,20 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) } /* * This only searches the current context, for error checking of * duplicates. * Returns TRUE if found. This only searches the current context, for error checking of duplicates. Returns TRUE if found. */ bool sp_pcontext::find_handler(sp_cond_type_t *cond) { uint i= m_handler.elements; uint i= m_handlers.elements; while (i--) { sp_cond_type_t *p; get_dynamic(&m_handler, (gptr)&p, i); get_dynamic(&m_handlers, (gptr)&p, i); if (cond->type == p->type) { switch (p->type) Loading @@ -341,31 +342,31 @@ sp_pcontext::push_cursor(LEX_STRING *name) { LEX_STRING n; if (m_cursor.elements == m_csubsize) m_csubsize+= 1; if (m_cursors.elements == m_max_cursor_index) m_max_cursor_index+= 1; n.str= name->str; n.length= name->length; insert_dynamic(&m_cursor, (gptr)&n); insert_dynamic(&m_cursors, (gptr)&n); } /* * See comment for find_pvar() above See comment for find_variable() above */ my_bool sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped) { uint i= m_cursor.elements; uint i= m_cursors.elements; while (i--) { LEX_STRING n; get_dynamic(&m_cursor, (gptr)&n, i); get_dynamic(&m_cursors, (gptr)&n, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)n.str, n.length) == 0) { *poff= m_coffset + i; *poff= m_cursor_offset + i; return TRUE; } } Loading @@ -380,10 +381,10 @@ sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) { /* Put local/context fields in the result list. */ for (uint i = 0; i < m_pvar.elements; ++i) for (uint i = 0; i < m_vars.elements; ++i) { sp_pvar_t *var_def; get_dynamic(&m_pvar, (gptr) &var_def, i); sp_variable_t *var_def; get_dynamic(&m_vars, (gptr) &var_def, i); field_def_lst->push_back(&var_def->field_def); } Loading @@ -404,13 +405,13 @@ sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) my_bool sp_pcontext::find_cursor(uint offset, LEX_STRING *n) { if (m_coffset <= offset && offset < m_coffset + m_cursor.elements) if (m_cursor_offset <= offset && offset < m_cursor_offset + m_cursors.elements) { // This frame get_dynamic(&m_cursor, (gptr)n, offset - m_coffset); get_dynamic(&m_cursors, (gptr)n, offset - m_cursor_offset); return TRUE; } if (m_parent) return m_parent->find_cursor(offset, n); // Some previous frame return FALSE; // index out of bounds } sql/sp_pcontext.h +78 −52 Original line number Diff line number Diff line Loading @@ -29,22 +29,23 @@ typedef enum sp_param_inout } sp_param_mode_t; typedef struct sp_pvar typedef struct sp_variable { LEX_STRING name; enum enum_field_types type; sp_param_mode_t mode; /* offset -- basically, this is an index of variable in the scope of root parsing context. This means, that all variables in a stored routine have distinct indexes/offsets. offset -- this the index to the variable's value in the runtime frame. This is calculated during parsing and used when creating sp_instr_set instructions and Item_splocal items. I.e. values are set/referred by array indexing in runtime. */ uint offset; Item *dflt; create_field field_def; } sp_pvar_t; } sp_variable_t; #define SP_LAB_REF 0 // Unresolved reference (for goto) Loading Loading @@ -76,8 +77,9 @@ typedef struct sp_cond_type uint mysqlerr; } sp_cond_type_t; /* Sanity check for SQLSTATEs. Will not check if it's really an existing * state (there are just too many), but will check length bad characters. /* Sanity check for SQLSTATEs. Will not check if it's really an existing state (there are just too many), but will check length bad characters. */ extern bool sp_cond_check(LEX_STRING *sqlstate); Loading @@ -90,7 +92,17 @@ typedef struct sp_cond /* This seems to be an "SP parsing context" or something. The parse-time context, used to keep track on declared variables/parameters, conditions, handlers, cursors and labels, during parsing. sp_contexts are organized as a tree, with one object for each begin-end block, plus a root-context for the parameters. This is used during parsing for looking up defined names (e.g. declared variables and visible labels), for error checking, and to calculate offsets to be used at runtime. (During execution variable values, active handlers and cursors, etc, are referred to by an index in a stack.) The pcontext tree is also kept during execution and is used for error checking (e.g. correct number of parameters), and in the future, used by the debugger. */ class sp_pcontext : public Sql_alloc Loading Loading @@ -134,50 +146,64 @@ class sp_pcontext : public Sql_alloc // Parameters and variables // /* The maximum number of variables used in this and all child contexts In the root, this gives us the number of slots needed for variables during execution. */ inline uint total_pvars() max_var_index() { return m_total_pvars; return m_max_var_index; } /* The current number of variables used in the parents (from the root), including this context. */ inline uint current_pvars() current_var_count() { return m_poffset + m_pvar.elements; return m_var_offset + m_vars.elements; } /* The number of variables in this context alone */ inline uint context_pvars() context_var_count() { return m_pvar.elements; return m_vars.elements; } /* Map index in this pcontext to runtime offset */ inline uint pvar_context2index(uint i) var_context2runtime(uint i) { return m_poffset + i; return m_var_offset + i; } /* Set type of variable. 'i' is the offset from the top */ inline void set_type(uint i, enum enum_field_types type) { sp_pvar_t *p= find_pvar(i); sp_variable_t *p= find_variable(i); if (p) p->type= type; } /* Set default value of variable. 'i' is the offset from the top */ inline void set_default(uint i, Item *it) { sp_pvar_t *p= find_pvar(i); sp_variable_t *p= find_variable(i); if (p) p->dflt= it; } sp_pvar_t * push_pvar(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode); sp_variable_t * push_variable(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode); /* Retrieve definitions of fields from the current context and its Loading @@ -187,12 +213,12 @@ class sp_pcontext : public Sql_alloc retrieve_field_definitions(List<create_field> *field_def_lst); // Find by name sp_pvar_t * find_pvar(LEX_STRING *name, my_bool scoped=0); sp_variable_t * find_variable(LEX_STRING *name, my_bool scoped=0); // Find by offset sp_pvar_t * find_pvar(uint offset); // Find by offset (from the top) sp_variable_t * find_variable(uint offset); /* Set the current scope boundary (for default values). Loading Loading @@ -280,7 +306,7 @@ class sp_pcontext : public Sql_alloc pop_cond(uint num) { while (num--) pop_dynamic(&m_cond); pop_dynamic(&m_conds); } sp_cond_type_t * Loading @@ -293,22 +319,22 @@ class sp_pcontext : public Sql_alloc inline void push_handler(sp_cond_type_t *cond) { insert_dynamic(&m_handler, (gptr)&cond); insert_dynamic(&m_handlers, (gptr)&cond); } bool find_handler(sp_cond_type *cond); inline uint max_handlers() max_handler_index() { return m_hsubsize + m_handlers; return m_max_handler_index + m_context_handlers; } inline void add_handlers(uint n) { m_handlers+= n; m_context_handlers+= n; } // Loading @@ -326,51 +352,51 @@ class sp_pcontext : public Sql_alloc find_cursor(uint offset, LEX_STRING *n); inline uint max_cursors() max_cursor_index() { return m_csubsize + m_cursor.elements; return m_max_cursor_index + m_cursors.elements; } inline uint current_cursors() current_cursor_count() { return m_coffset + m_cursor.elements; return m_cursor_offset + m_cursors.elements; } protected: /* m_total_pvars -- number of variables (including all types of arguments) m_max_var_index -- number of variables (including all types of arguments) in this context including all children contexts. m_total_pvars >= m_pvar.elements. m_max_var_index >= m_vars.elements. m_total_pvars of the root parsing context contains number of all m_max_var_index of the root parsing context contains number of all variables (including arguments) in all enclosed contexts. */ uint m_total_pvars; uint m_max_var_index; // The maximum sub context's framesizes uint m_csubsize; uint m_hsubsize; uint m_handlers; // No. of handlers in this context uint m_max_cursor_index; uint m_max_handler_index; uint m_context_handlers; // No. of handlers in this context private: sp_pcontext *m_parent; // Parent context /* m_poffset -- basically, this is an index of the first variable in this m_var_offset -- this is an index of the first variable in this parsing context. m_poffset is 0 for root context. m_var_offset is 0 for root context. Since now each variable is stored in separate place, no reuse is done, so m_poffset is different for all enclosed contexts. so m_var_offset is different for all enclosed contexts. */ uint m_poffset; uint m_var_offset; uint m_coffset; // Cursor offset for this context uint m_cursor_offset; // Cursor offset for this context /* Boundary for finding variables in this context. This is the number Loading @@ -382,11 +408,11 @@ class sp_pcontext : public Sql_alloc int m_num_case_exprs; DYNAMIC_ARRAY m_pvar; // Parameters/variables DYNAMIC_ARRAY m_vars; // Parameters/variables DYNAMIC_ARRAY m_case_expr_id_lst; /* Stack of CASE expression ids. */ DYNAMIC_ARRAY m_cond; // Conditions DYNAMIC_ARRAY m_cursor; // Cursors DYNAMIC_ARRAY m_handler; // Handlers, for checking of duplicates DYNAMIC_ARRAY m_conds; // Conditions DYNAMIC_ARRAY m_cursors; // Cursors DYNAMIC_ARRAY m_handlers; // Handlers, for checking for duplicates List<sp_label_t> m_label; // The label list Loading sql/sp_rcontext.cc +12 −12 Original line number Diff line number Diff line Loading @@ -73,16 +73,16 @@ bool sp_rcontext::init(THD *thd) return !(m_handler= (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handlers() * (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(sp_handler_t))) || !(m_hstack= (uint*)thd->alloc(m_root_parsing_ctx->max_handlers() * (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(uint))) || !(m_in_handler= (uint*)thd->alloc(m_root_parsing_ctx->max_handlers() * (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(uint))) || !(m_cstack= (sp_cursor**)thd->alloc(m_root_parsing_ctx->max_cursors() * (sp_cursor**)thd->alloc(m_root_parsing_ctx->max_cursor_index() * sizeof(sp_cursor*))) || !(m_case_expr_holders= (Item_cache**)thd->calloc(m_root_parsing_ctx->get_num_case_exprs() * Loading @@ -105,12 +105,12 @@ sp_rcontext::init_var_table(THD *thd) { List<create_field> field_def_lst; if (!m_root_parsing_ctx->total_pvars()) if (!m_root_parsing_ctx->max_var_index()) return FALSE; m_root_parsing_ctx->retrieve_field_definitions(&field_def_lst); DBUG_ASSERT(field_def_lst.elements == m_root_parsing_ctx->total_pvars()); DBUG_ASSERT(field_def_lst.elements == m_root_parsing_ctx->max_var_index()); if (!(m_var_table= create_virtual_tmp_table(thd, field_def_lst))) return TRUE; Loading @@ -134,7 +134,7 @@ bool sp_rcontext::init_var_items() { uint idx; uint num_vars= m_root_parsing_ctx->total_pvars(); uint num_vars= m_root_parsing_ctx->max_var_index(); if (!(m_var_items= (Item**) sql_alloc(num_vars * sizeof (Item *)))) return TRUE; Loading Loading @@ -381,7 +381,7 @@ sp_cursor::destroy() int sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) sp_cursor::fetch(THD *thd, List<struct sp_variable> *vars) { if (! server_side_cursor) { Loading Loading @@ -528,9 +528,9 @@ int Select_fetch_into_spvars::prepare(List<Item> &fields, SELECT_LEX_UNIT *u) bool Select_fetch_into_spvars::send_data(List<Item> &items) { List_iterator_fast<struct sp_pvar> pv_iter(*spvar_list); List_iterator_fast<struct sp_variable> spvar_iter(*spvar_list); List_iterator_fast<Item> item_iter(items); sp_pvar_t *pv; sp_variable_t *spvar; Item *item; /* Must be ensured by the caller */ Loading @@ -540,9 +540,9 @@ bool Select_fetch_into_spvars::send_data(List<Item> &items) Assign the row fetched from a server side cursor to stored procedure variables. */ for (; pv= pv_iter++, item= item_iter++; ) for (; spvar= spvar_iter++, item= item_iter++; ) { if (thd->spcont->set_variable(thd, pv->offset, item)) if (thd->spcont->set_variable(thd, spvar->offset, item)) return TRUE; } return FALSE; Loading Loading
sql/sp_head.cc +11 −11 Original line number Diff line number Diff line Loading @@ -1214,7 +1214,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, DBUG_ENTER("sp_head::execute_function"); DBUG_PRINT("info", ("function %s", m_name.str)); params = m_pcont->context_pvars(); params = m_pcont->context_var_count(); /* Check that the function is called with all specified arguments. Loading Loading @@ -1391,7 +1391,7 @@ bool sp_head::execute_procedure(THD *thd, List<Item> *args) { bool err_status= FALSE; uint params = m_pcont->context_pvars(); uint params = m_pcont->context_var_count(); sp_rcontext *save_spcont, *octx; sp_rcontext *nctx = NULL; DBUG_ENTER("sp_head::execute_procedure"); Loading Loading @@ -1443,15 +1443,15 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) for (uint i= 0 ; i < params ; i++) { Item *arg_item= it_args++; sp_pvar_t *pvar= m_pcont->find_pvar(i); sp_variable_t *spvar= m_pcont->find_variable(i); if (!arg_item) break; if (!pvar) if (!spvar) continue; if (pvar->mode != sp_param_in) if (spvar->mode != sp_param_in) { if (!arg_item->is_splocal() && !item_is_user_var(arg_item)) { Loading @@ -1461,7 +1461,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) } } if (pvar->mode == sp_param_out) if (spvar->mode == sp_param_out) { Item_null *null_item= new Item_null(); Loading Loading @@ -1521,9 +1521,9 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (!arg_item) break; sp_pvar_t *pvar= m_pcont->find_pvar(i); sp_variable_t *spvar= m_pcont->find_variable(i); if (pvar->mode == sp_param_in) if (spvar->mode == sp_param_in) continue; if (arg_item->is_splocal()) Loading Loading @@ -2388,7 +2388,7 @@ sp_instr_set::print(String *str) { /* set name@offset ... */ int rsrv = SP_INSTR_UINT_MAXLEN+6; sp_pvar_t *var = m_ctx->find_pvar(m_offset); sp_variable_t *var = m_ctx->find_variable(m_offset); /* 'var' should always be non-null, but just in case... */ if (var) Loading Loading @@ -3004,8 +3004,8 @@ sp_instr_cfetch::execute(THD *thd, uint *nextp) void sp_instr_cfetch::print(String *str) { List_iterator_fast<struct sp_pvar> li(m_varlist); sp_pvar_t *pv; List_iterator_fast<struct sp_variable> li(m_varlist); sp_variable_t *pv; LEX_STRING n; my_bool found= m_ctx->find_cursor(m_cursor, &n); /* cfetch name@offset vars... */ Loading
sql/sp_head.h +3 −3 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class sp_instr; class sp_instr_opt_meta; class sp_instr_jump_if_not; struct sp_cond_type; struct sp_pvar; struct sp_variable; class sp_name : public Sql_alloc { Loading Loading @@ -1074,7 +1074,7 @@ class sp_instr_cfetch : public sp_instr virtual void print(String *str); void add_to_varlist(struct sp_pvar *var) void add_to_varlist(struct sp_variable *var) { m_varlist.push_back(var); } Loading @@ -1082,7 +1082,7 @@ class sp_instr_cfetch : public sp_instr private: uint m_cursor; List<struct sp_pvar> m_varlist; List<struct sp_variable> m_varlist; }; // class sp_instr_cfetch : public sp_instr Loading
sql/sp_pcontext.cc +81 −80 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ #include "sp_head.h" /* * Sanity check for SQLSTATEs. Will not check if it's really an existing * state (there are just too many), but will check length and bad characters. * Returns TRUE if it's ok, FALSE if it's bad. Sanity check for SQLSTATEs. Will not check if it's really an existing state (there are just too many), but will check length and bad characters. Returns TRUE if it's ok, FALSE if it's bad. */ bool sp_cond_check(LEX_STRING *sqlstate) Loading @@ -51,25 +51,25 @@ sp_cond_check(LEX_STRING *sqlstate) } sp_pcontext::sp_pcontext(sp_pcontext *prev) :Sql_alloc(), m_total_pvars(0), m_csubsize(0), m_hsubsize(0), m_handlers(0), m_parent(prev), m_pboundary(0) :Sql_alloc(), m_max_var_index(0), m_max_cursor_index(0), m_max_handler_index(0), m_context_handlers(0), m_parent(prev), m_pboundary(0) { VOID(my_init_dynamic_array(&m_pvar, sizeof(sp_pvar_t *), 16, 8)); VOID(my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *), 16, 8)); VOID(my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int), 16, 8)); VOID(my_init_dynamic_array(&m_cond, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cursor, sizeof(LEX_STRING), 16, 8)); VOID(my_init_dynamic_array(&m_handler, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING), 16, 8)); VOID(my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *), 16, 8)); m_label.empty(); m_children.empty(); if (!prev) { m_poffset= m_coffset= 0; m_var_offset= m_cursor_offset= 0; m_num_case_exprs= 0; } else { m_poffset= prev->m_poffset + prev->m_total_pvars; m_coffset= prev->current_cursors(); m_var_offset= prev->m_var_offset + prev->m_max_var_index; m_cursor_offset= prev->current_cursor_count(); m_num_case_exprs= prev->get_num_case_exprs(); } } Loading @@ -85,11 +85,11 @@ sp_pcontext::destroy() m_children.empty(); m_label.empty(); delete_dynamic(&m_pvar); delete_dynamic(&m_vars); delete_dynamic(&m_case_expr_id_lst); delete_dynamic(&m_cond); delete_dynamic(&m_cursor); delete_dynamic(&m_handler); delete_dynamic(&m_conds); delete_dynamic(&m_cursors); delete_dynamic(&m_handlers); } sp_pcontext * Loading @@ -105,15 +105,15 @@ sp_pcontext::push_context() sp_pcontext * sp_pcontext::pop_context() { m_parent->m_total_pvars= m_parent->m_total_pvars + m_total_pvars; m_parent->m_max_var_index+= m_max_var_index; uint submax= max_handlers(); if (submax > m_parent->m_hsubsize) m_parent->m_hsubsize= submax; uint submax= max_handler_index(); if (submax > m_parent->m_max_handler_index) m_parent->m_max_handler_index= submax; submax= max_cursors(); if (submax > m_parent->m_csubsize) m_parent->m_csubsize= submax; submax= max_cursor_index(); if (submax > m_parent->m_max_cursor_index) m_parent->m_max_cursor_index= submax; if (m_num_case_exprs > m_parent->m_num_case_exprs) m_parent->m_num_case_exprs= m_num_case_exprs; Loading @@ -130,12 +130,12 @@ sp_pcontext::diff_handlers(sp_pcontext *ctx, bool exclusive) while (pctx && pctx != ctx) { n+= pctx->m_handlers; n+= pctx->m_context_handlers; last_ctx= pctx; pctx= pctx->parent_context(); } if (pctx) return (exclusive && last_ctx ? n - last_ctx->m_handlers : n); return (exclusive && last_ctx ? n - last_ctx->m_context_handlers : n); return 0; // Didn't find ctx } Loading @@ -148,32 +148,33 @@ sp_pcontext::diff_cursors(sp_pcontext *ctx, bool exclusive) while (pctx && pctx != ctx) { n+= pctx->m_cursor.elements; n+= pctx->m_cursors.elements; last_ctx= pctx; pctx= pctx->parent_context(); } if (pctx) return (exclusive && last_ctx ? n - last_ctx->m_cursor.elements : n); return (exclusive && last_ctx ? n - last_ctx->m_cursors.elements : n); return 0; // Didn't find ctx } /* This does a linear search (from newer to older variables, in case ** we have shadowed names). ** It's possible to have a more efficient allocation and search method, ** but it might not be worth it. The typical number of parameters and ** variables will in most cases be low (a handfull). ** ...and, this is only called during parsing. /* This does a linear search (from newer to older variables, in case we have shadowed names). It's possible to have a more efficient allocation and search method, but it might not be worth it. The typical number of parameters and variables will in most cases be low (a handfull). ...and, this is only called during parsing. */ sp_pvar_t * sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) sp_variable_t * sp_pcontext::find_variable(LEX_STRING *name, my_bool scoped) { uint i= m_pvar.elements - m_pboundary; uint i= m_vars.elements - m_pboundary; while (i--) { sp_pvar_t *p; sp_variable_t *p; get_dynamic(&m_pvar, (gptr)&p, i); get_dynamic(&m_vars, (gptr)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) Loading @@ -182,7 +183,7 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) } } if (!scoped && m_parent) return m_parent->find_pvar(name, scoped); return m_parent->find_variable(name, scoped); return NULL; } Loading @@ -193,39 +194,39 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped) at the end, of invokation. (Top frame only, so no recursion then.) - For printing of sp_instr_set. (Debug mode only.) */ sp_pvar_t * sp_pcontext::find_pvar(uint offset) sp_variable_t * sp_pcontext::find_variable(uint offset) { if (m_poffset <= offset && offset < m_poffset + m_pvar.elements) if (m_var_offset <= offset && offset < m_var_offset + m_vars.elements) { // This frame sp_pvar_t *p; sp_variable_t *p; get_dynamic(&m_pvar, (gptr)&p, offset - m_poffset); get_dynamic(&m_vars, (gptr)&p, offset - m_var_offset); return p; } if (m_parent) return m_parent->find_pvar(offset); // Some previous frame return m_parent->find_variable(offset); // Some previous frame return NULL; // index out of bounds } sp_pvar_t * sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type, sp_variable_t * sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode) { sp_pvar_t *p= (sp_pvar_t *)sql_alloc(sizeof(sp_pvar_t)); sp_variable_t *p= (sp_variable_t *)sql_alloc(sizeof(sp_variable_t)); if (!p) return NULL; ++m_total_pvars; ++m_max_var_index; p->name.str= name->str; p->name.length= name->length; p->type= type; p->mode= mode; p->offset= current_pvars(); p->offset= current_var_count(); p->dflt= NULL; insert_dynamic(&m_pvar, (gptr)&p); insert_dynamic(&m_vars, (gptr)&p); return p; } Loading Loading @@ -272,23 +273,23 @@ sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val) p->name.str= name->str; p->name.length= name->length; p->val= val; insert_dynamic(&m_cond, (gptr)&p); insert_dynamic(&m_conds, (gptr)&p); } } /* * See comment for find_pvar() above See comment for find_variable() above */ sp_cond_type_t * sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) { uint i= m_cond.elements; uint i= m_conds.elements; while (i--) { sp_cond_t *p; get_dynamic(&m_cond, (gptr)&p, i); get_dynamic(&m_conds, (gptr)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) Loading @@ -302,20 +303,20 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) } /* * This only searches the current context, for error checking of * duplicates. * Returns TRUE if found. This only searches the current context, for error checking of duplicates. Returns TRUE if found. */ bool sp_pcontext::find_handler(sp_cond_type_t *cond) { uint i= m_handler.elements; uint i= m_handlers.elements; while (i--) { sp_cond_type_t *p; get_dynamic(&m_handler, (gptr)&p, i); get_dynamic(&m_handlers, (gptr)&p, i); if (cond->type == p->type) { switch (p->type) Loading @@ -341,31 +342,31 @@ sp_pcontext::push_cursor(LEX_STRING *name) { LEX_STRING n; if (m_cursor.elements == m_csubsize) m_csubsize+= 1; if (m_cursors.elements == m_max_cursor_index) m_max_cursor_index+= 1; n.str= name->str; n.length= name->length; insert_dynamic(&m_cursor, (gptr)&n); insert_dynamic(&m_cursors, (gptr)&n); } /* * See comment for find_pvar() above See comment for find_variable() above */ my_bool sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped) { uint i= m_cursor.elements; uint i= m_cursors.elements; while (i--) { LEX_STRING n; get_dynamic(&m_cursor, (gptr)&n, i); get_dynamic(&m_cursors, (gptr)&n, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)n.str, n.length) == 0) { *poff= m_coffset + i; *poff= m_cursor_offset + i; return TRUE; } } Loading @@ -380,10 +381,10 @@ sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) { /* Put local/context fields in the result list. */ for (uint i = 0; i < m_pvar.elements; ++i) for (uint i = 0; i < m_vars.elements; ++i) { sp_pvar_t *var_def; get_dynamic(&m_pvar, (gptr) &var_def, i); sp_variable_t *var_def; get_dynamic(&m_vars, (gptr) &var_def, i); field_def_lst->push_back(&var_def->field_def); } Loading @@ -404,13 +405,13 @@ sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) my_bool sp_pcontext::find_cursor(uint offset, LEX_STRING *n) { if (m_coffset <= offset && offset < m_coffset + m_cursor.elements) if (m_cursor_offset <= offset && offset < m_cursor_offset + m_cursors.elements) { // This frame get_dynamic(&m_cursor, (gptr)n, offset - m_coffset); get_dynamic(&m_cursors, (gptr)n, offset - m_cursor_offset); return TRUE; } if (m_parent) return m_parent->find_cursor(offset, n); // Some previous frame return FALSE; // index out of bounds }
sql/sp_pcontext.h +78 −52 Original line number Diff line number Diff line Loading @@ -29,22 +29,23 @@ typedef enum sp_param_inout } sp_param_mode_t; typedef struct sp_pvar typedef struct sp_variable { LEX_STRING name; enum enum_field_types type; sp_param_mode_t mode; /* offset -- basically, this is an index of variable in the scope of root parsing context. This means, that all variables in a stored routine have distinct indexes/offsets. offset -- this the index to the variable's value in the runtime frame. This is calculated during parsing and used when creating sp_instr_set instructions and Item_splocal items. I.e. values are set/referred by array indexing in runtime. */ uint offset; Item *dflt; create_field field_def; } sp_pvar_t; } sp_variable_t; #define SP_LAB_REF 0 // Unresolved reference (for goto) Loading Loading @@ -76,8 +77,9 @@ typedef struct sp_cond_type uint mysqlerr; } sp_cond_type_t; /* Sanity check for SQLSTATEs. Will not check if it's really an existing * state (there are just too many), but will check length bad characters. /* Sanity check for SQLSTATEs. Will not check if it's really an existing state (there are just too many), but will check length bad characters. */ extern bool sp_cond_check(LEX_STRING *sqlstate); Loading @@ -90,7 +92,17 @@ typedef struct sp_cond /* This seems to be an "SP parsing context" or something. The parse-time context, used to keep track on declared variables/parameters, conditions, handlers, cursors and labels, during parsing. sp_contexts are organized as a tree, with one object for each begin-end block, plus a root-context for the parameters. This is used during parsing for looking up defined names (e.g. declared variables and visible labels), for error checking, and to calculate offsets to be used at runtime. (During execution variable values, active handlers and cursors, etc, are referred to by an index in a stack.) The pcontext tree is also kept during execution and is used for error checking (e.g. correct number of parameters), and in the future, used by the debugger. */ class sp_pcontext : public Sql_alloc Loading Loading @@ -134,50 +146,64 @@ class sp_pcontext : public Sql_alloc // Parameters and variables // /* The maximum number of variables used in this and all child contexts In the root, this gives us the number of slots needed for variables during execution. */ inline uint total_pvars() max_var_index() { return m_total_pvars; return m_max_var_index; } /* The current number of variables used in the parents (from the root), including this context. */ inline uint current_pvars() current_var_count() { return m_poffset + m_pvar.elements; return m_var_offset + m_vars.elements; } /* The number of variables in this context alone */ inline uint context_pvars() context_var_count() { return m_pvar.elements; return m_vars.elements; } /* Map index in this pcontext to runtime offset */ inline uint pvar_context2index(uint i) var_context2runtime(uint i) { return m_poffset + i; return m_var_offset + i; } /* Set type of variable. 'i' is the offset from the top */ inline void set_type(uint i, enum enum_field_types type) { sp_pvar_t *p= find_pvar(i); sp_variable_t *p= find_variable(i); if (p) p->type= type; } /* Set default value of variable. 'i' is the offset from the top */ inline void set_default(uint i, Item *it) { sp_pvar_t *p= find_pvar(i); sp_variable_t *p= find_variable(i); if (p) p->dflt= it; } sp_pvar_t * push_pvar(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode); sp_variable_t * push_variable(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode); /* Retrieve definitions of fields from the current context and its Loading @@ -187,12 +213,12 @@ class sp_pcontext : public Sql_alloc retrieve_field_definitions(List<create_field> *field_def_lst); // Find by name sp_pvar_t * find_pvar(LEX_STRING *name, my_bool scoped=0); sp_variable_t * find_variable(LEX_STRING *name, my_bool scoped=0); // Find by offset sp_pvar_t * find_pvar(uint offset); // Find by offset (from the top) sp_variable_t * find_variable(uint offset); /* Set the current scope boundary (for default values). Loading Loading @@ -280,7 +306,7 @@ class sp_pcontext : public Sql_alloc pop_cond(uint num) { while (num--) pop_dynamic(&m_cond); pop_dynamic(&m_conds); } sp_cond_type_t * Loading @@ -293,22 +319,22 @@ class sp_pcontext : public Sql_alloc inline void push_handler(sp_cond_type_t *cond) { insert_dynamic(&m_handler, (gptr)&cond); insert_dynamic(&m_handlers, (gptr)&cond); } bool find_handler(sp_cond_type *cond); inline uint max_handlers() max_handler_index() { return m_hsubsize + m_handlers; return m_max_handler_index + m_context_handlers; } inline void add_handlers(uint n) { m_handlers+= n; m_context_handlers+= n; } // Loading @@ -326,51 +352,51 @@ class sp_pcontext : public Sql_alloc find_cursor(uint offset, LEX_STRING *n); inline uint max_cursors() max_cursor_index() { return m_csubsize + m_cursor.elements; return m_max_cursor_index + m_cursors.elements; } inline uint current_cursors() current_cursor_count() { return m_coffset + m_cursor.elements; return m_cursor_offset + m_cursors.elements; } protected: /* m_total_pvars -- number of variables (including all types of arguments) m_max_var_index -- number of variables (including all types of arguments) in this context including all children contexts. m_total_pvars >= m_pvar.elements. m_max_var_index >= m_vars.elements. m_total_pvars of the root parsing context contains number of all m_max_var_index of the root parsing context contains number of all variables (including arguments) in all enclosed contexts. */ uint m_total_pvars; uint m_max_var_index; // The maximum sub context's framesizes uint m_csubsize; uint m_hsubsize; uint m_handlers; // No. of handlers in this context uint m_max_cursor_index; uint m_max_handler_index; uint m_context_handlers; // No. of handlers in this context private: sp_pcontext *m_parent; // Parent context /* m_poffset -- basically, this is an index of the first variable in this m_var_offset -- this is an index of the first variable in this parsing context. m_poffset is 0 for root context. m_var_offset is 0 for root context. Since now each variable is stored in separate place, no reuse is done, so m_poffset is different for all enclosed contexts. so m_var_offset is different for all enclosed contexts. */ uint m_poffset; uint m_var_offset; uint m_coffset; // Cursor offset for this context uint m_cursor_offset; // Cursor offset for this context /* Boundary for finding variables in this context. This is the number Loading @@ -382,11 +408,11 @@ class sp_pcontext : public Sql_alloc int m_num_case_exprs; DYNAMIC_ARRAY m_pvar; // Parameters/variables DYNAMIC_ARRAY m_vars; // Parameters/variables DYNAMIC_ARRAY m_case_expr_id_lst; /* Stack of CASE expression ids. */ DYNAMIC_ARRAY m_cond; // Conditions DYNAMIC_ARRAY m_cursor; // Cursors DYNAMIC_ARRAY m_handler; // Handlers, for checking of duplicates DYNAMIC_ARRAY m_conds; // Conditions DYNAMIC_ARRAY m_cursors; // Cursors DYNAMIC_ARRAY m_handlers; // Handlers, for checking for duplicates List<sp_label_t> m_label; // The label list Loading
sql/sp_rcontext.cc +12 −12 Original line number Diff line number Diff line Loading @@ -73,16 +73,16 @@ bool sp_rcontext::init(THD *thd) return !(m_handler= (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handlers() * (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(sp_handler_t))) || !(m_hstack= (uint*)thd->alloc(m_root_parsing_ctx->max_handlers() * (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(uint))) || !(m_in_handler= (uint*)thd->alloc(m_root_parsing_ctx->max_handlers() * (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * sizeof(uint))) || !(m_cstack= (sp_cursor**)thd->alloc(m_root_parsing_ctx->max_cursors() * (sp_cursor**)thd->alloc(m_root_parsing_ctx->max_cursor_index() * sizeof(sp_cursor*))) || !(m_case_expr_holders= (Item_cache**)thd->calloc(m_root_parsing_ctx->get_num_case_exprs() * Loading @@ -105,12 +105,12 @@ sp_rcontext::init_var_table(THD *thd) { List<create_field> field_def_lst; if (!m_root_parsing_ctx->total_pvars()) if (!m_root_parsing_ctx->max_var_index()) return FALSE; m_root_parsing_ctx->retrieve_field_definitions(&field_def_lst); DBUG_ASSERT(field_def_lst.elements == m_root_parsing_ctx->total_pvars()); DBUG_ASSERT(field_def_lst.elements == m_root_parsing_ctx->max_var_index()); if (!(m_var_table= create_virtual_tmp_table(thd, field_def_lst))) return TRUE; Loading @@ -134,7 +134,7 @@ bool sp_rcontext::init_var_items() { uint idx; uint num_vars= m_root_parsing_ctx->total_pvars(); uint num_vars= m_root_parsing_ctx->max_var_index(); if (!(m_var_items= (Item**) sql_alloc(num_vars * sizeof (Item *)))) return TRUE; Loading Loading @@ -381,7 +381,7 @@ sp_cursor::destroy() int sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) sp_cursor::fetch(THD *thd, List<struct sp_variable> *vars) { if (! server_side_cursor) { Loading Loading @@ -528,9 +528,9 @@ int Select_fetch_into_spvars::prepare(List<Item> &fields, SELECT_LEX_UNIT *u) bool Select_fetch_into_spvars::send_data(List<Item> &items) { List_iterator_fast<struct sp_pvar> pv_iter(*spvar_list); List_iterator_fast<struct sp_variable> spvar_iter(*spvar_list); List_iterator_fast<Item> item_iter(items); sp_pvar_t *pv; sp_variable_t *spvar; Item *item; /* Must be ensured by the caller */ Loading @@ -540,9 +540,9 @@ bool Select_fetch_into_spvars::send_data(List<Item> &items) Assign the row fetched from a server side cursor to stored procedure variables. */ for (; pv= pv_iter++, item= item_iter++; ) for (; spvar= spvar_iter++, item= item_iter++; ) { if (thd->spcont->set_variable(thd, pv->offset, item)) if (thd->spcont->set_variable(thd, spvar->offset, item)) return TRUE; } return FALSE; Loading