Skip to content

Commit 5ba700c

Browse files
author
Kristofer Pettersson
committed
automerge
2 parents 9f29134 + 2de6586 commit 5ba700c

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

mysql-test/r/sp.result

+18
Original file line numberDiff line numberDiff line change
@@ -7452,4 +7452,22 @@ c1
74527452
# Cleanup
74537453
drop table t1;
74547454
drop procedure p1;
7455+
#
7456+
# BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW)
7457+
# FAILS IN SET_FIELD_ITERATOR
7458+
#
7459+
CREATE TABLE t1 (a INT);
7460+
CREATE TABLE t2 (a INT);
7461+
CREATE VIEW v1 AS SELECT a FROM t2;
7462+
CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1;
7463+
ALTER TABLE t2 CHANGE COLUMN a b CHAR;
7464+
7465+
CALL proc();
7466+
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
7467+
CALL proc();
7468+
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
7469+
7470+
DROP TABLE t1,t2;
7471+
DROP VIEW v1;
7472+
DROP PROCEDURE proc;
74557473
# End of 5.5 test

mysql-test/t/sp.test

+22
Original file line numberDiff line numberDiff line change
@@ -8713,4 +8713,26 @@ call p1(3, 2);
87138713
drop table t1;
87148714
drop procedure p1;
87158715

8716+
--echo #
8717+
--echo # BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW)
8718+
--echo # FAILS IN SET_FIELD_ITERATOR
8719+
--echo #
8720+
8721+
CREATE TABLE t1 (a INT);
8722+
CREATE TABLE t2 (a INT);
8723+
CREATE VIEW v1 AS SELECT a FROM t2;
8724+
CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1;
8725+
ALTER TABLE t2 CHANGE COLUMN a b CHAR;
8726+
8727+
--echo
8728+
--error ER_VIEW_INVALID
8729+
CALL proc();
8730+
--error ER_VIEW_INVALID
8731+
CALL proc();
8732+
8733+
--echo
8734+
DROP TABLE t1,t2;
8735+
DROP VIEW v1;
8736+
DROP PROCEDURE proc;
8737+
87168738
--echo # End of 5.5 test

sql/sql_base.cc

+6-9
Original file line numberDiff line numberDiff line change
@@ -7594,20 +7594,17 @@ static bool setup_natural_join_row_types(THD *thd,
75947594
List<TABLE_LIST> *from_clause,
75957595
Name_resolution_context *context)
75967596
{
7597+
DBUG_ENTER("setup_natural_join_row_types");
75977598
thd->where= "from clause";
75987599
if (from_clause->elements == 0)
7599-
return FALSE; /* We come here in the case of UNIONs. */
7600+
DBUG_RETURN(false); /* We come here in the case of UNIONs. */
76007601

76017602
List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);
76027603
TABLE_LIST *table_ref; /* Current table reference. */
76037604
/* Table reference to the left of the current. */
76047605
TABLE_LIST *left_neighbor;
76057606
/* Table reference to the right of the current. */
76067607
TABLE_LIST *right_neighbor= NULL;
7607-
bool save_first_natural_join_processing=
7608-
context->select_lex->first_natural_join_processing;
7609-
7610-
context->select_lex->first_natural_join_processing= FALSE;
76117608

76127609
/* Note that tables in the list are in reversed order */
76137610
for (left_neighbor= table_ref_it++; left_neighbor ; )
@@ -7619,12 +7616,11 @@ static bool setup_natural_join_row_types(THD *thd,
76197616
1) for stored procedures,
76207617
2) for multitable update after lock failure and table reopening.
76217618
*/
7622-
if (save_first_natural_join_processing)
7619+
if (context->select_lex->first_natural_join_processing)
76237620
{
7624-
context->select_lex->first_natural_join_processing= FALSE;
76257621
if (store_top_level_join_columns(thd, table_ref,
76267622
left_neighbor, right_neighbor))
7627-
return TRUE;
7623+
DBUG_RETURN(true);
76287624
if (left_neighbor)
76297625
{
76307626
TABLE_LIST *first_leaf_on_the_right;
@@ -7644,8 +7640,9 @@ static bool setup_natural_join_row_types(THD *thd,
76447640
DBUG_ASSERT(right_neighbor);
76457641
context->first_name_resolution_table=
76467642
right_neighbor->first_leaf_for_name_resolution();
7643+
context->select_lex->first_natural_join_processing= false;
76477644

7648-
return FALSE;
7645+
DBUG_RETURN (false);
76497646
}
76507647

76517648

0 commit comments

Comments
 (0)