summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorJorgen Loland <jorgen.loland@oracle.com>2011-03-14 14:30:36 +0100
committerJorgen Loland <jorgen.loland@oracle.com>2011-03-14 14:30:36 +0100
commit2de6586287658f871a69167f6365d65051b5b7bc (patch)
treed97a169818229aee8191e732ac33fb8547a80523 /sql/sql_base.cc
parent27de68274027fdb25096acdbbfbc1bb123f0e79a (diff)
downloadmariadb-git-2de6586287658f871a69167f6365d65051b5b7bc.tar.gz
BUG#11766234: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW)
FAILS IN SET_FIELD_ITERATOR (Former 59299) When a PROCEDURE does a natural join, resolving of which columns are used in the join is done only once; consecutive CALLs to the procedure will reuse this information: CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1; CALL proc(); <- natural join columns resolved here CALL proc(); <- reuse resolved NJ columns from first CALL The second CALL knows that it can reuse the resolved NJ columns because the first CALL sets st_select_lex::first_natural_join_processing=false. The problem in this bug was that the table the view v1 depends on changed between CREATE PROCEDURE and the first CALL: CREATE PROCEDURE... ALTER TABLE t2 CHANGE COLUMN a b CHAR; CALL proc(); <- error when resolving natural join columns CALL proc(); <- tries to reuse from first CALL => crash The fix for this bug is to set first_natural_join_processing= FALSE iff the natural join columns resolving was successful.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 7c020515f87..f37f800d091 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7594,9 +7594,10 @@ static bool setup_natural_join_row_types(THD *thd,
List<TABLE_LIST> *from_clause,
Name_resolution_context *context)
{
+ DBUG_ENTER("setup_natural_join_row_types");
thd->where= "from clause";
if (from_clause->elements == 0)
- return FALSE; /* We come here in the case of UNIONs. */
+ DBUG_RETURN(false); /* We come here in the case of UNIONs. */
List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);
TABLE_LIST *table_ref; /* Current table reference. */
@@ -7604,10 +7605,6 @@ static bool setup_natural_join_row_types(THD *thd,
TABLE_LIST *left_neighbor;
/* Table reference to the right of the current. */
TABLE_LIST *right_neighbor= NULL;
- bool save_first_natural_join_processing=
- context->select_lex->first_natural_join_processing;
-
- context->select_lex->first_natural_join_processing= FALSE;
/* Note that tables in the list are in reversed order */
for (left_neighbor= table_ref_it++; left_neighbor ; )
@@ -7619,12 +7616,11 @@ static bool setup_natural_join_row_types(THD *thd,
1) for stored procedures,
2) for multitable update after lock failure and table reopening.
*/
- if (save_first_natural_join_processing)
+ if (context->select_lex->first_natural_join_processing)
{
- context->select_lex->first_natural_join_processing= FALSE;
if (store_top_level_join_columns(thd, table_ref,
left_neighbor, right_neighbor))
- return TRUE;
+ DBUG_RETURN(true);
if (left_neighbor)
{
TABLE_LIST *first_leaf_on_the_right;
@@ -7644,8 +7640,9 @@ static bool setup_natural_join_row_types(THD *thd,
DBUG_ASSERT(right_neighbor);
context->first_name_resolution_table=
right_neighbor->first_leaf_for_name_resolution();
+ context->select_lex->first_natural_join_processing= false;
- return FALSE;
+ DBUG_RETURN (false);
}