SQLite

Artifact [522469ca01]
Login

Artifact 522469ca013ff97c81b5367e730042290889a061:


# 2009 February 23
#
# 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 file is testing the reverse_select_order pragma.
#
# $Id: whereA.test,v 1.2 2009/04/06 12:26:58 drh Exp $

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

do_test whereA-1.1 {
  db eval {
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
    INSERT INTO t1 VALUES(1,2,3);
    INSERT INTO t1 values(2,'hello','world');
    INSERT INTO t1 VALUES(3,4.53,NULL);
    SELECT * FROM t1
  }
} {1 2 3 2 hello world 3 4.53 {}}
do_test whereA-1.2 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1;
  }
} {3 4.53 {} 2 hello world 1 2 3}

do_test whereA-1.3 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1 ORDER BY rowid;
  }
} {1 2 3 2 hello world 3 4.53 {}}

do_test whereA-2.1 {
  db eval {
    PRAGMA reverse_unordered_selects=0;
    SELECT * FROM t1 WHERE a>0;
  }
} {1 2 3 2 hello world 3 4.53 {}}
do_test whereA-2.2 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1 WHERE a>0;
  }
} {3 4.53 {} 2 hello world 1 2 3}

do_test whereA-2.3 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1 WHERE a>0 ORDER BY rowid;
  }
} {1 2 3 2 hello world 3 4.53 {}}

do_test whereA-3.1 {
  db eval {
    PRAGMA reverse_unordered_selects=0;
    SELECT * FROM t1 WHERE b>0;
  }
} {1 2 3 3 4.53 {} 2 hello world}
do_test whereA-3.2 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1 WHERE b>0;
  }
} {2 hello world 3 4.53 {} 1 2 3}
do_test whereA-3.3 {
  db eval {
    PRAGMA reverse_unordered_selects=1;
    SELECT * FROM t1 WHERE b>0 ORDER BY b;
  }
} {1 2 3 3 4.53 {} 2 hello world}

do_test whereA-4.1 {
  db eval {
    CREATE TABLE t2(x);
    INSERT INTO t2 VALUES(1);
    INSERT INTO t2 VALUES(2);
    SELECT x FROM t2;
  }
} {2 1}


finish_test