Commit c3d172a6 authored by unknown's avatar unknown

complex join example for test suite

parent 38f6c83e
...@@ -8952,6 +8952,58 @@ TYPE=InnoDB DEFAULT CHARSET=utf8"); ...@@ -8952,6 +8952,58 @@ TYPE=InnoDB DEFAULT CHARSET=utf8");
} }
static void test_xjoin()
{
MYSQL_STMT *stmt;
int rc, i;
const char *query=
"select t.id,p1.value, n1.value, p2.value, n2.value from t3 t LEFT JOIN t1 p1 ON (p1.id=t.param1_id) LEFT JOIN t2 p2 ON (p2.id=t.param2_id) LEFT JOIN t4 n1 ON (n1.id=p1.name_id) LEFT JOIN t4 n2 ON (n2.id=p2.name_id) where t.id=1";
myheader("test_xjoin");
rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2,t3,t4");
myquery(rc);
rc= mysql_query(mysql,"create table t3 (id int(8), param1_id int(8), param2_id int(8)) TYPE=InnoDB DEFAULT CHARSET=utf8");
myquery(rc);
rc= mysql_query(mysql,"create table t1 ( id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8");
myquery(rc);
rc= mysql_query(mysql,"create table t2 (id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8;");
myquery(rc);
rc= mysql_query(mysql,"create table t4(id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8");
myquery(rc);
rc= mysql_query(mysql, "insert into t3 values (1,1,1),(2,2,null)");
myquery(rc);
rc= mysql_query(mysql, "insert into t1 values (1,1,'aaa'),(2,null,'bbb')");
myquery(rc);
rc= mysql_query(mysql,"insert into t2 values (1,2,'ccc')");
myquery(rc);
rc= mysql_query(mysql, "insert into t4 values (1,'Name1'),(2,null)");
myquery(rc);
stmt= mysql_prepare(mysql, query, strlen(query));
mystmt_init(stmt);
for (i= 0; i < 3; i++)
{
rc= mysql_execute(stmt);
mystmt(stmt, rc);
assert(1 == my_process_stmt_result(stmt));
}
mysql_stmt_close(stmt);
rc= mysql_query(mysql, "DROP TABLE t1,t2,t3,t4");
myquery(rc);
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
*/ */
...@@ -9220,6 +9272,7 @@ int main(int argc, char **argv) ...@@ -9220,6 +9272,7 @@ int main(int argc, char **argv)
test_insert_select(); /* test INSERT ... SELECT */ test_insert_select(); /* test INSERT ... SELECT */
test_bind_nagative(); /* bind negative to unsigned BUG#3223 */ test_bind_nagative(); /* bind negative to unsigned BUG#3223 */
test_derived(); /* derived table with parameter BUG#3020 */ test_derived(); /* derived table with parameter BUG#3020 */
test_xjoin(); /* complex join test */
end_time= time((time_t *)0); end_time= time((time_t *)0);
total_time+= difftime(end_time, start_time); total_time+= difftime(end_time, start_time);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment