Loading mysql-test/r/heap.result +2 −2 Original line number Diff line number Diff line Loading @@ -702,11 +702,11 @@ insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1 drop table t1; CREATE TABLE t1 (a int, key(a)) engine=heap; insert delayed into t1 values (0); insert into t1 values (0); delete from t1; select * from t1; a insert delayed into t1 values (0), (1); insert into t1 values (0), (1); select * from t1 where a = 0; a 0 Loading mysql-test/r/ndb_basic.result +55 −0 Original line number Diff line number Diff line Loading @@ -678,6 +678,61 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; b drop table t1; create table t1 (a int) engine=ndb; create table t2 (a int) engine=ndb; insert into t1 values (1); insert into t2 values (1); delete t1.* from t1, t2 where t1.a = t2.a; select * from t1; a select * from t2; a 1 drop table t1; drop table t2; CREATE TABLE t1 ( i INT, j INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t2 ( i INT, k INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t3 ( j INT, k INT, x INT, y INT, z INT ) engine=ndb; INSERT INTO t1 VALUES ( 1, 2,13,14,15); INSERT INTO t2 VALUES ( 1, 3,23,24,25); INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); UPDATE t1 AS a INNER JOIN t2 AS b ON a.i = b.i INNER JOIN t3 AS c ON a.j = c.j AND b.k = c.k SET a.x = b.x, a.y = b.y, a.z = ( SELECT sum(z) FROM t3 WHERE y = 34 ) WHERE b.x = 23; select * from t1; i j x y z 1 2 23 24 71 drop table t1; drop table t2; drop table t3; create table atablewithareallylongandirritatingname (a int); insert into atablewithareallylongandirritatingname values (2); select * from atablewithareallylongandirritatingname; Loading mysql-test/t/heap.test +2 −2 Original line number Diff line number Diff line Loading @@ -440,10 +440,10 @@ drop table t1; # Bug 12796: Record doesn't show when selecting through index # CREATE TABLE t1 (a int, key(a)) engine=heap; insert delayed into t1 values (0); insert into t1 values (0); delete from t1; select * from t1; insert delayed into t1 values (0), (1); insert into t1 values (0), (1); select * from t1 where a = 0; drop table t1; Loading mysql-test/t/ndb_basic.test +66 −0 Original line number Diff line number Diff line Loading @@ -625,6 +625,72 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; drop table t1; # # Bug #17249 delete statement with join where clause fails # when table do not have pk # create table t1 (a int) engine=ndb; create table t2 (a int) engine=ndb; insert into t1 values (1); insert into t2 values (1); delete t1.* from t1, t2 where t1.a = t2.a; select * from t1; select * from t2; drop table t1; drop table t2; # # Bug #17257 update fails for inner joins if tables # do not have Primary Key # CREATE TABLE t1 ( i INT, j INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t2 ( i INT, k INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t3 ( j INT, k INT, x INT, y INT, z INT ) engine=ndb; INSERT INTO t1 VALUES ( 1, 2,13,14,15); INSERT INTO t2 VALUES ( 1, 3,23,24,25); INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); UPDATE t1 AS a INNER JOIN t2 AS b ON a.i = b.i INNER JOIN t3 AS c ON a.j = c.j AND b.k = c.k SET a.x = b.x, a.y = b.y, a.z = ( SELECT sum(z) FROM t3 WHERE y = 34 ) WHERE b.x = 23; select * from t1; drop table t1; drop table t2; drop table t3; # End of 4.1 tests # Loading sql/ha_ndbcluster.cc +7 −17 Original line number Diff line number Diff line Loading @@ -97,8 +97,6 @@ static uint ndbcluster_alter_table_flags(uint flags) } #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 #define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 #define NDB_AUTO_INCREMENT_RETRIES 10 Loading Loading @@ -952,7 +950,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, } // Used for hidden key only m_value[fieldnr].rec= ndb_op->getValue(fieldnr, NULL); m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_ref); DBUG_RETURN(m_value[fieldnr].rec == NULL); } Loading Loading @@ -2551,13 +2549,10 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) DBUG_PRINT("info", ("Using hidden key")); // Require that the PK for this record has previously been // read into m_value uint no_fields= table_share->fields; const NdbRecAttr* rec= m_value[no_fields].rec; DBUG_ASSERT(rec); DBUG_DUMP("key", (char*)rec->aRef(), NDB_HIDDEN_PRIMARY_KEY_LENGTH); // read into m_ref DBUG_DUMP("key", m_ref, NDB_HIDDEN_PRIMARY_KEY_LENGTH); if (set_hidden_key(op, no_fields, rec->aRef())) if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else Loading Loading @@ -2664,11 +2659,8 @@ int ha_ndbcluster::delete_row(const byte *record) { // This table has no primary key, use "hidden" primary key DBUG_PRINT("info", ("Using hidden key")); uint no_fields= table_share->fields; const NdbRecAttr* rec= m_value[no_fields].rec; DBUG_ASSERT(rec != NULL); if (set_hidden_key(op, no_fields, rec->aRef())) if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else Loading Loading @@ -3242,17 +3234,15 @@ void ha_ndbcluster::position(const byte *record) { // No primary key, get hidden key DBUG_PRINT("info", ("Getting hidden key")); int hidden_no= table_share->fields; const NdbRecAttr* rec= m_value[hidden_no].rec; memcpy(ref, (const void*)rec->aRef(), ref_length); #ifndef DBUG_OFF int hidden_no= table->s->fields; const NDBTAB *tab= (const NDBTAB *) m_table; const NDBCOL *hidden_col= tab->getColumn(hidden_no); DBUG_ASSERT(hidden_col->getPrimaryKey() && hidden_col->getAutoIncrement() && rec != NULL && ref_length == NDB_HIDDEN_PRIMARY_KEY_LENGTH); #endif memcpy(ref, m_ref, ref_length); } DBUG_DUMP("ref", (char*)ref, ref_length); Loading Loading
mysql-test/r/heap.result +2 −2 Original line number Diff line number Diff line Loading @@ -702,11 +702,11 @@ insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1 drop table t1; CREATE TABLE t1 (a int, key(a)) engine=heap; insert delayed into t1 values (0); insert into t1 values (0); delete from t1; select * from t1; a insert delayed into t1 values (0), (1); insert into t1 values (0), (1); select * from t1 where a = 0; a 0 Loading
mysql-test/r/ndb_basic.result +55 −0 Original line number Diff line number Diff line Loading @@ -678,6 +678,61 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; b drop table t1; create table t1 (a int) engine=ndb; create table t2 (a int) engine=ndb; insert into t1 values (1); insert into t2 values (1); delete t1.* from t1, t2 where t1.a = t2.a; select * from t1; a select * from t2; a 1 drop table t1; drop table t2; CREATE TABLE t1 ( i INT, j INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t2 ( i INT, k INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t3 ( j INT, k INT, x INT, y INT, z INT ) engine=ndb; INSERT INTO t1 VALUES ( 1, 2,13,14,15); INSERT INTO t2 VALUES ( 1, 3,23,24,25); INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); UPDATE t1 AS a INNER JOIN t2 AS b ON a.i = b.i INNER JOIN t3 AS c ON a.j = c.j AND b.k = c.k SET a.x = b.x, a.y = b.y, a.z = ( SELECT sum(z) FROM t3 WHERE y = 34 ) WHERE b.x = 23; select * from t1; i j x y z 1 2 23 24 71 drop table t1; drop table t2; drop table t3; create table atablewithareallylongandirritatingname (a int); insert into atablewithareallylongandirritatingname values (2); select * from atablewithareallylongandirritatingname; Loading
mysql-test/t/heap.test +2 −2 Original line number Diff line number Diff line Loading @@ -440,10 +440,10 @@ drop table t1; # Bug 12796: Record doesn't show when selecting through index # CREATE TABLE t1 (a int, key(a)) engine=heap; insert delayed into t1 values (0); insert into t1 values (0); delete from t1; select * from t1; insert delayed into t1 values (0), (1); insert into t1 values (0), (1); select * from t1 where a = 0; drop table t1; Loading
mysql-test/t/ndb_basic.test +66 −0 Original line number Diff line number Diff line Loading @@ -625,6 +625,72 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; drop table t1; # # Bug #17249 delete statement with join where clause fails # when table do not have pk # create table t1 (a int) engine=ndb; create table t2 (a int) engine=ndb; insert into t1 values (1); insert into t2 values (1); delete t1.* from t1, t2 where t1.a = t2.a; select * from t1; select * from t2; drop table t1; drop table t2; # # Bug #17257 update fails for inner joins if tables # do not have Primary Key # CREATE TABLE t1 ( i INT, j INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t2 ( i INT, k INT, x INT, y INT, z INT ) engine=ndb; CREATE TABLE t3 ( j INT, k INT, x INT, y INT, z INT ) engine=ndb; INSERT INTO t1 VALUES ( 1, 2,13,14,15); INSERT INTO t2 VALUES ( 1, 3,23,24,25); INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); UPDATE t1 AS a INNER JOIN t2 AS b ON a.i = b.i INNER JOIN t3 AS c ON a.j = c.j AND b.k = c.k SET a.x = b.x, a.y = b.y, a.z = ( SELECT sum(z) FROM t3 WHERE y = 34 ) WHERE b.x = 23; select * from t1; drop table t1; drop table t2; drop table t3; # End of 4.1 tests # Loading
sql/ha_ndbcluster.cc +7 −17 Original line number Diff line number Diff line Loading @@ -97,8 +97,6 @@ static uint ndbcluster_alter_table_flags(uint flags) } #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 #define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 #define NDB_AUTO_INCREMENT_RETRIES 10 Loading Loading @@ -952,7 +950,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, } // Used for hidden key only m_value[fieldnr].rec= ndb_op->getValue(fieldnr, NULL); m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_ref); DBUG_RETURN(m_value[fieldnr].rec == NULL); } Loading Loading @@ -2551,13 +2549,10 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) DBUG_PRINT("info", ("Using hidden key")); // Require that the PK for this record has previously been // read into m_value uint no_fields= table_share->fields; const NdbRecAttr* rec= m_value[no_fields].rec; DBUG_ASSERT(rec); DBUG_DUMP("key", (char*)rec->aRef(), NDB_HIDDEN_PRIMARY_KEY_LENGTH); // read into m_ref DBUG_DUMP("key", m_ref, NDB_HIDDEN_PRIMARY_KEY_LENGTH); if (set_hidden_key(op, no_fields, rec->aRef())) if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else Loading Loading @@ -2664,11 +2659,8 @@ int ha_ndbcluster::delete_row(const byte *record) { // This table has no primary key, use "hidden" primary key DBUG_PRINT("info", ("Using hidden key")); uint no_fields= table_share->fields; const NdbRecAttr* rec= m_value[no_fields].rec; DBUG_ASSERT(rec != NULL); if (set_hidden_key(op, no_fields, rec->aRef())) if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else Loading Loading @@ -3242,17 +3234,15 @@ void ha_ndbcluster::position(const byte *record) { // No primary key, get hidden key DBUG_PRINT("info", ("Getting hidden key")); int hidden_no= table_share->fields; const NdbRecAttr* rec= m_value[hidden_no].rec; memcpy(ref, (const void*)rec->aRef(), ref_length); #ifndef DBUG_OFF int hidden_no= table->s->fields; const NDBTAB *tab= (const NDBTAB *) m_table; const NDBCOL *hidden_col= tab->getColumn(hidden_no); DBUG_ASSERT(hidden_col->getPrimaryKey() && hidden_col->getAutoIncrement() && rec != NULL && ref_length == NDB_HIDDEN_PRIMARY_KEY_LENGTH); #endif memcpy(ref, m_ref, ref_length); } DBUG_DUMP("ref", (char*)ref, ref_length); Loading