Commit f2405d71 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

sp.test, sp.result:

  Added a test case for bug #6866.
sql_select.cc:
  Fixed bug #6866.
  Bug was due to the fact that on_expr was not backed up
  for the second execution of the stored procedure.
parent 83fae643
...@@ -3138,4 +3138,44 @@ x ...@@ -3138,4 +3138,44 @@ x
x x
3 3
drop procedure bug10961| drop procedure bug10961|
DROP PROCEDURE IF EXISTS bug6866|
DROP VIEW IF EXISTS tv|
Warnings:
Note 1051 Unknown table 'test.tv'
DROP TABLE IF EXISTS tt1,tt2,tt3|
Warnings:
Note 1051 Unknown table 'tt1'
Note 1051 Unknown table 'tt2'
Note 1051 Unknown table 'tt3'
CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
CREATE TABLE tt2 (a2 int, data2 varchar(10))|
CREATE TABLE tt3 (a3 int, data3 varchar(10))|
INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
INSERT INTO tt2 VALUES (1, 'a')|
INSERT INTO tt2 VALUES (2, 'b')|
INSERT INTO tt2 VALUES (3, 'c')|
INSERT INTO tt3 VALUES (4, 'd')|
INSERT INTO tt3 VALUES (5, 'e')|
INSERT INTO tt3 VALUES (6, 'f')|
CREATE VIEW tv AS
SELECT tt1.*, tt2.data2, tt3.data3
FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
LEFT JOIN tt3 ON tt1.a3 = tt3.a3
ORDER BY tt1.a1, tt2.a2, tt3.a3|
CREATE PROCEDURE bug6866 (_a1 int)
BEGIN
SELECT * FROM tv WHERE a1 = _a1;
END|
CALL bug6866(1)|
a1 a2 a3 data data2 data3
1 1 4 xx a d
CALL bug6866(1)|
a1 a2 a3 data data2 data3
1 1 4 xx a d
CALL bug6866(1)|
a1 a2 a3 data data2 data3
1 1 4 xx a d
DROP PROCEDURE bug6866;
DROP VIEW tv|
DROP TABLE tt1, tt2, tt3|
drop table t1,t2; drop table t1,t2;
...@@ -3848,6 +3848,50 @@ call bug10961()| ...@@ -3848,6 +3848,50 @@ call bug10961()|
drop procedure bug10961| drop procedure bug10961|
#
# BUG #6866: Second call of a stored procedure using a view with on expressions
#
--disable_warnings
DROP PROCEDURE IF EXISTS bug6866|
--enable_warnings
DROP VIEW IF EXISTS tv|
DROP TABLE IF EXISTS tt1,tt2,tt3|
CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
CREATE TABLE tt2 (a2 int, data2 varchar(10))|
CREATE TABLE tt3 (a3 int, data3 varchar(10))|
INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
INSERT INTO tt2 VALUES (1, 'a')|
INSERT INTO tt2 VALUES (2, 'b')|
INSERT INTO tt2 VALUES (3, 'c')|
INSERT INTO tt3 VALUES (4, 'd')|
INSERT INTO tt3 VALUES (5, 'e')|
INSERT INTO tt3 VALUES (6, 'f')|
CREATE VIEW tv AS
SELECT tt1.*, tt2.data2, tt3.data3
FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
LEFT JOIN tt3 ON tt1.a3 = tt3.a3
ORDER BY tt1.a1, tt2.a2, tt3.a3|
CREATE PROCEDURE bug6866 (_a1 int)
BEGIN
SELECT * FROM tv WHERE a1 = _a1;
END|
CALL bug6866(1)|
CALL bug6866(1)|
CALL bug6866(1)|
DROP PROCEDURE bug6866;
DROP VIEW tv|
DROP TABLE tt1, tt2, tt3|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
......
...@@ -7374,6 +7374,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top) ...@@ -7374,6 +7374,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
} }
else else
{ {
if (!(table->prep_on_expr))
table->prep_on_expr= table->on_expr;
used_tables= table->table->map; used_tables= table->table->map;
if (conds) if (conds)
not_null_tables= conds->not_null_tables(); not_null_tables= conds->not_null_tables();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment