Commit daf8cc67 authored by unknown's avatar unknown

Merge mysql.com:/home/jimw/my/mysql-4.1-clean

into  mysql.com:/home/jimw/my/mysql-5.0-clean


mysql-test/r/func_str.result:
  Auto merged
mysql-test/r/lowercase_table2.result:
  Auto merged
mysql-test/r/rpl_failed_optimize.result:
  Auto merged
vio/viossl.c:
  Auto merged
mysql-test/t/func_str.test:
  Merge from 4.1
sql/item_func.cc:
  Merge from 4.1
sql/sql_table.cc:
  Merge from 4.1
parents 2b3a1494 b4953598
...@@ -794,3 +794,9 @@ id aes_decrypt(str, 'bar') ...@@ -794,3 +794,9 @@ id aes_decrypt(str, 'bar')
1 foo 1 foo
2 NULL 2 NULL
DROP TABLE t1, t2; DROP TABLE t1, t2;
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
3 3 3
select field(NULL,1,2,NULL), field(NULL,1,2,0);
field(NULL,1,2,NULL) field(NULL,1,2,0)
0 0
...@@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` ( ...@@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` (
RENAME TABLE T1 TO T2; RENAME TABLE T1 TO T2;
SHOW TABLES LIKE "T2"; SHOW TABLES LIKE "T2";
Tables_in_test (T2) Tables_in_test (T2)
t2 T2
SELECT * FROM t2; SELECT * FROM t2;
a a
1 1
...@@ -83,25 +83,25 @@ t3 ...@@ -83,25 +83,25 @@ t3
RENAME TABLE T3 TO T1; RENAME TABLE T3 TO T1;
SHOW TABLES LIKE "T1"; SHOW TABLES LIKE "T1";
Tables_in_test (T1) Tables_in_test (T1)
t1 T1
ALTER TABLE T1 add b int; ALTER TABLE T1 add b int;
SHOW TABLES LIKE "T1"; SHOW TABLES LIKE "T1";
Tables_in_test (T1) Tables_in_test (T1)
t1 T1
ALTER TABLE T1 RENAME T2; ALTER TABLE T1 RENAME T2;
SHOW TABLES LIKE "T2"; SHOW TABLES LIKE "T2";
Tables_in_test (T2) Tables_in_test (T2)
t2 T2
LOCK TABLE T2 WRITE; LOCK TABLE T2 WRITE;
ALTER TABLE T2 drop b; ALTER TABLE T2 drop b;
SHOW TABLES LIKE "T2"; SHOW TABLES LIKE "T2";
Tables_in_test (T2) Tables_in_test (T2)
t2 T2
UNLOCK TABLES; UNLOCK TABLES;
RENAME TABLE T2 TO T1; RENAME TABLE T2 TO T1;
SHOW TABLES LIKE "T1"; SHOW TABLES LIKE "T1";
Tables_in_test (T1) Tables_in_test (T1)
t1 T1
SELECT * from T1; SELECT * from T1;
a a
1 1
......
...@@ -9,6 +9,7 @@ BEGIN; ...@@ -9,6 +9,7 @@ BEGIN;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize error Lock wait timeout exceeded; try restarting transaction
test.t1 optimize status Operation failed test.t1 optimize status Operation failed
Warnings: Warnings:
Error 1205 Lock wait timeout exceeded; try restarting transaction Error 1205 Lock wait timeout exceeded; try restarting transaction
......
...@@ -523,3 +523,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id ...@@ -523,3 +523,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
ORDER BY t1.id; ORDER BY t1.id;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# Bug #10944: Mishandling of NULL arguments in FIELD()
#
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
select field(NULL,1,2,NULL), field(NULL,1,2,0);
...@@ -2322,11 +2322,13 @@ void Item_func_locate::print(String *str) ...@@ -2322,11 +2322,13 @@ void Item_func_locate::print(String *str)
longlong Item_func_field::val_int() longlong Item_func_field::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (args[0]->is_null())
return 0;
if (cmp_type == STRING_RESULT) if (cmp_type == STRING_RESULT)
{ {
String *field; String *field;
if (!(field=args[0]->val_str(&value)))
return 0; // -1 if null ?
for (uint i=1 ; i < arg_count ; i++) for (uint i=1 ; i < arg_count ; i++)
{ {
String *tmp_value=args[i]->val_str(&tmp); String *tmp_value=args[i]->val_str(&tmp);
...@@ -2337,11 +2339,9 @@ longlong Item_func_field::val_int() ...@@ -2337,11 +2339,9 @@ longlong Item_func_field::val_int()
else if (cmp_type == INT_RESULT) else if (cmp_type == INT_RESULT)
{ {
longlong val= args[0]->val_int(); longlong val= args[0]->val_int();
if (args[0]->is_null())
return 0;
for (uint i=1; i < arg_count ; i++) for (uint i=1; i < arg_count ; i++)
{ {
if (val == args[i]->val_int() && ! args[i]->is_null()) if (!args[i]->is_null() && val == args[i]->val_int())
return (longlong) (i); return (longlong) (i);
} }
} }
...@@ -2349,8 +2349,6 @@ longlong Item_func_field::val_int() ...@@ -2349,8 +2349,6 @@ longlong Item_func_field::val_int()
{ {
my_decimal dec_arg_buf, *dec_arg, my_decimal dec_arg_buf, *dec_arg,
dec_buf, *dec= args[0]->val_decimal(&dec_buf); dec_buf, *dec= args[0]->val_decimal(&dec_buf);
if (args[0]->is_null())
return 0;
for (uint i=1; i < arg_count; i++) for (uint i=1; i < arg_count; i++)
{ {
dec_arg= args[i]->val_decimal(&dec_arg_buf); dec_arg= args[i]->val_decimal(&dec_arg_buf);
...@@ -2361,11 +2359,9 @@ longlong Item_func_field::val_int() ...@@ -2361,11 +2359,9 @@ longlong Item_func_field::val_int()
else else
{ {
double val= args[0]->val_real(); double val= args[0]->val_real();
if (args[0]->is_null())
return 0;
for (uint i=1; i < arg_count ; i++) for (uint i=1; i < arg_count ; i++)
{ {
if (val == args[i]->val_real() && ! args[i]->is_null()) if (!args[i]->is_null() && val == args[i]->val_real())
return (longlong) (i); return (longlong) (i);
} }
} }
......
...@@ -40,6 +40,34 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, ...@@ -40,6 +40,34 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
ha_rows *copied,ha_rows *deleted); ha_rows *copied,ha_rows *deleted);
static bool prepare_blob_field(THD *thd, create_field *sql_field); static bool prepare_blob_field(THD *thd, create_field *sql_field);
/*
Build the path to a file for a table (or the base path that can
then have various extensions stuck on to it).
SYNOPSIS
build_table_path()
buff Buffer to build the path into
bufflen sizeof(buff)
db Name of database
table Name of table
ext Filename extension
RETURN
0 Error
# Size of path
*/
static uint build_table_path(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext)
{
strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext,
NullS);
return unpack_filename(buff,buff);
}
/* /*
delete (drop) tables. delete (drop) tables.
...@@ -223,8 +251,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -223,8 +251,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
} }
alias= (lower_case_table_names == 2) ? table->alias : table->table_name; alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove form file and isam files */ /* remove form file and isam files */
strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); build_table_path(path, sizeof(path), db, alias, reg_ext);
(void) unpack_filename(path,path);
} }
if (drop_temporary || if (drop_temporary ||
(access(path,F_OK) && (access(path,F_OK) &&
...@@ -316,13 +343,10 @@ int quick_rm_table(enum db_type base,const char *db, ...@@ -316,13 +343,10 @@ int quick_rm_table(enum db_type base,const char *db,
{ {
char path[FN_REFLEN]; char path[FN_REFLEN];
int error=0; int error=0;
my_snprintf(path, sizeof(path), "%s/%s/%s%s", build_table_path(path, sizeof(path), db, table_name, reg_ext);
mysql_data_home, db, table_name, reg_ext);
unpack_filename(path,path);
if (my_delete(path,MYF(0))) if (my_delete(path,MYF(0)))
error=1; /* purecov: inspected */ error=1; /* purecov: inspected */
my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, db, table_name); build_table_path(path, sizeof(path), db, table_name, "");
unpack_filename(path,path);
return ha_delete_table(current_thd, base, path, table_name, 0) || error; return ha_delete_table(current_thd, base, path, table_name, 0) || error;
} }
...@@ -1516,11 +1540,9 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1516,11 +1540,9 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!create_info->default_table_charset) if (!create_info->default_table_charset)
{ {
HA_CREATE_INFO db_info; HA_CREATE_INFO db_info;
uint length;
char path[FN_REFLEN]; char path[FN_REFLEN];
strxmov(path, mysql_data_home, "/", db, NullS); /* Abuse build_table_path() to build the path to the db.opt file */
length= unpack_dirname(path,path); // Convert if not unix build_table_path(path, sizeof(path), db, MY_DB_OPT_FILE, "");
strmov(path+length, MY_DB_OPT_FILE);
load_db_opt(thd, path, &db_info); load_db_opt(thd, path, &db_info);
create_info->default_table_charset= db_info.default_table_charset; create_info->default_table_charset= db_info.default_table_charset;
} }
...@@ -1534,17 +1556,18 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1534,17 +1556,18 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check if table exists */ /* Check if table exists */
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{ {
my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s", char tmp_table_name[NAME_LEN+1];
mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id, my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x",
thd->tmp_table++, reg_ext); tmp_file_prefix, current_pid, thd->thread_id,
thd->tmp_table++);
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(files_charset_info, path); my_casedn_str(files_charset_info, tmp_table_name);
create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext);
} }
else else
my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, db, build_table_path(path, sizeof(path), db, alias, reg_ext);
alias, reg_ext);
unpack_filename(path,path);
/* Check if table already exists */ /* Check if table already exists */
if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) if ((create_info->options & HA_LEX_CREATE_TMP_TABLE)
&& find_temporary_table(thd,db,table_name)) && find_temporary_table(thd,db,table_name))
...@@ -1781,40 +1804,43 @@ mysql_rename_table(enum db_type base, ...@@ -1781,40 +1804,43 @@ mysql_rename_table(enum db_type base,
const char *new_db, const char *new_db,
const char *new_name) const char *new_name)
{ {
char from[FN_REFLEN], to[FN_REFLEN]; char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
char tmp_from[NAME_LEN+1], tmp_to[NAME_LEN+1]; char *from_base= from, *to_base= to;
char tmp_name[NAME_LEN+1];
handler *file=(base == DB_TYPE_UNKNOWN ? 0 : get_new_handler((TABLE*) 0, base)); handler *file=(base == DB_TYPE_UNKNOWN ? 0 : get_new_handler((TABLE*) 0, base));
int error=0; int error=0;
DBUG_ENTER("mysql_rename_table"); DBUG_ENTER("mysql_rename_table");
build_table_path(from, sizeof(from), old_db, old_name, "");
build_table_path(to, sizeof(to), new_db, new_name, "");
/*
If lower_case_table_names == 2 (case-preserving but case-insensitive
file system) and the storage is not HA_FILE_BASED, we need to provide
a lowercase file name, but we leave the .frm in mixed case.
*/
if (lower_case_table_names == 2 && file && if (lower_case_table_names == 2 && file &&
!(file->table_flags() & HA_FILE_BASED)) !(file->table_flags() & HA_FILE_BASED))
{ {
/* Table handler expects to get all file names as lower case */ strmov(tmp_name, old_name);
strmov(tmp_from, old_name); my_casedn_str(files_charset_info, tmp_name);
my_casedn_str(files_charset_info, tmp_from); build_table_path(lc_from, sizeof(lc_from), old_db, tmp_name, "");
old_name= tmp_from; from_base= lc_from;
strmov(tmp_to, new_name); strmov(tmp_name, new_name);
my_casedn_str(files_charset_info, tmp_to); my_casedn_str(files_charset_info, tmp_name);
new_name= tmp_to; build_table_path(lc_to, sizeof(lc_to), new_db, tmp_name, "");
to_base= lc_to;
} }
my_snprintf(from, sizeof(from), "%s/%s/%s",
mysql_data_home, old_db, old_name);
my_snprintf(to, sizeof(to), "%s/%s/%s",
mysql_data_home, new_db, new_name);
fn_format(from,from,"","",4);
fn_format(to,to, "","",4);
if (!file || if (!file || !(error=file->rename_table(from_base, to_base)))
!(error=file->rename_table((const char*) from,(const char *) to)))
{ {
if (rename_file_ext(from,to,reg_ext)) if (rename_file_ext(from,to,reg_ext))
{ {
error=my_errno; error=my_errno;
/* Restore old file name */ /* Restore old file name */
if (file) if (file)
file->rename_table((const char*) to,(const char *) from); file->rename_table(to_base, from_base);
} }
} }
delete file; delete file;
...@@ -1991,8 +2017,8 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, ...@@ -1991,8 +2017,8 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list,
if (!(table= table_list->table)) /* if open_ltable failed */ if (!(table= table_list->table)) /* if open_ltable failed */
{ {
char name[FN_REFLEN]; char name[FN_REFLEN];
strxmov(name, mysql_data_home, "/", table_list->db, "/", build_table_path(name, sizeof(name), table_list->db,
table_list->table_name, NullS); table_list->table_name, "");
if (openfrm(thd, name, "", 0, 0, 0, &tmp_table)) if (openfrm(thd, name, "", 0, 0, 0, &tmp_table))
DBUG_RETURN(0); // Can't open frm file DBUG_RETURN(0); // Can't open frm file
table= &tmp_table; table= &tmp_table;
...@@ -2327,6 +2353,28 @@ send_result_message: ...@@ -2327,6 +2353,28 @@ send_result_message:
((result_code= table->table->file->analyze(thd, check_opt)) > 0)) ((result_code= table->table->file->analyze(thd, check_opt)) > 0))
result_code= 0; // analyze went ok result_code= 0; // analyze went ok
} }
if (result_code) // either mysql_recreate_table or analyze failed
{
const char *err_msg;
if ((err_msg= thd->net.last_error))
{
if (!thd->vio_ok())
{
sql_print_error(err_msg);
}
else
{
/* Hijack the row already in-progress. */
protocol->store("error", 5, system_charset_info);
protocol->store(err_msg, system_charset_info);
(void)protocol->write();
/* Start off another row for HA_ADMIN_FAILED */
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
}
}
}
result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK; result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK;
table->next_local= save_next_local; table->next_local= save_next_local;
table->next_global= save_next_global; table->next_global= save_next_global;
...@@ -2858,11 +2906,10 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys) ...@@ -2858,11 +2906,10 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
else else
{ {
if (table->file->add_index(table, key_info_buffer, key_count)|| if (table->file->add_index(table, key_info_buffer, key_count)||
(my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, build_table_path(path, sizeof(path), table_list->db,
table_list->db, (lower_case_table_names == 2) ? (lower_case_table_names == 2) ?
table_list->alias: table_list->table_name, reg_ext) >= table_list->alias : table_list->table_name,
(int) sizeof(path)) || reg_ext) != 0 ||
! unpack_filename(path, path) ||
mysql_create_frm(thd, path, &create_info, mysql_create_frm(thd, path, &create_info,
fields, key_count, key_info_buffer, table->file)) fields, key_count, key_info_buffer, table->file))
/* don't need to free((gptr) key_info_buffer);*/ /* don't need to free((gptr) key_info_buffer);*/
...@@ -2960,11 +3007,10 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, ...@@ -2960,11 +3007,10 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
&keys, /*tmp_table*/ 0, &db_options, table->file, &keys, /*tmp_table*/ 0, &db_options, table->file,
&key_info_buffer, key_count, &key_info_buffer, key_count,
/*select_field_count*/ 0)|| /*select_field_count*/ 0)||
(snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, build_table_path(path, sizeof(path), table_list->db,
table_list->db, (lower_case_table_names == 2)? (lower_case_table_names == 2) ?
table_list->alias: table_list->table_name, reg_ext)>= table_list->alias : table_list->table_name,
(int)sizeof(path))|| reg_ext) != 0 ||
! unpack_filename(path, path)||
mysql_create_frm(thd, path, &create_info, mysql_create_frm(thd, path, &create_info,
fields, key_count, key_info_buffer, table->file)) fields, key_count, key_info_buffer, table->file))
/*don't need to free((gptr) key_numbers);*/ /*don't need to free((gptr) key_numbers);*/
...@@ -3718,9 +3764,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3718,9 +3764,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
shutdown. shutdown.
*/ */
char path[FN_REFLEN]; char path[FN_REFLEN];
my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, build_table_path(path, sizeof(path), new_db, table_name);
new_db, table_name);
fn_format(path,path,"","",4);
table=open_temporary_table(thd, path, new_db, tmp_name,0); table=open_temporary_table(thd, path, new_db, tmp_name,0);
if (table) if (table)
{ {
......
...@@ -128,26 +128,32 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) ...@@ -128,26 +128,32 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size)
int vio_ssl_fastsend(Vio * vio __attribute__((unused))) int vio_ssl_fastsend(Vio * vio __attribute__((unused)))
{ {
int r= 0; int r=0;
DBUG_ENTER("vio_ssl_fastsend"); DBUG_ENTER("vio_ssl_fastsend");
#ifdef IPTOS_THROUGHPUT #if defined(IPTOS_THROUGHPUT) && !defined(__EMX__)
{
#ifndef __EMX__
int tos = IPTOS_THROUGHPUT;
if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)))
#endif /* !__EMX__ */
{ {
int nodelay = 1; int tos= IPTOS_THROUGHPUT;
if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos));
sizeof(nodelay))) {
DBUG_PRINT("warning",
("Couldn't set socket option for fast send"));
r= -1;
} }
#endif /* IPTOS_THROUGHPUT && !__EMX__ */
if (!r)
{
#ifdef __WIN__
BOOL nodelay= 1;
r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay,
sizeof(nodelay));
#else
int nodelay= 1;
r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay,
sizeof(nodelay));
#endif /* __WIN__ */
} }
if (r)
{
DBUG_PRINT("warning", ("Couldn't set socket option for fast send"));
r= -1;
} }
#endif /* IPTOS_THROUGHPUT */
DBUG_PRINT("exit", ("%d", r)); DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r); DBUG_RETURN(r);
} }
...@@ -427,6 +433,11 @@ void vio_ssl_timeout(Vio *vio __attribute__((unused)), ...@@ -427,6 +433,11 @@ void vio_ssl_timeout(Vio *vio __attribute__((unused)),
uint which __attribute__((unused)), uint which __attribute__((unused)),
uint timeout __attribute__((unused))) uint timeout __attribute__((unused)))
{ {
/* Not yet implemented (non critical) */ #ifdef __WIN__
ulong wait_timeout= (ulong) timeout * 1000;
(void) setsockopt(vio->sd, SOL_SOCKET,
which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout,
sizeof(wait_timeout));
#endif /* __WIN__ */
} }
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment