From fb0878ac38d23ebf699109e2c472e0469dd67be3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 14 Oct 2026 18:39:44 +0000 Subject: [PATCH] Fix indexes on typeless generated columns that pull from REAL columns so that they correctly return REAL values. [bugs:/info/2026-10-14T17:34:30Z|Bug 2026-10-14T17:34:30Z]. FossilOrigin-Name: 7408f90ecc2dd26aceb52f92de78b8e1521cb5a294d3231fd32a903afe1db41d --- manifest | 14 ++-- manifest.uuid | 2 +- src/delete.c | 5 +- test/gencol1.test | 167 ++++++++++++++++++++++++++-------------------- 4 files changed, 105 insertions(+), 83 deletions(-) diff --git a/manifest b/manifest index 4d88207fd1..88fbffec84 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sjson_tree()\swhen\sit\sis\sgiven\sa\sroot\sthat\sends\swith\san\sarray\sindex\sso\nthat\sit\sreturns\sthe\scorrect\s"key"\sfor\sthe\sfirst\sroot.\s\sThis\swas\sbroken\nby\scheck-in\s[858b76a00e8ff552]\sand\sin\sversion\s3.45.0.\s\sProblem\sreported\nby\s[forum:/info/2026-10-14T08:42:26Z|Forum\spost\s2026-10-14T08:42:26Z]. -D 2026-10-14T17:52:44.574 +C Fix\sindexes\son\stypeless\sgenerated\scolumns\sthat\spull\sfrom\sREAL\scolumns\sso\nthat\sthey\scorrectly\sreturn\sREAL\svalues.\n[bugs:/info/2026-10-14T17:34:30Z|Bug\s2026-10-14T17:34:30Z]. +D 2026-10-14T18:39:44.984 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -754,7 +754,7 @@ F src/complete.c f68f545b9c6c19e2e848672dc0e4da230072fedc335d8980b55242cc4cfa60d F src/date.c 080641f59097d14fc7341f8bc0458d273b3a62d8381916db8ccbc89c2aae07b3 F src/dbpage.c ec8590c5e7a564cef28ca3c6156521316a4d26cb572a34841b0bcb26b67b3f97 F src/dbstat.c 34d4e825fbf763640ce3dbc56910ab080495ef4a6efb48b2b1852a43d43763fc -F src/delete.c 59eeca3fb88c29329afc41bb803ee568b120d9dd7470b5f38ab55cc38390b451 +F src/delete.c f3f07c1fb6ac87fac2425d48fd40ecb2f24a4495a9966f5a939668d3576916c8 F src/expr.c e4097826bbb853e233c1f4f27fd93f2ebc48104eb88d7ac9ba0541ddb631d5c7 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 26788ae6c785d70f9829c4176e9764447014fc73e6ba31e9f1881720a64ae7f1 @@ -1340,7 +1340,7 @@ F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc F test/fuzzinvariants.c 12e6bd4b878bce8627e72ba6a228f72ea30c242fe12a5210d058210fb237caba F test/gcfault.test 4ea410ac161e685f17b19e1f606f58514a2850e806c65b846d05f60d436c5b0d -F test/gencol1.test ceb3163b59cb77f4ad57ae4f01a143ce36b06fdd6a8dab1149235db89979ffd8 +F test/gencol1.test 7e5b0dacbe12d909890c80a77382b25104e668b13a6a377ab1e4a141e5d86e1b F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/having.test a89236dd8d55aa50c4805f82ac9daf64d477a44d712d8209c118978d0ca21ec9 F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 @@ -2289,8 +2289,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P b7ebfea1c1fd4a4d70f1e429c4ad5d21502e10ab28f90bdb7ae1da2df417cf8b -R 3f1448a6708915bf4329e06e60d98963 +P eaf646e376a5a3e10a874ed1c07ca1382f0ccb7cdf1cc963697638a54b98c779 +R cd5e05e09f37035495964650d20d3282 U drh -Z f9f5896078163a8ca87e19dbd687eb77 +Z 60c70d9c1707258a8e85a246e04bf473 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 329d4e6adf..77a70bb840 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eaf646e376a5a3e10a874ed1c07ca1382f0ccb7cdf1cc963697638a54b98c779 +7408f90ecc2dd26aceb52f92de78b8e1521cb5a294d3231fd32a903afe1db41d diff --git a/src/delete.c b/src/delete.c index 0b0b461afc..6e17c68bd4 100644 --- a/src/delete.c +++ b/src/delete.c @@ -997,6 +997,7 @@ int sqlite3GenerateIndexKey( regBase = sqlite3GetTempRange(pParse, nCol); if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0; for(j=0; jaiColumn[j]==pIdx->aiColumn[j] && pPrior->aiColumn[j]!=XN_EXPR @@ -1005,7 +1006,9 @@ int sqlite3GenerateIndexKey( continue; } sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j); - if( pIdx->aiColumn[j]>=0 ){ + if( (iTabCol = pIdx->aiColumn[j])>=0 + && (pIdx->pTable->aCol[iTabCol].colFlags & COLFLAG_VIRTUAL)==0 + ){ /* If the column affinity is REAL but the number is an integer, then it ** might be stored in the table as an integer (using a compact ** representation) then converted to REAL by an OP_RealAffinity opcode. diff --git a/test/gencol1.test b/test/gencol1.test index a247a7148d..45788df234 100644 --- a/test/gencol1.test +++ b/test/gencol1.test @@ -14,9 +14,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix gencol1 # ticket 830277d9db6c3ba1 on 2019-10-31 -do_execsql_test gencol1-100 { +do_execsql_test 100 { CREATE TABLE t0(c0 AS(TYPEOF(c1)), c1); INSERT INTO t0(c1) VALUES(0); CREATE TABLE t1(x AS (typeof(y)), y); @@ -104,42 +105,42 @@ foreach {tn schema} { catch {db close} sqlite3 db :memory: db eval $schema - do_execsql_test gencol1-2.$tn.100 { + do_execsql_test 2.$tn.100 { INSERT INTO t1(a,b,c) VALUES(1,'abcdef',5.5),(3,'cantaloupe',NULL); SELECT w, x, y, '|' FROM t1 ORDER BY a; } {10 real abc | 30 null ntalo |} - do_execsql_test gencol1-2.$tn.101 { + do_execsql_test 2.$tn.101 { SELECT w, x, y, '|' FROM t1 ORDER BY w; } {10 real abc | 30 null ntalo |} - do_execsql_test gencol1-2.$tn.102 { + do_execsql_test 2.$tn.102 { SELECT a FROM t1 WHERE w=30; } {3} - do_execsql_test gencol1-2.$tn.103 { + do_execsql_test 2.$tn.103 { SELECT a FROM t1 WHERE x='real'; } {1} - do_execsql_test gencol1-2.$tn.104 { + do_execsql_test 2.$tn.104 { SELECT a FROM t1 WHERE y LIKE '%tal%' OR x='real' ORDER BY b; } {1 3} - do_execsql_test gencol1-2.$tn.110 { + do_execsql_test 2.$tn.110 { CREATE INDEX t1w ON t1(w); SELECT a FROM t1 WHERE w=10; } {1} - do_execsql_test gencol1-2.$tn.120 { + do_execsql_test 2.$tn.120 { CREATE INDEX t1x ON t1(x) WHERE w BETWEEN 20 AND 40; SELECT a FROM t1 WHERE x='null' AND w BETWEEN 20 AND 40; } {3} - do_execsql_test gencol1-2.$tn.121 { + do_execsql_test 2.$tn.121 { SELECT a FROM t1 WHERE x='real'; } {1} - do_execsql_test gencol1-2.$tn.130 { + do_execsql_test 2.$tn.130 { VACUUM; PRAGMA integrity_check; } {ok} - do_execsql_test gencol1-2.$tn.140 { + do_execsql_test 2.$tn.140 { UPDATE t1 SET a=a+100 WHERE w<20; SELECT a, w, '|' FROM t1 ORDER BY w; } {3 30 | 101 1010 |} - do_execsql_test gencol1-2.$tn.150 { + do_execsql_test 2.$tn.150 { INSERT INTO t1 VALUES(4,'jambalaya','Chef John'),(15,87719874135,0); SELECT w, x, y, '|' FROM t1 ORDER BY w; } {30 null ntalo | 40 text balaya | 150 integer {} | 1010 real {} |} @@ -148,21 +149,21 @@ foreach {tn schema} { # 2019-10-31 ticket b9befa4b83a660cc db close sqlite3 db :memory: -do_execsql_test gencol1-3.100 { +do_execsql_test 3.100 { PRAGMA foreign_keys = true; CREATE TABLE t0(c0 PRIMARY KEY, c1, c2 AS (c0+c1-c3) REFERENCES t0, c3); INSERT INTO t0 VALUES (0, 0, 0), (11, 5, 5); UPDATE t0 SET c1 = c0, c3 = c0; SELECT *, '|' FROM t0 ORDER BY +c0; } {0 0 0 0 | 11 11 11 11 |} -do_catchsql_test gencol1-3.110 { +do_catchsql_test 3.110 { UPDATE t0 SET c1 = c0, c3 = c0+1; } {1 {FOREIGN KEY constraint failed}} # 2019-11-01 ticket c28a01da72f8957c db close sqlite3 db :memory: -do_execsql_test gencol1-4.100 { +do_execsql_test 4.100 { CREATE TABLE t0 ( c0, c1 a UNIQUE AS (1), @@ -172,14 +173,14 @@ do_execsql_test gencol1-4.100 { PRAGMA foreign_keys = true; INSERT INTO t0(c0,c2,c3) VALUES(0,0,1); } {} -do_catchsql_test gencol1-4.110 { +do_catchsql_test 4.110 { REPLACE INTO t0(c0,c2,c3) VALUES(0,0,0),(0,0,0); } {1 {FOREIGN KEY constraint failed}} # 2019-11-01 Problem found while adding new foreign key test cases in TH3. db close sqlite3 db :memory: -do_execsql_test gencol1-5.100 { +do_execsql_test 5.100 { PRAGMA foreign_keys=ON; CREATE TABLE t1( gcb AS (b*1), @@ -205,7 +206,7 @@ do_execsql_test gencol1-5.100 { SELECT id,x,'|' FROM t1a ORDER BY id; } {1 1 | 3 7 |} -do_catchsql_test gencol1-6.10 { +do_catchsql_test 6.10 { DROP TABLE IF EXISTS t0; CREATE TABLE t0(c0 NOT NULL AS(c1), c1); REPLACE INTO t0(c1) VALUES(NULL); @@ -219,24 +220,24 @@ do_catchsql_test gencol1-6.10 { # constraints on tables that have generated columns. # reset_db -do_execsql_test gencol1-7.10 { +do_execsql_test 7.10 { CREATE TABLE t0 (c0 GENERATED ALWAYS AS (1), c1 UNIQUE, c2 UNIQUE); INSERT INTO t0(c1) VALUES (1); SELECT quote(0 = t0.c2 OR t0.c1 BETWEEN t0.c2 AND 1) FROM t0; } {NULL} -do_execsql_test gencol1-7.11 { +do_execsql_test 7.11 { DROP TABLE t0; CREATE TABLE t0(c0 NOT NULL DEFAULT 'xyz', c1 AS(c0) NOT NULL); REPLACE INTO t0(c0) VALUES(NULL); SELECT * FROM t0; } {xyz xyz} -do_execsql_test gencol1-7.12 { +do_execsql_test 7.12 { DROP TABLE t0; CREATE TABLE t0(c0 NOT NULL DEFAULT 'xyz', c1 AS(c0) STORED NOT NULL); REPLACE INTO t0(c0) VALUES(NULL); SELECT * FROM t0; } {xyz xyz} -do_execsql_test gencol1-7.20 { +do_execsql_test 7.20 { CREATE TABLE t1( a NOT NULL DEFAULT 'aaa', b AS(c) NOT NULL, @@ -244,7 +245,7 @@ do_execsql_test gencol1-7.20 { REPLACE INTO t1(a,c) VALUES(NULL,NULL); SELECT * FROM t1; } {aaa ccc ccc} -do_execsql_test gencol1-7.21 { +do_execsql_test 7.21 { DROP TABLE t1; CREATE TABLE t1( a NOT NULL DEFAULT 'aaa', @@ -253,7 +254,7 @@ do_execsql_test gencol1-7.21 { REPLACE INTO t1(a,c) VALUES(NULL,NULL); SELECT * FROM t1; } {aaa ccc ccc} -do_execsql_test gencol1-7.30 { +do_execsql_test 7.30 { CREATE TABLE t2( a NOT NULL DEFAULT 'aaa', b AS(a) NOT NULL, @@ -261,7 +262,7 @@ do_execsql_test gencol1-7.30 { REPLACE INTO t2(a,c) VALUES(NULL,NULL); SELECT * FROM t2; } {aaa aaa ccc} -do_execsql_test gencol1-7.31 { +do_execsql_test 7.31 { DROP TABLE t2; CREATE TABLE t2( a NOT NULL DEFAULT 'aaa', @@ -270,25 +271,25 @@ do_execsql_test gencol1-7.31 { REPLACE INTO t2(a,c) VALUES(NULL,NULL); SELECT * FROM t2; } {aaa aaa ccc} -do_execsql_test gencol1-7.40 { +do_execsql_test 7.40 { CREATE TABLE t3(a NOT NULL DEFAULT 123, b AS(a) UNIQUE); REPLACE INTO t3 VALUES(NULL); SELECT * FROM t3; } {123 123} -do_execsql_test gencol1-7.41 { +do_execsql_test 7.41 { SELECT * FROM t3 WHERE b=123; } {123 123} -do_execsql_test gencol1-7.50 { +do_execsql_test 7.50 { CREATE TABLE t4(a NOT NULL DEFAULT 123, b AS(a*10+4) STORED UNIQUE); REPLACE INTO t4 VALUES(NULL); SELECT * FROM t4; } {123 1234} -do_execsql_test gencol1-7.51 { +do_execsql_test 7.51 { SELECT * FROM t4 WHERE b=1234; } {123 1234} # 2019-11-06 ticket 4fc08501f4e56692 -do_execsql_test gencol1-8.10 { +do_execsql_test 8.10 { DROP TABLE IF EXISTS t0; CREATE TABLE t0( c0 AS (('a', 9) < ('b', c1)), @@ -298,7 +299,7 @@ do_execsql_test gencol1-8.10 { INSERT INTO t0 VALUES (0),(99); SELECT * FROM t0; } {1 1 0 1 1 99} -do_catchsql_test gencol1-8.20 { +do_catchsql_test 8.20 { DROP TABLE IF EXISTS t0; CREATE TABLE t0( c0, @@ -311,7 +312,7 @@ do_catchsql_test gencol1-8.20 { # 2019-11-21 Problems in the new generated column logic # reported by Yongheng Chen and Rui Zhong reset_db -do_execsql_test gencol1-9.10 { +do_execsql_test 9.10 { PRAGMA foreign_keys=OFF; CREATE TABLE t1(aa , bb AS (17) UNIQUE); INSERT INTO t1 VALUES(17); @@ -319,7 +320,7 @@ do_execsql_test gencol1-9.10 { INSERT INTO t2 VALUES(41); SELECT * FROM t2 JOIN t1 WHERE t1.bb=t1.aa AND t1.bb=17; } {41 17 17} -do_execsql_test gencol1-9.20 { +do_execsql_test 9.20 { CREATE TABLE t3(aa INT PRIMARY KEY, bb UNIQUE AS(aa)); INSERT INTO t3 VALUES(1); SELECT 100, * FROM t3; @@ -331,7 +332,7 @@ do_execsql_test gencol1-9.20 { # does already exist. # sqlite3 db :memory: -do_execsql_test gencol1-10.10 { +do_execsql_test 10.10 { CREATE TABLE t1(aa,bb); CREATE TABLE IF NOT EXISTS t1(aa, bb AS (aa+1)); PRAGMA integrity_check; @@ -340,7 +341,7 @@ do_execsql_test gencol1-10.10 { # 2019-12-06 Found by mrigger # sqlite3 db :memory: -do_execsql_test gencol1-11.10 { +do_execsql_test 11.10 { PRAGMA foreign_keys = true; CREATE TABLE t0( c0, @@ -350,10 +351,10 @@ do_execsql_test gencol1-11.10 { FOREIGN KEY(c1) REFERENCES t0(c2) ); } -do_catchsql_test gencol1-11.20 { +do_catchsql_test 11.20 { INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0) } {1 {FOREIGN KEY constraint failed}} -do_execsql_test gencol1-11.30 { +do_execsql_test 11.30 { DROP TABLE t0; CREATE TABLE t0( c0, @@ -363,10 +364,10 @@ do_execsql_test gencol1-11.30 { FOREIGN KEY(c1) REFERENCES t0(c2) ); } -do_catchsql_test gencol1-11.40 { +do_catchsql_test 11.40 { INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0) } {1 {FOREIGN KEY constraint failed}} -do_execsql_test gencol1-11.50 { +do_execsql_test 11.50 { DROP TABLE t0; CREATE TABLE t0( c0, @@ -376,10 +377,10 @@ do_execsql_test gencol1-11.50 { FOREIGN KEY(c1) REFERENCES t0(c2) ); } -do_catchsql_test gencol1-11.60 { +do_catchsql_test 11.60 { INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0) } {1 {FOREIGN KEY constraint failed}} -do_execsql_test gencol1-11.70 { +do_execsql_test 11.70 { DROP TABLE t0; CREATE TABLE t0( c3 BLOB GENERATED ALWAYS AS (1), @@ -389,7 +390,7 @@ do_execsql_test gencol1-11.70 { FOREIGN KEY(c1) REFERENCES t0(c2) ); } -do_catchsql_test gencol1-11.80 { +do_catchsql_test 11.80 { INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0) } {1 {FOREIGN KEY constraint failed}} @@ -401,7 +402,7 @@ do_catchsql_test gencol1-11.80 { # PRAGMA integrity_check code. # sqlite3 db :memory: -do_execsql_test gencol1-12.10 { +do_execsql_test 12.10 { CREATE TABLE t0 (c0, c1 NOT NULL AS (c0==0)); INSERT INTO t0(c0) VALUES (0); PRAGMA integrity_check; @@ -411,39 +412,39 @@ do_execsql_test gencol1-12.10 { # Ensure that the SrcList_item.colUsed field is set correctly when a # generated column appears in the USING clause of a join. # -do_execsql_test gencol1-13.10 { +do_execsql_test 13.10 { CREATE TABLE t1(x, y AS(x+1)); INSERT INTO t1 VALUES(10); SELECT y FROM t1 JOIN t1 USING (y,y); } {11} -do_execsql_test gencol1-13.11 { +do_execsql_test 13.11 { SELECT 123 FROM t1 JOIN t1 USING (x); } {123} -do_execsql_test gencol1-13.11 { +do_execsql_test 13.11 { SELECT 456 FROM t1 JOIN t1 USING (x,x); } {456} -do_execsql_test gencol1-13.20 { +do_execsql_test 13.20 { CREATE INDEX t1y ON t1(y); SELECT y FROM t1 JOIN t1 USING (y,y); } {11} -do_execsql_test gencol1-13.21 { +do_execsql_test 13.21 { CREATE INDEX t1x ON t1(x); SELECT 123 FROM t1 JOIN t1 USING (x); } {123} -do_execsql_test gencol1-13.22 { +do_execsql_test 13.22 { SELECT 456 FROM t1 JOIN t1 USING (x,x); } {456} # 2019-12-14 ticket b439bfcfb7deedc6 # sqlite3 db :memory: -do_execsql_test gencol1-14.10 { +do_execsql_test 14.10 { CREATE TABLE t0(c0 AS(1 >= 1), c1 UNIQUE AS(TYPEOF(c0)), c2); INSERT INTO t0 VALUES(0); REINDEX; SELECT * FROM t0; } {1 integer 0} -do_catchsql_test gencol1-14.10 { +do_catchsql_test 14.10 { INSERT INTO t0 VALUES(2); } {1 {UNIQUE constraint failed: t0.c1}} @@ -458,7 +459,7 @@ do_catchsql_test gencol1-14.10 { # to the schema. # reset_db -do_test gencol1-15.10 { +do_test 15.10 { sqlite3 db {} db deserialize [decode_hexdb { | size 8192 pagesize 4096 filename c27.db @@ -478,7 +479,7 @@ do_test gencol1-15.10 { | 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................ | end c27.db }]} {} -do_execsql_test gencol1-15.20 { +do_execsql_test 15.20 { PRAGMA writable_schema=ON; REPLACE INTO t1 VALUES(9); SELECT a, quote(b) FROM t1 @@ -488,22 +489,22 @@ do_execsql_test gencol1-15.20 { # When a table is the right table of a LEFT JOIN and the ON clause is # false, make sure any generated columns evaluate to NULL. reset_db -do_execsql_test gencol1-16.10 { +do_execsql_test 16.10 { CREATE TABLE t0(c0); CREATE TABLE t1(c1, c2 AS(1)); INSERT INTO t0 VALUES(0); SELECT c0, c1, c2 FROM t0 LEFT JOIN t1; } {0 {} {}} -do_execsql_test gencol1-16.20 { +do_execsql_test 16.20 { DROP TABLE t1; CREATE TABLE t1(c1, c2 AS (c1 ISNULL)); SELECT c0, c1, c2 FROM t0 LEFT JOIN t1; } {0 {} {}} -do_execsql_test gencol1-16.30 { +do_execsql_test 16.30 { INSERT INTO t1(c1) VALUES(1),(NULL); SELECT * FROM t1; } {1 0 {} 1} -do_execsql_test gencol1-16.40 { +do_execsql_test 16.40 { SELECT c0, c1, c2 FROM t0 LEFT JOIN t1 ON c0=c1; } {0 {} {}} @@ -512,23 +513,23 @@ do_execsql_test gencol1-16.40 { # opcode applied, even when the column value is extracted from an index. # reset_db -do_execsql_test gencol1-17.10 { +do_execsql_test 17.10 { CREATE TABLE t0(c0 REAL AS(1) UNIQUE, c1 INT); INSERT INTO t0 VALUES(''); SELECT quote(c0), quote(c1) from t0; } {1.0 ''} -do_execsql_test gencol1-17.20 { +do_execsql_test 17.20 { SELECT *, (1 BETWEEN CAST(t0.c0 AS TEXT) AND t0.c0) FROM t0; } {1.0 {} 0} -do_execsql_test gencol1-17.30 { +do_execsql_test 17.30 { SELECT * FROM t0 WHERE (1 BETWEEN CAST(t0.c0 AS TEXT) AND t0.c0); } {} -do_execsql_test gencol1-17.40 { +do_execsql_test 17.40 { CREATE TABLE t1(a TEXT AS(b) COLLATE nocase, b TEXT, c INT, d DEFAULT 1); INSERT INTO t1(b,c) VALUES('abc',11),('DEF',22),('ghi',33); SELECT a FROM t1 WHERE b='DEF' AND a='def'; } {DEF} -do_execsql_test gencol1-17.50 { +do_execsql_test 17.50 { CREATE INDEX t1bca ON t1(b,c,a); SELECT a FROM t1 WHERE b='DEF' AND a='def'; } {DEF} @@ -538,12 +539,12 @@ do_execsql_test gencol1-17.50 { # ever do such a thing?) can cause problems for a one-pass DELETE. # reset_db -do_execsql_test gencol1-18.10 { +do_execsql_test 18.10 { CREATE TABLE t0(c0 UNIQUE AS(0), c1, c2); INSERT INTO t0(c1) VALUES(0); SELECT * FROM t0; } {0 0 {}} -do_execsql_test gencol1-18.20 { +do_execsql_test 18.20 { UPDATE t0 SET c1=0, c2=0 WHERE c0>=0; SELECT * FROM t0; } {0 0 0} @@ -551,7 +552,7 @@ do_execsql_test gencol1-18.20 { # 2019-12-27 ticket de4b04149b9fdeae # reset_db -do_catchsql_test gencol1-19.10 { +do_catchsql_test 19.10 { CREATE TABLE t0( c0 INT AS(2) UNIQUE, c1 TEXT UNIQUE, @@ -563,7 +564,7 @@ do_catchsql_test gencol1-19.10 { # 2020-06-29 forum bug report. # https://sqlite.org/forum/forumpost/73b9a8ccfb # -do_execsql_test gencol1-20.1 { +do_execsql_test 20.1 { CREATE TEMPORARY TABLE tab ( prim DATE PRIMARY KEY, a INTEGER, @@ -576,7 +577,7 @@ do_execsql_test gencol1-20.1 { -- Check that each column is 0 like I expect SELECT * FROM tab; } {2001-01-01 0 0 0 {}} -do_execsql_test gencol1-20.2 { +do_execsql_test 20.2 { -- Do an UPSERT on the b column INSERT INTO tab (prim, b) VALUES ('2001-01-01',5) @@ -589,7 +590,7 @@ do_execsql_test gencol1-20.2 { # ifcapable vtab { reset_db - do_execsql_test gencol1-21.1 { + do_execsql_test 21.1 { CREATE TABLE t1( a integer primary key, b int generated always as (a+5), @@ -607,7 +608,7 @@ reset_db # 2021-09-07 forum https://sqlite.org/forum/forumpost/699b44b3ee # reset_db -do_execsql_test gencol1-22.1 { +do_execsql_test 22.1 { CREATE TABLE t0(a PRIMARY KEY,b TEXT AS ('2') UNIQUE); INSERT INTO t0(a) VALUES(2); SELECT * FROM t0 AS x JOIN t0 AS y @@ -634,12 +635,12 @@ foreach t1 $typelist { INSERT INTO t1(x) VALUES(NULL),('1'),(2),(3.5),('xyz'); " set x1 [lsort [db eval {SELECT typeof(b) FROM t1}]] - do_test gencol1-23.1.$cnt { + do_test 23.1.$cnt { lsort [db eval {SELECT typeof(b) FROM t1 INDEXED BY x2}] } $x1 } } -do_execsql_test gencol1-23.2 { +do_execsql_test 23.2 { DROP TABLE t1; CREATE TABLE t1( x, @@ -650,11 +651,11 @@ do_execsql_test gencol1-23.2 { INSERT INTO t1(x) VALUES(NULL),('1'),('xyz'),(2),(3.5); SELECT quote(a) FROM t1 INDEXED BY x2; } {NULL 1 2 3.5 'xyz'} -do_execsql_test gencol1-23.3 { +do_execsql_test 23.3 { EXPLAIN SELECT a FROM t1 INDEXED BY x2; } {~/Column 0/} # ^^^^^^^^---- verfies that x2 acts like a covering index -do_execsql_test gencol1-23.4 { +do_execsql_test 23.4 { EXPLAIN SELECT b FROM t1 INDEXED BY x2; } {/Column 0/} # ^^^^^^^^^^--- Must reference the original table in this case because @@ -662,8 +663,26 @@ do_execsql_test gencol1-23.4 { # 2023-03-07 https://sqlite.org/forum/forumpost/b312e075b5 # -do_catchsql_test gencol1-23.5 { +do_catchsql_test 23.5 { CREATE TABLE v0(c1 INT, c2 AS (RAISE(IGNORE))); } {1 {RAISE() may only be used within a trigger-program}} +# Bug 2026-10-14T17:34:30Z +# +do_execsql_test 24.0 { + CREATE TABLE t(a REAL, b AS (a) VIRTUAL); + INSERT INTO t(a) VALUES(1.0); + CREATE INDEX i ON t(b); +} +do_execsql_test 24.1 { + SELECT b, typeof(b) FROM t NOT INDEXED; +} {1.0 real} +do_execsql_test 24.2 { + SELECT b, typeof(b) FROM t INDEXED BY i; +} {1.0 real} +do_execsql_test 24.3 { + SELECT b, typeof(b) FROM t WHERE b = 1; +} {1.0 real} + + finish_test