From: magnus.blaudd Date: July 5 2012 1:51pm Subject: bzr push into mysql-5.5-cluster-7.2 branch (magnus.blaudd:3963 to 3964) List-Archive: http://lists.mysql.com/commits/144381 Message-Id: <20120705135140.15252.54787.3964@peek02.se.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3964 magnus.blaudd@stripped 2012-07-05 [merge] Merge 7.1 -> 7.2 added: storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/TableWithoutPKTest.java storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/TableWithoutPKTest.java modified: mysql-test/suite/ndb/t/clusterj.test storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/metadata/DomainTypeHandlerImpl.java storage/ndb/clusterj/clusterj-core/src/main/resources/com/mysql/clusterj/core/Bundle.properties storage/ndb/clusterj/clusterj-test/src/main/resources/schema.sql 3963 magnus.blaudd@stripped 2012-07-05 ndb - remove trailing 'a' from MYSQL_SERVER_VERSION used to mask output from ndb_mgm, ndb_mgm doesn't print it - change to use the new "ndb_version_string" variable for the ndb_version mask modified: mysql-test/suite/ndb/t/ndb_mgm.test === modified file 'mysql-test/suite/ndb/t/clusterj.test' --- a/mysql-test/suite/ndb/t/clusterj.test 2012-03-06 00:46:42 +0000 +++ b/mysql-test/suite/ndb/t/clusterj.test 2012-06-28 23:49:16 +0000 @@ -56,6 +56,7 @@ DROP TABLE stringtype; DROP TABLE t_basic; DROP TABLE timestamptypes; DROP TABLE timetypes; +DROP TABLE twopk; DROP TABLE yeartypes; DROP TABLE localetypes; DROP TABLE stringtypes; === modified file 'storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/metadata/DomainTypeHandlerImpl.java' --- a/storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/metadata/DomainTypeHandlerImpl.java 2012-04-02 20:43:14 +0000 +++ b/storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/metadata/DomainTypeHandlerImpl.java 2012-06-28 22:30:59 +0000 @@ -268,6 +268,14 @@ public class DomainTypeHandlerImpl ex indexHandler.assertAllColumnsHaveFields(); } + // Make sure that the PRIMARY index is usable + // If not, this table has no primary key or there is no primary key field + if (!indexHandlerImpls.get(0).isUsable()) { + String reason = local.message("ERR_Primary_Field_Missing", name); + logger.info(reason); + throw new ClusterJUserException(reason); + } + if (logger.isDebugEnabled()) { logger.debug(toString()); logger.debug("DomainTypeHandlerImpl " + name + "Indices " + indexHandlerImpls); === modified file 'storage/ndb/clusterj/clusterj-core/src/main/resources/com/mysql/clusterj/core/Bundle.properties' --- a/storage/ndb/clusterj/clusterj-core/src/main/resources/com/mysql/clusterj/core/Bundle.properties 2012-05-31 00:47:21 +0000 +++ b/storage/ndb/clusterj/clusterj-core/src/main/resources/com/mysql/clusterj/core/Bundle.properties 2012-06-28 22:30:59 +0000 @@ -36,6 +36,7 @@ ERR_Get_Constructor:Cannot get Construct ERR_Annotate_Set_Method:Property {0}: Cannot annotate set methods with {1}. ERR_Primary_Field_Type:For class {0}, primary key column {1}: field type {2} is not supported. ERR_Primary_Column_Type:For class {0}, primary key column {1}: column type {2} is not supported. +ERR_Primary_Field_Missing:For class {0}, there is no field mapped to the primary key column. ERR_Field_Construction:Error in metadata initialization for {0}:\n{1} ERR_Value_Delegate:For field {0} column {1} valueDelegate {2}, error executing {3}. ERR_Filter_Value:Error performing filter operation for field {0} column {1} \ === added file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/TableWithoutPKTest.java' --- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/TableWithoutPKTest.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/TableWithoutPKTest.java 2012-06-28 22:30:59 +0000 @@ -0,0 +1,76 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +package testsuite.clusterj; + +import testsuite.clusterj.model.IdBase; + +import com.mysql.clusterj.ClusterJUserException; + +import com.mysql.clusterj.annotation.PersistenceCapable; + +public class TableWithoutPKTest extends AbstractClusterJModelTest { + + @Override + public void localSetUp() { + createSessionFactory(); + session = sessionFactory.getSession(); + } + + public void testFind() { + try { + session.find(TableWithoutPK.class, 0); + error("Find on table without primary key mapped should fail."); + } catch (ClusterJUserException e) { + if (!e.getMessage().contains("TableWithoutPK")) { + error("Find on table without primary key mapped should fail with ClusterJUserException."); + } + } + failOnError(); + } + + public void testInsert() { + try { + session.newInstance(TableWithoutPK.class); + error("newInstance on table without primary key mapped should fail."); + } catch (ClusterJUserException e) { + if (!e.getMessage().contains("TableWithoutPK")) { + error("newInstance on table without primary key mapped should fail with ClusterJUserException."); + } + } + failOnError(); + } + + public void testQuery() { + try { + session.getQueryBuilder().createQueryDefinition(TableWithoutPK.class); + error("createQueryDefinition on table without primary key mapped should fail."); + } catch (ClusterJUserException e) { + if (!e.getMessage().contains("TableWithoutPK")) { + error("newInstance on table without primary key mapped should fail with ClusterJUserException."); + } + } + failOnError(); + } + + @PersistenceCapable(table="twopk") + static public interface TableWithoutPK extends IdBase { + String getName(); + void setName(String value); + } + +} === modified file 'storage/ndb/clusterj/clusterj-test/src/main/resources/schema.sql' --- a/storage/ndb/clusterj/clusterj-test/src/main/resources/schema.sql 2012-03-06 07:58:33 +0000 +++ b/storage/ndb/clusterj/clusterj-test/src/main/resources/schema.sql 2012-07-05 13:50:52 +0000 @@ -3,6 +3,13 @@ drop table if exists t_basic; # the second statement is a test; if it succeeds, skip the rest of the file. select id from t_basic where id = 9999; # the following statements are delimited by semicolon + +DROP TABLE IF EXISTS twopk; +CREATE TABLE IF NOT EXISTS twopk ( + id int not null, + name varchar(30) +) ENGINE = ndbcluster; + DROP TABLE IF EXISTS subscriber ; CREATE TABLE IF NOT EXISTS subscriber ( === added file 'storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/TableWithoutPKTest.java' --- a/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/TableWithoutPKTest.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/TableWithoutPKTest.java 2012-06-28 22:30:59 +0000 @@ -0,0 +1,22 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +package testsuite.clusterj.tie; + +public class TableWithoutPKTest extends testsuite.clusterj.TableWithoutPKTest { + +} No bundle (reason: useless for push emails).