xref: /sqlite-3.40.0/test/func6.test (revision fe6d20e9)
1# 2017-12-16
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#
12# Test cases for the location() function.
13#
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16
17do_execsql_test func6-100 {
18  CREATE TABLE t1(a,b,c,d);
19  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
20   INSERT INTO t1(a,b,c,d) SELECT printf('abc%03x',x), x, 1000-x, NULL FROM c;
21}
22do_execsql_test func6-110 {
23  SELECT a, typeof(location(a)) FROM t1 ORDER BY rowid LIMIT 2;
24} {abc001 integer abc002 integer}
25do_execsql_test func6-120 {
26  SELECT a, typeof(location(+a)) FROM t1 ORDER BY rowid LIMIT 2;
27} {abc001 null abc002 null}
28do_execsql_test func6-130 {
29  CREATE INDEX t1a ON t1(a);
30  SELECT a, typeof(location(a)) FROM t1 ORDER BY a LIMIT 2;
31} {abc001 integer abc002 integer}
32do_execsql_test func6-140 {
33  SELECT a, typeof(location(a)) FROM t1 NOT INDEXED ORDER BY a LIMIT 2;
34} {abc001 integer abc002 integer}
35
36finish_test
37