mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
test that attribute name truncation works
exposed the attribute name size limit for handler added field name truncation to ndb handler mysql-test/t/ndb_basic.test: test that attribute name truncation works ndb/include/ndbapi/ndbapi_limits.h: exposed the attribute name size limit for handler sql/ha_ndbcluster.cc: added field name truncation to ndb handler
This commit is contained in:
@@ -507,3 +507,18 @@ c127 int,
|
|||||||
c128 int,
|
c128 int,
|
||||||
primary key(c1)) engine=ndb;
|
primary key(c1)) engine=ndb;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# test max size of attribute name and truncation
|
||||||
|
#
|
||||||
|
|
||||||
|
create table t1 (
|
||||||
|
a1234567890123456789012345678901234567890 int primary key,
|
||||||
|
a12345678901234567890123456789a1234567890 int,
|
||||||
|
index(a12345678901234567890123456789a1234567890)
|
||||||
|
) engine=ndb;
|
||||||
|
show tables;
|
||||||
|
insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1);
|
||||||
|
explain select * from t1 where a12345678901234567890123456789a1234567890=2;
|
||||||
|
select * from t1 where a12345678901234567890123456789a1234567890=2;
|
||||||
|
drop table t1;
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#define NDB_MAX_DATABASE_NAME_SIZE 128
|
#define NDB_MAX_DATABASE_NAME_SIZE 128
|
||||||
#define NDB_MAX_SCHEMA_NAME_SIZE 128
|
#define NDB_MAX_SCHEMA_NAME_SIZE 128
|
||||||
#define NDB_MAX_TAB_NAME_SIZE 128
|
#define NDB_MAX_TAB_NAME_SIZE 128
|
||||||
|
#define NDB_MAX_ATTR_NAME_SIZE 32
|
||||||
#define NDB_MAX_ATTRIBUTES_IN_TABLE 128
|
#define NDB_MAX_ATTRIBUTES_IN_TABLE 128
|
||||||
|
|
||||||
#define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013
|
#define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013
|
||||||
|
@@ -1393,8 +1393,13 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op,
|
|||||||
|
|
||||||
// Set bound if not cancelled via type -1
|
// Set bound if not cancelled via type -1
|
||||||
if (p.bound_type != -1)
|
if (p.bound_type != -1)
|
||||||
if (op->setBound(field->field_name, p.bound_type, p.bound_ptr))
|
{
|
||||||
|
char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
|
||||||
|
strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
|
||||||
|
truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
|
||||||
|
if (op->setBound(truncated_field_name, p.bound_type, p.bound_ptr))
|
||||||
ERR_RETURN(op->getNdbError());
|
ERR_RETURN(op->getNdbError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3102,7 +3107,12 @@ static int create_ndb_column(NDBCOL &col,
|
|||||||
HA_CREATE_INFO *info)
|
HA_CREATE_INFO *info)
|
||||||
{
|
{
|
||||||
// Set name
|
// Set name
|
||||||
col.setName(field->field_name);
|
{
|
||||||
|
char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
|
||||||
|
strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
|
||||||
|
truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
|
||||||
|
col.setName(truncated_field_name);
|
||||||
|
}
|
||||||
// Get char set
|
// Get char set
|
||||||
CHARSET_INFO *cs= field->charset();
|
CHARSET_INFO *cs= field->charset();
|
||||||
// Set type and sizes
|
// Set type and sizes
|
||||||
@@ -3430,7 +3440,12 @@ int ha_ndbcluster::create_index(const char *name,
|
|||||||
{
|
{
|
||||||
Field *field= key_part->field;
|
Field *field= key_part->field;
|
||||||
DBUG_PRINT("info", ("attr: %s", field->field_name));
|
DBUG_PRINT("info", ("attr: %s", field->field_name));
|
||||||
ndb_index.addColumnName(field->field_name);
|
{
|
||||||
|
char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
|
||||||
|
strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
|
||||||
|
truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
|
||||||
|
ndb_index.addColumnName(truncated_field_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict->createIndex(ndb_index))
|
if (dict->createIndex(ndb_index))
|
||||||
|
Reference in New Issue
Block a user