Commit 44db341f authored by unknown's avatar unknown
Browse files

fix so that ndb handler can cope with char(0), mapped to char(1) for now

parent b76fb15c
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -395,3 +395,22 @@ b attr1
9413	9412
drop table test.t1, t2;
drop database mysqltest;
use test;
create table t1 (a int primary key, b char(0));
insert into t1 values (1,"");
insert into t1 values (2,NULL);
select * from t1 order by a;
a	b
1	
2	NULL
select * from t1 order by b;
a	b
2	NULL
1	
select * from t1 where b IS NULL;
a	b
2	NULL
select * from t1 where b IS NOT NULL;
a	b
1	
drop table t1;
+13 −0
Original line number Diff line number Diff line
@@ -358,3 +358,16 @@ select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a;
drop table test.t1, t2;
drop database mysqltest;

#
# test support of char(0)
#

use test;
create table t1 (a int primary key, b char(0));
insert into t1 values (1,"");
insert into t1 values (2,NULL);
select * from t1 order by a;
select * from t1 order by b;
select * from t1 where b IS NULL;
select * from t1 where b IS NOT NULL;
drop table t1;
+22 −2
Original line number Diff line number Diff line
@@ -89,6 +89,12 @@ static int ndb_get_table_statistics(Ndb*, const char *,
				    Uint64* rows, Uint64* commits);


/*
  Dummy buffer to read zero pack_length fields
  which are mapped to 1 char
*/
static byte dummy_buf[1];

/*
  Error handling functions
*/
@@ -443,6 +449,13 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field,

  if (ndb_supported_type(field->type()))
  {
    // ndb currently does not support size 0
    const byte *empty_field= "";
    if (pack_len == 0)
    {
      pack_len= 1;
      field_ptr= empty_field;
    }
    if (! (field->flags & BLOB_FLAG))
    {
      if (field->is_null())
@@ -586,7 +599,11 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field,
      DBUG_ASSERT(field->ptr != NULL);
      if (! (field->flags & BLOB_FLAG))
      {	
	byte *field_buf= buf + (field->ptr - table->record[0]);
	byte *field_buf;
	if (field->pack_length() != 0)
	  field_buf= buf + (field->ptr - table->record[0]);
	else
	  field_buf= dummy_buf;
        m_value[fieldnr].rec= ndb_op->getValue(fieldnr, 
					       field_buf);
        DBUG_RETURN(m_value[fieldnr].rec == NULL);
@@ -3164,6 +3181,9 @@ static int create_ndb_column(NDBCOL &col,
      col.setType(NDBCOL::Char);
      col.setCharset(cs);
    }
    if (field->pack_length() == 0)
      col.setLength(1); // currently ndb does not support size 0
    else
      col.setLength(field->pack_length());
    break;
  case MYSQL_TYPE_VAR_STRING: