diff options
author | bell@sanja.is.com.ua <> | 2004-04-09 10:30:07 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2004-04-09 10:30:07 +0300 |
commit | 0d773f29de0990495474d96d36bf8ebafa816a53 (patch) | |
tree | a9203375accfa297578d8d78df03eee40507d959 /tests | |
parent | 555eb86616dbe7efb9481a7ad28c002b71fdf343 (diff) | |
download | mariadb-git-0d773f29de0990495474d96d36bf8ebafa816a53.tar.gz |
complex join example for test suite
Diffstat (limited to 'tests')
-rw-r--r-- | tests/client_test.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/client_test.c b/tests/client_test.c index 8de0767e5e3..6e8fcca1053 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -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 */ @@ -9220,6 +9272,7 @@ int main(int argc, char **argv) test_insert_select(); /* test INSERT ... SELECT */ test_bind_nagative(); /* bind negative to unsigned BUG#3223 */ test_derived(); /* derived table with parameter BUG#3020 */ + test_xjoin(); /* complex join test */ end_time= time((time_t *)0); total_time+= difftime(end_time, start_time); |