[Commits] Rev 2910: Merge with 5.1 in lp:maria/5.2

Michael Widenius monty at askmonty.org
Wed Jan 12 17:38:21 EET 2011


At lp:maria/5.2

------------------------------------------------------------
revno: 2910 [merge]
revision-id: monty at askmonty.org-20110112153813-xlyrhakqe5j3r9ae
parent: monty at askmonty.org-20110111122919-bw89ue0th734hes7
parent: monty at askmonty.org-20110112143252-054j7pvmvhs73cfj
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.2
timestamp: Wed 2011-01-12 17:38:13 +0200
message:
  Merge with 5.1
modified:
  mysql-test/r/table_elim.result table_elim.result-20090603125022-nge13y0ohk1g2tt2-1
  mysql-test/suite/handler/innodb.result sp1f-innodb_handler.resul-20020821205505-jopsqbjuqwwxb5hvf3r2wn37vobunxru
  mysql-test/suite/handler/innodb.test sp1f-innodb_handler.test-20020821205505-gwqk7yb24jcfxay37a2svxwwoqq4ybdr
  mysql-test/t/table_elim.test   table_elim.test-20090603125018-ka3vcfrm07bsldz8-1
  sql/handler.h                  sp1f-handler.h-19700101030959-mumq2hpilkpgxuf22ftyv5kbilysnzvn
  sql/table.h                    sp1f-table.h-19700101030959-dv72bajftxj5fbdjuajquappanuv2ija
  storage/federated/ha_federated.cc sp1f-ha_federated.cc-20041211200120-gu52ex5sicbua5vtoocuki3ltllsvm2c
  storage/maria/ha_maria.cc      sp1f-ha_maria.cc-20060411134405-dmngb4v5x5fxlxhff527ud3etiutxuxk
  storage/maria/ma_pagecache.c   sp1f-mf_pagecache.c-20060706081022-sq6xnd367a2snwk4dup6yokn4paw7b5e
  storage/maria/maria_read_log.c sp1f-maria_read_log.c-20070626144920-3n32phkjk3xrsid3ksgnuicghunwwfzt
-------------- next part --------------
=== modified file 'mysql-test/r/table_elim.result'
--- a/mysql-test/r/table_elim.result	2010-09-11 15:20:35 +0000
+++ b/mysql-test/r/table_elim.result	2011-01-11 10:42:16 +0000
@@ -535,3 +535,34 @@ HAVING
 field4 != 6;
 field1  field2  field3  field4  field5  field6
 drop table t0,t1,t2,t3,t4,t5,t6;
+#
+# BUG#675118: Elimination of a table results in an invalid execution plan
+#
+CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ;
+CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ;
+Warnings:
+Warning 1071    Specified key was too long; max key length is 1000 bytes
+INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'),
+('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'),
+('hczkfqjeggivdvac'),('e'),('okay'),('up');
+CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ;
+INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416');
+CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ;
+INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c');
+CREATE TABLE t5 (f5 int(11), KEY (f5)) ;
+EXPLAIN 
+SELECT t3.f2
+FROM t2
+LEFT JOIN t3
+LEFT JOIN t4
+LEFT JOIN t1 ON t4.f1 = t1.f1
+JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4
+WHERE t3.f2 ;
+id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
+1       SIMPLE  t3      ALL     NULL    NULL    NULL    NULL    2       Using where
+1       SIMPLE  t5      ref     f5      f5      5       test.t3.f1      2       Using index
+1       SIMPLE  t4      ALL     NULL    NULL    NULL    NULL    3       
+1       SIMPLE  t2      ALL     f4      NULL    NULL    NULL    11      Using where; Using join buffer
+# ^^ The above must not produce a QEP of t3,t5,t2,t4
+#    as that violates the "no interleaving of outer join nests" rule.
+DROP TABLE t1,t2,t3,t4,t5;

