Added DO command
Docs/manual.texi: ChangeLog sql/gen_lex_hash.cc: Safety fix
This commit is contained in:
parent
f8b4629cf7
commit
1808d80fb3
@ -3628,7 +3628,7 @@ Use of @code{REPLACE} instead of @code{DELETE} + @code{INSERT}.
|
||||
@xref{REPLACE, , @code{REPLACE}}.
|
||||
|
||||
@item
|
||||
The @code{FLUSH flush_option} statement.
|
||||
The @code{FLUSH}, @code{RESET} and @code{DO} statements.
|
||||
|
||||
@item
|
||||
The possibility to set variables in a statement with @code{:=}:
|
||||
@ -31993,6 +31993,9 @@ and @code{NULL} if the named lock didn't exist. The lock will not exist if
|
||||
it was never obtained by a call to @code{GET_LOCK()} or if it already has
|
||||
been released.
|
||||
|
||||
The @code{DO} statement is convinient to use with @code{RELEASE_LOCK()}.
|
||||
@xref{DO}.
|
||||
|
||||
@findex BENCHMARK()
|
||||
@item BENCHMARK(count,expr)
|
||||
The @code{BENCHMARK()} function executes the expression @code{expr}
|
||||
@ -32064,6 +32067,7 @@ facilitate replication testing.
|
||||
* TRUNCATE:: @code{TRUNCATE} Syntax
|
||||
* REPLACE:: @code{REPLACE} Syntax
|
||||
* LOAD DATA:: @code{LOAD DATA INFILE} Syntax
|
||||
* DO:: @code{DO} Syntax
|
||||
@end menu
|
||||
|
||||
@node SELECT, INSERT, Data Manipulation, Data Manipulation
|
||||
@ -32973,7 +32977,7 @@ The above makes it easy to check if @code{REPLACE} added or replaced a
|
||||
row.
|
||||
|
||||
|
||||
@node LOAD DATA, , REPLACE, Data Manipulation
|
||||
@node LOAD DATA, DO, REPLACE, Data Manipulation
|
||||
@subsection @code{LOAD DATA INFILE} Syntax
|
||||
|
||||
@findex LOAD DATA INFILE
|
||||
@ -33469,6 +33473,23 @@ For more information about the efficiency of @code{INSERT} versus
|
||||
@xref{Insert speed}.
|
||||
|
||||
|
||||
@node DO, , LOAD DATA, Data Manipulation
|
||||
@subsection @code{DO} Syntax
|
||||
|
||||
@findex DO
|
||||
|
||||
@example
|
||||
DO expression, [expression, ...]
|
||||
@end example
|
||||
|
||||
Execute the expression but don't return any results. This is a
|
||||
shorthand of @code{SELECT expression, expression}, but has the advantage
|
||||
that it's slightly faster when you don't care about the result.
|
||||
|
||||
This is mainly useful with functions that has side effects, like
|
||||
@code{RELEASE_LOCK}.
|
||||
|
||||
|
||||
@node Data Definition, Basic User Commands, Data Manipulation, Reference
|
||||
@section Data Definition: @code{CREATE}, @code{DROP}, @code{ALTER}
|
||||
|
||||
@ -46867,6 +46888,10 @@ not yet 100% confident in this code.
|
||||
@appendixsubsec Changes in release 3.23.47
|
||||
@itemize @bullet
|
||||
@item
|
||||
Fixed core-dump bug in replication when using SELECT RELEASE_LOCK();
|
||||
@item
|
||||
Added new statement DO expression,[expression].
|
||||
@item
|
||||
Added @code{slave-skip-errors} option
|
||||
@item
|
||||
Added statistics variables for all MySQL commands. (@code{SHOW STATUS} is
|
||||
|
@ -65,7 +65,7 @@ mysqld_SOURCES = sql_lex.cc \
|
||||
mysqld.cc password.c hash_filo.cc hostname.cc \
|
||||
convert.cc sql_parse.cc sql_yacc.yy \
|
||||
sql_base.cc table.cc sql_select.cc sql_insert.cc \
|
||||
sql_update.cc sql_delete.cc \
|
||||
sql_update.cc sql_delete.cc sql_do.cc \
|
||||
procedure.cc item_uniq.cc sql_test.cc \
|
||||
log.cc log_event.cc init.cc derror.cc sql_acl.cc \
|
||||
unireg.cc \
|
||||
|
@ -278,8 +278,17 @@ void print_arrays()
|
||||
|
||||
for (i=0;i<size;i++)
|
||||
{
|
||||
ulong order = tab_index_function ((i < how_long_symbols) ? symbols[i].name : sql_functions[i - how_long_symbols].name,function_plus,function_type);
|
||||
const char *name= ((i < how_long_symbols) ?
|
||||
symbols[i].name :
|
||||
sql_functions[i - how_long_symbols].name);
|
||||
ulong order = tab_index_function(name,function_plus,function_type);
|
||||
order %= function_mod;
|
||||
/* This should never be true */
|
||||
if (prva[order] != max_symbol)
|
||||
{
|
||||
fprintf(stderr,"Error: Got duplicate value for symbol '%s'\n",name);
|
||||
exit(1);
|
||||
}
|
||||
prva [order] = i;
|
||||
}
|
||||
|
||||
@ -330,11 +339,11 @@ static struct option long_options[] =
|
||||
|
||||
static void usage(int version)
|
||||
{
|
||||
printf("%s Ver 3.2 Distrib %s, for %s (%s)\n",
|
||||
printf("%s Ver 3.3 Distrib %s, for %s (%s)\n",
|
||||
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
|
||||
if (version)
|
||||
return;
|
||||
puts("Copyright (C) 2000 MySQL AB & MySQL Finland AB, by Sinisa and Monty");
|
||||
puts("Copyright (C) 2001 MySQL AB, by Sinisa and Monty");
|
||||
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
|
||||
puts("This program generates a perfect hashing function for the sql_lex.cc");
|
||||
printf("Usage: %s [OPTIONS]\n", my_progname);
|
||||
@ -521,7 +530,7 @@ int main(int argc,char **argv)
|
||||
function_mod=best_mod; function_plus=best_add;
|
||||
make_char_table(best_t1,best_t2,best_type);
|
||||
|
||||
printf("/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB\n\
|
||||
printf("/* Copyright (C) 2001 MySQL AB\n\
|
||||
This program is free software; you can redistribute it and/or modify\n\
|
||||
it under the terms of the GNU General Public License as published by\n\
|
||||
the Free Software Foundation; either version 2 of the License, or\n\
|
||||
|
@ -1406,7 +1406,7 @@ void item_user_lock_release(ULL *ull)
|
||||
char buf[256];
|
||||
String tmp(buf,sizeof(buf));
|
||||
tmp.length(0);
|
||||
tmp.append("SELECT release_lock(\"");
|
||||
tmp.append("DO RELEASE_LOCK(\"");
|
||||
tmp.append(ull->key,ull->key_length);
|
||||
tmp.append("\")");
|
||||
save_errno=thd->net.last_errno;
|
||||
|
@ -114,6 +114,7 @@ static SYMBOL symbols[] = {
|
||||
{ "DESCRIBE", SYM(DESCRIBE),0,0},
|
||||
{ "DISTINCT", SYM(DISTINCT),0,0},
|
||||
{ "DISTINCTROW", SYM(DISTINCT),0,0}, /* Access likes this */
|
||||
{ "DO", SYM(DO_SYM),0,0},
|
||||
{ "DOUBLE", SYM(DOUBLE_SYM),0,0},
|
||||
{ "DROP", SYM(DROP),0,0},
|
||||
{ "DUMPFILE", SYM(DUMPFILE),0,0},
|
||||
@ -466,9 +467,9 @@ static SYMBOL sql_functions[] = {
|
||||
{ "TO_DAYS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_to_days)},
|
||||
{ "TRIM", SYM(TRIM),0,0},
|
||||
{ "UCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
|
||||
{ "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
|
||||
{ "UNIQUE_USERS", SYM(UNIQUE_USERS),0,0},
|
||||
{ "UNIX_TIMESTAMP", SYM(UNIX_TIMESTAMP),0,0},
|
||||
{ "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
|
||||
{ "USER", SYM(USER),0,0},
|
||||
{ "VERSION", SYM(FUNC_ARG0),0,CREATE_FUNC(create_func_version)},
|
||||
{ "WEEK", SYM(WEEK_SYM),0,0},
|
||||
|
@ -373,6 +373,9 @@ Field *find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables);
|
||||
Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
|
||||
bool check_grant,bool allow_rowid);
|
||||
|
||||
/* sql_do.cc */
|
||||
int mysql_do(THD *thd, List<Item> &values);
|
||||
|
||||
/* sql_list.c */
|
||||
int mysqld_show_dbs(THD *thd,const char *wild);
|
||||
int mysqld_show_open_tables(THD *thd,const char *db,const char *wild);
|
||||
|
35
sql/sql_do.cc
Normal file
35
sql/sql_do.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 */
|
||||
|
||||
|
||||
/* Execute DO statement */
|
||||
|
||||
#include "mysql_priv.h"
|
||||
#include "sql_acl.h"
|
||||
|
||||
int mysql_do(THD *thd, List<Item> &values)
|
||||
{
|
||||
int error;
|
||||
List_iterator<Item> li(values);
|
||||
Item *value;
|
||||
DBUG_ENTER("mysql_do");
|
||||
if (setup_fields(thd,0, values, 0, 0))
|
||||
DBUG_RETURN(-1);
|
||||
while ((value = li++))
|
||||
value->val_int();
|
||||
send_ok(&thd->net);
|
||||
DBUG_RETURN(0);
|
||||
}
|
@ -53,7 +53,7 @@ enum enum_sql_command {
|
||||
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
|
||||
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
|
||||
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS,
|
||||
SQLCOM_SHOW_OPEN_TABLES,
|
||||
SQLCOM_SHOW_OPEN_TABLES, SQLCOM_DO,
|
||||
SQLCOM_END
|
||||
};
|
||||
|
||||
|
@ -1164,6 +1164,10 @@ mysql_execute_command(void)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case SQLCOM_DO:
|
||||
res=mysql_do(thd, *lex->insert_list);
|
||||
break;
|
||||
|
||||
case SQLCOM_PURGE:
|
||||
{
|
||||
if (check_process_priv(thd))
|
||||
|
@ -102,6 +102,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
||||
%token CREATE
|
||||
%token CROSS
|
||||
%token DELETE_SYM
|
||||
%token DO_SYM
|
||||
%token DROP
|
||||
%token INSERT
|
||||
%token FLUSH_SYM
|
||||
@ -509,7 +510,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
||||
%type <lex_user> user grant_user
|
||||
|
||||
%type <NONE>
|
||||
query verb_clause create change select drop insert replace insert2
|
||||
query verb_clause create change select do drop insert replace insert2
|
||||
insert_values update delete truncate rename
|
||||
show describe load alter optimize flush
|
||||
reset purge begin commit rollback slave master_def master_defs
|
||||
@ -560,6 +561,7 @@ verb_clause:
|
||||
| create
|
||||
| delete
|
||||
| describe
|
||||
| do
|
||||
| drop
|
||||
| grant
|
||||
| insert
|
||||
@ -1227,7 +1229,7 @@ table_to_table:
|
||||
}
|
||||
|
||||
/*
|
||||
** Select : retrieve data from table
|
||||
Select : retrieve data from table
|
||||
*/
|
||||
|
||||
|
||||
@ -1861,7 +1863,7 @@ opt_escape:
|
||||
|
||||
|
||||
/*
|
||||
** group by statement in select
|
||||
group by statement in select
|
||||
*/
|
||||
|
||||
group_clause:
|
||||
@ -1875,7 +1877,7 @@ group_list:
|
||||
{ if (add_group_to_list($1,(bool) $2)) YYABORT; }
|
||||
|
||||
/*
|
||||
** Order by statement in select
|
||||
Order by statement in select
|
||||
*/
|
||||
|
||||
opt_order_clause:
|
||||
@ -1971,9 +1973,20 @@ opt_into:
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Drop : delete tables or index
|
||||
DO statement
|
||||
*/
|
||||
|
||||
do: DO_SYM
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command = SQLCOM_DO;
|
||||
if (!(lex->insert_list = new List_item))
|
||||
YYABORT;
|
||||
}
|
||||
values
|
||||
/*
|
||||
Drop : delete tables or index
|
||||
*/
|
||||
|
||||
drop:
|
||||
@ -2534,6 +2547,7 @@ keyword:
|
||||
| DATE_SYM {}
|
||||
| DAY_SYM {}
|
||||
| DELAY_KEY_WRITE_SYM {}
|
||||
| DO_SYM {}
|
||||
| DUMPFILE {}
|
||||
| DYNAMIC_SYM {}
|
||||
| END {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user