]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In a 3-fold compound SELECT make sure early code generation of the SELECTs
authordrh <drh@noemail.net>
Thu, 16 Apr 2009 00:24:23 +0000 (00:24 +0000)
committerdrh <drh@noemail.net>
Thu, 16 Apr 2009 00:24:23 +0000 (00:24 +0000)
to the right do not dereference non-existant columns in SELECTs on the left. (CVS 6511)

FossilOrigin-Name: 414f340809c487901fa913026a342b19a2956c0a

manifest
manifest.uuid
src/select.c
test/select4.test

index 0f2206c2965f2628f4bbcc8011783bff33fb48e4..a78ad5cab71bafe2cea71feee5dc6bfb33141e59 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sgroup_concat()\sfunction\sso\sthat\sit\sinserts\sthe\sseparator\sstring\neven\sif\sthe\sinitial\scontent\sstrings\sare\sempty.\s\sTicket\s#3806.\s(CVS\s6510)
-D 2009-04-15T15:16:53
+C In\sa\s3-fold\scompound\sSELECT\smake\ssure\searly\scode\sgeneration\sof\sthe\sSELECTs\nto\sthe\sright\sdo\snot\sdereference\snon-existant\scolumns\sin\sSELECTs\son\sthe\sleft.\s(CVS\s6511)
+D 2009-04-16T00:24:24
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -155,7 +155,7 @@ F src/printf.c ea2d76000cc5f4579d7e9cb2f5460433eec0d384
 F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
 F src/resolve.c 094e44450371fb27869eb8bf679aacbe51fdc56d
 F src/rowset.c badb9f36b3a2ced9ee9551f4ce730f5fab442791
-F src/select.c 462d9671e91accd983110fa38674be0d2a3daa66
+F src/select.c 35225756c247484f473678e5bd191d70a6e4dba0
 F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7
 F src/sqlite.h.in 1537d33b86d022f53a97009e2a0e2229badc23cf
 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
@@ -518,7 +518,7 @@ F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5
 F test/select1.test 7de2cabb417c142c40e5b8005855b8bd4eedc9e7
 F test/select2.test 9735da20ccd41e42bf2b4c19fd939141b591adae
 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054
-F test/select4.test b64d5d248d008e1dc365f451c76090bde907e665
+F test/select4.test 44aa6e7110592e18110b0b9cf5c024d37d23be17
 F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535
 F test/select6.test 2b5e8500d8ec3dd4c8e0c99eb1431b3d11fcc24c
 F test/select7.test 7906735805cfbee4dddc0bed4c14e68d7f5f9c5f
@@ -717,7 +717,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P e203ad400dd61431b3e6b8219eb5357b6ca06561
-R 08374e872e7a2a83a20b5c0b0a651c1a
+P b83fbf15a3920755ed77dc9c91b4f00a86ddb9ac
+R 1b07912c8c6ff40738cf08bdcff2243f
 U drh
-Z a006ab98ab05ae9fc2b427cfcf96e911
+Z 5dd358d6f1180bed564e211b297b0523
index c1e5b4922b0425fa39c8c5552221b3e9a089fc57..8f4fe90ebcad9333ec20153657ec414ed0c6a010 100644 (file)
@@ -1 +1 @@
-b83fbf15a3920755ed77dc9c91b4f00a86ddb9ac
\ No newline at end of file
+414f340809c487901fa913026a342b19a2956c0a
\ No newline at end of file
index 08d9e416f753e884cee1933cba37fb5520b79a3f..98afa508e1d69307492d01ad5823993456c79109 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.507 2009/04/02 16:59:47 drh Exp $
+** $Id: select.c,v 1.508 2009/04/16 00:24:24 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -1394,7 +1394,8 @@ static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){
   }else{
     pRet = 0;
   }
-  if( pRet==0 ){
+  assert( iCol>=0 );
+  if( pRet==0 && iCol<p->pEList->nExpr ){
     pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
   }
   return pRet;
@@ -2101,7 +2102,7 @@ static int multiSelectOrderBy(
   }
 
   /* Compute the comparison permutation and keyinfo that is used with
-  ** the permutation in order to comparisons to determine if the next
+  ** the permutation used to determine if the next
   ** row of results comes from selectA or selectB.  Also add explicit
   ** collations to the ORDER BY clause terms so that when the subqueries
   ** to the right and the left are evaluated, they use the correct
index f369389b1e7bd552f8d3d04aeb9cbcc6c751ff29..dff0b90fee01e363f2d56ec099ceda73a4a65e87 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing UNION, INTERSECT and EXCEPT operators
 # in SELECT statements.
 #
-# $Id: select4.test,v 1.29 2008/08/04 03:51:24 danielk1977 Exp $
+# $Id: select4.test,v 1.30 2009/04/16 00:24:24 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -374,6 +374,11 @@ do_test select4-5.3 {
   }} msg]
   lappend v $msg
 } {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test select4-5.3-3807-1 {
+  catchsql {
+    SELECT 1 UNION SELECT 2, 3 UNION SELECT 4, 5 ORDER BY 1;
+  }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
 do_test select4-5.4 {
   set v [catch {execsql {
     SELECT log FROM t1 WHERE n=2
@@ -791,6 +796,13 @@ do_test select4-11.15 {
   }
 } {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
 
+do_test select4-12.1 {
+  sqlite3 db2 :memory:
+  catchsql {
+    SELECT 1 UNION SELECT 2,3 UNION SELECT 4,5 ORDER BY 1;
+  } db2
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+
 } ;# ifcapable compound
 
 finish_test