xref: /titanic_44/usr/src/lib/libsqlite/test/quote.test (revision 1514c4dab4067c36f9a55668b984e4c283fed205)
1
2#pragma ident	"%Z%%M%	%I%	%E% SMI"
3
4# 2001 September 15
5#
6# The author disclaims copyright to this source code.  In place of
7# a legal notice, here is a blessing:
8#
9#    May you do good and not evil.
10#    May you find forgiveness for yourself and forgive others.
11#    May you share freely, never taking more than you give.
12#
13#***********************************************************************
14# This file implements regression tests for SQLite library.  The
15# focus of this file is the ability to specify table and column names
16# as quoted strings.
17#
18# $Id: quote.test,v 1.3 2002/05/21 13:43:04 drh Exp $
19
20set testdir [file dirname $argv0]
21source $testdir/tester.tcl
22
23# Create a table with a strange name and with strange column names.
24#
25do_test quote-1.0 {
26  set r [catch {
27    execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
28  } msg]
29  lappend r $msg
30} {0 {}}
31
32# Insert, update and query the table.
33#
34do_test quote-1.1 {
35  set r [catch {
36    execsql {INSERT INTO '@abc' VALUES(5,'hello')}
37  } msg]
38  lappend r $msg
39} {0 {}}
40do_test quote-1.2 {
41  set r [catch {
42    execsql {SELECT * FROM '@abc'}
43  } msg ]
44  lappend r $msg
45} {0 {5 hello}}
46do_test quote-1.3 {
47  set r [catch {
48    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
49  } msg ]
50  lappend r $msg
51} {0 {hello 10}}
52do_test quote-1.3.1 {
53  catchsql {
54    SELECT '!pqr', '#xyz'+5 FROM '@abc'
55  }
56} {0 {!pqr 5}}
57do_test quote-1.3.2 {
58  catchsql {
59    SELECT "!pqr", "#xyz"+5 FROM '@abc'
60  }
61} {0 {hello 10}}
62do_test quote-1.3 {
63  set r [catch {
64    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
65  } msg ]
66  lappend r $msg
67} {0 {hello 10}}
68do_test quote-1.4 {
69  set r [catch {
70    execsql {UPDATE '@abc' SET '#xyz'=11}
71  } msg ]
72  lappend r $msg
73} {0 {}}
74do_test quote-1.5 {
75  set r [catch {
76    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
77  } msg ]
78  lappend r $msg
79} {0 {hello 16}}
80
81# Drop the table with the strange name.
82#
83do_test quote-1.6 {
84  set r [catch {
85    execsql {DROP TABLE '@abc'}
86  } msg ]
87  lappend r $msg
88} {0 {}}
89
90
91finish_test
92