List:Commits« Previous MessageNext Message »
From:Craig L Russell Date:March 29 2012 12:28am
Subject:bzr push into mysql-5.1-telco-7.1 branch (Craig.Russell:4505 to 4506)
View as plain text  
 4506 Craig L Russell	2012-03-28
      Improve length validation for variable columns; remove check for 8000 characters in columns
      Add check for data exceeding column size
      Thanks to ted.wennmark@stripped

    modified:
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/VarcharStringLengthTest.java
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/OperationImpl.java
      storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java
      storage/ndb/clusterj/clusterj-tie/src/main/resources/com/mysql/clusterj/tie/Bundle.properties
 4505 Frazer Clement	2012-03-28 [merge]
      Merge 7.0->7.1

    added:
      mysql-test/suite/ndb_binlog/r/ndb_binlog_index.result
      mysql-test/suite/ndb_binlog/t/ndb_binlog_check_binlog_index.inc
      mysql-test/suite/ndb_binlog/t/ndb_binlog_index.test
      mysql-test/suite/ndb_binlog/t/ndb_binlog_index_test_schema_independent.inc
    modified:
      mysql-test/suite/ndb_binlog/r/ndb_binlog_ignore_db.result
      mysql-test/suite/ndb_binlog/t/ndb_binlog_ignore_db.test
      mysql-test/suite/ndb_rpl/r/ndb_rpl_idempotent.result
      mysql-test/suite/ndb_rpl/r/ndb_rpl_sync.result
      mysql-test/suite/ndb_rpl/t/ndb_rpl_idempotent.test
      scripts/mysql_system_tables.sql
      scripts/mysql_system_tables_fix.sql
      sql/ha_ndbcluster_binlog.cc
      sql/log.cc
      sql/log.h
      sql/log_event.h
      sql/rpl_injector.cc
      sql/rpl_injector.h
      sql/sql_class.cc
      sql/sql_class.h
=== modified file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/VarcharStringLengthTest.java'
--- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/VarcharStringLengthTest.java	2012-03-05 22:28:15 +0000
+++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/VarcharStringLengthTest.java	2012-03-29 00:25:53 +0000
@@ -19,11 +19,12 @@ package testsuite.clusterj;
 
 import com.mysql.clusterj.ClusterJException;
 
