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....
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>
|
|
|
|
|
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
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
Item_result
|
|
|
|
sp_map_result_type(enum enum_field_types type);
|
|
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
class sp_instr;
|
|
|
|
|
|
|
|
class sp_head : public Sql_alloc
|
|
|
|
{
|
|
|
|
sp_head(const sp_head &); /* Prevent use of these */
|
|
|
|
void operator=(sp_head &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
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
|
2002-12-17 10:01:52 +01:00
|
|
|
my_bool m_simple_case; // TRUE if parsing simple case, FALSE otherwise
|
2003-04-23 09:22:54 +02:00
|
|
|
my_bool m_multi_query; // TRUE if a procedure with SELECT(s)
|
|
|
|
uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value
|
2003-03-02 19:17:41 +01:00
|
|
|
#if 0
|
2003-04-27 17:35:54 +02:00
|
|
|
// QQ We're not using this at the moment.
|
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
|
2002-12-17 10:01:52 +01:00
|
|
|
|
2003-05-06 21:09:20 +05:00
|
|
|
sp_head(LEX_STRING *name, LEX *lex, LEX_STRING *comment, char suid);
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
int
|
|
|
|
create(THD *thd);
|
|
|
|
|
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....
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....
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
inline void
|
|
|
|
add_instr(sp_instr *i)
|
|
|
|
{
|
|
|
|
insert_dynamic(&m_instr, (gptr)&i);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint
|
|
|
|
instructions()
|
|
|
|
{
|
|
|
|
return m_instr.elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
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;
|
2003-02-21 17:37:05 +01:00
|
|
|
}
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
inline Item_result result()
|
|
|
|
{
|
|
|
|
return sp_map_result_type(m_returns);
|
|
|
|
}
|
|
|
|
|
2003-05-06 21:09:20 +05:00
|
|
|
void sp_set_info(char *creator, uint creatorlen,
|
|
|
|
longlong created, longlong modified,
|
|
|
|
bool suid, char *comment, uint commentlen)
|
|
|
|
{
|
|
|
|
m_creator= creator;
|
|
|
|
m_creatorlen= creatorlen;
|
|
|
|
m_created= created;
|
|
|
|
m_modified= modified;
|
|
|
|
m_comment.length= commentlen;
|
|
|
|
m_comment.str= comment;
|
|
|
|
m_suid= suid;
|
|
|
|
}
|
|
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
private:
|
|
|
|
|
2003-04-03 16:00:09 +02:00
|
|
|
LEX_STRING m_name;
|
|
|
|
LEX_STRING m_defstr;
|
2003-05-06 21:09:20 +05:00
|
|
|
LEX_STRING m_comment;
|
|
|
|
char *m_creator;
|
|
|
|
uint m_creatorlen;
|
|
|
|
longlong m_created;
|
|
|
|
longlong m_modified;
|
|
|
|
bool m_suid;
|
|
|
|
|
2003-03-02 19:17:41 +01:00
|
|
|
sp_pcontext *m_pcont; // Parse context
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
LEX m_lex; // Temp. store for the other lex
|
|
|
|
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;
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
inline sp_instr *
|
|
|
|
get_instr(uint i)
|
|
|
|
{
|
2003-04-02 20:42:28 +02:00
|
|
|
sp_instr *ip;
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
if (i < m_instr.elements)
|
2003-04-02 20:42:28 +02:00
|
|
|
get_dynamic(&m_instr, (gptr)&ip, i);
|
|
|
|
else
|
|
|
|
ip= NULL;
|
|
|
|
return ip;
|
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....
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....
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....
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:
|
|
|
|
|
|
|
|
// Should give each a name or type code for debugging purposes?
|
2002-12-11 14:24:29 +01:00
|
|
|
sp_instr(uint ip)
|
|
|
|
: Sql_alloc(), m_ip(ip)
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr()
|
|
|
|
{}
|
|
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
// Returns 0 on success, non-zero if some error occured.
|
|
|
|
virtual int
|
2002-12-11 14:24:29 +01:00
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
{ // Default is a no-op.
|
2002-12-11 14:24:29 +01:00
|
|
|
*nextp = m_ip+1; // Next instruction
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
uint m_ip; // My index
|
|
|
|
|
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....
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:
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
sp_instr_stmt(uint ip)
|
|
|
|
: sp_instr(ip)
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_stmt()
|
|
|
|
{}
|
|
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
|
|
|
|
inline void
|
|
|
|
set_lex(LEX *lex)
|
|
|
|
{
|
|
|
|
memcpy(&m_lex, lex, sizeof(LEX));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LEX *
|
|
|
|
get_lex()
|
|
|
|
{
|
|
|
|
return &m_lex;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
LEX m_lex; // My own lex
|
|
|
|
|
|
|
|
}; // 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:
|
|
|
|
|
2002-12-11 14:24:29 +01:00
|
|
|
sp_instr_set(uint ip, uint offset, Item *val, enum enum_field_types type)
|
|
|
|
: sp_instr(ip), 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....
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....
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....
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
|
|
|
|
|
|
|
class sp_instr_jump : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_jump(const sp_instr_jump &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_jump &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
sp_instr_jump(uint ip)
|
|
|
|
: sp_instr(ip)
|
|
|
|
{}
|
|
|
|
|
|
|
|
sp_instr_jump(uint ip, uint dest)
|
|
|
|
: sp_instr(ip), m_dest(dest)
|
|
|
|
{}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
virtual void
|
|
|
|
set_destination(uint dest)
|
|
|
|
{
|
|
|
|
m_dest= dest;
|
|
|
|
}
|
|
|
|
|
2002-12-12 13:14:23 +01:00
|
|
|
protected:
|
2002-12-11 14:24:29 +01:00
|
|
|
|
|
|
|
int m_dest; // Where we will go
|
|
|
|
|
|
|
|
}; // 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:
|
|
|
|
|
|
|
|
sp_instr_jump_if(uint ip, Item *i)
|
|
|
|
: sp_instr_jump(ip), m_expr(i)
|
|
|
|
{}
|
|
|
|
|
|
|
|
sp_instr_jump_if(uint ip, Item *i, uint dest)
|
|
|
|
: sp_instr_jump(ip, dest), m_expr(i)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_jump_if()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
sp_instr_jump_if_not(uint ip, Item *i)
|
|
|
|
: sp_instr_jump(ip), m_expr(i)
|
|
|
|
{}
|
|
|
|
|
|
|
|
sp_instr_jump_if_not(uint ip, Item *i, uint dest)
|
|
|
|
: sp_instr_jump(ip, dest), m_expr(i)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_jump_if_not()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Item *m_expr; // The condition
|
|
|
|
|
|
|
|
}; // class sp_instr_jump_if_not : public sp_instr_jump
|
|
|
|
|
2003-02-26 19:22:29 +01:00
|
|
|
|
|
|
|
class sp_instr_return : public sp_instr
|
|
|
|
{
|
|
|
|
sp_instr_return(const sp_instr_return &); /* Prevent use of these */
|
|
|
|
void operator=(sp_instr_return &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
sp_instr_return(uint ip, Item *val, enum enum_field_types type)
|
|
|
|
: sp_instr(ip), m_value(val), m_type(type)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~sp_instr_return()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int execute(THD *thd, uint *nextp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
Item *m_value;
|
|
|
|
enum enum_field_types m_type;
|
|
|
|
|
|
|
|
}; // class sp_instr_return : public sp_instr
|
|
|
|
|
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....
2002-12-08 19:59:22 +01:00
|
|
|
#endif /* _SP_HEAD_H_ */
|