~maria-captains/mariadb-native-client/trunk

« back to all changes in this revision

Viewing changes to unittest/libmysql/result.c

  • Committer: Georg Richter
  • Date: 2012-11-26 07:32:41 UTC
  • Revision ID: georg@linux-eozo-20121126073241-ues51lp2vo9td9vd
Added openssl layer support
Imported libmysql unittests
Added simple ssl tests
minor cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 
3
 
 
4
The MySQL Connector/C is licensed under the terms of the GPLv2
 
5
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
 
6
MySQL Connectors. There are special exceptions to the terms and
 
7
conditions of the GPLv2 as it is applied to this software, see the
 
8
FLOSS License Exception
 
9
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
 
10
 
 
11
This program is free software; you can redistribute it and/or modify
 
12
it under the terms of the GNU General Public License as published
 
13
by the Free Software Foundation; version 2 of the License.
 
14
 
 
15
This program is distributed in the hope that it will be useful, but
 
16
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
17
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 
18
for more details.
 
19
 
 
20
You should have received a copy of the GNU General Public License along
 
21
with this program; if not, write to the Free Software Foundation, Inc.,
 
22
51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
23
*/
 
24
/**
 
25
  Some basic tests of the client API.
 
26
*/
 
27
 
 
28
#include "my_test.h"
 
29
 
 
30
static int client_store_result(MYSQL *mysql)
 
31
{
 
32
  MYSQL_RES *result;
 
33
  int       rc, rowcount= 0;
 
34
 
 
35
  rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL UNION SELECT 'bar' FROM DUAL");
 
36
  check_mysql_rc(rc, mysql);
 
37
 
 
38
  /* get the result */
 
39
  result= mysql_store_result(mysql);
 
40
  FAIL_IF(!result, "Invalid result set");
 
41
 
 
42
  /* since we use store result, we should be able execute other api calls */
 
43
  rc= mysql_ping(mysql);
 
44
  FAIL_IF(rc, "mysql_ping failed");
 
45
 
 
46
  while (mysql_fetch_row(result))
 
47
    rowcount++;
 
48
 
 
49
  FAIL_IF(rowcount != 2, "rowcount != 2");
 
50
  
 
51
  mysql_free_result(result);
 
52
 
 
53
  return OK;
 
54
}
 
55
 
 
56
static int client_use_result(MYSQL *mysql)
 
57
{
 
58
  MYSQL_RES *result;
 
59
  int       rc, rowcount= 0;
 
60
 
 
61
  rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL UNION SELECT 'bar' FROM DUAL");
 
62
  check_mysql_rc(rc, mysql);
 
63
 
 
64
  /* get the result */
 
65
  result= mysql_use_result(mysql);
 
66
  FAIL_IF(!result, "Invalid result set");
 
67
 
 
68
  /* since we use use result, we shouldn't be able execute other api calls */
 
69
  rc= mysql_ping(mysql);
 
70
  FAIL_IF(!rc, "Error expected");
 
71
 
 
72
  while (mysql_fetch_row(result))
 
73
    rowcount++;
 
74
 
 
75
  FAIL_IF(rowcount != 2, "rowcount != 2");
 
76
  
 
77
  mysql_free_result(result);
 
78
 
 
79
  return OK;
 
80
}
 
81
 
 
82
static int test_free_result(MYSQL *mysql)
 
83
{
 
84
  MYSQL_STMT *stmt;
 
85
  MYSQL_BIND my_bind[1];
 
86
  char       c2[5];
 
87
  ulong      bl1, l2;
 
88
  int        rc, c1, bc1;
 
89
  char       query[MAX_TEST_QUERY_LENGTH];
 
90
 
 
91
  rc= mysql_query(mysql, "drop table if exists test_free_result");
 
92
  check_mysql_rc(rc, mysql);
 
93
 
 
94
  rc= mysql_query(mysql, "create table test_free_result("
 
95
                         "c1 int primary key auto_increment)");
 
96
  check_mysql_rc(rc, mysql);
 
97
 
 
98
  rc= mysql_query(mysql, "insert into test_free_result values(), (), ()");
 
99
  check_mysql_rc(rc, mysql);
 
100
 
 
101
  strcpy(query, "select * from test_free_result");
 
102
  stmt= mysql_stmt_init(mysql);
 
103
  FAIL_IF(!stmt, mysql_error(mysql));
 
104
  rc= mysql_stmt_prepare(stmt, query, strlen(query));
 
105
  check_stmt_rc(rc, stmt);
 
106
 
 
107
  memset(my_bind, '\0', sizeof(my_bind));
 
108
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
109
  my_bind[0].buffer= (void *)&bc1;
 
110
  my_bind[0].length= &bl1;
 
111
 
 
112
  rc= mysql_stmt_execute(stmt);
 
113
  check_stmt_rc(rc, stmt);
 
114
 
 
115
  rc= mysql_stmt_bind_result(stmt, my_bind);
 
116
  check_stmt_rc(rc, stmt);
 
117
 
 
118
  rc= mysql_stmt_fetch(stmt);
 
119
  check_stmt_rc(rc, stmt);
 
120
 
 
121
  c2[0]= '\0'; l2= 0;
 
122
  my_bind[0].buffer_type= MYSQL_TYPE_STRING;
 
123
  my_bind[0].buffer= (void *)c2;
 
124
  my_bind[0].buffer_length= 7;
 
125
  my_bind[0].is_null= 0;
 
126
  my_bind[0].length= &l2;
 
127
 
 
128
  rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
 
129
  check_stmt_rc(rc, stmt);
 
130
  FAIL_UNLESS(strncmp(c2, "1", 1) == 0, "c2 != '1'");
 
131
  FAIL_UNLESS(l2 == 1, "l2 != 1");
 
132
 
 
133
  rc= mysql_stmt_fetch(stmt);
 
134
  check_stmt_rc(rc, stmt);
 
135
 
 
136
  c1= 0, l2= 0;
 
137
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
138
  my_bind[0].buffer= (void *)&c1;
 
139
  my_bind[0].buffer_length= 0;
 
140
  my_bind[0].is_null= 0;
 
141
  my_bind[0].length= &l2;
 
142
 
 
143
  rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
 
144
  check_stmt_rc(rc, stmt);
 
145
  FAIL_UNLESS(c1 == 2, "c1 != 2");
 
146
  FAIL_UNLESS(l2 == 4, "l2 != 4");
 
147
 
 
148
  rc= mysql_query(mysql, "drop table test_free_result");
 
149
  FAIL_IF(!rc, "Error commands out of sync expected");
 
150
 
 
151
  rc= mysql_stmt_free_result(stmt);
 
152
  check_stmt_rc(rc, stmt);
 
153
 
 
154
  rc= mysql_query(mysql, "drop table test_free_result");
 
155
  check_mysql_rc(rc, mysql);  /* should be successful */
 
156
 
 
157
  mysql_stmt_close(stmt);
 
158
 
 
159
  return OK;
 
160
}
 
