diff options
author | unknown <hf@deer.(none)> | 2004-03-23 13:09:50 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-03-23 13:09:50 +0400 |
commit | b02e83becf986b386acffc204bc4fde41caffc48 (patch) | |
tree | c3bbcc4238d692985e74dd0d56d5c4020c126797 | |
parent | a0dce8c864bce640690847c5600b3d233508d4a9 (diff) | |
parent | a25455eea533974a2106be75605ca3ee8377da76 (diff) | |
download | mariadb-git-b02e83becf986b386acffc204bc4fde41caffc48.tar.gz |
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.3188
sql/item.cc:
Auto merged
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rw-r--r-- | VC++Files/mysys/mysys.dsp | 8 | ||||
-rw-r--r-- | VC++Files/sql/mysqld.dsp | 4 | ||||
-rw-r--r-- | include/mysql.h | 21 | ||||
-rw-r--r-- | libmysql/client_settings.h | 2 | ||||
-rw-r--r-- | libmysql/libmysql.c | 172 | ||||
-rw-r--r-- | myisam/mi_check.c | 7 | ||||
-rw-r--r-- | mysql-test/r/lowercase_table.result | 11 | ||||
-rw-r--r-- | mysql-test/r/repair_part1.result | 15 | ||||
-rw-r--r-- | mysql-test/t/lowercase_table.test | 15 | ||||
-rw-r--r-- | mysql-test/t/repair_part1.test | 12 | ||||
-rw-r--r-- | sql-common/client.c | 5 | ||||
-rw-r--r-- | sql/item.cc | 5 | ||||
-rw-r--r-- | sql/set_var.h | 2 | ||||
-rw-r--r-- | sql/sql_cache.cc | 7 | ||||
-rw-r--r-- | sql/sql_db.cc | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
18 files changed, 254 insertions, 43 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index db98622657e..7a75d7a9873 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -63,6 +63,7 @@ jani@ua167d18.elisa.omakaista.fi jani@ua72d24.elisa.omakaista.fi jcole@abel.spaceapes.com jcole@main.burghcom.com +jcole@mugatu.jcole.us jcole@mugatu.spaceapes.com jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index f81614b6295..a7be57d94c0 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -330,10 +330,18 @@ SOURCE=.\my_gethostbyname.c # End Source File # Begin Source File +SOURCE=.\my_gethwaddr.c +# End Source File +# Begin Source File + SOURCE=.\my_getopt.c # End Source File # Begin Source File +SOURCE=.\my_getsystime.c +# End Source File +# Begin Source File + SOURCE=.\my_getwd.c # End Source File # Begin Source File diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 9678a0faed3..af75cfa84aa 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -711,10 +711,6 @@ SOURCE=.\nt_servc.h # End Source File # Begin Source File -SOURCE=.\opt_ft.cpp -# End Source File -# Begin Source File - SOURCE=.\opt_range.cpp !IF "$(CFG)" == "mysqld - Win32 Release" diff --git a/include/mysql.h b/include/mysql.h index e14381a94de..d922b552e38 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -185,6 +185,12 @@ struct st_mysql_options { char *client_ip; /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */ my_bool secure_auth; + + /* function pointers for local infile support */ + int (*local_infile_init)(void **, char *); + int (*local_infile_read)(void *, char *, uint); + int (*local_infile_end)(void *); + int (*local_infile_error)(void *, char *, uint); }; enum mysql_status @@ -384,6 +390,21 @@ my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q, my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, unsigned long length); +/* local infile support */ + +#define LOCAL_INFILE_ERROR_LEN 512 + +int +mysql_set_local_infile_handler(MYSQL *mysql, + int (*local_infile_init)(void **, char *), + int (*local_infile_read)(void *, char *, uint), + int (*local_infile_end)(void *), + int (*local_infile_error)(void *, char *, uint)); + +void +mysql_set_local_infile_default(MYSQL *mysql); + + /* enable/disable parsing of all queries to decide if they go on master or slave diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 9fc8e67df27..3fdadf29dea 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -23,7 +23,7 @@ extern my_string mysql_unix_port; sig_handler pipe_sig_handler(int sig __attribute__((unused))); void read_user_name(char *name); -my_bool send_file_to_server(MYSQL *mysql, const char *filename); +my_bool handle_local_infile(MYSQL *mysql, const char *net_filename); /* Let the user specify that we don't want SIGPIPE; This doesn't however work diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 0a93fe60990..357c85c09b2 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -794,35 +794,55 @@ void read_user_name(char *name) #endif -my_bool send_file_to_server(MYSQL *mysql, const char *filename) +my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) { - int fd, readcount; my_bool result= 1; uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE); - char *buf, tmp_name[FN_REFLEN]; NET *net= &mysql->net; - DBUG_ENTER("send_file_to_server"); + int error; + int readcount; + void *li_ptr; /* pass state to local_infile functions */ + char *buf = NULL; /* buffer to be filled by local_infile_read */ + char *filename = NULL; /* local copy of filename arg */ - if (!(buf=my_malloc(packet_length,MYF(0)))) + DBUG_ENTER("handle_local_infile"); + + /* check that we've got valid callback functions */ + if (!((mysql->options.local_infile_init) && + (mysql->options.local_infile_read) && + (mysql->options.local_infile_end) && + (mysql->options.local_infile_error))) { - strmov(net->sqlstate, unknown_sqlstate); - strmov(net->last_error, ER(net->last_errno=CR_OUT_OF_MEMORY)); - DBUG_RETURN(1); + /* if any of the functions is invalid, set the default */ + mysql_set_local_infile_default(mysql); } - fn_format(tmp_name,filename,"","",4); /* Convert to client format */ - if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0) + /* copy filename into local memory and allocate read buffer */ + if ((!(filename = my_strdup(net_filename, MYF(0)))) || + (!(buf=my_malloc(packet_length, MYF(0))))) + goto oom; + + + /* initialize local infile (open file, usually) */ + if ( (error = (*mysql->options.local_infile_init)(&li_ptr, filename)) ) { my_net_write(net,"",0); /* Server needs one packet */ net_flush(net); + if(error < 0) + goto oom; strmov(net->sqlstate, unknown_sqlstate); - net->last_errno=EE_FILENOTFOUND; - my_snprintf(net->last_error,sizeof(net->last_error)-1, - EE(net->last_errno),tmp_name, errno); + net->last_errno=error; + (*mysql->options.local_infile_error)(li_ptr, + net->last_error, + sizeof(net->last_error)-1); goto err; } - while ((readcount = (int) my_read(fd,(byte*) buf,packet_length,MYF(0))) > 0) + /* read blocks of data from local infile callback */ + while ( (readcount = + (*mysql->options.local_infile_read)(li_ptr, + buf, + packet_length) ) > 0) { if (my_net_write(net,buf,readcount)) { @@ -833,6 +853,7 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename) goto err; } } + /* Send empty packet to mark end of file */ if (my_net_write(net,"",0) || net_flush(net)) { @@ -841,21 +862,136 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename) sprintf(net->last_error,ER(net->last_errno),errno); goto err; } + if (readcount < 0) { strmov(net->sqlstate, unknown_sqlstate); net->last_errno=EE_READ; /* the errmsg for not entire file read */ my_snprintf(net->last_error,sizeof(net->last_error)-1, - tmp_name,errno); + filename, errno); goto err; } + result=0; /* Ok */ err: - if (fd >= 0) - (void) my_close(fd,MYF(0)); - my_free(buf,MYF(0)); + /* free up memory allocated with _init, usually */ + (*mysql->options.local_infile_end)(li_ptr); + + my_free(filename, MYF(0)); + my_free(buf, MYF(0)); DBUG_RETURN(result); + +oom: + /* out of memory */ + my_free(filename, MYF(MY_ALLOW_ZERO_PTR)); + my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error, ER(net->last_errno=CR_OUT_OF_MEMORY)); + DBUG_RETURN(1); +} + + +typedef struct default_local_infile_st { + int fd; + int error_num; + char error_msg[LOCAL_INFILE_ERROR_LEN]; +} default_local_infile_data; + + +int +default_local_infile_init(void **ptr, char *filename) +{ + default_local_infile_data *data; + + if (!(*ptr= data= ((default_local_infile_data *) + my_malloc(sizeof(default_local_infile_data), MYF(0))))) + return -1; /* out of memory */ + + *ptr = data; /* save the struct, we need it to return an error */ + + data->error_msg[0]= 0; + data->error_num= 0; + + if ((data->fd = my_open(filename, O_RDONLY, MYF(0))) < 0) + { + my_snprintf(data->error_msg, sizeof(data->error_msg)-1, + EE(EE_FILENOTFOUND), filename, errno); + return data->error_num=errno; /* error */ + } + + return 0; /* ok */ +} + + +int +default_local_infile_read(void *ptr, char *buf, uint buf_len) +{ + default_local_infile_data *data = (default_local_infile_data *) ptr; + + return ((int) my_read(data->fd, (byte *)buf, buf_len, MYF(0))); +} + + +int +default_local_infile_end(void *ptr) +{ + default_local_infile_data *data = (default_local_infile_data *) ptr; + if(data) + { + my_close(data->fd, MYF(0)); + my_free(ptr, MYF(0)); + } + return 0; +} + + +int +default_local_infile_error(void *ptr, char *error_msg, uint error_msg_len) +{ + default_local_infile_data *data = (default_local_infile_data *) ptr; + + if(data) { + strmake(error_msg, data->error_msg, error_msg_len); + return data->error_num; + } + else + { + strmake(error_msg, "Internal error", error_msg_len); + return 0; + } +} + + +int +mysql_set_local_infile_handler(MYSQL *mysql, + int (*local_infile_init)(void **, char *), + int (*local_infile_read)(void *, char *, uint), + int (*local_infile_end)(void *), + int (*local_infile_error)(void *, char *, uint)) +{ + if(mysql && + local_infile_init && + local_infile_read && + local_infile_end && + local_infile_error) { + mysql->options.local_infile_init= local_infile_init; + mysql->options.local_infile_read= local_infile_read; + mysql->options.local_infile_end= local_infile_end; + mysql->options.local_infile_error= local_infile_error; + return 0; + } + return 1; +} + + +void +mysql_set_local_infile_default(MYSQL *mysql) +{ + mysql->options.local_infile_init= default_local_infile_init; + mysql->options.local_infile_read= default_local_infile_read; + mysql->options.local_infile_end= default_local_infile_end; + mysql->options.local_infile_error= default_local_infile_error; } diff --git a/myisam/mi_check.c b/myisam/mi_check.c index cdaed59cd01..79167a885cd 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1274,11 +1274,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, I think mi_repair and mi_repair_by_sort should do the same (according, e.g. to ha_myisam::repair), but as mi_repair doesn't touch key_map it cannot be used to T_CREATE_MISSING_KEYS. - That is what the next line is for... (serg) + That is what the next line is for */ - share->state.key_map= ((((ulonglong) 1L << share->base.keys)-1) & - param->keys_in_use); + if (param->testflag & T_CREATE_MISSING_KEYS) + share->state.key_map= ((((ulonglong) 1L << share->base.keys)-1) & + param->keys_in_use); info->state->key_file_length=share->base.keystart; diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index f4e7723a608..8bf3db8cad0 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2,t3,t4,T1; +drop table if exists t1,t2,t3,t4; create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table t4 (id int primary key, Word varchar(40) not null); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); @@ -49,3 +49,12 @@ delete P1.*,p2.* from t1 as P1, t2 as P2 where P1.a=p2.a; update t1 as p1, t2 as p2 SET p1.a=1,P2.a=1 where p1.a=P2.a; update t1 as P1, t2 as P2 SET P1.a=1,p2.a=1 where P1.a=p2.a; drop table t1,t2; +create table t1 (a int); +create table t2 (a int); +select * from t1 c, t2 C; +ERROR 42000: Not unique table/alias: 'C' +select C.a, c.a from t1 c, t2 C; +ERROR 42000: Not unique table/alias: 'C' +drop table t1, t2; +show tables; +Tables_in_test diff --git a/mysql-test/r/repair_part1.result b/mysql-test/r/repair_part1.result index e0030327743..6dcec409ea6 100644 --- a/mysql-test/r/repair_part1.result +++ b/mysql-test/r/repair_part1.result @@ -9,6 +9,21 @@ repair table t1 use_frm; Table Op Msg_type Msg_text test.t1 repair error The storage engine for the table doesn't support repair drop table t1; +create table t1(id int PRIMARY KEY, st varchar(10), KEY st_key(st)); +insert into t1 values(1, "One"); +alter table t1 disable keys; +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 id A 1 NULL NULL BTREE +t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled +repair table t1 extended; +Table Op Msg_type Msg_text +test.t1 repair status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 id A 1 NULL NULL BTREE +t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled +drop table t1; repair table t1 use_frm; Table Op Msg_type Msg_text test.t1 repair error Table 'test.t1' doesn't exist diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index 42e9cdc9f3d..db46f3d432d 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1,t2,t3,t4,T1; +drop table if exists t1,t2,t3,t4; --enable_warnings create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); @@ -41,3 +41,16 @@ delete P1.*,p2.* from t1 as P1, t2 as P2 where P1.a=p2.a; update t1 as p1, t2 as p2 SET p1.a=1,P2.a=1 where p1.a=P2.a; update t1 as P1, t2 as P2 SET P1.a=1,p2.a=1 where P1.a=p2.a; drop table t1,t2; + +# +# aliases case insensitive +# +create table t1 (a int); +create table t2 (a int); +-- error 1066 +select * from t1 c, t2 C; +-- error 1066 +select C.a, c.a from t1 c, t2 C; +drop table t1, t2; + +show tables; diff --git a/mysql-test/t/repair_part1.test b/mysql-test/t/repair_part1.test index e82edb64713..a2e186fd385 100644 --- a/mysql-test/t/repair_part1.test +++ b/mysql-test/t/repair_part1.test @@ -12,6 +12,18 @@ alter table t1 ENGINE=HEAP; repair table t1 use_frm; drop table t1; +# +# disabled keys during repair +# +create table t1(id int PRIMARY KEY, st varchar(10), KEY st_key(st)); +insert into t1 values(1, "One"); +alter table t1 disable keys; +show keys from t1; +repair table t1 extended; +show keys from t1; +drop table t1; + + # non-existent table repair table t1 use_frm; diff --git a/sql-common/client.c b/sql-common/client.c index 27492e8d405..b94f3e1de38 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1358,12 +1358,15 @@ mysql_init(MYSQL *mysql) Only enable LOAD DATA INFILE by default if configured with --enable-local-infile */ + #if defined(ENABLED_LOCAL_INFILE) && !defined(MYSQL_SERVER) mysql->options.client_flag|= CLIENT_LOCAL_FILES; #endif + #ifdef HAVE_SMEM mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name; #endif + mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION; return mysql; } @@ -2282,7 +2285,7 @@ get_info: #ifdef MYSQL_CLIENT if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */ { - int error=send_file_to_server(mysql,(char*) pos); + int error=handle_local_infile(mysql,(char*) pos); if ((length=net_safe_read(mysql)) == packet_error || error) DBUG_RETURN(1); goto get_info; /* Get info packet */ diff --git a/sql/item.cc b/sql/item.cc index faacf49fcc3..124310b68d5 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -456,9 +456,8 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const (!my_strcasecmp(table_alias_charset, item_field->table_name, table_name) && (!item_field->db_name || - (item_field->db_name && !my_strcasecmp(table_alias_charset, - item_field->db_name, - db_name)))))); + (item_field->db_name && !strcmp(item_field->db_name, + db_name)))))); } diff --git a/sql/set_var.h b/sql/set_var.h index 8f21c5a729f..dc5b1bf927f 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -141,7 +141,7 @@ public: sys_update_func update_func_arg, sys_set_default_func set_default_func_arg, char *value_arg) - :sys_var(name_arg), check_func(check_func_arg), value(value_arg), + :sys_var(name_arg), value(value_arg), check_func(check_func_arg), update_func(update_func_arg),set_default_func(set_default_func_arg) {} bool check(THD *thd, set_var *var); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index afeee044799..40d9b1b42d8 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1259,12 +1259,7 @@ void Query_cache::invalidate(char *db) do { next= curr->next; - /* - table_alias_charset used here because it depends of - lower_case_table_names variable - */ - if (my_strcasecmp(table_alias_charset, db, - (char*)(curr->table()->db())) == 0) + if (strcmp(db, (char*)(curr->table()->db())) == 0) invalidate_table(curr); /* invalidate_table can freed block on which point 'next' (if diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6aaca975e53..08582391754 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -504,7 +504,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, found_other_files++; continue; } - if (db && !my_strcasecmp(&my_charset_latin1, + // just for safety we use files_charset_info + if (db && !my_strcasecmp(files_charset_info, extension, reg_ext)) { /* Drop the table nicely */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d21f20d1697..73811dddf75 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2712,7 +2712,7 @@ mysql_execute_command(THD *thd) for (walk= (TABLE_LIST*) tables; walk; walk= walk->next) { if (!my_strcasecmp(table_alias_charset, auxi->alias, walk->alias) && - !my_strcasecmp(table_alias_charset, walk->db, auxi->db)) + !strcmp(walk->db, auxi->db)) break; } if (!walk) @@ -4495,7 +4495,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, tables ; tables=tables->next) { - if (!strcmp(alias_str,tables->alias) && !strcmp(ptr->db, tables->db)) + if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) && + !strcmp(ptr->db, tables->db)) { net_printf(thd,ER_NONUNIQ_TABLE,alias_str); /* purecov: tested */ DBUG_RETURN(0); /* purecov: tested */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 020356782ba..94bedd9bfa2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9376,7 +9376,7 @@ void st_select_lex::print(THD *thd, String *str) str->append(table->db); str->append('.'); str->append(table->real_name); - if (strcmp(table->real_name, table->alias)) + if (my_strcasecmp(table_alias_charset, table->real_name, table->alias)) { str->append(' '); str->append(table->alias); |