summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.intranet>2006-11-22 14:17:24 +0300
committerunknown <kroki/tomash@moonlight.intranet>2006-11-22 14:17:24 +0300
commit74dff152265ecd0ae03c638702d7b98908829ede (patch)
treee83722126a82cd3fb65f0f672c85186862d6d462 /tests
parent413e0f0b2a9fe41c8e4dc8ea0308ce7ca42414b1 (diff)
parent5af294b9aa250f393fea101ba3534b27ab8b9dd7 (diff)
downloadmariadb-git-74dff152265ecd0ae03c638702d7b98908829ede.tar.gz
Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0
into moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug21635 tests/mysql_client_test.c: Manual merge.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 4f552af772f..473a3f1f6c2 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -15385,6 +15385,73 @@ static void test_bug23383()
/*
+ BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for
+ expression cols
+
+ Check that for MIN(), MAX(), COUNT() only MYSQL_FIELD::name is set
+ to either expression or its alias, and db, org_table, table,
+ org_name fields are empty strings.
+*/
+static void test_bug21635()
+{
+ const char *expr[]=
+ {
+ "MIN(i)", "MIN(i)",
+ "MIN(i) AS A1", "A1",
+ "MAX(i)", "MAX(i)",
+ "MAX(i) AS A2", "A2",
+ "COUNT(i)", "COUNT(i)",
+ "COUNT(i) AS A3", "A3",
+ };
+ const char *query_end;
+ MYSQL_RES *result;
+ MYSQL_FIELD *field;
+ unsigned int field_count, i;
+ int rc;
+
+ DBUG_ENTER("test_bug21635");
+ myheader("test_bug21635");
+
+ query_end= strxmov(query, "SELECT ", NullS);
+ for (i= 0; i < sizeof(expr) / sizeof(*expr) / 2; ++i)
+ query_end= strxmov(query_end, expr[i * 2], ", ", NullS);
+ query_end= strxmov(query_end - 2, " FROM t1 GROUP BY i", NullS);
+ DIE_UNLESS(query_end - query < MAX_TEST_QUERY_LENGTH);
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)");
+ myquery(rc);
+ rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
+ myquery(rc);
+
+ rc= mysql_real_query(mysql, query, query_end - query);
+ myquery(rc);
+
+ 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");
+ }
+
+ mysql_free_result(result);
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+
+ DBUG_VOID_RETURN;
+}
+
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -15661,6 +15728,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug21206", test_bug21206 },
{ "test_bug21726", test_bug21726 },
{ "test_bug23383", test_bug23383 },
+ { "test_bug21635", test_bug21635 },
{ 0, 0 }
};