161
 
 
162
 
 
163
/* Test mysql_stmt_store_result() */
 
164
 
 
165
static int test_free_store_result(MYSQL *mysql)
 
166
{
 
167
  MYSQL_STMT *stmt;
 
168
  MYSQL_BIND my_bind[1];
 
169
  char       c2[5];
 
170
  ulong      bl1, l2;
 
171
  int        rc, c1, bc1;
 
172
  char       query[MAX_TEST_QUERY_LENGTH];
 
173
 
 
174
  rc= mysql_query(mysql, "drop table if exists test_free_result");
 
175
  check_mysql_rc(rc, mysql);
 
176
 
 
177
  rc= mysql_query(mysql, "create table test_free_result(c1 int primary key auto_increment)");
 
178
  check_mysql_rc(rc, mysql);
 
179
 
 
180
  rc= mysql_query(mysql, "insert into test_free_result values(), (), ()");
 
181
  check_mysql_rc(rc, mysql);
 
182
 
 
183
  strcpy(query, "select * from test_free_result");
 
184
  stmt= mysql_stmt_init(mysql);
 
185
  FAIL_IF(!stmt, mysql_error(mysql));
 
186
  rc= mysql_stmt_prepare(stmt, query, strlen(query));
 
187
  check_stmt_rc(rc, stmt);
 
188
 
 
189
  memset(my_bind, '\0', sizeof(my_bind));
 
190
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
191
  my_bind[0].buffer= (void *)&bc1;
 
192
  my_bind[0].buffer_length= 0;
 
193
  my_bind[0].is_null= 0;
 
194
  my_bind[0].length= &bl1;
 
195
 
 
196
  rc= mysql_stmt_execute(stmt);
 
197
  check_stmt_rc(rc, stmt);
 
198
 
 
199
  rc= mysql_stmt_bind_result(stmt, my_bind);
 
200
  check_stmt_rc(rc, stmt);
 
201
 
 
202
  rc= mysql_stmt_store_result(stmt);
 
203
  check_stmt_rc(rc, stmt);
 
204
 
 
205
  rc= mysql_stmt_fetch(stmt);
 
206
  check_stmt_rc(rc, stmt);
 
207
 
 
208
  c2[0]= '\0'; l2= 0;
 
209
  my_bind[0].buffer_type= MYSQL_TYPE_STRING;
 
210
  my_bind[0].buffer= (void *)c2;
 
211
  my_bind[0].buffer_length= 7;
 
212
  my_bind[0].is_null= 0;
 
213
  my_bind[0].length= &l2;
 
214
 
 
215
  rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
 
216
  check_stmt_rc(rc, stmt);
 
217
  FAIL_UNLESS(strncmp(c2, "1", 1) == 0, "c2 != '1'");
 
218
  FAIL_UNLESS(l2 == 1, "l2 != 1");
 
219
 
 
220
  rc= mysql_stmt_fetch(stmt);
 
221
  check_stmt_rc(rc, stmt);
 
222
 
 
223
  c1= 0, l2= 0;
 
224
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
225
  my_bind[0].buffer= (void *)&c1;
 
226
  my_bind[0].buffer_length= 0;
 
227
  my_bind[0].is_null= 0;
 
228
  my_bind[0].length= &l2;
 
229
 
 
230
  rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
 
231
  check_stmt_rc(rc, stmt);
 
232
  FAIL_UNLESS(c1 == 2, "c1 != 2");
 
233
  FAIL_UNLESS(l2 == 4, "l2 != 4");
 
234
 
 
235
  rc= mysql_stmt_free_result(stmt);
 
236
  check_stmt_rc(rc, stmt);
 
237
 
 
238
  rc= mysql_query(mysql, "drop table test_free_result");
 
239
  check_mysql_rc(rc, mysql);
 
240
 
 
241
  mysql_stmt_close(stmt);
 
242
 
 
243
  return OK;
 
244
}
 
245
 
 
246
static int test_store_result(MYSQL *mysql)
 
