List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:April 10 2012 10:00am
Subject:bzr push into mysql-trunk branch (magnus.blaudd:3734 to 3735) WL#5961
View as plain text  
 3735 magnus.blaudd@stripped	2012-04-10
      WL#5961 Simplified syntax extensions for CREATE TABLE
       - Fix review comments
       - Add explicit case labels for all allowed values of COLUMN_FORMAT and
       STORAGE in sql_show.cc
       - Make sure that no one is using the bits in field::flags reserved for
         STORAGE and COLUMN_FORMAT
       - Clear the value(the bits) in Lex->type before setting the new, thus
         allowing multiple COLUM_FORMAT or STORAGE deifintions  in the same CREATE or
         ALTER
       - Add comments describing "column_format_type" 
       - Add testcases for MODIFY COLUMN and the new attributes
       - Add testcases for multipli defienitons of the new attributes

    modified:
      include/mysql_com.h
      mysql-test/r/tablespace.result
      mysql-test/t/tablespace.test
      sql/field.h
      sql/handler.h
      sql/sql_show.cc
      sql/sql_yacc.yy
 3734 magnus.blaudd@stripped	2012-03-13
      WL#5961
       - fix review comments
       - the "magic version" should be 5.6.6 although this syntax
         is understood by MySQL Cluster from 5.1.20
       - update .result file

    modified:
      mysql-test/r/tablespace.result
      sql/sql_show.cc
=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h	2012-03-06 14:29:42 +0000
+++ b/include/mysql_com.h	2012-04-10 09:29:14 +0000
@@ -115,10 +115,10 @@ enum enum_server_command
 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
 #define FIELD_IN_ADD_INDEX (1<< 20)	/* Intern: Field used in ADD INDEX */
 #define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
-#define FIELD_FLAGS_STORAGE_MEDIA 22    /* Field storage media, bit 22-23,
-                                           reserved by MySQL Cluster */
-#define FIELD_FLAGS_COLUMN_FORMAT 24    /* Field column format, bit 24-25,
-                                           reserved by MySQL Cluster */
+#define FIELD_FLAGS_STORAGE_MEDIA 22    /* Field storage media, bit 22-23 */
+#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
+#define FIELD_FLAGS_COLUMN_FORMAT 24    /* Field column format, bit 24-25 */
+#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
 
 #define REFRESH_GRANT		1	/* Refresh grant tables */
 #define REFRESH_LOG		2	/* Start on new log file */

