mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
ndb: bug#6435
fix null handling in ha_ndbcluster when using ordered index
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
drop table if exists t1;
|
||||
drop table if exists t1, test1, test2;
|
||||
CREATE TABLE t1 (
|
||||
a int unsigned NOT NULL PRIMARY KEY,
|
||||
b int unsigned not null,
|
||||
@@ -275,3 +275,38 @@ a b c
|
||||
1 1 1
|
||||
4 4 NULL
|
||||
drop table t1;
|
||||
CREATE TABLE test1 (
|
||||
SubscrID int(11) NOT NULL auto_increment,
|
||||
UsrID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (SubscrID),
|
||||
KEY idx_usrid (UsrID)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
|
||||
INSERT INTO test1 VALUES (2,224),(3,224),(1,224);
|
||||
CREATE TABLE test2 (
|
||||
SbclID int(11) NOT NULL auto_increment,
|
||||
SbcrID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (SbclID),
|
||||
KEY idx_sbcrid (SbcrID)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
|
||||
INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2);
|
||||
select * from test1 order by 1;
|
||||
SubscrID UsrID
|
||||
1 224
|
||||
2 224
|
||||
3 224
|
||||
select * from test2 order by 1;
|
||||
SbclID SbcrID
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON
|
||||
l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2;
|
||||
SubscrID SbclID
|
||||
1 1
|
||||
1 2
|
||||
2 3
|
||||
2 4
|
||||
3 NULL
|
||||
drop table test1;
|
||||
drop table test2;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- source include/have_ndb.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
drop table if exists t1, test1, test2;
|
||||
--enable_warnings
|
||||
|
||||
#
|
||||
@@ -146,3 +146,29 @@ select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
|
||||
select * from t1 use index (bc) where b < 4 order by a;
|
||||
select * from t1 use index (bc) where b IS NOT NULL order by a;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #6435
|
||||
CREATE TABLE test1 (
|
||||
SubscrID int(11) NOT NULL auto_increment,
|
||||
UsrID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (SubscrID),
|
||||
KEY idx_usrid (UsrID)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO test1 VALUES (2,224),(3,224),(1,224);
|
||||
|
||||
CREATE TABLE test2 (
|
||||
SbclID int(11) NOT NULL auto_increment,
|
||||
SbcrID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (SbclID),
|
||||
KEY idx_sbcrid (SbcrID)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2);
|
||||
select * from test1 order by 1;
|
||||
select * from test2 order by 1;
|
||||
SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON
|
||||
l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2;
|
||||
drop table test1;
|
||||
drop table test2;
|
||||
|
||||
@@ -1290,7 +1290,6 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op,
|
||||
Field *field= key_part->field;
|
||||
uint part_len= key_part->length;
|
||||
uint part_store_len= key_part->store_length;
|
||||
bool part_nullable= (bool) key_part->null_bit;
|
||||
// Info about each key part
|
||||
struct part_st {
|
||||
bool part_last;
|
||||
@@ -1312,9 +1311,9 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op,
|
||||
p.part_last= (tot_len + part_store_len >= key_tot_len[j]);
|
||||
p.key= keys[j];
|
||||
p.part_ptr= &p.key->key[tot_len];
|
||||
p.part_null= (field->maybe_null() && *p.part_ptr);
|
||||
p.part_null= key_part->null_bit && *p.part_ptr;
|
||||
p.bound_ptr= (const char *)
|
||||
p.part_null ? 0 : part_nullable ? p.part_ptr + 1 : p.part_ptr;
|
||||
p.part_null ? 0 : key_part->null_bit ? p.part_ptr + 1 : p.part_ptr;
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user