3079 Tomas Ulin 2008-11-14 [merge]
merge
modified:
storage/ndb/include/ndb_version.h.in
storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
storage/ndb/src/mgmsrv/ConfigManager.cpp
=== modified file 'mysql-test/suite/ndb/r/ndb_dbug_tc_select.result'
--- a/mysql-test/suite/ndb/r/ndb_dbug_tc_select.result 2008-11-13 19:34:09 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dbug_tc_select.result 2008-11-14 11:01:37 +0000
@@ -1,8 +1,33 @@
drop table if exists t1,t2;
+#
+# Test tc select with 2-way joins with unique lookups
+#
create table t1 (a int key, b int) engine ndb;
create table t2 (a int, b int, c int, d int, primary key(a,b), unique(d)) engine ndb partition by key(a);
+#
# 2-way join tc selection in pk
+#
+explain select t2.c from t1,t2 where t1.a=50 and t2.a=t1.a and t2.b=t1.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
+1 SIMPLE t2 const PRIMARY PRIMARY 8 const,const #
+#
# 2-way join tc selection in unique key
+#
+explain select t1.b from t1,t2 where t2.d=50 and t1.a=t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const PRIMARY,d d 5 const #
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
+drop table t1,t2;
+#
+# Test tc select with 2-way joins with scan followed by unique lookup
+#
+create table t1 (a int, b int, primary key(a,b)) engine ndb partition by key (a);
+create table t2 (a int, b int, c int, primary key(a,b)) engine ndb partition by key (a);
+explain select t2.c from t1,t2 where t1.a=50 and t2.a=t1.a and t2.b=t1.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY PRIMARY 4 const #
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 8 const,test.t1.b #
drop table t1,t2;
create table t1 (a int , b varchar(22), c int, primary key(a), unique(b)) engine ndb;
# verify tc select on insert using simple int key
=== modified file 'mysql-test/suite/ndb/t/ndb_dbug_tc_select.test'
--- a/mysql-test/suite/ndb/t/ndb_dbug_tc_select.test 2008-11-13 19:34:09 +0000
+++ b/mysql-test/suite/ndb/t/ndb_dbug_tc_select.test 2008-11-14 11:01:37 +0000
@@ -9,6 +9,10 @@ drop table if exists t1,t2;
# make ndb nodes die if correct tc is not selected
+--echo #
+--echo # Test tc select with 2-way joins with unique lookups
+--echo #
+
create table t1 (a int key, b int) engine ndb;
create table t2 (a int, b int, c int, d int, primary key(a,b), unique(d)) engine ndb partition by key(a);
--disable_query_log
@@ -25,21 +29,29 @@ inc $j;
--enable_query_log
--enable_result_log
+--echo #
--echo # 2-way join tc selection in pk
+--echo #
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "all error 8072" >> $NDB_TOOLS_OUTPUT
+--replace_column 9 #
+explain select t2.c from t1,t2 where t1.a=50 and t2.a=t1.a and t2.b=t1.b;
--disable_query_log
--disable_result_log
let $i= 100;
while ($i)
{
---eval select t2.c from t1,t2 where t1.a="$i" and t2.a=t2.a and t2.b=t1.b
+--eval select t2.c from t1,t2 where t1.a="$i" and t2.a=t1.a and t2.b=t1.b
dec $i;
}
--enable_query_log
--enable_result_log
+--echo #
--echo # 2-way join tc selection in unique key
+--echo #
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "all error 8071" >> $NDB_TOOLS_OUTPUT
+--replace_column 9 #
+explain select t1.b from t1,t2 where t2.d=50 and t1.a=t2.a;
--disable_query_log
--disable_result_log
let $i= 100;
@@ -54,6 +66,47 @@ dec $i;
# cleanup
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "all error 0" >> $NDB_TOOLS_OUTPUT
drop table t1,t2;
+
+
+--echo #
+--echo # Test tc select with 2-way joins with scan followed by unique lookup
+--echo #
+
+create table t1 (a int, b int, primary key(a,b)) engine ndb partition by key (a);
+create table t2 (a int, b int, c int, primary key(a,b)) engine ndb partition by key (a);
+
+--disable_query_log
+--disable_result_log
+let $i= 100;
+let $j= 1;
+while ($i)
+{
+--eval insert into t1 values ("$i","$j")
+--eval insert into t2 values ("$i",9999,"$j")
+dec $i;
+inc $j;
+}
+--enable_query_log
+--enable_result_log
+
+--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "all error 8071" >> $NDB_TOOLS_OUTPUT
+--replace_column 9 #
+explain select t2.c from t1,t2 where t1.a=50 and t2.a=t1.a and t2.b=t1.b;
+--disable_query_log
+--disable_result_log
+let $i= 100;
+while ($i)
+{
+--eval select t2.c from t1,t2 where t1.a="$i" and t2.a=t1.a and t2.b=t1.b
+dec $i;
+}
+--enable_query_log
+--enable_result_log
+
+# cleanup
+--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "all error 0" >> $NDB_TOOLS_OUTPUT
+drop table t1,t2;
+
--let $type1= int
--let $type2= varchar(22)
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2008-11-13 16:32:23 +0000
+++ b/sql/ha_ndbcluster.cc 2008-11-14 11:01:37 +0000
@@ -3250,7 +3250,7 @@ int ha_ndbcluster::ndb_write_row(uchar *
}
trans= thd_ndb->trans;
- if (m_user_defined_partitioning || (!trans && m_use_partition_pruning))
+ if (m_user_defined_partitioning)
{
DBUG_ASSERT(m_use_partition_pruning);
longlong func_value= 0;
@@ -3262,7 +3262,6 @@ int ha_ndbcluster::ndb_write_row(uchar *
m_part_info->err_value= func_value;
DBUG_RETURN(error);
}
- if (m_user_defined_partitioning)
{
/*
We need to set the value of the partition function value in
@@ -4522,6 +4521,13 @@ int ha_ndbcluster::read_range_first_to_b
default:
break;
}
+ if (!m_use_partition_pruning && !m_thd_ndb->trans)
+ {
+ get_partition_set(table, buf, active_index, start_key, &part_spec);
+ if (part_spec.start_part == part_spec.end_part)
+ if (unlikely(!start_transaction_part_id(part_spec.start_part, error)))
+ DBUG_RETURN(error);
+ }
// Start the ordered index scan and fetch the first row
DBUG_RETURN(ordered_index_scan(start_key, end_key, sorted, desc, buf,
(m_use_partition_pruning)? &part_spec : NULL));
@@ -10566,10 +10572,25 @@ ha_ndbcluster::read_multi_range_first(KE
if (read_multi_needs_scan(cur_index_type, key_info, r))
{
- // ToDo see if we can use start_transaction_key here
if (!trans)
- if (unlikely(!(trans= start_transaction(error))))
+ {
+ // ToDo see if we can use start_transaction_key here instead
+ if (!m_use_partition_pruning)
+ {
+ get_partition_set(table, table->record[0], active_index, &r->start_key,
+ &part_spec);
+ if (part_spec.start_part == part_spec.end_part)
+ {
+ if (unlikely(!(trans= start_transaction_part_id(part_spec.start_part,
+ error))))
+ DBUG_RETURN(error);
+ }
+ else if (unlikely(!(trans= start_transaction(error))))
+ DBUG_RETURN(error);
+ }
+ else if (unlikely(!(trans= start_transaction(error))))
DBUG_RETURN(error);
+ }
any_real_read= TRUE;
/*
| Thread |
|---|
| • bzr push into mysql-5.1 branch (tomas.ulin:3079) | Tomas Ulin | 17 Nov |