summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/error_simulation.result2
-rw-r--r--mysql-test/r/func_misc.result10
-rw-r--r--mysql-test/r/union_crash-714.result5
-rw-r--r--mysql-test/suite/sphinx/suite.pm1
-rw-r--r--mysql-test/suite/sphinx/union-5539.result10
-rw-r--r--mysql-test/suite/sphinx/union-5539.test16
-rw-r--r--mysql-test/t/error_simulation.test2
-rw-r--r--mysql-test/t/func_misc.test11
-rw-r--r--mysql-test/t/union_crash-714.test9
-rw-r--r--sql/item.cc31
-rw-r--r--sql/item_subselect.cc9
-rw-r--r--sql/item_subselect.h1
-rw-r--r--sql/scheduler.cc1
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_union.cc3
15 files changed, 85 insertions, 34 deletions
diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result
index d2f5a24ef1d..8c16ebf482e 100644
--- a/mysql-test/r/error_simulation.result
+++ b/mysql-test/r/error_simulation.result
@@ -94,7 +94,7 @@ INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES (1),(2);
SET SESSION debug_dbug="+d,bug11747970_raise_error";
INSERT IGNORE INTO t2 SELECT f1 FROM t1 a WHERE NOT EXISTS (SELECT 1 FROM t2 b WHERE a.f1 = b.f1);
-ERROR HY000: Unknown error
+ERROR 70100: Query execution was interrupted
SET SESSION debug_dbug = DEFAULT;
DROP TABLE t1,t2;
#
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index 55b0f9d3c57..34bab225276 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -264,6 +264,13 @@ INET_NTOA(0)
SELECT '1' IN ('1', INET_NTOA(0));
'1' IN ('1', INET_NTOA(0))
1
+SELECT NAME_CONST('a', -(1 OR 2)) OR 1;
+ERROR HY000: Incorrect arguments to NAME_CONST
+SELECT NAME_CONST('a', -(1 AND 2)) AND 1;
+ERROR HY000: Incorrect arguments to NAME_CONST
+SELECT NAME_CONST('a', -(1)) OR 1;
+NAME_CONST('a', -(1)) OR 1
+1
#
# Bug #52165: Assertion failed: file .\dtoa.c, line 465
#
@@ -340,6 +347,3 @@ drop table t1,tv;
#
# End of 5.5 tests
#
-#
-# End of tests
-#
diff --git a/mysql-test/r/union_crash-714.result b/mysql-test/r/union_crash-714.result
new file mode 100644
index 00000000000..4a51f88b76f
--- /dev/null
+++ b/mysql-test/r/union_crash-714.result
@@ -0,0 +1,5 @@
+create table t1 (i tinyint);
+set debug_dbug='+d,bug11747970_raise_error';
+insert into t1 (i) select i from t1 union select i from t1;
+ERROR 70100: Query execution was interrupted
+drop table t1;
diff --git a/mysql-test/suite/sphinx/suite.pm b/mysql-test/suite/sphinx/suite.pm
index f9787d80aa3..91795803ff3 100644
--- a/mysql-test/suite/sphinx/suite.pm
+++ b/mysql-test/suite/sphinx/suite.pm
@@ -60,6 +60,7 @@ sub searchd_start {
my ($sphinx, $test) = @_; # My::Config::Group, My::Test
return unless $exe_sphinx_indexer and $exe_sphinx_searchd;
+ return if $sphinx->{proc}; # Already started
# First we must run the indexer to create the data.
my $sphinx_data_dir= "$::opt_vardir/" . $sphinx->name();
diff --git a/mysql-test/suite/sphinx/union-5539.result b/mysql-test/suite/sphinx/union-5539.result
new file mode 100644
index 00000000000..414bcce30e9
--- /dev/null
+++ b/mysql-test/suite/sphinx/union-5539.result
@@ -0,0 +1,10 @@
+create table ts (id bigint unsigned not null, w int not null, query varchar(255) not null, index(query)) engine=sphinx connection="sphinx://127.0.0.1:PORT/*";
+SELECT a.* FROM (SELECT * FROM ts si WHERE si.query=';mode=extended2;limit=1000000;maxmatches=500') AS a UNION SELECT b.* FROM (SELECT * FROM ts si WHERE si.query='@* 123nothingtofind123;mode=extended2;limit=1000000;maxmatches=500') AS b;
+id w query
+SELECT a.* FROM (SELECT * FROM ts si WHERE si.query='@* 123nothingtofind123;mode=extended2;limit=1000000;maxmatches=500') AS a UNION SELECT b.* FROM (SELECT * FROM ts si WHERE si.query=';mode=extended2;limit=1000000;maxmatches=500') AS b;
+id w query
+1 1 ;mode=extended2;limit=1000000;maxmatches=500
+2 1 ;mode=extended2;limit=1000000;maxmatches=500
+3 1 ;mode=extended2;limit=1000000;maxmatches=500
+4 1 ;mode=extended2;limit=1000000;maxmatches=500
+drop table ts;
diff --git a/mysql-test/suite/sphinx/union-5539.test b/mysql-test/suite/sphinx/union-5539.test
new file mode 100644
index 00000000000..ec73be1ab3e
--- /dev/null
+++ b/mysql-test/suite/sphinx/union-5539.test
@@ -0,0 +1,16 @@
+#
+# MDEV-5539 Empty results in UNION with Sphinx engine
+#
+--replace_result $SPHINXSEARCH_PORT PORT
+eval create table ts (id bigint unsigned not null, w int not null, query varchar(255) not null, index(query)) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/*";
+let $q1=SELECT * FROM ts si WHERE si.query=';mode=extended2;limit=1000000;maxmatches=500';
+let $q2=SELECT * FROM ts si WHERE si.query='@* 123nothingtofind123;mode=extended2;limit=1000000;maxmatches=500';
+########################
+# BUG BUG BUG !!!
+# Note, the result below is incorrect! It should be updated when
+# MDEV-5539 is fixed upstream!!!
+########################
+eval SELECT a.* FROM ($q1) AS a UNION SELECT b.* FROM ($q2) AS b;
+eval SELECT a.* FROM ($q2) AS a UNION SELECT b.* FROM ($q1) AS b;
+drop table ts;
+
diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test
index ea7dd12fb9e..58ead1e3ced 100644
--- a/mysql-test/t/error_simulation.test
+++ b/mysql-test/t/error_simulation.test
@@ -103,7 +103,7 @@ CREATE TABLE t2(f1 INT);
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES (1),(2);
SET SESSION debug_dbug="+d,bug11747970_raise_error";
---error 1105
+--error ER_QUERY_INTERRUPTED
INSERT IGNORE INTO t2 SELECT f1 FROM t1 a WHERE NOT EXISTS (SELECT 1 FROM t2 b WHERE a.f1 = b.f1);
SET SESSION debug_dbug = DEFAULT;
DROP TABLE t1,t2;
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 292db69a6e3..424722a8990 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -298,6 +298,14 @@ DROP TABLE t1;
SELECT INET_NTOA(0);
SELECT '1' IN ('1', INET_NTOA(0));
+#
+# MDEV-5655 Server crashes on NAME_CONST containing AND/OR expressions
+#
+--error ER_WRONG_ARGUMENTS
+SELECT NAME_CONST('a', -(1 OR 2)) OR 1;
+--error ER_WRONG_ARGUMENTS
+SELECT NAME_CONST('a', -(1 AND 2)) AND 1;
+SELECT NAME_CONST('a', -(1)) OR 1;
--echo #
--echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465
@@ -372,6 +380,3 @@ drop table t1,tv;
--echo # End of 5.5 tests
--echo #
---echo #
---echo # End of tests
---echo #
diff --git a/mysql-test/t/union_crash-714.test b/mysql-test/t/union_crash-714.test
new file mode 100644
index 00000000000..6c31a2202cb
--- /dev/null
+++ b/mysql-test/t/union_crash-714.test
@@ -0,0 +1,9 @@
+#
+# MDEV-714 LP:1020645 - crash (sig 11) with union query
+#
+--source include/have_debug.inc
+create table t1 (i tinyint);
+set debug_dbug='+d,bug11747970_raise_error';
+--error ER_QUERY_INTERRUPTED
+insert into t1 (i) select i from t1 union select i from t1;
+drop table t1;
diff --git a/sql/item.cc b/sql/item.cc
index 2bf4ecd230c..5e4c4b03c16 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1677,17 +1677,28 @@ bool Item_name_const::is_null()
Item_name_const::Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
- if (!(valid_args= name_item->basic_const_item() &&
- (value_item->basic_const_item() ||
- ((value_item->type() == FUNC_ITEM) &&
- ((((Item_func *) value_item)->functype() ==
- Item_func::COLLATE_FUNC) ||
- ((((Item_func *) value_item)->functype() ==
- Item_func::NEG_FUNC) &&
- (((Item_func *) value_item)->key_item()->type() !=
- FUNC_ITEM)))))))
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
+ valid_args= true;
+ if (!name_item->basic_const_item())
+ goto err;
+
+ if (value_item->basic_const_item())
+ return; // ok
+
+ if (value_item->type() == FUNC_ITEM)
+ {
+ Item_func *value_func= (Item_func *) value_item;
+ if (value_func->functype() != Item_func::COLLATE_FUNC &&
+ value_func->functype() != Item_func::NEG_FUNC)
+ goto err;
+
+ if (value_func->key_item()->basic_const_item())
+ return; // ok
+ }
+
+err:
+ valid_args= false;
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index be3879758a3..65ce50c1e3c 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -2883,7 +2883,7 @@ subselect_single_select_engine(THD *thd_arg, st_select_lex *select,
select_result_interceptor *result_arg,
Item_subselect *item_arg)
:subselect_engine(thd_arg, item_arg, result_arg),
- prepared(0), executed(0), optimize_error(0),
+ prepared(0), executed(0),
select_lex(select), join(0)
{
select_lex->master_unit()->item= item_arg;
@@ -2897,7 +2897,7 @@ int subselect_single_select_engine::get_identifier()
void subselect_single_select_engine::cleanup()
{
DBUG_ENTER("subselect_single_select_engine::cleanup");
- prepared= executed= optimize_error= 0;
+ prepared= executed= 0;
join= 0;
result->cleanup();
select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
@@ -3131,9 +3131,6 @@ int subselect_single_select_engine::exec()
{
DBUG_ENTER("subselect_single_select_engine::exec");
- if (optimize_error)
- DBUG_RETURN(1);
-
char const *save_where= thd->where;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
@@ -3146,7 +3143,7 @@ int subselect_single_select_engine::exec()
if (join->optimize())
{
thd->where= save_where;
- executed= optimize_error= 1;
+ executed= 1;
thd->lex->current_select= save_select;
DBUG_RETURN(join->error ? join->error : 1);
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 25852b55d98..592e7711a10 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -780,7 +780,6 @@ class subselect_single_select_engine: public subselect_engine
{
bool prepared; /* simple subselect is prepared */
bool executed; /* simple subselect is executed */
- bool optimize_error; /* simple subselect optimization failed */
st_select_lex *select_lex; /* corresponding select_lex */
JOIN * join; /* corresponding JOIN structure */
public:
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 54653557b16..06e8ffb2b5e 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -129,7 +129,6 @@ void one_thread_scheduler(scheduler_functions *func)
{
scheduler_init();
func->max_threads= 1;
- //max_connections= 1;
func->max_connections= &max_connections;
func->connection_count= &connection_count;
#ifndef EMBEDDED_LIBRARY
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a773eac1a32..84ccd51004e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3214,13 +3214,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
#endif
DBUG_EXECUTE_IF("bug11747970_raise_error",
- {
- if (!error)
- {
- my_error(ER_UNKNOWN_ERROR, MYF(0));
- goto error;
- }
- });
+ { join->thd->killed= KILL_QUERY_HARD; });
if (error)
{
table->file->print_error(error, MYF(0));
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 82fe7f2936a..1d4ceb6245d 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -639,7 +639,8 @@ bool st_select_lex_unit::exec()
if (!(uncacheable & ~UNCACHEABLE_EXPLAIN) && item)
item->make_const();
- saved_error= optimize();
+ if ((saved_error= optimize()))
+ DBUG_RETURN(saved_error);
if (uncacheable || !item || !item->assigned() || describe)
{