diff options
author | unknown <monty@hundin.mysql.fi> | 2001-12-17 19:59:20 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-12-17 19:59:20 +0200 |
commit | 1808d80fb35ff10d1c5bbdc5d417d00f7973f3b0 (patch) | |
tree | 8a029b3a64d087a02845998db4731aa1b475b7b0 /sql | |
parent | f8b4629cf728072b230159718994f585145b4ce2 (diff) | |
download | mariadb-git-1808d80fb35ff10d1c5bbdc5d417d00f7973f3b0.tar.gz |
Added DO command
Docs/manual.texi:
ChangeLog
sql/gen_lex_hash.cc:
Safety fix
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/gen_lex_hash.cc | 17 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/lex.h | 3 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/sql_do.cc | 35 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 24 |
9 files changed, 79 insertions, 13 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index f1941e1e25c..47cee300b09 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -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 \ diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index e05fdafcbc4..7bbf08b50f3 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.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\ diff --git a/sql/item_func.cc b/sql/item_func.cc index c5274333008..94464bdc594 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -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; diff --git a/sql/lex.h b/sql/lex.h index ed97eea751f..30fbf46e354 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -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}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 11bf7d36389..a569fecfc9d 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -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); 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 e70a8902901..7555d605e35 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -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 }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2f629ec920c..dd627017ead 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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)) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c1935df732f..42872399dec 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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; } +/* + 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: @@ -2534,6 +2547,7 @@ keyword: | DATE_SYM {} | DAY_SYM {} | DELAY_KEY_WRITE_SYM {} + | DO_SYM {} | DUMPFILE {} | DYNAMIC_SYM {} | END {} |