63 #define CLIENT_ERROR(__function, __ret, __client) { \
64 printf(__function ":%d:%s\n", __ret, \
65 drizzle_error(&((__client)->drizzle))); \
68 int main(
int argc,
char *argv[])
75 int wait_for_connections= 0;
89 while ((c = getopt(argc, argv,
"bB:c:d:h:Hmp:P:u:")) != -1)
98 if (!strcasecmp(optarg,
"none"))
100 else if (!strcasecmp(optarg,
"field"))
102 else if (!strcasecmp(optarg,
"row"))
104 else if (!strcasecmp(optarg,
"all"))
108 printf(
"Invalid buffer level: %s\n", optarg);
134 port= (in_port_t)atoi(optarg);
143 printf(
"\nUsage: %s [options] [query]\n", argv[0]);
144 printf(
"\t-b - Use blocking sockets\n");
145 printf(
"\t-B <level> - Use buffer <level>, options are:\n");
146 printf(
"\t none - Don't buffer anything (default)\n");
147 printf(
"\t field - Only buffer individual fields\n");
148 printf(
"\t row - Only buffer individual rows\n");
149 printf(
"\t all - Buffer entire result\n");
150 printf(
"\t-c <cons> - Create <cons> connections\n");
151 printf(
"\t-d <db> - Use <db> for the connection\n");
152 printf(
"\t-h <host> - Connect to <host>\n");
153 printf(
"\t-H - Print this help menu\n");
154 printf(
"\t-m - Use MySQL protocol\n");
155 printf(
"\t-p <password> - Use <password> for authentication\n");
156 printf(
"\t-P <port> - Connect to <port>\n");
157 printf(
"\t-u <user> - Use <user> for authentication\n");
164 client.
query= argv[optind];
174 printf(
"calloc:%d\n", errno);
182 printf(
"drizzle_create failed\n");
197 host, port, user, password, db,
205 wait_for_connections++;
210 while (wait_for_connections != 0)
221 wait_for_connections--;
248 switch (client_con->
state)
251 if (client->
query == NULL)
286 &(client_con->
column), &ret);
310 printf(
"Row: %" PRId64
"\n",
319 printf(
" (%zd) %.*s\n", field_sizes[x], (int32_t)field_sizes[x],
336 if (client_con->
row == 0)
347 if (client_con->
row == 0)
353 printf(
"Row: %" PRId64
"\n", client_con->
row);
381 printf(
"%.*s", (int32_t)length, field);
383 printf(
" (%zd) %.*s", total, (int32_t)length, field);
385 if (offset + length == total)
412 printf(
"Row: %" PRId64
"\n",
421 printf(
" (%zd) %.*s\n", field_sizes[x], (int32_t)field_sizes[x],
444 printf(
"Connected: protocol_version=%u\n"
457 printf(
"Result: row_count=%" PRId64
"\n"
458 " insert_id=%" PRId64
"\n"
459 " warning_count=%u\n"
460 " column_count=%u\n\n",
469 printf(
"Field: catalog=%s\n"