]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix minor problems on this branch.
authordan <dan@noemail.net>
Sat, 19 May 2018 14:15:29 +0000 (14:15 +0000)
committerdan <dan@noemail.net>
Sat, 19 May 2018 14:15:29 +0000 (14:15 +0000)
FossilOrigin-Name: 19c2e4b2f164521eab84cb0a0e12984be9431eaedd001dd3671e9ea1a6212353

manifest
manifest.uuid
src/expr.c
src/parse.y
src/select.c
test/permutations.test
test/window1.test
test/window2.tcl [new file with mode: 0644]
test/window2.test [new file with mode: 0644]

index d398b3ccfd717742d54cbfac1105d2f16de62a74..b33fe88ab5c33606b1c4e4a3746c366c87f13b58 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Evaluate\smultiple\swindow\sfunctions\sin\sa\ssingle\spass\sif\sthey\suse\sthe\ssame\nwindow\sdefinition.\sAdd\sxValue\scallbacks\sfor\sother\sbuilt-in\saggregate\nfunctions.
-D 2018-05-17T19:24:08.904
+C Fix\sminor\sproblems\son\sthis\sbranch.
+D 2018-05-19T14:15:29.031
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
@@ -445,7 +445,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
 F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6
 F src/dbstat.c edabb82611143727511a45ca0859b8cd037851ebe756ae3db289859dd18b6f91
 F src/delete.c b0f90749e22d5e41a12dbf940f4811138cf97da54b46b737089b93eb64a2896f
-F src/expr.c 75cef2e9fa3318c284faeea2c259100b7538776ca47573bf45b7b45c06ba0825
+F src/expr.c bb57b0b5ba1351335091ce4ec43b40968746f03afd65c9e2920d7cbe4dc98133
 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331
 F src/func.c b1a5122c69ef13c7bf0100e792ca539a36034c1b50476233ded6d2f72afcfbfc
@@ -482,7 +482,7 @@ F src/os_win.c ac29c25cde4cfb4adacc59cdec4aa45698ca0e29164ea127859585ccd9faa354
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c 1bb6a57fa0465296a4d6109a1a64610a0e7adde1f3acf3ef539a9d972908ce8f
 F src/pager.h c571b064df842ec8f2e90855dead9acf4cbe0d1b2c05afe0ef0d0145f7fd0388
-F src/parse.y 5df899a48f439c5e67e5194fe06ff28d928d2f531edc3169964f668eb16fee34
+F src/parse.y 9ae79a4f9df5d1ba474807361b3d66ae901d9502abe205fcf96a1dc7793d87fd
 F src/pcache.c 135ef0bc6fb2e3b7178d49ab5c9176254c8a691832c1bceb1156b2fbdd0869bd
 F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
 F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
@@ -493,7 +493,7 @@ F src/printf.c 1d1b4a568a58d0f32a5ff26c6b98db8a6e1883467f343a6406263cacd2e60c21
 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
 F src/resolve.c 446f60b2e0d2440bb233d6a69a4ed0f2ad030a4e63ac4b3cfc0e98cf73d9c5a3
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
-F src/select.c 2b4bc6bb66b85a9ba8bd4ad4161d0d6b32fcfdf6d472229a08364d3f0c407fe5
+F src/select.c 34a5cb9e6a37d4f7e25160ba0caeb02bccc1abee462805ba5f3fde9abc266873
 F src/shell.c.in 53affa90711f280342f7238f9c9aa9dcaed321ec6218a18043cf92154ef8a704
 F src/sqlite.h.in 34be2d0d18bf4726538793bdc9854cd87f689fda4b3789515134cdbd68188cf4
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@@ -1146,7 +1146,7 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854
 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
 F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
-F test/permutations.test a4c5c94c5f4e6c49004bf9b9b8b81201081e1d2d127cdda61bdb1c61dd0deb4e
+F test/permutations.test 10793f1de89a226fa22dde9ba9398de22571fee1bfb53a935a11be4aa014704f
 F test/pragma.test 7c8cfc328a1717a95663cf8edb06c52ddfeaf97bb0aee69ae7457132e8d39e7d
 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
 F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
@@ -1613,7 +1613,9 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
 F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
 F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
-F test/window1.test 5278e1578b55867e69e050376daef1eb6f6b4557fd728e5babb610c086af9f08
+F test/window1.test 5705337783d220b47f6fb4432264543b7557a05be8013d772f57d71f2fded271
+F test/window2.tcl f9df2fded8de70fc4252030775351b42440bc10aa2eb07d2f625e5d14a666775
+F test/window2.test 57c0500f98a08fd372f7fecf60f0d2ade58ad3373dad5031063d0a278fd79b18
 F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
 F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
 F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