247
{
 
248
  MYSQL_STMT *stmt;
 
249
  int        rc;
 
250
  int32      nData;
 
251
  char       szData[100];
 
252
  MYSQL_BIND my_bind[2];
 
253
  ulong      length, length1;
 
254
  my_bool    is_null[2];
 
255
  char       query[MAX_TEST_QUERY_LENGTH];
 
256
 
 
257
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
 
258
  check_mysql_rc(rc, mysql);
 
259
 
 
260
  rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
 
261
  check_mysql_rc(rc, mysql);
 
262
 
 
263
  rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
 
264
  check_mysql_rc(rc, mysql);
 
265
 
 
266
  rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')");
 
267
  check_mysql_rc(rc, mysql);
 
268
 
 
269
  rc= mysql_commit(mysql);
 
270
  check_mysql_rc(rc, mysql);
 
271
 
 
272
  /* fetch */
 
273
  memset(my_bind, '\0', sizeof(my_bind));
 
274
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
275
  my_bind[0].buffer= (void *) &nData;       /* integer data */
 
276
  my_bind[0].length= &length;
 
277
  my_bind[0].is_null= &is_null[0];
 
278
 
 
279
  length= 0;
 
280
  my_bind[1].buffer_type= MYSQL_TYPE_STRING;
 
281
  my_bind[1].buffer= szData;                /* string data */
 
282
  my_bind[1].buffer_length= sizeof(szData);
 
283
  my_bind[1].length= &length1;
 
284
  my_bind[1].is_null= &is_null[1];
 
285
  length1= 0;
 
286
 
 
287
  strcpy(query, "SELECT * FROM test_store_result");
 
288
  stmt= mysql_stmt_init(mysql);
 
289
  FAIL_IF(!stmt, mysql_error(mysql));
 
290
  rc= mysql_stmt_prepare(stmt, query, strlen(query));
 
291
  check_stmt_rc(rc, stmt);
 
292
 
 
293
  rc= mysql_stmt_bind_result(stmt, my_bind);
 
294
  check_stmt_rc(rc, stmt);
 
295
 
 
296
  rc= mysql_stmt_execute(stmt);
 
297
  check_stmt_rc(rc, stmt);
 
298
 
 
299
  rc= mysql_stmt_store_result(stmt);
 
300
  check_stmt_rc(rc, stmt);
 
301
 
 
302
  rc= mysql_stmt_fetch(stmt);
 
303
  check_stmt_rc(rc, stmt);
 
304
 
 
305
  FAIL_UNLESS(nData == 10, "nData != 10");
 
306
  FAIL_UNLESS(strcmp(szData, "venu") == 0, "szData != 'Venu'");
 
307
  FAIL_UNLESS(length1 == 4, "length1 != 4");
 
308
 
 
309
  rc= mysql_stmt_fetch(stmt);
 
310
  check_stmt_rc(rc, stmt);
 
311
 
 
312
  FAIL_UNLESS(nData == 20, "nData != 20");
 
313
  FAIL_UNLESS(strcmp(szData, "mysql") == 0, "szDaza != 'mysql'");
 
314
  FAIL_UNLESS(length1 == 5, "length1 != 5");
 
315
 
 
316
  length= 99;
 
317
  rc= mysql_stmt_fetch(stmt);
 
318
  check_stmt_rc(rc, stmt);
 
319
 
 
320
  FAIL_UNLESS(is_null[0], "isnull set");
 
321
  FAIL_UNLESS(strcmp(szData, "monty") == 0, "szData != 'monty'");
 
322
  FAIL_UNLESS(length1 == 5, "length1 != 5");
 
323
 
 
324
  rc= mysql_stmt_fetch(stmt);
 
325
  FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
 
326
 
 
327
  rc= mysql_stmt_execute(stmt);
 
328
  check_stmt_rc(rc, stmt);
 
329
 
 
330
  rc= mysql_stmt_store_result(stmt);
 
331
  check_stmt_rc(rc, stmt);
 
332
 
 
333
  rc= mysql_stmt_fetch(stmt);
 
334
  check_stmt_rc(rc, stmt);
 
335
 
 
336
  FAIL_UNLESS(nData == 10, "nData != 10");
 
337
  FAIL_UNLESS(strcmp(szData, "venu") == 0, "szData != 'Venu'");
 
338
  FAIL_UNLESS(length1 == 4, "length1 != 4");
 
339
 
 
340
  rc= mysql_stmt_fetch(stmt);
 
341
  check_stmt_rc(rc, stmt);
 
342
 
 
343
  FAIL_UNLESS(nData == 20, "nData != 20");
 
344
  FAIL_UNLESS(strcmp(szData, "mysql") == 0, "szDaza != 'mysql'");
 
345
  FAIL_UNLESS(length1 == 5, "length1 != 5");
 
346
 
 
347
  length= 99;
 
348
  rc= mysql_stmt_fetch(stmt);
 
349
  check_stmt_rc(rc, stmt);
 
350
 
 
351
  FAIL_UNLESS(is_null[0], "isnull set");
 
352
  FAIL_UNLESS(strcmp(szData, "monty") == 0, "szData != 'monty'");
 
353
  FAIL_UNLESS(length1 == 5, "length1 != 5");
 
354
 
 
355
  rc= mysql_stmt_fetch(stmt);
 
356
  FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
 
357
 
 
358
  mysql_stmt_close(stmt);
 
359
 
 
360
  return OK;
 
361
}
 
362
 
 
363
 
 
364
/* Test simple bind store result */
 
365
 
 
366
static int test_store_result1(MYSQL *mysql)
 
367
{
 
368
  MYSQL_STMT *stmt;
 
369
  int        rc;
 
370
  char       query[MAX_TEST_QUERY_LENGTH];
 
371
 
 
372
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
 
373
  check_mysql_rc(rc, mysql);
 
374
 
 
375
  rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
 
376
  check_mysql_rc(rc, mysql);
 
377
 
 
378
  rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
 
379
  check_mysql_rc(rc, mysql);
 
380
 
 
381
  rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')");
 
382
  check_mysql_rc(rc, mysql);
 
383
 
 
384
  rc= mysql_commit(mysql);
 
385
  check_mysql_rc(rc, mysql);
 
386
 
 
387
  strcpy(query, "SELECT * FROM test_store_result");
 
388
  stmt= mysql_stmt_init(mysql);
 
389
  FAIL_IF(!stmt, mysql_error(mysql));
 
390
  rc= mysql_stmt_prepare(stmt, query, strlen(query));
 
391
  check_stmt_rc(rc, stmt);
 
392
 
 
393
  rc= mysql_stmt_execute(stmt);
 
394
  check_stmt_rc(rc, stmt);
 
395
 
 
396
  rc= mysql_stmt_store_result(stmt);
 
397
  check_stmt_rc(rc, stmt);
 
398
 
 
399
  rc= 0;
 
400
  while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
 
401
    rc++;
 
402
  FAIL_UNLESS(rc == 3, "rowcount != 3");
 
403
 
 
404
  rc= mysql_stmt_execute(stmt);
 
405
  check_stmt_rc(rc, stmt);
 
406
 
 
407
  rc= mysql_stmt_store_result(stmt);
 
408
  check_stmt_rc(rc, stmt);
 
409
 
 
410
  rc= 0;
 
411
  while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
 
412
    rc++;
 
413
  FAIL_UNLESS(rc == 3, "rowcount != 3");
 
414
 
 
415
  mysql_stmt_close(stmt);
 
416
 
 
417
  return OK;
 
418
}
 
