List:Internals« Previous MessageNext Message »
From:reggie Date:July 12 2005 4:35pm
Subject:bk commit into 4.1 tree (reggie:1.2329) BUG#7142
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of reggie. When reggie 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.2329 05/07/12 08:35:30 reggie@stripped +8 -0
  Bug #7142  Show Fields from fails using Borland's dbExpress interface
  
  The problem here is that columns that have an especially long type 
  such as an enum type with many options would be longer than 40 chars
  but the type column returned from show columns always was defined
  as varchar(40).
  
  This is fixed in 5.0 using info schema.

  tests/mysql_client_test.c
    1.152 05/07/12 08:35:04 reggie@stripped +3 -3
    update columns which will now be reported as blobs

  sql/sql_show.cc
    1.199 05/07/12 08:35:04 reggie@stripped +30 -1
    Add function to iterate over all the fields of a table and determine 
    the longest type name.
    
    We call this function at the top of our show fields code.  We pass in 
    either 40 or max_len whichever is longer to the ctor of
    Item_empty_string.

  sql/item.cc
    1.211 05/07/12 08:35:04 reggie@stripped +8 -1
    report a column as a particular blob type if it's size warrants

  mysql-test/r/ps_5merge.result
    1.24 05/07/12 08:35:04 reggie@stripped +6 -6
    update columns which will now be reported as blobs

  mysql-test/r/ps_4heap.result
    1.24 05/07/12 08:35:03 reggie@stripped +3 -3
    update columns which will now be reported as blobs

  mysql-test/r/ps_3innodb.result
    1.26 05/07/12 08:35:03 reggie@stripped +3 -3
    update columns which will now be reported as blobs

  mysql-test/r/ps_2myisam.result
    1.25 05/07/12 08:35:03 reggie@stripped +3 -3
    update columns which will now be reported as blobs

  mysql-test/r/ps_1general.result
    1.21 05/07/12 08:35:03 reggie@stripped +6 -6
    update columns which will now be reported as blobs

# 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:	reggie
# Host:	linux.site
# Root:	/home/reggie/bk/mysql-4.1

--- 1.210/sql/item.cc	2005-06-27 07:46:35 -06:00
+++ 1.211/sql/item.cc	2005-07-12 08:35:04 -06:00
@@ -1768,7 +1768,14 @@
 
 void Item_empty_string::make_field(Send_field *tmp_field)
 {
-  init_make_field(tmp_field,FIELD_TYPE_VAR_STRING);
+  enum_field_types type = FIELD_TYPE_VAR_STRING;  
+  if (max_length >= 16777216)    
+    type = FIELD_TYPE_LONG_BLOB;  
+  else if (max_length >= 65536)    
+    type = FIELD_TYPE_MEDIUM_BLOB;  
+  else if (max_length >= 256)    
+    type = FIELD_TYPE_BLOB;  
+  init_make_field(tmp_field, type);
 }
 
 

--- 1.198/sql/sql_show.cc	2005-04-16 13:35:37 -06:00
+++ 1.199/sql/sql_show.cc	2005-07-12 08:35:04 -06:00
@@ -638,6 +638,30 @@
   DBUG_RETURN(0);
 }
 
+/*
+returns the length of the longest type on the given table.
+This is used so that show fields will return the data using the proper 
+lengths instead of forcing columns such as type to always return with a 
+given length.
+*/
+uint get_longest_type_in_table(TABLE *table, const char *wild)
+{  
+  Field **ptr,*field;  
+  char tmp[MAX_FIELD_WIDTH];  
+  uint max_len = 0;  
+
+  for (ptr=table->field; (field= *ptr); ptr++)  
+  {    
+    if (!wild || !wild[0] ||         
+        !wild_case_compare(system_charset_info, field->field_name,wild))    
+    {
+      String type(tmp,sizeof(tmp), system_charset_info);      
+      field->sql_type(type);      
+      max_len = max(max_len, type.length());     
+    }  
+  }  
+  return max_len;
+}
 
 /***************************************************************************
 ** List all columns in a table_list->real_name
@@ -667,9 +691,14 @@
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   (void) get_table_grant(thd, table_list);
 #endif
+
+  /* we scan for the longest since long enum types can exceed 40 */
+  uint max_len = get_longest_type_in_table(table, wild);
+
   List<Item> field_list;
   field_list.push_back(new Item_empty_string("Field",NAME_LEN));
