Commit e7f87bd0 authored by unknown's avatar unknown
Browse files

Merge rurik.mysql.com:/home/igor/mysql-5.0

into  rurik.mysql.com:/home/igor/dev/mysql-5.0-2

parents b5726801 7bb4f778
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2649,3 +2649,14 @@ ldt
2006-01-01 03:00:00
drop view v1, v2;
drop table t1;
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime);
CREATE VIEW v1 AS
SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*)
FROM t1 GROUP BY id, t;
SHOW CREATE VIEW v1;
View	Create View
v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second)
SELECT * FROM v1;
id	t	COUNT(*)
DROP VIEW v1;
DROP TABLE t1;
+16 −0
Original line number Diff line number Diff line
@@ -2512,3 +2512,19 @@ create view v2 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from v1;
select * from v2;
drop view v1, v2;
drop table t1;

#
# Bug #19490: usage of view specified by a query with GROUP BY
#             an expression containing non-constant interval

CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime);

CREATE VIEW v1 AS
SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*)
  FROM t1 GROUP BY id, t;

SHOW CREATE VIEW v1;
SELECT * FROM v1;

DROP VIEW v1;
DROP TABLE t1;
+7 −2
Original line number Diff line number Diff line
@@ -2144,8 +2144,13 @@ bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
  Item_date_add_interval *other= (Item_date_add_interval*) item;

  if ((int_type != other->int_type) ||
      (!args[0]->eq(other->args[0], binary_cmp)) ||
      (get_interval_value(args[1], int_type, &val, &interval)))
      (!args[0]->eq(other->args[0], binary_cmp)))
    return FALSE;

  if (!args[1]->const_item() || !other->args[1]->const_item())
    return (args[1]->eq(other->args[1], binary_cmp)); 

  if (get_interval_value(args[1], int_type, &val, &interval))
    return FALSE;

  val= other->value;