mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03: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....
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include "ha_innodb.h"
|
||||
#endif
|
||||
|
||||
#include "sp_head.h"
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
/*
|
||||
Without SSL the handshake consists of one packet. This packet
|
||||
@@ -2739,6 +2741,84 @@ mysql_execute_command(THD *thd)
|
||||
res= -1;
|
||||
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
|
||||
break;
|
||||
case SQLCOM_CREATE_PROCEDURE:
|
||||
if (!lex->sphead)
|
||||
res= -1;
|
||||
else
|
||||
{
|
||||
res= lex->sphead->create(thd);
|
||||
if (res < 0)
|
||||
{
|
||||
// QQ Error!
|
||||
}
|
||||
send_ok(thd);
|
||||
}
|
||||
break;
|
||||
case SQLCOM_CALL:
|
||||
{
|
||||
Item_string *s;
|
||||
sp_head *sp;
|
||||
|
||||
s= (Item_string*)lex->value_list.head();
|
||||
sp= sp_find(thd, s);
|
||||
if (! sp)
|
||||
{
|
||||
// QQ Error!
|
||||
res= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
res= sp->execute(thd);
|
||||
if (res == 0)
|
||||
send_ok(thd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SQLCOM_ALTER_PROCEDURE:
|
||||
{
|
||||
Item_string *s;
|
||||
sp_head *sp;
|
||||
|
||||
s= (Item_string*)lex->value_list.head();
|
||||
sp= sp_find(thd, s);
|
||||
if (! sp)
|
||||
{
|
||||
// QQ Error!
|
||||
res= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* QQ This is an no-op right now, since we haven't
|
||||
put the characteristics in yet. */
|
||||
send_ok(thd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SQLCOM_DROP_PROCEDURE:
|
||||
{
|
||||
Item_string *s;
|
||||
sp_head *sp;
|
||||
|
||||
s = (Item_string*)lex->value_list.head();
|
||||
sp = sp_find(thd, s);
|
||||
if (! sp)
|
||||
{
|
||||
// QQ Error!
|
||||
res= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
String *name = s->const_string();
|
||||
|
||||
res= sp_drop(thd, name->c_ptr(), name->length());
|
||||
if (res < 0)
|
||||
{
|
||||
// QQ Error!
|
||||
}
|
||||
send_ok(thd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: /* Impossible */
|
||||
send_ok(thd);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user