=== modified file 'mysql-test/r/tablespace.result'
--- a/mysql-test/r/tablespace.result	2012-03-13 14:37:22 +0000
+++ b/mysql-test/r/tablespace.result	2012-04-10 09:29:14 +0000
@@ -110,6 +110,9 @@ t1	CREATE TABLE `t1` (
   PRIMARY KEY (`a`)
 ) /*!50100 TABLESPACE the_tablespacename STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;
+#
+# WL#3627 Add COLUMN_FORMAT and STORAGE for fields
+#
 CREATE TABLE t1 (
 a int STORAGE DISK,
 b int STORAGE MEMORY NOT NULL,
@@ -166,4 +169,73 @@ t1	CREATE TABLE `t1` (
   `q` int(11) /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
   `r` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1
+MODIFY COLUMN j int STORAGE MEMORY NOT NULL,
+MODIFY COLUMN k int COLUMN_FORMAT DYNAMIC,
+MODIFY COLUMN l int COLUMN_FORMAT FIXED,
+MODIFY COLUMN m int COLUMN_FORMAT DEFAULT,
+MODIFY COLUMN n int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+MODIFY COLUMN o int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+MODIFY COLUMN p int STORAGE DISK COLUMN_FORMAT FIXED,
+MODIFY COLUMN q int STORAGE MEMORY COLUMN_FORMAT FIXED,
+MODIFY COLUMN r int STORAGE DISK;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) /*!50606 STORAGE DISK */ DEFAULT NULL,
+  `b` int(11) NOT NULL /*!50606 STORAGE MEMORY */,
+  `c` int(11) /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `d` int(11) /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `e` int(11) DEFAULT NULL,
+  `f` int(11) NOT NULL /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT DYNAMIC */,
+  `g` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `h` int(11) /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `i` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `j` int(11) NOT NULL /*!50606 STORAGE MEMORY */,
+  `k` int(11) /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `l` int(11) /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `m` int(11) DEFAULT NULL,
+  `n` int(11) NOT NULL /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT DYNAMIC */,
+  `o` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `p` int(11) /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `q` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `r` int(11) /*!50606 STORAGE DISK */ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1
+MODIFY COLUMN h int COLUMN_FORMAT DYNAMIC COLUMN_FORMAT FIXED,
+MODIFY COLUMN i int COLUMN_FORMAT DYNAMIC COLUMN_FORMAT DEFAULT,
+MODIFY COLUMN j int COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC,
+MODIFY COLUMN k int COLUMN_FORMAT FIXED COLUMN_FORMAT DEFAULT,
+MODIFY COLUMN l int STORAGE DISK STORAGE MEMORY,
+MODIFY COLUMN m int STORAGE DISK STORAGE DEFAULT,
+MODIFY COLUMN n int STORAGE MEMORY STORAGE DISK,
+MODIFY COLUMN o int STORAGE MEMORY STORAGE DEFAULT,
+MODIFY COLUMN p int STORAGE DISK STORAGE MEMORY
+COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC,
+MODIFY COLUMN q int STORAGE DISK STORAGE MEMORY STORAGE DEFAULT
+COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC COLUMN_FORMAT DEFAULT,
+MODIFY COLUMN r int STORAGE DEFAULT STORAGE DEFAULT STORAGE MEMORY
+STORAGE DISK STORAGE MEMORY STORAGE DISK STORAGE DISK;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) /*!50606 STORAGE DISK */ DEFAULT NULL,
+  `b` int(11) NOT NULL /*!50606 STORAGE MEMORY */,
+  `c` int(11) /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `d` int(11) /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `e` int(11) DEFAULT NULL,
+  `f` int(11) NOT NULL /*!50606 STORAGE DISK */ /*!50606 COLUMN_FORMAT DYNAMIC */,
+  `g` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `h` int(11) /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
+  `i` int(11) DEFAULT NULL,
+  `j` int(11) /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `k` int(11) DEFAULT NULL,
+  `l` int(11) /*!50606 STORAGE MEMORY */ DEFAULT NULL,
+  `m` int(11) DEFAULT NULL,
+  `n` int(11) /*!50606 STORAGE DISK */ DEFAULT NULL,
+  `o` int(11) DEFAULT NULL,
+  `p` int(11) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL,
+  `q` int(11) DEFAULT NULL,
+  `r` int(11) /*!50606 STORAGE DISK */ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;

=== modified file 'mysql-test/t/tablespace.test'
--- a/mysql-test/t/tablespace.test	2012-03-08 19:28:40 +0000
+++ b/mysql-test/t/tablespace.test	2012-04-10 09:29:14 +0000
@@ -107,10 +107,6 @@ DROP TABLE t1;
 #   k int STORAGE MEMORY COLUMN_FORMAT FIXED
 # ) STORAGE DISK TABLESPACE the_tablespacename ENGINE=MyISAM;
 #
-# NOTE! The column level properties will not yet show up
-# in SHOW CREATE TABLE of MySQL Server(although they are
-# visible in .trace file)
-#
 
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 copy_file std_data/cluster_7022_table.frm $MYSQLD_DATADIR/test/t1.frm;
@@ -121,9 +117,9 @@ SHOW CREATE TABLE t1;
 
 DROP TABLE t1;
 
