summaryrefslogtreecommitdiff
path: root/sql/sql_cursor.cc
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-11-09 20:31:01 +0300
committerunknown <konstantin@mysql.com>2005-11-09 20:31:01 +0300
commit75fab5146f0c230115ddc6e2e1e0f1b9c213f3d5 (patch)
treed7c8b15f9e7d1d4503383243fdb60d355613dade /sql/sql_cursor.cc
parentdb46acd0bcec59e876c01953587fa9f1d5c93ded (diff)
downloadmariadb-git-75fab5146f0c230115ddc6e2e1e0f1b9c213f3d5.tar.gz
A fix and a test case for Bug#13488 "Left outer join query incorrectly
gives MYSQL_DATA_TRUNCATED" sql/sql_cursor.cc: A partial fix for Bug#13488 "Left outer join query incorrectly gives MYSQL_DATA_TRUNCATED": send the correct metadata of the cursor result set at execute. The full fix would be to make sure that the metadata doesn't change between prepare and execute. tests/mysql_client_test.c: A test case for Bug#13488 "Left outer join query incorrectly gives MYSQL_DATA_TRUNCATED"
Diffstat (limited to 'sql/sql_cursor.cc')
-rw-r--r--sql/sql_cursor.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index e8da691ea18..07be9efa6ac 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -558,6 +558,24 @@ int Materialized_cursor::open(JOIN *join __attribute__((unused)))
result->prepare(item_list, &fake_unit) ||
table->file->ha_rnd_init(TRUE));
thd->restore_active_arena(this, &backup_arena);
+ if (rc == 0)
+ {
+ /*
+ Now send the result set metadata to the client. We need to do it
+ here, as in Select_materialize::send_fields the exact column types
+ are not yet known. The new types may differ from the original ones
+ sent at prepare if some of them were altered by MySQL HEAP tables
+ mechanism -- used when create_tmp_field_from_item may alter the
+ original column type.
+
+ We can't simply supply SEND_EOF flag to send_fields, because
+ send_fields doesn't flush the network buffer.
+ */
+ rc= result->send_fields(item_list, Protocol::SEND_NUM_ROWS);
+ thd->server_status|= SERVER_STATUS_CURSOR_EXISTS;
+ result->send_eof();
+ thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS;
+ }
return rc;
}
@@ -647,14 +665,6 @@ bool Select_materialize::send_fields(List<Item> &list, uint flags)
if (create_result_table(unit->thd, unit->get_unit_column_types(),
FALSE, thd->options | TMP_TABLE_ALL_COLUMNS, ""))
return TRUE;
- /*
- We can't simply supply SEND_EOF flag to send_fields, because send_fields
- doesn't flush the network buffer.
- */
- rc= result->send_fields(list, Protocol::SEND_NUM_ROWS);
- thd->server_status|= SERVER_STATUS_CURSOR_EXISTS;
- result->send_eof();
- thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS;
return rc;
}