List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:February 20 2008 3:25pm
Subject:bk commit into 5.0 tree (kaa:1.2607) BUG#33834
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa.  When kaa 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@stripped, 2008-02-20 17:25:25+03:00, kaa@kaamos.(none) +3 -0
  Fix for bug #33834: FRAC_SECOND: Applicability not clear in 
                      documentation
  
  While the manual mentions FRAC_SECOND only for the TIMESTAMPADD()
  function, it was also possible to use FRAC_SECOND with DATE_ADD(),
  DATE_SUB() and +/- INTERVAL.
  
  Fixed the parser to match the manual, i.e. using FRAC_SECOND for 
  anything other than TIMESTAMPADD()/TIMESTAMPDIFF() now produces a 
  syntax error.

  mysql-test/r/func_time.result@stripped, 2008-02-20 17:25:24+03:00, kaa@kaamos.(none) +14 -0
    Added a test case for bug #33834.

  mysql-test/t/func_time.test@stripped, 2008-02-20 17:25:24+03:00, kaa@kaamos.(none) +19 -0
    Added a test case for bug #33834.

  sql/sql_yacc.yy@stripped, 2008-02-20 17:25:24+03:00, kaa@kaamos.(none) +10 -4
    Reject FRAC_SECOND for anything other than TIMESTAMPADD() or
    TIMESTAMPDIFF().

diff -Nrup a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
--- a/mysql-test/r/func_time.result	2007-12-10 11:17:16 +03:00
+++ b/mysql-test/r/func_time.result	2008-02-20 17:25:24 +03:00
@@ -1285,4 +1285,18 @@ DATE_ADD(20071108,         INTERVAL 1 DA
 select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
 LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND
 2007-12-30 23:59:59
+SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
+TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18')
+2008-02-18 00:00:00.000001
+SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
+TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18')
+86400000000
+SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
+SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
+SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
+SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
 End of 5.0 tests
diff -Nrup a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
--- a/mysql-test/t/func_time.test	2007-12-10 11:17:17 +03:00
+++ b/mysql-test/t/func_time.test	2008-02-20 17:25:24 +03:00
@@ -804,4 +804,23 @@ select DATE_ADD(20071108,         INTERV
 
 select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
 
+#
+# Bug#33834: FRAC_SECOND: Applicability not clear in documentation
+#
+# Show that he use of FRAC_SECOND, for anything other than
+# TIMESTAMPADD / TIMESTAMPDIFF, is a server error.
+
+SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
+SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
+
+--error ER_PARSE_ERROR
+SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
+--error ER_PARSE_ERROR
+SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
+
+--error ER_PARSE_ERROR
+SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
+--error ER_PARSE_ERROR
+SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
+
 --echo End of 5.0 tests
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2008-02-01 11:00:39 +03:00
+++ b/sql/sql_yacc.yy	2008-02-20 17:25:24 +03:00
@@ -461,7 +461,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
   Currently there are 245 shift/reduce conflicts.
   We should not introduce new conflicts any more.
 */
-%expect 245
+%expect 240
 
 %token  END_OF_INPUT
 
@@ -1111,6 +1111,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %type <interval_time_st> interval_time_st
 
+%type <interval_time_st> interval_time_stamp
+
 %type <db_type> storage_engines
 
 %type <row_type> row_types
@@ -5027,9 +5029,9 @@ simple_expr:
 	  { $$= new Item_datetime_typecast($3); }
 	| TIMESTAMP '(' expr ',' expr ')'
 	  { $$= new Item_func_add_time($3, $5, 1, 0); }
-	| TIMESTAMP_ADD '(' interval_time_st ',' expr ',' expr ')'
+	| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
 	  { $$= new Item_date_add_interval($7,$5,$3,0); }
-	| TIMESTAMP_DIFF '(' interval_time_st ',' expr ',' expr ')'
+	| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
 	  { $$= new Item_func_timestamp_diff($5,$7,$3); }
 	| TRIM '(' expr ')'
 	  { $$= new Item_func_trim($3); }
@@ -6011,11 +6013,15 @@ interval:
 	| SECOND_MICROSECOND_SYM	{ $$=INTERVAL_SECOND_MICROSECOND; }
 	| YEAR_MONTH_SYM	{ $$=INTERVAL_YEAR_MONTH; };
 
+interval_time_stamp:
+	interval_time_st	{}
+	| FRAC_SECOND_SYM	{ $$=INTERVAL_MICROSECOND; }
+	;
+
 interval_time_st:
 	DAY_SYM			{ $$=INTERVAL_DAY; }
 	| WEEK_SYM		{ $$=INTERVAL_WEEK; }
 	| HOUR_SYM		{ $$=INTERVAL_HOUR; }
-	| FRAC_SECOND_SYM	{ $$=INTERVAL_MICROSECOND; }
 	| MINUTE_SYM		{ $$=INTERVAL_MINUTE; }
 	| MONTH_SYM		{ $$=INTERVAL_MONTH; }
 	| QUARTER_SYM		{ $$=INTERVAL_QUARTER; }
Thread
bk commit into 5.0 tree (kaa:1.2607) BUG#33834Alexey Kopytov20 Feb 2008