Commit 28444ac8 authored by unknown's avatar unknown

Bug #29103 ndb_restore segfaults on NULL var[char|binary]



mysql-test/r/ndb_restore.result:
  Bug #29103 ndb_restore segfaults on NULL var[char|binary]
  - add extra row with NULL value to test
mysql-test/t/ndb_restore.test:
  Bug #29103 ndb_restore segfaults on NULL var[char|binary]
  - add extra row with NULL value to test
storage/ndb/tools/restore/consumer_restore.cpp:
  Bug #29103 ndb_restore segfaults on NULL var[char|binary]
  - check that the attribute is not null
parent ef3ed50b
......@@ -18,7 +18,7 @@ CREATE TABLE `t2_c` (
PRIMARY KEY (`capgotod`),
KEY `i quadaddsvr` (`gotod`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,'');
CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
`capgotod` smallint(5) unsigned NOT NULL default '0',
......@@ -154,15 +154,15 @@ count(*)
5
select count(*) from t2;
count(*)
6
7
select count(*) from t2_c;
count(*)
6
7
select count(*)
from (select * from t2 union
select * from t2_c) a;
count(*)
6
7
select count(*) from t3;
count(*)
4
......@@ -286,15 +286,15 @@ count(*)
5
select count(*) from t2;
count(*)
6
7
select count(*) from t2_c;
count(*)
6
7
select count(*)
from (select * from t2 union
select * from t2_c) a;
count(*)
6
7
select count(*) from t3;
count(*)
4
......@@ -386,15 +386,15 @@ count(*)
5
select count(*) from t2;
count(*)
6
7
select count(*) from t2_c;
count(*)
6
7
select count(*)
from (select * from t2 union
select * from t2_c) a;
count(*)
6
7
select count(*) from t3;
count(*)
4
......
......@@ -33,7 +33,7 @@ CREATE TABLE `t2_c` (
PRIMARY KEY (`capgotod`),
KEY `i quadaddsvr` (`gotod`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,'');
# Added ROW_FORMAT=FIXED to use below to see that setting is preserved
# by restore
......
......@@ -1158,19 +1158,22 @@ void BackupRestore::tuple_a(restore_callback_t *cb)
char * dataPtr = attr_data->string_value;
Uint32 length = 0;
const unsigned char * src = (const unsigned char *)dataPtr;
switch(attr_desc->m_column->getType()){
case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Varbinary:
length = src[0] + 1;
break;
case NdbDictionary::Column::Longvarchar:
case NdbDictionary::Column::Longvarbinary:
length = src[0] + (src[1] << 8) + 2;
break;
default:
length = attr_data->size;
break;
if (!attr_data->null)
{
const unsigned char * src = (const unsigned char *)dataPtr;
switch(attr_desc->m_column->getType()){
case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Varbinary:
length = src[0] + 1;
break;
case NdbDictionary::Column::Longvarchar:
case NdbDictionary::Column::Longvarbinary:
length = src[0] + (src[1] << 8) + 2;
break;
default:
length = attr_data->size;
break;
}
}
if (j == 0 && tup.getTable()->have_auto_inc(i))
tup.getTable()->update_max_auto_val(dataPtr,size*arraySize);
......
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