1bcdf78a6Sdrh# 2015-09-10 2bcdf78a6Sdrh# 3bcdf78a6Sdrh# The author disclaims copyright to this source code. In place of 4bcdf78a6Sdrh# a legal notice, here is a blessing: 5bcdf78a6Sdrh# 6bcdf78a6Sdrh# May you do good and not evil. 7bcdf78a6Sdrh# May you find forgiveness for yourself and forgive others. 8bcdf78a6Sdrh# May you share freely, never taking more than you give. 9bcdf78a6Sdrh# 10bcdf78a6Sdrh#*********************************************************************** 11bcdf78a6Sdrh# This file implements tests for sqlite3_value_subtype() and 12bcdf78a6Sdrh# sqlite3_result_subtype() interfaces. 13bcdf78a6Sdrh# 14bcdf78a6Sdrh 15bcdf78a6Sdrhset testdir [file dirname $argv0] 16bcdf78a6Sdrhsource $testdir/tester.tcl 17bcdf78a6Sdrh 18bcdf78a6Sdrhdo_execsql_test subtype1-100 { 19bcdf78a6Sdrh SELECT test_getsubtype('hello'); 20bcdf78a6Sdrh} {0} 21bcdf78a6Sdrhdo_execsql_test subtype1-110 { 22bcdf78a6Sdrh SELECT test_getsubtype(test_setsubtype('hello',123)); 23bcdf78a6Sdrh} {123} 24bcdf78a6Sdrhdo_execsql_test subtype1-120 { 25bcdf78a6Sdrh SELECT typeof(test_setsubtype('hello',123)); 26bcdf78a6Sdrh} {text} 27bcdf78a6Sdrhdo_execsql_test subtype1-130 { 28bcdf78a6Sdrh SELECT test_setsubtype('hello',123); 29bcdf78a6Sdrh} {hello} 30bcdf78a6Sdrh 318878f8a8Sdrh# 2022-06-09 328878f8a8Sdrh# https://sqlite.org/forum/forumpost/3d9caa45cbe38c78 338878f8a8Sdrh# 348878f8a8Sdrh# Avoid carrying subtypes through into a subquery that has been flattened 358878f8a8Sdrh# or to which the outer WHERE clause has been pushed down. 368878f8a8Sdrh# 378878f8a8Sdrhreset_db 388878f8a8Sdrhdo_execsql_test subtype1-200 { 398878f8a8Sdrh CREATE TABLE t1(a); INSERT INTO t1 VALUES ('x'); 408878f8a8Sdrh CREATE VIEW t2(b) AS SELECT json(TRUE); 418878f8a8Sdrh CREATE TABLE t3(b); INSERT INTO t3 VALUES(json(TRUE)); 428878f8a8Sdrh} 438878f8a8Sdrhdo_execsql_test subtype1-210 { 448878f8a8Sdrh SELECT * FROM t3, t1 WHERE NOT json_quote(b); 458878f8a8Sdrh} {1 x} 468878f8a8Sdrhdo_execsql_test subtype1-220 { 478878f8a8Sdrh SELECT * FROM t2, t1 WHERE NOT json_quote(b); 488878f8a8Sdrh} {1 x} 49*e5dea284Sdrhdo_execsql_test subtype1-230 { 50*e5dea284Sdrh WITH t4(a) AS MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4; 51*e5dea284Sdrh} {0} 52*e5dea284Sdrhdo_execsql_test subtype1-231 { 53*e5dea284Sdrh WITH t4(a) AS NOT MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4; 54*e5dea284Sdrh} {0} 558878f8a8Sdrh 568878f8a8Sdrh 578878f8a8Sdrh 588878f8a8Sdrh 59bcdf78a6Sdrhfinish_test 60