MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Alex Ivanov Date:September 14 2005 4:25pm
Subject:bk commit into 5.0 tree (aivanov:1.1955) BUG#13000
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alexi. When alexi does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1955 05/09/14 20:25:00 aivanov@stripped +6 -0
  Fixed BUG#12963, BUG#13000: wrong VIEW creation with DAYNAME(),
   DAYOFWEEK(), and WEEKDAY().

  sql/item_timefunc.h
    1.59 05/09/14 20:24:30 aivanov@stripped +4 -1
    Fixed bugs #12963, 13000: wrong VIEW creation with DAYNAME(),
     DAYOFWEEK(), and WEEKDAY.
     Modified Item_func_weekday::func_name(). It returns now different
     names depending on the odbc_type attribute value.

  sql/item_timefunc.cc
    1.94 05/09/14 20:24:30 aivanov@stripped +7 -6
    Fixed bugs #12963, #13000: wrong VIEW creation with DAYNAME(),
     DAYOFWEEK(), and WEEKDAY().
     Modified Item_func_weekday::val_int(). The argument of weekday should
     not be considered now to be Item_func_to_days object.

  sql/item_create.cc
    1.58 05/09/14 20:24:30 aivanov@stripped +3 -3
    Fixed bugs #12963, #13000: wrong VIEW creation with DAYNAME(),
     DAYOFWEEK(), and WEEKDAY().
     Modified create_func_dayname(), create_func_dayofweek(), and
     create_func_weekday(). They don´t insert Item_func_to_days
     object now.

  mysql-test/t/view.test
    1.107 05/09/14 20:24:30 aivanov@stripped +31 -0
    Added testcases for for bugs #12963, #13000.

  mysql-test/r/view.result
    1.113 05/09/14 20:24:30 aivanov@stripped +43 -0
    Fixed some testcases results (bugs #12963, #13000).

  mysql-test/r/func_time.result
    1.46 05/09/14 20:24:30 aivanov@stripped +1 -1
    Fixed new results for testcases containing EXPLAIN EXTENDED SELECT ...
     WEEKDAY ... DAYNAME. The new results are correct and correspond to
     the changes in create_func_weekday() and create_func_dayname().

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	aivanov
# Host:	mysql.creware.com
# Root:	/home/alexi/dev/mysql-5.0-13000

--- 1.57/sql/item_create.cc	2005-08-25 17:34:13 +04:00
+++ 1.58/sql/item_create.cc	2005-09-14 20:24:30 +04:00
@@ -109,7 +109,7 @@
 
 Item *create_func_dayofweek(Item* a)
 {
-  return new Item_func_weekday(new Item_func_to_days(a),1);
+  return new Item_func_weekday(a, 1);
 }
 
 Item *create_func_dayofyear(Item* a)
@@ -119,7 +119,7 @@
 
 Item *create_func_dayname(Item* a)
 {
-  return new Item_func_dayname(new Item_func_to_days(a));
+  return new Item_func_dayname(a);
 }
 
 Item *create_func_degrees(Item *a)
@@ -443,7 +443,7 @@
 
 Item *create_func_weekday(Item* a)
 {
-  return new Item_func_weekday(new Item_func_to_days(a),0);
+  return new Item_func_weekday(a, 0);
 }
 
 Item *create_func_year(Item* a)

--- 1.93/sql/item_timefunc.cc	2005-08-25 02:50:54 +04:00
+++ 1.94/sql/item_timefunc.cc	2005-09-14 20:24:30 +04:00
@@ -1030,16 +1030,17 @@
 }
 
 
-/* weekday() has a automatic to_days() on item */
-
 longlong Item_func_weekday::val_int()
 {
   DBUG_ASSERT(fixed == 1);
-  ulong tmp_value=(ulong) args[0]->val_int();
-  if ((null_value=(args[0]->null_value || !tmp_value)))
-    return 0; /* purecov: inspected */
+  TIME ltime;
+  
+  if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
+    return 0;
 
-  return (longlong) calc_weekday(tmp_value,odbc_type)+test(odbc_type);
+  return (longlong) calc_weekday(calc_daynr(ltime.year, ltime.month,
+                                            ltime.day),
+                                 odbc_type) + test(odbc_type);
 }
 
 

--- 1.58/sql/item_timefunc.h	2005-08-25 02:50:54 +04:00
+++ 1.59/sql/item_timefunc.h	2005-09-14 20:24:30 +04:00
@@ -257,7 +257,10 @@
     str->set(val_int(), &my_charset_bin);
     return null_value ? 0 : str;
   }
