mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug #19573.
The select statement that specified a view could be slightly changed when the view was saved in a frm file. In particular references to an alias name in the HAVING clause could be substituted for the expression named by this alias. This could result in an error message for a query of the form SELECT * FROM <view>. Yet no such message appeared when executing the query specifying the view. mysql-test/r/having.result: Adjusted results after fixing bug #19573. mysql-test/r/view.result: Added a test case for bug #19573. mysql-test/t/view.test: Added a test case for bug #19573.
This commit is contained in:
@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (count(`test`.`t1`.`a`) >= 0)
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (`b` >= 0)
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
raw_id int(10) NOT NULL default '0',
|
||||
|
@ -2660,3 +2660,28 @@ SELECT * FROM v1;
|
||||
id t COUNT(*)
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(
|
||||
fName varchar(25) NOT NULL,
|
||||
lName varchar(25) NOT NULL,
|
||||
DOB date NOT NULL,
|
||||
uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
INSERT INTO t1(fName, lName, DOB) VALUES
|
||||
('Hank', 'Hill', '1964-09-29'),
|
||||
('Tom', 'Adams', '1908-02-14'),
|
||||
('Homer', 'Simpson', '1968-03-05');
|
||||
CREATE VIEW v1 AS
|
||||
SELECT (year(now())-year(DOB)) AS Age
|
||||
FROM t1 HAVING Age < 75;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75)
|
||||
SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
|
||||
Age
|
||||
42
|
||||
38
|
||||
SELECT * FROM v1;
|
||||
Age
|
||||
42
|
||||
38
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
@ -2528,3 +2528,31 @@ SELECT * FROM v1;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #19573: VIEW with HAVING that refers an alias name
|
||||
#
|
||||
|
||||
CREATE TABLE t1(
|
||||
fName varchar(25) NOT NULL,
|
||||
lName varchar(25) NOT NULL,
|
||||
DOB date NOT NULL,
|
||||
uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
|
||||
INSERT INTO t1(fName, lName, DOB) VALUES
|
||||
('Hank', 'Hill', '1964-09-29'),
|
||||
('Tom', 'Adams', '1908-02-14'),
|
||||
('Homer', 'Simpson', '1968-03-05');
|
||||
|
||||
CREATE VIEW v1 AS
|
||||
SELECT (year(now())-year(DOB)) AS Age
|
||||
FROM t1 HAVING Age < 75;
|
||||
SHOW CREATE VIEW v1;
|
||||
|
||||
SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
|
||||
SELECT * FROM v1;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user