=== modified file 'mysql-test/suite/handler/innodb.result'
--- a/mysql-test/suite/handler/innodb.result	2011-01-10 21:22:40 +0000
+++ b/mysql-test/suite/handler/innodb.result	2011-01-12 13:41:39 +0000
@@ -560,3 +560,13 @@ HANDLER t1 READ a NEXT;
 a
 HANDLER t1 CLOSE;
 DROP TABLE t1;
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+f1      f2
+1       1
+HANDLER t1 READ `PRIMARY` PREV;
+f1      f2
+3       3
+DROP TABLE t1;

=== modified file 'mysql-test/suite/handler/innodb.test'
--- a/mysql-test/suite/handler/innodb.test	2011-01-10 21:22:40 +0000
+++ b/mysql-test/suite/handler/innodb.test	2011-01-12 13:41:39 +0000
@@ -15,3 +15,14 @@ let $engine_type= InnoDB;
 
 --source init.inc
 --source handler.inc
+
+#
+# LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX'
+#
+
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+HANDLER t1 READ `PRIMARY` PREV;
+DROP TABLE t1;

=== modified file 'mysql-test/t/table_elim.test'
--- a/mysql-test/t/table_elim.test	2010-03-06 12:09:02 +0000
+++ b/mysql-test/t/table_elim.test	2011-01-11 10:42:16 +0000
@@ -467,3 +467,35 @@ HAVING
   field4 != 6;
 
 drop table t0,t1,t2,t3,t4,t5,t6;
+
+--echo #
+--echo # BUG#675118: Elimination of a table results in an invalid execution plan
+--echo #
+CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ;
+
+CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ;
+INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'),
+   ('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'),
+   ('hczkfqjeggivdvac'),('e'),('okay'),('up');
+
+CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ;
+INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416');
+
+CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ;
+INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c');
+
+CREATE TABLE t5 (f5 int(11), KEY (f5)) ;
+
+EXPLAIN 
+SELECT t3.f2
+FROM t2
+LEFT JOIN t3
+LEFT JOIN t4
+LEFT JOIN t1 ON t4.f1 = t1.f1
+JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4
+WHERE t3.f2 ;
+--echo # ^^ The above must not produce a QEP of t3,t5,t2,t4
+--echo #    as that violates the "no interleaving of outer join nests" rule.
+
+DROP TABLE t1,t2,t3,t4,t5;
+

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-01-10 21:42:47 +0000
+++ b/sql/handler.h	2011-01-12 15:38:13 +0000
@@ -1321,14 +1321,18 @@ class handler :public Sql_alloc
     DBUG_ENTER("ha_index_init");
     DBUG_ASSERT(inited==NONE);
     if (!(result= index_init(idx, sorted)))
-      inited=INDEX;
+    {
+      inited=       INDEX;
+      active_index= idx;
+    }
     DBUG_RETURN(result);
   }
   int ha_index_end()
   {
     DBUG_ENTER("ha_index_end");
     DBUG_ASSERT(inited==INDEX);
-    inited=NONE;
+    inited=       NONE;
+    active_index= MAX_KEY;
     DBUG_RETURN(index_end());
   }
   /* This is called after index_init() if we need to do a index scan */
@@ -1511,7 +1515,12 @@ class handler :public Sql_alloc
     as there may be several calls to this routine.
   */
   virtual void column_bitmaps_signal();
-  uint get_index(void) const { return active_index; }
+  /*
+    We have to check for inited as some engines, like innodb, sets
+    active_index during table scan.
+  */
+  uint get_index(void) const
+  { return inited == INDEX ? active_index : MAX_KEY; }
   virtual int close(void)=0;
 
   /**
@@ -1997,8 +2006,8 @@ class handler :public Sql_alloc
   */
 
   virtual int open(const char *name, int mode, uint test_if_locked)=0;
