List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:May 3 2012 10:43am
Subject:bzr push into mysql-5.5-cluster-7.2 branch (ole.john.aske:3907 to 3908)
View as plain text  
 3908 Ole John Aske	2012-05-03
      Backported some WL5940 related changes to 7.2-cluster:
      
        The handler extension ::test_push_flag() has now been removed.
        The two remaining HA_PUSH_<foo>-flags related to this extension
        has been made obsolete by:
      
        - HA_PUSH_BLOCK_CONST_TABLE is replaced with the 'test_flag'
          HA_BLOCK_CONST_TABLE. Furthermore it was identified that
          usage of this flag was obsolete at one of the places it was used.
          (As 'system' table optimization is not possible for handlers
           with non-EXACT statistics)
      
        - HA_PUSH_MULTIPLE_DEPENDENCY has been entirely removed as this
          covered a corner case with questionable advantage of being pushed.
          Previous changes to join_no_more_records() has been reverted.

    modified:
      mysql-test/suite/ndb/r/ndb_blob.result
      mysql-test/suite/ndb/r/ndb_dd_sql_features.result
      mysql-test/suite/ndb/r/ndb_join_pushdown_default.result
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/ha_ndbcluster_push.cc
      sql/handler.h
      sql/sql_select.cc
 3907 John David Duncan	2012-05-01
      Fix bug where the ndb_engine would log to stderr even if some other logger was configured in memcached.

    modified:
      storage/ndb/memcache/src/ndb_engine.c
=== modified file 'mysql-test/suite/ndb/r/ndb_blob.result'
--- a/mysql-test/suite/ndb/r/ndb_blob.result	2011-06-30 12:19:14 +0000
+++ b/mysql-test/suite/ndb/r/ndb_blob.result	2012-05-03 10:42:49 +0000
@@ -40,7 +40,7 @@ insert into t1 values(2,@b2,222,@d2);
 commit;
 explain select * from t1 where a = 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	#	
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	const	#	
 select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3)
 from t1 where a=1;
 a	length(b)	substr(b,1+2*900,2)	length(d)	substr(d,1+3*900,3)
@@ -89,7 +89,7 @@ replace t1 set a=2,b=@b2,c=222,d=@d2;
 commit;
 explain select * from t1 where a = 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	#	
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	const	#	
 select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3)
 from t1 where a=1;
 a	length(b)	substr(b,1+2*900,2)	length(d)	substr(d,1+3*900,3)

=== modified file 'mysql-test/suite/ndb/r/ndb_dd_sql_features.result'
--- a/mysql-test/suite/ndb/r/ndb_dd_sql_features.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dd_sql_features.result	2012-05-03 10:42:49 +0000
@@ -441,7 +441,7 @@ INSERT INTO test.t1 values(1,@vc1,@d1);
 INSERT INTO test.t1 values(2,@vc2,@d2);
 explain SELECT * from test.t1 WHERE a1 = 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	#	
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	const	#	
 SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3)
 FROM test.t1 WHERE a1=1 ORDER BY a1;
 a1	length(a2)	substr(a2,1+2*900,2)	length(a3)	substr(a3,1+3*900,3)

=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown_default.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown_default.result	2012-04-25 09:34:51 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown_default.result	2012-05-03 10:42:49 +0000
@@ -3392,10 +3392,11 @@ from t1, t2
 where t2.a = t1.b
 and t1.a = 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	1	100.00	
-1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	const	1	100.00	
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	const	1	100.00	
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.b	1	100.00	
 Warnings:
-Note	1003	select '2' AS `a`,'1' AS `b`,'kalle' AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '1'))
+Note	9999	Table 't1' is not pushable: select list can't contain BLOB columns
+Note	1003	select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`b`))
 select *
 from t1, t2
 where t2.a = t1.b
@@ -4847,11 +4848,12 @@ on table3.u = table1.u
 where table2.pk = 3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	13	100.00	
