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