Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add initial test cases for the new sqlite_bind() API. Fix bugs that the new test cases found. (CVS 1096) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f6c4908e9b5b6ac9adc4af50dc5110db |
User & Date: | drh 2003-09-06 22:45:21.000 |
Context
2003-09-09
| ||
00:47 | Add test cases that check out sqlite_get_table() on queries with results sets containing 100 columns. (CVS 1097) (check-in: f9feedec32 user: drh tags: trunk) | |
2003-09-06
| ||
22:45 | Add initial test cases for the new sqlite_bind() API. Fix bugs that the new test cases found. (CVS 1096) (check-in: f6c4908e9b user: drh tags: trunk) | |
22:18 | Update Makefile.in for the new vdbeaux.c file. Remove the experimental "sqlite_instantiate()" routine and replace it with "sqlite_bind()" which is more like ODBC and JDBC. (CVS 1095) (check-in: 990bb11898 user: drh tags: trunk) | |
Changes
Changes to src/vdbeaux.c.
︙ | ︙ | |||
572 573 574 575 576 577 578 | sqlite_callback xCallback, /* Result callback */ void *pCallbackArg, /* 1st argument to xCallback() */ int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; assert( p!=0 ); | < > | > | | | | | | | | | > | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | sqlite_callback xCallback, /* Result callback */ void *pCallbackArg, /* 1st argument to xCallback() */ int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; assert( p!=0 ); assert( p->magic==VDBE_MAGIC_INIT ); /* Add a HALT instruction to the very end of the program. */ if( p->nOp==0 || (p->aOp && p->aOp[p->nOp-1].opcode!=OP_Halt) ){ sqliteVdbeAddOp(p, OP_Halt, 0, 0); } /* No instruction ever pushes more than a single element onto the ** stack. And the stack never grows on successive executions of the ** same loop. So the total number of instructions is an upper bound ** on the maximum stack depth required. ** ** Allocation all the stack space we will ever need. */ if( p->aStack==0 ){ p->nVar = nVar; assert( nVar>=0 ); n = isExplain ? 10 : p->nOp; p->aStack = sqliteMalloc( n*(sizeof(p->aStack[0]) + 2*sizeof(char*)) /* aStack and zStack */ + p->nVar*(sizeof(char*)+sizeof(int)+1) /* azVar, anVar, abVar */ ); p->zStack = (char**)&p->aStack[n]; p->azColName = (char**)&p->zStack[n]; p->azVar = (char**)&p->azColName[n]; p->anVar = (int*)&p->azVar[p->nVar]; p->abVar = (u8*)&p->anVar[p->nVar]; } sqliteHashInit(&p->agg.hash, SQLITE_HASH_BINARY, 0); p->agg.pSearch = 0; #ifdef MEMORY_DEBUG if( sqliteOsFileExists("vdbe_trace") ){ p->trace = stdout; } |
︙ | ︙ | |||
944 945 946 947 948 949 950 | if( len<0 ){ len = strlen(zVal)+1; } if( copy ){ p->azVar[i] = sqliteMalloc( len ); if( p->azVar[i] ) memcpy(p->azVar[i], zVal, len); }else{ | | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | if( len<0 ){ len = strlen(zVal)+1; } if( copy ){ p->azVar[i] = sqliteMalloc( len ); if( p->azVar[i] ) memcpy(p->azVar[i], zVal, len); }else{ p->azVar[i] = (char*)zVal; } p->abVar[i] = copy; p->anVar[i] = len; return SQLITE_OK; } |
︙ | ︙ |
Added test/bind.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # 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.1 2003/09/06 22:45:21 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl do_test bind-1.1 { db close set DB [sqlite db test.db] execsql {CREATE TABLE t1(a,b,c)} set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(?,?,?)} TAIL] set TAIL } {} do_test bind-1.2 { sqlite_step $VM N VALUES COLNAMES } {SQLITE_DONE} do_test bind-1.3 { execsql {SELECT rowid, * FROM t1} } {1 {} {} {}} do_test bind-1.4 { sqlite_reset $VM sqlite_bind $VM 1 {test value 1} normal sqlite_step $VM N VALUES COLNAMES } SQLITE_DONE do_test bind-1.5 { execsql {SELECT rowid, * FROM t1} } {1 {} {} {} 2 {test value 1} {} {}} do_test bind-1.6 { sqlite_reset $VM sqlite_bind $VM 3 {'test value 2'} normal sqlite_step $VM N VALUES COLNAMES } SQLITE_DONE do_test bind-1.7 { execsql {SELECT rowid, * FROM t1} } {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}} do_test bind-1.8 { sqlite_reset $VM set sqlite_static_bind_value 123 sqlite_bind $VM 1 {} static sqlite_bind $VM 2 {abcdefg} normal sqlite_bind $VM 3 {} null execsql {DELETE FROM t1} sqlite_step $VM N VALUES COLNAMES execsql {SELECT rowid, * FROM t1} } {1 123 abcdefg {}} do_test bind-1.9 { sqlite_reset $VM sqlite_bind $VM 1 {456} normal sqlite_step $VM N VALUES COLNAMES execsql {SELECT rowid, * FROM t1} } {1 123 abcdefg {} 2 456 abcdefg {}} do_test bind-1.99 { sqlite_finalize $VM } {} finish_test |