-1	SIMPLE	table2	eq_ref	PRIMARY,ix2	PRIMARY	4	const	1	100.00	Parent of 2 pushed join@1
-1	SIMPLE	table3	ref	ix2	ix2	9	test.table2.a,test.table1.u	1	100.00	Child of 'table2' in pushed join@1; Using where
+1	SIMPLE	table2	eq_ref	PRIMARY,ix2	PRIMARY	4	const	1	100.00	
+1	SIMPLE	table3	ref	ix2	ix2	9	test.table2.a,test.table1.u	1	100.00	Using where
 Warnings:
 Note	9999	Can't push table 'table2' as child of 'table1', their dependency is 'const'
 Note	9999	Can't push table 'table3' as child of 'table1', column 'table2.a' is outside scope of pushable join
+Note	9999	Cannot push table 'table3' as child of 'table2', since it referes to column 'table1.u' prior to a potential 'const' root.
 Note	1003	select straight_join `test`.`table1`.`pk` AS `pk`,`test`.`table1`.`u` AS `u`,`test`.`table1`.`a` AS `a`,`test`.`table1`.`b` AS `b`,`test`.`table2`.`pk` AS `pk`,`test`.`table2`.`u` AS `u`,`test`.`table2`.`a` AS `a`,`test`.`table2`.`b` AS `b`,`test`.`table3`.`pk` AS `pk`,`test`.`table3`.`u` AS `u`,`test`.`table3`.`a` AS `a`,`test`.`table3`.`b` AS `b` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table3`.`a` = `test`.`table2`.`a`) and (`test`.`table3`.`u` = `test`.`table1`.`u`) and (`test`.`table2`.`pk` = 3))
 select straight_join * from
 t1 as table1 join 
@@ -5675,7 +5677,7 @@ CONST_PRUNED_RANGE_SCANS_RECEIVED	8
 LOCAL_TABLE_SCANS_SENT	254
 PRUNED_RANGE_SCANS_RECEIVED	27
 RANGE_SCANS_RECEIVED	736
-READS_RECEIVED	60
+READS_RECEIVED	47
 TABLE_SCANS_RECEIVED	254
 drop table spj_counts_at_startup;
 drop table spj_counts_at_end;
@@ -5686,9 +5688,9 @@ where new.variable_name = old.variable_n
 order by new.variable_name;
 variable_name	new.variable_value - old.variable_value
 NDB_PRUNED_SCAN_COUNT	8
-NDB_PUSHED_QUERIES_DEFINED	411
+NDB_PUSHED_QUERIES_DEFINED	409
 NDB_PUSHED_QUERIES_DROPPED	8
-NDB_PUSHED_QUERIES_EXECUTED	554
+NDB_PUSHED_QUERIES_EXECUTED	541
 NDB_SORTED_SCAN_COUNT	11
 drop table server_counts_at_startup;
 set ndb_join_pushdown = @save_ndb_join_pushdown;

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2012-04-25 09:22:21 +0000
+++ b/sql/ha_ndbcluster.cc	2012-05-03 10:42:49 +0000
@@ -12480,6 +12480,19 @@ ulonglong ha_ndbcluster::table_flags(voi
   */
   if (thd->variables.binlog_format == BINLOG_FORMAT_STMT)
     f= (f | HA_BINLOG_STMT_CAPABLE) & ~HA_HAS_OWN_BINLOGGING;
+
+  /**
+   * To maximize join pushability we want const-table optimization
+   * blocked if table is possibly pushable, that is:
+   *  - Variable 'ndb_join_pushdown= on'
+   *  - Lock mode is LM_CommittedRead
+   */
+  if (THDVAR(thd, join_pushdown) &&
+      get_ndb_lock_mode(m_lock.type) == NdbOperation::LM_CommittedRead)
+  {
+    f= f | HA_BLOCK_CONST_TABLE;
+  }
+
   return f;
 }
 
@@ -14665,57 +14678,6 @@ ha_ndbcluster::parent_of_pushed_join() c
   return NULL;
 }
 
-bool
-ha_ndbcluster::test_push_flag(enum ha_push_flag flag) const
-{
-  DBUG_ENTER("test_push_flag");
-  switch (flag) {
-  case HA_PUSH_BLOCK_CONST_TABLE:
-  {
-    /**
-     * We don't support join push down if...
-     *   - not LM_CommittedRead
-     *   - uses blobs
-     */
-    THD *thd= current_thd;
-    if (unlikely(!THDVAR(thd, join_pushdown)))
-      DBUG_RETURN(false);
-
-    if (table->read_set != NULL && uses_blob_value(table->read_set))
-    {
-      DBUG_RETURN(false);
-    }
-
-    NdbOperation::LockMode lm= get_ndb_lock_mode(m_lock.type);
-
-    if (lm != NdbOperation::LM_CommittedRead)
-    {
-      DBUG_RETURN(false);
-    }
-
-    DBUG_RETURN(true);
-  }
-  case HA_PUSH_MULTIPLE_DEPENDENCY:
-    /**
-     * If any child operation within this pushed join refer 
-     * column values (paramValues), the pushed join has dependencies
-     * in addition to the root operation itself.
-     */
-    if (m_pushed_join_operation==PUSHED_ROOT &&
-        m_pushed_join_member->get_field_referrences_count() > 0)  // Childs has field refs
-    {
-      DBUG_RETURN(true);
-    }
-    DBUG_RETURN(false);
-
-  default:
-    DBUG_ASSERT(0);
-    DBUG_RETURN(false);
-  }
-  DBUG_RETURN(false);
-}
-
-
 /**
   @param[in] comment  table comment defined by user
 

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2012-04-18 11:34:20 +0000
+++ b/sql/ha_ndbcluster.h	2012-05-03 10:42:49 +0000
@@ -330,15 +330,6 @@ static void set_tabname(const char *path
   bool maybe_pushable_join(const char*& reason) const;
   int assign_pushed_join(const ndb_pushed_join* pushed_join);
 
-#ifdef NDB_WITHOUT_JOIN_PUSHDOWN
-  enum ha_push_flag {
-    HA_PUSH_BLOCK_CONST_TABLE,
-    HA_PUSH_MULTIPLE_DEPENDENCY,
-    HA_PUSH_NO_ORDERED_INDEX
-  };
-#endif
-  bool test_push_flag(enum ha_push_flag flag) const;
-
   uint number_of_pushed_joins() const;
   const TABLE* root_of_pushed_join() const;
   const TABLE* parent_of_pushed_join() const;

=== modified file 'sql/ha_ndbcluster_push.cc'
--- a/sql/ha_ndbcluster_push.cc	2012-03-30 07:31:27 +0000
+++ b/sql/ha_ndbcluster_push.cc	2012-05-03 10:42:49 +0000
@@ -950,12 +950,38 @@ bool ndb_pushed_builder_ctx::is_field_it
     // This key item is const. and did not cause the set of possible parents
     // to be recalculated. Reuse what we had before this key item.
     DBUG_ASSERT(field_parents.is_clear_all());
-    /** 
-     * Scan queries cannot be pushed if the pushed query may refer column 
-     * values (paramValues) from rows stored in a join cache.  
+
+    /**
+     * Field referrence is a 'paramValue' to a column value evaluated
+     * prior to the root of this pushed join candidate. Some restrictions
+     * applies to when a field reference is allowed in a pushed join:
      */
-    if (!ndbcluster_is_lookup_operation(m_join_root->get_access_type()))
+    if (ndbcluster_is_lookup_operation(m_join_root->get_access_type()))
     {
+      /**
+       * The 'eq_ref' access function join_read_key(), may optimize away
+       * key reads if the key for a requested row is the same as the
+       * previous. Thus, iff this is the root of a pushed lookup join
+       * we do not want it to contain childs with references to columns 
+       * 'outside' the the pushed joins, as these may still change
+       * between calls to join_read_key() independent of the root key
+       * itself being the same.
+       */
+      EXPLAIN_NO_PUSH("Cannot push table '%s' as child of '%s', since "
+                      "it referes to column '%s.%s' prior to a "
+                      "potential 'const' root.",
+                      table->get_table()->alias, 
+                      m_join_root->get_table()->alias,
+                      get_referred_table_access_name(key_item_field),
+                      get_referred_field_name(key_item_field));
+      DBUG_RETURN(false);
+    }
+    else  
+    {
+      /** 
+       * Scan queries cannot be pushed if the pushed query may refer column 
+       * values (paramValues) from rows stored in a join cache.  
+       */
       const TABLE* const referred_tab = key_item_field->field->table;
       uint access_no = tab_no;
       do

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2012-03-23 07:44:14 +0000
+++ b/sql/handler.h	2012-05-03 10:42:49 +0000
@@ -241,6 +241,13 @@ typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_AL
 #define HA_READ_BEFORE_WRITE_REMOVAL  (LL(1) << 38)
 #endif
 
+#ifndef MCP_WL4784
+/*
+  The handler don't want accesses to this table to 
+  be const-table optimized
+*/
+#define HA_BLOCK_CONST_TABLE          (LL(1) << 39)
+#endif
 
 /* bits in index_flags(index_number) for what you can do with index */
 #define HA_READ_NEXT            1       /* TODO really use this flag */
@@ -487,21 +494,6 @@ typedef ulonglong my_xid; // this line i
 namespace AQP {
   class Join_plan;
 };
-
-/* Flag used for for test_push_flag() */
-enum ha_push_flag {
-
-  /* Handler want to block const table optimization */
-  HA_PUSH_BLOCK_CONST_TABLE
-
-  /* Handler reports a pushed join as having multiple dependencies 
-     if its results does not only depend on the root operation:
-     ie. results from some child operations does not only depend
-     on results from the root operation and/or other child operations
-     within this pushed join 
-   */
-  ,HA_PUSH_MULTIPLE_DEPENDENCY
-};
 #endif
 
 /**
@@ -2106,11 +2098,6 @@ public:
   virtual const TABLE* parent_of_pushed_join() const
   { return NULL; }
 
-  virtual bool test_push_flag(enum ha_push_flag flag) const
-  {
-    return FALSE;
-  }
-
   virtual int index_read_pushed(uchar * buf, const uchar * key,
                              key_part_map keypart_map)
   { return  HA_ERR_WRONG_COMMAND; }

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-04-25 09:34:51 +0000
+++ b/sql/sql_select.cc	2012-05-03 10:42:49 +0000
@@ -2880,12 +2880,7 @@ make_join_statistics(JOIN *join, TABLE_L
          no_partitions_used) &&
 	!s->dependent &&
 	(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) &&
-#ifndef MCP_WL4784
-        !table->fulltext_searched && !join->no_const_tables &&
-        !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE))
-#else
         !table->fulltext_searched && !join->no_const_tables)
-#endif
     {
       set_position(join,const_count++,s,(KEYUSE*) 0);
     }
@@ -3081,7 +3076,7 @@ make_join_statistics(JOIN *join, TABLE_L
               !table->fulltext_searched && 
 #ifndef MCP_WL4784
               !table->pos_in_table_list->embedding &&
-              !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE))
+              !(table->file->ha_table_flags() & HA_BLOCK_CONST_TABLE))
 #else
               !table->pos_in_table_list->embedding)
 #endif
@@ -6634,7 +6629,7 @@ static bool create_ref_for_key(JOIN *joi
   }
 #ifndef MCP_WL4784
   else if (keyuse_uses_no_tables &&
-           !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE))
+           !(table->file->ha_table_flags() & HA_BLOCK_CONST_TABLE))
 #else
   else if (keyuse_uses_no_tables)
 #endif
@@ -13190,21 +13185,8 @@ join_read_last_key(JOIN_TAB *tab)
 
 	/* ARGSUSED */
 static int
-join_no_more_records(READ_RECORD *info)
+join_no_more_records(READ_RECORD *info __attribute__((unused)))
 {
-#ifndef MCP_WL4784
-  /**
-   * When a pushed join completes, and its results did not only depend on
-   * the key of this root operations: ('tab->ref.key_buff')
-   * Results from this pushed join can not be reused 
-   * for later queries having the same root key.
-   * (ref: join_read_key())
-   */
-  if (info->table->file->test_push_flag(HA_PUSH_MULTIPLE_DEPENDENCY))
-  {
-    info->table->status= STATUS_GARBAGE;
-  }
-#endif
   return -1;
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster-7.2 branch (ole.john.aske:3907 to 3908) Ole John Aske3 May