=== modified file 'mysql-test/suite/ndb/r/ndb_native_default_support.result' --- mysql-test/suite/ndb/r/ndb_native_default_support.result 2010-06-08 22:13:11 +0000 +++ mysql-test/suite/ndb/r/ndb_native_default_support.result 2010-07-15 14:26:47 +0000 @@ -1410,4 +1410,33 @@ i j f d d2 ch HEX(b) HEX(vb) HEX(blob1) 10 10 10 10 10 nnnnn 6E6E6E6E6E0000000000000000000000000000 6E6E6E6E6E 6E6E6E6E6E nnnnn 2008-11-16 08:13:32 Comment field default 11 6 6.6 8.8 0 mmm 63636300000000000000000000000000000000 646464 NULL NULL 2008-12-18 17:41:20 Comment field default drop table t1; -End of ndb native default support test +Bug#55121 error 839 'Illegal null attribute' from NDB for fields with default value +Ensure that Ndb handler doesn't expect native defaults for Blobs. +CREATE TABLE t1 ( +fid smallint(6) unsigned NOT NULL DEFAULT '0', +f01 text NOT NULL, +f02 varchar(255) NOT NULL DEFAULT '', +f03 text NOT NULL DEFAULT '', +PRIMARY KEY (fid) +) engine=ndb; +Warnings: +Warning 1101 BLOB/TEXT column 'f03' can't have a default value +show warnings; +Level Code Message +Warning 1101 BLOB/TEXT column 'f03' can't have a default value +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fid` smallint(6) unsigned NOT NULL DEFAULT '0', + `f01` text NOT NULL, + `f02` varchar(255) NOT NULL DEFAULT '', + `f03` text NOT NULL, + PRIMARY KEY (`fid`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +insert into t1(fid) value(100); +Warnings: +Warning 1364 Field 'f01' doesn't have a default value +select fid, isnull(f01), isnull(f02), isnull(f03) from t1; +fid isnull(f01) isnull(f02) isnull(f03) +100 0 0 0 +drop table t1; === modified file 'mysql-test/suite/ndb/t/ndb_native_default_support.test' --- mysql-test/suite/ndb/t/ndb_native_default_support.test 2010-06-08 22:13:11 +0000 +++ mysql-test/suite/ndb/t/ndb_native_default_support.test 2010-07-15 14:17:41 +0000 @@ -630,4 +630,23 @@ SELECT i, j, f, d, d2, ch, HEX(b), HEX(v drop table t1; ---echo End of ndb native default support test +--echo Bug#55121 error 839 'Illegal null attribute' from NDB for fields with default value +--echo Ensure that Ndb handler doesn't expect native defaults for Blobs. + +CREATE TABLE t1 ( + fid smallint(6) unsigned NOT NULL DEFAULT '0', + f01 text NOT NULL, + f02 varchar(255) NOT NULL DEFAULT '', + f03 text NOT NULL DEFAULT '', + PRIMARY KEY (fid) +) engine=ndb; + +show warnings; + +show create table t1; + +insert into t1(fid) value(100); + +select fid, isnull(f01), isnull(f02), isnull(f03) from t1; + +drop table t1; \ No newline at end of file === modified file 'sql/ha_ndbcluster.cc' --- sql/ha_ndbcluster.cc 2010-07-14 11:26:51 +0000 +++ sql/ha_ndbcluster.cc 2010-07-15 13:57:46 +0000 @@ -3948,8 +3948,16 @@ int ha_ndbcluster::ndb_write_row(uchar * for (uint i= 0; i < table->s->fields; i++) { Field *field= table->field[i]; - if (field->flags & (NO_DEFAULT_VALUE_FLAG | // bug 41616 - PRI_KEY_FLAG)) // bug 42238 + DBUG_PRINT("info", ("Field#%u, (%u), Type : %u " + "NO_DEFAULT_VALUE_FLAG : %u PRI_KEY_FLAG : %u", + i, + field->field_index, + field->real_type(), + field->flags & NO_DEFAULT_VALUE_FLAG, + field->flags & PRI_KEY_FLAG)); + if ((field->flags & (NO_DEFAULT_VALUE_FLAG | // bug 41616 + PRI_KEY_FLAG)) || // bug 42238 + ! type_supports_default_value(field->real_type())) { bitmap_set_bit(user_cols_written_bitmap, field->field_index); }