Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More changes to do with the new sqlite3_step() API. (CVS 1458) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e83138250ce0a8caacbd1822eec2e067 |
User & Date: | danielk1977 2004-05-26 00:07:25.000 |
Context
2004-05-26
| ||
02:04 | Use the new API calls more consistently. (CVS 1459) (check-in: 17e7db488d user: danielk1977 tags: trunk) | |
00:07 | More changes to do with the new sqlite3_step() API. (CVS 1458) (check-in: e83138250c user: danielk1977 tags: trunk) | |
00:01 | Minor code fixes in btree.c and pragma.c to help with watcom C. (CVS 1457) (check-in: 143c502a59 user: drh tags: trunk) | |
Changes
Changes to src/sqlite.h.in.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** ** @(#) $Id: sqlite.h.in,v 1.78 2004/05/26 00:07:25 danielk1977 Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
581 582 583 584 585 586 587 | sqlite *db, /* The open database */ const char *zSql, /* SQL statement to be compiled */ const char **pzTail, /* OUT: uncompiled tail of zSql */ sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */ char **pzErrmsg /* OUT: Error message. */ ); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | sqlite *db, /* The open database */ const char *zSql, /* SQL statement to be compiled */ const char **pzTail, /* OUT: uncompiled tail of zSql */ sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */ char **pzErrmsg /* OUT: Error message. */ ); /* ** This routine is called to delete a virtual machine after it has finished ** executing. The return value is the result code. SQLITE_OK is returned ** if the statement executed successfully and some other value is returned if ** there was any kind of error. If an error occurred and pzErrMsg is not ** NULL, then an error message is written into memory obtained from malloc() ** and *pzErrMsg is made to point to that error message. The calling routine |
︙ | ︙ | |||
1119 1120 1121 1122 1123 1124 1125 | ** ** SQLITE_MISUSE means that the this routine was called inappropriately. ** Perhaps it was called on a virtual machine that had already been ** finalized or on one that had previously returned SQLITE_ERROR or ** SQLITE_DONE. Or it could be the case the the same database connection ** is being used simulataneously by two or more threads. */ | | | 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | ** ** SQLITE_MISUSE means that the this routine was called inappropriately. ** Perhaps it was called on a virtual machine that had already been ** finalized or on one that had previously returned SQLITE_ERROR or ** SQLITE_DONE. Or it could be the case the the same database connection ** is being used simulataneously by two or more threads. */ int sqlite3_step(sqlite3_stmt*); /* ** The sqlite3_finalize() function is called to delete a compiled ** SQL statement obtained by a previous call to sqlite3_prepare() ** or sqlite3_prepare16(). If the statement was executed successfully, or ** not executed at all, then SQLITE_OK is returned. If execution of the |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** 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. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** 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.53 2004/05/26 00:07:26 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
754 755 756 757 758 759 760 | if( rc!=0 && rc!=SQLITE_ABORT ){ Tcl_AppendResult(interp, sqlite3_error_string(rc), 0); return TCL_ERROR; } return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 754 755 756 757 758 759 760 761 762 763 764 765 766 767 | if( rc!=0 && rc!=SQLITE_ABORT ){ Tcl_AppendResult(interp, sqlite3_error_string(rc), 0); return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite3_finalize STMT ** ** Finalize a statement handle. */ static int test_finalize( void * clientData, |
︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 | } /* ** Usage: sqlite3_step STMT ** ** Advance the statement to the next row. */ | | | > | 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 | } /* ** Usage: sqlite3_step STMT ** ** Advance the statement to the next row. */ static int test_step( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int rc; if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite3_step(pStmt); if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; Tcl_SetResult(interp, errorName(rc), 0); return TCL_OK; } /* ** Usage: sqlite3_column_data STMT column ** ** Advance the statement to the next row. |
︙ | ︙ | |||
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 | len = sqlite3_column_bytes16(pStmt, col); pRet = Tcl_NewByteArrayObj(sqlite3_column_data16(pStmt, col), len); Tcl_SetObjResult(interp, pRet); return TCL_OK; } /* ** This is a collating function named "REVERSE" which sorts text ** in reverse order. */ static int reverseCollatingFunc( void *NotUsed, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 | len = sqlite3_column_bytes16(pStmt, col); pRet = Tcl_NewByteArrayObj(sqlite3_column_data16(pStmt, col), len); 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, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; if( objc!=2 ){ 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; Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_column_count(pStmt))); return TCL_OK; } /* ** Usage: sqlite3_data_count STMT ** ** Return the number of columns returned by the sql statement STMT. */ static int test_data_count( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; if( objc!=2 ){ 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; Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_data_count(pStmt))); return TCL_OK; } /* ** This is a collating function named "REVERSE" which sorts text ** in reverse order. */ static int reverseCollatingFunc( void *NotUsed, |
︙ | ︙ | |||
1573 1574 1575 1576 1577 1578 1579 | { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func }, { "sqlite_abort", (Tcl_CmdProc*)sqlite_abort }, { "sqlite_datatypes", (Tcl_CmdProc*)sqlite_datatypes }, #ifdef MEMORY_DEBUG { "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail }, { "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat }, #endif | < | 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func }, { "sqlite_abort", (Tcl_CmdProc*)sqlite_abort }, { "sqlite_datatypes", (Tcl_CmdProc*)sqlite_datatypes }, #ifdef MEMORY_DEBUG { "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail }, { "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat }, #endif { "sqlite_bind", (Tcl_CmdProc*)test_bind }, { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; } aObjCmd[] = { |
︙ | ︙ | |||
1597 1598 1599 1600 1601 1602 1603 | { "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 }, | | > > | 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 | { "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_data", (Tcl_ObjCmdProc*)test_column_data }, { "sqlite3_column_data16", (Tcl_ObjCmdProc*)test_column_data16 }, { "sqlite3_column_count", (Tcl_ObjCmdProc*)test_column_count }, { "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); } |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.330 2004/05/26 00:07:26 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* |
︙ | ︙ | |||
488 489 490 491 492 493 494 495 | }else{ pStack->r = 0.0; } /* pStack->flags |= MEM_Real; */ pStack->flags = MEM_Real; } /* | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | }else{ pStack->r = 0.0; } /* pStack->flags |= MEM_Real; */ pStack->flags = MEM_Real; } /* ** Execute the statement pStmt, either until a row of data is ready, the ** statement is completely executed or an error occurs. */ int sqlite3_step(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe*)pStmt; sqlite *db; int rc; if( p->magic!=VDBE_MAGIC_RUN ){ return SQLITE_MISUSE; } |
︙ | ︙ |
Changes to test/bind.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 September 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # 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 sqlite_bind API. # | | > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # 2003 September 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # 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 sqlite_bind API. # # $Id: bind.test,v 1.8 2004/05/26 00:07:25 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals upvar COLS cols set vals [list] set cols [list] set rc [sqlite3_step $stmt] for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} { lappend cols [sqlite3_column_name $stmt $i] } for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} { lappend vals [sqlite3_column_data $stmt $i] } return $rc } do_test bind-1.1 { db close set DB [sqlite db test.db] execsql {CREATE TABLE t1(a,b,c)} set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(?,?,?)} -1 TAIL] set TAIL |
︙ | ︙ |