@@ -1730,7 +1732,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 35af0b750e70dcf0f343b115f4bbd0860a7e8064be204d4dfba1a43c22ff07b1
-R e0e67ced56bb91a58c4c8146b7d7e3b8
+P c9f0f140941660ff368e5bb5752d54feb1964b7a9eac986d4bfb8f24a1c20d86
+R 6dddf8e93774e8d8cc7600c6ceb6a6b5
 U dan
-Z b68147f44c001ca2d08d81bf2dc7bdbf
+Z 12927ac87a28c4acd3b751d346125a3b
index 5641f29536dc7c79d26a1e971c2abd29952bf838..e8182e6ce4eee48e3c1da1bbf47530f59a82dfc9 100644 (file)
@@ -1 +1 @@
-c9f0f140941660ff368e5bb5752d54feb1964b7a9eac986d4bfb8f24a1c20d86
\ No newline at end of file
+19c2e4b2f164521eab84cb0a0e12984be9431eaedd001dd3671e9ea1a6212353
\ No newline at end of file
index c93ce3f443a6727b6ebb878d1bf9f21b296b248c..81aa66f690cbb5f2f05926b7980630f416c39de7 100644 (file)
@@ -3831,7 +3831,7 @@ expr_code_doover:
         pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0);
       }
 #endif
-      if( pDef==0 /* || pDef->xFinalize!=0 */ ){
+      if( pDef==0 || pDef->xFinalize!=0 ){
         sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
         break;
       }
index 1d1a2ddaac485c5bc7cc2d169681cb1583c2b8ae..a997ea4010e448509941eef431b5850ca4f93551 100644 (file)
@@ -1013,8 +1013,9 @@ expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP window(Z). {
     A->flags |= EP_Distinct;
   }
 }
