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