summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sanja@montyprogram.com>2012-10-14 19:29:31 +0300
committerunknown <sanja@montyprogram.com>2012-10-14 19:29:31 +0300
commit72ab07c1cba0565a8ef043931610a2510a85cfd5 (patch)
treefa721a0805aeda13c0baa307f4b7fa94cdfed7dd /sql
parent82eb2c6de05787cda48745bcf4225be7b5a9870e (diff)
downloadmariadb-git-72ab07c1cba0565a8ef043931610a2510a85cfd5.tar.gz
MDEV-746: Merged mysql fix of the bug LP:1002546 & MySQL Bug#13651009.
Empty result after reading const tables now works for subqueries.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc36
1 files changed, 26 insertions, 10 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c6bddbf9a28..2a6c60af85f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1065,11 +1065,9 @@ JOIN::optimize()
DBUG_RETURN(1); // error == -1
}
if (const_table_map != found_const_table_map &&
- !(select_options & SELECT_DESCRIBE) &&
- (!conds ||
- !(conds->used_tables() & RAND_TABLE_BIT) ||
- select_lex->master_unit() == &thd->lex->unit)) // upper level SELECT
+ !(select_options & SELECT_DESCRIBE))
{
+ // There is at least one empty const table
zero_result_cause= "no matching row in const table";
DBUG_PRINT("error",("Error: %s", zero_result_cause));
error= 0;
@@ -12204,6 +12202,17 @@ int safe_index_read(JOIN_TAB *tab)
}
+/**
+ Reads content of constant table
+
+ @param tab table
+ @param pos position of table in query plan
+
+ @retval 0 ok, one row was found or one NULL-complemented row was created
+ @retval -1 ok, no row was found and no NULL-complemented row was created
+ @retval 1 error
+*/
+
static int
join_read_const_table(JOIN_TAB *tab, POSITION *pos)
{
@@ -12295,6 +12304,16 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
}
+/**
+ Read a constant table when there is at most one matching row, using a table
+ scan.
+
+ @param tab Table to read
+
+ @retval 0 Row was found
+ @retval -1 Row was not found
+ @retval 1 Got an error (other than row not found) during read
+*/
static int
join_read_system(JOIN_TAB *tab)
{
@@ -12326,12 +12345,9 @@ join_read_system(JOIN_TAB *tab)
@param tab Table to read
- @retval
- 0 Row was found
- @retval
- -1 Row was not found
- @retval
- 1 Got an error (other than row not found) during read
+ @retval 0 Row was found
+ @retval -1 Row was not found
+ @retval 1 Got an error (other than row not found) during read
*/
static int