main.c 15.8 KB
Newer Older
F
freemine 已提交
1
#include "os.h"
F
freemine 已提交
2
#include <sql.h>
F
freemine 已提交
3
#include <sqlext.h>
F
freemine 已提交
4 5

#include <stdio.h>
F
freemine 已提交
6
#include <string.h>
F
freemine 已提交
7

F
freemine 已提交
8
#include "os.h"
F
freemine 已提交
9
#include "../src/todbc_log.h"
F
freemine 已提交
10

F
freemine 已提交
11 12 13 14
// static const char *dsn = "TAOS_DSN";
// static const char *uid = "root";
// static const char *pwd = "taosdata";

F
freemine 已提交
15 16 17 18 19 20 21 22
#define CHK_TEST(statement)                       \
do {                                              \
  D("testing: %s", #statement);                   \
  int r = (statement);                            \
  if (r) return 1;                                \
} while (0);


F
freemine 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
typedef struct data_s            data_t;
struct data_s {
  int64_t                 ts;
  int8_t                  b;
  int8_t                  v1;
  int16_t                 v2;
  int32_t                 v4;
  int64_t                 v8;
  float                   f4;
  double                  f8;
  char                    bin[40+1];
  char                    blob[40+1]; // why 80?  ref: tests/examples/c/apitest.c
};

static const char *pre_stmts[] = {
  "create database db",
  "use db",
  "create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))"
};

static const char *pro_stmts[] = {
  // "insert into t values ('2019-07-15 00:00:00', 1)",
  // "insert into t values ('2019-07-15 01:00:00', 2)",
  "select * from t"
  // "drop database db"
};

F
freemine 已提交
50
#define CHK_RESULT(r, ht, h, fmt, ...)                                          \
F
freemine 已提交
51 52 53 54 55 56 57 58 59 60
do {                                                                            \
  if (r==0) break;                                                              \
  SQLCHAR      ss[10];                                                          \
  SQLINTEGER   ne = 0;                                                          \
  SQLCHAR      es[4096];                                                        \
  SQLSMALLINT  n  = 0;                                                          \
  ss[0] = '\0';                                                                 \
  es[0] = '\0';                                                                 \
  SQLRETURN ret = SQLGetDiagRec(ht, h, 1, ss, &ne, es, sizeof(es), &n);         \
  if (ret) break;                                                               \
F
freemine 已提交
61
  D("[%s]%s: " fmt "", ss, es, ##__VA_ARGS__);                                  \
F
freemine 已提交
62 63
} while (0)

F
freemine 已提交
64 65 66 67 68 69 70 71 72 73 74
static int open_connect(const char *dsn, const char *uid, const char *pwd, SQLHENV *pEnv, SQLHDBC *pConn) {
  SQLRETURN r;
  SQLHENV env = {0};
  SQLHDBC conn = {0};
  r = SQLAllocEnv(&env);
  if (r!=SQL_SUCCESS) return 1;
  do {
    r = SQLAllocConnect(env, &conn);
    CHK_RESULT(r, SQL_HANDLE_ENV, env, "");
    if (r!=SQL_SUCCESS) break;
    do {
75 76 77
      r = SQLConnect(conn, (SQLCHAR*)dsn, (SQLSMALLINT)strlen(dsn),
                           (SQLCHAR*)uid, (SQLSMALLINT)strlen(uid),
                           (SQLCHAR*)pwd, (SQLSMALLINT)strlen(pwd));
F
freemine 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
      CHK_RESULT(r, SQL_HANDLE_DBC, conn, "");
      if (r==SQL_SUCCESS) {
        *pEnv  = env;
        *pConn = conn;
        return 0;
      }
    } while (0);
    SQLFreeConnect(conn);
  } while (0);
  SQLFreeEnv(env);

  return 1;
}

static int open_driver_connect(const char *connstr, SQLHENV *pEnv, SQLHDBC *pConn) {
  SQLRETURN r;
  SQLHENV env = {0};
  SQLHDBC conn = {0};
  r = SQLAllocEnv(&env);
  if (r!=SQL_SUCCESS) return 1;
  do {
    r = SQLAllocConnect(env, &conn);
    CHK_RESULT(r, SQL_HANDLE_ENV, env, "");
    if (r!=SQL_SUCCESS) break;
    do {
      SQLCHAR buf[4096];
      SQLSMALLINT blen = 0;
      SQLHDBC         ConnectionHandle      = conn;
      SQLHWND         WindowHandle          = NULL;
      SQLCHAR *       InConnectionString    = (SQLCHAR*)connstr;
108
      SQLSMALLINT     StringLength1         = (SQLSMALLINT)strlen(connstr);
F
freemine 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
      SQLCHAR *       OutConnectionString   = buf;
      SQLSMALLINT     BufferLength          = sizeof(buf);
      SQLSMALLINT *   StringLength2Ptr      = &blen;
      SQLUSMALLINT    DriverCompletion      = SQL_DRIVER_NOPROMPT;
      r = SQLDriverConnect(ConnectionHandle, WindowHandle, InConnectionString,
                           StringLength1, OutConnectionString, BufferLength,
                           StringLength2Ptr, DriverCompletion);
      CHK_RESULT(r, SQL_HANDLE_DBC, conn, "");
      if (r==SQL_SUCCESS) {
        *pEnv  = env;
        *pConn = conn;
        return 0;
      }
    } while (0);
    SQLFreeConnect(conn);
  } while (0);
  SQLFreeEnv(env);

  return 1;
}
F
freemine 已提交
129 130 131
static int do_statement(SQLHSTMT stmt, const char *statement) {
  SQLRETURN r = 0;
  do {
F
freemine 已提交
132 133
    r = SQLExecDirect(stmt, (SQLCHAR*)statement, SQL_NTS);
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: [%s]", statement);
F
freemine 已提交
134
    if (r) break;
F
freemine 已提交
135 136 137
    SQLSMALLINT cols = 0;
    r = SQLNumResultCols(stmt, &cols);
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "");
F
freemine 已提交
138
    if (r) break;
F
freemine 已提交
139 140 141 142 143 144 145 146
    if (cols <= 0) break;
    char buf[4096];
    while (1) {
      SQLRETURN r = SQLFetch(stmt);
      if (r==SQL_NO_DATA) break;
      CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "");
      for (size_t i=0; i<cols; ++i) {
        SQLLEN soi = 0;
147
        r = SQLGetData(stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, buf, sizeof(buf), &soi);
F
freemine 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "");
        if (r) {
          if (r!=SQL_SUCCESS_WITH_INFO) {
            if (i>0) fprintf(stdout, "\n");
            return r;
          }
        }
        if (soi==SQL_NULL_DATA) {
          fprintf(stdout, "%snull", i==0?"":",");
        } else {
          fprintf(stdout, "%s\"%s\"", i==0?"":",", buf);
        }
      }
      fprintf(stdout, "\n");
    }

    // r = SQLFetch(stmt);
    // if (r==SQL_NO_DATA) {
    //   D("..........");
    //   r = SQL_SUCCESS;
    //   break;
    // }
    // CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "");
    // if (r) break;
    // r = SQLPrepare(stmt, (SQLCHAR*)statement, strlen(statement));
    // CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "");
    // if (r) break;
    // r = SQLExecute(stmt);
    // CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
    // if (r) break;
F
freemine 已提交
178 179 180 181 182 183 184 185 186 187
  } while (0);
  return r;
}