-expr(A) ::= id(X) LP STAR RP. {
+expr(A) ::= id(X) LP STAR RP window(Z). {
   A = sqlite3ExprFunction(pParse, 0, &X);
+  sqlite3WindowAttach(pParse, A, Z);
 }
 term(A) ::= CTIME_KW(OP). {
   A = sqlite3ExprFunction(pParse, 0, &OP);
index 1b0bbe40e880acf4e05fd6855aa1b4d716a05da5..cbe3183c0f1e0b4e7577639cca327ac1df5d01c9 100644 (file)
@@ -4685,21 +4685,6 @@ static int selectExpander(Walker *pWalker, Select *p){
       assert( pFrom->pTab==0 );
       if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
       if( selectExpandSubquery(pParse, pFrom) ) return WRC_Abort;
-#if 0
-      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
-      if( pTab==0 ) return WRC_Abort;
-      pTab->nTabRef = 1;
-      if( pFrom->zAlias ){
-        pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);
-      }else{
-        pTab->zName = sqlite3MPrintf(db, "subquery_%p", (void*)pTab);
-      }
-      while( pSel->pPrior ){ pSel = pSel->pPrior; }
-      sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
-      pTab->iPKey = -1;
-      pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
-      pTab->tabFlags |= TF_Ephemeral;
-#endif
 #endif
     }else{
       /* An ordinary table or view name in the FROM clause */
index d240b34da88a088b1543ef7e5ef3dfca626724f8..52e2509fc1508c3f2bc4e45c22907d248edb3a83 100644 (file)
@@ -167,7 +167,7 @@ test_suite "veryquick" -prefix "" -description {
   that test malloc and IO errors are omitted.
 } -files [
   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
-      *fts5corrupt* *fts5big* *fts5aj* *expert* table.test
+      *fts5corrupt* *fts5big* *fts5aj*
 ]
 
 test_suite "extraquick" -prefix "" -description {
index 04d4380ae37a6f52c14f9baf5417c2b00501b77a..33664b30f0a968545674fb30a35e613f2317b3a9 100644 (file)
@@ -151,7 +151,7 @@ do_execsql_test 4.9 {
   6  21      3.0
 }
 
-do_execsql_test 4.10 {
+do_execsql_test 4.10.1 {
   SELECT a, 
     count() OVER (ORDER BY a DESC),
     group_concat(a, '.') OVER (ORDER BY a DESC) 
@@ -166,5 +166,20 @@ do_execsql_test 4.10 {
   0 7 6.5.4.3.2.1.0
 }
 
+do_execsql_test 4.10.2 {
+  SELECT a, 
+    count(*) OVER (ORDER BY a DESC),
+    group_concat(a, '.') OVER (ORDER BY a DESC) 
+  FROM t2 ORDER BY a DESC
+} {
+  6 1 6
+  5 2 6.5
+  4 3 6.5.4
+  3 4 6.5.4.3
+  2 5 6.5.4.3.2
+  1 6 6.5.4.3.2.1
+  0 7 6.5.4.3.2.1.0
+}
+
 
 finish_test
diff --git a/test/window2.tcl b/test/window2.tcl
new file mode 100644 (file)
index 0000000..9c567f2
--- /dev/null
@@ -0,0 +1,127 @@
+# 2018 May 19
+#
+# 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.
+#
+#***********************************************************************
+#
+
+package require sqlite3
+package require Pgtcl
+
+set db [pg_connect -conninfo "dbname=postgres user=postgres password=postgres"]
+sqlite3 sqlite ""
+
+proc execsql {sql} {
+
+  set lSql [list]
+  set frag ""
+  while {[string length $sql]>0} {
+    set i [string first ";" $sql]
+    if {$i>=0} {
+      append frag [string range $sql 0 $i]
+      set sql [string range $sql $i+1 end]
+      if {[sqlite complete $frag]} {
+        lappend lSql $frag
+        set frag ""
+      }
+    } else {
+      set frag $sql
+      set sql ""
+    }
+  }
+  if {$frag != ""} {
+    lappend lSql $frag
+  }
+  #puts $lSql
+
+  set ret [list]
+  foreach stmt $lSql {
+    set res [pg_exec $::db $stmt]
+    set err [pg_result $res -error]
+    if {$err!=""} { error $err }
+    for {set i 0} {$i < [pg_result $res -numTuples]} {incr i} {
+      lappend ret {*}[pg_result $res -getTuple $i]
+    }
+    pg_result $res -clear
+  }
+
+  set ret
+}
+
+proc execsql_test {tn sql} {
+  set res [execsql $sql]
+  puts $::fd "do_execsql_test $tn {"
+  puts $::fd "  [string trim $sql]"
+  puts $::fd "} {$res}"
+  puts $::fd ""
+}
+
+proc start_test {name date} {
+  set dir [file dirname $::argv0]
+  set output [file join $dir $name.test]
+  set ::fd [open $output w]
+puts $::fd [string trimleft "
+# $date
+#
+# 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+"]
+  puts $::fd {set testdir [file dirname $argv0]}
+  puts $::fd {source $testdir/tester.tcl}
+  puts $::fd "set testprefix $name"
+  puts $::fd ""
+}
+
+proc finish_test {} {
+  puts $::fd finish_test
+  close $::fd
+}
+
+#=========================================================================
+
+
+start_test window2 "2018 May 19"
+
+execsql_test 1.0 {
+  DROP TABLE IF EXISTS t1;
+  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+  INSERT INTO t1 VALUES(1, 'odd',  'one',   1);
+  INSERT INTO t1 VALUES(2, 'even', 'two',   2);
+  INSERT INTO t1 VALUES(3, 'odd',  'three', 3);
+  INSERT INTO t1 VALUES(4, 'even', 'four',  4);
+  INSERT INTO t1 VALUES(5, 'odd',  'five',  5);
+  INSERT INTO t1 VALUES(6, 'even', 'six',   6);
+}
+
+execsql_test 1.1 {
+  SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
+}
+
+execsql_test 1.2 {
+  SELECT sum(d) OVER () FROM t1;
+}
+
+execsql_test 1.3 {
+  SELECT sum(d) OVER (PARTITION BY b) FROM t1;
+}
+
+finish_test
+
+
diff --git a/test/window2.test b/test/window2.test
new file mode 100644 (file)
index 0000000..02b47ae
--- /dev/null
@@ -0,0 +1,45 @@
+# 2018 May 19
+#
+# 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window2
+
+do_execsql_test 1.0 {
+  DROP TABLE IF EXISTS t1;
+  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+  INSERT INTO t1 VALUES(1, 'odd',  'one',   1);
+  INSERT INTO t1 VALUES(2, 'even', 'two',   2);
+  INSERT INTO t1 VALUES(3, 'odd',  'three', 3);
+  INSERT INTO t1 VALUES(4, 'even', 'four',  4);
+  INSERT INTO t1 VALUES(5, 'odd',  'five',  5);
+  INSERT INTO t1 VALUES(6, 'even', 'six',   6);
+} {}
+
+do_execsql_test 1.1 {
+  SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
+} {four 4 six 10 two 12 five 5 one 6 three 9}
+
+do_execsql_test 1.2 {
+  SELECT sum(d) OVER () FROM t1;
+} {21 21 21 21 21 21}
+
+do_execsql_test 1.3 {
+  SELECT sum(d) OVER (PARTITION BY b) FROM t1;
+} {12 12 12 9 9 9}
+
+finish_test