diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2004-10-20 17:22:58 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2004-10-20 17:22:58 +0000 |
commit | 44db341fdb241ea954ce417f995e3b11c032d9b0 (patch) | |
tree | ad22cf6b9c6918aa5a222e126d9106b6c08f8496 | |
parent | b76fb15ce6e71ab001f5fe25bee34e411ee9a35c (diff) | |
download | mariadb-git-44db341fdb241ea954ce417f995e3b11c032d9b0.tar.gz |
fix so that ndb handler can cope with char(0), mapped to char(1) for now
-rw-r--r-- | mysql-test/r/ndb_basic.result | 19 | ||||
-rw-r--r-- | mysql-test/t/ndb_basic.test | 13 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 24 |
3 files changed, 54 insertions, 2 deletions
diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 9f8dcf3610a..abe1b98b536 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -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; diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 5f32a8016bf..e79815bbeb1 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -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; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 61316317691..e1050a73b7a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -90,6 +90,12 @@ static int ndb_get_table_statistics(Ndb*, const char *, /* + 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,7 +3181,10 @@ static int create_ndb_column(NDBCOL &col, col.setType(NDBCOL::Char); col.setCharset(cs); } - col.setLength(field->pack_length()); + 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: if (field->flags & BINARY_FLAG) |