419
 
 
420
 
 
421
/* Another test for bind and store result */
 
422
 
 
423
static int test_store_result2(MYSQL *mysql)
 
424
{
 
425
  MYSQL_STMT *stmt;
 
426
  int        rc;
 
427
  int        nData;
 
428
  ulong      length;
 
429
  MYSQL_BIND my_bind[1];
 
430
  char query[MAX_TEST_QUERY_LENGTH];
 
431
 
 
432
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
 
433
  check_mysql_rc(rc, mysql);
 
434
 
 
435
  rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
 
436
  check_mysql_rc(rc, mysql);
 
437
 
 
438
  rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
 
439
  check_mysql_rc(rc, mysql);
 
440
 
 
441
  rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')");
 
442
  check_mysql_rc(rc, mysql);
 
443
 
 
444
  rc= mysql_commit(mysql);
 
445
  check_mysql_rc(rc, mysql);
 
446
 
 
447
  memset(my_bind, '\0', sizeof(my_bind));
 
448
 
 
449
  my_bind[0].buffer_type= MYSQL_TYPE_LONG;
 
450
  my_bind[0].buffer= (void *) &nData;      /* integer data */
 
451
  my_bind[0].length= &length;
 
452
  my_bind[0].is_null= 0;
 
453
 
 
454
  strcpy((char *)query , "SELECT col1 FROM test_store_result where col1= ?");
 
455
  stmt= mysql_stmt_init(mysql);
 
456
  FAIL_IF(!stmt, mysql_error(mysql));
 
457
  rc= mysql_stmt_prepare(stmt, query, strlen(query));
 
458
  check_stmt_rc(rc, stmt);
 
459
 
 
460
  rc= mysql_stmt_bind_param(stmt, my_bind);
 
461
  check_stmt_rc(rc, stmt);
 
462
 
 
463
  rc= mysql_stmt_bind_result(stmt, my_bind);
 
464
  check_stmt_rc(rc, stmt);
 
465
 
 
466
  nData= 10; length= 0;
 
467
  rc= mysql_stmt_execute(stmt);
 
468
  check_stmt_rc(rc, stmt);
 
469
 
 
470
  nData= 0;
 
471
  rc= mysql_stmt_store_result(stmt);
 
472
  check_stmt_rc(rc, stmt);
 
473
 
 
474
  rc= mysql_stmt_fetch(stmt);
 
475
  check_stmt_rc(rc, stmt);
 
476
 
 
477
  FAIL_UNLESS(nData == 10, "nData != 10");
 
478
 
 
479
  rc= mysql_stmt_fetch(stmt);
 
480
  FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
 
481
 
 
482
  nData= 20;
 
483
  rc= mysql_stmt_execute(stmt);
 
484
  check_stmt_rc(rc, stmt);
 
485
 
 
486
  nData= 0;
 
487
  rc= mysql_stmt_store_result(stmt);
 
488
  check_stmt_rc(rc, stmt);
 
489
 
 
490
  rc= mysql_stmt_fetch(stmt);
 
491
  check_stmt_rc(rc, stmt);
 
492
 
 
493
  FAIL_UNLESS(nData == 20, "nData != 20");
 
494
 
 
495
  rc= mysql_stmt_fetch(stmt);
 
496
  FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
 
497
  mysql_stmt_close(stmt);
 
498
 
 
499
  return OK;
 
500
}
 
501
 
 
502
static int test_bug11718(MYSQL *mysql)
 
503
{
 
504
  MYSQL_RES     *res;
 
505
  int rc;
 
506
  const char *query= "select str_to_date(concat(f3),'%Y%m%d') from t1,t2 "
 
507
                     "where f1=f2 order by f1";
 
508
 
 
509
  rc= mysql_query(mysql, "drop table if exists t1, t2");
 
510
  check_mysql_rc(rc, mysql);
 
511
  rc= mysql_query(mysql, "create table t1 (f1 int)");
 
512
  check_mysql_rc(rc, mysql);
 
513
  rc= mysql_query(mysql, "create table t2 (f2 int, f3 numeric(8))");
 
514
  check_mysql_rc(rc, mysql);
 
515
  rc= mysql_query(mysql, "insert into t1 values (1), (2)");
 
516
  check_mysql_rc(rc, mysql);
 
517
  rc= mysql_query(mysql, "insert into t2 values (1,20050101), (2,20050202)");
 
518
  check_mysql_rc(rc, mysql);
 
519
  rc= mysql_query(mysql, query);
 
520
  check_mysql_rc(rc, mysql);
 
521
  res = mysql_store_result(mysql);
 
522
 
 
523
  FAIL_UNLESS(res->fields[0].type == MYSQL_TYPE_DATE, "type != MYSQL_TYPE_DATE");
 
524
  mysql_free_result(res);
 
525
  rc= mysql_query(mysql, "drop table t1, t2");
 
526
  check_mysql_rc(rc, mysql);
 
527
 
 
528
  return OK;
 
529
}
 
530
 
 
531
static int test_bug19671(MYSQL *mysql)
 
