Loading include/mysql_com.h +5 −5 Original line number Diff line number Diff line Loading @@ -391,7 +391,7 @@ typedef struct st_udf_init unsigned int decimals; /* for real functions */ unsigned long max_length; /* For string functions */ char *ptr; /* free pointer for function data */ my_bool const_item; /* 0 if result is independent of arguments */ my_bool const_item; /* 1 if function always returns the same value */ } UDF_INIT; /* TODO: add a notion for determinism of the UDF. Loading libmysqld/lib_sql.cc +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data) net->last_errno= ei->last_errno; strmake(net->last_error, ei->info, sizeof(net->last_error)); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); mysql->server_status= ei->server_status; my_free((gptr) data, MYF(0)); } Loading Loading @@ -1027,6 +1028,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) ei->last_errno= sql_errno; strmake(ei->info, err, sizeof(ei->info)-1); strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno)); ei->server_status= thd->server_status; thd->cur_data= 0; } Loading mysql-test/r/federated.result +111 −0 Original line number Diff line number Diff line Loading @@ -1934,6 +1934,117 @@ select * from federated.t2; a 1 drop table federated.t1, federated.t2; 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 DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; Loading mysql-test/t/federated.test +31 −0 Original line number Diff line number Diff line Loading @@ -1686,4 +1686,35 @@ insert into federated.t1 (a) values (1); select * from federated.t2; drop table federated.t1, federated.t2; # # 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; source include/federated_cleanup.inc; sql/ha_federated.cc +18 −0 Original line number Diff line number Diff line Loading @@ -2166,6 +2166,24 @@ int ha_federated::index_read_idx_with_result_set(byte *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()) */ int ha_federated::index_init(uint keynr) Loading Loading
include/mysql_com.h +5 −5 Original line number Diff line number Diff line Loading @@ -391,7 +391,7 @@ typedef struct st_udf_init unsigned int decimals; /* for real functions */ unsigned long max_length; /* For string functions */ char *ptr; /* free pointer for function data */ my_bool const_item; /* 0 if result is independent of arguments */ my_bool const_item; /* 1 if function always returns the same value */ } UDF_INIT; /* TODO: add a notion for determinism of the UDF. Loading
libmysqld/lib_sql.cc +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data) net->last_errno= ei->last_errno; strmake(net->last_error, ei->info, sizeof(net->last_error)); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); mysql->server_status= ei->server_status; my_free((gptr) data, MYF(0)); } Loading Loading @@ -1027,6 +1028,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) ei->last_errno= sql_errno; strmake(ei->info, err, sizeof(ei->info)-1); strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno)); ei->server_status= thd->server_status; thd->cur_data= 0; } Loading
mysql-test/r/federated.result +111 −0 Original line number Diff line number Diff line Loading @@ -1934,6 +1934,117 @@ select * from federated.t2; a 1 drop table federated.t1, federated.t2; 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 DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; Loading
mysql-test/t/federated.test +31 −0 Original line number Diff line number Diff line Loading @@ -1686,4 +1686,35 @@ insert into federated.t1 (a) values (1); select * from federated.t2; drop table federated.t1, federated.t2; # # 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; source include/federated_cleanup.inc;
sql/ha_federated.cc +18 −0 Original line number Diff line number Diff line Loading @@ -2166,6 +2166,24 @@ int ha_federated::index_read_idx_with_result_set(byte *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()) */ int ha_federated::index_init(uint keynr) Loading