-  virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
-  virtual int index_end() { active_index= MAX_KEY; return 0; }
+  virtual int index_init(uint idx, bool sorted) { return 0; }
+  virtual int index_end() { return 0; }
   /**
     rnd_init() can be called two times without rnd_end() in between
     (it only makes sense if scan=1).

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-11-30 21:11:03 +0000
+++ b/sql/table.h	2011-01-12 15:38:13 +0000
@@ -1781,7 +1781,7 @@ typedef struct st_nested_join
 
      2. All child join nest nodes are fully covered.
    */
-  bool is_fully_covered() const { return join_list.elements == counter; }
+  bool is_fully_covered() const { return n_tables == counter; }
 } NESTED_JOIN;
 
 

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2010-09-11 18:43:48 +0000
+++ b/storage/federated/ha_federated.cc	2011-01-12 15:38:13 +0000
@@ -2453,7 +2453,6 @@ int ha_federated::index_init(uint keynr,
 {
   DBUG_ENTER("ha_federated::index_init");
   DBUG_PRINT("info", ("table: '%s'  key: %u", table->s->table_name.str, keynr));
-  active_index= keynr;
   DBUG_RETURN(0);
 }
 
@@ -2589,7 +2588,6 @@ int ha_federated::index_end(void)
 {
   DBUG_ENTER("ha_federated::index_end");
   free_result();
-  active_index= MAX_KEY;
   DBUG_RETURN(0);
 }
 

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2011-01-07 16:07:22 +0000
+++ b/storage/maria/ha_maria.cc	2011-01-12 15:38:13 +0000
@@ -228,7 +228,7 @@ static MYSQL_SYSVAR_ULONGLONG(pagecache_
        "The size of the buffer used for index blocks for Aria tables. "
        "Increase this to get better index handling (for all reads and "
        "multiple writes) to as much as you can afford.", 0, 0,
-       KEY_CACHE_SIZE, 0, ~(ulong) 0, 1);
+       KEY_CACHE_SIZE, 8192*16L, ~(ulong) 0, 1);
 
 static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit,
        PLUGIN_VAR_RQCMDARG,