static int do_insert(SQLHSTMT stmt, data_t data) {
  SQLRETURN r = 0;
  SQLLEN 		lbin;
  SQLLEN    lblob;

  const char *statement = "insert into t values (?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
188
  #define ignored 0
F
freemine 已提交
189 190

  do {
191
    r = SQLPrepare(stmt, (SQLCHAR*)statement, (SQLINTEGER)strlen(statement));
F
freemine 已提交
192
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
193 194
    if (r) break;

195
    r = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_SBIGINT, SQL_TIMESTAMP, ignored, ignored, &data.ts, ignored, NULL);
F
freemine 已提交
196
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
197 198
    if (r) break;

199
    r = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_BIT, SQL_BIT, ignored, ignored, &data.b, ignored, NULL);
F
freemine 已提交
200
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
201 202
    if (r) break;

203
    r = SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, ignored, ignored, &data.v1, ignored, NULL);
F
freemine 已提交
204
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
205 206
    if (r) break;

207
    r = SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_SHORT, SQL_SMALLINT, ignored, ignored, &data.v2, ignored, NULL);
F
freemine 已提交
208
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
209 210
    if (r) break;

211
    r = SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, ignored, ignored, &data.v4, ignored, NULL);
F
freemine 已提交
212
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
213 214
    if (r) break;

215
    r = SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_SBIGINT, SQL_BIGINT, ignored, ignored, &data.v8, ignored, NULL);
F
freemine 已提交
216
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
217 218
    if (r) break;

219
    r = SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_FLOAT, SQL_FLOAT, ignored, ignored, &data.f4, ignored, NULL);
F
freemine 已提交
220
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
221 222
    if (r) break;

223
    r = SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_DOUBLE, ignored, ignored, &data.f8, ignored, NULL);
F
freemine 已提交
224
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
225 226 227
    if (r) break;

    lbin = SQL_NTS;
228
    r = SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, sizeof(data.bin)-1, ignored, &data.bin, ignored, &lbin);
F
freemine 已提交
229
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
230 231 232
    if (r) break;

    lblob = SQL_NTS;
233
    r = SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(data.blob)-1, ignored, &data.blob, ignored, &lblob);
F
freemine 已提交
234
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
235 236 237
    if (r) break;

    r = SQLExecute(stmt);
F
freemine 已提交
238
    CHK_RESULT(r, SQL_HANDLE_STMT, stmt, "statement: %s", statement);
F
freemine 已提交
239 240 241 242 243 244 245
    if (r) break;

    // ts += 1;
    // v  = 2;
    // r = SQLExecute(stmt);
    // if (r) break;
  } while (0);
246 247

  #undef ignored
F
freemine 已提交
248 249 250
  return r;
}

F
freemine 已提交
251
static int test1(const char *dsn, const char *uid, const char *pwd) {
F
freemine 已提交
252 253
  SQLHENV env = {0};
  SQLHDBC conn = {0};
F
freemine 已提交
254 255 256
  int n = open_connect(dsn, uid, pwd, &env, &conn);
  if (n) return 1;

257
  int ok = 0;
F
freemine 已提交
258
  do {
259
    SQLRETURN r = SQL_SUCCESS;
F
freemine 已提交
260 261
    SQLHSTMT stmt = {0};
    r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt);
F
freemine 已提交
262
    if (r!=SQL_SUCCESS) break;
F
freemine 已提交
263
    do {
F
freemine 已提交
264 265 266 267
      if (do_statement(stmt, "drop database if exists db")) {
        break;
      }
      for (size_t i=0; i<sizeof(pre_stmts)/sizeof(pre_stmts[0]); ++i) {
268 269
        n = do_statement(stmt, pre_stmts[i]);
        if (n) break;
F
freemine 已提交
270
      }
F
freemine 已提交
271
      do {
F
freemine 已提交
272 273 274 275 276 277 278
        data_t       data = {0};
        data.ts      = 1591060628001;
        data.b       = 1;
        data.v1      = 127;
        data.v2      = 32767;
        data.v4      = 2147483647;
        data.v8      = 9223372036854775807;
279
        data.f4      = 123.456f;
F
freemine 已提交
280 281 282 283 284 285
        data.f8      = 9999999.999999;
        memset(data.bin, 0, sizeof(data.bin));
        memset(data.blob, 0, sizeof(data.blob));
        snprintf(data.bin, sizeof(data.bin), "hel我lo");
        snprintf(data.blob, sizeof(data.blob), "world");
        snprintf(data.blob, sizeof(data.blob), "wo人rld");
F
freemine 已提交
286 287 288 289
        SQLHSTMT stmt = {0};
        r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt);
        if (r!=SQL_SUCCESS) break;
        do {
290 291
          n = do_insert(stmt, data);
          if (n) break;
F
freemine 已提交
292 293
        } while (0);
        SQLFreeHandle(SQL_HANDLE_STMT, stmt);
F
freemine 已提交
294 295 296 297 298 299 300 301

        // r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt);
        // if (r!=SQL_SUCCESS) break;
        // do {
        //   r = do_insert(stmt, ts++, v++);
        //   if (r!=SQL_SUCCESS) break;
        // } while (0);
        // SQLFreeHandle(SQL_HANDLE_STMT, stmt);
302
        ok = 1;
F
freemine 已提交
303
      } while (0);
304 305
      if (!ok) break;
      ok = 0;
F
freemine 已提交
306
      for (size_t i=0; i<sizeof(pro_stmts)/sizeof(pro_stmts[0]); ++i) {
307 308
        n = do_statement(stmt, pro_stmts[i]);
        if (n) break;
F
freemine 已提交
309
      }
310
      ok = 1;
F
freemine 已提交
311
    } while (0);
F
freemine 已提交
312
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);
F
freemine 已提交
313
  } while (0);
F
freemine 已提交
314 315
  SQLDisconnect(conn);
  SQLFreeConnect(conn);
F
freemine 已提交
316
  SQLFreeEnv(env);
F
freemine 已提交
317

318
  return ok ? 0 : 1;
F
freemine 已提交
319 320
}

F
freemine 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
int test_statements(const char *dsn, const char *uid, const char *pwd, const char **statements) {
  SQLRETURN r = SQL_SUCCESS;
  SQLHENV env = {0};
  SQLHDBC conn = {0};
  int n = open_connect(dsn, uid, pwd, &env, &conn);
  if (n) return 1;
  do {
    SQLHSTMT stmt = {0};
    r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt);
    if (r!=SQL_SUCCESS) break;
    const char **p = statements;
    while (*p) {
      if (do_statement(stmt, *p)) {
        r = SQL_ERROR;
        break;
      }
      ++p;
    }
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);
  } while (0);
  SQLDisconnect(conn);
  SQLFreeConnect(conn);
  SQLFreeEnv(env);
  return r ? 1 : 0;
}

int test_driver_connect(const char *connstr) {
  SQLRETURN r = SQL_SUCCESS;
  SQLHENV env = {0};
  SQLHDBC conn = {0};
  int n = open_driver_connect(connstr, &env, &conn);
  if (n) return 1;
  SQLDisconnect(conn);
  SQLFreeConnect(conn);
  SQLFreeEnv(env);
  return r ? 1 : 0;
}

int create_statement(SQLHENV env, SQLHDBC conn, SQLHSTMT *pStmt) {
  SQLHSTMT stmt = {0};
  SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt);
  CHK_RESULT(r, SQL_HANDLE_DBC, conn, "");
  if (r==SQL_SUCCESS) {
    *pStmt = stmt;
    return 0;
  }
  if (r==SQL_SUCCESS_WITH_INFO) {
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);
  }
  return 1;
}

int do_statements(SQLHSTMT stmt, const char **statements) {
  const char **p = statements;
  while (p && *p) {
    CHK_TEST(do_statement(stmt, *p));
    ++p;
  }
  return 0;
}

int tests_stmt(SQLHENV env, SQLHDBC conn, SQLHSTMT stmt) {
  const char *statements[] = {
    "drop database if exists m",
    "create database m",
    "use m",
    // "create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(1), name nchar(1))",
    "create table t (ts timestamp, b bool)",
    "insert into t values('2020-10-10 00:00:00', 0)",
    "insert into t values('2020-10-10 00:00:00.001', 1)",
    NULL
  };
  CHK_TEST(do_statements(stmt, statements));
  return 0;
}

int tests(SQLHENV env, SQLHDBC conn) {
  SQLHSTMT stmt = {0};
  CHK_TEST(create_statement(env, conn, &stmt));
  int r = tests_stmt(env, conn, stmt);
  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
  return r ? 1 : 0;
}

