Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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.2030 05/10/12 01:37:54 evgen@stripped +2 -0
Fix bug #13488 Wrong tmp field was created for cursor with left outer join
Original field type was lost while creating tmp field.
This bug have same nature that #11718 has. create_tmp_field_from_item() was
creating tmp field with result_type == INT_RESULT without regard to original
field type of Item. This results in wrong type being reported to client.
create_tmp_field_from_item() now checks whether length of field <= 11. If so
then it uses item->tmp_table_field_from_field_type() to create tmp field with
exact type.
sql/sql_select.cc
1.377 05/10/12 01:36:32 evgen@stripped +4 -1
Fix bug #13488 Wrong tmp field was created for cursor with left outer join
create_tmp_field_from_item() now uses item->tmp_table_field_from_field_type() to
create tmp field for Item_field with int result type and with length <= 11.
tests/mysql_client_test.c
1.160 05/10/12 01:36:12 evgen@stripped +71 -0
Test case for bug#13488 Wrong tmp field was created for cursor with left outer join
# 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: evgen
# Host: moonbone.local
# Root: /work/13488-bug-5.0-mysql
--- 1.376/sql/sql_select.cc 2005-09-30 01:34:15 +04:00
+++ 1.377/sql/sql_select.cc 2005-10-12 01:36:32 +04:00
@@ -7694,7 +7694,10 @@
item->name, table, item->decimals);
break;
case INT_RESULT:
- new_field=new Field_longlong(item->max_length, maybe_null,
+ if (item->max_length <= 11)
+ new_field= item->tmp_table_field_from_field_type(table);
+ else
+ new_field=new Field_longlong(item->max_length, maybe_null,
item->name, table, item->unsigned_flag);
break;
case STRING_RESULT:
--- 1.159/tests/mysql_client_test.c 2005-09-22 02:10:59 +04:00
+++ 1.160/tests/mysql_client_test.c 2005-10-12 01:36:12 +04:00
@@ -14351,6 +14351,76 @@
rc= mysql_query(mysql, "drop table t1, t2");
myquery(rc);
}
+
+/*
+ Bug#13488: Wrong tmp field was created for cursor with left outer join
+*/
+
+static void test_bug13488()
+{
+ MYSQL_BIND bind[3];
+ MYSQL_STMT *stmt1;
+ int rc, f1, f2, f3, i;
+ const ulong type= CURSOR_TYPE_READ_ONLY;
+ const char *query= "select * from t1 left join t2 on f1=f2 where f1=1";
+
+ myheader("test_bug13488");
+
+ rc= mysql_query(mysql, "drop table if exists t1, t2");
+ myquery(rc);
+ rc= mysql_query(mysql, "create table t1 (f1 int not null primary key)");
+ myquery(rc);
+ rc= mysql_query(mysql, "create table t2 (f2 int not null primary key, "
+ "f3 int not null)");
+ myquery(rc);
+ rc= mysql_query(mysql, "insert into t1 values (1), (2)");
+ myquery(rc);
+ rc= mysql_query(mysql, "insert into t2 values (1,2), (2,4)");
+ myquery(rc);
+
+ memset(bind, 0, sizeof(bind));
+ for (i= 0; i < 3; i++)
+ {
+ bind[i].buffer_type= MYSQL_TYPE_LONG;
+ bind[i].buffer_length= 4;
+ bind[i].length= 0;
+ }
+ bind[0].buffer=&f1;
+ bind[1].buffer=&f2;
+ bind[2].buffer=&f3;
+
+ stmt1= mysql_stmt_init(mysql);
+ rc= mysql_stmt_attr_set(stmt1,STMT_ATTR_CURSOR_TYPE, (const void *)&type);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_prepare(stmt1, query, strlen(query));
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_execute(stmt1);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_bind_result(stmt1, bind);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_fetch(stmt1);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_free_result(stmt1);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_reset(stmt1);
+ check_execute(stmt1, rc);
+
+ rc= mysql_stmt_close(stmt1);
+ check_execute(stmt1, rc);
+
+ if (!opt_silent)
+ printf("data is: %s", (f1 == 1 && f2 == 1 && f3 == 2)?"OK":
+ "wrong");
+ DIE_UNLESS(f1 == 1 && f2 == 1 && f3 == 2);
+ rc= mysql_query(mysql, "drop table t1, t2");
+ myquery(rc);
+}
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -14602,6 +14672,7 @@
{ "test_bug11901", test_bug11901 },
{ "test_bug11904", test_bug11904 },
{ "test_bug12243", test_bug12243 },
+ { "test_bug13488", test_bug13488 },
{ 0, 0 }
};
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2030) BUG#13488 | eugene | 11 Oct |