532
{
 
533
  MYSQL_RES *result;
 
534
  int rc;
 
535
 
 
536
  mysql_query(mysql, "set sql_mode=''");
 
537
  rc= mysql_query(mysql, "drop table if exists t1");
 
538
  check_mysql_rc(rc, mysql)
 
539
 
 
540
  rc= mysql_query(mysql, "drop view if exists v1");
 
541
  check_mysql_rc(rc, mysql)
 
542
 
 
543
  rc= mysql_query(mysql, "create table t1(f1 int)");
 
544
  check_mysql_rc(rc, mysql)
 
545
 
 
546
  rc= mysql_query(mysql, "create view v1 as select va.* from t1 va");
 
547
  check_mysql_rc(rc, mysql)
 
548
 
 
549
  result= mysql_list_fields(mysql, "v1", NULL);
 
550
  FAIL_IF(!result, "Invalid result set");
 
551
 
 
552
  rc= 0;
 
553
  while (mysql_fetch_row(result))
 
554
    rc++;
 
555
  FAIL_UNLESS(rc == 0, "");
 
556
 
 
557
  if (verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG,
 
558
                       "v1", "v1", schema, 11, "0")) {
 
559
    mysql_free_result(result);
 
560
    diag("verify_prepare_field failed");
 
561
    return FAIL;
 
562
  }
 
563
 
 
564
  mysql_free_result(result);
 
565
  check_mysql_rc(mysql_query(mysql, "drop view v1"), mysql)
 
566
  check_mysql_rc(mysql_query(mysql, "drop table t1"), mysql)
 
567
  return OK;
 
568
}
 
569
 
 
570
/*
 
571
  Bug#21726: Incorrect result with multiple invocations of
 
572
  LAST_INSERT_ID
 
573
 
 
574
  Test that client gets updated value of insert_id on UPDATE that uses
 
575
  LAST_INSERT_ID(expr).
 
576
  select_query added to test for bug
 
577
    #26921 Problem in mysql_insert_id() Embedded C API function
 
578
*/
 
579
static int test_bug21726(MYSQL *mysql)
 
580
{
 
581
  const char *create_table[]=
 
582
  {
 
583
    "DROP TABLE IF EXISTS t1",
 
584
    "CREATE TABLE t1 (i INT)",
 
585
    "INSERT INTO t1 VALUES (1)",
 
586
  };
 
587
  const char *update_query= "UPDATE t1 SET i= LAST_INSERT_ID(i + 1)";
 
588
  int rc;
 
589
  my_ulonglong insert_id;
 
590
  const char *select_query= "SELECT * FROM t1";
 
591
  MYSQL_RES  *result;
 
592
 
 
593
  rc= mysql_query(mysql, create_table[0]);
 
594
  check_mysql_rc(rc, mysql);
 
595
  rc= mysql_query(mysql, create_table[1]);
 
596
  check_mysql_rc(rc, mysql);
 
597
  rc= mysql_query(mysql, create_table[2]);
 
598
  check_mysql_rc(rc, mysql);
 
599
 
 
600
  rc= mysql_query(mysql, update_query);
 
601
  check_mysql_rc(rc, mysql)
 
602
  insert_id= mysql_insert_id(mysql);
 
603
  FAIL_UNLESS(insert_id == 2, "insert_id != 2");
 
604
 
 
605
  rc= mysql_query(mysql, update_query);
 
606
  check_mysql_rc(rc, mysql)
 
607
  insert_id= mysql_insert_id(mysql);
 
608
  FAIL_UNLESS(insert_id == 3, "insert_id != 3");
 
609
 
 
610
  rc= mysql_query(mysql, select_query);
 
611
  check_mysql_rc(rc, mysql)
 
612
  insert_id= mysql_insert_id(mysql);
 
613
  FAIL_UNLESS(insert_id == 3, "insert_id != 3");
 
614
  result= mysql_store_result(mysql);
 
615
  mysql_free_result(result);
 
616
 
 
617
  return OK;
 
618
}
 
619
 
 
620
/* Bug#6761 - mysql_list_fields doesn't work */
 
621
 
 
622
static int test_bug6761(MYSQL *mysql)
 
623
{
 
624
  const char *stmt_text;
 
625
  MYSQL_RES *res;
 
626
  int rc;
 
627
 
 
628
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
 
629
  check_mysql_rc(rc, mysql);
 
630
 
 
631
  stmt_text= "CREATE TABLE t1 (a int, b char(255), c decimal)";
 
632
  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
 
633
  check_mysql_rc(rc, mysql);
 
634
 
 
635
  res= mysql_list_fields(mysql, "t1", "%");
 
636
  FAIL_UNLESS(res && mysql_num_fields(res) == 3, "num_fields != 3");
 
637
  mysql_free_result(res);
 
638
 
 
639
  stmt_text= "DROP TABLE t1";
 
640
  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
 
641
  check_mysql_rc(rc, mysql);
 
642
  return OK;
 
643
}
 
644
 
 
645
/* Test field flags (verify .NET provider) */
 
646
 
 
647
static int test_field_flags(MYSQL *mysql)
 
648
{
 
649
  int          rc;
 
650
  MYSQL_RES    *result;
 
651
  MYSQL_FIELD  *field;
 
652
 
 
653
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_flags");
 
654
  check_mysql_rc(rc, mysql);
 
655
 
 
656
  rc= mysql_query(mysql, "CREATE TABLE test_field_flags(id int NOT NULL AUTO_INCREMENT PRIMARY KEY, \
 
657
                                                        id1 int NOT NULL, \
 
658
                                                        id2 int UNIQUE, \
 
659
                                                        id3 int, \
 
660
                                                        id4 int NOT NULL, \
 
661
                                                        id5 int, \
 
662
                                                        KEY(id3, id4))");
 
663
  check_mysql_rc(rc, mysql);
 
664
 
 
665
  /* with table name included with TRUE column name */
 
666
  rc= mysql_query(mysql, "SELECT * FROM test_field_flags");
 
667
  check_mysql_rc(rc, mysql);
 
668
 
 
669
  result= mysql_use_result(mysql);
 
670
  FAIL_IF(!result, "Invalid result set");
 
671
 
 
672
  mysql_field_seek(result, 0);
 
673
 
 
674
  field= mysql_fetch_field(result);
 
675
  FAIL_UNLESS(field->flags & NOT_NULL_FLAG && 
 
676
              field->flags & PRI_KEY_FLAG &&
 
677
              field->flags & AUTO_INCREMENT_FLAG, "Wrong flags for field 0");
 
678
 
 
679
  field= mysql_fetch_field(result);
 
680
  FAIL_UNLESS(field->flags & NOT_NULL_FLAG, "Wrong flags for field 1");
 
681
 
 
682
  field= mysql_fetch_field(result);
 
683
  FAIL_UNLESS(field->flags & UNIQUE_KEY_FLAG, "Wrong flags for field 2");
 
684
 
 
685
  field= mysql_fetch_field(result);
 
686
  FAIL_UNLESS(field->flags & MULTIPLE_KEY_FLAG, "Wrong flags for field 3");
 
687
 
 
688
  field= mysql_fetch_field(result);
 
689
  FAIL_UNLESS(field->flags & NOT_NULL_FLAG, "Wrong flags for field 4");
 
690
 
 
691
  mysql_free_result(result);
 
692
  return OK;
 
693
}
 
