]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved comments on sqlite3CodeSubquery(). No changes to code.
authordrh <drh@noemail.net>
Fri, 19 Aug 2016 19:12:58 +0000 (19:12 +0000)
committerdrh <drh@noemail.net>
Fri, 19 Aug 2016 19:12:58 +0000 (19:12 +0000)
FossilOrigin-Name: acea4ee136def4815d22eec240c5903a72bde9bd

manifest
manifest.uuid
src/expr.c

index 2d1e3df4645126aa210f58a6f3607e911a6e3446..75bb629cc66b78c2fd8e51aa44e73d22ba1fad18 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Show\sthe\sWhereTerm.iField\svalue\son\sdebugging\soutput,\swhen\sit\sis\snon-zero.
-D 2016-08-19T18:40:17.138
+C Improved\scomments\son\ssqlite3CodeSubquery().\s\sNo\schanges\sto\scode.
+D 2016-08-19T19:12:58.298
 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a
@@ -338,7 +338,7 @@ F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7
 F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b
 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
 F src/delete.c 76c084f0265f4a3cd1ecf17eee112a94f1ccbc05
-F src/expr.c d79a02ba0f5b44c3319154641247979c48eec637
+F src/expr.c e139851835a8532e3974ca4bc8f6b0e5aef0e06f
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
 F src/fkey.c e2be0968c1adc679c87e467aa5b4f167588f38a8
 F src/func.c 29cc9acb170ec1387b9f63eb52cd85f8de96c771
@@ -1518,7 +1518,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 d07be5afb0a915769382dfd815403f8832cb3eec
-R 8b996d549f6c06da9085faa1b04f9847
+P 931c95358d8bc02f3e3d8ee4e545a07b2d2c97e8
+R 041e4a08027e633fe8c3ceee8cf4a385
 U drh
-Z 5690c4429160dd9b0cc8734ae0e94c60
+Z b93c8a041c20867db97a84e58d7255a6
index 6105e3743f0b431cf334f2a843874ef19cbacfd8..715e015f26fbc93a5a6d125d040e8d22ecb122dc 100644 (file)
@@ -1 +1 @@
-931c95358d8bc02f3e3d8ee4e545a07b2d2c97e8
\ No newline at end of file
+acea4ee136def4815d22eec240c5903a72bde9bd
\ No newline at end of file
index 4f02c98c454c4cbdc12d31e73d1c80c5e1f79b98..1949be50afc02fdf1a1650c28310b60e77f5c604 100644 (file)
@@ -2211,7 +2211,9 @@ void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
 ** value to non-NULL if the RHS is NULL-free.
 **
 ** For a SELECT or EXISTS operator, return the register that holds the
-** result.  For IN operators or if an error occurs, the return value is 0.
+** result.  For a multi-column SELECT, the result is stored in a contiguous
+** array of registers and the return value is the register of the left-most
+** result column.  Return 0 for IN operators or if an error occurs.
 */
 #ifndef SQLITE_OMIT_SUBQUERY
 int sqlite3CodeSubselect(
@@ -2226,8 +2228,8 @@ int sqlite3CodeSubselect(
   if( NEVER(v==0) ) return 0;
   sqlite3ExprCachePush(pParse);
 
-  /* This code must be run in its entirety every time it is encountered
-  ** if any of the following is true:
+  /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
+  ** is encountered if any of the following is true:
   **
   **    *  The right-hand side is a correlated subquery
   **    *  The right-hand side is an expression list containing variables
@@ -2387,14 +2389,21 @@ int sqlite3CodeSubselect(
     case TK_EXISTS:
     case TK_SELECT:
     default: {
-      /* If this has to be a scalar SELECT.  Generate code to put the
-      ** value of this select in a memory cell and record the number
-      ** of the memory cell in iColumn.  If this is an EXISTS, write
-      ** an integer 0 (not exists) or 1 (exists) into a memory cell
-      ** and record that memory cell in iColumn.
+      /* Case 3:    (SELECT ... FROM ...)
+      **     or:    EXISTS(SELECT ... FROM ...)
+      **
+      ** For a SELECT, generate code to put the values for all columns of
+      ** the first row into an array of registers and return the index of
+      ** the first register.
+      **
+      ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
+      ** into a register and return that register number.
+      **
+      ** In both cases, the query is augmented with "LIMIT 1".  Any 
+      ** preexisting limit is discarded in place of the new LIMIT 1.
       */
       Select *pSel;                         /* SELECT statement to encode */
-      SelectDest dest;                      /* How to deal with SELECt result */
+      SelectDest dest;                      /* How to deal with SELECT result */
       int nReg;                             /* Registers to allocate */
 
       testcase( pExpr->op==TK_EXISTS );