List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:June 3 2011 10:54am
Subject:bzr commit into mysql-trunk branch (davi:3153) WL#2111
View as plain text  
# At a local mysql-trunk repository of davi

 3153 Davi Arnaut	2011-06-03
      WL#2111: #1 Stored Procedures: Implement GET DIAGNOSTICS
      
      Add ROW_COUNT as a non-reserved keyword, to be used as part of
      the grammar for GET DIAGNOSTICS. Since the name ROW_COUNT is
      already used to name a regular (native) function, the parser
      needs to be adjusted to interpret ROW_COUNT() as a function
      call using a non-reserved keyword.
     @ mysql-test/t/sp.test
        Use ROW_COUNT in places where reserved keywords aren't allowed.
     @ sql/item_create.cc
        ROW_COUNT function is now created directly in the parser.
     @ sql/lex.h
        Add the ROW_COUNT symbol.
     @ sql/sql_yacc.yy
        Add ROW_COUNT as a non-reserved token/keyword. Add a rule to
        parse ROW_COUNT() as a function call.

    modified:
      mysql-test/r/sp.result
      mysql-test/t/sp.test
      sql/item_create.cc
      sql/lex.h
      sql/sql_yacc.yy
=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2011-03-17 11:33:17 +0000
+++ b/mysql-test/r/sp.result	2011-06-03 10:54:21 +0000
@@ -7500,4 +7500,27 @@ CALL p1();
 DROP TABLE t1, t2, t3;
 DROP PROCEDURE p1;
 
-# End of 5.5 test
+# End of 5.5 tests
+#
+# WL#2111: Add non-reserved ROW_COUNT keyword.
+#
+DROP PROCEDURE IF EXISTS p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE row_count INT DEFAULT -1;
+SELECT row_count;
+SELECT row_count();
+ROW_COUNT: WHILE row_count < 0 DO
+SET row_count = row_count + 1;
+END WHILE ROW_COUNT;
+SELECT ROW_COUNT;
+END|
+CALL p1();
+row_count
+-1
+row_count()
+-1
+ROW_COUNT
+0
+DROP PROCEDURE p1;
+# End of 5.6 tests

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2011-03-17 11:33:17 +0000
+++ b/mysql-test/t/sp.test	2011-06-03 10:54:21 +0000
@@ -8778,4 +8778,33 @@ DROP TABLE t1, t2, t3;
 DROP PROCEDURE p1;
 --echo
 
---echo # End of 5.5 test
+--echo # End of 5.5 tests
+
+--echo #
+--echo # WL#2111: Add non-reserved ROW_COUNT keyword.
+--echo #
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+DELIMITER |;
+
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE row_count INT DEFAULT -1;
+  SELECT row_count;
+  SELECT row_count();
+  ROW_COUNT: WHILE row_count < 0 DO
+    SET row_count = row_count + 1;
+  END WHILE ROW_COUNT;
+  SELECT ROW_COUNT;
+END|
+
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo # End of 5.6 tests

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2011-05-21 08:25:33 +0000
+++ b/sql/item_create.cc	2011-06-03 10:54:21 +0000
@@ -2032,19 +2032,6 @@ protected:
 };
 
 
-class Create_func_row_count : public Create_func_arg0
-{
-public:
-  virtual Item *create(THD *thd);
-
-  static Create_func_row_count s_singleton;
-
-protected:
-  Create_func_row_count() {}
-  virtual ~Create_func_row_count() {}
-};
-
-
 class Create_func_rpad : public Create_func_arg3
 {
 public:
@@ -4808,18 +4795,6 @@ Create_func_round::create_native(THD *th
 }
 
 
-Create_func_row_count Create_func_row_count::s_singleton;
-
-Item*
-Create_func_row_count::create(THD *thd)
-{
-  DBUG_ENTER("Create_func_row_count::create");
-  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
-  thd->lex->safe_to_cache_query= 0;
-  DBUG_RETURN(new (thd->mem_root) Item_func_row_count());
-}
-
-
 Create_func_rpad Create_func_rpad::s_singleton;
 
 Item*
@@ -5500,7 +5475,6 @@ static Native_func_registry func_array[]
   { { C_STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
   { { C_STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)},
   { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
-  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
   { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
   { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
   { { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2010-11-25 11:20:16 +0000
+++ b/sql/lex.h	2011-06-03 10:54:21 +0000
@@ -475,6 +475,7 @@ static SYMBOL symbols[] = {
   { "ROLLUP",		SYM(ROLLUP_SYM)},
   { "ROUTINE",		SYM(ROUTINE_SYM)},
   { "ROW",		SYM(ROW_SYM)},
+  { "ROW_COUNT",        SYM(ROW_COUNT_SYM)},
   { "ROWS",		SYM(ROWS_SYM)},
   { "ROW_FORMAT",	SYM(ROW_FORMAT_SYM)},
   { "RTREE",		SYM(RTREE_SYM)},

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-05-26 15:20:09 +0000
+++ b/sql/sql_yacc.yy	2011-06-03 10:54:21 +0000
@@ -1246,6 +1246,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  ROWS_SYM                      /* SQL-2003-R */
 %token  ROW_FORMAT_SYM
 %token  ROW_SYM                       /* SQL-2003-R */
+%token  ROW_COUNT_SYM                 /* SQL-2003-N */
 %token  RTREE_SYM
 %token  SAVEPOINT_SYM                 /* SQL-2003-R */
 %token  SCHEDULE_SYM
@@ -8610,6 +8611,14 @@ function_call_conflict:
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
+        | ROW_COUNT_SYM '(' ')'
+          {
+            $$= new (YYTHD->mem_root) Item_func_row_count();
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+            Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
+            Lex->safe_to_cache_query= 0;
+          }
         | TRUNCATE_SYM '(' expr ',' expr ')'
           {
             $$= new (YYTHD->mem_root) Item_func_round($3,$5,1);
@@ -12804,6 +12813,7 @@ keyword_sp:
         | ROLLUP_SYM               {}
         | ROUTINE_SYM              {}
         | ROWS_SYM                 {}
+        | ROW_COUNT_SYM            {}
         | ROW_FORMAT_SYM           {}
         | ROW_SYM                  {}
         | RTREE_SYM                {}


Attachment: [text/bzr-bundle] bzr/davi.arnaut@oracle.com-20110603105421-yjkgkn2ueljnbl8p.bundle
Thread
bzr commit into mysql-trunk branch (davi:3153) WL#2111Davi Arnaut4 Jun
Re: bzr commit into mysql-trunk branch (davi:3153) WL#2111Jon Olav Hauglid7 Jun