summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/test/vtab2.test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sqlite/test/vtab2.test')
-rwxr-xr-xthird_party/sqlite/test/vtab2.test108
1 files changed, 108 insertions, 0 deletions
diff --git a/third_party/sqlite/test/vtab2.test b/third_party/sqlite/test/vtab2.test
new file mode 100755
index 0000000..5e7ac42
--- /dev/null
+++ b/third_party/sqlite/test/vtab2.test
@@ -0,0 +1,108 @@
+# 2006 June 10
+#
+# 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.
+#
+# $Id: vtab2.test,v 1.8 2008/01/31 15:53:46 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!schema_pragmas {
+ finish_test
+ return
+}
+
+register_schema_module [sqlite3_connection_pointer db]
+do_test vtab2-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE schema USING schema;
+ SELECT * FROM schema;
+ }
+} [list \
+ main schema 0 database {} 0 {} 0 \
+ main schema 1 tablename {} 0 {} 0 \
+ main schema 2 cid {} 0 {} 0 \
+ main schema 3 name {} 0 {} 0 \
+ main schema 4 type {} 0 {} 0 \
+ main schema 5 not_null {} 0 {} 0 \
+ main schema 6 dflt_value {} 0 {} 0 \
+ main schema 7 pk {} 0 {} 0 \
+]
+
+# See ticket #2230.
+#
+do_test vtab2-1.2 {
+ execsql {
+ SELECT length(tablename) FROM schema GROUP by tablename;
+ }
+} {6}
+do_test vtab2-1.3 {
+ execsql {
+ SELECT tablename FROM schema GROUP by length(tablename);
+ }
+} {schema}
+do_test vtab2-1.4 {
+ execsql {
+ SELECT length(tablename) FROM schema GROUP by length(tablename);
+ }
+} {6}
+
+register_tclvar_module [sqlite3_connection_pointer db]
+do_test vtab2-2.1 {
+ set ::abc 123
+ execsql {
+ CREATE VIRTUAL TABLE vars USING tclvar;
+ SELECT * FROM vars WHERE name='abc';
+ }
+} [list abc "" 123]
+do_test vtab2-2.2 {
+ set A(1) 1
+ set A(2) 4
+ set A(3) 9
+ execsql {
+ SELECT * FROM vars WHERE name='A';
+ }
+} [list A 1 1 A 2 4 A 3 9]
+unset -nocomplain result
+unset -nocomplain var
+set result {}
+foreach var [lsort [info vars tcl_*]] {
+ catch {lappend result $var [set $var]}
+}
+do_test vtab2-2.3 {
+ execsql {
+ SELECT name, value FROM vars
+ WHERE name MATCH 'tcl_*' AND arrayname = ''
+ ORDER BY name;
+ }
+} $result
+unset result
+unset var
+
+# Ticket #2894.
+#
+# Make sure we do call Column(), and Rowid() methods of
+# a virtual table when that table is in a LEFT JOIN.
+#
+do_test vtab2-3.1 {
+ execsql {
+ SELECT * FROM schema WHERE dflt_value IS NULL LIMIT 1
+ }
+} {main schema 0 database {} 0 {} 0}
+do_test vtab2-3.2 {
+ execsql {
+ SELECT *, b.rowid
+ FROM schema a LEFT JOIN schema b ON a.dflt_value=b.dflt_value
+ WHERE a.rowid=1
+ }
+} {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}
+
+finish_test