[Commits] Rev 3523: Check and obey dynamic column name length limits implementation. in file:///home/bell/maria/bzr/work-maria-5.5-cassandra/

sanja at montyprogram.com sanja at montyprogram.com
Thu Sep 27 10:53:09 EEST 2012


At file:///home/bell/maria/bzr/work-maria-5.5-cassandra/

------------------------------------------------------------
revno: 3523
revision-id: sanja at montyprogram.com-20120927075306-xj00c5ao4hqgxf9c
parent: sanja at montyprogram.com-20120926190923-oxdeydkyu12bmx1m
committer: sanja at montyprogram.com
branch nick: work-maria-5.5-cassandra
timestamp: Thu 2012-09-27 10:53:06 +0300
message:
  Check and obey dynamic column name length limits implementation.
-------------- next part --------------
=== modified file 'include/ma_dyncol.h'
--- a/include/ma_dyncol.h	2012-09-26 19:09:23 +0000
+++ b/include/ma_dyncol.h	2012-09-27 07:53:06 +0000
@@ -39,6 +39,12 @@
 */
 #define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL
 
+/*
+  Limits of implementation
+*/
+#define MAX_NAME_LENGTH 255
+#define MAX_TOTAL_NAME_LENGTH 65535
+
 /* NO and OK is the same used just to show semantics */
 #define ER_DYNCOL_NO ER_DYNCOL_OK
 

=== modified file 'mysys/ma_dyncol.c'
--- a/mysys/ma_dyncol.c	2012-09-26 19:09:23 +0000
+++ b/mysys/ma_dyncol.c	2012-09-27 07:53:06 +0000
@@ -213,7 +213,7 @@ static my_bool check_limit_num(const voi
 
 static my_bool check_limit_str(const void *val)
 {
-  return (*((LEX_STRING **)val))->length > 255;
+  return (*((LEX_STRING **)val))->length > MAX_NAME_LENGTH;
 }
 
 
@@ -290,7 +290,7 @@ my_bool put_header_entry_str(DYN_HEADER
                              size_t offset)
 {
   LEX_STRING *column_name= (LEX_STRING *)column_key;
-  DBUG_ASSERT(column_name->length <= 255);
+  DBUG_ASSERT(column_name->length <= MAX_NAME_LENGTH);
   hdr->entry[0]= column_name->length;
   DBUG_ASSERT(hdr->name - hdr->nmpool < (long) 0x10000L);
   int2store(hdr->entry + 1, hdr->name - hdr->nmpool);

=== modified file 'storage/cassandra/ha_cassandra.cc'
--- a/storage/cassandra/ha_cassandra.cc	2012-09-26 19:09:23 +0000
+++ b/storage/cassandra/ha_cassandra.cc	2012-09-27 07:53:06 +0000
@@ -1666,7 +1666,7 @@ int ha_cassandra::read_cassandra_columns
   int cass_value_len, cass_name_len;
   Field **field;
   int res= 0;
-  bool do_dyncol= dyncol_set;
+  ulong total_name_len= 0;
 
   /*
     cassandra_to_mariadb() calls will use field->store(...) methods, which
@@ -1705,7 +1705,7 @@ int ha_cassandra::read_cassandra_columns
         break;
       }
     }
-    if (do_dyncol && !found)
+    if (dyncol_set && !found)
     {
       DYNAMIC_COLUMN_VALUE val;
       LEX_STRING nm;
@@ -1713,19 +1713,50 @@ int ha_cassandra::read_cassandra_columns
                                                         cass_name_len);
       nm.str= cass_name;
       nm.length= cass_name_len;
-      if ((*(type->cassandra_to_dynamic))(cass_value, cass_value_len, &val) ||
+      if (nm.length > MAX_NAME_LENGTH)
+      {
+        se->print_error("Unable to convert value for field `%s`"
+                        " from Cassandra's data format. Name"
+                        " length of the field '%s' exceed limit of %u",
+                        table->field[dyncol_field]->field_name,
+                        cass_name, (uint)MAX_NAME_LENGTH);
+        my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
+        res=1;
+        goto err;
+      }
+      total_name_len+= cass_name_len;
+      if (nm.length > MAX_TOTAL_NAME_LENGTH)
+      {
+        se->print_error("Unable to convert value for field `%s`"
+                        " from Cassandra's data format. Sum of all names"
+                        " length exceed limit of %lu",
+                        table->field[dyncol_field]->field_name,
+                        cass_name, (uint)MAX_TOTAL_NAME_LENGTH);
+        my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
+        res=1;
+        goto err;
+      }
+
+      if ((res= (*(type->cassandra_to_dynamic))(cass_value,
+                                                cass_value_len, &val)) ||
           insert_dynamic(&dynamic_names, (uchar *) &nm) ||
           insert_dynamic(&dynamic_values, (uchar *) &val))
       {
+        if (res)
+        {
+          print_conversion_error(cass_name, cass_value, cass_value_len);
+        }
         free_strings((DYNAMIC_COLUMN_VALUE *)dynamic_values.buffer,
                      dynamic_values.elements);
-        do_dyncol= FALSE;
+        // EOM shouldm be already reported if happened
+        res=1;
+        goto err;
       }
     }
   }
 
   dynamic_rec.length= 0;
-  if (do_dyncol)
+  if (dyncol_set)
   {
     if (dynamic_column_create_many_internal_fmt(&dynamic_rec,
                                                 dynamic_names.elements,



More information about the commits mailing list