694
 
 
695
/* Test real and alias names */
 
696
 
 
697
static int test_field_names(MYSQL *mysql)
 
698
{
 
699
  int        rc;
 
700
  MYSQL_RES  *result;
 
701
 
 
702
 
 
703
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names1");
 
704
  check_mysql_rc(rc, mysql);
 
705
 
 
706
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names2");
 
707
  check_mysql_rc(rc, mysql);
 
708
 
 
709
  rc= mysql_query(mysql, "CREATE TABLE test_field_names1(id int, name varchar(50))");
 
710
  check_mysql_rc(rc, mysql);
 
711
 
 
712
  rc= mysql_query(mysql, "CREATE TABLE test_field_names2(id int, name varchar(50))");
 
713
  check_mysql_rc(rc, mysql);
 
714
 
 
715
  /* with table name included with TRUE column name */
 
716
  rc= mysql_query(mysql, "SELECT id as 'id-alias' FROM test_field_names1");
 
717
  check_mysql_rc(rc, mysql);
 
718
 
 
719
  result= mysql_use_result(mysql);
 
720
  FAIL_IF(!result, "Invalid result set");
 
721
 
 
722
  rc= 0;
 
723
  while (mysql_fetch_row(result))
 
724
    rc++;
 
725
  FAIL_UNLESS(rc == 0, "rowcount != 0");
 
726
  mysql_free_result(result);
 
727
 
 
728
  /* with table name included with TRUE column name */
 
729
  rc= mysql_query(mysql, "SELECT t1.id as 'id-alias', test_field_names2.name FROM test_field_names1 t1, test_field_names2");
 
730
  check_mysql_rc(rc, mysql);
 
731
 
 
732
  result= mysql_use_result(mysql);
 
733
  FAIL_IF(!result, "Invalid result set");
 
734
 
 
735
  rc= 0;
 
736
  while (mysql_fetch_row(result))
 
737
    rc++;
 
738
  FAIL_UNLESS(rc == 0, "rowcount != 0");
 
739
  mysql_free_result(result);
 
740
  return OK;
 
741
}
 
742
 
 
743
/* Test FUNCTION field info / DATE_FORMAT() table_name . */
 
744
 
 
745
static int test_func_fields(MYSQL *mysql)
 
746
{
 
747
  int        rc;
 
748
  MYSQL_RES  *result;
 
749
  MYSQL_FIELD *field;
 
750
 
 
751
 
 
752
  rc= mysql_autocommit(mysql, TRUE);
 
753
  check_mysql_rc(rc, mysql);
 
754
 
 
755
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_dateformat");
 
756
  check_mysql_rc(rc, mysql);
 
757
 
 
758
  rc= mysql_query(mysql, "CREATE TABLE test_dateformat(id int, \
 
759
                                                       ts timestamp)");
 
760
  check_mysql_rc(rc, mysql);
 
761
 
 
762
  rc= mysql_query(mysql, "INSERT INTO test_dateformat(id) values(10)");
 
763
  check_mysql_rc(rc, mysql);
 
764
 
 
765
  rc= mysql_query(mysql, "SELECT ts FROM test_dateformat");
 
766
  check_mysql_rc(rc, mysql);
 
767
 
 
768
  result= mysql_store_result(mysql);
 
769
  FAIL_IF(!result, "Invalid result set");
 
770
 
 
771
  field= mysql_fetch_field(result);
 
772
  FAIL_IF(!field, "Invalid field");
 
773
  FAIL_UNLESS(strcmp(field->table, "test_dateformat") == 0, "field->table != 'test_dateformat'");
 
774
 
 
775
  field= mysql_fetch_field(result);
 
776
  FAIL_IF(field, "no more fields expected");
 
777
 
 
778
  mysql_free_result(result);
 
779
 
 
780
  /* DATE_FORMAT */
 
781
  rc= mysql_query(mysql, "SELECT DATE_FORMAT(ts, '%Y') AS 'venu' FROM test_dateformat");
 
782
  check_mysql_rc(rc, mysql);
 
783
 
 
784
  result= mysql_store_result(mysql);
 
785
  FAIL_IF(!result, "Invalid result set");
 
786
 
 
787
  field= mysql_fetch_field(result);
 
788
  FAIL_IF(!field, "Invalid field");
 
789
  FAIL_UNLESS(field->table[0] == '\0', "field->table != ''");
 
790
 
 
791
  field= mysql_fetch_field(result);
 
792
  FAIL_IF(field, "no more fields expected");
 
793
 
 
794
  mysql_free_result(result);
 
795
 
 
796
  /* FIELD ALIAS TEST */
 
797
  rc= mysql_query(mysql, "SELECT DATE_FORMAT(ts, '%Y')  AS 'YEAR' FROM test_dateformat");
 
798
  check_mysql_rc(rc, mysql);
 
799
 
 
800
  result= mysql_store_result(mysql);
 
801
  FAIL_IF(!result, "Invalid result set");
 
802
 
 
803
  field= mysql_fetch_field(result);
 
804
  FAIL_IF(!field, "Invalid field");
 
805
  FAIL_UNLESS(strcmp(field->name, "YEAR") == 0, "name != 'YEAR'");
 
806
  FAIL_UNLESS(field->org_name[0] == '\0', "org_name != ''");
 
807
 
 
808
  field= mysql_fetch_field(result);
 
809
  FAIL_IF(field, "no more fields expected");
 
810
 
 
811
  mysql_free_result(result);
 
812
  return OK;
 
813
}
 
