diff options
author | unknown <sanja@askmonty.org> | 2013-12-04 16:54:33 +0200 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2013-12-04 16:54:33 +0200 |
commit | b78f721460de41e1a749f78e064f42a8e2953247 (patch) | |
tree | eb8f6f3069ac9115a8b3e641ca4bc72936d04d45 /sql | |
parent | 62e959437ee5bf64e89c7b16233ab2ca0fd8507c (diff) | |
download | mariadb-git-b78f721460de41e1a749f78e064f42a8e2953247.tar.gz |
MDEV-5353: server crash on subselect if WHERE applied to some result field
Correct processing of view/derived with no tables added.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 7 | ||||
-rw-r--r-- | sql/table.cc | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/sql/item.h b/sql/item.h index 03b333e7997..5e8e4dfc892 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2963,13 +2963,16 @@ class Item_direct_view_ref :public Item_direct_ref TABLE_LIST *view; TABLE *null_ref_table; +#define NO_NULL_TABLE (reinterpret_cast<TABLE *>(0x1)) + bool check_null_ref() { if (null_ref_table == NULL) { - null_ref_table= view->get_real_join_table(); + if (!(null_ref_table= view->get_real_join_table())) + null_ref_table= NO_NULL_TABLE; } - if (null_ref_table->null_row) + if (null_ref_table != NO_NULL_TABLE && null_ref_table->null_row) { null_value= 1; return TRUE; diff --git a/sql/table.cc b/sql/table.cc index 9e1c53f7b22..066eb506835 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4487,10 +4487,8 @@ TABLE *TABLE_LIST::get_real_join_table() */ for (TABLE_LIST *t= ti++; t; t= ti++) tbl= t; - /* - It is impossible that the list is empty - so tbl can't be NULL after above loop. - */ + if (!tbl) + return NULL; // view/derived with no tables if (!tbl->nested_join) break; /* go deeper if we've found nested join */ |