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