diff options
author | unknown <pem@mysql.com> | 2003-02-26 19:22:29 +0100 |
---|---|---|
committer | unknown <pem@mysql.com> | 2003-02-26 19:22:29 +0100 |
commit | 76b037dc4288fada1b64efbef422cb8b4bd0d5b5 (patch) | |
tree | 21d88c3a00a56c11d4f65d0c77e082899658ec01 /sql/sp_head.h | |
parent | 0521fb5444df9a97e0682307242700bd94c6595e (diff) | |
download | mariadb-git-76b037dc4288fada1b64efbef422cb8b4bd0d5b5.tar.gz |
Made stored FUNCTION invokation work almost always. Still buggy and unstable, and
various known problems, but good enough for a checkpoint commit.
mysql-test/r/sp.result:
New tests for invoking simple FUNCTIONs.
mysql-test/t/sp.test:
New tests for invoking simple FUNCTIONs.
sql/item_func.cc:
New Item_func_sp for stored FUNCTIONs.
sql/item_func.h:
New Item_func_sp for stored FUNCTIONs.
sql/sp.cc:
Close mysql.proc table earlier so recursive find_function calls work.
Added temporary sp_function_exists() function for checking without parsing.
sql/sp.h:
Added temporary sp_function_exists() function for checking without parsing.
sql/sp_head.cc:
New code for executing a FUNCTION. (And reworked some of the old code in the process.)
sql/sp_head.h:
New code for executing a FUNCTION.
sql/sp_rcontext.h:
Added result slot for FUNCTIONs.
sql/sql_lex.cc:
Added check for stored FUNCTION, analogous to UDFs.
sql/sql_parse.cc:
sp_head::execute was renamed into execute_procedure.
sql/sql_yacc.yy:
Added parsing of stored FUNCTION invocation and code generation for RETURN statement.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r-- | sql/sp_head.h | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h index b0f57757f98..fa2a76753e7 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -29,6 +29,9 @@ #define TYPE_ENUM_FUNCTION 1 #define TYPE_ENUM_PROCEDURE 2 +Item_result +sp_map_result_type(enum enum_field_types type); + struct sp_label; class sp_instr; @@ -62,7 +65,10 @@ public: create(THD *thd); int - execute(THD *thd); + execute_function(THD *thd, Item **args, uint argcount, Item **resp); + + int + execute_procedure(THD *thd, List<Item> *args); inline void add_instr(sp_instr *i) @@ -103,6 +109,11 @@ public: return n->c_ptr(); } + inline Item_result result() + { + return sp_map_result_type(m_returns); + } + private: Item_string *m_name; @@ -122,10 +133,14 @@ private: { sp_instr *in= NULL; - get_dynamic(&m_instr, (gptr)&in, i); + if (i < m_instr.elements) + get_dynamic(&m_instr, (gptr)&in, i); return in; } + int + execute(THD *thd); + }; // class sp_head : public Sql_alloc @@ -319,4 +334,28 @@ private: }; // class sp_instr_jump_if_not : public sp_instr_jump + +class sp_instr_return : public sp_instr +{ + sp_instr_return(const sp_instr_return &); /* Prevent use of these */ + void operator=(sp_instr_return &); + +public: + + sp_instr_return(uint ip, Item *val, enum enum_field_types type) + : sp_instr(ip), m_value(val), m_type(type) + {} + + virtual ~sp_instr_return() + {} + + virtual int execute(THD *thd, uint *nextp); + +protected: + + Item *m_value; + enum enum_field_types m_type; + +}; // class sp_instr_return : public sp_instr + #endif /* _SP_HEAD_H_ */ |