[Commits] Rev 3114: Added optional 'M' modifier to executed comments. This allows one to use MariaDB extended syntax on MySQL by using /*!M###### */ in lp:maria/5.3

Michael Widenius monty at askmonty.org
Thu Aug 11 16:01:54 EEST 2011


At lp:maria/5.3

------------------------------------------------------------
revno: 3114
revision-id: monty at askmonty.org-20110811130154-zg2daqtt722n635x
parent: sanja at askmonty.org-20110715091646-a2r1pl8y6vn25tz3
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.3
timestamp: Thu 2011-08-11 16:01:54 +0300
message:
  Added optional 'M' modifier to executed comments. This allows one to use MariaDB extended syntax on MySQL by using /*!M###### */
-------------- next part --------------
=== 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-11 13:01:54 +0000
@@ -51,3 +51,6 @@ ERROR 42000: You have an error in your S
 prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*";
 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 '/*!98765' AND b = 'bar';*' at line 1
 drop table table_28779;
+select 1 + /*!M00000 2 */ + 3 /*!M99999 noise*/ + 4;
+1 +  2  + 3  + 4
+10

=== 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-11 13:01:54 +0000
@@ -65,3 +65,8 @@ prepare bar from "DELETE FROM table_2877
 
 drop table table_28779;
 
+#
+# Check new MariaDB comment syntax
+#
+
+select 1 + /*!M00000 2 */ + 3 /*!M99999 noise*/ + 4;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2011-05-28 02:11:32 +0000
+++ b/sql/slave.cc	2011-08-11 13:01:54 +0000
@@ -3842,7 +3842,6 @@ static int queue_event(Master_info* mi,c
       (uchar)buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
     DBUG_RETURN(queue_old_event(mi,buf,event_len));
 
-  LINT_INIT(inc_pos);
   pthread_mutex_lock(&mi->data_lock);
 
   switch ((uchar)buf[EVENT_TYPE_OFFSET]) {

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-07-14 04:06:28 +0000
+++ b/sql/sql_lex.cc	2011-08-11 13:01:54 +0000
@@ -1277,34 +1277,30 @@ int MYSQLlex(void *arg, void *yythd)
         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);
+        /* Skip MariaDB unique marker */
+        if (lip->yyPeekn(0) == 'M')
+          lip->yySkip();
 
         /*
           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