List:Commits« Previous MessageNext Message »
From:Jan Wedvik Date:October 26 2010 12:41pm
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(jan.wedvik:3326)
View as plain text  
#At file:///net/atum17/export/home2/tmp/jw159207/mysql/repo/push-scan-scan/ based on revid:ole.john.aske@stripped

 3326 Jan Wedvik	2010-10-26
      This commit fixes two errors related to pushed queries involving varchar types:
      
      1. Some queries would fail with the error message: 'Character Parameter was
      right truncated'. This was due to an attempt to convert string from a format
      with 2-byte length field to 1-byte length field when the string already had
      a one-byte length field.
      
      2. Varchar values that were parameters to non-root pushed operations would
      not get the one- or two-byte length fields they should have. The SPJ block would
      then either crash (on an ndbrequire) or misinterpret the string.

    modified:
      mysql-test/suite/ndb/r/ndb_join_pushdown.result
      mysql-test/suite/ndb/t/ndb_join_pushdown.test
      sql/ha_ndbcluster.cc
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-10-21 08:31:51 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-10-26 12:41:00 +0000
@@ -4054,6 +4054,29 @@ select * from t as t1 join t as t2 on t2
 b	a	b	a
 0	0	0	0
 drop table t;
+CREATE TABLE tc(
+a varchar(10) NOT NULL,
+b varchar(10),
+c varchar(10),
+PRIMARY KEY (a),
+UNIQUE KEY uk1 (b, c) 
+)ENGINE=ndbcluster;
+insert into tc values ('aa','bb', 'x'), ('bb','cc', 'x'), ('cc', 'dd', 'x');
+explain select * from tc as x1 
+right outer join tc as x2 on x1.b=x2.a   
+left outer join tc as x3 on x2.b = x3.b and x1.c=x3.c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	x2	ALL	NULL	NULL	NULL	NULL	3	
+1	SIMPLE	x1	ref	uk1	uk1	13	test.x2.a	1	Parent of 2 pushed join@1
+1	SIMPLE	x3	ref	uk1	uk1	26	test.x2.b,test.x1.c	1	Child of pushed join@1
+select * from tc as x1 
+right outer join tc as x2 on x1.b=x2.a   
+left outer join tc as x3 on x2.b = x3.b and x1.c=x3.c;
+a	b	c	a	b	c	a	b	c
+NULL	NULL	NULL	aa	bb	x	NULL	NULL	NULL
+aa	bb	x	bb	cc	x	bb	cc	x
+bb	cc	x	cc	dd	x	cc	dd	x
+drop table tc;
 create temporary table spj_counts_at_end
 select counter_name, sum(val) AS val 
 from ndbinfo.counters 
@@ -4071,10 +4094,10 @@ counter_name	spj_counts_at_end.val - spj
 CONST_PRUNED_RANGE_SCANS_RECEIVED	6
 LOCAL_TABLE_SCANS_SENT	196
 PRUNED_RANGE_SCANS_RECEIVED	16
-RANGE_SCANS_RECEIVED	203
+RANGE_SCANS_RECEIVED	209
 READS_NOT_FOUND	405
 READS_RECEIVED	61
-SCAN_ROWS_RETURNED	63863
+SCAN_ROWS_RETURNED	63867
 TABLE_SCANS_RECEIVED	196
 select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT'
        from spj_counts_at_end, spj_counts_at_startup 
@@ -4082,19 +4105,19 @@ where spj_counts_at_end.counter_name = s
 and (spj_counts_at_end.counter_name = 'LOCAL_READS_SENT'
        or spj_counts_at_end.counter_name = 'REMOTE_READS_SENT');
 LOCAL+REMOTE READS_SENT
-29146
+29150
 drop table spj_counts_at_startup;
 drop table spj_counts_at_end;
 scan_count
-2000
+2008
 pruned_scan_count
 7
 sorted_scan_count
 7
 pushed_queries_defined
-343
+345
 pushed_queries_dropped
 11
 pushed_queries_executed
-264
+267
 set ndb_join_pushdown = @save_ndb_join_pushdown;

=== modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-10-16 15:05:21 +0000
+++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-10-26 12:41:00 +0000
@@ -2882,6 +2882,31 @@ select * from t as t1 join t as t2 on t2
 
 drop table t;
 
+#######
+# Test of varchar query parameteres.
+#######
+
+CREATE TABLE tc(
+  a varchar(10) NOT NULL,
+  b varchar(10),
+  c varchar(10),
+  PRIMARY KEY (a),
+  UNIQUE KEY uk1 (b, c) 
+)ENGINE=ndbcluster;
+
+insert into tc values ('aa','bb', 'x'), ('bb','cc', 'x'), ('cc', 'dd', 'x');
+
+explain select * from tc as x1 
+  right outer join tc as x2 on x1.b=x2.a   
+  left outer join tc as x3 on x2.b = x3.b and x1.c=x3.c;
+
+--sorted_result
+select * from tc as x1 
+  right outer join tc as x2 on x1.b=x2.a   
+  left outer join tc as x3 on x2.b = x3.b and x1.c=x3.c;
+
+drop table tc;
+
 ########################################
 # Verify DBSPJ counters for entire test:
 

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-10-26 10:44:16 +0000
+++ b/sql/ha_ndbcluster.cc	2010-10-26 12:41:00 +0000
@@ -1869,9 +1869,8 @@ ha_ndbcluster::create_pushed_join(NdbQue
   for (uint i= 0; i < m_pushed_join->get_field_referrences_count(); i++)
   {
     Field* field= m_pushed_join->get_field_ref(i);
-    bool shrinkVarChar= is_shrinked_varchar(field);
     DBUG_ASSERT(!field->is_real_null());  // Checked by ::check_if_pushable()
-    paramValues[paramOffs+i]= NdbQueryParamValue(field->ptr, shrinkVarChar);
+    paramValues[paramOffs+i]= NdbQueryParamValue(field->ptr, false);
   }
 
   NdbQuery* const query= m_thd_ndb->trans->createQuery(&m_pushed_join->get_query_def(), paramValues);

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-10-16 15:05:21 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-10-26 12:41:00 +0000
@@ -3601,6 +3601,10 @@ NdbQueryOperationImpl::serializeProject(
   return 0;
 } // NdbQueryOperationImpl::serializeProject
 
+static int
+formatAttr(const NdbColumnImpl* column,
+           const void* &value, Uint32& len,
+           char* buffer, Uint32 buflen);
 
 int NdbQueryOperationImpl::serializeParams(const NdbQueryParamValue* paramValues)
 {
@@ -3624,12 +3628,20 @@ int NdbQueryOperationImpl::serializePara
     const void* addr;
     Uint32 len;
     bool null;
-    const int error = paramValue.getValue(paramDef,addr,len,null);
+    int error = paramValue.getValue(paramDef,addr,len,null);
     if (unlikely(error))
       return error;
     if (unlikely(null))
       return QRY_NEED_PARAMETER;
 
+    char tmp[NDB_MAX_KEY_SIZE];
+
+    error = 
+      formatAttr(paramDef.getColumn(), addr, len, tmp, 
+               static_cast<Uint32>(sizeof(tmp)));
+    if (unlikely(error))
+      return error;
+
     m_params.append(len);          // paramValue length in #bytes
     m_params.append(addr,len);
 


Attachment: [text/bzr-bundle] bzr/jan.wedvik@sun.com-20101026124100-oxrqei60g0j8pgu4.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(jan.wedvik:3326) Jan Wedvik26 Oct