File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sqlite3 / test / keyword1.test
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 17:04:16 2012 UTC (12 years, 8 months ago) by misho
CVS tags: MAIN, HEAD
Initial revision

# 2009 January 29
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Verify that certain keywords can be used as identifiers.
#
# $Id: keyword1.test,v 1.1 2012/02/21 17:04:16 misho Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

db eval {
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES(1, 'one');
  INSERT INTO t1 VALUES(2, 'two');
  INSERT INTO t1 VALUES(3, 'three');
}

set kwlist {
  abort
  after
  analyze
  asc
  attach
  before
  begin
  by
  cascade
  cast
  column
  conflict
  current_date
  current_time
  current_timestamp
  database
  deferred
  desc
  detach
  end
  each
  exclusive
  explain
  fail
  for
  glob
  if
  ignore
  immediate
  initially
  instead
  key
  like
  match
  of
  offset
  plan
  pragma
  query
  raise
  regexp
  reindex
  release
  rename
  replace
  restrict
  rollback
  row
  savepoint
  temp
  temporary
  trigger
  vacuum
  view
  virtual
};
set exprkw {
  cast
  current_date
  current_time
  current_timestamp
  raise
}
foreach kw $kwlist {  
  do_test keyword1-$kw.1 {
    if {$kw=="if"} {
      db eval "CREATE TABLE \"$kw\"($kw $kw)"
    } else {
      db eval "CREATE TABLE ${kw}($kw $kw)"
    }
    db eval "INSERT INTO $kw VALUES(99)"
    db eval "INSERT INTO $kw SELECT a FROM t1"
    if {[lsearch $exprkw $kw]<0} {
      db eval "SELECT * FROM $kw ORDER BY $kw ASC"
    } else {
      db eval "SELECT * FROM $kw ORDER BY \"$kw\" ASC"
    }
  } {1 2 3 99}
  do_test keyword1-$kw.2 {
    if {$kw=="if"} {
      db eval "DROP TABLE \"$kw\""
      db eval "CREATE INDEX \"$kw\" ON t1(a)"
    } else {
      db eval "DROP TABLE $kw"
      db eval "CREATE INDEX $kw ON t1(a)"
    }
    db eval "SELECT b FROM t1 INDEXED BY $kw WHERE a=2"
  } {two}
}

finish_test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>