1*1da57d55SToomas Soome# 27c478bd9Sstevel@tonic-gate# 2001 September 15 37c478bd9Sstevel@tonic-gate# 47c478bd9Sstevel@tonic-gate# The author disclaims copyright to this source code. In place of 57c478bd9Sstevel@tonic-gate# a legal notice, here is a blessing: 67c478bd9Sstevel@tonic-gate# 77c478bd9Sstevel@tonic-gate# May you do good and not evil. 87c478bd9Sstevel@tonic-gate# May you find forgiveness for yourself and forgive others. 97c478bd9Sstevel@tonic-gate# May you share freely, never taking more than you give. 107c478bd9Sstevel@tonic-gate# 117c478bd9Sstevel@tonic-gate#*********************************************************************** 127c478bd9Sstevel@tonic-gate# This file implements regression tests for SQLite library. The 137c478bd9Sstevel@tonic-gate# focus of this file is the ability to specify table and column names 147c478bd9Sstevel@tonic-gate# as quoted strings. 157c478bd9Sstevel@tonic-gate# 167c478bd9Sstevel@tonic-gate# $Id: quote.test,v 1.3 2002/05/21 13:43:04 drh Exp $ 177c478bd9Sstevel@tonic-gate 187c478bd9Sstevel@tonic-gateset testdir [file dirname $argv0] 197c478bd9Sstevel@tonic-gatesource $testdir/tester.tcl 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate# Create a table with a strange name and with strange column names. 227c478bd9Sstevel@tonic-gate# 237c478bd9Sstevel@tonic-gatedo_test quote-1.0 { 247c478bd9Sstevel@tonic-gate set r [catch { 257c478bd9Sstevel@tonic-gate execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );} 267c478bd9Sstevel@tonic-gate } msg] 277c478bd9Sstevel@tonic-gate lappend r $msg 287c478bd9Sstevel@tonic-gate} {0 {}} 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate# Insert, update and query the table. 317c478bd9Sstevel@tonic-gate# 327c478bd9Sstevel@tonic-gatedo_test quote-1.1 { 337c478bd9Sstevel@tonic-gate set r [catch { 347c478bd9Sstevel@tonic-gate execsql {INSERT INTO '@abc' VALUES(5,'hello')} 357c478bd9Sstevel@tonic-gate } msg] 367c478bd9Sstevel@tonic-gate lappend r $msg 377c478bd9Sstevel@tonic-gate} {0 {}} 387c478bd9Sstevel@tonic-gatedo_test quote-1.2 { 397c478bd9Sstevel@tonic-gate set r [catch { 407c478bd9Sstevel@tonic-gate execsql {SELECT * FROM '@abc'} 417c478bd9Sstevel@tonic-gate } msg ] 427c478bd9Sstevel@tonic-gate lappend r $msg 437c478bd9Sstevel@tonic-gate} {0 {5 hello}} 447c478bd9Sstevel@tonic-gatedo_test quote-1.3 { 457c478bd9Sstevel@tonic-gate set r [catch { 467c478bd9Sstevel@tonic-gate execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'} 477c478bd9Sstevel@tonic-gate } msg ] 487c478bd9Sstevel@tonic-gate lappend r $msg 497c478bd9Sstevel@tonic-gate} {0 {hello 10}} 507c478bd9Sstevel@tonic-gatedo_test quote-1.3.1 { 517c478bd9Sstevel@tonic-gate catchsql { 527c478bd9Sstevel@tonic-gate SELECT '!pqr', '#xyz'+5 FROM '@abc' 537c478bd9Sstevel@tonic-gate } 547c478bd9Sstevel@tonic-gate} {0 {!pqr 5}} 557c478bd9Sstevel@tonic-gatedo_test quote-1.3.2 { 567c478bd9Sstevel@tonic-gate catchsql { 577c478bd9Sstevel@tonic-gate SELECT "!pqr", "#xyz"+5 FROM '@abc' 587c478bd9Sstevel@tonic-gate } 597c478bd9Sstevel@tonic-gate} {0 {hello 10}} 607c478bd9Sstevel@tonic-gatedo_test quote-1.3 { 617c478bd9Sstevel@tonic-gate set r [catch { 627c478bd9Sstevel@tonic-gate execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'} 637c478bd9Sstevel@tonic-gate } msg ] 647c478bd9Sstevel@tonic-gate lappend r $msg 657c478bd9Sstevel@tonic-gate} {0 {hello 10}} 667c478bd9Sstevel@tonic-gatedo_test quote-1.4 { 677c478bd9Sstevel@tonic-gate set r [catch { 687c478bd9Sstevel@tonic-gate execsql {UPDATE '@abc' SET '#xyz'=11} 697c478bd9Sstevel@tonic-gate } msg ] 707c478bd9Sstevel@tonic-gate lappend r $msg 717c478bd9Sstevel@tonic-gate} {0 {}} 727c478bd9Sstevel@tonic-gatedo_test quote-1.5 { 737c478bd9Sstevel@tonic-gate set r [catch { 747c478bd9Sstevel@tonic-gate execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'} 757c478bd9Sstevel@tonic-gate } msg ] 767c478bd9Sstevel@tonic-gate lappend r $msg 777c478bd9Sstevel@tonic-gate} {0 {hello 16}} 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate# Drop the table with the strange name. 807c478bd9Sstevel@tonic-gate# 817c478bd9Sstevel@tonic-gatedo_test quote-1.6 { 827c478bd9Sstevel@tonic-gate set r [catch { 837c478bd9Sstevel@tonic-gate execsql {DROP TABLE '@abc'} 847c478bd9Sstevel@tonic-gate } msg ] 857c478bd9Sstevel@tonic-gate lappend r $msg 867c478bd9Sstevel@tonic-gate} {0 {}} 87*1da57d55SToomas Soome 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gatefinish_test 90