List:Internals« Previous MessageNext Message »
From:konstantin Date:July 14 2005 12:09am
Subject:bk commit into 4.1 tree (konstantin:1.2351) BUG#9735
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2351 05/07/14 02:09:31 konstantin@stripped +2 -0
  A fix and a test case for Bug#9735.
  No separate typecode for MEDIUMTEXT/LONGTEXT is added, as we
  have no sound decision yet what typecodes and for what types are
  sent by the server (aka what constitutes a distinct type in MySQL).

  tests/mysql_client_test.c
    1.152 05/07/14 02:09:25 konstantin@stripped +30 -1
    A test case for Bug#9735  "mysql_fetch_fields() acts strange on 
    LONGBLOB/LONGTEXT"

  sql/field.cc
    1.223 05/07/14 02:09:25 konstantin@stripped +3 -1
    A fix for Bug#9735 "mysql_fetch_fields() acts strange on 
    LONGBLOB/LONGTEXT": fix wrong initialization of field_length
    in case of BLOB fields.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	konstantin
# Host:	dragonfly.local
# Root:	/opt/local/work/mysql-4.1-root

--- 1.222/sql/field.cc	2005-06-28 14:19:52 +04:00
+++ 1.223/sql/field.cc	2005-07-14 02:09:25 +04:00
@@ -47,6 +47,8 @@
 const char field_separator=',';
 
 #define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320
+#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
+((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
 
 /*
   Rules for merging different types of fields in UNION
@@ -5445,7 +5447,7 @@
 		       enum utype unireg_check_arg, const char *field_name_arg,
 		       struct st_table *table_arg,uint blob_pack_length,
 		       CHARSET_INFO *cs)
-  :Field_str(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L,
+  :Field_str(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
 	     null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
 	     table_arg, cs),
    packlength(blob_pack_length)

--- 1.151/tests/mysql_client_test.c	2005-04-28 04:50:46 +04:00
+++ 1.152/tests/mysql_client_test.c	2005-07-14 02:09:25 +04:00
@@ -672,7 +672,7 @@
     fprintf(stdout, "\n    org_table:`%s`\t(expected: `%s`)",
             field->org_table, org_table);
     fprintf(stdout, "\n    database :`%s`\t(expected: `%s`)", field->db, db);
-    fprintf(stdout, "\n    length   :`%ld`\t(expected: `%ld`)",
+    fprintf(stdout, "\n    length   :`%lu`\t(expected: `%lu`)",
             field->length, length * cs->mbmaxlen);
     fprintf(stdout, "\n    maxlength:`%ld`", field->max_length);
     fprintf(stdout, "\n    charsetnr:`%d`", field->charsetnr);
@@ -11670,6 +11670,34 @@
 #endif
 }
 
+
+/* Test correct max length for MEDIUMTEXT and LONGTEXT columns */
+
+static void test_bug9735()
+{
+  MYSQL_RES *res;
+  int rc;
+
+  myheader("test_bug9735");
+
+  rc= mysql_query(mysql, "drop table if exists t1");
+  myquery(rc);
+  rc= mysql_query(mysql, "create table t1 (a mediumtext, b longtext) "
+                         "character set latin1");
+  myquery(rc);
+  rc= mysql_query(mysql, "select * from t1");
+  myquery(rc);
+  res= mysql_store_result(mysql);
+  verify_prepare_field(res, 0, "a", "a", MYSQL_TYPE_BLOB,
+                       "t1", "t1", current_db, (1U << 24)-1, 0);
+  verify_prepare_field(res, 1, "b", "b", MYSQL_TYPE_BLOB,
+                       "t1", "t1", current_db, ~0U, 0);
+  mysql_free_result(res);
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -11884,6 +11912,7 @@
   { "test_bug8330", test_bug8330 },
   { "test_bug7990", test_bug7990 },
   { "test_bug8378", test_bug8378 },
+  { "test_bug9735", test_bug9735 },
   { 0, 0 }
 };
 
Thread
bk commit into 4.1 tree (konstantin:1.2351) BUG#9735konstantin14 Jul