~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
17
#ifdef __WIN__
18
#include <windows.h>
19
#endif
20
#include <stdio.h>
21
#include <stdlib.h>
22
#include "mysql.h"
23
24
#define SELECT_QUERY "select name from test where num = %d"
25
26
27
int main(int argc, char **argv)
28
{
29
  int	count, num;
30
  MYSQL mysql,*sock;
31
  MYSQL_RES *res;
32
  char	qbuf[160];
33
34
  if (argc != 3)
35
  {
36
    fprintf(stderr,"usage : select_test <dbname> <num>\n\n");
37
    exit(1);
38
  }
39
40
  mysql_init(&mysql);
41
  if (!(sock = mysql_real_connect(&mysql,NULL,0,0,argv[1],0,NULL,0)))
42
  {
43
    fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql));
44
    perror("");
45
    exit(1);
46
  }
47
  mysql.reconnect= 1;
48
49
  count = 0;
50
  num = atoi(argv[2]);
51
  while (count < num)
52
  {
53
    sprintf(qbuf,SELECT_QUERY,count);
54
    if(!(res=mysql_list_dbs(sock,NULL)))
55
    {
56
      fprintf(stderr,"Query failed (%s)\n",mysql_error(sock));
57
      exit(1);
58
    }
59
    printf("number of fields: %d\n",mysql_num_rows(res));
60
    mysql_free_result(res);
61
    count++;
62
  }
63
  mysql_close(sock);
64
  exit(0);
65
  return 0;					/* Keep some compilers happy */
66
}