=== modified file 'storage/maria/ma_pagecache.c'
--- a/storage/maria/ma_pagecache.c	2011-01-07 10:17:34 +0000
+++ b/storage/maria/ma_pagecache.c	2011-01-12 15:38:13 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2008 MySQL AB
+/* Copyright (C) 2000-2008 MySQL AB, 2008-2011 Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -760,6 +760,8 @@ ulong init_pagecache(PAGECACHE *pagecach
   {
     if (blocks < 8)
     {
+      my_message(ENOMEM, "Not enough memory to allocate 8 pagecache pages",
+                 MYF(0));
       my_errno= ENOMEM;
       goto err;
     }
@@ -4214,6 +4216,7 @@ static void free_block(PAGECACHE *pageca
   DBUG_ASSERT(block->rlocks == 0);
   DBUG_ASSERT(block->rlocks_queue == 0);
   DBUG_ASSERT(block->pins == 0);
+  DBUG_ASSERT((block->status & ~(PCBLOCK_ERROR | PCBLOCK_READ | PCBLOCK_IN_FLUSH | PCBLOCK_CHANGED | PCBLOCK_REASSIGNED)) == 0);
   block->status= 0;
 #ifndef DBUG_OFF
   block->type= PAGECACHE_EMPTY_PAGE;
@@ -4542,6 +4545,7 @@ static int flush_pagecache_blocks_int(PA
           KEYCACHE_DBUG_ASSERT(count<= pagecache->blocks_used);
         }
       }
+      count++;    /* Allocate one extra for easy end-of-buffer test */
       /* Allocate a new buffer only if its bigger than the one we have */
       if (count > FLUSH_CACHE &&
           !(cache=
@@ -4579,22 +4583,24 @@ static int flush_pagecache_blocks_int(PA
         DBUG_ASSERT(filter_res == FLUSH_FILTER_OK);
       }
       {
+        DBUG_ASSERT(!(block->status & PCBLOCK_IN_FLUSH));
         /*
-           Mark the block with BLOCK_IN_FLUSH in order not to let
-           other threads to use it for new pages and interfere with
-           our sequence of flushing dirty file pages
+          We care only for the blocks for which flushing was not
+          initiated by other threads as a result of page swapping
         */
-        block->status|= PCBLOCK_IN_FLUSH;
-
         if (! (block->status & PCBLOCK_IN_SWITCH))
         {
-          /*
-            We care only for the blocks for which flushing was not
-            initiated by other threads as a result of page swapping
+          /*
+            Mark the block with BLOCK_IN_FLUSH in order not to let
+            other threads to use it for new pages and interfere with
+            our sequence of flushing dirty file pages
           */
+          block->status|= PCBLOCK_IN_FLUSH;
+
           reg_requests(pagecache, block, 1);
           if (type != FLUSH_IGNORE_CHANGED)
           {
+            *pos++= block;
             /* It's not a temporary file */
             if (pos == end)
             {
@@ -4614,7 +4620,6 @@ static int flush_pagecache_blocks_int(PA
               */
               goto restart;
             }
-            *pos++= block;
           }
           else
           {

=== modified file 'storage/maria/maria_read_log.c'
--- a/storage/maria/maria_read_log.c	2011-01-07 10:05:46 +0000
+++ b/storage/maria/maria_read_log.c	2011-01-12 15:38:13 +0000
@@ -192,14 +192,18 @@ static struct my_option my_long_options[
   {"display-only", 'd', "display brief info read from records' header",
    &opt_display_only, &opt_display_only, 0, GET_BOOL,
    NO_ARG,0, 0, 0, 0, 0, 0},
+  { "end-lsn", 'e', "Stop applying at this lsn. If end-lsn is used, UNDO:s "
+    "will not be applied", &opt_end_lsn, &opt_end_lsn,
+    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
   {"aria-log-dir-path", 'l',
     "Path to the directory where to store transactional log",
     (uchar **) &maria_data_root, (uchar **) &maria_data_root, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  { "page-buffer-size", 'P', "",
+  { "page-buffer-size", 'P',
+    "The size of the buffer used for index blocks for Maria tables",
     &opt_page_buffer_size, &opt_page_buffer_size, 0,
     GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT,
-    (long) USE_BUFFER_INIT, (long) ~(ulong) 0, (long) MALLOC_OVERHEAD,
+    1024L*1024L, (long) ~(ulong) 0, (long) MALLOC_OVERHEAD,
     (long) IO_SIZE, 0},
   { "start-from-lsn", 'o', "Start reading log from this lsn",
     &opt_start_from_lsn, &opt_start_from_lsn,
@@ -207,18 +211,12 @@ static struct my_option my_long_options[
   {"start-from-checkpoint", 'C', "Start applying from last checkpoint",
    &opt_start_from_checkpoint, &opt_start_from_checkpoint, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  { "end-lsn", 'e', "Stop applying at this lsn. If end-lsn is used, UNDO:s "
-    "will not be applied", &opt_end_lsn, &opt_end_lsn,
-    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
   {"silent", 's', "Print less information during apply/undo phase",
    &opt_silent, &opt_silent, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"tables-to-redo", 'T',
    "List of tables sepearated with , that we should apply REDO on. Use this if you only want to recover some tables",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"verbose", 'v', "Print more information during apply/undo phase",
-   &maria_recovery_verbose, &maria_recovery_verbose, 0,
-   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"tmpdir", 't', "Path for temporary files. Multiple paths can be specified, "
    "separated by "
 #if defined( __WIN__) || defined(__NETWARE__)
@@ -230,6 +228,9 @@ static struct my_option my_long_options[
   {"undo", 'u', "Apply UNDO records to tables. (disable with --disable-undo)",
    (uchar **) &opt_apply_undo, (uchar **) &opt_apply_undo, 0,
    GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+  {"verbose", 'v', "Print more information during apply/undo phase",
+   &maria_recovery_verbose, &maria_recovery_verbose, 0,
+   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"version", 'V', "Print version and exit.",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}



More information about the commits mailing list