#include <stdio.h>#include <stdlib.h>#include "mysql.h"Include dependency graph for select_test.c:

Go to the source code of this file.
Defines | |
| #define | SELECT_QUERY "select name from test where num = %d" |
Functions | |
| int | main (int argc, char **argv) |
Definition at line 24 of file select_test.c.
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 27 of file select_test.c.
References atoi(), count, exit, mysql, mysql_close(), mysql_error(), mysql_free_result(), mysql_init(), mysql_num_fields(), mysql_query(), mysql_real_connect(), mysql_store_result(), NULL, perror(), st_mysql::reconnect, SELECT_QUERY, and sock.
00028 { 00029 int count, num; 00030 MYSQL mysql,*sock; 00031 MYSQL_RES *res; 00032 char qbuf[160]; 00033 00034 if (argc != 3) 00035 { 00036 fprintf(stderr,"usage : select_test <dbname> <num>\n\n"); 00037 exit(1); 00038 } 00039 00040 mysql_init(&mysql); 00041 if (!(sock = mysql_real_connect(&mysql,NULL,0,0,argv[1],0,NULL,0))) 00042 { 00043 fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); 00044 perror(""); 00045 exit(1); 00046 } 00047 mysql.reconnect= 1; 00048 00049 count = 0; 00050 num = atoi(argv[2]); 00051 while (count < num) 00052 { 00053 sprintf(qbuf,SELECT_QUERY,count); 00054 if(mysql_query(sock,qbuf)) 00055 { 00056 fprintf(stderr,"Query failed (%s)\n",mysql_error(sock)); 00057 exit(1); 00058 } 00059 if (!(res=mysql_store_result(sock))) 00060 { 00061 fprintf(stderr,"Couldn't get result from %s\n", 00062 mysql_error(sock)); 00063 exit(1); 00064 } 00065 #ifdef TEST 00066 printf("number of fields: %d\n",mysql_num_fields(res)); 00067 #endif 00068 mysql_free_result(res); 00069 count++; 00070 } 00071 mysql_close(sock); 00072 exit(0); 00073 return 0; /* Keep some compilers happy */ 00074 }
Here is the call graph for this function:

1.4.7

