merge with 3.23.47 (DO statement)
This commit is contained in:
commit
c298f03570
@ -2817,7 +2817,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 ability to set variables in a statement with @code{:=}:
|
||||
@ -32040,6 +32040,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}
|
||||
@ -32270,6 +32273,7 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
|
||||
* TRUNCATE:: @code{TRUNCATE} Syntax
|
||||
* REPLACE:: @code{REPLACE} Syntax
|
||||
* LOAD DATA:: @code{LOAD DATA INFILE} Syntax
|
||||
* DO:: @code{DO} Syntax
|
||||
@end menu
|
||||
|
||||
@node SELECT, HANDLER, Data Manipulation, Data Manipulation
|
||||
@ -33346,7 +33350,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
|
||||
@ -33842,6 +33846,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}
|
||||
|
||||
@ -48060,6 +48081,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
|
||||
|
@ -455,7 +455,7 @@ dict_table_get(
|
||||
mutex_exit(&(dict_sys->mutex));
|
||||
|
||||
if (table != NULL) {
|
||||
if (table->stat_last_estimate_counter == (ulint)(-1)) {
|
||||
if (!table->stat_initialized) {
|
||||
dict_update_statistics(table);
|
||||
}
|
||||
}
|
||||
@ -2617,9 +2617,11 @@ dict_update_statistics_low(
|
||||
table->stat_clustered_index_size = index->stat_index_size;
|
||||
|
||||
table->stat_sum_of_other_index_sizes = sum_of_index_sizes
|
||||
- index->stat_index_size;
|
||||
- index->stat_index_size;
|
||||
|
||||
table->stat_last_estimate_counter = table->stat_modif_counter;
|
||||
table->stat_initialized = TRUE;
|
||||
|
||||
table->stat_modified_counter = 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -73,9 +73,9 @@ dict_mem_table_create(
|
||||
|
||||
table->does_not_fit_in_memory = FALSE;
|
||||
|
||||
table->stat_last_estimate_counter = (ulint)(-1);
|
||||
table->stat_initialized = FALSE;
|
||||
|
||||
table->stat_modif_counter = 0;
|
||||
table->stat_modified_counter = 0;
|
||||
|
||||
mutex_create(&(table->autoinc_mutex));
|
||||
mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);
|
||||
|
@ -348,20 +348,20 @@ struct dict_table_struct{
|
||||
database pages */
|
||||
ulint stat_sum_of_other_index_sizes;
|
||||
/* other indexes in database pages */
|
||||
ulint stat_last_estimate_counter;
|
||||
/* when the estimates were last time
|
||||
calculated; a value (ulint)-1 denotes that
|
||||
they have not yet been calculated for this
|
||||
table (or the counter has wrapped over) */
|
||||
ulint stat_modif_counter;
|
||||
ibool stat_initialized; /* TRUE if statistics have
|
||||
been calculated the first time
|
||||
after database startup or table creation */
|
||||
ulint stat_modified_counter;
|
||||
/* when a row is inserted, updated, or deleted,
|
||||
we add the row length to this number; we
|
||||
calculate new estimates for the stat_...
|
||||
values for the table and the indexes at an
|
||||
interval of DICT_STAT_CALCULATE_INTERVAL,
|
||||
but for small tables more often, also
|
||||
interval of 2 GB or when about 1 / 16 of table
|
||||
has been modified; also
|
||||
when the estimate operation is called
|
||||
for MySQL SHOW TABLE STATUS; this counter
|
||||
for MySQL SHOW TABLE STATUS; the counter is
|
||||
reset to zero at statistics calculation;
|
||||
this counter
|
||||
is not protected by any latch, because this
|
||||
is only used for heuristics */
|
||||
/*----------------------*/
|
||||
@ -377,10 +377,6 @@ struct dict_table_struct{
|
||||
ulint magic_n;/* magic number */
|
||||
};
|
||||
#define DICT_TABLE_MAGIC_N 76333786
|
||||
|
||||
/* Statistics are calculated at least with this interval; see the struct
|
||||
above */
|
||||
#define DICT_STAT_CALCULATE_INTERVAL (UNIV_PAGE_SIZE * 8)
|
||||
|
||||
/* Data structure for a stored procedure */
|
||||
struct dict_proc_struct{
|
||||
|
@ -432,19 +432,24 @@ row_update_statistics_if_needed(
|
||||
row_prebuilt_t* prebuilt) /* in: prebuilt struct */
|
||||
{
|
||||
ulint counter;
|
||||
ulint old_counter;
|
||||
|
||||
counter = prebuilt->table->stat_modif_counter;
|
||||
counter = prebuilt->table->stat_modified_counter;
|
||||
|
||||
counter += prebuilt->mysql_row_len;
|
||||
prebuilt->table->stat_modif_counter = counter;
|
||||
/* Since the physical size of an InnoDB row is bigger than the
|
||||
MySQL row len, we put a safety factor 2 below */
|
||||
|
||||
old_counter = prebuilt->table->stat_last_estimate_counter;
|
||||
counter += 2 * prebuilt->mysql_row_len;
|
||||
|
||||
if (counter - old_counter >= DICT_STAT_CALCULATE_INTERVAL
|
||||
|| counter - old_counter >=
|
||||
(UNIV_PAGE_SIZE
|
||||
* prebuilt->table->stat_clustered_index_size / 2)) {
|
||||
prebuilt->table->stat_modified_counter = counter;
|
||||
|
||||
/* Calculate new statistics if 1 / 16 of table has been modified
|
||||
since the last time a statistics batch was run, or if
|
||||
stat_modified_counter > 2 000 000 000 (to avoid wrap-around) */
|
||||
|
||||
if (counter > 2000000000
|
||||
|| ((ib_longlong)counter >
|
||||
(UNIV_PAGE_SIZE * prebuilt->table->stat_clustered_index_size)
|
||||
/ 16)) {
|
||||
|
||||
dict_update_statistics(prebuilt->table);
|
||||
}
|
||||
@ -1021,6 +1026,26 @@ row_create_table_for_mysql(
|
||||
os_event_set(srv_lock_timeout_thread_event);
|
||||
}
|
||||
|
||||
keywordlen = ut_strlen("innodb_mem_validate");
|
||||
|
||||
if (namelen >= keywordlen
|
||||
&& 0 == ut_memcmp(table->name + namelen - keywordlen,
|
||||
"innodb_mem_validate", keywordlen)) {
|
||||
|
||||
/* We define here a debugging feature intended for
|
||||
developers */
|
||||
|
||||
printf("Validating InnoDB memory:\n"
|
||||
"to use this feature you must compile InnoDB with\n"
|
||||
"UNIV_MEM_DEBUG defined in univ.i and the server must be\n"
|
||||
"quiet because allocation from a mem heap is not protected\n"
|
||||
"by any semaphore.\n");
|
||||
|
||||
ut_a(mem_validate());
|
||||
|
||||
printf("Memory validated\n");
|
||||
}
|
||||
|
||||
/* Serialize data dictionary operations with dictionary mutex:
|
||||
no deadlocks can occur then in these operations */
|
||||
|
||||
|
@ -67,7 +67,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.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 uniques.cc \
|
||||
sql_update.cc sql_delete.cc uniques.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 des_key_file.cc \
|
||||
|
@ -279,8 +279,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;
|
||||
}
|
||||
|
||||
@ -331,11 +340,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);
|
||||
@ -527,7 +536,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\
|
||||
|
@ -3040,15 +3040,18 @@ ha_innobase::estimate_number_of_rows(void)
|
||||
|
||||
DBUG_ENTER("info");
|
||||
|
||||
dict_update_statistics(prebuilt->table);
|
||||
|
||||
index = dict_table_get_first_index_noninline(prebuilt->table);
|
||||
|
||||
data_file_length = ((ulonglong) index->stat_n_leaf_pages)
|
||||
* UNIV_PAGE_SIZE;
|
||||
/* Calculate a minimum length for a clustered index record */
|
||||
|
||||
estimate = data_file_length / dict_index_calc_min_rec_len(index);
|
||||
/* Calculate a minimum length for a clustered index record and from
|
||||
that an upper bound for the number of rows. Since we only calculate
|
||||
new statistics in row0mysql.c when a tablehas grown
|
||||
by a threshold factor, we must add a safety factor 2 in front
|
||||
of the formula below. */
|
||||
|
||||
estimate = 2 * data_file_length / dict_index_calc_min_rec_len(index);
|
||||
|
||||
if (prebuilt->trx) {
|
||||
prebuilt->trx->op_info = (char*) "";
|
||||
|
@ -1421,7 +1421,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("\")");
|
||||
thd->query_length=tmp.length();
|
||||
|
@ -123,6 +123,7 @@ static SYMBOL symbols[] = {
|
||||
{ "DISABLE", SYM(DISABLE_SYM),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},
|
||||
@ -498,9 +499,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},
|
||||
|
@ -412,6 +412,9 @@ extern pthread_mutex_t LOCK_des_key_file;
|
||||
bool load_des_key_file(const char *file_name);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
/* 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 *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);
|
||||
}
|
@ -57,6 +57,7 @@ enum enum_sql_command {
|
||||
SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
|
||||
SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI,
|
||||
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER,
|
||||
SQLCOM_SHOW_OPEN_TABLES, SQLCOM_DO,
|
||||
SQLCOM_END
|
||||
};
|
||||
|
||||
|
@ -1188,6 +1188,10 @@ mysql_execute_command(void)
|
||||
delete result;
|
||||
break;
|
||||
}
|
||||
case SQLCOM_DO:
|
||||
res=mysql_do(thd, *lex->insert_list);
|
||||
break;
|
||||
|
||||
case SQLCOM_PURGE:
|
||||
{
|
||||
if (check_process_priv(thd))
|
||||
|
@ -112,6 +112,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
|
||||
@ -551,7 +552,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
|
||||
@ -605,6 +606,7 @@ verb_clause:
|
||||
| create
|
||||
| delete
|
||||
| describe
|
||||
| do
|
||||
| drop
|
||||
| grant
|
||||
| insert
|
||||
@ -1344,7 +1346,7 @@ table_to_table:
|
||||
}
|
||||
|
||||
/*
|
||||
** Select : retrieve data from table
|
||||
Select : retrieve data from table
|
||||
*/
|
||||
|
||||
|
||||
@ -2070,7 +2072,7 @@ opt_escape:
|
||||
|
||||
|
||||
/*
|
||||
** group by statement in select
|
||||
group by statement in select
|
||||
*/
|
||||
|
||||
group_clause:
|
||||
@ -2084,7 +2086,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:
|
||||
@ -2185,9 +2187,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:
|
||||
@ -2924,6 +2937,7 @@ keyword:
|
||||
| DEMAND_SYM {}
|
||||
| DES_KEY_FILE {}
|
||||
| DIRECTORY_SYM {}
|
||||
| DO_SYM {}
|
||||
| DUMPFILE {}
|
||||
| DYNAMIC_SYM {}
|
||||
| END {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user