Commit 2ffbfe27 authored by monty@mysql.com's avatar monty@mysql.com

Merge mysql.com:/my/mysql-4.1 into mysql.com:/my/mysql-5.0

parents d15f2426 5eb92715
...@@ -2154,7 +2154,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) ...@@ -2154,7 +2154,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
DYNAMIC_STRING ds_tmp; DYNAMIC_STRING ds_tmp;
DYNAMIC_STRING eval_query; DYNAMIC_STRING eval_query;
char* query; char* query;
int query_len; int query_len, got_error_on_send= 0;
DBUG_ENTER("run_query"); DBUG_ENTER("run_query");
if (q->type != Q_EVAL) if (q->type != Q_EVAL)
...@@ -2179,9 +2179,13 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) ...@@ -2179,9 +2179,13 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
else else
ds= &ds_res; ds= &ds_res;
if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len)) if (flags & QUERY_SEND)
die("At line %u: unable to send query '%s'(mysql_errno=%d,errno=%d)", {
got_error_on_send= mysql_send_query(mysql, query, query_len);
if (got_error_on_send && !q->expected_errno[0])
die("At line %u: unable to send query '%s' (mysql_errno=%d , errno=%d)",
start_lineno, query, mysql_errno(mysql), errno); start_lineno, query, mysql_errno(mysql), errno);
}
do do
{ {
...@@ -2194,7 +2198,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) ...@@ -2194,7 +2198,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
if (!(flags & QUERY_REAP)) if (!(flags & QUERY_REAP))
DBUG_RETURN(0); DBUG_RETURN(0);
if ((!counter && (*mysql->methods->read_query_result)(mysql)) || if (got_error_on_send ||
(!counter && (*mysql->methods->read_query_result)(mysql)) ||
(!(last_result= res= mysql_store_result(mysql)) && (!(last_result= res= mysql_store_result(mysql)) &&
mysql_field_count(mysql))) mysql_field_count(mysql)))
{ {
......
...@@ -198,6 +198,8 @@ USER_TEST= ...@@ -198,6 +198,8 @@ USER_TEST=
EXTRA_MASTER_OPT="" EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT="" EXTRA_MYSQL_TEST_OPT=""
EXTRA_MYSQLDUMP_OPT=""
EXTRA_MYSQLBINLOG_OPT=""
USE_RUNNING_SERVER="" USE_RUNNING_SERVER=""
DO_GCOV="" DO_GCOV=""
DO_GDB="" DO_GDB=""
...@@ -373,6 +375,10 @@ while test $# -gt 0; do ...@@ -373,6 +375,10 @@ while test $# -gt 0; do
--debug=d:t:i:A,$MYSQL_TEST_DIR/var/log/slave.trace" --debug=d:t:i:A,$MYSQL_TEST_DIR/var/log/slave.trace"
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT \ EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT \
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqltest.trace" --debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqltest.trace"
EXTRA_MYSQLDUMP_OPT="$EXTRA_MYSQLDUMP_OPT \
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqldump.trace"
EXTRA_MYSQLBINLOG_OPT="$EXTRA_MYSQLBINLOG_OPT \
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqlbinlog.trace"
;; ;;
--fast) --fast)
FAST_START=1 FAST_START=1
...@@ -490,8 +496,8 @@ else ...@@ -490,8 +496,8 @@ else
fi fi
fi fi
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK" MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK $EXTRA_MYSQLDUMP_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
export MYSQL_DUMP export MYSQL_DUMP
export MYSQL_BINLOG export MYSQL_BINLOG
......
...@@ -20,5 +20,5 @@ hex(a) ...@@ -20,5 +20,5 @@ hex(a)
616263 616263
set GLOBAL init_connect="adsfsdfsdfs"; set GLOBAL init_connect="adsfsdfsdfs";
select @a; select @a;
ERROR HY000: Lost connection to MySQL server during query Got one of the listed errors
drop table t1; drop table t1;
...@@ -584,3 +584,9 @@ CREATE TABLE t1 (a INT, b INT); ...@@ -584,3 +584,9 @@ CREATE TABLE t1 (a INT, b INT);
SET @id=0; SET @id=0;
UPDATE t1 SET a=0 ORDER BY (a=@id), b; UPDATE t1 SET a=0 ORDER BY (a=@id), b;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
id
11392
drop table t1;
--set-variable=init_connect="set @a='a\0c'" --set-variable=init_connect="set @a='a\\0c'"
...@@ -28,7 +28,7 @@ connection con0; ...@@ -28,7 +28,7 @@ connection con0;
set GLOBAL init_connect="adsfsdfsdfs"; set GLOBAL init_connect="adsfsdfsdfs";
connect (con5,localhost,user_1,,); connect (con5,localhost,user_1,,);
connection con5; connection con5;
--error 2013 --error 2013,2006
select @a; select @a;
connection con0; connection con0;
drop table t1; drop table t1;
...@@ -373,3 +373,11 @@ SET @id=0; ...@@ -373,3 +373,11 @@ SET @id=0;
UPDATE t1 SET a=0 ORDER BY (a=@id), b; UPDATE t1 SET a=0 ORDER BY (a=@id), b;
DROP TABLE t1; DROP TABLE t1;
#
# Bug when doing an order by on a 1 byte string (Bug #2147)
#
CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
drop table t1;
...@@ -161,8 +161,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -161,8 +161,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
records=table->file->estimate_number_of_rows(); records=table->file->estimate_number_of_rows();
selected_records_file= 0; selected_records_file= 0;
} }
if (param.rec_length == param.ref_length && records > param.max_rows)
records=param.max_rows; /* purecov: inspected */
if (multi_byte_charset && if (multi_byte_charset &&
!(param.tmp_buffer=my_malloc(param.sort_length,MYF(MY_WME)))) !(param.tmp_buffer=my_malloc(param.sort_length,MYF(MY_WME))))
...@@ -192,7 +190,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -192,7 +190,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
DISK_BUFFER_SIZE, MYF(MY_WME))) DISK_BUFFER_SIZE, MYF(MY_WME)))
goto err; goto err;
param.keys--; param.keys--; /* TODO: check why we do this */
param.sort_form= table; param.sort_form= table;
param.end=(param.local_sortorder=sortorder)+s_length; param.end=(param.local_sortorder=sortorder)+s_length;
if ((records=find_all_keys(&param,select,sort_keys, &buffpek_pointers, if ((records=find_all_keys(&param,select,sort_keys, &buffpek_pointers,
...@@ -432,16 +430,6 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -432,16 +430,6 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile)) if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
idx=0; idx=0;
if (param->ref_length == param->rec_length &&
my_b_tell(tempfile)/param->rec_length >= param->max_rows)
{
/*
We are writing the result index file and have found all
rows that we need. Abort the sort and return the result.
*/
error=HA_ERR_END_OF_FILE;
break; /* Found enough records */
}
indexpos++; indexpos++;
} }
make_sortkey(param,sort_keys[idx++],ref_pos); make_sortkey(param,sort_keys[idx++],ref_pos);
......
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */ virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */
void set_name(const char *str,uint length, CHARSET_INFO *cs); void set_name(const char *str,uint length, CHARSET_INFO *cs);
void init_make_field(Send_field *tmp_field,enum enum_field_types type); void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup() {} virtual void cleanup() { fixed=0; }
virtual void make_field(Send_field *field); virtual void make_field(Send_field *field);
virtual bool fix_fields(THD *, struct st_table_list *, Item **); virtual bool fix_fields(THD *, struct st_table_list *, Item **);
virtual int save_in_field(Field *field, bool no_conversions); virtual int save_in_field(Field *field, bool no_conversions);
......
...@@ -1782,17 +1782,25 @@ char *ull_get_key(const ULL *ull,uint *length, ...@@ -1782,17 +1782,25 @@ char *ull_get_key(const ULL *ull,uint *length,
return (char*) ull->key; return (char*) ull->key;
} }
static bool item_user_lock_inited= 0;
void item_user_lock_init(void) void item_user_lock_init(void)
{ {
pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW); pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
hash_init(&hash_user_locks,system_charset_info, hash_init(&hash_user_locks,system_charset_info,
16,0,0,(hash_get_key) ull_get_key,NULL,0); 16,0,0,(hash_get_key) ull_get_key,NULL,0);
item_user_lock_inited= 1;
} }
void item_user_lock_free(void) void item_user_lock_free(void)
{ {
if (item_user_lock_inited)
{
item_user_lock_inited= 0;
hash_free(&hash_user_locks); hash_free(&hash_user_locks);
pthread_mutex_destroy(&LOCK_user_locks); pthread_mutex_destroy(&LOCK_user_locks);
}
} }
void item_user_lock_release(ULL *ull) void item_user_lock_release(ULL *ull)
...@@ -2452,7 +2460,7 @@ Item_func_get_user_var::val_str(String *str) ...@@ -2452,7 +2460,7 @@ Item_func_get_user_var::val_str(String *str)
{ {
DBUG_ENTER("Item_func_get_user_var::val_str"); DBUG_ENTER("Item_func_get_user_var::val_str");
if (!var_entry) if (!var_entry)
return (String*) 0; // No such variable DBUG_RETURN((String*) 0); // No such variable
DBUG_RETURN(var_entry->val_str(&null_value, str, decimals)); DBUG_RETURN(var_entry->val_str(&null_value, str, decimals));
} }
......
...@@ -3080,13 +3080,13 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -3080,13 +3080,13 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
float8get(real_val, val); float8get(real_val, val);
it= new Item_real(real_val); it= new Item_real(real_val);
val= (char*) &real_val; // Pointer to value in native format val= (char*) &real_val; // Pointer to value in native format
val_len= sizeof(real_val); val_len= 8;
break; break;
case INT_RESULT: case INT_RESULT:
int_val= (longlong) uint8korr(val); int_val= (longlong) uint8korr(val);
it= new Item_int(int_val); it= new Item_int(int_val);
val= (char*) &int_val; // Pointer to value in native format val= (char*) &int_val; // Pointer to value in native format
val_len= sizeof(int_val); val_len= 8;
break; break;
case STRING_RESULT: case STRING_RESULT:
it= new Item_string(val, val_len, charset); it= new Item_string(val, val_len, charset);
......
...@@ -847,8 +847,11 @@ public: ...@@ -847,8 +847,11 @@ public:
inline void end_time() { time(&start_time); } inline void end_time() { time(&start_time); }
inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; } inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
inline void lock_time() { time(&time_after_lock); } inline void lock_time() { time(&time_after_lock); }
inline void insert_id(ulonglong id) inline void insert_id(ulonglong id_arg)
{ last_insert_id=id; insert_id_used=1; } {
last_insert_id= id_arg;
insert_id_used=1;
}
inline ulonglong insert_id(void) inline ulonglong insert_id(void)
{ {
if (!last_insert_id_used) if (!last_insert_id_used)
......
...@@ -888,7 +888,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) ...@@ -888,7 +888,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
{ {
LEX *lex; LEX *lex;
Prepared_statement *stmt= new Prepared_statement(thd); Prepared_statement *stmt= new Prepared_statement(thd);
SELECT_LEX *sl;
DBUG_ENTER("mysql_stmt_prepare"); DBUG_ENTER("mysql_stmt_prepare");
if (stmt == 0) if (stmt == 0)
...@@ -919,7 +919,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) ...@@ -919,7 +919,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
my_pthread_setprio(pthread_self(),WAIT_PRIOR); my_pthread_setprio(pthread_self(),WAIT_PRIOR);
// save WHERE clause pointers to avoid damaging they by optimisation // save WHERE clause pointers to avoid damaging they by optimisation
for (SELECT_LEX *sl= thd->lex->all_selects_list; for (sl= thd->lex->all_selects_list;
sl; sl;
sl= sl->next_select_in_list()) sl= sl->next_select_in_list())
{ {
......
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