-  field_list.push_back(new Item_empty_string("Type",40));
+  field_list.push_back(new Item_empty_string("Type",
+	max_len > 40 ? max_len : 40));
   if (verbose)
     field_list.push_back(new Item_empty_string("Collation",40));
   field_list.push_back(new Item_empty_string("Null",1));

--- 1.20/mysql-test/r/ps_1general.result	2005-06-07 07:31:42 -06:00
+++ 1.21/mysql-test/r/ps_1general.result	2005-07-12 08:35:03 -06:00
@@ -470,12 +470,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	14	N	1	31	8
+def					Extra	252	255	14	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 SET @arg00=1 ;
@@ -486,12 +486,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	5	Y	0	31	8
-def					possible_keys	253	4096	7	Y	0	31	8
+def					possible_keys	252	4096	7	Y	0	31	8
 def					key	253	64	7	Y	0	31	8
 def					key_len	8	3	1	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	27	N	1	31	8
+def					Extra	252	255	27	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	Using where; Using filesort
 drop table if exists t2;

--- 1.24/mysql-test/r/ps_2myisam.result	2005-06-07 07:32:12 -06:00
+++ 1.25/mysql-test/r/ps_2myisam.result	2005-07-12 08:35:03 -06:00
@@ -1153,12 +1153,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	0	N	1	31	8
+def					Extra	252	255	0	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
 drop table if exists t2 ;

--- 1.25/mysql-test/r/ps_3innodb.result	2005-06-07 07:32:40 -06:00
+++ 1.26/mysql-test/r/ps_3innodb.result	2005-07-12 08:35:03 -06:00
@@ -1153,12 +1153,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	0	N	1	31	8
+def					Extra	252	255	0	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
 test_sequence

--- 1.23/mysql-test/r/ps_4heap.result	2005-06-07 07:33:09 -06:00
+++ 1.24/mysql-test/r/ps_4heap.result	2005-07-12 08:35:03 -06:00
@@ -1154,12 +1154,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	0	N	1	31	8
+def					Extra	252	255	0	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
 test_sequence

--- 1.23/mysql-test/r/ps_5merge.result	2005-06-07 07:33:34 -06:00
+++ 1.24/mysql-test/r/ps_5merge.result	2005-07-12 08:35:04 -06:00
@@ -1196,12 +1196,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	0	N	1	31	8
+def					Extra	252	255	0	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
 test_sequence
@@ -4210,12 +4210,12 @@
 def					select_type	253	19	6	N	1	31	8
 def					table	253	64	2	Y	0	31	8
 def					type	253	10	3	Y	0	31	8
-def					possible_keys	253	4096	0	Y	0	31	8
+def					possible_keys	252	4096	0	Y	0	31	8
 def					key	253	64	0	Y	0	31	8
 def					key_len	8	3	0	Y	32928	0	63
-def					ref	253	1024	0	Y	0	31	8
+def					ref	252	1024	0	Y	0	31	8
 def					rows	8	10	1	Y	32928	0	63
-def					Extra	253	255	0	N	1	31	8
+def					Extra	252	255	0	N	1	31	8
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t9	ALL	NULL	NULL	NULL	NULL	2	
 test_sequence

--- 1.151/tests/mysql_client_test.c	2005-04-27 18:50:46 -06:00
+++ 1.152/tests/mysql_client_test.c	2005-07-12 08:35:04 -06:00
@@ -7173,7 +7173,7 @@
   verify_prepare_field(result, 3, "type", "", MYSQL_TYPE_VAR_STRING,
                        "", "", "", 10, 0);
 
-  verify_prepare_field(result, 4, "possible_keys", "", MYSQL_TYPE_VAR_STRING,
+  verify_prepare_field(result, 4, "possible_keys", "", MYSQL_TYPE_BLOB,
                        "", "", "", NAME_LEN*64, 0);
 
   verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING,
@@ -7186,13 +7186,13 @@
                        (mysql_get_server_version(mysql) <= 50000 ? 3 : 4096),
                        0);
 
-  verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING,
+  verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_BLOB,
                        "", "", "", NAME_LEN*16, 0);
 
   verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG,
                        "", "", "", 10, 0);
 
-  verify_prepare_field(result, 9, "Extra", "", MYSQL_TYPE_VAR_STRING,
+  verify_prepare_field(result, 9, "Extra", "", MYSQL_TYPE_BLOB,
                        "", "", "", 255, 0);
 
   mysql_free_result(result);
Thread
bk commit into 4.1 tree (reggie:1.2329) BUG#7142reggie12 Jul