[Commits] Rev 3168: Added MariaDB executable comment syntax: /*M!##### */ in lp:maria/5.3

Michael Widenius monty at askmonty.org
Mon Aug 29 18:14:15 EEST 2011


At lp:maria/5.3

------------------------------------------------------------
revno: 3168
revision-id: monty at askmonty.org-20110829151414-6dsxm5sd9gd24tg9
parent: timour at askmonty.org-20110826214029-vh6gj92pa6km7fr1
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.3
timestamp: Mon 2011-08-29 18:14:14 +0300
message:
  Added MariaDB executable comment syntax:  /*M!##### */
-------------- next part --------------
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-07-01 12:08:30 +0000
+++ b/client/mysql.cc	2011-08-29 15:14:14 +0000
@@ -49,7 +49,7 @@ and you are welcome to modify and redist
 #include <locale.h>
 #endif
 
-const char *VER= "15.0";
+const char *VER= "15.1";
 
 /* Don't try to make a nice table if the data is too big */
 #define MAX_COLUMN_LENGTH            1024
@@ -2302,7 +2302,7 @@ static bool add_line(String &buffer,char
       break;
     }
     else if (!*in_string && inchar == '/' && *(pos+1) == '*' &&
-             *(pos+2) != '!')
+             !(*(pos+2) == '!' || (*(pos+2) == 'M' && *(pos+3) == '!')))
     {
       if (preserve_comments)
       {

=== modified file 'mysql-test/r/comments.result'
--- a/mysql-test/r/comments.result	2008-07-07 21:53:20 +0000
+++ b/mysql-test/r/comments.result	2011-08-29 15:14:14 +0000
@@ -26,6 +26,20 @@ select 1 # The rest of the row will be i
 1
 1
 /* line with only comment */;
+select 1 /*M! +1 */;
+1  +1
+2
+select 1 /*M!50000 +1 */;
+1  +1
+2
+select 1 /*M!50300 +1 */;
+1  +1
+2
+select 2 /*M!99999 +1 */;
+2
+2
+select 2 /*M!0000 +1 */;
+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 '0000 +1 */' at line 1
 select 1/*!2*/;
 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 '2*/' at line 1
 select 1/*!000002*/;

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2010-12-01 06:55:31 +0000
+++ b/mysql-test/r/mysql.result	2011-08-29 15:14:14 +0000
@@ -137,6 +137,14 @@ drop table t1;
 1
 ERROR 1064 (42000) at line 3: 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 '' at line 1
 ERROR at line 1: USE must be followed by a database name
+1  +1
+2
+1  +1
+2
+1  +1
+2
+1  +1
+2
 \
 \\
 ';

=== modified file 'mysql-test/t/comments.test'
--- a/mysql-test/t/comments.test	2007-08-30 18:57:05 +0000
+++ b/mysql-test/t/comments.test	2011-08-29 15:14:14 +0000
@@ -21,6 +21,17 @@ select 1 # The rest of the row will be i
 # End of 4.1 tests
 
 #
+# Testing of MariaDB executable comments
+#
+
+select 1 /*M! +1 */;
+select 1 /*M!50000 +1 */;
+select 1 /*M!50300 +1 */;
+select 2 /*M!99999 +1 */;
+--error ER_PARSE_ERROR
+select 2 /*M!0000 +1 */;
+
+#
 # Bug#25411 (trigger code truncated)
 #
 

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2011-05-02 17:58:45 +0000
+++ b/mysql-test/t/mysql.test	2011-08-29 15:14:14 +0000
@@ -124,6 +124,13 @@ drop table t1;
 --exec echo "use"         >  $file
 --exec $MYSQL              < $file 2>&1
 
+# Test exceutable comments
+--exec echo "SELECT 1 /*! +1 */;"       > $file
+--exec echo "SELECT 1 /*M! +1 */;"      >> $file
+--exec echo "SELECT 1 /*!00000 +1 */;"  >> $file
+--exec echo "SELECT 1 /*M!00000 +1 */" >> $file
+--exec $MYSQL                           < $file 2>&1
+
 --remove_file $file
 
 #

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2011-06-16 04:48:38 +0000
+++ b/sql/sql_cache.cc	2011-08-29 15:14:14 +0000
@@ -491,11 +491,12 @@ static void make_base_query(String *new_
       continue;                                 // Continue with next symbol
     case '/':                                   // Start of comment ?
       /*
-        Comment of format /#!number #/, must be skipped.
+        Comment of format /#!number #/ or /#M!number #/, must be skipped.
         These may include '"' and other comments, but it should
         be safe to parse the content as a normal string.
       */
-      if (query[0] != '*' || query[1] == '!')
+      if (query[0] != '*' || query[1] == '!' ||
+          (query[1] == 'M' && query[2] == '!'))
         break;
 
       query++;                               // skip "/"

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-08-17 05:48:35 +0000
+++ b/sql/sql_lex.cc	2011-08-29 15:14:14 +0000
@@ -1272,39 +1272,39 @@ int MYSQLlex(void *arg, void *yythd)
 
       lip->save_in_comment_state();
 
+      if (lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!')
+      {
+        /* Skip MariaDB unique marker */
+        lip->set_echo(FALSE);
+        lip->yySkip();
+        /* The following if will be true */
+      }
       if (lip->yyPeekn(2) == '!')
       {
         lip->in_comment= DISCARD_COMMENT;
         /* Accept '/' '*' '!', but do not keep this marker. */
         lip->set_echo(FALSE);
-        lip->yySkip();
-        lip->yySkip();
-        lip->yySkip();
+        lip->yySkipn(3);
 
         /*
           The special comment format is very strict:
-          '/' '*' '!', followed by exactly
+          '/' '*' '!', followed by an optional 'M' and exactly
           1 digit (major), 2 digits (minor), then 2 digits (dot).
           32302 -> 3.23.02
           50032 -> 5.0.32
           50114 -> 5.1.14
         */
-        char version_str[6];
-        version_str[0]= lip->yyPeekn(0);
-        version_str[1]= lip->yyPeekn(1);
-        version_str[2]= lip->yyPeekn(2);
-        version_str[3]= lip->yyPeekn(3);
-        version_str[4]= lip->yyPeekn(4);
-        version_str[5]= 0;
-        if (  my_isdigit(cs, version_str[0])
-           && my_isdigit(cs, version_str[1])
-           && my_isdigit(cs, version_str[2])
-           && my_isdigit(cs, version_str[3])
-           && my_isdigit(cs, version_str[4])
+        if (  my_isdigit(cs, lip->yyPeekn(0))
+           && my_isdigit(cs, lip->yyPeekn(1))
+           && my_isdigit(cs, lip->yyPeekn(2))
+           && my_isdigit(cs, lip->yyPeekn(3))
+           && my_isdigit(cs, lip->yyPeekn(4))
            )
         {
           ulong version;
-          version=strtol(version_str, NULL, 10);
+          char *end_ptr= (char*) lip->get_ptr()+5;
+          int error;
+          version= (ulong) my_strtoll10(lip->get_ptr(), &end_ptr, &error);
 
           if (version <= MYSQL_VERSION_ID)
           {



More information about the commits mailing list