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