summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-12-17 20:47:20 +0200
committerunknown <monty@hundin.mysql.fi>2001-12-17 20:47:20 +0200
commit4fff4025063b0408a917f2b0c5809ab84d6a00a1 (patch)
tree9189968dca2f68cfe5634ccd7ac1cd1a8a6228d2 /sql
parent1fe5615f52ce8e59e6e7cf55eb3e6e59647b6923 (diff)
parent75db3094c2432f809031465bb277fb4b6b51b7ae (diff)
downloadmariadb-git-4fff4025063b0408a917f2b0c5809ab84d6a00a1.tar.gz
merge with 3.23.47 (DO statement)
innobase/dict/dict0dict.c: Auto merged innobase/row/row0mysql.c: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_innobase.cc: Auto merged sql/item_func.cc: Auto merged sql/lex.h: Auto merged sql/sql_parse.cc: Auto merged Docs/manual.texi: merge sql/Makefile.am: merge sql/mysql_priv.h: merge sql/sql_lex.h: merge sql/sql_yacc.yy: merge
Diffstat (limited to 'sql')
-rw-r--r--sql/Makefile.am2
-rw-r--r--sql/gen_lex_hash.cc17
-rw-r--r--sql/ha_innobase.cc11
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/lex.h3
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/sql_do.cc35
-rw-r--r--sql/sql_lex.h1
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_yacc.yy24
10 files changed, 86 insertions, 16 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 8238160d652..88306098107 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -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 \
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 4e5d6fb3111..7ebdbcd8ba8 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.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\
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 8dd2e49e093..3a71da6ba84 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -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*) "";
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 5b4fb816404..4caa959bce8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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();
diff --git a/sql/lex.h b/sql/lex.h
index d72d2ff63a4..59c71f20cd7 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -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},
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index abce5b0c4ac..27dba4d62fd 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -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);
diff --git a/sql/sql_do.cc b/sql/sql_do.cc
new file mode 100644
index 00000000000..8e197b47fd5
--- /dev/null
+++ b/sql/sql_do.cc
@@ -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);
+}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 19ed35da22e..6ec8d4070b1 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -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
};
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 215a6723db9..851c07265b0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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))
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a4d6f6a558e..5282fb157e6 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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;
}
+/*
+ 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 : delete tables or index
*/
drop:
@@ -2924,6 +2937,7 @@ keyword:
| DEMAND_SYM {}
| DES_KEY_FILE {}
| DIRECTORY_SYM {}
+ | DO_SYM {}
| DUMPFILE {}
| DYNAMIC_SYM {}
| END {}