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)
DYNAMIC_STRING ds_tmp;
DYNAMIC_STRING eval_query;
char* query;
int query_len;
int query_len, got_error_on_send= 0;
DBUG_ENTER("run_query");
if (q->type != Q_EVAL)
......@@ -2179,9 +2179,13 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
else
ds= &ds_res;
if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len))
die("At line %u: unable to send query '%s'(mysql_errno=%d,errno=%d)",
start_lineno, query, mysql_errno(mysql), errno);
if (flags & QUERY_SEND)
{
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);
}
do
{
......@@ -2194,9 +2198,10 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
if (!(flags & QUERY_REAP))
DBUG_RETURN(0);
if ((!counter && (*mysql->methods->read_query_result)(mysql)) ||
(!(last_result= res= mysql_store_result(mysql)) &&
mysql_field_count(mysql)))
if (got_error_on_send ||
(!counter && (*mysql->methods->read_query_result)(mysql)) ||
(!(last_result= res= mysql_store_result(mysql)) &&
mysql_field_count(mysql)))
{
if (q->require_file)
{
......
......@@ -198,6 +198,8 @@ USER_TEST=
EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
EXTRA_MYSQLDUMP_OPT=""
EXTRA_MYSQLBINLOG_OPT=""
USE_RUNNING_SERVER=""
DO_GCOV=""
DO_GDB=""
......@@ -373,6 +375,10 @@ while test $# -gt 0; do
--debug=d:t:i:A,$MYSQL_TEST_DIR/var/log/slave.trace"
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT \
--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_START=1
......@@ -490,8 +496,8 @@ else
fi
fi
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR"
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK $EXTRA_MYSQLDUMP_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
export MYSQL_DUMP
export MYSQL_BINLOG
......
......@@ -20,5 +20,5 @@ hex(a)
616263
set GLOBAL init_connect="adsfsdfsdfs";
select @a;
ERROR HY000: Lost connection to MySQL server during query
Got one of the listed errors
drop table t1;
......@@ -584,3 +584,9 @@ CREATE TABLE t1 (a INT, b INT);
SET @id=0;
UPDATE t1 SET a=0 ORDER BY (a=@id), b;
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;
set GLOBAL init_connect="adsfsdfsdfs";
connect (con5,localhost,user_1,,);
connection con5;
--error 2013
--error 2013,2006
select @a;
connection con0;
drop table t1;
......@@ -373,3 +373,11 @@ SET @id=0;
UPDATE t1 SET a=0 ORDER BY (a=@id), b;
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,
records=table->file->estimate_number_of_rows();
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 &&
!(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,
DISK_BUFFER_SIZE, MYF(MY_WME)))
goto err;
param.keys--;
param.keys--; /* TODO: check why we do this */
param.sort_form= table;
param.end=(param.local_sortorder=sortorder)+s_length;
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,
if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
DBUG_RETURN(HA_POS_ERROR);
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++;
}
make_sortkey(param,sort_keys[idx++],ref_pos);
......
......@@ -129,7 +129,7 @@ class Item {
virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */
void set_name(const char *str,uint length, CHARSET_INFO *cs);
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 bool fix_fields(THD *, struct st_table_list *, Item **);
virtual int save_in_field(Field *field, bool no_conversions);
......
......@@ -1782,17 +1782,25 @@ char *ull_get_key(const ULL *ull,uint *length,
return (char*) ull->key;
}
static bool item_user_lock_inited= 0;
void item_user_lock_init(void)
{
pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
hash_init(&hash_user_locks,system_charset_info,
16,0,0,(hash_get_key) ull_get_key,NULL,0);
item_user_lock_inited= 1;
}
void item_user_lock_free(void)
{
hash_free(&hash_user_locks);
pthread_mutex_destroy(&LOCK_user_locks);
if (item_user_lock_inited)
{
item_user_lock_inited= 0;
hash_free(&hash_user_locks);
pthread_mutex_destroy(&LOCK_user_locks);
}
}
void item_user_lock_release(ULL *ull)
......@@ -2452,7 +2460,7 @@ Item_func_get_user_var::val_str(String *str)
{
DBUG_ENTER("Item_func_get_user_var::val_str");
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));
}
......
......@@ -3080,13 +3080,13 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
float8get(real_val, val);
it= new Item_real(real_val);
val= (char*) &real_val; // Pointer to value in native format
val_len= sizeof(real_val);
val_len= 8;
break;
case INT_RESULT:
int_val= (longlong) uint8korr(val);
it= new Item_int(int_val);
val= (char*) &int_val; // Pointer to value in native format
val_len= sizeof(int_val);
val_len= 8;
break;
case STRING_RESULT:
it= new Item_string(val, val_len, charset);
......
......@@ -847,8 +847,11 @@ class THD :public ilink,
inline void end_time() { time(&start_time); }
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 insert_id(ulonglong id)
{ last_insert_id=id; insert_id_used=1; }
inline void insert_id(ulonglong id_arg)
{
last_insert_id= id_arg;
insert_id_used=1;
}
inline ulonglong insert_id(void)
{
if (!last_insert_id_used)
......
......@@ -888,7 +888,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
{
LEX *lex;
Prepared_statement *stmt= new Prepared_statement(thd);
SELECT_LEX *sl;
DBUG_ENTER("mysql_stmt_prepare");
if (stmt == 0)
......@@ -919,7 +919,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
my_pthread_setprio(pthread_self(),WAIT_PRIOR);
// 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->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