814
 
 
815
/* Test mysql_list_fields() */
 
816
 
 
817
static int test_list_fields(MYSQL *mysql)
 
818
{
 
819
  MYSQL_RES *result;
 
820
  int rc;
 
821
 
 
822
  rc= mysql_query(mysql, "drop table if exists t1");
 
823
  check_mysql_rc(rc, mysql);
 
824
 
 
825
  rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10) default 'mysql')");
 
826
  check_mysql_rc(rc, mysql);
 
827
 
 
828
  result= mysql_list_fields(mysql, "t1", NULL);
 
829
  FAIL_IF(!result, "Invalid result set");
 
830
 
 
831
  rc= 0;
 
832
  while (mysql_fetch_row(result))
 
833
    rc++;
 
834
  FAIL_UNLESS(rc == 0, "rowcount != 0");
 
835
 
 
836
  if (verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG,
 
837
                       "t1", "t1",
 
838
                       schema, 11, "0"))
 
839
    goto error;
 
840
 
 
841
  if (verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING,
 
842
                       "t1", "t1",
 
843
                       schema, 10, "mysql"))
 
844
    goto error;
 
845
 
 
846
  mysql_free_result(result);
 
847
  check_mysql_rc(mysql_query(mysql, "drop table t1"), mysql);
 
848
  return OK;
 
849
 
 
850
error:
 
851
  mysql_free_result(result);
 
852
  check_mysql_rc(mysql_query(mysql, "drop table t1"), mysql);
 
853
  return FAIL;
 
854
}
 
855
 
 
856
/* Test correct max length for MEDIUMTEXT and LONGTEXT columns */
 
857
 
 
858
static int test_bug9735(MYSQL *mysql)
 
859
{
 
860
  MYSQL_RES *res;
 
861
  int rc;
 
862
 
 
863
 
 
864
  rc= mysql_query(mysql, "drop table if exists t1");
 
865
  check_mysql_rc(rc, mysql);
 
866
  rc= mysql_query(mysql, "create table t1 (a mediumtext, b longtext) "
 
867
                         "character set latin1");
 
868
  check_mysql_rc(rc, mysql);
 
869
  rc= mysql_query(mysql, "select * from t1");
 
870
  check_mysql_rc(rc, mysql);
 
871
  res= mysql_store_result(mysql);
 
872
  if (verify_prepare_field(res, 0, "a", "a", MYSQL_TYPE_BLOB,
 
873
                       "t1", "t1", schema, (1U << 24)-1, 0)) 
 
874
    goto error;
 
875
  if (verify_prepare_field(res, 1, "b", "b", MYSQL_TYPE_BLOB,
 
876
                       "t1", "t1", schema, ~0U, 0))
 
877
    goto error;
 
878
  mysql_free_result(res);
 
879
  rc= mysql_query(mysql, "drop table t1");
 
880
  check_mysql_rc(rc, mysql);
 
881
  return OK;
 
882
error:
 
883
  mysql_free_result(res);
 
884
  rc= mysql_query(mysql, "drop table t1");
 
885
  return FAIL;
 
886
}
 
887
 
 
888
/*
 
889
  Check that mysql_next_result works properly in case when one of
 
890
  the statements used in a multi-statement query is erroneous
 
891
*/
 
892
 
 
893
static int test_bug9992(MYSQL *mysql)
 
894
{
 
895
  MYSQL_RES* res ;
 
896
  int   rc;
 
897
 
 
898
  /* Sic: SHOW DATABASE is incorrect syntax. */
 
899
  rc= mysql_query(mysql, "SHOW TABLES; SHOW DATABASE; SELECT 1;");
 
900
  check_mysql_rc(rc, mysql);
 
901
  
 
902
  res= mysql_store_result(mysql);
 
903
  FAIL_UNLESS(res, "Invalid resultset");
 
904
  mysql_free_result(res);
 
905
  rc= mysql_next_result(mysql);
 
906
  FAIL_UNLESS(rc == 1, "Error expected");                         /* Got errors, as expected */
 
907
 
 
908
  return OK;
 
909
}
 
910
 
 
911
/* Test the support of multi-statement executions */
 
912
 
 
913
static int test_multi_statements(MYSQL *mysql)
 
914
{
 
915
  MYSQL *mysql_local;
 
916
  MYSQL_RES *result;
 
917
  int    rc;
 
918
 
 
919
  const char *query= "\
 
920
DROP TABLE IF EXISTS test_multi_tab;\
 
921
CREATE TABLE test_multi_tab(id int, name char(20));\
 
922
INSERT INTO test_multi_tab(id) VALUES(10), (20);\
 
923
INSERT INTO test_multi_tab VALUES(20, 'insert;comma');\
 
924
SELECT * FROM test_multi_tab;\
 
925
UPDATE test_multi_tab SET name='new;name' WHERE id=20;\
 
926
DELETE FROM test_multi_tab WHERE name='new;name';\
 
927
SELECT * FROM test_multi_tab;\
 
928
DELETE FROM test_multi_tab WHERE id=10;\
 
929
SELECT * FROM test_multi_tab;\
 
930
DROP TABLE test_multi_tab;\
 
931
select 1;\
 
932
DROP TABLE IF EXISTS test_multi_tab";
 
933
  uint count, exp_value;
 
934
  uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0};
 
