Commit 3de0f8d3 authored by unknown's avatar unknown

Merging 4.1 into 5.0


BitKeeper/etc/gone:
  auto-union
BitKeeper/etc/logging_ok:
  auto-union
client/mysql.cc:
  Auto merged
configure.in:
  Auto merged
client/mysqltest.c:
  Auto merged
mysql-test/r/connect.result:
  Auto merged
mysql-test/r/insert.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/t/insert.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
scripts/mysql_install_db.sh:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/item.h:
  Auto merged
sql/lex.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/share/english/errmsg.txt:
  Auto merged
parents 49e6a2d0 d6303970
...@@ -6,6 +6,7 @@ FROM=$USER@mysql.com ...@@ -6,6 +6,7 @@ FROM=$USER@mysql.com
INTERNALS=internals@lists.mysql.com INTERNALS=internals@lists.mysql.com
DOCS=docs-commit@mysql.com DOCS=docs-commit@mysql.com
LIMIT=10000 LIMIT=10000
REPOV=5.0
if [ "$REAL_EMAIL" = "" ] if [ "$REAL_EMAIL" = "" ]
then then
...@@ -27,15 +28,15 @@ CHANGESET=`bk -R prs -r+ -h -d':I:' ChangeSet` ...@@ -27,15 +28,15 @@ CHANGESET=`bk -R prs -r+ -h -d':I:' ChangeSet`
echo "Commit successful, notifying developers at $TO" echo "Commit successful, notifying developers at $TO"
( (
cat <<EOF cat <<EOF
List-ID: <bk.mysql-4.1> List-ID: <bk.mysql-$REPOV>
From: $FROM From: $FROM
To: $TO To: $TO
Subject: bk commit - 4.1 tree ($CHANGESET) Subject: bk commit - $REPOV tree ($CHANGESET)
EOF EOF
bk changes -v -r+ bk changes -v -r+
bk cset -r+ -d bk cset -r+ -d
) | head -n $LIMIT | /usr/sbin/sendmail -t ) | /usr/sbin/sendmail -t
#++ #++
# internals@ mail # internals@ mail
...@@ -43,13 +44,13 @@ EOF ...@@ -43,13 +44,13 @@ EOF
echo "Notifying internals list at $INTERNALS" echo "Notifying internals list at $INTERNALS"
( (
cat <<EOF cat <<EOF
List-ID: <bk.mysql-4.1> List-ID: <bk.mysql-$REPOV>
From: $FROM From: $FROM
To: $INTERNALS To: $INTERNALS
Subject: bk commit into 4.1 tree ($CHANGESET) Subject: bk commit into $REPOV tree ($CHANGESET)
Below is the list of changes that have just been committed into a local Below is the list of changes that have just been committed into a local
4.1 repository of $USER. When $USER does a push these changes will $REPOV repository of $USER. When $USER does a push these changes will
be propagated to the main repository and, within 24 hours after the be propagated to the main repository and, within 24 hours after the
push, to the public repository. push, to the public repository.
For information on how to access the public repository For information on how to access the public repository
...@@ -70,15 +71,15 @@ EOF ...@@ -70,15 +71,15 @@ EOF
echo "Notifying docs list at $DOCS" echo "Notifying docs list at $DOCS"
( (
cat <<EOF cat <<EOF
List-ID: <bk.mysql-4.1> List-ID: <bk.mysql-$REPOV>
From: $FROM From: $FROM
To: $DOCS To: $DOCS
Subject: bk commit - 4.1 tree (Manual) ($CHANGESET) Subject: bk commit - $REPOV tree (Manual) ($CHANGESET)
EOF EOF
bk changes -v -r+ bk changes -v -r+
bk cset -r+ -d bk cset -r+ -d
) | head -n $LIMIT | /usr/sbin/sendmail -t ) | /usr/sbin/sendmail -t
fi fi
else else
......
This diff is collapsed.
Stored Procedures implemented 2003-02-02:
Summary of Not Yet Implemented:
- FUNCTIONs
- Routine characteristics
- External languages
- Access control
- Prepared SP caching; SPs are fetched and reparsed at each call
- SQL-99 COMMIT (related to BEGIN/END)
- DECLARE CURSOR ...
- FOR-loops (as it requires cursors)
Summary of what's implemented:
- SQL PROCEDURES (CREATE/DROP)
- CALL
- DECLARE of local variables
- BEGIN/END, SET, CASE, IF, LOOP, WHILE, REPEAT, ITERATE, LEAVE
- SELECT INTO local variables
List of what's implemented:
- CREATE PROCEDURE name ( args ) body
No routine characteristics yet.
- ALTER PROCEDURE name ...
Is parsed, but a no-op (as there are no characteristics implemented yet).
CASCADE/RESTRICT is not implemented (and CASCADE probably will not be).
- DROP PROCEDURE name
CASCADE/RESTRICT is not implemented (and CASCADE probably will not be).
- CALL name (args)
OUT and INOUT parameters are only supported for local variables, and
therefore only useful when calling such procedures from within another
procedure.
Note: For the time being, when a procedure with OUT/INOUT parameter is
called, the out values are silently discarded. In the future, this
will either generate an error message, or it might even work to
call all procedures from the top-level.
- Procedure body:
- BEGIN/END
Is parsed, but not the real thing with (optional) transaction
control, it only serves as block syntax for multiple statements (and
local variable binding).
Note: Multiple statements requires a client that can send bodies
containing ";". This is handled in the CLI clients mysql and
mysqltest with the "delimiter" command. Changing the end-of-query
delimiter ";" to for instance "|" allows
- SET of local variables
Implemented as part of the pre-existing SET syntax. This allows an
extended syntax of "SET a=x, b=y, ..." where different variable types
(SP local and global) can be mixed. This also allows combinations
of local variables and some options that only make sense for
global/system variables; in that case the options are accepted but
ignored.
- The flow control constructs: CASE, IF, LOOP, WHILE, ITERATE and LEAVE
are fully implemented.
- SELECT ... INTO local variables (as well as global session variables)
is implemented. (Note: This is not SQL-99 feature, but common in other
databases.)
Open questions:
- What is the expected result when creating a procedure with a name that
already exists? An error or overwrite?
- Do PROCEDUREs and FUNCTIONs share namespace or not? I think not, but the
we need to flag the type in the mysql.proc table and the name alone is
not a unique key any more, or, we have separate tables.
(Unfortunately, mysql.func is already taken. Use "sfunc" and maybe even
rename "proc" into "sproc" while we still can, for consistency?)
- SQL-99 variables and parameters are typed. For the present we don't do
any type checking, since this is the way MySQL works. I still don't know
if we should keep it this way, or implement type checking.
...@@ -104,6 +104,7 @@ extern "C" { ...@@ -104,6 +104,7 @@ extern "C" {
#include "completion_hash.h" #include "completion_hash.h"
#define PROMPT_CHAR '\\' #define PROMPT_CHAR '\\'
#define DEFAULT_DELIMITER ';'
typedef struct st_status typedef struct st_status
{ {
...@@ -155,6 +156,7 @@ static char pager[FN_REFLEN], outfile[FN_REFLEN]; ...@@ -155,6 +156,7 @@ static char pager[FN_REFLEN], outfile[FN_REFLEN];
static FILE *PAGER, *OUTFILE; static FILE *PAGER, *OUTFILE;
static MEM_ROOT hash_mem_root; static MEM_ROOT hash_mem_root;
static uint prompt_counter; static uint prompt_counter;
static char delimiter= DEFAULT_DELIMITER;
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
...@@ -181,7 +183,7 @@ static int com_quit(String *str,char*), ...@@ -181,7 +183,7 @@ static int com_quit(String *str,char*),
com_use(String *str,char*), com_source(String *str, char*), com_use(String *str,char*), com_source(String *str, char*),
com_rehash(String *str, char*), com_tee(String *str, char*), com_rehash(String *str, char*), com_tee(String *str, char*),
com_notee(String *str, char*), com_notee(String *str, char*),
com_prompt(String *str, char*); com_prompt(String *str, char*), com_delimiter(String *str, char*);
#ifdef USE_POPEN #ifdef USE_POPEN
static int com_nopager(String *str, char*), com_pager(String *str, char*), static int com_nopager(String *str, char*), com_pager(String *str, char*),
...@@ -249,7 +251,8 @@ static COMMANDS commands[] = { ...@@ -249,7 +251,8 @@ static COMMANDS commands[] = {
"Set outfile [to_outfile]. Append everything into given outfile." }, "Set outfile [to_outfile]. Append everything into given outfile." },
{ "use", 'u', com_use, 1, { "use", 'u', com_use, 1,
"Use another database. Takes database name as argument." }, "Use another database. Takes database name as argument." },
{ "delimiter", 'd', com_delimiter, 1,
"Set query delimiter. " },
/* Get bash-like expansion for some commands */ /* Get bash-like expansion for some commands */
{ "create table", 0, 0, 0, ""}, { "create table", 0, 0, 0, ""},
{ "create database", 0, 0, 0, ""}, { "create database", 0, 0, 0, ""},
...@@ -918,7 +921,7 @@ static COMMANDS *find_command (char *name,char cmd_char) ...@@ -918,7 +921,7 @@ static COMMANDS *find_command (char *name,char cmd_char)
{ {
while (my_isspace(system_charset_info,*name)) while (my_isspace(system_charset_info,*name))
name++; name++;
if (strchr(name,';') || strstr(name,"\\g")) if (strchr(name, delimiter) || strstr(name,"\\g"))
return ((COMMANDS *) 0); return ((COMMANDS *) 0);
if ((end=strcont(name," \t"))) if ((end=strcont(name," \t")))
{ {
...@@ -996,7 +999,7 @@ static bool add_line(String &buffer,char *line,char *in_string, ...@@ -996,7 +999,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
return 1; // Quit return 1; // Quit
if (com->takes_params) if (com->takes_params)
{ {
for (pos++ ; *pos && *pos != ';' ; pos++) ; // Remove parameters for (pos++ ; *pos && *pos != delimiter; pos++) ; // Remove parameters
if (!*pos) if (!*pos)
pos--; pos--;
} }
...@@ -1012,7 +1015,7 @@ static bool add_line(String &buffer,char *line,char *in_string, ...@@ -1012,7 +1015,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
continue; continue;
} }
} }
else if (!*ml_comment && inchar == ';' && !*in_string) else if (!*ml_comment && inchar == delimiter && !*in_string)
{ // ';' is end of command { // ';' is end of command
if (out != line) if (out != line)
buffer.append(line,(uint) (out-line)); // Add this line buffer.append(line,(uint) (out-line)); // Add this line
...@@ -1529,7 +1532,7 @@ com_help(String *buffer __attribute__((unused)), ...@@ -1529,7 +1532,7 @@ com_help(String *buffer __attribute__((unused)),
for (i = 0; commands[i].name; i++) for (i = 0; commands[i].name; i++)
{ {
if (commands[i].func) if (commands[i].func)
tee_fprintf(stdout, "%s\t(\\%c)\t%s\n", commands[i].name, tee_fprintf(stdout, "%-10s(\\%c)\t%s\n", commands[i].name,
commands[i].cmd_char, commands[i].doc); commands[i].cmd_char, commands[i].doc);
} }
} }
...@@ -2366,6 +2369,37 @@ static int com_source(String *buffer, char *line) ...@@ -2366,6 +2369,37 @@ static int com_source(String *buffer, char *line)
return error; return error;
} }
/* ARGSUSED */
static int
com_delimiter(String *buffer __attribute__((unused)), char *line)
{
char *tmp;
char buff[256];
if (strlen(line)> 255)
{
put_info("'DELIMITER' command was too long.", INFO_ERROR);
return 0;
}
bzero(buff, sizeof(buff));
strmov(buff, line);
tmp= get_arg(buff, 0);
if (!tmp || !*tmp)
{
put_info("DELIMITER must be followed by a 'delimiter' char", INFO_ERROR);
return 0;
}
if (strlen(tmp)> 1)
{
put_info("Argument must be one char", INFO_ERROR);
return 0;
}
delimiter= *tmp;
return 0;
}
/* ARGSUSED */ /* ARGSUSED */
static int static int
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
#define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */ #define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */
#define DEFAULT_DELIMITER ';'
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC}; OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC};
...@@ -123,6 +124,8 @@ static int block_stack[BLOCK_STACK_DEPTH]; ...@@ -123,6 +124,8 @@ static int block_stack[BLOCK_STACK_DEPTH];
static int block_ok_stack[BLOCK_STACK_DEPTH]; static int block_ok_stack[BLOCK_STACK_DEPTH];
static uint global_expected_errno[MAX_EXPECTED_ERRORS], global_expected_errors; static uint global_expected_errno[MAX_EXPECTED_ERRORS], global_expected_errors;
static char delimiter= DEFAULT_DELIMITER;
DYNAMIC_ARRAY q_lines; DYNAMIC_ARRAY q_lines;
typedef struct typedef struct
...@@ -197,7 +200,7 @@ Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER, ...@@ -197,7 +200,7 @@ Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_WAIT_FOR_SLAVE_TO_STOP, Q_WAIT_FOR_SLAVE_TO_STOP,
Q_REQUIRE_VERSION, Q_REQUIRE_VERSION,
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_DELIMITER,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */ Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND Q_COMMENT_WITH_COMMAND
...@@ -260,6 +263,7 @@ const char *command_names[]= ...@@ -260,6 +263,7 @@ const char *command_names[]=
"disable_warnings", "disable_warnings",
"enable_info", "enable_info",
"diable_info", "diable_info",
"delimiter",
0 0
}; };
...@@ -1529,6 +1533,16 @@ int do_while(struct st_query* q) ...@@ -1529,6 +1533,16 @@ int do_while(struct st_query* q)
return 0; return 0;
} }
int do_delimiter(char *p)
{
while (*p && my_isspace(system_charset_info,*p))
p++;
if (!*p)
die("Missing delimiter character\n");
delimiter=*p;
return 0;
}
int safe_copy_unescape(char* dest, char* src, int size) int safe_copy_unescape(char* dest, char* src, int size)
{ {
...@@ -1608,7 +1622,7 @@ int read_line(char* buf, int size) ...@@ -1608,7 +1622,7 @@ int read_line(char* buf, int size)
switch(state) { switch(state) {
case R_NORMAL: case R_NORMAL:
/* Only accept '{' in the beginning of a line */ /* Only accept '{' in the beginning of a line */
if (c == ';') if (c == delimiter)
{ {
*p = 0; *p = 0;
return 0; return 0;
...@@ -1648,7 +1662,7 @@ int read_line(char* buf, int size) ...@@ -1648,7 +1662,7 @@ int read_line(char* buf, int size)
*buf = 0; *buf = 0;
return 0; return 0;
} }
else if (c == ';' || c == '{') else if (c == delimiter || c == '{')
{ {
*p = 0; *p = 0;
return 0; return 0;
...@@ -1668,7 +1682,7 @@ int read_line(char* buf, int size) ...@@ -1668,7 +1682,7 @@ int read_line(char* buf, int size)
state = R_ESC_SLASH_Q1; state = R_ESC_SLASH_Q1;
break; break;
case R_ESC_Q_Q1: case R_ESC_Q_Q1:
if (c == ';') if (c == delimiter)
{ {
*p = 0; *p = 0;
return 0; return 0;
...@@ -1689,7 +1703,7 @@ int read_line(char* buf, int size) ...@@ -1689,7 +1703,7 @@ int read_line(char* buf, int size)
state = R_ESC_SLASH_Q2; state = R_ESC_SLASH_Q2;
break; break;
case R_ESC_Q_Q2: case R_ESC_Q_Q2:
if (c == ';') if (c == delimiter)
{ {
*p = 0; *p = 0;
return 0; return 0;
...@@ -2535,6 +2549,9 @@ int main(int argc, char** argv) ...@@ -2535,6 +2549,9 @@ int main(int argc, char** argv)
do_sync_with_master2(""); do_sync_with_master2("");
break; break;
} }
case Q_DELIMITER:
do_delimiter(q->first_argument);
break;
case Q_COMMENT: /* Ignore row */ case Q_COMMENT: /* Ignore row */
case Q_COMMENT_WITH_COMMAND: case Q_COMMENT_WITH_COMMAND:
case Q_PING: case Q_PING:
......
...@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. ...@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc) AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line! # The Docs Makefile.am parses this line!
AM_INIT_AUTOMAKE(mysql, 4.1.0-alpha) AM_INIT_AUTOMAKE(mysql, 5.0.0-alpha)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10 PROTOCOL_VERSION=10
......
...@@ -266,4 +266,15 @@ ...@@ -266,4 +266,15 @@
#define ER_SELECT_REDUCED 1247 #define ER_SELECT_REDUCED 1247
#define ER_TABLENAME_NOT_ALLOWED_HERE 1248 #define ER_TABLENAME_NOT_ALLOWED_HERE 1248
#define ER_NOT_SUPPORTED_AUTH_MODE 1249 #define ER_NOT_SUPPORTED_AUTH_MODE 1249
#define ER_ERROR_MESSAGES 250 #define ER_SP_NO_RECURSIVE_CREATE 1250
#define ER_SP_ALREADY_EXISTS 1251
#define ER_SP_DOES_NOT_EXIST 1252
#define ER_SP_DROP_FAILED 1253
#define ER_SP_STORE_FAILED 1254
#define ER_SP_LILABEL_MISMATCH 1255
#define ER_SP_LABEL_REDEFINE 1256
#define ER_SP_LABEL_MISMATCH 1257
#define ER_SP_UNINIT_VAR 1258
#define ER_SP_BADSELECT 1259
#define ER_ERROR_MESSAGES 260
...@@ -55,7 +55,8 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \ ...@@ -55,7 +55,8 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \ sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \ unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc spatial.cc gstream.cc sql_help.cc \
sp_head.cc sp_pcontext.cc sp.cc
EXTRA_DIST = lib_vio.c EXTRA_DIST = lib_vio.c
......
...@@ -69,6 +69,7 @@ c_t="" c_c="" ...@@ -69,6 +69,7 @@ c_t="" c_c=""
c_hl="" c_hl="" c_hl="" c_hl=""
c_hc="" c_hc="" c_hc="" c_hc=""
c_clr="" c_clr="" c_clr="" c_clr=""
c_p=""
# Check for old tables # Check for old tables
if test ! -f $mdata/db.frm if test ! -f $mdata/db.frm
...@@ -246,6 +247,16 @@ then ...@@ -246,6 +247,16 @@ then
c_hc="$c_hc comment='categories of help topics';" c_hc="$c_hc comment='categories of help topics';"
fi fi
if test ! -f $mdata/proc.frm
then
c_p="$c_p CREATE TABLE proc ("
c_p="$c_p name char(64) binary DEFAULT '' NOT NULL,"
c_p="$c_p body blob DEFAULT '' NOT NULL,"
c_p="$c_p PRIMARY KEY (name)"
c_p="$c_p )"
c_p="$c_p comment='Stored Procedures';"
fi
mysqld_boot=" $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \ mysqld_boot=" $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \
--basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $EXTRA_ARG" --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $EXTRA_ARG"
echo "running $mysqld_boot" echo "running $mysqld_boot"
...@@ -270,6 +281,9 @@ $c_c ...@@ -270,6 +281,9 @@ $c_c
$c_hl $c_hl
$c_hc $c_hc
$c_clr $c_clr
$c_p
END_OF_DATA END_OF_DATA
then then
exit 0 exit 0
......
...@@ -7,6 +7,7 @@ help_category ...@@ -7,6 +7,7 @@ help_category
help_relation help_relation
help_topic help_topic
host host
proc
tables_priv tables_priv
user user
show tables; show tables;
...@@ -22,6 +23,7 @@ help_category ...@@ -22,6 +23,7 @@ help_category
help_relation help_relation
help_topic help_topic
host host
proc
tables_priv tables_priv
user user
show tables; show tables;
...@@ -37,6 +39,7 @@ help_category ...@@ -37,6 +39,7 @@ help_category
help_relation help_relation
help_topic help_topic
host host
proc
tables_priv tables_priv
user user
show tables; show tables;
......
...@@ -64,3 +64,16 @@ use test_$1; ...@@ -64,3 +64,16 @@ use test_$1;
create table t1 (c int); create table t1 (c int);
insert into test_$1.t1 set test_$1.t1.c = '1'; insert into test_$1.t1 set test_$1.t1.c = '1';
drop database test_$1; drop database test_$1;
use test;
drop table if exists t1,t2,t3;
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
select count(*) from t2;
count(*)
500
insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3;
select count(*) from t2;
count(*)
25500
drop table if exists t1,t2,t3;
use test;
drop table if exists t1;
create table t1 (
id char(16) not null,
data int not null
);
create procedure foo42()
insert into test.t1 values ("foo", 42);
create procedure bar(x char(16), y int)
insert into test.t1 values (x, y);
create procedure two(x1 char(16), x2 char(16), y int)
begin
insert into test.t1 values (x1, y);
insert into test.t1 values (x2, y);
end;
create procedure locset(x char(16), y int)
begin
declare z1, z2 int;
set z1 = y;
set z2 = z1+2;
insert into test.t1 values (x, z2);
end;
create procedure mixset(x char(16), y int)
begin
declare z int;
set @z = y, z = 666, max_join_size = 100;
insert into test.t1 values (x, z);
end;
create procedure zip(x char(16), y int)
begin
declare z int;
call zap(y, z);
call bar(x, z);
end;
create procedure zap(x int, out y int)
begin
declare z int;
set z = x+1, y = z;
end;
create procedure iotest(x1 char(16), x2 char(16), y int)
begin
call inc2(x2, y);
insert into test.t1 values (x1, y);
end;
create procedure inc2(x char(16), y int)
begin
call inc(y);
insert into test.t1 values (x, y);
end;
create procedure inc(inout io int)
set io = io + 1;
create procedure cbv1()
begin
declare y int;
set y = 3;
call cbv2(y+1, y);
insert into test.t1 values ("cbv1", y);
end;
create procedure cbv2(y1 int, inout y2 int)
begin
set y2 = 4711;
insert into test.t1 values ("cbv2", y1);
end;
create procedure a0(x int)
while x do
set x = x-1;
insert into test.t1 values ("a0", x);
end while;
create procedure a(x int)
while x > 0 do
set x = x-1;
insert into test.t1 values ("a", x);
end while;
create procedure b(x int)
repeat
insert into test.t1 values (repeat("b",3), x);
set x = x-1;
until x = 0 end repeat;
create procedure b2(x int)
repeat(select 1 into outfile 'b2');
insert into test.t1 values (repeat("b2",3), x);
set x = x-1;
until x = 0 end repeat;
drop procedure b2;
create procedure b3(x int)
repeat
select * from test.t1; # No INTO!
insert into test.t1 values (repeat("b3",3), x);
set x = x-1;
until x = 0 end repeat;
SELECT in a stored procedure must have INTO
create procedure c(x int)
hmm: while x > 0 do
insert into test.t1 values ("c", x);
set x = x-1;
iterate hmm;
insert into test.t1 values ("x", x);
end while hmm;
create procedure d(x int)
hmm: while x > 0 do
insert into test.t1 values ("d", x);
set x = x-1;
leave hmm;
insert into test.t1 values ("x", x);
end while hmm;
create procedure e(x int)
foo: loop
if x = 0 then
leave foo;
end if;
insert into test.t1 values ("e", x);
set x = x-1;
end loop foo;
create procedure f(x int)
if x < 0 then
insert into test.t1 values ("f", 0);
elseif x = 0 then
insert into test.t1 values ("f", 1);
else
insert into test.t1 values ("f", 2);
end if;
create procedure g(x int)
case
when x < 0 then
insert into test.t1 values ("g", 0);
when x = 0 then
insert into test.t1 values ("g", 1);
else
insert into test.t1 values ("g", 2);
end case;
create procedure h(x int)
case x
when 0 then
insert into test.t1 values ("h0", x);
when 1 then
insert into test.t1 values ("h1", x);
else
insert into test.t1 values ("h?", x);
end case;
create procedure into_test(x char(16), y int)
begin
insert into test.t1 values (x, y);
select id,data into x,y from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end;
create procedure into_test2(x char(16), y int)
begin
insert into test.t1 values (x, y);
select id,data into x,@z from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end;
call foo42();
select * from t1;
id data
foo 42
delete from t1;
call bar("bar", 666);
select * from t1;
id data
bar 666
delete from t1;
call two("one", "two", 3);
select * from t1;
id data
one 3
two 3
delete from t1;
call locset("locset", 19);
select * from t1;
id data
locset 21
delete from t1;
call mixset("mixset", 19);
show variables like 'max_join_size';
Variable_name Value
max_join_size 100
select id,data,@z from t1;
id data @z
mixset 666 19
delete from t1;
call zip("zip", 99);
select * from t1;
id data
zip 100
delete from t1;
call iotest("io1", "io2", 1);
select * from t1;
id data
io2 2
io1 1
delete from t1;
call cbv1();
select * from t1;
id data
cbv2 4
cbv1 4711
delete from t1;
call a0(3);
select * from t1;
id data
a0 2
a0 1
a0 0
delete from t1;
call a(3);
select * from t1;
id data
a 2
a 1
a 0
delete from t1;
call b(3);
select * from t1;
id data
bbb 3
bbb 2
bbb 1
delete from t1;
call c(3);
select * from t1;
id data
c 3
c 2
c 1
delete from t1;
call d(3);
select * from t1;
id data
d 3
delete from t1;
call e(3);
select * from t1;
id data
e 3
e 2
e 1
delete from t1;
call f(-2);
call f(0);
call f(4);
select * from t1;
id data
f 0
f 1
f 2
delete from t1;
call g(-42);
call g(0);
call g(1);
select * from t1;
id data
g 0
g 1
g 2
delete from t1;
call h(0);
call h(1);
call h(17);
select * from t1;
id data
h0 0
h1 1
h? 17
delete from t1;
call into_test("into", 100);
select * from t1;
id data
into 100
into2 102
delete from t1;
call into_test2("into", 100);
select id,data,@z from t1;
id data @z
into 100 100
into2 102 100
delete from t1;
drop procedure foo42;
drop procedure bar;
drop procedure two;
drop procedure locset;
drop procedure mixset;
drop procedure zip;
drop procedure zap;
drop procedure iotest;
drop procedure inc2;
drop procedure inc;
drop procedure cbv1;
drop procedure cbv2;
drop procedure a0;
drop procedure a;
drop procedure b;
drop procedure c;
drop procedure d;
drop procedure e;
drop procedure f;
drop procedure g;
drop procedure h;
drop procedure into_test;
drop procedure into_test2;
drop table t1;
...@@ -593,7 +593,6 @@ x ...@@ -593,7 +593,6 @@ x
3 3
3 3
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
You can't specify target table 't1' for update in FROM clause
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
select * from t1; select * from t1;
x x
...@@ -601,6 +600,8 @@ x ...@@ -601,6 +600,8 @@ x
2 2
3 3
3 3
11
11
0 0
drop table t1, t2, t3; drop table t1, t2, t3;
CREATE TABLE t1 (x int not null, y int, primary key (x)); CREATE TABLE t1 (x int not null, y int, primary key (x));
......
...@@ -65,3 +65,34 @@ use test_$1; ...@@ -65,3 +65,34 @@ use test_$1;
create table t1 (c int); create table t1 (c int);
insert into test_$1.t1 set test_$1.t1.c = '1'; insert into test_$1.t1 set test_$1.t1.c = '1';
drop database test_$1; drop database test_$1;
use test;
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
disable_query_log;
let $1 = 100;
while ($1)
{
let $2 = 5;
eval insert into t1(t) values ('$1');
while ($2)
{
eval insert into t2(id2,t) values ($1,'$2');
let $3 = 10;
while ($3)
{
eval insert into t3(id3,t) values ($1,'$2');
dec $3;
}
dec $2;
}
dec $1;
}
enable_query_log;
select count(*) from t2;
insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3;
select count(*) from t2;
drop table if exists t1,t2,t3;
#
# Basic stored PROCEDURE tests
#
#
use test;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (
id char(16) not null,
data int not null
);
# Single statement, no params.
create procedure foo42()
insert into test.t1 values ("foo", 42);
# Single statement, two IN params.
create procedure bar(x char(16), y int)
insert into test.t1 values (x, y);
# Now for multiple statements...
delimiter |;
# Two statements.
create procedure two(x1 char(16), x2 char(16), y int)
begin
insert into test.t1 values (x1, y);
insert into test.t1 values (x2, y);
end|
# Simple test of local variables and SET.
create procedure locset(x char(16), y int)
begin
declare z1, z2 int;
set z1 = y;
set z2 = z1+2;
insert into test.t1 values (x, z2);
end|
# The peculiar (non-standard) mixture of variables types in SET.
create procedure mixset(x char(16), y int)
begin
declare z int;
set @z = y, z = 666, max_join_size = 100;
insert into test.t1 values (x, z);
end|
# Multiple CALL statements, one with OUT parameter.
create procedure zip(x char(16), y int)
begin
declare z int;
call zap(y, z);
call bar(x, z);
end|
# SET local variables and OUT parameter.
create procedure zap(x int, out y int)
begin
declare z int;
set z = x+1, y = z;
end|
# INOUT test
create procedure iotest(x1 char(16), x2 char(16), y int)
begin
call inc2(x2, y);
insert into test.t1 values (x1, y);
end|
create procedure inc2(x char(16), y int)
begin
call inc(y);
insert into test.t1 values (x, y);
end|
create procedure inc(inout io int)
set io = io + 1|
# Call-by-value test
# The expected result is:
# ("cbv2", 4)
# ("cbv1", 4711)
create procedure cbv1()
begin
declare y int;
set y = 3;
call cbv2(y+1, y);
insert into test.t1 values ("cbv1", y);
end|
create procedure cbv2(y1 int, inout y2 int)
begin
set y2 = 4711;
insert into test.t1 values ("cbv2", y1);
end|
# Minimal tests of the flow control construts
# Just test on 'x'...
create procedure a0(x int)
while x do
set x = x-1;
insert into test.t1 values ("a0", x);
end while|
# The same, but with a more traditional test.
create procedure a(x int)
while x > 0 do
set x = x-1;
insert into test.t1 values ("a", x);
end while|
# REPEAT
create procedure b(x int)
repeat
insert into test.t1 values (repeat("b",3), x);
set x = x-1;
until x = 0 end repeat|
# Check that repeat isn't parsed the wrong way
create procedure b2(x int)
repeat(select 1 into outfile 'b2');
insert into test.t1 values (repeat("b2",3), x);
set x = x-1;
until x = 0 end repeat|
# We don't actually want to call it.
drop procedure b2|
# Btw, this should generate an error
--error 1259
create procedure b3(x int)
repeat
select * from test.t1; # No INTO!
insert into test.t1 values (repeat("b3",3), x);
set x = x-1;
until x = 0 end repeat|
# Labelled WHILE with ITERATE (pointless really)
create procedure c(x int)
hmm: while x > 0 do
insert into test.t1 values ("c", x);
set x = x-1;
iterate hmm;
insert into test.t1 values ("x", x);
end while hmm|
# Labelled WHILE with LEAVE
create procedure d(x int)
hmm: while x > 0 do
insert into test.t1 values ("d", x);
set x = x-1;
leave hmm;
insert into test.t1 values ("x", x);
end while hmm|
# LOOP, with simple IF statement
create procedure e(x int)
foo: loop
if x = 0 then
leave foo;
end if;
insert into test.t1 values ("e", x);
set x = x-1;
end loop foo|
# A full IF statement
create procedure f(x int)
if x < 0 then
insert into test.t1 values ("f", 0);
elseif x = 0 then
insert into test.t1 values ("f", 1);
else
insert into test.t1 values ("f", 2);
end if|
# This form of CASE is really just syntactic sugar for IF-ELSEIF-...
create procedure g(x int)
case
when x < 0 then
insert into test.t1 values ("g", 0);
when x = 0 then
insert into test.t1 values ("g", 1);
else
insert into test.t1 values ("g", 2);
end case|
# The "simple CASE"
create procedure h(x int)
case x
when 0 then
insert into test.t1 values ("h0", x);
when 1 then
insert into test.t1 values ("h1", x);
else
insert into test.t1 values ("h?", x);
end case|
create procedure into_test(x char(16), y int)
begin
insert into test.t1 values (x, y);
select id,data into x,y from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
# Test INTO with a mix of local and global variables
create procedure into_test2(x char(16), y int)
begin
insert into test.t1 values (x, y);
select id,data into x,@z from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
delimiter ;|
# Now, the CALL tests...
call foo42();
select * from t1;
delete from t1;
call bar("bar", 666);
select * from t1;
delete from t1;
call two("one", "two", 3);
select * from t1;
delete from t1;
call locset("locset", 19);
select * from t1;
delete from t1;
call mixset("mixset", 19);
show variables like 'max_join_size';
select id,data,@z from t1;
delete from t1;
call zip("zip", 99);
select * from t1;
delete from t1;
call iotest("io1", "io2", 1);
select * from t1;
delete from t1;
call cbv1();
select * from t1;
delete from t1;
call a0(3);
select * from t1;
delete from t1;
call a(3);
select * from t1;
delete from t1;
call b(3);
select * from t1;
delete from t1;
call c(3);
select * from t1;
delete from t1;
call d(3);
select * from t1;
delete from t1;
call e(3);
select * from t1;
delete from t1;
call f(-2);
call f(0);
call f(4);
select * from t1;
delete from t1;
call g(-42);
call g(0);
call g(1);
select * from t1;
delete from t1;
call h(0);
call h(1);
call h(17);
select * from t1;
delete from t1;
call into_test("into", 100);
select * from t1;
delete from t1;
call into_test2("into", 100);
select id,data,@z from t1;
delete from t1;
drop procedure foo42;
drop procedure bar;
drop procedure two;
drop procedure locset;
drop procedure mixset;
drop procedure zip;
drop procedure zap;
drop procedure iotest;
drop procedure inc2;
drop procedure inc;
drop procedure cbv1;
drop procedure cbv2;
drop procedure a0;
drop procedure a;
drop procedure b;
drop procedure c;
drop procedure d;
drop procedure e;
drop procedure f;
drop procedure g;
drop procedure h;
drop procedure into_test;
drop procedure into_test2;
drop table t1;
...@@ -343,7 +343,6 @@ INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); ...@@ -343,7 +343,6 @@ INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
-- error 1093
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
-- sleep 1 -- sleep 1
......
...@@ -306,6 +306,18 @@ then ...@@ -306,6 +306,18 @@ then
c_c="$c_c comment='Column privileges';" c_c="$c_c comment='Column privileges';"
fi fi
if test ! -f $mdata/proc.frm
then
echo "Preparing proc table"
c_p="$c_p CREATE TABLE proc ("
c_p="$c_p name char(64) binary DEFAULT '' NOT NULL,"
c_p="$c_p body blob DEFAULT '' NOT NULL,"
c_p="$c_p PRIMARY KEY (name)"
c_p="$c_p )"
c_p="$c_p comment='Stored Procedures';"
fi
echo "Installing all prepared tables" echo "Installing all prepared tables"
if ( if (
cat << END_OF_DATA cat << END_OF_DATA
...@@ -324,6 +336,7 @@ $i_f ...@@ -324,6 +336,7 @@ $i_f
$c_t $c_t
$c_c $c_c
$c_p
END_OF_DATA END_OF_DATA
cat fill_help_tables.sql cat fill_help_tables.sql
) | eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \ ) | eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \
......
...@@ -57,7 +57,8 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ ...@@ -57,7 +57,8 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
lex.h lex_symbol.h sql_acl.h sql_crypt.h \ lex.h lex_symbol.h sql_acl.h sql_crypt.h \
log_event.h mini_client.h sql_repl.h slave.h \ log_event.h mini_client.h sql_repl.h slave.h \
stacktrace.h sql_sort.h sql_cache.h set_var.h \ stacktrace.h sql_sort.h sql_cache.h set_var.h \
spatial.h gstream.h spatial.h gstream.h sp_head.h sp_pcontext.h \
sp_rcontext.h sp.h
mysqld_SOURCES = sql_lex.cc sql_handler.cc \ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
item.cc item_sum.cc item_buff.cc item_func.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \
item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
...@@ -85,7 +86,8 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ ...@@ -85,7 +86,8 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
slave.cc sql_repl.cc sql_union.cc sql_derived.cc \ slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
mini_client.cc mini_client_errors.c \ mini_client.cc mini_client_errors.c \
stacktrace.c repl_failsafe.h repl_failsafe.cc sql_olap.cc\ stacktrace.c repl_failsafe.h repl_failsafe.cc sql_olap.cc\
gstream.cc spatial.cc sql_help.cc gstream.cc spatial.cc sql_help.cc \
sp_head.cc sp_pcontext.cc sp.cc
gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include <m_ctype.h> #include <m_ctype.h>
#include "my_dir.h" #include "my_dir.h"
#include "sp_rcontext.h"
/***************************************************************************** /*****************************************************************************
** Item functions ** Item functions
...@@ -166,6 +167,24 @@ CHARSET_INFO * Item::thd_charset() const ...@@ -166,6 +167,24 @@ CHARSET_INFO * Item::thd_charset() const
return current_thd->variables.thd_charset; return current_thd->variables.thd_charset;
} }
Item *
Item_splocal::this_item()
{
THD *thd= current_thd;
return thd->spcont->get_item(m_offset);
}
Item *
Item_splocal::this_const_item() const
{
THD *thd= current_thd;
return thd->spcont->get_item(m_offset);
}
Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
{ {
set_field(f); set_field(f);
......
...@@ -111,6 +111,8 @@ public: ...@@ -111,6 +111,8 @@ public:
CHARSET_INFO *charset() const { return str_value.charset(); }; CHARSET_INFO *charset() const { return str_value.charset(); };
void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); } void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
virtual void set_outer_resolving() {} virtual void set_outer_resolving() {}
virtual Item *this_item() { return this; } /* For SPs mostly. */
virtual Item *this_const_item() const { return const_cast<Item*>(this); } /* For SPs mostly. */
// Row emulation // Row emulation
virtual uint cols() { return 1; } virtual uint cols() { return 1; }
...@@ -124,6 +126,57 @@ public: ...@@ -124,6 +126,57 @@ public:
}; };
// A local SP variable (incl. parameters), used in runtime
class Item_splocal : public Item
{
private:
uint m_offset;
public:
Item_splocal(uint offset)
: m_offset(offset)
{}
Item *this_item();
Item *this_const_item() const;
inline uint get_offset()
{
return m_offset;
}
// Abstract methods inherited from Item. Just defer the call to
// the item in the frame
inline enum Type type() const
{
return this_const_item()->type();
}
inline double val()
{
return this_item()->val();
}
inline longlong val_int()
{
return this_item()->val_int();
}
inline String *val_str(String *sp)
{
return this_item()->val_str(sp);
}
inline void make_field(Send_field *field)
{
this_item()->make_field(field);
}
};
class st_select_lex; class st_select_lex;
class Item_ident :public Item class Item_ident :public Item
{ {
......
...@@ -60,6 +60,7 @@ static SYMBOL symbols[] = { ...@@ -60,6 +60,7 @@ static SYMBOL symbols[] = {
{ "AS", SYM(AS),0,0}, { "AS", SYM(AS),0,0},
{ "ASC", SYM(ASC),0,0}, { "ASC", SYM(ASC),0,0},
{ "ASCII", SYM(ASCII_SYM),0,0}, { "ASCII", SYM(ASCII_SYM),0,0},
{ "ASENSITIVE", SYM(ASENSITIVE_SYM),0,0},
{ "AVG", SYM(AVG_SYM),0,0}, { "AVG", SYM(AVG_SYM),0,0},
{ "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0},
{ "AUTO_INCREMENT", SYM(AUTO_INC),0,0}, { "AUTO_INCREMENT", SYM(AUTO_INC),0,0},
...@@ -80,6 +81,7 @@ static SYMBOL symbols[] = { ...@@ -80,6 +81,7 @@ static SYMBOL symbols[] = {
{ "BY", SYM(BY),0,0}, { "BY", SYM(BY),0,0},
{ "BYTE", SYM(BYTE_SYM), 0, 0}, { "BYTE", SYM(BYTE_SYM), 0, 0},
{ "CACHE", SYM(CACHE_SYM),0,0}, { "CACHE", SYM(CACHE_SYM),0,0},
{ "CALL", SYM(CALL_SYM),0,0},
{ "CASCADE", SYM(CASCADE),0,0}, { "CASCADE", SYM(CASCADE),0,0},
{ "CASE", SYM(CASE_SYM),0,0}, { "CASE", SYM(CASE_SYM),0,0},
{ "CHAR", SYM(CHAR_SYM),0,0}, { "CHAR", SYM(CHAR_SYM),0,0},
...@@ -107,6 +109,7 @@ static SYMBOL symbols[] = { ...@@ -107,6 +109,7 @@ static SYMBOL symbols[] = {
{ "CURRENT_DATE", SYM(CURDATE),0,0}, { "CURRENT_DATE", SYM(CURDATE),0,0},
{ "CURRENT_TIME", SYM(CURTIME),0,0}, { "CURRENT_TIME", SYM(CURTIME),0,0},
{ "CURRENT_TIMESTAMP", SYM(NOW_SYM),0,0}, { "CURRENT_TIMESTAMP", SYM(NOW_SYM),0,0},
{ "CURSOR", SYM(CURSOR_SYM),0,0},
{ "DATA", SYM(DATA_SYM),0,0}, { "DATA", SYM(DATA_SYM),0,0},
{ "DATABASE", SYM(DATABASE),0,0}, { "DATABASE", SYM(DATABASE),0,0},
{ "DATABASES", SYM(DATABASES),0,0}, { "DATABASES", SYM(DATABASES),0,0},
...@@ -118,6 +121,7 @@ static SYMBOL symbols[] = { ...@@ -118,6 +121,7 @@ static SYMBOL symbols[] = {
{ "DAY_SECOND", SYM(DAY_SECOND_SYM),0,0}, { "DAY_SECOND", SYM(DAY_SECOND_SYM),0,0},
{ "DEC", SYM(DECIMAL_SYM),0,0}, { "DEC", SYM(DECIMAL_SYM),0,0},
{ "DECIMAL", SYM(DECIMAL_SYM),0,0}, { "DECIMAL", SYM(DECIMAL_SYM),0,0},
{ "DECLARE", SYM(DECLARE_SYM),0,0},
{ "DES_KEY_FILE", SYM(DES_KEY_FILE),0,0}, { "DES_KEY_FILE", SYM(DES_KEY_FILE),0,0},
{ "DEFAULT", SYM(DEFAULT),0,0}, { "DEFAULT", SYM(DEFAULT),0,0},
{ "DELAYED", SYM(DELAYED_SYM),0,0}, { "DELAYED", SYM(DELAYED_SYM),0,0},
...@@ -140,6 +144,7 @@ static SYMBOL symbols[] = { ...@@ -140,6 +144,7 @@ static SYMBOL symbols[] = {
{ "ERRORS", SYM(ERRORS),0,0}, { "ERRORS", SYM(ERRORS),0,0},
{ "END", SYM(END),0,0}, { "END", SYM(END),0,0},
{ "ELSE", SYM(ELSE),0,0}, { "ELSE", SYM(ELSE),0,0},
{ "ELSEIF", SYM(ELSEIF_SYM),0,0},
{ "ESCAPE", SYM(ESCAPE_SYM),0,0}, { "ESCAPE", SYM(ESCAPE_SYM),0,0},
{ "ESCAPED", SYM(ESCAPED),0,0}, { "ESCAPED", SYM(ESCAPED),0,0},
{ "ENABLE", SYM(ENABLE_SYM),0,0}, { "ENABLE", SYM(ENABLE_SYM),0,0},
...@@ -195,6 +200,8 @@ static SYMBOL symbols[] = { ...@@ -195,6 +200,8 @@ static SYMBOL symbols[] = {
{ "INNER", SYM(INNER_SYM),0,0}, { "INNER", SYM(INNER_SYM),0,0},
{ "INNOBASE", SYM(INNOBASE_SYM),0,0}, { "INNOBASE", SYM(INNOBASE_SYM),0,0},
{ "INNODB", SYM(INNOBASE_SYM),0,0}, { "INNODB", SYM(INNOBASE_SYM),0,0},
{ "INOUT", SYM(INOUT_SYM),0,0},
{ "INSENSITIVE", SYM(INSENSITIVE_SYM),0,0},
{ "INSERT", SYM(INSERT),0,0}, { "INSERT", SYM(INSERT),0,0},
{ "INSERT_METHOD", SYM(INSERT_METHOD),0,0}, { "INSERT_METHOD", SYM(INSERT_METHOD),0,0},
{ "INT", SYM(INT_SYM),0,0}, { "INT", SYM(INT_SYM),0,0},
...@@ -212,12 +219,14 @@ static SYMBOL symbols[] = { ...@@ -212,12 +219,14 @@ static SYMBOL symbols[] = {
{ "ISOLATION", SYM(ISOLATION),0,0}, { "ISOLATION", SYM(ISOLATION),0,0},
{ "ISAM", SYM(ISAM_SYM),0,0}, { "ISAM", SYM(ISAM_SYM),0,0},
{ "ISSUER", SYM(ISSUER_SYM),0,0}, { "ISSUER", SYM(ISSUER_SYM),0,0},
{ "ITERATE", SYM(ITERATE_SYM),0,0},
{ "JOIN", SYM(JOIN_SYM),0,0}, { "JOIN", SYM(JOIN_SYM),0,0},
{ "KEY", SYM(KEY_SYM),0,0}, { "KEY", SYM(KEY_SYM),0,0},
{ "KEYS", SYM(KEYS),0,0}, { "KEYS", SYM(KEYS),0,0},
{ "KILL", SYM(KILL_SYM),0,0}, { "KILL", SYM(KILL_SYM),0,0},
{ "LAST", SYM(LAST_SYM),0,0}, { "LAST", SYM(LAST_SYM),0,0},
{ "LEADING", SYM(LEADING),0,0}, { "LEADING", SYM(LEADING),0,0},
{ "LEAVE", SYM(LEAVE_SYM),0,0},
{ "LEFT", SYM(LEFT),0,0}, { "LEFT", SYM(LEFT),0,0},
{ "LEVEL", SYM(LEVEL_SYM),0,0}, { "LEVEL", SYM(LEVEL_SYM),0,0},
{ "LIKE", SYM(LIKE),0,0}, { "LIKE", SYM(LIKE),0,0},
...@@ -233,6 +242,7 @@ static SYMBOL symbols[] = { ...@@ -233,6 +242,7 @@ static SYMBOL symbols[] = {
{ "LOGS", SYM(LOGS_SYM),0,0}, { "LOGS", SYM(LOGS_SYM),0,0},
{ "LONG", SYM(LONG_SYM),0,0}, { "LONG", SYM(LONG_SYM),0,0},
{ "LONGBLOB", SYM(LONGBLOB),0,0}, { "LONGBLOB", SYM(LONGBLOB),0,0},
{ "LOOP", SYM(LOOP_SYM),0,0},
{ "LONGTEXT", SYM(LONGTEXT),0,0}, { "LONGTEXT", SYM(LONGTEXT),0,0},
{ "LOW_PRIORITY", SYM(LOW_PRIORITY),0,0}, { "LOW_PRIORITY", SYM(LOW_PRIORITY),0,0},
{ "MASTER", SYM(MASTER_SYM),0,0}, { "MASTER", SYM(MASTER_SYM),0,0},
...@@ -285,6 +295,7 @@ static SYMBOL symbols[] = { ...@@ -285,6 +295,7 @@ static SYMBOL symbols[] = {
{ "OPTIONALLY", SYM(OPTIONALLY),0,0}, { "OPTIONALLY", SYM(OPTIONALLY),0,0},
{ "OR", SYM(OR),0,0}, { "OR", SYM(OR),0,0},
{ "ORDER", SYM(ORDER_SYM),0,0}, { "ORDER", SYM(ORDER_SYM),0,0},
{ "OUT", SYM(OUT_SYM),0,0},
{ "OUTER", SYM(OUTER),0,0}, { "OUTER", SYM(OUTER),0,0},
{ "OUTFILE", SYM(OUTFILE),0,0}, { "OUTFILE", SYM(OUTFILE),0,0},
{ "PACK_KEYS", SYM(PACK_KEYS_SYM),0,0}, { "PACK_KEYS", SYM(PACK_KEYS_SYM),0,0},
...@@ -314,6 +325,7 @@ static SYMBOL symbols[] = { ...@@ -314,6 +325,7 @@ static SYMBOL symbols[] = {
{ "REPAIR", SYM(REPAIR),0,0}, { "REPAIR", SYM(REPAIR),0,0},
{ "REPLACE", SYM(REPLACE),0,0}, { "REPLACE", SYM(REPLACE),0,0},
{ "REPLICATION", SYM(REPLICATION),0,0}, { "REPLICATION", SYM(REPLICATION),0,0},
{ "REPEAT", SYM(REPEAT_SYM),0,0},
{ "REPEATABLE", SYM(REPEATABLE_SYM),0,0}, { "REPEATABLE", SYM(REPEATABLE_SYM),0,0},
{ "REQUIRE", SYM(REQUIRE_SYM),0,0}, { "REQUIRE", SYM(REQUIRE_SYM),0,0},
{ "RESET", SYM(RESET_SYM),0,0}, { "RESET", SYM(RESET_SYM),0,0},
...@@ -331,6 +343,7 @@ static SYMBOL symbols[] = { ...@@ -331,6 +343,7 @@ static SYMBOL symbols[] = {
{ "RTREE", SYM(RTREE_SYM),0,0}, { "RTREE", SYM(RTREE_SYM),0,0},
{ "SECOND", SYM(SECOND_SYM),0,0}, { "SECOND", SYM(SECOND_SYM),0,0},
{ "SELECT", SYM(SELECT_SYM),0,0}, { "SELECT", SYM(SELECT_SYM),0,0},
{ "SENSITIVE", SYM(SENSITIVE_SYM),0,0},
{ "SERIAL", SYM(SERIAL_SYM),0,0}, { "SERIAL", SYM(SERIAL_SYM),0,0},
{ "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0}, { "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0},
{ "SESSION", SYM(SESSION_SYM),0,0}, { "SESSION", SYM(SESSION_SYM),0,0},
...@@ -345,6 +358,7 @@ static SYMBOL symbols[] = { ...@@ -345,6 +358,7 @@ static SYMBOL symbols[] = {
{ "SOME", SYM(ANY_SYM),0,0}, { "SOME", SYM(ANY_SYM),0,0},
{ "SONAME", SYM(UDF_SONAME_SYM),0,0}, { "SONAME", SYM(UDF_SONAME_SYM),0,0},
{ "SPATIAL", SYM(SPATIAL_SYM),0,0}, { "SPATIAL", SYM(SPATIAL_SYM),0,0},
{ "SPECIFIC", SYM(SPECIFIC_SYM),0,0},
{ "SQL_BIG_RESULT", SYM(SQL_BIG_RESULT),0,0}, { "SQL_BIG_RESULT", SYM(SQL_BIG_RESULT),0,0},
{ "SQL_BUFFER_RESULT", SYM(SQL_BUFFER_RESULT),0,0}, { "SQL_BUFFER_RESULT", SYM(SQL_BUFFER_RESULT),0,0},
{ "SQL_CACHE", SYM(SQL_CACHE_SYM), 0, 0}, { "SQL_CACHE", SYM(SQL_CACHE_SYM), 0, 0},
...@@ -387,6 +401,7 @@ static SYMBOL symbols[] = { ...@@ -387,6 +401,7 @@ static SYMBOL symbols[] = {
{ "UNIQUE", SYM(UNIQUE_SYM),0,0}, { "UNIQUE", SYM(UNIQUE_SYM),0,0},
{ "UNLOCK", SYM(UNLOCK_SYM),0,0}, { "UNLOCK", SYM(UNLOCK_SYM),0,0},
{ "UNSIGNED", SYM(UNSIGNED),0,0}, { "UNSIGNED", SYM(UNSIGNED),0,0},
{ "UNTIL", SYM(UNTIL_SYM),0,0},
{ "USE", SYM(USE_SYM),0,0}, { "USE", SYM(USE_SYM),0,0},
{ "USE_FRM", SYM(USE_FRM),0,0}, { "USE_FRM", SYM(USE_FRM),0,0},
{ "USING", SYM(USING),0,0}, { "USING", SYM(USING),0,0},
...@@ -405,6 +420,7 @@ static SYMBOL symbols[] = { ...@@ -405,6 +420,7 @@ static SYMBOL symbols[] = {
{ "WRITE", SYM(WRITE_SYM),0,0}, { "WRITE", SYM(WRITE_SYM),0,0},
{ "WHEN", SYM(WHEN_SYM),0,0}, { "WHEN", SYM(WHEN_SYM),0,0},
{ "WHERE", SYM(WHERE),0,0}, { "WHERE", SYM(WHERE),0,0},
{ "WHILE", SYM(WHILE_SYM),0,0},
{ "XOR", SYM(XOR),0,0}, { "XOR", SYM(XOR),0,0},
{ "X509", SYM(X509_SYM),0,0}, { "X509", SYM(X509_SYM),0,0},
{ "YEAR", SYM(YEAR_SYM),0,0}, { "YEAR", SYM(YEAR_SYM),0,0},
...@@ -555,7 +571,6 @@ static SYMBOL sql_functions[] = { ...@@ -555,7 +571,6 @@ static SYMBOL sql_functions[] = {
{ "RADIANS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_radians)}, { "RADIANS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_radians)},
{ "RAND", SYM(RAND),0,0}, { "RAND", SYM(RAND),0,0},
{ "RELEASE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_release_lock)}, { "RELEASE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_release_lock)},
{ "REPEAT", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_repeat)},
{ "REVERSE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_reverse)}, { "REVERSE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_reverse)},
{ "ROUND", SYM(ROUND),0,0}, { "ROUND", SYM(ROUND),0,0},
{ "RPAD", SYM(FUNC_ARG3),0,CREATE_FUNC(create_func_rpad)}, { "RPAD", SYM(FUNC_ARG3),0,CREATE_FUNC(create_func_rpad)},
......
...@@ -361,7 +361,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg); ...@@ -361,7 +361,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg);
extern "C" pthread_handler_decl(handle_bootstrap,arg); extern "C" pthread_handler_decl(handle_bootstrap,arg);
void end_thread(THD *thd,bool put_in_cache); void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache(); void flush_thread_cache();
void mysql_execute_command(THD *thd); int mysql_execute_command(THD *thd);
bool do_command(THD *thd); bool do_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length); char* packet, uint packet_length);
......
...@@ -259,4 +259,14 @@ v/* ...@@ -259,4 +259,14 @@ v/*
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -253,4 +253,14 @@ ...@@ -253,4 +253,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -261,4 +261,14 @@ ...@@ -261,4 +261,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias", "Every derived table must have it's own alias",
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -255,4 +255,14 @@ ...@@ -255,4 +255,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -260,4 +260,14 @@ ...@@ -260,4 +260,14 @@
"Für jede abgeleitete Tabelle muss ein eigener Alias angegeben werden.", "Für jede abgeleitete Tabelle muss ein eigener Alias angegeben werden.",
"Select %u wurde während der Optimierung reduziert.", "Select %u wurde während der Optimierung reduziert.",
"Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde kann nicht in %-.32s verwendet werden." "Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde kann nicht in %-.32s verwendet werden."
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -252,4 +252,14 @@ ...@@ -252,4 +252,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -252,4 +252,14 @@ ...@@ -252,4 +252,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -252,4 +252,14 @@ ...@@ -252,4 +252,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -252,4 +252,14 @@ ...@@ -252,4 +252,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -254,4 +254,14 @@ ...@@ -254,4 +254,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -254,4 +254,14 @@ ...@@ -254,4 +254,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -253,4 +253,14 @@ ...@@ -253,4 +253,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u ", "Select %u ",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -246,4 +246,14 @@ ...@@ -246,4 +246,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -258,4 +258,14 @@ ...@@ -258,4 +258,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -251,4 +251,14 @@ ...@@ -251,4 +251,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -250,4 +250,14 @@ ...@@ -250,4 +250,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
...@@ -255,4 +255,14 @@ ...@@ -255,4 +255,14 @@
"Every derived table must have it's own alias" "Every derived table must have it's own alias"
"Select %u was iii", "Select %u was iii",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" "Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
\ No newline at end of file "Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"SELECT in a stored procedure must have INTO"
/* 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 */
#include "mysql_priv.h"
#include "sp.h"
#include "sp_head.h"
// Finds the SP 'name'. Currently this always reads from the database
// and prepares (parse) it, but in the future it will first look in
// the in-memory cache for SPs. (And store newly prepared SPs there of
// course.)
sp_head *
sp_find_procedure(THD *thd, Item_string *iname)
{
DBUG_ENTER("sp_find_procedure");
extern int yyparse(void *thd);
LEX *tmplex;
TABLE *table;
TABLE_LIST tables;
const char *defstr;
String *name;
sp_head *sp = NULL;
name = iname->const_string();
DBUG_PRINT("enter", ("name: %*s", name->length(), name->c_ptr()));
memset(&tables, 0, sizeof(tables));
tables.db= (char*)"mysql";
tables.real_name= tables.alias= (char*)"proc";
if (! (table= open_ltable(thd, &tables, TL_READ)))
DBUG_RETURN(NULL);
if (table->file->index_read_idx(table->record[0], 0,
(byte*)name->c_ptr(), name->length(),
HA_READ_KEY_EXACT))
goto done;
if ((defstr= get_field(&thd->mem_root, table, 1)) == NULL)
goto done;
// QQ Set up our own mem_root here???
tmplex= lex_start(thd, (uchar*)defstr, strlen(defstr));
if (yyparse(thd) || thd->fatal_error || tmplex->sphead == NULL)
goto done; // Error
else
sp = tmplex->sphead;
done:
if (table)
close_thread_tables(thd);
DBUG_RETURN(sp);
}
int
sp_create_procedure(THD *thd, char *name, uint namelen, char *def, uint deflen)
{
DBUG_ENTER("sp_create_procedure");
DBUG_PRINT("enter", ("name: %*s def: %*s", namelen, name, deflen, def));
int ret= 0;
TABLE *table;
TABLE_LIST tables;
memset(&tables, 0, sizeof(tables));
tables.db= (char*)"mysql";
tables.real_name= tables.alias= (char*)"proc";
/* Allow creation of procedures even if we can't open proc table */
if (! (table= open_ltable(thd, &tables, TL_WRITE)))
{
ret= -1;
goto done;
}
restore_record(table, 2); // Get default values for fields
table->field[0]->store(name, namelen, default_charset_info);
table->field[1]->store(def, deflen, default_charset_info);
ret= table->file->write_row(table->record[0]);
done:
close_thread_tables(thd);
DBUG_RETURN(ret);
}
int
sp_drop_procedure(THD *thd, char *name, uint namelen)
{
DBUG_ENTER("sp_drop_procedure");
DBUG_PRINT("enter", ("name: %*s", namelen, name));
TABLE *table;
TABLE_LIST tables;
tables.db= (char *)"mysql";
tables.real_name= tables.alias= (char *)"proc";
if (! (table= open_ltable(thd, &tables, TL_WRITE)))
goto err;
if (! table->file->index_read_idx(table->record[0], 0,
(byte *)name, namelen,
HA_READ_KEY_EXACT))
{
int error;
if ((error= table->file->delete_row(table->record[0])))
table->file->print_error(error, MYF(0));
}
close_thread_tables(thd);
DBUG_RETURN(0);
err:
close_thread_tables(thd);
DBUG_RETURN(-1);
}
/* -*- 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_H_
#define _SP_H_
//
// Finds a stored procedure given its name. Returns NULL if not found.
//
sp_head *
sp_find_procedure(THD *thd, Item_string *name);
int
sp_create_procedure(THD *thd, char *name, uint namelen, char *def, uint deflen);
int
sp_drop_procedure(THD *thd, char *name, uint namelen);
#if 0
sp_head *
sp_find_function(THD *thd, Item_string *name);
int
sp_create_function(THD *thd, char *name, uint namelen, char *def, uint deflen);
int
sp_drop_function(THD *thd, char *name, uint namelen);
#endif
#endif /* _SP_H_ */
This diff is collapsed.
/* -*- 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>
struct sp_label;
class sp_instr;
class sp_head : public Sql_alloc
{
sp_head(const sp_head &); /* Prevent use of these */
void operator=(sp_head &);
public:
my_bool m_simple_case; // TRUE if parsing simple case, FALSE otherwise
List<Item_string> m_calls; // Called procedures.
List<char *> m_tables; // Used tables.
static void *operator new(size_t size)
{
return (void*) sql_alloc((uint) size);
}
static void operator delete(void *ptr, size_t size)
{
/* Empty */
}
sp_head(LEX_STRING *name, LEX* lex);
int
create(THD *thd);
int
execute(THD *thd);
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);
// Put the instruction on the backpatch list, associated with the label.
void
push_backpatch(sp_instr *, struct sp_label *);
// Update all instruction with this label in the backpatch list to
// the current position.
void
backpatch(struct sp_label *);
private:
Item_string *m_name;
Item_string *m_defstr;
LEX *m_call_lex; // The CALL's own lex
LEX m_lex; // Temp. store for the other lex
DYNAMIC_ARRAY m_instr; // The "instructions"
typedef struct
{
struct sp_label *lab;
sp_instr *instr;
} bp_t;
List<bp_t> m_backpatch; // Instructions needing backpaching
inline sp_instr *
get_instr(uint i)
{
sp_instr *in= NULL;
get_dynamic(&m_instr, (gptr)&in, i);
return in;
}
}; // class sp_head : public Sql_alloc
//
// "Instructions"...
//
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?
sp_instr(uint ip)
: Sql_alloc(), m_ip(ip)
{}
virtual ~sp_instr()
{}
// 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.)
// Returns 0 on success, non-zero if some error occured.
virtual int
execute(THD *thd, uint *nextp)
{ // Default is a no-op.
*nextp = m_ip+1; // Next instruction
return 0;
}
protected:
uint m_ip; // My index
}; // 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:
sp_instr_stmt(uint ip)
: sp_instr(ip)
{}
virtual ~sp_instr_stmt()
{}
virtual int execute(THD *thd, uint *nextp);
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:
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)
{}
virtual ~sp_instr_set()
{}
virtual int execute(THD *thd, uint *nextp);
private:
uint m_offset; // Frame offset
Item *m_value;
enum enum_field_types m_type; // The declared type
}; // class sp_instr_set : public sp_instr
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()
{}
virtual int execute(THD *thd, uint *nextp)
{
*nextp= m_dest;
return 0;
}
virtual void
set_destination(uint dest)
{
m_dest= dest;
}
protected:
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
#endif /* _SP_HEAD_H_ */
/* 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 */
#ifdef __GNUC__
#pragma implementation
#endif
#if defined(WIN32) || defined(__WIN__)
#undef SAFEMALLOC /* Problems with threads */
#endif
#include "mysql_priv.h"
#include "sp_pcontext.h"
#include "sp_head.h"
sp_pcontext::sp_pcontext()
: m_params(0), m_framesize(0), m_i(0), m_genlab(0)
{
m_pvar_size = 16;
m_pvar = (sp_pvar_t *)my_malloc(m_pvar_size * sizeof(sp_pvar_t), MYF(MY_WME));
if (m_pvar)
memset(m_pvar, 0, m_pvar_size * sizeof(sp_pvar_t));
m_label.empty();
}
void
sp_pcontext::grow()
{
uint sz = m_pvar_size + 8;
sp_pvar_t *a = (sp_pvar_t *)my_realloc((char *)m_pvar,
sz * sizeof(sp_pvar_t),
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
if (a)
{
m_pvar_size = sz;
m_pvar = a;
}
}
/* This does a linear search (from newer to older variables, in case
** we have shadowed names).
** It's possible to have a more efficient allocation and search method,
** but it might not be worth it. The typical number of parameters and
** variables will in most cases be low (a handfull).
** And this is only called during parsing.
*/
sp_pvar_t *
sp_pcontext::find_pvar(LEX_STRING *name)
{
String n(name->str, name->length, default_charset_info);
uint i = m_i;
while (i-- > 0)
{
if (stringcmp(&n, m_pvar[i].name->const_string()) == 0)
return m_pvar + i;
}
return NULL;
}
void
sp_pcontext::push(LEX_STRING *name, enum enum_field_types type,
sp_param_mode_t mode)
{
if (m_i >= m_pvar_size)
grow();
if (m_i < m_pvar_size)
{
if (m_i == m_framesize)
m_framesize += 1;
m_pvar[m_i].name= new Item_string(name->str, name->length,
default_charset_info);
m_pvar[m_i].type= type;
m_pvar[m_i].mode= mode;
m_pvar[m_i].offset= m_i;
m_pvar[m_i].isset= (mode == sp_param_out ? FALSE : TRUE);
m_i += 1;
}
}
sp_label_t *
sp_pcontext::push_label(char *name, uint ip)
{
sp_label_t *lab = (sp_label_t *)my_malloc(sizeof(sp_label_t), MYF(MY_WME));
if (lab)
{
lab->name= name;
lab->ip= ip;
m_label.push_front(lab);
}
return lab;
}
sp_label_t *
sp_pcontext::find_label(char *name)
{
List_iterator_fast<sp_label_t> li(m_label);
sp_label_t *lab;
while ((lab= li++))
if (strcasecmp(name, lab->name) == 0)
return lab;
return NULL;
}
/* -*- 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_PCONTEXT_H_
#define _SP_PCONTEXT_H_
#ifdef __GNUC__
#pragma interface /* gcc class implementation */
#endif
typedef enum
{
sp_param_in,
sp_param_out,
sp_param_inout
} sp_param_mode_t;
typedef struct
{
Item_string *name;
enum enum_field_types type;
sp_param_mode_t mode;
uint offset; // Offset in current frame
my_bool isset;
} sp_pvar_t;
typedef struct sp_label
{
char *name;
uint ip; // Instruction index
} sp_label_t;
class sp_pcontext : public Sql_alloc
{
sp_pcontext(const sp_pcontext &); /* Prevent use of these */
void operator=(sp_pcontext &);
public:
sp_pcontext();
inline uint
max_framesize()
{
return m_framesize;
}
inline uint
current_framesize()
{
return m_i;
}
inline uint
params()
{
return m_params;
}
// Set the number of parameters to the current esize
inline void
set_params()
{
m_params= m_i;
}
inline void
set_type(uint i, enum enum_field_types type)
{
if (i < m_i)
m_pvar[i].type= type;
}
inline void
set_isset(uint i, my_bool val)
{
if (i < m_i)
m_pvar[i].isset= val;
}
void
push(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode);
// Pop the last 'num' slots of the frame
inline void
pop(uint num = 1)
{
if (num < m_i)
m_i -= num;
}
// Find by name
sp_pvar_t *
find_pvar(LEX_STRING *name);
// Find by index
sp_pvar_t *
find_pvar(uint i)
{
if (i >= m_i)
return NULL;
return m_pvar+i;
}
sp_label_t *
push_label(char *name, uint ip);
sp_label_t *
find_label(char *name);
inline sp_label_t *
last_label()
{
return m_label.head();
}
inline sp_label_t *
pop_label()
{
return m_label.pop();
}
private:
uint m_params; // The number of parameters
uint m_framesize; // The maximum framesize
uint m_i; // The current index (during parsing)
sp_pvar_t *m_pvar;
uint m_pvar_size; // Current size of m_pvar.
void
grow();
List<sp_label_t> m_label; // The label list
uint m_genlab; // Gen. label counter
}; // class sp_pcontext : public Sql_alloc
#endif /* _SP_PCONTEXT_H_ */
/* -*- 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_RCONTEXT_H_
#define _SP_RCONTEXT_H_
class sp_rcontext : public Sql_alloc
{
sp_rcontext(const sp_rcontext &); /* Prevent use of these */
void operator=(sp_rcontext &);
public:
sp_rcontext(uint size)
: m_count(0), m_size(size)
{
m_frame = (Item **)sql_alloc(size * sizeof(Item*));
m_outs = (int *)sql_alloc(size * sizeof(int));
}
~sp_rcontext()
{
// Not needed?
//sql_element_free(m_frame);
}
inline void
push_item(Item *i)
{
if (m_count < m_size)
m_frame[m_count++] = i;
}
inline void
set_item(uint idx, Item *i)
{
if (idx < m_count)
m_frame[idx] = i;
}
inline Item *
get_item(uint idx)
{
return m_frame[idx];
}
inline void
set_oindex(uint idx, int oidx)
{
m_outs[idx] = oidx;
}
inline int
get_oindex(uint idx)
{
return m_outs[idx];
}
private:
uint m_count;
uint m_size;
Item **m_frame;
int *m_outs;
}; // class sp_rcontext : public Sql_alloc
#endif /* _SP_RCONTEXT_H_ */
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <io.h> #include <io.h>
#endif #endif
#include <mysys_err.h> #include <mysys_err.h>
#include <sp_rcontext.h>
/***************************************************************************** /*****************************************************************************
...@@ -80,7 +81,7 @@ extern "C" void free_user_var(user_var_entry *entry) ...@@ -80,7 +81,7 @@ extern "C" void free_user_var(user_var_entry *entry)
THD::THD():user_time(0), is_fatal_error(0), THD::THD():user_time(0), is_fatal_error(0),
last_insert_id_used(0), last_insert_id_used(0),
insert_id_used(0), rand_used(0), in_lock_tables(0), insert_id_used(0), rand_used(0), in_lock_tables(0),
global_read_lock(0), bootstrap(0) global_read_lock(0), bootstrap(0), spcont(NULL)
{ {
host=user=priv_user=db=query=ip=0; host=user=priv_user=db=query=ip=0;
host_or_ip="unknown ip"; host_or_ip="unknown ip";
...@@ -967,8 +968,9 @@ bool select_exists_subselect::send_data(List<Item> &items) ...@@ -967,8 +968,9 @@ bool select_exists_subselect::send_data(List<Item> &items)
int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{ {
List_iterator_fast<Item> li(list); List_iterator_fast<Item> li(list);
List_iterator_fast<LEX_STRING> gl(var_list); List_iterator_fast<my_var> gl(var_list);
Item *item; Item *item;
my_var *mv;
LEX_STRING *ls; LEX_STRING *ls;
if (var_list.elements != list.elements) if (var_list.elements != list.elements)
{ {
...@@ -978,19 +980,38 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) ...@@ -978,19 +980,38 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
unit=u; unit=u;
while ((item=li++)) while ((item=li++))
{ {
ls= gl++; mv=gl++;
Item_func_set_user_var *xx = new Item_func_set_user_var(*ls,item); ls= &mv->s;
xx->fix_fields(thd,(TABLE_LIST*) thd->lex.select_lex.table_list.first,&item); if (mv->local)
xx->fix_length_and_dec(); {
vars.push_back(xx); (void)local_vars.push_back(new Item_splocal(mv->offset));
}
else
{
Item_func_set_user_var *xx = new Item_func_set_user_var(*ls,item);
xx->fix_fields(thd,(TABLE_LIST*) thd->lex.select_lex.table_list.first,&item);
xx->fix_length_and_dec();
vars.push_back(xx);
}
} }
return 0; return 0;
} }
bool select_dumpvar::send_data(List<Item> &items) bool select_dumpvar::send_data(List<Item> &items)
{ {
List_iterator_fast<Item_func_set_user_var> li(vars); List_iterator_fast<Item_func_set_user_var> li(vars);
List_iterator_fast<Item_splocal> var_li(local_vars);
List_iterator_fast<my_var> my_li(var_list);
List_iterator_fast<Item> it(items);
Item_func_set_user_var *xx; Item_func_set_user_var *xx;
Item_splocal *yy;
Item *item;
my_var *zz;
DBUG_ENTER("send_data"); DBUG_ENTER("send_data");
if (unit->offset_limit_cnt)
{ // using limit offset,count
unit->offset_limit_cnt--;
DBUG_RETURN(0);
}
if (unit->offset_limit_cnt) if (unit->offset_limit_cnt)
{ // Using limit offset,count { // Using limit offset,count
...@@ -1002,8 +1023,21 @@ bool select_dumpvar::send_data(List<Item> &items) ...@@ -1002,8 +1023,21 @@ bool select_dumpvar::send_data(List<Item> &items)
my_error(ER_TOO_MANY_ROWS, MYF(0)); my_error(ER_TOO_MANY_ROWS, MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
while ((xx=li++)) while ((zz=my_li++) && (item=it++))
xx->update(); {
if (zz->local)
{
if ((yy=var_li++))
{
thd->spcont->set_item(yy->get_offset(), item);
}
}
else
{
if ((xx=li++))
xx->update();
}
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
class Query_log_event; class Query_log_event;
class Load_log_event; class Load_log_event;
class Slave_log_event; class Slave_log_event;
class sp_rcontext;
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE }; enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY }; enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY };
...@@ -551,6 +552,7 @@ public: ...@@ -551,6 +552,7 @@ public:
bool volatile killed; bool volatile killed;
bool prepare_command; bool prepare_command;
bool tmp_table_used; bool tmp_table_used;
sp_rcontext *spcont; // SP runtime context
/* /*
If we do a purge of binary logs, log index info of the threads If we do a purge of binary logs, log index info of the threads
...@@ -1018,13 +1020,22 @@ public: ...@@ -1018,13 +1020,22 @@ public:
bool send_eof(); bool send_eof();
}; };
class my_var : public Sql_alloc {
public:
LEX_STRING s;
bool local;
uint offset;
my_var (LEX_STRING& j, bool i, uint o) : s(j), local(i), offset(o) {}
~my_var() {}
};
class select_dumpvar :public select_result { class select_dumpvar :public select_result {
ha_rows row_count; ha_rows row_count;
public: public:
List<LEX_STRING> var_list; List<my_var> var_list;
List<Item_func_set_user_var> vars; List<Item_func_set_user_var> vars;
select_dumpvar(void) { var_list.empty(); vars.empty(); row_count=0;} List<Item_splocal> local_vars;
select_dumpvar(void) { var_list.empty(); local_vars.empty(); vars.empty(); row_count=0;}
~select_dumpvar() {} ~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_fields(List<Item> &list, uint flag) {return 0;} bool send_fields(List<Item> &list, uint flag) {return 0;}
......
...@@ -157,6 +157,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) ...@@ -157,6 +157,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
{ {
LEX *lex= &thd->lex; LEX *lex= &thd->lex;
lex->next_state=STATE_START; lex->next_state=STATE_START;
lex->buf= buf;
lex->end_of_query=(lex->ptr=buf)+length; lex->end_of_query=(lex->ptr=buf)+length;
lex->yylineno = 1; lex->yylineno = 1;
lex->select_lex.create_refs=lex->in_comment=0; lex->select_lex.create_refs=lex->in_comment=0;
...@@ -171,6 +172,8 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) ...@@ -171,6 +172,8 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
lex->yacc_yyss=lex->yacc_yyvs=0; lex->yacc_yyss=lex->yacc_yyvs=0;
lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE); lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE);
lex->sql_command=SQLCOM_END; lex->sql_command=SQLCOM_END;
lex->sphead= NULL;
lex->spcont= NULL;
return lex; return lex;
} }
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
class Table_ident; class Table_ident;
class sql_exchange; class sql_exchange;
class LEX_COLUMN; class LEX_COLUMN;
class sp_head;
class sp_instr;
class sp_pcontext;
/* /*
The following hack is needed because mysql_yacc.cc does not define The following hack is needed because mysql_yacc.cc does not define
...@@ -72,6 +75,8 @@ enum enum_sql_command { ...@@ -72,6 +75,8 @@ enum enum_sql_command {
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS, SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES, SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES,
SQLCOM_HELP, SQLCOM_HELP,
SQLCOM_CREATE_PROCEDURE, SQLCOM_CALL, SQLCOM_DROP_PROCEDURE,
SQLCOM_ALTER_PROCEDURE,
/* This should be the last !!! */ /* This should be the last !!! */
SQLCOM_END SQLCOM_END
...@@ -419,6 +424,7 @@ typedef struct st_lex ...@@ -419,6 +424,7 @@ typedef struct st_lex
SELECT_LEX_NODE *current_select; SELECT_LEX_NODE *current_select;
/* list of all SELECT_LEX */ /* list of all SELECT_LEX */
SELECT_LEX *all_selects_list; SELECT_LEX *all_selects_list;
uchar *buf; /* The beginning of string, used by SPs */
uchar *ptr,*tok_start,*tok_end,*end_of_query; uchar *ptr,*tok_start,*tok_end,*end_of_query;
char *length,*dec,*change,*name; char *length,*dec,*change,*name;
char *backup_dir; /* For RESTORE/BACKUP */ char *backup_dir; /* For RESTORE/BACKUP */
...@@ -477,6 +483,8 @@ typedef struct st_lex ...@@ -477,6 +483,8 @@ typedef struct st_lex
uint slave_thd_opt; uint slave_thd_opt;
CHARSET_INFO *charset; CHARSET_INFO *charset;
char *help_arg; char *help_arg;
sp_head *sphead;
sp_pcontext *spcont;
inline void uncacheable() inline void uncacheable()
{ {
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "ha_innodb.h" #include "ha_innodb.h"
#endif #endif
#include "sp_head.h"
#include "sp.h"
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
/* /*
Without SSL the handshake consists of one packet. This packet Without SSL the handshake consists of one packet. This packet
...@@ -1570,7 +1573,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) ...@@ -1570,7 +1573,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length)
** Execute command saved in thd and current_lex->sql_command ** Execute command saved in thd and current_lex->sql_command
****************************************************************************/ ****************************************************************************/
void int
mysql_execute_command(THD *thd) mysql_execute_command(THD *thd)
{ {
int res= 0; int res= 0;
...@@ -1602,7 +1605,7 @@ mysql_execute_command(THD *thd) ...@@ -1602,7 +1605,7 @@ mysql_execute_command(THD *thd)
given and the table list says the query should not be replicated given and the table list says the query should not be replicated
*/ */
if (table_rules_on && tables && !tables_ok(thd,tables)) if (table_rules_on && tables && !tables_ok(thd,tables))
DBUG_VOID_RETURN; DBUG_RETURN(0);
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
/* /*
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 This is a workaround to deal with the shortcoming in 3.23.44-3.23.46
...@@ -1637,7 +1640,7 @@ mysql_execute_command(THD *thd) ...@@ -1637,7 +1640,7 @@ mysql_execute_command(THD *thd)
{ {
if (res < 0 || thd->net.report_error) if (res < 0 || thd->net.report_error)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
DBUG_VOID_RETURN; DBUG_RETURN(res);
} }
} }
} }
...@@ -1650,7 +1653,7 @@ mysql_execute_command(THD *thd) ...@@ -1650,7 +1653,7 @@ mysql_execute_command(THD *thd)
!tables_ok(thd,tables)) !tables_ok(thd,tables))
#endif #endif
) )
DBUG_VOID_RETURN; DBUG_RETURN(0);
statistic_increment(com_stat[lex->sql_command],&LOCK_status); statistic_increment(com_stat[lex->sql_command],&LOCK_status);
switch (lex->sql_command) { switch (lex->sql_command) {
...@@ -1689,7 +1692,7 @@ mysql_execute_command(THD *thd) ...@@ -1689,7 +1692,7 @@ mysql_execute_command(THD *thd)
if (!(result= new select_send())) if (!(result= new select_send()))
{ {
send_error(thd, ER_OUT_OF_RESOURCES); send_error(thd, ER_OUT_OF_RESOURCES);
DBUG_VOID_RETURN; goto error;
} }
else else
thd->send_explain_fields(result); thd->send_explain_fields(result);
...@@ -1943,7 +1946,7 @@ mysql_execute_command(THD *thd) ...@@ -1943,7 +1946,7 @@ mysql_execute_command(THD *thd)
find_real_table_in_list(tables->next, tables->db, tables->real_name)) find_real_table_in_list(tables->next, tables->db, tables->real_name))
{ {
net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name);
DBUG_VOID_RETURN; DBUG_RETURN(-1);
} }
if (tables->next) if (tables->next)
{ {
...@@ -2024,7 +2027,7 @@ mysql_execute_command(THD *thd) ...@@ -2024,7 +2027,7 @@ mysql_execute_command(THD *thd)
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
break; goto error;
} }
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;
...@@ -2037,7 +2040,7 @@ mysql_execute_command(THD *thd) ...@@ -2037,7 +2040,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_ALTER_TABLE: case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS) #if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
break; goto error;
#else #else
{ {
ulong priv=0; ulong priv=0;
...@@ -2129,7 +2132,7 @@ mysql_execute_command(THD *thd) ...@@ -2129,7 +2132,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
...@@ -2142,7 +2145,7 @@ mysql_execute_command(THD *thd) ...@@ -2142,7 +2145,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_CREATE: case SQLCOM_SHOW_CREATE:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (check_db_used(thd, tables) || if (check_db_used(thd, tables) ||
...@@ -2214,7 +2217,7 @@ mysql_execute_command(THD *thd) ...@@ -2214,7 +2217,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
res= mysql_update(thd,tables, res= mysql_update(thd,tables,
select_lex->item_list, select_lex->item_list,
...@@ -2235,7 +2238,7 @@ mysql_execute_command(THD *thd) ...@@ -2235,7 +2238,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
{ {
const char *msg= 0; const char *msg= 0;
...@@ -2271,7 +2274,7 @@ mysql_execute_command(THD *thd) ...@@ -2271,7 +2274,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
res = mysql_insert(thd,tables,lex->field_list,lex->many_values, res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
select_lex->item_list, lex->value_list, select_lex->item_list, lex->value_list,
...@@ -2310,8 +2313,7 @@ mysql_execute_command(THD *thd) ...@@ -2310,8 +2313,7 @@ mysql_execute_command(THD *thd)
if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) if (find_real_table_in_list(tables->next, tables->db, tables->real_name))
{ {
net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); lex->select_lex.options |= OPTION_BUFFER_RESULT;
DBUG_VOID_RETURN;
} }
/* Skip first table, which is the table we are inserting in */ /* Skip first table, which is the table we are inserting in */
...@@ -2471,7 +2473,7 @@ mysql_execute_command(THD *thd) ...@@ -2471,7 +2473,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_DATABASES: case SQLCOM_SHOW_DATABASES:
#if defined(DONT_ALLOW_SHOW_COMMANDS) #if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
if ((specialflag & SPECIAL_SKIP_SHOW_DB) && if ((specialflag & SPECIAL_SKIP_SHOW_DB) &&
check_global_access(thd, SHOW_DB_ACL)) check_global_access(thd, SHOW_DB_ACL))
...@@ -2505,7 +2507,7 @@ mysql_execute_command(THD *thd) ...@@ -2505,7 +2507,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_LOGS: case SQLCOM_SHOW_LOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (grant_option && check_access(thd, FILE_ACL, any_db)) if (grant_option && check_access(thd, FILE_ACL, any_db))
...@@ -2518,7 +2520,7 @@ mysql_execute_command(THD *thd) ...@@ -2518,7 +2520,7 @@ mysql_execute_command(THD *thd)
/* FALL THROUGH */ /* FALL THROUGH */
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=select_lex->db ? select_lex->db : thd->db; char *db=select_lex->db ? select_lex->db : thd->db;
...@@ -2554,7 +2556,7 @@ mysql_execute_command(THD *thd) ...@@ -2554,7 +2556,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_FIELDS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=tables->db; char *db=tables->db;
...@@ -2579,7 +2581,7 @@ mysql_execute_command(THD *thd) ...@@ -2579,7 +2581,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_KEYS: case SQLCOM_SHOW_KEYS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=tables->db; char *db=tables->db;
...@@ -2949,16 +2951,113 @@ mysql_execute_command(THD *thd) ...@@ -2949,16 +2951,113 @@ mysql_execute_command(THD *thd)
res= -1; res= -1;
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
break; break;
case SQLCOM_CREATE_PROCEDURE:
if (!lex->sphead)
{
send_error(thd, ER_SP_NO_RECURSIVE_CREATE);
goto error;
}
else
{
res= lex->sphead->create(thd);
if (res != 0)
{
send_error(thd, ER_SP_ALREADY_EXISTS);
goto error;
}
send_ok(thd);
}
break;
case SQLCOM_CALL:
{
Item_string *s;
sp_head *sp;
s= (Item_string*)lex->value_list.head();
sp= sp_find_procedure(thd, s);
if (! sp)
{
send_error(thd, ER_SP_DOES_NOT_EXIST);
goto error;
}
else
{
// When executing substatements, they're assumed to send_error when
// it happens, but not to send_ok.
my_bool nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
res= sp->execute(thd);
thd->net.no_send_ok= nsok;
if (res == 0)
send_ok(thd);
else
goto error; // Substatement should already have sent error
}
}
break;
case SQLCOM_ALTER_PROCEDURE:
{
Item_string *s;
sp_head *sp;
s= (Item_string*)lex->value_list.head();
sp= sp_find_procedure(thd, s);
if (! sp)
{
send_error(thd, ER_SP_DOES_NOT_EXIST);
goto error;
}
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_procedure(thd, s);
if (! sp)
{
send_error(thd, ER_SP_DOES_NOT_EXIST);
goto error;
}
else
{
String *name = s->const_string();
res= sp_drop_procedure(thd, name->c_ptr(), name->length());
if (res != 0)
{
send_error(thd, ER_SP_DROP_FAILED);
goto error;
}
send_ok(thd);
}
}
break;
default: /* Impossible */ default: /* Impossible */
send_ok(thd); send_ok(thd);
break; break;
} }
thd->proc_info="query end"; // QQ thd->proc_info="query end"; // QQ
// We end up here if res == 0 and send_ok() has been done,
// or res != 0 and no send_error() has yet been done.
if (res < 0) if (res < 0)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
DBUG_RETURN(res);
error: error:
DBUG_VOID_RETURN; // We end up here if send_error() has already been done.
DBUG_RETURN(-1);
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment