/ Check-in [d72adf0c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add TCL test bindings and some more test cases for the new query API. (CVS 1467)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d72adf0c522b442d5e1663862bdd639c282d4495
User & Date: danielk1977 2004-05-27 01:04:07
Context
2004-05-27
01:49
More test cases for the new query API. (CVS 1468) check-in: 74097ecd user: danielk1977 tags: trunk
01:04
Add TCL test bindings and some more test cases for the new query API. (CVS 1467) check-in: d72adf0c user: danielk1977 tags: trunk
2004-05-26
23:43
Break Mem.flags into Mem.type and Mem.enc. (CVS 1466) check-in: 68ef1702 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test1.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
....
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524





























1525
1526
1527
1528
1529
1530
1531

1532
1533
1534
1535
1536
1537
1538
1539
1540
1541

1542
1543
1544
1545
1546
1547
1548
1549
....
1605
1606
1607
1608
1609
1610
1611
































































































1612
1613
1614
1615
1616
1617
1618
....
1641
1642
1643
1644
1645
1646
1647

1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662




1663
1664
1665
1666
1667


1668
1669
1670

1671



1672
1673
1674









1675
1676
1677
1678
1679
1680
1681
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.59 2004/05/26 23:25:31 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  rc = sqlite3_step(pStmt);

  if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR;
  Tcl_SetResult(interp, (char *)errorName(rc), 0);
  return TCL_OK;
}

/*
** Usage: sqlite3_column_text STMT column
**
** Advance the statement to the next row.
*/
static int test_column_text(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  Tcl_Obj *pRet;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  if( SQLITE3_BLOB==sqlite3_column_type(pStmt, col) ){
    int len = sqlite3_column_bytes(pStmt, col);
    pRet = Tcl_NewByteArrayObj(sqlite3_column_text(pStmt, col), len);
  }else{
    pRet = Tcl_NewStringObj(sqlite3_column_text(pStmt, col), -1);
  }
  Tcl_SetObjResult(interp, pRet);

  return TCL_OK;
}

/*
** Usage: sqlite3_column_text16 STMT column
**
** Advance the statement to the next row.
*/
static int test_column_text16(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  Tcl_Obj *pRet;
  int len;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  len = sqlite3_column_bytes16(pStmt, col);
  pRet = Tcl_NewByteArrayObj(sqlite3_column_text16(pStmt, col), len);
  Tcl_SetObjResult(interp, pRet);

  return TCL_OK;
}

/*
** Usage: sqlite3_column_name STMT column
**
** Advance the statement to the next row.
*/
static int test_column_name(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  Tcl_SetResult(interp, (char *)sqlite3_column_name(pStmt, col), 0);

  return TCL_OK;
}

/*
** Usage: sqlite3_column_name16 STMT column
**
** Advance the statement to the next row.
*/
static int test_column_name16(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  Tcl_Obj *pRet;
  const void *zName16;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  zName16 = sqlite3_column_name16(pStmt, col);
  pRet = Tcl_NewByteArrayObj(zName16, sqlite3utf16ByteLen(zName16, -1)+2);
  Tcl_SetObjResult(interp, pRet);

  return TCL_OK;
}

/*
** Usage: sqlite3_column_count STMT 
**
** Return the number of columns returned by the sql statement STMT.
*/
static int test_column_count(
  void * clientData,
................................................................................
      assert(0);
  }

  return TCL_OK;
}

/*
** Usage: sqlite3_column_int STMT column
**
** Return the data in column 'column' of the current row cast as an
** integer.
*/
static int test_column_int(





























  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;


  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;


  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_column_int(pStmt, col)));
  return TCL_OK;
}

/*
** Usage: sqlite3_data_count STMT 
**
** Return the number of columns returned by the sql statement STMT.
................................................................................
    return TCL_ERROR;
  }
  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  sqlite3ChangeCollatingFunction(db, "REVERSE", 7, 0, reverseCollatingFunc);
  return TCL_OK;
}


































































































/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
  extern int sqlite3_search_count;
  extern int sqlite3_interrupt_count;
................................................................................
#endif
     { "sqlite_bind",                    (Tcl_CmdProc*)test_bind             },
     { "breakpoint",                     (Tcl_CmdProc*)test_breakpoint       },
  };
  static struct {
     char *zName;
     Tcl_ObjCmdProc *xProc;

  } aObjCmd[] = {
     { "sqlite3_bind_int32",            (Tcl_ObjCmdProc*)test_bind_int32    },
     { "sqlite3_bind_int64",            (Tcl_ObjCmdProc*)test_bind_int64    },
     { "sqlite3_bind_double",           (Tcl_ObjCmdProc*)test_bind_double   },
     { "sqlite3_bind_null",             (Tcl_ObjCmdProc*)test_bind_null     },
     { "sqlite3_bind_text",             (Tcl_ObjCmdProc*)test_bind_text     },
     { "sqlite3_bind_text16",           (Tcl_ObjCmdProc*)test_bind_text16   },
     { "sqlite3_bind_blob",             (Tcl_ObjCmdProc*)test_bind_blob     },
     { "sqlite3_errcode",               (Tcl_ObjCmdProc*)test_errcode       },
     { "sqlite3_errmsg",                (Tcl_ObjCmdProc*)test_errmsg        },
     { "sqlite3_errmsg16",              (Tcl_ObjCmdProc*)test_errmsg16      },
     { "sqlite3_prepare",               (Tcl_ObjCmdProc*)test_prepare       },
     { "sqlite3_prepare16",             (Tcl_ObjCmdProc*)test_prepare16     },
     { "sqlite3_open",                  (Tcl_ObjCmdProc*)test_open          },
     { "sqlite3_open16",                (Tcl_ObjCmdProc*)test_open16        },




     { "sqlite3_finalize",              (Tcl_ObjCmdProc*)test_finalize      },
     { "sqlite3_reset",                 (Tcl_ObjCmdProc*)test_reset         },
     { "sqlite3_step",                  (Tcl_ObjCmdProc*)test_step},
     { "sqlite3_column_text",           (Tcl_ObjCmdProc*)test_column_text   },
     { "sqlite3_column_text16",         (Tcl_ObjCmdProc*)test_column_text16 },


     { "sqlite3_column_count",          (Tcl_ObjCmdProc*)test_column_count  },
     { "sqlite3_column_name",           (Tcl_ObjCmdProc*)test_column_name   },
     { "sqlite3_column_name16",         (Tcl_ObjCmdProc*)test_column_name16 },

     { "sqlite3_column_type",           (Tcl_ObjCmdProc*)test_column_type   },



     { "sqlite3_column_int",            (Tcl_ObjCmdProc*)test_column_int   },
     { "sqlite3_data_count",            (Tcl_ObjCmdProc*)test_data_count   },
     { "add_reverse_collating_func",    (Tcl_ObjCmdProc*)reverse_collfunc   },









  };
  int i;

  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
  }
  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){







|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|


|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>










>
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>

|
|
|
|
|
|
|
|
|
|
<
<
|
|
>
>
>
>
|
|
|
<
<
>
>
|
<
<
>
|
>
>
>
|
<
<
>
>
>
>
>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1311
1312
1313
1314
1315
1316
1317































































































































1318
1319
1320
1321
1322
1323
1324
....
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
....
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
....
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659


1660
1661
1662
1663
1664
1665
1666
1667
1668


1669
1670
1671


1672
1673
1674
1675
1676
1677


1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.60 2004/05/27 01:04:07 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  rc = sqlite3_step(pStmt);

  if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR;
  Tcl_SetResult(interp, (char *)errorName(rc), 0);
  return TCL_OK;
}
































































































































/*
** Usage: sqlite3_column_count STMT 
**
** Return the number of columns returned by the sql statement STMT.
*/
static int test_column_count(
  void * clientData,
................................................................................
      assert(0);
  }

  return TCL_OK;
}

/*
** Usage: sqlite3_column_int64 STMT column
**
** Return the data in column 'column' of the current row cast as an
** wide (64-bit) integer.
*/
static int test_column_int64(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  i64 iVal;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  iVal = sqlite3_column_int64(pStmt, col);
  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iVal));
  return TCL_OK;
}

/*
** Usage: sqlite3_column_double STMT column
**
** Return the data in column 'column' of the current row cast as a double.
*/
static int test_column_double(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  double rVal;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  rVal = sqlite3_column_double(pStmt, col);
  Tcl_SetObjResult(interp, Tcl_NewDoubleObj(iVal));
  return TCL_OK;
}

/*
** Usage: sqlite3_data_count STMT 
**
** Return the number of columns returned by the sql statement STMT.
................................................................................
    return TCL_ERROR;
  }
  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  sqlite3ChangeCollatingFunction(db, "REVERSE", 7, 0, reverseCollatingFunc);
  return TCL_OK;
}

/*
** Usage: sqlite3_column_text STMT column
**
** Usage: sqlite3_column_decltype STMT column
**
** Usage: sqlite3_column_name STMT column
*/
static int test_stmt_utf8(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  const char *(xFunc *)(sqlite3_stmt*, int) = clientData;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;
  Tcl_SetResult(interp, (char *)xFunc(pStmt, col), 0);
  return TCL_OK;
}

/*
** Usage: sqlite3_column_text STMT column
**
** Usage: sqlite3_column_decltype STMT column
**
** Usage: sqlite3_column_name STMT column
*/
static int test_stmt_utf16(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  Tcl_Obj *pRet;
  const void *zName16;
  const void *(xFunc *)(sqlite3_stmt*, int) = clientData;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  zName16 = xFunc(pStmt, col);
  pRet = Tcl_NewByteArrayObj(zName16, sqlite3utf16ByteLen(zName16, -1)+2);
  Tcl_SetObjResult(interp, pRet);

  return TCL_OK;
}

/*
** Usage: sqlite3_column_int STMT column
**
** Usage: sqlite3_column_bytes STMT column
**
** Usage: sqlite3_column_bytes16 STMT column
**
*/
static int test_stmt_int(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_stmt *pStmt;
  int col;
  int (xFunc *)(sqlite3_stmt*, int) = clientData;

  if( objc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", 
       Tcl_GetString(objv[0]), " STMT column", 0);
    return TCL_ERROR;
  }

  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;

  Tcl_SetObjResult(interp, Tcl_NewIntObj(xFunc(pStmt, col)));
  return TCL_OK;
}



/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
  extern int sqlite3_search_count;
  extern int sqlite3_interrupt_count;
................................................................................
#endif
     { "sqlite_bind",                    (Tcl_CmdProc*)test_bind             },
     { "breakpoint",                     (Tcl_CmdProc*)test_breakpoint       },
  };
  static struct {
     char *zName;
     Tcl_ObjCmdProc *xProc;
     void *clientData;
  } aObjCmd[] = {
     { "sqlite3_bind_int32",            test_bind_int32, 0    },
     { "sqlite3_bind_int64",            test_bind_int64 , 0   },
     { "sqlite3_bind_double",           test_bind_double, 0   },
     { "sqlite3_bind_null",             test_bind_null     ,0 },
     { "sqlite3_bind_text",             test_bind_text     ,0 },
     { "sqlite3_bind_text16",           test_bind_text16   ,0 },
     { "sqlite3_bind_blob",             test_bind_blob     ,0 },
     { "sqlite3_errcode",               test_errcode       ,0 },
     { "sqlite3_errmsg",                test_errmsg        ,0 },
     { "sqlite3_errmsg16",              test_errmsg16      ,0 },


     { "sqlite3_open",                  test_open          ,0 },
     { "sqlite3_open16",                test_open16        ,0 },
     { "add_reverse_collating_func",    reverse_collfunc   ,0 },

     { "sqlite3_prepare",               test_prepare       ,0 },
     { "sqlite3_prepare16",             test_prepare16     ,0 },
     { "sqlite3_finalize",              test_finalize      ,0 },
     { "sqlite3_reset",                 test_reset         ,0 },
     { "sqlite3_step",                  test_step,0 },



     /* sqlite3_column_*() API */
     { "sqlite3_column_count",          test_column_count  ,0 },


     { "sqlite3_data_count",            test_data_count    ,0 },
     { "sqlite3_column_type",           test_column_type   ,0 },
     { "sqlite3_column_blob",           test_column_name   ,0 },
     { "sqlite3_column_double",         test_column_double ,0 },
     { "sqlite3_column_int64",          test_column_int64  ,0 },
     { "sqlite3_column_int", test_stmt_int ,sqlite3_column_int },


     { "sqlite3_column_bytes", test_stmt_int ,sqlite3_column_bytes },
     { "sqlite3_column_bytes16", test_stmt_int ,sqlite3_column_bytes16 },
     { "sqlite3_column_text", test_stmt_utf8,       sqlite3_column_text},
     { "sqlite3_column_decltype", test_stmt_utf8,   sqlite3_column_decltype},
     { "sqlite3_column_name", test_stmt_utf8,       sqlite3_column_name},
     { "sqlite3_column_text16", test_stmt_utf16,    sqlite3_column_text16},
     { "sqlite3_column_decltype16", test_stmt_utf16,sqlite3_column_decltype16},
     { "sqlite3_column_name16", test_stmt_utf16,    sqlite3_column_name16},

  };
  int i;

  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
  }
  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){

Changes to test/capi3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
158
159
160
161
162
163
164

165
166
167
168

169



170
171
172
173

174
175
176
177
178
179
180
181
...
194
195
196
197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
212
213
214
215
216
217

218
219
220
221
222
223






224

225
226
227
228
229
230

231





















232
233
234
235
236
237
238
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi3.test,v 1.5 2004/05/26 13:27:00 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................

# The tests cases capi3-5.* test work as follows:
#
# capi3-5.0: Prepare a statement, and check we can retrieve the number of
#            columns (before the statement is executed).
# capi3-5.1: Check we can retrieve column names (before statement execution)
# capi3-5.2: Check we can retrieve column names in UTF-16

# capi3-5.3: Step the statement.
# capi3-5.4: Check the types of the values.
# capi3-5.5: Check the values can be retrieved as integers.
# capi3-5.6: Check the values can be retrieved as UTF-8 text.

# capi3-5.7: Check the values can be retrieved as UTF-16 text.



# capi3-5.8: Check that the types of the values have not been altered by
#            retrieving the values as text.
#
# Test cases capi3-5.9 - capi3-5.14 are a repeat of 3-8, with a different

# row of data.
#

do_test capi3-5.0 {
  execsql {
    CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
    INSERT INTO t1 VALUES(1, 2, 3);
    INSERT INTO t1 VALUES('one', 'two', NULL);
................................................................................

do_test capi3-5.2 {
  set cnamelist [list]
  foreach i {0 1 2} {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]}
  set cnamelist
} {a b c}

do_test capi3-5.3 {
  sqlite3_step $STMT
} SQLITE_ROW


do_test capi3-5.4 {
  set types [list]
  foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
  set types
} {INTEGER INTEGER TEXT}

if 0 {
do_test capi3-5.5 {
  set ints [list]
  foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
  set ints
} {1 2 3}


do_test capi3-5.6 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
  set utf8
} {1 2 3}
}








do_test capi3-5.7 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [utf8 [sqlite3_column_data16 $STMT $i]]}
  set utf8
} {1 2 3}


