# 2008 August 28
#
# 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.
#
#***********************************************************************
#
# This file implements regression tests for SQLite library. The
# focus of this script is correct code generation of aliased result-set
# values. See ticket #3343.
#
# $Id: alias.test,v 1.3 2009/04/23 13:22:44 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Aliases are currently evaluated twice. We might try to change this
# in the future. But not now.
return
# A procedure to return a sequence of increasing integers.
#
namespace eval ::seq {
variable counter 0
proc value {args} {
variable counter
incr counter
return $counter
}
proc reset {} {
variable counter
set counter 0
}
}
do_test alias-1.1 {
db function sequence ::seq::value
db eval {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(9);
INSERT INTO t1 VALUES(8);
INSERT INTO t1 VALUES(7);
SELECT x, sequence() FROM t1;
}
} {9 1 8 2 7 3}
do_test alias-1.2 {
::seq::reset
db eval {
SELECT x, sequence() AS y FROM t1 WHERE y>0
}
} {9 1 8 2 7 3}
do_test alias-1.3 {
::seq::reset
db eval {
SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y0 AND y0 AND y