summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-09-28 23:24:40 +0000
committerunknown <evgen@moonbone.local>2007-09-28 23:24:40 +0000
commit6a8bd84a825094c99919f4391c22fd70f47c08ac (patch)
tree8eac86ce3439f35209aaa770d4d2cb7e11a96297 /tests
parent4430048ee8084e0fcef144e64ab89b59f8e31a71 (diff)
downloadmariadb-git-6a8bd84a825094c99919f4391c22fd70f47c08ac.tar.gz
Bug#27990: Wrong info in MYSQL_FIELD struct members when a tmp table was used.
The change_to_use_tmp_fields function leaves the orig_table member of an expression's tmp table field filled for the new Item_field being created. Later orig_table is used by the Field::make_field function to provide some info about original table and field name to a user. This is ok for a field but for an expression it should be empty. The change_to_use_tmp_fields function now resets orig_table member of an expression's tmp table field to prevent providing a wrong info to a user. The Field::make_field function now resets the table_name and the org_col_name variables when the orig_table is set to 0. sql/field.cc: Bug#27990: Wrong info in MYSQL_FIELD struct members when a tmp table was used. The Field::make_field function now resets the table_name and the org_col_name variables when the orig_table is set to 0. sql/sql_select.cc: Bug#27990: Wrong info in MYSQL_FIELD struct members when a tmp table was used. The change_to_use_tmp_fields function now resets orig_table member of an expression's tmp table field to prevent providing a wrong info to a user. tests/mysql_client_test.c: The test case for the bug#21635 is altered to test behavior on both const and non-const tables.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index d64ec08a71d..3e50e1ede84 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -15486,7 +15486,7 @@ static void test_bug21635()
char *query_end;
MYSQL_RES *result;
MYSQL_FIELD *field;
- unsigned int field_count, i;
+ unsigned int field_count, i, j;
int rc;
DBUG_ENTER("test_bug21635");
@@ -15502,28 +15502,35 @@ static void test_bug21635()
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)");
myquery(rc);
- rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
- myquery(rc);
+ /*
+ We need this loop to ensure correct behavior with both constant and
+ non-constant tables.
+ */
+ for (j= 0; j < 2 ; j++)
+ {
+ rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
+ myquery(rc);
- rc= mysql_real_query(mysql, query, query_end - query);
- myquery(rc);
+ rc= mysql_real_query(mysql, query, query_end - query);
+ myquery(rc);
- result= mysql_use_result(mysql);
- DIE_UNLESS(result);
+ result= mysql_use_result(mysql);
+ DIE_UNLESS(result);
- field_count= mysql_field_count(mysql);
- for (i= 0; i < field_count; ++i)
- {
- field= mysql_fetch_field_direct(result, i);
- printf("%s -> %s ... ", expr[i * 2], field->name);
- fflush(stdout);
- DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 &&
- field->table[0] == 0 && field->org_name[0] == 0);
- DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0);
- puts("OK");
- }
+ field_count= mysql_field_count(mysql);
+ for (i= 0; i < field_count; ++i)
+ {
+ field= mysql_fetch_field_direct(result, i);
+ printf("%s -> %s ... ", expr[i * 2], field->name);
+ fflush(stdout);
+ DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 &&
+ field->table[0] == 0 && field->org_name[0] == 0);
+ DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0);
+ puts("OK");
+ }
- mysql_free_result(result);
+ mysql_free_result(result);
+ }
rc= mysql_query(mysql, "DROP TABLE t1");
myquery(rc);