fix char(0) to use ndb bit format

parent bcbbd47d
...@@ -90,7 +90,7 @@ static int ndb_get_table_statistics(Ndb*, const char *, ...@@ -90,7 +90,7 @@ static int ndb_get_table_statistics(Ndb*, const char *,
Dummy buffer to read zero pack_length fields Dummy buffer to read zero pack_length fields
which are mapped to 1 char which are mapped to 1 char
*/ */
static byte dummy_buf[1]; static uint32 dummy_buf;
/* /*
Error handling functions Error handling functions
...@@ -470,11 +470,15 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, ...@@ -470,11 +470,15 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field,
if (ndb_supported_type(field->type())) if (ndb_supported_type(field->type()))
{ {
// ndb currently does not support size 0 // ndb currently does not support size 0
const byte *empty_field= ""; uint32 empty_field;
if (pack_len == 0) if (pack_len == 0)
{ {
pack_len= 1; pack_len= sizeof(empty_field);
field_ptr= empty_field; field_ptr= (byte *)&empty_field;
if (field->is_null())
empty_field= 0;
else
empty_field= 1;
} }
if (! (field->flags & BLOB_FLAG)) if (! (field->flags & BLOB_FLAG))
{ {
...@@ -623,7 +627,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, ...@@ -623,7 +627,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field,
if (field->pack_length() != 0) if (field->pack_length() != 0)
field_buf= buf + (field->ptr - table->record[0]); field_buf= buf + (field->ptr - table->record[0]);
else else
field_buf= dummy_buf; field_buf= (byte *)&dummy_buf;
m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_value[fieldnr].rec= ndb_op->getValue(fieldnr,
field_buf); field_buf);
DBUG_RETURN(m_value[fieldnr].rec == NULL); DBUG_RETURN(m_value[fieldnr].rec == NULL);
...@@ -3329,19 +3333,22 @@ static int create_ndb_column(NDBCOL &col, ...@@ -3329,19 +3333,22 @@ static int create_ndb_column(NDBCOL &col,
break; break;
// Char types // Char types
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Binary);
else {
col.setType(NDBCOL::Char);
col.setCharset(cs);
}
if (field->pack_length() == 0) if (field->pack_length() == 0)
{ {
col.setType(NDBCOL::Bit); col.setType(NDBCOL::Bit);
col.setLength(1); col.setLength(1);
} }
else if (field->flags & BINARY_FLAG)
{
col.setType(NDBCOL::Binary);
col.setLength(field->pack_length());
}
else else
{
col.setType(NDBCOL::Char);
col.setCharset(cs);
col.setLength(field->pack_length()); col.setLength(field->pack_length());
}
break; break;
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
if (field->flags & BINARY_FLAG) if (field->flags & BINARY_FLAG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment