YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
class sp_cursor; class sp_lex_keeper; class sp_instr_cpush; class sp_instr_hpush_jump; class Query_arena; class sp_head; class Item_cache; class Virtual_tmp_table;
class sp_rcontext : public Sql_alloc
{ public: /// Construct and properly initialize a new sp_rcontext instance. The static /// create-function is needed because we need a way to return an error from /// the constructor. /// /// @param thd Thread handle. /// @param root_parsing_ctx Top-level parsing context for this stored program. /// @param return_value_fld Field object to store the return value /// (for stored functions only). /// /// @return valid sp_rcontext object or NULL in case of OOM-error. static sp_rcontext *create(THD *thd,
sp_head *owner, const sp_pcontext *root_parsing_ctx,
Field *return_value_fld,
Row_definition_list &defs);
~sp_rcontext();
private:
sp_rcontext(sp_head *owner, const sp_pcontext *root_parsing_ctx,
Field *return_value_fld, bool in_sub_stmt);
// Prevent use of copying constructor and operator.
sp_rcontext(const sp_rcontext &); voidoperator=(sp_rcontext &);
public: /// This class stores basic information about SQL-condition, such as: /// - SQL error code; /// - error level; /// - SQLSTATE; /// - text message. /// /// It's used to organize runtime SQL-handler call stack. /// /// Standard Sql_condition class can not be used, because we don't always have /// an Sql_condition object for an SQL-condition in Diagnostics_area. /// /// Eventually, this class should be moved to sql_error.h, and be a part of /// standard SQL-condition processing (Diagnostics_area should contain an /// object for active SQL-condition, not just information stored in DA's /// fields). class Sql_condition_info : public Sql_alloc, public Sql_condition_identity
{ public: /// Text message. char *message;
/** Row number where the condition has happened */
ulong m_row_number;
private: /// This class represents a call frame of SQL-handler (one invocation of a /// handler). Basically, it's needed to store continue instruction pointer for /// CONTINUE SQL-handlers. class Handler_call_frame : public Sql_alloc
{ public: /// SQL-condition, triggered handler activation. const Sql_condition_info *sql_condition;
/// Continue-instruction-pointer for CONTINUE-handlers. /// The attribute contains 0 for EXIT-handlers.
uint continue_ip;
public: /// Arena used to (re) allocate items on. E.g. reallocate INOUT/OUT /// SP-variables when they don't fit into prealloced items. This is common /// situation with String items. It is used mainly in sp_eval_func_item().
Query_arena *callers_arena;
/// Flag to end an open result set before start executing an SQL-handler /// (if one is found). Otherwise the client will hang due to a violation /// of the client/server protocol. bool end_partial_result_set; bool pause_state; bool quit_func;
uint instr_ptr;
/// The stored program for which this runtime context is created. Used for /// checking if correct runtime context is used for variable handling, /// and to access the package run-time context. /// Also used by slow log.
sp_head *m_sp;
/// Push an sp_instr_hpush_jump instance to the handler call stack. /// /// @param entry The condition handler entry /// /// @return error flag. /// @retval false on success. /// @retval true on error. bool push_handler(sp_instr_hpush_jump *entry);
/// Pop and delete given number of instances from the handler /// call stack. /// /// @param count Number of handler entries to pop & delete. void pop_handlers(size_t count);
/// Handle current SQL condition (if any). /// /// This is the public-interface function to handle SQL conditions in /// stored routines. /// /// @param thd Thread handle. /// @param ip[out] Instruction pointer to the first handler /// instruction. /// @param cur_spi Current SP instruction. /// /// @retval true if an SQL-handler has been activated. That means, all of /// the following conditions are satisfied: /// - the SP-instruction raised SQL-condition(s), /// - and there is an SQL-handler to process at least one of those /// SQL-conditions, /// - and that SQL-handler has been activated. /// Note, that the return value has nothing to do with "error flag" /// semantics. /// /// @retval false otherwise. bool handle_sql_condition(THD *thd,
uint *ip, const sp_instr *cur_spi);
/// Remove latest call frame from the handler call stack. /// /// @param da Diagnostics area containing handled conditions. /// /// @return continue instruction pointer of the removed handler.
uint exit_handler(Diagnostics_area *da);
/// Push a cursor to the cursor stack. /// /// @param cursor The cursor /// void push_cursor(sp_cursor *cur);
void pop_cursor(THD *thd); /// Pop and delete given number of sp_cursor instance from the cursor stack. /// /// @param count Number of cursors to pop & delete. void pop_cursors(THD *thd, size_t count);
///////////////////////////////////////////////////////////////////////// // CASE expressions. /////////////////////////////////////////////////////////////////////////
/// Set CASE expression to the specified value. /// /// @param thd Thread handler. /// @param case_expr_id The CASE expression identifier. /// @param case_expr_item The CASE expression value /// /// @return error flag. /// @retval false on success. /// @retval true on error. /// /// @note The idea is to reuse Item_cache for the expression of the one /// CASE statement. This optimization takes place when there is CASE /// statement inside of a loop. So, in other words, we will use the same /// object on each iteration instead of creating a new one for each /// iteration. /// /// TODO /// Hypothetically, a type of CASE expression can be different for each /// iteration. For instance, this can happen if the expression contains /// a session variable (something like @@VAR) and its type is changed /// from one iteration to another. /// /// In order to cope with this problem, we check type each time, when we /// use already created object. If the type does not match, we re-create /// Item. This also can (should?) be optimized. bool set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr);
private: /// Internal function to allocate memory for arrays. /// /// @param thd Thread handle. /// /// @return error flag: false on success, true in case of failure. bool alloc_arrays(THD *thd);
/// Create and initialize a table to store SP-variables. /// /// param thd Thread handle. /// /// @return error flag. /// @retval false on success. /// @retval true on error. bool init_var_table(THD *thd, List<Spvar_definition> &defs);
/// Create and initialize an Item-adapter (Item_field) for each SP-var field. /// /// param thd Thread handle. /// /// @return error flag. /// @retval false on success. /// @retval true on error. bool init_var_items(THD *thd, List<Spvar_definition> &defs);
/// Create an instance of appropriate Item_cache class depending on the /// specified type in the callers arena. /// /// @note We should create cache items in the callers arena, as they are /// used between in several instructions. /// /// @param thd Thread handler. /// @param item Item to get the expression type. /// /// @return Pointer to valid object on success, or NULL in case of error.
Item_cache *create_case_expr_holder(THD *thd, const Item *item) const;
private: /// Top-level (root) parsing context for this runtime context. const sp_pcontext *m_root_parsing_ctx;
/// Virtual table for storing SP-variables.
Virtual_tmp_table *m_var_table;
/// Collection of Item_field proxies, each of them points to the /// corresponding field in m_var_table.
Bounds_checked_array<Item_field *> m_var_items;
/// This is a pointer to a field, which should contain return value for /// stored functions (only). For stored procedures, this pointer is NULL.
Field *m_return_value_fld;
/// Indicates whether the return value (in m_return_value_fld) has been /// set during execution. bool m_return_value_set;
/// Flag to tell if the runtime context is created for a sub-statement. bool m_in_sub_stmt;
/// Stack of visible handlers.
Dynamic_array<sp_instr_hpush_jump *> m_handlers;
/// Stack of caught SQL conditions.
Dynamic_array<Handler_call_frame *> m_handler_call_stack;
/// Stack of cursors.
Bounds_checked_array<sp_cursor *> m_cstack;
/// Current number of cursors in m_cstack.
uint m_ccount;
/// Array of CASE expression holders.
Bounds_checked_array<Item_cache *> m_case_expr_holders;
/// Number of parameters initialized by the callee. This is used to /// determine which parameters should be initialized with the default value.
uint m_inited_params_count;
}; // class sp_rcontext : public Sql_alloc
#endif/* _SP_RCONTEXT_H_ */
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.42Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.