Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
/* -*- C++ -*- */
|
|
|
|
/* Copyright (C) 2002 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
#ifndef _SP_HEAD_H_
|
|
|
|
#define _SP_HEAD_H_
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma interface /* gcc class implementation */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
// Values for the type enum. This reflects the order of the enum declaration
|
|
|
|
// in the CREATE TABLE command.
|
|
|
|
#define TYPE_ENUM_FUNCTION 1
|
|
|
|
#define TYPE_ENUM_PROCEDURE 2
|
2004-09-07 14:29:46 +02:00
|
|
|
#define TYPE_ENUM_TRIGGER 3
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
Item_result
|
|
|
|
sp_map_result_type(enum enum_field_types type);
|
|
|
|
|
2004-08-06 13:47:01 +02:00
|
|
|
bool
|
|
|
|
sp_multi_results_command(enum enum_sql_command cmd);
|
|
|
|
|
2002-12-16 15:40:44 +01:00
|
|
|
struct sp_label;
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
class sp_instr;
|
2003-09-16 14:26:08 +02:00
|
|
|
struct sp_cond_type;
|
2003-10-10 16:57:21 +02:00
|
|
|
struct sp_pvar;
|
2003-09-16 14:26:08 +02:00
|
|
|
|
WL#1366: Use the schema (db) associated with an SP.
Phase 1: Introduced sp_name class, for qualified name support.
sql/item_func.cc:
Introduced sp_name class; moved some methods from item_func.h.
sql/item_func.h:
Introduced sp_name class; moved some methods to item_func.cc.
sql/sp.cc:
Introduced sp_name class, for qualified name support.
sql/sp.h:
Introduced sp_name class, for qualified name support.
sql/sp_cache.cc:
Introduced sp_name class, for qualified name support.
sql/sp_cache.h:
Introduced sp_name class, for qualified name support.
sql/sp_head.cc:
Introduced sp_name class, for qualified name support.
sql/sp_head.h:
Introduced sp_name class, for qualified name support.
sql/sql_lex.h:
Introduced sp_name class, for qualified name support.
sql/sql_parse.cc:
Introduced sp_name class, for qualified name support.
sql/sql_yacc.yy:
Introduced sp_name class, for qualified name support.
2004-02-17 17:36:53 +01:00
|
|
|
class sp_name : public Sql_alloc
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
LEX_STRING m_db;
|
|
|
|
LEX_STRING m_name;
|
|
|
|
LEX_STRING m_qname;
|
|
|
|
|
|
|
|
sp_name(LEX_STRING name)
|
|
|
|
: m_name(name)
|
|
|
|
{
|
|
|
|
m_db.str= m_qname.str= 0;
|
|
|
|
m_db.length= m_qname.length= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sp_name(LEX_STRING db, LEX_STRING name)
|
|
|
|
: m_db(db), m_name(name)
|
|
|
|
{
|
|
|
|
m_qname.str= 0;
|
|
|
|
m_qname.length= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init. the qualified name from the db and name.
|
|
|
|
void init_qname(THD *thd); // thd for memroot allocation
|
|
|
|
|
|
|
|
~sp_name()
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2004-03-11 17:18:59 +01:00
|
|
|
sp_name *
|
|
|
|
sp_name_current_db_new(THD *thd, LEX_STRING name);
|
|
|
|
|
|
|
|
|
2004-05-20 01:02:49 +02:00
|
|
|
class sp_head :private Item_arena
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
{
|
|
|
|
sp_head(const sp_head &); /* Prevent use of these */
|
|
|
|
void operator=(sp_head &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
|
|
|
|
enum enum_field_types m_returns; // For FUNCTIONs only
|
2004-04-06 13:26:53 +02:00
|
|
|
CHARSET_INFO *m_returns_cs; // For FUNCTIONs only
|
2003-10-03 17:38:12 +02:00
|
|
|
my_bool m_has_return; // For FUNCTIONs only
|
2002-12-17 10:01:52 +01:00
|
|
|
my_bool m_simple_case; // TRUE if parsing simple case, FALSE otherwise
|
2003-08-27 17:04:33 +02:00
|
|
|
my_bool m_multi_results; // TRUE if a procedure with SELECT(s)
|
2004-08-26 12:54:30 +02:00
|
|
|
my_bool m_in_handler; // TRUE if parser in a handler body
|
2003-04-23 09:22:54 +02:00
|
|
|
uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value
|
2003-12-10 19:05:37 +01:00
|
|
|
st_sp_chistics *m_chistics;
|
2004-06-09 14:19:43 +02:00
|
|
|
ulong m_sql_mode; // For SHOW CREATE
|
2003-07-03 15:58:37 +02:00
|
|
|
#if NOT_USED_NOW
|
2003-04-27 17:35:54 +02:00
|
|
|
// QQ We're not using this at the moment.
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
List<char *> m_calls; // Called procedures.
|
2002-12-19 18:43:25 +01:00
|
|
|
List<char *> m_tables; // Used tables.
|
2003-03-02 19:17:41 +01:00
|
|
|
#endif
|
WL#1366: Use the schema (db) associated with an SP.
Phase 1: Introduced sp_name class, for qualified name support.
sql/item_func.cc:
Introduced sp_name class; moved some methods from item_func.h.
sql/item_func.h:
Introduced sp_name class; moved some methods to item_func.cc.
sql/sp.cc:
Introduced sp_name class, for qualified name support.
sql/sp.h:
Introduced sp_name class, for qualified name support.
sql/sp_cache.cc:
Introduced sp_name class, for qualified name support.
sql/sp_cache.h:
Introduced sp_name class, for qualified name support.
sql/sp_head.cc:
Introduced sp_name class, for qualified name support.
sql/sp_head.h:
Introduced sp_name class, for qualified name support.
sql/sql_lex.h:
Introduced sp_name class, for qualified name support.
sql/sql_parse.cc:
Introduced sp_name class, for qualified name support.
sql/sql_yacc.yy:
Introduced sp_name class, for qualified name support.
2004-02-17 17:36:53 +01:00
|
|
|
LEX_STRING m_qname; // db.name
|
|
|
|
LEX_STRING m_db;
|
In order to make ALTER PROCEDURE|FUNCTION work correctly, and in general to
make characteristics (and SHOW) work right, we had to separate the old
definition blob in the mysql.proc table into separate fields for parameters,
return type, and body, and handle the characteristics (like SQL SECURITY)
separately... and then reassemble the CREATE string for parsing, of course.
This is rather ugly, mostly the parser bit. (Hopefully that will be better
with the new parser.)
Docs/sp-imp-spec.txt:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
mysql-test/r/sp.result:
New characteristics tests.
mysql-test/t/sp.test:
New characteristics tests.
scripts/mysql_create_system_tables.sh:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
scripts/mysql_fix_privilege_tables.sql:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
sql/sp.cc:
Separated the definitions string of the procedure into different columns.
Rewrote much of the code related this (have a assemble the definition
string from its different parts now) and the way characteristics are now
handled, in order to make ALTER actually work.
sql/sp.h:
Changed prototypes.
sql/sp_head.cc:
Rewrote much of the code related to the new mysql.proc schema with separate
definition fields (have to assemble the definition string from its different
parts now) and the way characteristics are now handled, in order to make ALTER
actually work.
sql/sp_head.h:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
sql/sql_yacc.yy:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
This is ugly and messy; hopefully there's a more elegant way to do this
when the new parser is installed.
2003-12-12 14:05:29 +01:00
|
|
|
LEX_STRING m_name;
|
|
|
|
LEX_STRING m_params;
|
|
|
|
LEX_STRING m_retstr; // For FUNCTIONs only
|
|
|
|
LEX_STRING m_body;
|
|
|
|
LEX_STRING m_defstr;
|
2003-12-13 16:40:52 +01:00
|
|
|
LEX_STRING m_definer_user;
|
|
|
|
LEX_STRING m_definer_host;
|
In order to make ALTER PROCEDURE|FUNCTION work correctly, and in general to
make characteristics (and SHOW) work right, we had to separate the old
definition blob in the mysql.proc table into separate fields for parameters,
return type, and body, and handle the characteristics (like SQL SECURITY)
separately... and then reassemble the CREATE string for parsing, of course.
This is rather ugly, mostly the parser bit. (Hopefully that will be better
with the new parser.)
Docs/sp-imp-spec.txt:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
mysql-test/r/sp.result:
New characteristics tests.
mysql-test/t/sp.test:
New characteristics tests.
scripts/mysql_create_system_tables.sh:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
scripts/mysql_fix_privilege_tables.sql:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
sql/sp.cc:
Separated the definitions string of the procedure into different columns.
Rewrote much of the code related this (have a assemble the definition
string from its different parts now) and the way characteristics are now
handled, in order to make ALTER actually work.
sql/sp.h:
Changed prototypes.
sql/sp_head.cc:
Rewrote much of the code related to the new mysql.proc schema with separate
definition fields (have to assemble the definition string from its different
parts now) and the way characteristics are now handled, in order to make ALTER
actually work.
sql/sp_head.h:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
sql/sql_yacc.yy:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
This is ugly and messy; hopefully there's a more elegant way to do this
when the new parser is installed.
2003-12-12 14:05:29 +01:00
|
|
|
longlong m_created;
|
|
|
|
longlong m_modified;
|
|
|
|
// Pointers set during parsing
|
|
|
|
uchar *m_param_begin, *m_param_end, *m_returns_begin, *m_returns_end,
|
|
|
|
*m_body_begin;
|
2002-12-17 10:01:52 +01:00
|
|
|
|
2003-06-29 18:15:17 +02:00
|
|
|
static void *
|
|
|
|
operator new(size_t size);
|
|
|
|
|
2004-05-26 13:28:35 +02:00
|
|
|
static void
|
2003-06-29 18:15:17 +02:00
|
|
|
operator delete(void *ptr, size_t size);
|
|
|
|
|
2003-07-01 17:19:48 +02:00
|
|
|
sp_head();
|
|
|
|
|
|
|
|
// Initialize after we have reset mem_root
|
|
|
|
void
|
In order to make ALTER PROCEDURE|FUNCTION work correctly, and in general to
make characteristics (and SHOW) work right, we had to separate the old
definition blob in the mysql.proc table into separate fields for parameters,
return type, and body, and handle the characteristics (like SQL SECURITY)
separately... and then reassemble the CREATE string for parsing, of course.
This is rather ugly, mostly the parser bit. (Hopefully that will be better
with the new parser.)
Docs/sp-imp-spec.txt:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
mysql-test/r/sp.result:
New characteristics tests.
mysql-test/t/sp.test:
New characteristics tests.
scripts/mysql_create_system_tables.sh:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
scripts/mysql_fix_privilege_tables.sql:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
sql/sp.cc:
Separated the definitions string of the procedure into different columns.
Rewrote much of the code related this (have a assemble the definition
string from its different parts now) and the way characteristics are now
handled, in order to make ALTER actually work.
sql/sp.h:
Changed prototypes.
sql/sp_head.cc:
Rewrote much of the code related to the new mysql.proc schema with separate
definition fields (have to assemble the definition string from its different
parts now) and the way characteristics are now handled, in order to make ALTER
actually work.
sql/sp_head.h:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
sql/sql_yacc.yy:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
This is ugly and messy; hopefully there's a more elegant way to do this
when the new parser is installed.
2003-12-12 14:05:29 +01:00
|
|
|
init(LEX *lex);
|
|
|
|
|
|
|
|
// Initialize strings after parsing header
|
|
|
|
void
|
WL#1366: Use the schema (db) associated with an SP.
Phase 1: Introduced sp_name class, for qualified name support.
sql/item_func.cc:
Introduced sp_name class; moved some methods from item_func.h.
sql/item_func.h:
Introduced sp_name class; moved some methods to item_func.cc.
sql/sp.cc:
Introduced sp_name class, for qualified name support.
sql/sp.h:
Introduced sp_name class, for qualified name support.
sql/sp_cache.cc:
Introduced sp_name class, for qualified name support.
sql/sp_cache.h:
Introduced sp_name class, for qualified name support.
sql/sp_head.cc:
Introduced sp_name class, for qualified name support.
sql/sp_head.h:
Introduced sp_name class, for qualified name support.
sql/sql_lex.h:
Introduced sp_name class, for qualified name support.
sql/sql_parse.cc:
Introduced sp_name class, for qualified name support.
sql/sql_yacc.yy:
Introduced sp_name class, for qualified name support.
2004-02-17 17:36:53 +01:00
|
|
|
init_strings(THD *thd, LEX *lex, sp_name *name);
|
2003-11-17 18:21:36 +01:00
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
int
|
|
|
|
create(THD *thd);
|
2004-05-26 13:28:35 +02:00
|
|
|
|
2003-06-29 18:15:17 +02:00
|
|
|
virtual ~sp_head();
|
|
|
|
|
2003-04-02 20:42:28 +02:00
|
|
|
// Free memory
|
|
|
|
void
|
|
|
|
destroy();
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
int
|
2003-02-26 19:22:29 +01:00
|
|
|
execute_function(THD *thd, Item **args, uint argcount, Item **resp);
|
|
|
|
|
|
|
|
int
|
|
|
|
execute_procedure(THD *thd, List<Item> *args);
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2003-11-17 18:21:36 +01:00
|
|
|
int
|
|
|
|
show_create_procedure(THD *thd);
|
|
|
|
|
|
|
|
int
|
|
|
|
show_create_function(THD *thd);
|
|
|
|
|
2004-05-26 13:28:35 +02:00
|
|
|
void
|
|
|
|
add_instr(sp_instr *instr);
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
inline uint
|
|
|
|
instructions()
|
|
|
|
{
|
|
|
|
return m_instr.elements;
|
|
|
|
}
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
inline sp_instr *
|
|
|
|
last_instruction()
|
|
|
|
{
|
|
|
|
sp_instr *i;
|
|
|
|
|
|
|
|
get_dynamic(&m_instr, (gptr)&i, m_instr.elements-1);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
// Resets lex in 'thd' and keeps a copy of the old one.
|
|
|
|
void
|
|
|
|
reset_lex(THD *thd);
|
|
|
|
|
|
|
|
// Restores lex in 'thd' from our copy, but keeps some status from the
|
|
|
|
// one in 'thd', like ptr, tables, fields, etc.
|
|
|
|
void
|
|
|
|
restore_lex(THD *thd);
|
|
|
|
|
2002-12-16 15:40:44 +01:00
|
|
|
// Put the instruction on the backpatch list, associated with the label.
|
2002-12-11 14:24:29 +01:00
|
|
|
void
|
2002-12-16 15:40:44 +01:00
|
|
|
push_backpatch(sp_instr *, struct sp_label *);
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2002-12-16 15:40:44 +01:00
|
|
|
// Update all instruction with this label in the backpatch list to
|
|
|
|
// the current position.
|
2002-12-11 14:24:29 +01:00
|
|
|
void
|
2002-12-16 15:40:44 +01:00
|
|
|
backpatch(struct sp_label *);
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2004-08-17 20:20:58 +02:00
|
|
|
// Check that no unresolved references exist.
|
|
|
|
// If none found, 0 is returned, otherwise errors have been issued
|
|
|
|
// and -1 is returned.
|
|
|
|
// This is called by the parser at the end of a create procedure/function.
|
|
|
|
int
|
|
|
|
check_backpatch(THD *thd);
|
|
|
|
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
char *name(uint *lenp = 0) const
|
|
|
|
{
|
|
|
|
if (lenp)
|
2003-04-03 16:00:09 +02:00
|
|
|
*lenp= m_name.length;
|
|
|
|
return m_name.str;
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
}
|
|
|
|
|
In order to make ALTER PROCEDURE|FUNCTION work correctly, and in general to
make characteristics (and SHOW) work right, we had to separate the old
definition blob in the mysql.proc table into separate fields for parameters,
return type, and body, and handle the characteristics (like SQL SECURITY)
separately... and then reassemble the CREATE string for parsing, of course.
This is rather ugly, mostly the parser bit. (Hopefully that will be better
with the new parser.)
Docs/sp-imp-spec.txt:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
mysql-test/r/sp.result:
New characteristics tests.
mysql-test/t/sp.test:
New characteristics tests.
scripts/mysql_create_system_tables.sh:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
scripts/mysql_fix_privilege_tables.sql:
Separated the definitions string of the procedure into different columns
in the mysql.proc schema.
sql/sp.cc:
Separated the definitions string of the procedure into different columns.
Rewrote much of the code related this (have a assemble the definition
string from its different parts now) and the way characteristics are now
handled, in order to make ALTER actually work.
sql/sp.h:
Changed prototypes.
sql/sp_head.cc:
Rewrote much of the code related to the new mysql.proc schema with separate
definition fields (have to assemble the definition string from its different
parts now) and the way characteristics are now handled, in order to make ALTER
actually work.
sql/sp_head.h:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
sql/sql_yacc.yy:
Separated the different parts of the definition strings: name, parameters,
return type (for functions) and body.
This is ugly and messy; hopefully there's a more elegant way to do this
when the new parser is installed.
2003-12-12 14:05:29 +01:00
|
|
|
char *create_string(THD *thd, ulong *lenp);
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
inline Item_result result()
|
|
|
|
{
|
|
|
|
return sp_map_result_type(m_returns);
|
|
|
|
}
|
|
|
|
|
2003-12-13 16:40:52 +01:00
|
|
|
void set_info(char *definer, uint definerlen,
|
2003-12-10 19:05:37 +01:00
|
|
|
longlong created, longlong modified,
|
2004-06-09 14:19:43 +02:00
|
|
|
st_sp_chistics *chistics, ulong sql_mode);
|
2003-06-29 18:15:17 +02:00
|
|
|
|
2004-03-11 17:18:59 +01:00
|
|
|
void reset_thd_mem_root(THD *thd);
|
|
|
|
|
|
|
|
void restore_thd_mem_root(THD *thd);
|
2003-06-29 18:15:17 +02:00
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
void optimize();
|
|
|
|
void opt_mark(uint ip);
|
|
|
|
|
|
|
|
inline sp_instr *
|
|
|
|
get_instr(uint i)
|
|
|
|
{
|
|
|
|
sp_instr *ip;
|
|
|
|
|
|
|
|
if (i < m_instr.elements)
|
|
|
|
get_dynamic(&m_instr, (gptr)&ip, i);
|
|
|
|
else
|
|
|
|
ip= NULL;
|
|
|
|
return ip;
|
|
|
|
}
|
2003-05-06 18:09:20 +02:00
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
private:
|
|
|
|
|
2003-06-29 18:15:17 +02:00
|
|
|
MEM_ROOT m_thd_root; // Temp. store for thd's mem_root
|
|
|
|
THD *m_thd; // Set if we have reset mem_root
|
2004-03-11 17:18:59 +01:00
|
|
|
char *m_thd_db; // Original thd->db pointer
|
2003-07-07 14:55:10 +02:00
|
|
|
|
2003-03-02 19:17:41 +01:00
|
|
|
sp_pcontext *m_pcont; // Parse context
|
2003-06-29 18:15:17 +02:00
|
|
|
List<LEX> m_lex; // Temp. store for the other lex
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
DYNAMIC_ARRAY m_instr; // The "instructions"
|
2002-12-16 15:40:44 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct sp_label *lab;
|
|
|
|
sp_instr *instr;
|
|
|
|
} bp_t;
|
Most of the groundwork for sprint task 729 (implement FUNCTIONs).
Expanded the mysql.proc table, reworked the find/create/drop functions
completely, added new functions for FUNCTIONs (lotta functions here :),
got rid of some unnecessary use of Item_strings while at it. Extended
the parser correspondingly, and fiddled around a bit to make SP FUNCTIONs
coexist with UDFs.
Can now CREATE and DROP FUNCTIONs. Invoking yet to come...
Docs/sp-implemented.txt:
Updated with info about CASCADE/RESTICT and METHOD, and some answers to questions.
include/mysqld_error.h:
New error message for misuse of RETURN.
mysql-test/install_test_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
mysql-test/r/sp.result:
New test for creating and dropping FUNCTIONS.
mysql-test/t/sp.test:
New test for creating and dropping FUNCTIONS.
scripts/mysql_install_db.sh:
Added enum field to mysql.proc to distinguish between FUNCTION and PROCEDURE.
sql/lex.h:
De-UDFed some symbol names, as they are now used for SPs as well.
Added RETURN_SYM.
sql/share/czech/errmsg.txt:
New error message for misuse of RETURN.
sql/share/danish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/dutch/errmsg.txt:
New error message for misuse of RETURN.
sql/share/english/errmsg.txt:
New error message for misuse of RETURN.
sql/share/estonian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/french/errmsg.txt:
New error message for misuse of RETURN.
sql/share/german/errmsg.txt:
New error message for misuse of RETURN.
sql/share/greek/errmsg.txt:
New error message for misuse of RETURN.
sql/share/hungarian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/italian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/japanese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/korean/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian-ny/errmsg.txt:
New error message for misuse of RETURN.
sql/share/norwegian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/polish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/portuguese/errmsg.txt:
New error message for misuse of RETURN.
sql/share/romanian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/russian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/serbian/errmsg.txt:
New error message for misuse of RETURN.
sql/share/slovak/errmsg.txt:
New error message for misuse of RETURN.
sql/share/spanish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/swedish/errmsg.txt:
New error message for misuse of RETURN.
sql/share/ukrainian/errmsg.txt:
New error message for misuse of RETURN.
sql/sp.cc:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp.h:
Major rehack to accomodate FUNCTIONs, and to make it easier to add
future in-memory cache of prepared SPs.
sql/sp_head.cc:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sp_head.h:
Now creates FUNCTIONs too. (And got rid of some unnecessary Item_string use.)
sql/sql_lex.h:
New stored FUNCTION commands.
sql/sql_parse.cc:
Added FUNCTION support ("drop" merged with the old UDF code), and made some
additional changes for better error handling (following the sp.cc rehacking).
sql/sql_yacc.yy:
Some former UDF specific symbols renamed.
Added CREATE FUNCTION parsing.
DROP FUNCTION had to be partly merged with the old UDF code, because of the similar
syntax.
RETURN statement added, but still a no-op.
2003-02-21 17:37:05 +01:00
|
|
|
List<bp_t> m_backpatch; // Instructions needing backpatching
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
int
|
|
|
|
execute(THD *thd);
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
}; // class sp_head : public Sql_alloc
|
|
|
|
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
//
|
|
|
|
// "Instructions"...
|
|
|
|
//
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
class sp_instr : public Sql_alloc
|
|
|
|
{
|
|
|
|
sp_instr(const sp_instr &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
uint marked;
|
2004-05-26 13:28:35 +02:00
|
|
|
Item *free_list; // My Items
|
2004-08-02 18:05:31 +02:00
|
|
|
uint m_ip; // My index
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_pcontext *m_ctx; // My parse context
|
2004-05-26 13:28:35 +02:00
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
// Should give each a name or type code for debugging purposes?
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr(uint ip, sp_pcontext *ctx)
|
|
|
|
:Sql_alloc(), marked(0), free_list(0), m_ip(ip), m_ctx(ctx)
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr()
|
2004-05-26 13:28:35 +02:00
|
|
|
{ free_items(free_list); }
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
// Execute this instrution. '*nextp' will be set to the index of the next
|
|
|
|
// instruction to execute. (For most instruction this will be the
|
|
|
|
// instruction following this one.)
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
// Returns 0 on success, non-zero if some error occured.
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual int execute(THD *thd, uint *nextp) = 0;
|
|
|
|
|
|
|
|
virtual void print(String *str) = 0;
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual void backpatch(uint dest, sp_pcontext *dst_ctx)
|
2004-08-02 18:05:31 +02:00
|
|
|
{}
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
marked= 1;
|
|
|
|
return m_ip+1;
|
|
|
|
}
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
|
2004-08-02 18:05:31 +02:00
|
|
|
{
|
|
|
|
return m_ip;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void opt_move(uint dst, List<sp_instr> *ibp)
|
|
|
|
{
|
|
|
|
m_ip= dst;
|
|
|
|
}
|
2002-12-11 14:24:29 +01:00
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
}; // class sp_instr : public Sql_alloc
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Call out to some prepared SQL statement.
|
|
|
|
//
|
|
|
|
class sp_instr_stmt : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_stmt(const sp_instr_stmt &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_stmt &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_stmt(uint ip, sp_pcontext *ctx)
|
|
|
|
: sp_instr(ip, ctx), m_lex(NULL)
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
{}
|
|
|
|
|
2003-06-29 18:15:17 +02:00
|
|
|
virtual ~sp_instr_stmt();
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
inline void
|
|
|
|
set_lex(LEX *lex)
|
|
|
|
{
|
2003-05-23 15:32:31 +02:00
|
|
|
m_lex= lex;
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline LEX *
|
|
|
|
get_lex()
|
|
|
|
{
|
2003-05-23 15:32:31 +02:00
|
|
|
return m_lex;
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
}
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
int exec_stmt(THD *thd, LEX *lex); // Execute a statement
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
private:
|
|
|
|
|
2003-05-23 15:32:31 +02:00
|
|
|
LEX *m_lex; // My own lex
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
}; // class sp_instr_stmt : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_set : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_set(const sp_instr_set &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_set &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-24 16:07:39 +02:00
|
|
|
TABLE_LIST *tables;
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_set(uint ip, sp_pcontext *ctx,
|
|
|
|
uint offset, Item *val, enum enum_field_types type)
|
|
|
|
: sp_instr(ip, ctx),
|
|
|
|
tables(NULL), m_offset(offset), m_value(val), m_type(type)
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_set()
|
|
|
|
{}
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
private:
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
uint m_offset; // Frame offset
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
Item *m_value;
|
|
|
|
enum enum_field_types m_type; // The declared type
|
|
|
|
|
|
|
|
}; // class sp_instr_set : public sp_instr
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2004-09-07 14:29:46 +02:00
|
|
|
/*
|
|
|
|
Set user variable instruction.
|
|
|
|
Used in functions and triggers to set user variables because we don't
|
|
|
|
want use sp_instr_stmt + "SET @a:=..." statement in this case since
|
|
|
|
latter will close all tables and thus will ruin execution of statement
|
|
|
|
calling/invoking this function/trigger.
|
|
|
|
*/
|
|
|
|
class sp_instr_set_user_var : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_set_user_var(const sp_instr_set_user_var &);
|
|
|
|
void operator=(sp_instr_set_user_var &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-09-08 22:46:01 +02:00
|
|
|
sp_instr_set_user_var(uint ip, sp_pcontext *ctx, LEX_STRING var, Item *val)
|
|
|
|
: sp_instr(ip, ctx), m_set_var_item(var, val)
|
2004-09-07 14:29:46 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_set_user_var()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
virtual void print(String *str);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Item_func_set_user_var m_set_var_item;
|
|
|
|
}; // class sp_instr_set_user_var : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Set NEW/OLD row field value instruction. Used in triggers.
|
|
|
|
*/
|
|
|
|
class sp_instr_set_trigger_field : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_set_trigger_field(const sp_instr_set_trigger_field &);
|
|
|
|
void operator=(sp_instr_set_trigger_field &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-09-08 22:46:01 +02:00
|
|
|
sp_instr_set_trigger_field(uint ip, sp_pcontext *ctx,
|
|
|
|
LEX_STRING field_name, Item *val)
|
|
|
|
: sp_instr(ip, ctx),
|
2004-09-07 14:29:46 +02:00
|
|
|
trigger_field(Item_trigger_field::NEW_ROW, field_name.str),
|
|
|
|
value(val)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_set_trigger_field()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
virtual void print(String *str);
|
|
|
|
|
|
|
|
bool setup_field(THD *thd, TABLE *table, enum trg_event_type event)
|
|
|
|
{
|
|
|
|
return trigger_field.setup_field(thd, table, event);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
|
|
|
|
Item_trigger_field trigger_field;
|
|
|
|
Item *value;
|
|
|
|
}; // class sp_instr_trigger_field : public sp_instr
|
|
|
|
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
class sp_instr_jump : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_jump(const sp_instr_jump &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_jump &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
uint m_dest; // Where we will go
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump(uint ip, sp_pcontext *ctx)
|
|
|
|
: sp_instr(ip, ctx), m_dest(0), m_optdest(0)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
|
|
|
|
: sp_instr(ip, ctx), m_dest(dest), m_optdest(0)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_jump()
|
|
|
|
{}
|
|
|
|
|
2003-03-05 19:45:17 +01:00
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start);
|
2004-08-02 18:05:31 +02:00
|
|
|
|
|
|
|
virtual void opt_move(uint dst, List<sp_instr> *ibp);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual void backpatch(uint dest, sp_pcontext *dst_ctx)
|
2002-12-11 14:24:29 +01:00
|
|
|
{
|
2004-04-05 17:01:19 +02:00
|
|
|
if (m_dest == 0) // Don't reset
|
|
|
|
m_dest= dest;
|
2002-12-11 14:24:29 +01:00
|
|
|
}
|
|
|
|
|
2002-12-12 13:14:23 +01:00
|
|
|
protected:
|
2002-12-11 14:24:29 +01:00
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
sp_instr *m_optdest; // Used during optimization
|
2002-12-11 14:24:29 +01:00
|
|
|
|
|
|
|
}; // class sp_instr_jump : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_jump_if : public sp_instr_jump
|
|
|
|
{
|
|
|
|
sp_instr_jump_if(const sp_instr_jump_if &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_jump_if &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-24 16:07:39 +02:00
|
|
|
TABLE_LIST *tables;
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump_if(uint ip, sp_pcontext *ctx, Item *i)
|
|
|
|
: sp_instr_jump(ip, ctx), tables(NULL), m_expr(i)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump_if(uint ip, sp_pcontext *ctx, Item *i, uint dest)
|
|
|
|
: sp_instr_jump(ip, ctx, dest), tables(NULL), m_expr(i)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_jump_if()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
|
2004-08-02 18:05:31 +02:00
|
|
|
{
|
|
|
|
return m_ip;
|
|
|
|
}
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
Item *m_expr; // The condition
|
|
|
|
|
|
|
|
}; // class sp_instr_jump_if : public sp_instr_jump
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_jump_if_not : public sp_instr_jump
|
|
|
|
{
|
|
|
|
sp_instr_jump_if_not(const sp_instr_jump_if_not &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_jump_if_not &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-24 16:07:39 +02:00
|
|
|
TABLE_LIST *tables;
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i)
|
|
|
|
: sp_instr_jump(ip, ctx), tables(NULL), m_expr(i)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i, uint dest)
|
|
|
|
: sp_instr_jump(ip, ctx, dest), tables(NULL), m_expr(i)
|
2002-12-11 14:24:29 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_jump_if_not()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
|
2004-08-02 18:05:31 +02:00
|
|
|
{
|
|
|
|
return m_ip;
|
|
|
|
}
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
Item *m_expr; // The condition
|
|
|
|
|
|
|
|
}; // class sp_instr_jump_if_not : public sp_instr_jump
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
class sp_instr_freturn : public sp_instr
|
2003-02-26 19:22:29 +01:00
|
|
|
{
|
2003-09-16 14:26:08 +02:00
|
|
|
sp_instr_freturn(const sp_instr_freturn &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_freturn &);
|
2003-02-26 19:22:29 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-24 16:07:39 +02:00
|
|
|
TABLE_LIST *tables;
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_freturn(uint ip, sp_pcontext *ctx,
|
|
|
|
Item *val, enum enum_field_types type)
|
|
|
|
: sp_instr(ip, ctx), tables(NULL), m_value(val), m_type(type)
|
2003-02-26 19:22:29 +01:00
|
|
|
{}
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
virtual ~sp_instr_freturn()
|
2003-02-26 19:22:29 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
marked= 1;
|
|
|
|
return UINT_MAX;
|
|
|
|
}
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
Item *m_value;
|
|
|
|
enum enum_field_types m_type;
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
}; // class sp_instr_freturn : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_hpush_jump : public sp_instr_jump
|
|
|
|
{
|
|
|
|
sp_instr_hpush_jump(const sp_instr_hpush_jump &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_hpush_jump &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, int htype, uint fp)
|
|
|
|
: sp_instr_jump(ip, ctx), m_type(htype), m_frame(fp)
|
2003-09-16 14:26:08 +02:00
|
|
|
{
|
|
|
|
m_handler= ip+1;
|
|
|
|
m_cond.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~sp_instr_hpush_jump()
|
|
|
|
{
|
|
|
|
m_cond.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
|
2004-08-02 18:05:31 +02:00
|
|
|
{
|
|
|
|
return m_ip;
|
|
|
|
}
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
inline void add_condition(struct sp_cond_type *cond)
|
|
|
|
{
|
|
|
|
m_cond.push_front(cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
int m_type; // Handler type
|
|
|
|
uint m_frame;
|
|
|
|
uint m_handler; // Location of handler
|
|
|
|
List<struct sp_cond_type> m_cond;
|
|
|
|
|
|
|
|
}; // class sp_instr_hpush_jump : public sp_instr_jump
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_hpop : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_hpop(const sp_instr_hpop &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_hpop &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_hpop(uint ip, sp_pcontext *ctx, uint count)
|
|
|
|
: sp_instr(ip, ctx), m_count(count)
|
2003-09-16 14:26:08 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_hpop()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual void backpatch(uint dest, sp_pcontext *dst_ctx);
|
2004-08-17 20:20:58 +02:00
|
|
|
|
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
if (m_count)
|
|
|
|
marked= 1;
|
|
|
|
return m_ip+1;
|
|
|
|
}
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_count;
|
|
|
|
|
|
|
|
}; // class sp_instr_hpop : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_hreturn : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_hreturn(const sp_instr_hreturn &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_hreturn &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_hreturn(uint ip, sp_pcontext *ctx, uint fp)
|
|
|
|
: sp_instr(ip, ctx), m_frame(fp)
|
2003-09-16 14:26:08 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_hreturn()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
marked= 1;
|
|
|
|
return UINT_MAX;
|
|
|
|
}
|
|
|
|
|
2003-09-16 14:26:08 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_frame;
|
|
|
|
|
|
|
|
}; // class sp_instr_hreturn : public sp_instr
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
class sp_instr_cpush : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_cpush(const sp_instr_cpush &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_cpush &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *lex)
|
|
|
|
: sp_instr(ip, ctx), m_lex(lex)
|
2003-10-10 16:57:21 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_cpush();
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
LEX *m_lex;
|
|
|
|
|
|
|
|
}; // class sp_instr_cpush : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_cpop : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_cpop(const sp_instr_cpop &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_cpop &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
|
|
|
|
: sp_instr(ip, ctx), m_count(count)
|
2003-10-10 16:57:21 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_cpop()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
virtual void backpatch(uint dest, sp_pcontext *dst_ctx);
|
2004-08-17 20:20:58 +02:00
|
|
|
|
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
if (m_count)
|
|
|
|
marked= 1;
|
|
|
|
return m_ip+1;
|
|
|
|
}
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_count;
|
|
|
|
|
|
|
|
}; // class sp_instr_cpop : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_copen : public sp_instr_stmt
|
|
|
|
{
|
|
|
|
sp_instr_copen(const sp_instr_copen &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_copen &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_copen(uint ip, sp_pcontext *ctx, uint c)
|
|
|
|
: sp_instr_stmt(ip, ctx), m_cursor(c)
|
2003-10-10 16:57:21 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_copen()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_cursor; // Stack index
|
|
|
|
|
|
|
|
}; // class sp_instr_copen : public sp_instr_stmt
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_cclose : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_cclose(const sp_instr_cclose &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_cclose &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_cclose(uint ip, sp_pcontext *ctx, uint c)
|
|
|
|
: sp_instr(ip, ctx), m_cursor(c)
|
2003-10-10 16:57:21 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_cclose()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_cursor;
|
|
|
|
|
|
|
|
}; // class sp_instr_cclose : public sp_instr
|
|
|
|
|
|
|
|
|
|
|
|
class sp_instr_cfetch : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_cfetch(const sp_instr_cfetch &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_cfetch &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_cfetch(uint ip, sp_pcontext *ctx, uint c)
|
|
|
|
: sp_instr(ip, ctx), m_cursor(c)
|
2003-10-10 16:57:21 +02:00
|
|
|
{
|
|
|
|
m_varlist.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~sp_instr_cfetch()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
virtual void print(String *str);
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
void add_to_varlist(struct sp_pvar *var)
|
|
|
|
{
|
|
|
|
m_varlist.push_back(var);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
uint m_cursor;
|
|
|
|
List<struct sp_pvar> m_varlist;
|
|
|
|
|
|
|
|
}; // class sp_instr_cfetch : public sp_instr
|
|
|
|
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
class sp_instr_error : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_error(const sp_instr_error &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_error &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-08-26 12:54:30 +02:00
|
|
|
sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
|
|
|
|
: sp_instr(ip, ctx), m_errcode(errcode)
|
2004-03-29 11:16:45 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_error()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
virtual void print(String *str);
|
|
|
|
|
2004-08-02 18:05:31 +02:00
|
|
|
virtual uint opt_mark(sp_head *sp)
|
|
|
|
{
|
|
|
|
marked= 1;
|
|
|
|
return UINT_MAX;
|
|
|
|
}
|
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
int m_errcode;
|
|
|
|
|
|
|
|
}; // class sp_instr_error : public sp_instr
|
|
|
|
|
|
|
|
|
2003-12-13 16:40:52 +01:00
|
|
|
struct st_sp_security_context
|
|
|
|
{
|
|
|
|
bool changed;
|
|
|
|
uint master_access;
|
|
|
|
uint db_access;
|
|
|
|
char *priv_user;
|
|
|
|
char priv_host[MAX_HOSTNAME];
|
|
|
|
char *user;
|
|
|
|
char *host;
|
|
|
|
char *ip;
|
|
|
|
};
|
|
|
|
|
2003-12-16 14:15:27 +01:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2003-12-13 16:40:52 +01:00
|
|
|
void
|
|
|
|
sp_change_security_context(THD *thd, sp_head *sp, st_sp_security_context *ctxp);
|
|
|
|
void
|
|
|
|
sp_restore_security_context(THD *thd, sp_head *sp,st_sp_security_context *ctxp);
|
2003-12-16 14:15:27 +01:00
|
|
|
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
|
2003-12-13 16:40:52 +01:00
|
|
|
|
Simplistic, experimental framework for Stored Procedures (SPs).
Implements creation and dropping of PROCEDUREs, IN, OUT, and INOUT parameters,
single-statement procedures, rudimentary multi-statement (begin-end) prodedures
(when the client can handle it), and local variables.
Missing most of the embedded SQL language, all attributes, FUNCTIONs, error handling,
reparses procedures at each call (no caching), etc, etc.
Certainly buggy too, but procedures can actually be created and called....
sql/Makefile.am:
Added SP files.
sql/item.cc:
Added this*_item() methods for Item_splocal. (SP local variable)
sql/item.h:
Added this*_item() methods for SPs in Item, and the new Item_splocal
class (SP local variable).
sql/lex.h:
Added new symbols for SPs. (Note: SPSET is temporary and will go away later.)
sql/sql_class.cc:
Initialize SP runtime context in THD.
sql/sql_class.h:
Add SP runtime context to THD.
sql/sql_lex.cc:
Init. buf pointer to beginning of command (needed by SPs).
Also initialize SP head and parse time context.
sql/sql_lex.h:
New SQLCOM_ tags for SPs, and added pointer to beginning of command pointer and
SP head and parse-time context to LEX.
sql/sql_parse.cc:
Added SQLCOM_CREATE_PROCEDURE, _CALL, _ALTER_PROCEDURE and _DROP_PROCEDURE cases.
(Still rudimentary and lacking proper error handling...)
sql/sql_yacc.yy:
Lots and lots of additions for SPs...
(Still even more missing, and no error messages...)
2002-12-08 19:59:22 +01:00
|
|
|
#endif /* _SP_HEAD_H_ */
|