Team Ai
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
sort2.test89 linesDownload Raw Back to test
1# 2014 March 25.2#3# The author disclaims copyright to this source code.  In place of4# 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# This file implements regression tests for SQLite library. 12#13# Specifically, the tests in this file attempt to verify that 14# multi-threaded sorting works.15#16 17set testdir [file dirname $argv0]18source $testdir/tester.tcl19set testprefix sort220db close21sqlite3_shutdown22sqlite3_config_pmasz 1023sqlite3_initialize24sqlite3 db test.db25 26foreach {tn script} {27  1 { }28  2 {29    catch { db close }30    reset_db31    catch { db eval {PRAGMA threads=7} }32  }33} {34  eval $script35 36  do_execsql_test $tn.1 {37    PRAGMA cache_size = 5;38    WITH r(x,y) AS (39      SELECT 1, randomblob(100)40      UNION ALL41      SELECT x+1, randomblob(100) FROM r42      LIMIT 10000043    )44    SELECT count(x), length(y) FROM r GROUP BY (x%5)45  } {46    20000 100 20000 100 20000 100 20000 100 20000 10047  }48 49  do_execsql_test $tn.2.1 {50    CREATE TABLE t1(a, b);51    WITH r(x,y) AS (52      SELECT 1, randomblob(100)53      UNION ALL54      SELECT x+1, randomblob(100) FROM r55      LIMIT 1000056    ) INSERT INTO t1 SELECT * FROM r;57  }58  59  do_execsql_test $tn.2.2 {60    CREATE UNIQUE INDEX i1 ON t1(b, a);61  }62  63  do_execsql_test $tn.2.3 {64    CREATE UNIQUE INDEX i2 ON t1(a);65  }66  67  do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok}68  69  # Because it uses so much data, this test can take 12-13 seconds even on70  # a modern workstation. So it is omitted from "veryquick" and other71  # permutations.test tests.72  if {[isquick]==0 && [clang_sanitize_address]==0} {73    do_execsql_test $tn.3 {74      PRAGMA cache_size = 5;75      WITH r(x,y) AS (76          SELECT 1, randomblob(100)77          UNION ALL78          SELECT x+1, randomblob(100) FROM r79          LIMIT 100000080          )81        SELECT count(x), length(y) FROM r GROUP BY (x%5)82    } {83      200000 100 200000 100 200000 100 200000 100 200000 10084    }85  }86}87 88finish_test89