-import testsuite.clusterj.model.Employee;
+import testsuite.clusterj.model.CharsetLatin1;
 
 public class VarcharStringLengthTest extends AbstractClusterJTest {
 
-    private static String name = 
+    private static String characters = 
+        "11111111111111111111111111111111111111111111111111" +
         "11111111111111111111111111111111111111111111111111" +
         "11111111111111111111111111111111111111111111111111" +
         "11111111111111111111111111111111111111111111111111" +
@@ -39,29 +40,52 @@ public class VarcharStringLengthTest ext
     public void localSetUp() {
         createSessionFactory();
         session = sessionFactory.getSession();
-        session.deletePersistentAll(Employee.class);
-        addTearDownClasses(Employee.class);
+        session.deletePersistentAll(CharsetLatin1.class);
+        addTearDownClasses(CharsetLatin1.class);
+    }
+
+    public void testSmall() {
+        session.currentTransaction().begin();
+        for (int i = 195; i < 205; ++i) {
+            try {
+                CharsetLatin1 e = session.newInstance(CharsetLatin1.class, i);
+                e.setSmallColumn(characters.substring(0, i));
+                session.makePersistent(e);
+                if (i > 200) {
+                    // unexpected success for lengths greater than varchar size
+                    error("Expected exception not thrown for: " + i);
+                }
+            } catch (ClusterJException ex) {
+                if (i < 201) {
+                    // unexpected error for lengths not greater than varchar size 
+                    error("Unexpected exception for: " + i + " " + ex.getMessage());
+                }
+            }
+        }
+        session.currentTransaction().rollback();
+        failOnError();
     }
 
-    public void test() {
-        for (int i = 0; i < 500; ++i) {
+    public void testMedium() {
+        session.currentTransaction().begin();
+        for (int i = 495; i < 505; ++i) {
             try {
-            Employee e = session.newInstance(Employee.class, i);
-            e.setName(name.substring(0, i));
-            e.setAge(i);
-            e.setMagic(i);
+                CharsetLatin1 e = session.newInstance(CharsetLatin1.class, i);
+                e.setMediumColumn(characters.substring(0, i));
                 session.makePersistent(e);
-                if (i > 32) {
+                if (i > 500) {
                     // unexpected success for lengths greater than varchar size
                     error("Expected exception not thrown for: " + i);
                 }
             } catch (ClusterJException ex) {
-                if (i < 33) {
+                if (i < 501) {
                     // unexpected error for lengths not greater than varchar size 
                     error("Unexpected exception for: " + i + " " + ex.getMessage());
                 }
             }
         }
+        session.currentTransaction().rollback();
         failOnError();
     }
+
 }

=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/OperationImpl.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/OperationImpl.java	2012-03-05 22:28:15 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/OperationImpl.java	2012-03-29 00:25:53 +0000
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import com.mysql.clusterj.ClusterJUserException;
 import com.mysql.clusterj.core.store.Blob;
 import com.mysql.clusterj.core.store.Column;
 import com.mysql.clusterj.core.store.Operation;
@@ -235,6 +236,11 @@ class OperationImpl implements Operation
 
     public void setBytes(Column storeColumn, byte[] value) {
         // TODO use the string storage buffer instead of allocating a new buffer for each value
+        int length = value.length;
+        if (length > storeColumn.getLength()) {
+            throw new ClusterJUserException(local.message("ERR_Data_Too_Long", 
+                    storeColumn.getName(), storeColumn.getLength(), length));
+        }
         ByteBuffer buffer = Utility.convertValue(storeColumn, value);
         int returnCode = ndbOperation.setValue(storeColumn.getColumnId(), buffer);
         handleError(returnCode, ndbOperation);
@@ -280,6 +286,11 @@ class OperationImpl implements Operation
 
     public void setString(Column storeColumn, String value) {
         ByteBuffer stringStorageBuffer = Utility.encode(value, storeColumn, bufferManager);
+        int length = stringStorageBuffer.remaining() - storeColumn.getPrefixLength();
+        if (length > storeColumn.getLength()) {
+            throw new ClusterJUserException(local.message("ERR_Data_Too_Long", 
+                    storeColumn.getName(), storeColumn.getLength(), length));
+        }
         int returnCode = ndbOperation.setValue(storeColumn.getColumnId(), stringStorageBuffer);
         bufferManager.clearStringStorageBuffer();
         handleError(returnCode, ndbOperation);

=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java	2012-03-05 22:28:15 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java	2012-03-29 00:25:53 +0000
@@ -975,37 +975,26 @@ public class Utility {
      */
     public static void convertValue(ByteBuffer buffer, Column storeColumn, byte[] value) {
         int dataLength = value.length;
+        int maximumLength = storeColumn.getLength();
+        if (dataLength > maximumLength) {
+            throw new ClusterJUserException(
+                    local.message("ERR_Data_Too_Long",
+                    storeColumn.getName(), maximumLength, dataLength));
+        }
         int prefixLength = storeColumn.getPrefixLength();
         switch (prefixLength) {
             case 0:
-                int requiredLength = storeColumn.getColumnSpace();
-                if (dataLength > requiredLength) {
-                    throw new ClusterJFatalInternalException(
-                            local.message("ERR_Data_Too_Long",
-                            storeColumn.getName(), requiredLength, dataLength));
-                } else {
-                    buffer.put(value);
-                    if (dataLength < requiredLength) {
-                        // pad with 0x00 on right
-                        buffer.put(ZERO_PAD, 0, requiredLength - dataLength);
-                    }
+                buffer.put(value);
+                if (dataLength < maximumLength) {
+                    // pad with 0x00 on right
+                    buffer.put(ZERO_PAD, 0, maximumLength - dataLength);
                 }
                 break;
             case 1:
-                if (dataLength > 255) {
-                    throw new ClusterJFatalInternalException(
-                            local.message("ERR_Data_Too_Long",
-                            storeColumn.getName(), "255", dataLength));
-                }
                 buffer.put((byte)dataLength);
                 buffer.put(value);
                 break;
             case 2:
-                if (dataLength > 8000) {
-                    throw new ClusterJFatalInternalException(
-                            local.message("ERR_Data_Too_Long",
-                            storeColumn.getName(), "8000", dataLength));
-                }
                 buffer.put((byte)(dataLength%256));
                 buffer.put((byte)(dataLength/256));
                 buffer.put(value);
@@ -1240,17 +1229,9 @@ public class Utility {
             case 0:
                 break;
             case 1:
-                if (length > 255) {
-                    throw new ClusterJUserException(local.message("ERR_Varchar_Too_Big",
-                            length, columnName));
-                }
                 byteBuffer.put((byte)(length % 256));
                 break;
             case 2:
-                if (length > 65535) {
-                    throw new ClusterJUserException(local.message("ERR_Varchar_Too_Big",
-                            length, columnName));
-                }
                 byteBuffer.put((byte)(length % 256));
                 byteBuffer.put((byte)(length / 256));
                 break;

=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/resources/com/mysql/clusterj/tie/Bundle.properties'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/resources/com/mysql/clusterj/tie/Bundle.properties	2012-03-05 22:28:15 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/resources/com/mysql/clusterj/tie/Bundle.properties	2012-03-29 00:25:53 +0000
@@ -33,7 +33,7 @@ ERR_NdbJTie:Error in NdbJTie: returnCode
 status {3}, classification {4}, message {5} {6}.
 ERR_Invalid_Prefix_Length:The prefix length {0} is invalid.
 ERR_Blob_Read_Data:Blob readData read the wrong length; expected {0}, actual {1}.
-ERR_Data_Too_Long:Data length {2} too long. Column {0} can only accept data of length {1}.
+ERR_Data_Too_Long:Data length {2} too long. Column ''{0}'' can only accept data of length {1}.
 ERR_Charset_Decoder_Error:Error decoding string.
 ERR_String_To_Binary_Decimal:Error code {0} converting string {1} to binary decimal. The column \
 {2} has precision {3} and scale {4}.
@@ -56,7 +56,6 @@ ERR_Encode_Bad_Source:Error encoding cha
 ERR_Encode_Buffer_Too_Small:Error encoding characters, buffer too small: character set number {0}, before input length {1}, \
 before output length {2}, after input length {3}, after output length {4}.
 ERR_Encode_Bad_Return_Code:Error encoding characters, unknown return code {0}.
-ERR_Data_Too_Large:Error writing characters for column {0}; maximum size {1}, actual size {2}.
 ERR_Mismatch_No_Of_Primary_Key_Columns:For table {0} number of primary key columns {1} doesn't match \
 number of columns in primary key index {2}.
 ERR_Failed_Loading_Library:Attempt to load native library {0} from path {1} failed with {2} ({3}).
@@ -68,7 +67,6 @@ ERR_Bad_Charset_Decode_All_Chars:Error d
 ERR_Charset_Number_Too_Big:The charset number {0} for charset {1} exceeds the compiled maximum {2}.
 WARN_Unknown_Collation:The collation {0} for charset {1} is unknown.
 ERR_Cannot_Set_Join_Transaction_Id_After_Transaction_Begin:Cannot set join transaction id after transaction begin.
-ERR_Varchar_Too_Big:Varchar data of size {0} is too big for column ''{1}''.
 ERR_Cluster_Connection_Must_Not_Be_Null:The cluster connection must not be null.
 INFO_Close_Cluster_Connection:Closing cluster connection ''{0}'' with node id {1}.
 INFO_Create_Cluster_Connection:Created cluster connection ''{0}'' with node id {1}.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.1 branch (Craig.Russell:4505 to 4506) Craig L Russell29 Mar