45
45
int main(int argc, char *argv[])
47
47
const char *query= "SELECT table_schema,table_name FROM tables";
50
std::vector<drizzle_con_st *> cons;
51
std::vector<drizzle_result_st *> result;
52
std::vector<drizzle_query_st *> ql;
54
if ((drizzle= drizzle_create()) == NULL)
50
drizzle_result_st *result;
56
con= (drizzle_con_st*)malloc(sizeof(drizzle_con_st) * SIMPLE_MULTI_COUNT);
57
result= (drizzle_result_st*)malloc(sizeof(drizzle_result_st) * SIMPLE_MULTI_COUNT);
58
ql= (drizzle_query_st*)malloc(sizeof(drizzle_query_st) * SIMPLE_MULTI_COUNT);
60
if (drizzle_create(&drizzle) == NULL)
56
fprintf(stderr, "drizzle_create:NULL\n");
62
printf("drizzle_create:NULL\n");
60
66
/* Create SIMPLE_MULTI_COUNT connections and initialize query list. */
61
for (int x= 0; x < SIMPLE_MULTI_COUNT; x++)
67
for (x= 0; x < SIMPLE_MULTI_COUNT; x++)
66
if ((con= drizzle_con_create(drizzle)) == NULL)
71
if (drizzle_con_create(&drizzle, &(con[0])) == NULL)
68
printf("drizzle_con_create:%s\n", drizzle_error(drizzle));
73
printf("drizzle_con_create:%s\n", drizzle_error(&drizzle));
72
77
if (argc == 2 && !strcmp(argv[1], "-m"))
74
drizzle_con_add_options(con, DRIZZLE_CON_MYSQL);
78
drizzle_con_add_options(&(con[0]), DRIZZLE_CON_MYSQL);
76
79
else if (argc != 1)
78
81
printf("usage: %s [-m]\n", argv[0]);
82
drizzle_con_set_db(con, "information_schema");
85
drizzle_con_set_db(&(con[0]), "information_schema");
87
if ((con= drizzle_con_clone(drizzle, cons[0])) == NULL)
89
if (drizzle_con_clone(&drizzle, &(con[x]), &(con[0])) == NULL)
89
fprintf(stderr, "drizzle_con_clone:%s\n", drizzle_error(drizzle));
91
printf("drizzle_con_clone:%s\n", drizzle_error(&drizzle));
95
drizzle_result_st *res= drizzle_result_create(con);
96
result.push_back(res);
98
drizzle_query_st *exec_query;
99
if ((exec_query= drizzle_query_add(drizzle, NULL, con, res, query, strlen(query), DRIZZLE_QUERY_NONE, NULL)) == NULL)
96
if (drizzle_query_add(&drizzle, &(ql[x]), &(con[x]), &(result[x]), query,
97
strlen(query), DRIZZLE_QUERY_NONE, NULL) == NULL)
101
fprintf(stderr, "drizzle_query_add:%s\n", drizzle_error(drizzle));
99
printf("drizzle_query_add:%s\n", drizzle_error(&drizzle));
104
ql.push_back(exec_query);
107
drizzle_return_t ret= drizzle_query_run_all(drizzle);
104
ret= drizzle_query_run_all(&drizzle);
108
105
if (ret != DRIZZLE_RETURN_OK)
110
printf("drizzle_query_run_all:%s\n", drizzle_error(drizzle));
107
printf("drizzle_query_run_all:%s\n", drizzle_error(&drizzle));
115
for (std::vector<drizzle_result_st *>::iterator iter= result.begin(); iter != result.end(); iter++)
111
for (x= 0; x < SIMPLE_MULTI_COUNT; x++)
117
if (drizzle_result_error_code(*iter) != 0)
113
if (drizzle_result_error_code(&(result[x])) != 0)
119
printf("%d:%s\n", drizzle_result_error_code(*iter),
120
drizzle_result_error(*iter));
115
printf("%d:%s\n", drizzle_result_error_code(&(result[x])),
116
drizzle_result_error(&(result[x])));
125
while ((row= drizzle_row_next(*iter)) != NULL)
127
printf("%x %s:%s\n", x, row[0], row[1]);
120
while ((row= drizzle_row_next(&(result[x]))) != NULL)
121
printf("%d %s:%s\n", x, row[0], row[1]);
132
drizzle_free(drizzle);
124
drizzle_free(&drizzle);