xref: /onnv-gate/usr/src/lib/libsqlite/test/bind.test (revision 4520:7dbeadedd7fe)
1*4520Snw141292
2*4520Snw141292#pragma ident	"%Z%%M%	%I%	%E% SMI"
3*4520Snw141292
4*4520Snw141292# 2003 September 6
5*4520Snw141292#
6*4520Snw141292# The author disclaims copyright to this source code.  In place of
7*4520Snw141292# a legal notice, here is a blessing:
8*4520Snw141292#
9*4520Snw141292#    May you do good and not evil.
10*4520Snw141292#    May you find forgiveness for yourself and forgive others.
11*4520Snw141292#    May you share freely, never taking more than you give.
12*4520Snw141292#
13*4520Snw141292#***********************************************************************
14*4520Snw141292# This file implements regression tests for SQLite library.  The
15*4520Snw141292# focus of this script testing the sqlite_bind API.
16*4520Snw141292#
17*4520Snw141292# $Id: bind.test,v 1.1 2003/09/06 22:45:21 drh Exp $
18*4520Snw141292#
19*4520Snw141292
20*4520Snw141292set testdir [file dirname $argv0]
21*4520Snw141292source $testdir/tester.tcl
22*4520Snw141292
23*4520Snw141292do_test bind-1.1 {
24*4520Snw141292  db close
25*4520Snw141292  set DB [sqlite db test.db]
26*4520Snw141292  execsql {CREATE TABLE t1(a,b,c)}
27*4520Snw141292  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(?,?,?)} TAIL]
28*4520Snw141292  set TAIL
29*4520Snw141292} {}
30*4520Snw141292do_test bind-1.2 {
31*4520Snw141292  sqlite_step $VM N VALUES COLNAMES
32*4520Snw141292} {SQLITE_DONE}
33*4520Snw141292do_test bind-1.3 {
34*4520Snw141292  execsql {SELECT rowid, * FROM t1}
35*4520Snw141292} {1 {} {} {}}
36*4520Snw141292do_test bind-1.4 {
37*4520Snw141292  sqlite_reset $VM
38*4520Snw141292  sqlite_bind $VM 1 {test value 1} normal
39*4520Snw141292  sqlite_step $VM N VALUES COLNAMES
40*4520Snw141292} SQLITE_DONE
41*4520Snw141292do_test bind-1.5 {
42*4520Snw141292  execsql {SELECT rowid, * FROM t1}
43*4520Snw141292} {1 {} {} {} 2 {test value 1} {} {}}
44*4520Snw141292do_test bind-1.6 {
45*4520Snw141292  sqlite_reset $VM
46*4520Snw141292  sqlite_bind $VM 3 {'test value 2'} normal
47*4520Snw141292  sqlite_step $VM N VALUES COLNAMES
48*4520Snw141292} SQLITE_DONE
49*4520Snw141292do_test bind-1.7 {
50*4520Snw141292  execsql {SELECT rowid, * FROM t1}
51*4520Snw141292} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
52*4520Snw141292do_test bind-1.8 {
53*4520Snw141292  sqlite_reset $VM
54*4520Snw141292  set sqlite_static_bind_value 123
55*4520Snw141292  sqlite_bind $VM 1 {} static
56*4520Snw141292  sqlite_bind $VM 2 {abcdefg} normal
57*4520Snw141292  sqlite_bind $VM 3 {} null
58*4520Snw141292  execsql {DELETE FROM t1}
59*4520Snw141292  sqlite_step $VM N VALUES COLNAMES
60*4520Snw141292  execsql {SELECT rowid, * FROM t1}
61*4520Snw141292} {1 123 abcdefg {}}
62*4520Snw141292do_test bind-1.9 {
63*4520Snw141292  sqlite_reset $VM
64*4520Snw141292  sqlite_bind $VM 1 {456} normal
65*4520Snw141292  sqlite_step $VM N VALUES COLNAMES
66*4520Snw141292  execsql {SELECT rowid, * FROM t1}
67*4520Snw141292} {1 123 abcdefg {} 2 456 abcdefg {}}
68*4520Snw141292
69*4520Snw141292
70*4520Snw141292do_test bind-1.99 {
71*4520Snw141292  sqlite_finalize $VM
72*4520Snw141292} {}
73*4520Snw141292
74*4520Snw141292
75*4520Snw141292finish_test
76