-#
-# WL#3627 Add COLUMN_FORMAT and STORAGE for fields
-#
+--echo #
+--echo # WL#3627 Add COLUMN_FORMAT and STORAGE for fields
+--echo #
 
 CREATE TABLE t1 (
  a int STORAGE DISK,
@@ -138,6 +134,8 @@ CREATE TABLE t1 (
 );
 SHOW CREATE TABLE t1;
 
+# Add new columns with all variations of the new column
+# level attributes
 ALTER TABLE t1
   ADD COLUMN j int STORAGE DISK,
   ADD COLUMN k int STORAGE MEMORY NOT NULL,
@@ -150,5 +148,38 @@ ALTER TABLE t1
   ADD COLUMN r int STORAGE MEMORY COLUMN_FORMAT FIXED;
 SHOW CREATE TABLE t1;
 
+# Use MODIFY COLUMN to "shift" all new attributes to the next column
+ALTER TABLE t1
+  MODIFY COLUMN j int STORAGE MEMORY NOT NULL,
+  MODIFY COLUMN k int COLUMN_FORMAT DYNAMIC,
+  MODIFY COLUMN l int COLUMN_FORMAT FIXED,
+  MODIFY COLUMN m int COLUMN_FORMAT DEFAULT,
+  MODIFY COLUMN n int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+  MODIFY COLUMN o int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+  MODIFY COLUMN p int STORAGE DISK COLUMN_FORMAT FIXED,
+  MODIFY COLUMN q int STORAGE MEMORY COLUMN_FORMAT FIXED,
+  MODIFY COLUMN r int STORAGE DISK;
+SHOW CREATE TABLE t1;
+
+# Check behaviour of multiple COLUMN_FORMAT and/or STORAGE definitions
+ALTER TABLE t1
+  MODIFY COLUMN h int COLUMN_FORMAT DYNAMIC COLUMN_FORMAT FIXED,
+  MODIFY COLUMN i int COLUMN_FORMAT DYNAMIC COLUMN_FORMAT DEFAULT,
+  MODIFY COLUMN j int COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC,
+  MODIFY COLUMN k int COLUMN_FORMAT FIXED COLUMN_FORMAT DEFAULT,
+  MODIFY COLUMN l int STORAGE DISK STORAGE MEMORY,
+  MODIFY COLUMN m int STORAGE DISK STORAGE DEFAULT,
+  MODIFY COLUMN n int STORAGE MEMORY STORAGE DISK,
+  MODIFY COLUMN o int STORAGE MEMORY STORAGE DEFAULT,
+  MODIFY COLUMN p int STORAGE DISK STORAGE MEMORY
+                      COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC,
+  MODIFY COLUMN q int STORAGE DISK STORAGE MEMORY STORAGE DEFAULT
+                      COLUMN_FORMAT FIXED COLUMN_FORMAT DYNAMIC COLUMN_FORMAT DEFAULT,
+  MODIFY COLUMN r int STORAGE DEFAULT STORAGE DEFAULT STORAGE MEMORY
+                      STORAGE DISK STORAGE MEMORY STORAGE DISK STORAGE DISK;
+SHOW CREATE TABLE t1;
+
+
+
 DROP TABLE t1;
 

=== modified file 'sql/field.h'
--- a/sql/field.h	2012-03-08 19:28:40 +0000
+++ b/sql/field.h	2012-04-10 09:29:14 +0000
@@ -1024,9 +1024,10 @@ public:
       ((flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3);
   }
 
-  void set_storage_type(ha_storage_media storage_type)
+  void set_storage_type(ha_storage_media storage_type_arg)
   {
-    flags |= (storage_type << FIELD_FLAGS_STORAGE_MEDIA);
+    DBUG_ASSERT(field_storage_type() == HA_SM_DEFAULT);
+    flags |= (storage_type_arg << FIELD_FLAGS_STORAGE_MEDIA);
   }
 
   column_format_type column_format() const
@@ -1035,9 +1036,10 @@ public:
       ((flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3);
   }
 
-  void set_column_format(column_format_type column_format)
+  void set_column_format(column_format_type column_format_arg)
   {
-    flags |= (column_format << FIELD_FLAGS_COLUMN_FORMAT);
+    DBUG_ASSERT(column_format() == COLUMN_FORMAT_TYPE_DEFAULT);
+    flags |= (column_format_arg << FIELD_FLAGS_COLUMN_FORMAT);
   }
 
   /* Hash value */

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2012-03-08 19:28:40 +0000
+++ b/sql/handler.h	2012-04-10 09:29:14 +0000
@@ -357,10 +357,11 @@ enum row_type { ROW_TYPE_NOT_USED=-1, RO
                 /** Unused. Reserved for future versions. */
                 ROW_TYPE_PAGE };
 
+/* Specifies data storage format for individual columns */
 enum column_format_type {
-  COLUMN_FORMAT_TYPE_DEFAULT=   0,
-  COLUMN_FORMAT_TYPE_FIXED=     1,
-  COLUMN_FORMAT_TYPE_DYNAMIC=   2
+  COLUMN_FORMAT_TYPE_DEFAULT=   0, /* Not specified (use engine default) */
+  COLUMN_FORMAT_TYPE_FIXED=     1, /* FIXED format */
+  COLUMN_FORMAT_TYPE_DYNAMIC=   2  /* DYNAMIC format */
 };
 
 enum enum_binlog_func {

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2012-03-13 14:37:22 +0000
+++ b/sql/sql_show.cc	2012-04-10 09:29:14 +0000
@@ -1544,6 +1544,8 @@ int store_create_info(THD *thd, TABLE_LI
     }
 
     switch(field->field_storage_type()){
+    case HA_SM_DEFAULT:
+      break;
     case HA_SM_DISK:
       packet->append(STRING_WITH_LEN(" /*!50606 STORAGE DISK */"));
       break;
@@ -1551,10 +1553,13 @@ int store_create_info(THD *thd, TABLE_LI
       packet->append(STRING_WITH_LEN(" /*!50606 STORAGE MEMORY */"));
       break;
     default:
+      DBUG_ASSERT(0);
       break;
     }
 
     switch(field->column_format()){
+    case COLUMN_FORMAT_TYPE_DEFAULT:
+      break;
     case COLUMN_FORMAT_TYPE_FIXED:
       packet->append(STRING_WITH_LEN(" /*!50606 COLUMN_FORMAT FIXED */"));
       break;
@@ -1562,6 +1567,7 @@ int store_create_info(THD *thd, TABLE_LI
       packet->append(STRING_WITH_LEN(" /*!50606 COLUMN_FORMAT DYNAMIC */"));
       break;
     default:
+      DBUG_ASSERT(0);
       break;
     }
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2012-03-08 19:28:40 +0000
+++ b/sql/sql_yacc.yy	2012-04-10 09:29:14 +0000
@@ -6183,29 +6183,35 @@ attribute:
           }
         | COLUMN_FORMAT_SYM DEFAULT
           {
+            Lex->type&= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
             Lex->type|=
               (COLUMN_FORMAT_TYPE_DEFAULT << FIELD_FLAGS_COLUMN_FORMAT);
           }
         | COLUMN_FORMAT_SYM FIXED_SYM
           {
+            Lex->type&= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
             Lex->type|=
               (COLUMN_FORMAT_TYPE_FIXED << FIELD_FLAGS_COLUMN_FORMAT);
           }
         | COLUMN_FORMAT_SYM DYNAMIC_SYM
           {
+            Lex->type&= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
             Lex->type|=
               (COLUMN_FORMAT_TYPE_DYNAMIC << FIELD_FLAGS_COLUMN_FORMAT);
           }
         | STORAGE_SYM DEFAULT
           {
+            Lex->type&= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
             Lex->type|= (HA_SM_DEFAULT << FIELD_FLAGS_STORAGE_MEDIA);
           }
         | STORAGE_SYM DISK_SYM
           {
+            Lex->type&= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
             Lex->type|= (HA_SM_DISK << FIELD_FLAGS_STORAGE_MEDIA);
           }
         | STORAGE_SYM MEMORY_SYM
           {
+            Lex->type&= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
             Lex->type|= (HA_SM_MEMORY << FIELD_FLAGS_STORAGE_MEDIA);
           }
         ;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (magnus.blaudd:3734 to 3735) WL#5961magnus.blaudd10 Apr