int test_env(void) {
  SQLRETURN r;
  SQLHENV env = {0};
  r = SQLAllocEnv(&env);
  if (r!=SQL_SUCCESS) return 1;
  SQLFreeEnv(env);
  return 0;
}

int test_sqls_in_stmt(SQLHENV env, SQLHDBC conn, SQLHSTMT stmt, const char *sqls) {
  FILE *f = fopen(sqls, "rb");
  if (!f) {
    D("failed to open file [%s]", sqls);
    return -1;
  }

  int r = 0;
  while (!feof(f)) {
    char *line = NULL;
    size_t len = 0;

F
freemine 已提交
426 427 428 429 430 431
    ssize_t n = 0;
#ifdef _MSC_VER
    n = taosGetlineImp(&line, &len, f);
#else
    n = getline(&line, &len, f);
#endif
F
freemine 已提交
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
    if (n==-1) break;

    const char *p = NULL;
    do {
      if (line[0] == '#') break;
      if (line[n-1] == '\n') line[n-1]='\0';
      p = line;
      while (isspace(*p)) ++p;

      if (*p==0) break;

      int positive = 1;
      if (strncmp(p, "N:", 2)==0) {
        positive = 0;
        p += 2;
      } else if (strncmp(p, "P:", 2)==0) {
        p += 2;
      }

      D("statement: [%s]", p);
      r = do_statement(stmt, p);

      if (positive && r==0) break;
      if (!positive && r) { r = 0; break; }
      if (positive) return r;
      D("expecting negative result, but got positive");
      return -1;
    } while (0);

    free(line);

    if (r) break;
  }

  fclose(f);
  return r ? 1 : 0;
}

int test_sqls_in_conn(SQLHENV env, SQLHDBC conn, const char *sqls) {
  SQLHSTMT stmt = {0};
  CHK_TEST(create_statement(env, conn, &stmt));
  int r = test_sqls_in_stmt(env, conn, stmt, sqls);
  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
  return r ? 1 : 0;
}

int test_sqls(const char *dsn, const char *uid, const char *pwd, const char *connstr, const char *sqls) {
  int r = 0;
  SQLHENV env  = {0};
  SQLHDBC conn = {0};
  if (dsn) {
    CHK_TEST(open_connect(dsn, uid, pwd, &env, &conn));
  } else {
    CHK_TEST(open_driver_connect(connstr, &env, &conn));
  }
  r = test_sqls_in_conn(env, conn, sqls);
  SQLDisconnect(conn);
  SQLFreeConnect(conn);
  SQLFreeEnv(env);
  return r ? 1 : 0;
}

int main(int argc, char *argv[]) {
  if (argc==1) {
    CHK_TEST(test_env());
    return 0;
  }

  const char *dsn = (argc>1) ? argv[1] : NULL;
  const char *uid = (argc>2) ? argv[2] : NULL;
  const char *pwd = (argc>3) ? argv[3] : NULL;
  const char *connstr = (argc>4) ? argv[4] : NULL;
  const char *sqls = (argc>5) ? argv[5] : NULL;

506
  if (1) {
F
freemine 已提交
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
    CHK_TEST(test_env());

    CHK_TEST(test1(dsn, uid, pwd));

    const char *statements[] = {
      "drop database if exists m",
      "create database m",
      "use m",
      "drop database m",
      NULL
    };
    CHK_TEST(test_statements(dsn, uid, pwd, statements));

    if (connstr)
      CHK_TEST(test_driver_connect(connstr));

    if (connstr) {
      SQLHENV env  = {0};
      SQLHDBC conn = {0};
      CHK_TEST(open_driver_connect(connstr, &env, &conn));
      int r = tests(env, conn);
      SQLDisconnect(conn);
      SQLFreeConnect(conn);
      SQLFreeEnv(env);
      if (r) return 1;
    }
  }

  if ((dsn || connstr) && 1) {
    CHK_TEST(test_sqls(dsn, uid, pwd, connstr, sqls));
  }

  return 0;
}