MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Anurag Shekhar Date:November 13 2009 7:45am
Subject:bzr commit into mysql-pe branch (anurag.shekhar:3679) Bug#47012
View as plain text  
#At file:///home/anurag/mysqlsrc/mysql-pe/ based on revid:alexey.kopytov@stripped

 3679 Anurag Shekhar	2009-11-13 [merge]
      merging fix for bug#47012.

    added:
      mysql-test/std_data/bug47012.ARM
      mysql-test/std_data/bug47012.ARZ
      mysql-test/std_data/bug47012.frm
    modified:
      mysql-test/r/archive.result
      mysql-test/t/archive.test
      storage/archive/azio.c
      storage/archive/ha_archive.cc
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result	2009-09-10 07:13:39 +0000
+++ b/mysql-test/r/archive.result	2009-11-13 07:42:53 +0000
@@ -12731,3 +12731,14 @@ id	id	name	name
 1	1	a	b
 2	2	a	b
 DROP TABLE t1,t2;
+SHOW CREATE TABLE t1;
+ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+SELECT * FROM t1;
+ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+INSERT INTO t1 (col1, col2) VALUES (1, "value");
+ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+REPAIR TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	Error	Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+test.t1	repair	error	Corrupt
+DROP TABLE t1;

=== added file 'mysql-test/std_data/bug47012.ARM'
Binary files a/mysql-test/std_data/bug47012.ARM	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/bug47012.ARM	2009-11-11 08:03:29 +0000 differ

=== added file 'mysql-test/std_data/bug47012.ARZ'
Binary files a/mysql-test/std_data/bug47012.ARZ	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/bug47012.ARZ	2009-11-11 08:03:29 +0000 differ

=== added file 'mysql-test/std_data/bug47012.frm'
Binary files a/mysql-test/std_data/bug47012.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/bug47012.frm	2009-11-11 08:03:29 +0000 differ

=== modified file 'mysql-test/t/archive.test'
--- a/mysql-test/t/archive.test	2009-09-10 07:13:39 +0000
+++ b/mysql-test/t/archive.test	2009-11-13 07:42:53 +0000
@@ -1637,3 +1637,24 @@ CREATE TABLE t2(id INT NOT NULL AUTO_INC
 INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
 SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
 DROP TABLE t1,t2;
+
+#
+# BUG#47012 archive tables are not upgradeable, and server crashes on any access
+#
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug47012.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/bug47012.ARZ $MYSQLD_DATADIR/test/t1.ARZ;
+copy_file std_data/bug47012.ARM $MYSQLD_DATADIR/test/t1.ARM;
+
+--error ER_TABLE_NEEDS_UPGRADE
+SHOW CREATE TABLE t1;
+
+--error ER_TABLE_NEEDS_UPGRADE
+SELECT * FROM t1;
+
+--error ER_TABLE_NEEDS_UPGRADE
+INSERT INTO t1 (col1, col2) VALUES (1, "value");
+
+REPAIR TABLE t1;
+DROP TABLE t1;
+remove_file $MYSQLD_DATADIR/test/t1.ARM;

=== modified file 'storage/archive/azio.c'
--- a/storage/archive/azio.c	2009-08-21 21:06:34 +0000
+++ b/storage/archive/azio.c	2009-11-13 07:42:53 +0000
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <assert.h>
 
+static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
 static int const az_magic[3] = {0xfe, 0x03, 0x01}; /* az magic header */
 
 /* gzip flag uchar */
@@ -182,8 +183,8 @@ int azopen(azio_stream *s, const char *p
   s->crc = crc32(0L, Z_NULL, 0);
   s->mode = 'r';
   s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */
-  s->version = (unsigned char)az_magic[2]; /* minor version */
   s->method= method;
+  s->minor_version= (unsigned char) az_magic[2]; /* minor version */
 
   /*
     We do our own version of append by nature. 
@@ -359,7 +360,10 @@ int get_byte(s)
 */
 void check_header(azio_stream *s)
 {
+  int method; /* method uchar */
+  int flags;  /* flags uchar */
   uInt len;
+  int c;
 
   /* Assure two bytes in the buffer so we can peek ahead -- handle case
     where first byte of header is at the end of the buffer after the last
@@ -387,8 +391,19 @@ void check_header(azio_stream *s)
     for (; len < s->start; len++)
       get_byte(s);
   }
-  else
+  else if ( s->stream.next_in[0] == gz_magic[0]
+                && s->stream.next_in[1] == gz_magic[1])
   {
+    /*
+      Header suggests that its older archive.
+      Can't process this until upgraded.
+    */
+    s->stream.avail_in -= 2;
+    s->stream.next_in += 2;
+    s->version= (unsigned char)2;
+    s->z_err= Z_OK;
+
+  } else {
     s->z_err = Z_OK;
 
     return;
@@ -415,10 +430,20 @@ void read_header(azio_stream *s, unsigne
     s->comment_length= (unsigned int)uint4korr(buffer + AZ_COMMENT_LENGTH_POS);
     s->dirty= (unsigned int)buffer[AZ_DIRTY_POS];
   }
-  else
+  else if (buffer[0] == gz_magic[0]  && buffer[1] == gz_magic[1])
   {
     s->z_err = Z_OK;
-    return;
+    /*
+      Set version number to previous version (2).
+    */
+    s->version= (unsigned char) 2;
+  } else {
+    /*
+      Unknown version.
+      Most probably due to a corrupt archive.
+    */
+    s->dirty= AZ_STATE_DIRTY;
+    s->z_err= Z_VERSION_ERROR;
   }
 }
 

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2009-10-23 11:41:42 +0000
+++ b/storage/archive/ha_archive.cc	2009-11-13 07:42:53 +0000
@@ -349,6 +349,12 @@ ARCHIVE_SHARE *ha_archive::get_share(con
       share->version_rows= share->rows_recorded;
       share->version= global_version;
     }
+    /*
+      If archive version is less than 3, It should be upgraded before
+      use.
+    */
+    if (archive_tmp.version < ARCHIVE_VERSION)
+      *rc= HA_ERR_TABLE_NEEDS_UPGRADE;
     azclose(&archive_tmp);
 
     (void) my_hash_insert(&archive_open_tables, (uchar*) share);
@@ -494,7 +500,15 @@ int ha_archive::open(const char *name, i
                       (open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no"));
   share= get_share(name, &rc);
 
-  if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
+ /*
+    Allow open on crashed table in repair mode only.
+    Block open on 5.0 ARCHIVE table. Though we have almost all
+    routines to access these tables, they were not well tested.
+    For now we have to refuse to open such table to avoid
+    potential data loss.
+  */
+  if ((rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
+      ||  rc == HA_ERR_TABLE_NEEDS_UPGRADE)
   {
     /* purecov: begin inspected */
     free_share();


Attachment: [text/bzr-bundle] bzr/anurag.shekhar@sun.com-20091113074253-q5595y3wzoete8qz.bundle
Thread
bzr commit into mysql-pe branch (anurag.shekhar:3679) Bug#47012Anurag Shekhar13 Nov