diff options
author | unknown <jonas@perch.ndb.mysql.com> | 2005-12-14 10:57:09 +0100 |
---|---|---|
committer | unknown <jonas@perch.ndb.mysql.com> | 2005-12-14 10:57:09 +0100 |
commit | 2c808bed240141a6d35fe4cf49bbf899210d6a77 (patch) | |
tree | 4e0d38eb2ad2f5d39885b554678ac2bb5ad24f3b /sql/ha_ndbcluster.cc | |
parent | 01c7bd20b9fc28530387eeb5e3165f9ad8535301 (diff) | |
download | mariadb-git-2c808bed240141a6d35fe4cf49bbf899210d6a77.tar.gz |
bug#15682 - ndb - invalid handling of varchar in position/rnd_pos
mysql-test/r/ndb_basic.result:
bug#15682 - invalid handling of varchar in position/rnd_pos
mysql-test/t/ndb_basic.test:
bug#15682 - invalid handling of varchar in position/rnd_pos
ndb/src/kernel/blocks/dbtc/Dbtc.hpp:
New error code for invalid key
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
Handle invalid key gracefully
ndb/src/kernel/vm/SimulatedBlock.cpp:
Handle invalid key gracefully
ndb/src/ndbapi/ndberror.c:
New error code
sql/ha_ndbcluster.cc:
Fix varchar keys in position/rnd_pos
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index bad20ecb6e9..043e613c10b 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2796,8 +2796,26 @@ void ha_ndbcluster::position(const byte *record) } *buff++= 0; } - memcpy(buff, record + key_part->offset, key_part->length); - buff += key_part->length; + + size_t len = key_part->length; + const byte * ptr = record + key_part->offset; + Field *field = key_part->field; + if ((field->type() == MYSQL_TYPE_VARCHAR) && + ((Field_varstring*)field)->length_bytes == 1) + { + /** + * Keys always use 2 bytes length + */ + buff[0] = ptr[0]; + buff[1] = 0; + memcpy(buff+2, ptr + 1, len); + len += 2; + } + else + { + memcpy(buff, ptr, len); + } + buff += len; } } else |