935
 
 
936
  /*
 
937
    First test that we get an error for multi statements
 
938
    (Because default connection is not opened with CLIENT_MULTI_STATEMENTS)
 
939
  */
 
940
  mysql_local= mysql;
 
941
  mysql = test_connect(NULL);
 
942
  rc= mysql_query(mysql, query); /* syntax error */
 
943
  FAIL_IF(!rc, "Error expected");
 
944
 
 
945
  rc= mysql_next_result(mysql);
 
946
  FAIL_UNLESS(rc == -1, "rc != -1");
 
947
  rc= mysql_more_results(mysql);
 
948
  FAIL_UNLESS(rc == 0, "rc != 0");
 
949
 
 
950
  mysql_close(mysql);
 
951
  mysql= mysql_local;
 
952
 
 
953
  mysql_local->reconnect= 1;
 
954
 
 
955
  rc= mysql_query(mysql_local, query);
 
956
  check_mysql_rc(rc, mysql);
 
957
 
 
958
  for (count= 0 ; count < array_elements(rows) ; count++)
 
959
  {
 
960
    if ((result= mysql_store_result(mysql_local)))
 
961
    {
 
962
      mysql_free_result(result);
 
963
    }
 
964
 
 
965
    exp_value= (uint) mysql_affected_rows(mysql_local);
 
966
    FAIL_IF(rows[count] !=  exp_value, "row[count] != exp_value");
 
967
    if (count != array_elements(rows) -1)
 
968
    {
 
969
      rc= mysql_more_results(mysql_local);
 
970
      FAIL_IF(!rc, "More results expected");
 
971
      rc= mysql_next_result(mysql_local);
 
972
      check_mysql_rc(rc, mysql_local);
 
973
    }
 
974
    else
 
975
    {
 
976
      rc= mysql_more_results(mysql_local);
 
977
      FAIL_UNLESS(rc == 0, "rc != 0");
 
978
      rc= mysql_next_result(mysql_local);
 
979
      FAIL_UNLESS(rc == -1, "rc != -1");
 
980
    }
 
981
  }
 
982
 
 
983
  /* check that errors abort multi statements */
 
984
 
 
985
  rc= mysql_query(mysql_local, "select 1+1+a;select 1+1");
 
986
  FAIL_IF(!rc, "Error expected");
 
987
  rc= mysql_more_results(mysql_local);
 
988
  FAIL_UNLESS(rc == 0, "rc != 0");
 
989
  rc= mysql_next_result(mysql_local);
 
990
  FAIL_UNLESS(rc == -1, "rc != -1");
 
991
 
 
992
  rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1");
 
993
  check_mysql_rc(rc, mysql);
 
994
  result= mysql_store_result(mysql_local);
 
995
  FAIL_IF(!result, "Invalid result set");
 
996
  mysql_free_result(result);
 
997
  rc= mysql_more_results(mysql_local);
 
998
  FAIL_UNLESS(rc == 1, "rc != 1");
 
999
  rc= mysql_next_result(mysql_local);
 
1000
  FAIL_UNLESS(rc > 0, "rc <= 0");
 
1001
 
 
1002
  /*
 
1003
    Ensure that we can now do a simple query (this checks that the server is
 
1004
    not trying to send us the results for the last 'select 1'
 
1005
  */
 
1006
  rc= mysql_query(mysql_local, "select 1+1+1");
 
1007
  check_mysql_rc(rc, mysql);
 
1008
  result= mysql_store_result(mysql_local);
 
1009
  FAIL_IF(!result, "Invalid result set");
 
1010
  mysql_free_result(result);
 
1011
 
 
1012
  /*
 
1013
    Check if errors in one of the queries handled properly.
 
1014
  */
 
1015
  rc= mysql_query(mysql_local, "select 1; select * from not_existing_table");
 
1016
  check_mysql_rc(rc, mysql);
 
1017
  result= mysql_store_result(mysql_local);
 
1018
  mysql_free_result(result);
 
1019
 
 
1020
  rc= mysql_next_result(mysql_local);
 
1021
  FAIL_UNLESS(rc > 0, "rc <= 0");
 
1022
 
 
1023
  rc= mysql_next_result(mysql_local);
 
1024
  FAIL_UNLESS(rc < 0, "rc >= 0");
 
1025
 
 
1026
  return OK;
 
1027
}
 
1028
 
 
1029
 
 
1030
 
 
1031
struct my_tests_st my_tests[] = {
 
1032
  {"client_store_result", client_store_result, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1033
  {"client_use_result", client_use_result, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1034
  {"test_free_result", test_free_result, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1035
  {"test_free_store_result", test_free_store_result, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1036
  {"test_store_result", test_store_result, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1037
  {"test_store_result1", test_store_result1, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1038
  {"test_store_result2", test_store_result2, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1039
  {"test_bug11718", test_bug11718, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1040
  {"test_bug19671", test_bug19671, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1041
  {"test_bug21726", test_bug21726, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1042
  {"test_bug6761", test_bug6761, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1043
  {"test_field_flags", test_field_flags, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1044
  {"test_field_names", test_field_names, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1045
  {"test_func_fields", test_func_fields, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1046
  {"test_list_fields", test_list_fields, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1047
  {"test_bug9735", test_bug9735, TEST_CONNECTION_DEFAULT, 0,  NULL,  NULL},
 
1048
  {"test_bug9992", test_bug9992, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS,  NULL,  NULL},
 
1049
  {"test_multi_statements", test_multi_statements, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS,  NULL,  NULL},
 
1050
  {NULL, NULL, 0, 0, NULL, NULL}
 
1051
};
 
1052
 
 
1053
 
 
1054
int main(int argc, char **argv)
 
1055
{
 
1056
//  if (argc > 1)
 
1057
//    get_options(&argc, &argv);
 
1058
 
 
1059
  get_envvars();
 
1060
 
 
1061
  run_tests(my_tests);
 
1062
 
 
1063
  return(exit_status());
 
1064
}