-  const char *func_name() const { return "weekday"; }
+  const char *func_name() const
+  {
+     return (odbc_type ? "dayofweek" : "weekday");
+  }
   enum Item_result result_type () const { return INT_RESULT; }
   void fix_length_and_dec()
   {

--- 1.112/mysql-test/r/view.result	2005-09-14 10:10:12 +04:00
+++ 1.113/mysql-test/r/view.result	2005-09-14 20:24:30 +04:00
@@ -2196,3 +2196,46 @@
 f2
 drop view v1;
 drop table t1;
+CREATE TABLE t1 (date DATE NOT NULL);
+INSERT INTO  t1 VALUES ('2005-09-06');
+CREATE VIEW v1 AS SELECT DAYNAME(date) FROM t1;
+SHOW CREATE VIEW v1;
+View	Create View
+v1	CREATE ALGORITHM=UNDEFINED VIEW `v1` AS select dayname(`t1`.`date`) AS `DAYNAME(date)` from `t1`
+CREATE VIEW v2 AS SELECT DAYOFWEEK(date) FROM t1;
+SHOW CREATE VIEW v2;
+View	Create View
+v2	CREATE ALGORITHM=UNDEFINED VIEW `v2` AS select dayofweek(`t1`.`date`) AS `DAYOFWEEK(date)` from `t1`
+CREATE VIEW v3 AS SELECT WEEKDAY(date) FROM t1;
+SHOW CREATE VIEW v3;
+View	Create View
+v3	CREATE ALGORITHM=UNDEFINED VIEW `v3` AS select weekday(`t1`.`date`) AS `WEEKDAY(date)` from `t1`
+SELECT DAYNAME('2005-09-06');
+DAYNAME('2005-09-06')
+Tuesday
+SELECT DAYNAME(date) FROM t1;
+DAYNAME(date)
+Tuesday
+SELECT * FROM v1;
+DAYNAME(date)
+Tuesday
+SELECT DAYOFWEEK('2005-09-06');
+DAYOFWEEK('2005-09-06')
+3
+SELECT DAYOFWEEK(date) FROM t1;
+DAYOFWEEK(date)
+3
+SELECT * FROM v2;
+DAYOFWEEK(date)
+3
+SELECT WEEKDAY('2005-09-06');
+WEEKDAY('2005-09-06')
+1
+SELECT WEEKDAY(date) FROM t1;
+WEEKDAY(date)
+1
+SELECT * FROM v3;
+WEEKDAY(date)
+1
+DROP TABLE t1;
+DROP VIEW  v1, v2, v3;

--- 1.106/mysql-test/t/view.test	2005-09-13 22:22:50 +04:00
+++ 1.107/mysql-test/t/view.test	2005-09-14 20:24:30 +04:00
@@ -2077,3 +2077,34 @@
 select * from (select f1 as f2 from v1) v where v.f2='a';
 drop view v1;
 drop table t1;
+
+#
+# Bugs #12963, #13000: wrong creation of VIEW with DAYNAME, DAYOFWEEK, and WEEKDAY
+#
+
+CREATE TABLE t1 (date DATE NOT NULL);
+INSERT INTO  t1 VALUES ('2005-09-06');
+
+CREATE VIEW v1 AS SELECT DAYNAME(date) FROM t1;
+SHOW CREATE VIEW v1;
+
+CREATE VIEW v2 AS SELECT DAYOFWEEK(date) FROM t1;
+SHOW CREATE VIEW v2;
+
+CREATE VIEW v3 AS SELECT WEEKDAY(date) FROM t1;
+SHOW CREATE VIEW v3;
+
+SELECT DAYNAME('2005-09-06');
+SELECT DAYNAME(date) FROM t1;
+SELECT * FROM v1;
+
+SELECT DAYOFWEEK('2005-09-06');
+SELECT DAYOFWEEK(date) FROM t1;
+SELECT * FROM v2;
+
+SELECT WEEKDAY('2005-09-06');
+SELECT WEEKDAY(date) FROM t1;
+SELECT * FROM v3;
+
+DROP TABLE t1;
+DROP VIEW  v1, v2, v3;

--- 1.45/mysql-test/r/func_time.result	2005-08-25 02:50:54 +04:00
+++ 1.46/mysql-test/r/func_time.result	2005-09-14 20:24:30 +04:00
@@ -686,7 +686,7 @@
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 Warnings:
-Note	1003	select sql_no_cache period_add(_latin1'9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,_latin1'9404') AS `period_diff(199505,"9404")`,from_days(to_days(_latin1'960101')) AS `from_days(to_days("960101"))`,dayofmonth(_latin1'1997-01-02') AS `dayofmonth("1997-01-02")`,month(_latin1'1997-01-02') AS `month("1997-01-02")`,monthname(_latin1'1972-03-04') AS `monthname("1972-03-04")`,dayofyear(_latin1'0000-00-00') AS `dayofyear("0000-00-00")`,hour(_latin1'1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute(_latin1'23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week(_latin1'1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek(_latin1'2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year(_latin1'98-02-03') AS `year("98-02-03")`,(weekday(to_days(curdate())) - weekday(to_days(now()))) AS `weekday(curdate())-weekday(now())`,dayname(to_days(_latin1'1962-03-03')) AS `day
 name("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec(_latin1'0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format(_latin1'1997-01-02 03:04:05',_latin1'%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp(_latin1'1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,(_latin1'1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,(_latin1'1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from _latin1'1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,(_latin1'1997-12-31 23:59:59' + interval 1 second
 ) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
+Note	1003	select sql_no_cache period_add(_latin1'9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,_latin1'9404') AS `period_diff(199505,"9404")`,from_days(to_days(_latin1'960101')) AS `from_days(to_days("960101"))`,dayofmonth(_latin1'1997-01-02') AS `dayofmonth("1997-01-02")`,month(_latin1'1997-01-02') AS `month("1997-01-02")`,monthname(_latin1'1972-03-04') AS `monthname("1972-03-04")`,dayofyear(_latin1'0000-00-00') AS `dayofyear("0000-00-00")`,hour(_latin1'1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute(_latin1'23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week(_latin1'1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek(_latin1'2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year(_latin1'98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname(_latin1'1962-03-03') AS `dayname("1962-03-03")`,unix_ti
 mestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec(_latin1'0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format(_latin1'1997-01-02 03:04:05',_latin1'%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp(_latin1'1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,(_latin1'1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,(_latin1'1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from _latin1'1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 
 23:59:59",INTERVAL 1 SECOND)`
 SET @TMP=NOW();
 CREATE TABLE t1 (d DATETIME);
 INSERT INTO t1 VALUES (NOW());
Thread
bk commit into 5.0 tree (aivanov:1.1955) BUG#13000Alex Ivanov14 Sep