summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2006-08-30 00:38:58 +0400
committerunknown <kostja@bodhi.local>2006-08-30 00:38:58 +0400
commit4355ea5a38c819cf1e98089b3d85fc628c48da46 (patch)
treecdfe8a72e8e640072c7742e9aa8836f40a34ab72 /sql/field.cc
parentc923270f2194a9b1c6b7383658778cb64300cec7 (diff)
downloadmariadb-git-4355ea5a38c819cf1e98089b3d85fc628c48da46.tar.gz
A fix for Bug#14897 "ResultSet.getString("table.column") sometimes
doesn't find the column" When a user was using 4.1 tables with VARCHAR column and 5.0 server and a query that used a temporary table to resolve itself, the table metadata for the varchar column sent to client was incorrect: MYSQL_FIELD::table member was empty. The bug was caused by implicit "upgrade" from old VARCHAR to new VARCHAR hard-coded in Field::new_field, which did not preserve the information about the original table. Thus, the field metadata of the "upgraded" field pointed to an auxiliary temporary table created for query execution. The fix is to copy the pointer to the original table to the new field. mysql-test/r/type_varchar.result: Update test results (Bug#14897) mysql-test/t/type_varchar.test: Add a test case for Bug#14897 "ResultSet.getString("table.column") sometimes doesn't find the column" sql/field.cc: Preserve the original table name when converting fields from old VARCHAR to new VARCHAR. mysql-test/std_data/14897.frm: New BitKeeper file ``mysql-test/std_data/14897.frm''
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 921148e8f0f..05eb7d2d744 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6154,15 +6154,26 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table,
Field *new_field;
if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
- return Field::new_field(root, new_table, keep_type);
+ new_field= Field::new_field(root, new_table, keep_type);
+ else
+ {
- /*
- Old VARCHAR field which should be modified to a VARCHAR on copy
- This is done to ensure that ALTER TABLE will convert old VARCHAR fields
- to now VARCHAR fields.
- */
- return new Field_varstring(field_length, maybe_null(),
- field_name, new_table, charset());
+ /*
+ Old VARCHAR field which should be modified to a VARCHAR on copy
+ This is done to ensure that ALTER TABLE will convert old VARCHAR fields
+ to now VARCHAR fields.
+ */
+ new_field= new Field_varstring(field_length, maybe_null(),
+ field_name, new_table, charset());
+ /*
+ Normally orig_table is different from table only if field was created
+ via ::new_field. Here we alter the type of field, so ::new_field is
+ not applicable. But we still need to preserve the original field
+ metadata for the client-server protocol.
+ */
+ new_field->orig_table= orig_table;
+ }
+ return new_field;
}
/****************************************************************************