do_test capi3-5.8 {





















  set types [list]
  foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
  set types
} {INTEGER INTEGER TEXT}










|







 







>
|
|
|
|
>
|
>
>
>
|
|

<
>
|







 







|



>
|





|
|





>
|




|
>
>
>
>
>
>

>
|





>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi3.test,v 1.6 2004/05/27 01:04:07 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................

# The tests cases capi3-5.* test work as follows:
#
# capi3-5.0: Prepare a statement, and check we can retrieve the number of
#            columns (before the statement is executed).
# capi3-5.1: Check we can retrieve column names (before statement execution)
# capi3-5.2: Check we can retrieve column names in UTF-16
#
# capi3-5.1.3: Step the statement.
# capi3-5.1.4: Check the types of the values.
# capi3-5.1.5: Check the values can be retrieved as integers.
# capi3-5.1.6: Check the values can be retrieved as UTF-8 text.
# capi3-5.1.7: Check the values can be retrieved as floats.
# capi3-5.1.8: Check the values can be retrieved as UTF-16 text.
# capi3-5.1.9: Check the values can be retrieved as integers.
# capi3-5.1.10: Check the values can be retrieved as floats.
# capi3-5.1.11: Check the values can still be retrieved as UTF-8 text.
# capi3-5.1.12: Check that the types of the values have not been altered by
#               retrieving the values as text.
#

# Test cases capi3-5.2.3 - capi3-5.2.12 are a repeat of 1.3-1.12, with a
# different row of data.
#

do_test capi3-5.0 {
  execsql {
    CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
    INSERT INTO t1 VALUES(1, 2, 3);
    INSERT INTO t1 VALUES('one', 'two', NULL);
................................................................................

do_test capi3-5.2 {
  set cnamelist [list]
  foreach i {0 1 2} {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]}
  set cnamelist
} {a b c}

do_test capi3-5.1.3 {
  sqlite3_step $STMT
} SQLITE_ROW

# types
do_test capi3-5.1.4 {
  set types [list]
  foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
  set types
} {INTEGER INTEGER TEXT}

# Integers
do_test capi3-5.1.5 {
  set ints [list]
  foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
  set ints
} {1 2 3}

# UTF-8
do_test capi3-5.1.6 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
  set utf8
} {1 2 3}

# Floats
do_test capi3-5.1.7 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]}
  set utf8
} {1 2 3}

# UTF-16
do_test capi3-5.1.8 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [utf8 [sqlite3_column_data16 $STMT $i]]}
  set utf8
} {1 2 3}

# Integers
do_test capi3-5.1.9 {
  set ints [list]
  foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
  set ints
} {1 2 3}

# Floats
do_test capi3-5.1.10 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]}
  set utf8
} {1 2 3}

# UTF-8
do_test capi3-5.1.11 {
  set utf8 [list]
  foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
  set utf8
} {1 2 3}

# Types
do_test capi3-5.1.12 {
  set types [list]
  foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
  set types
} {INTEGER INTEGER TEXT}