Commit 34de3070 authored by holyfoot/hf@hfmain.(none)'s avatar holyfoot/hf@hfmain.(none)

Merge mysql.com:/home/hf/work/mrg/my50-mrg

into  mysql.com:/home/hf/work/mrg/my51-mrg
parents a756bfd4 ad52a590
...@@ -401,8 +401,7 @@ typedef struct st_udf_init ...@@ -401,8 +401,7 @@ typedef struct st_udf_init
unsigned int decimals; /* for real functions */ unsigned int decimals; /* for real functions */
unsigned long max_length; /* For string functions */ unsigned long max_length; /* For string functions */
char *ptr; /* free pointer for function data */ char *ptr; /* free pointer for function data */
/* 0 if result is independent of arguments */ my_bool const_item; /* 1 if function always returns the same value */
my_bool const_item;
void *extension; void *extension;
} UDF_INIT; } UDF_INIT;
/* /*
......
...@@ -64,6 +64,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data) ...@@ -64,6 +64,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
net->last_errno= ei->last_errno; net->last_errno= ei->last_errno;
strmake(net->last_error, ei->info, sizeof(net->last_error)); strmake(net->last_error, ei->info, sizeof(net->last_error));
memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate));
mysql->server_status= ei->server_status;
my_free(data, MYF(0)); my_free(data, MYF(0));
} }
...@@ -1029,6 +1030,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) ...@@ -1029,6 +1030,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
ei->last_errno= sql_errno; ei->last_errno= sql_errno;
strmake(ei->info, err, sizeof(ei->info)-1); strmake(ei->info, err, sizeof(ei->info)-1);
strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno)); strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno));
ei->server_status= thd->server_status;
thd->cur_data= 0; thd->cur_data= 0;
} }
......
...@@ -1956,6 +1956,117 @@ a ...@@ -1956,6 +1956,117 @@ a
DROP TABLE federated.t1; DROP TABLE federated.t1;
DROP TABLE federated.t1; DROP TABLE federated.t1;
End of 5.1 tests End of 5.1 tests
create table t1 (a varchar(256));
drop view if exists v1;
create view v1 as select a from t1;
create table t1
(a varchar(256)) engine=federated
connection='mysql://root@127.0.0.1:SLAVE_PORT/test/v1';
select 1 from t1 order by a;
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
drop table t1;
drop table t1;
drop view v1;
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
......
...@@ -1764,6 +1764,35 @@ DROP TABLE federated.t1; ...@@ -1764,6 +1764,35 @@ DROP TABLE federated.t1;
connection slave; connection slave;
DROP TABLE federated.t1; DROP TABLE federated.t1;
--echo End of 5.1 tests #
# Bug #32374 crash with filesort when selecting from federated table and view
#
connection slave;
create table t1 (a varchar(256));
--disable_warnings
drop view if exists v1;
--enable_warnings
create view v1 as select a from t1;
--disable_query_log
let $n= 100;
while ($n)
{
insert into t1 values (repeat('a',200));
dec $n;
}
--enable_query_log
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create table t1
(a varchar(256)) engine=federated
connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/v1';
select 1 from t1 order by a;
drop table t1;
connection slave;
drop table t1;
drop view v1;
--echo End of 5.1 tests
source include/federated_cleanup.inc; source include/federated_cleanup.inc;
...@@ -174,7 +174,7 @@ typedef fp_except fp_except_t; ...@@ -174,7 +174,7 @@ typedef fp_except fp_except_t;
this on freebsd this on freebsd
*/ */
inline void reset_floating_point_exceptions() inline void set_proper_floating_point_mode()
{ {
/* Don't fall for overflow, underflow,divide-by-zero or loss of precision */ /* Don't fall for overflow, underflow,divide-by-zero or loss of precision */
#if defined(__i386__) #if defined(__i386__)
...@@ -185,8 +185,22 @@ inline void reset_floating_point_exceptions() ...@@ -185,8 +185,22 @@ inline void reset_floating_point_exceptions()
FP_X_IMP)); FP_X_IMP));
#endif #endif
} }
#elif defined(__sgi)
/* for IRIX to use set_fpc_csr() */
#include <sys/fpu.h>
inline void set_proper_floating_point_mode()
{
/* Enable denormalized DOUBLE values support for IRIX */
{
union fpc_csr n;
n.fc_word = get_fpc_csr();
n.fc_struct.flush = 0;
set_fpc_csr(n.fc_word);
}
}
#else #else
#define reset_floating_point_exceptions() #define set_proper_floating_point_mode()
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ #endif /* __FreeBSD__ && HAVE_IEEEFP_H */
} /* cplusplus */ } /* cplusplus */
...@@ -3244,7 +3258,7 @@ static int init_server_components() ...@@ -3244,7 +3258,7 @@ static int init_server_components()
query_cache_init(); query_cache_init();
query_cache_resize(query_cache_size); query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2); randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
reset_floating_point_exceptions(); set_proper_floating_point_mode();
init_thr_lock(); init_thr_lock();
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
init_slave_list(); init_slave_list();
......
...@@ -110,13 +110,14 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -110,13 +110,14 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
} }
/* Abort multi-result sets */
thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
net_send_error_packet(thd, sql_errno, err); net_send_error_packet(thd, sql_errno, err);
thd->is_fatal_error= 0; // Error message is given thd->is_fatal_error= 0; // Error message is given
thd->net.report_error= 0; thd->net.report_error= 0;
/* Abort multi-result sets */
thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -2408,6 +2408,24 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index, ...@@ -2408,6 +2408,24 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index,
} }
/*
This method is used exlusevely by filesort() to check if we
can create sorting buffers of necessary size.
If the handler returns more records that it declares
here server can just crash on filesort().
We cannot guarantee that's not going to happen with
the FEDERATED engine, as we have records==0 always if the
client is a VIEW, and for the table the number of
records can inpredictably change during execution.
So we return maximum possible value here.
*/
ha_rows ha_federated::estimate_rows_upper_bound()
{
return HA_POS_ERROR;
}
/* Initialized at each key walk (called multiple times unlike rnd_init()) */ /* Initialized at each key walk (called multiple times unlike rnd_init()) */
int ha_federated::index_init(uint keynr, bool sorted) int ha_federated::index_init(uint keynr, bool sorted)
......
...@@ -210,6 +210,7 @@ class ha_federated: public handler ...@@ -210,6 +210,7 @@ class ha_federated: public handler
int update_row(const uchar *old_data, uchar *new_data); int update_row(const uchar *old_data, uchar *new_data);
int delete_row(const uchar *buf); int delete_row(const uchar *buf);
int index_init(uint keynr, bool sorted); int index_init(uint keynr, bool sorted);
ha_rows estimate_rows_upper_bound();
int index_read(uchar *buf, const uchar *key, int index_read(uchar *buf, const uchar *key,
uint key_len, enum ha_rkey_function find_flag); uint key_len, enum ha_rkey_function find_flag);
int index_read_idx(uchar *buf, uint idx, const uchar *key, int index_read_idx(uchar *buf, uint idx, const uchar *key,
......
...@@ -5914,6 +5914,20 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -5914,6 +5914,20 @@ DROP TABLE IF EXISTS test_multi_tab";
(void) my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
/*
Check if errors in one of the queries handled properly.
*/
rc= mysql_query(mysql_local, "select 1; select * from not_existing_table");
myquery(rc);
result= mysql_store_result(mysql_local);
mysql_free_result(result);
rc= mysql_next_result(mysql_local);
DIE_UNLESS(rc > 0);
rc= mysql_next_result(mysql_local);
DIE_UNLESS(rc < 0);
mysql_close(mysql_local); mysql_close(mysql_local);
} }
......
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