]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Call the authorizer callback the same number of times whether or not the query flatte...
authordanielk1977 <danielk1977@noemail.net>
Wed, 2 Jul 2008 13:13:51 +0000 (13:13 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 2 Jul 2008 13:13:51 +0000 (13:13 +0000)
FossilOrigin-Name: 8b88b64bb37df4e38cbfe31a14c219688b26e2af

manifest
manifest.uuid
src/select.c
test/auth.test
test/auth2.test

index 616304cf2f9e75c09f0f02a62d3684abb4f7e825..060e9418a2fe099be0aae521ced486f7b5c6a162 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\serrors\sin\sin.test.\sAlso\sadd\sa\sfew\stests\sto\sselectB.test.\s(CVS\s5337)
-D 2008-07-01T18:26:50
+C Call\sthe\sauthorizer\scallback\sthe\ssame\snumber\sof\stimes\swhether\sor\snot\sthe\squery\sflattening\soccurs.\s(CVS\s5338)
+D 2008-07-02T13:13:52
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -140,7 +140,7 @@ F src/pragma.c 9a95f5b3708f6d3ddd987eab5f369a19ffcb6795
 F src/prepare.c aba51dad52308e3d9d2074d8ff4e612e7f1cab51
 F src/printf.c 8b063da9dcde26b7c500a01444b718d86f21bc6e
 F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a
-F src/select.c 154b3feee700273671b74a8436c31331309171e5
+F src/select.c 31c8ab4c9514981d33d85cb29e2abedfb531a7ea
 F src/shell.c 484e7297e066f22830f9c15d7abbcdd2acb097b0
 F src/sqlite.h.in 76c144d23f8824e8811e837e9396b9f1361f5902
 F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e
@@ -206,8 +206,8 @@ F test/attach.test 4ab582932e3c815689f61afcdb9bce245f0bac53
 F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
 F test/attach3.test 7b92dc8e40c1ebca9732ca6f2d3fefbd46f196df
 F test/attachmalloc.test 56c5e55563dba6d64641ef2f70ce06900df16912
-F test/auth.test 100cde29a9913530994289038ec80ef5f63d38d3
-F test/auth2.test 65ac294b8d52cbdd463f61e77ad0165268373126
+F test/auth.test 9eb4b6b99eee54c95711c74c4b9694acf4d850ed
+F test/auth2.test ee3ba272e2b975e913afc9b041ee75706e190005
 F test/autoinc.test 42af2c407c4e37d0626f9cda57ed381e94522c9d
 F test/autovacuum.test 4339e66003b9cf813dd667a83aed2dee27c4c36d
 F test/autovacuum_ioerr2.test dc189f323cf0546289b5a9bbda60bcb1fe52bd4b
@@ -596,7 +596,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 56109b9a1f600ab3f16769aba0d47dcf782bbc95
-R 7cae1eb722ade0f7563a43911c2df151
+P 8f9d1abb315a3d4aa3a580fd5cf3ae572cc330f4
+R d5d889c70567d9d659ef03a502196b4b
 U danielk1977
-Z 24db410bfd4f0e01c8ce47ef0672d11f
+Z 6abe9fcc0b95c3c5d712e076cf4d4e5d
index 1f2b73ccff021eeed0b7f405a71d2721e72fe665..44159b0c666181c4d39b7a20ea795d7af9f131f5 100644 (file)
@@ -1 +1 @@
-8f9d1abb315a3d4aa3a580fd5cf3ae572cc330f4
\ No newline at end of file
+8b88b64bb37df4e38cbfe31a14c219688b26e2af
\ No newline at end of file
index 1871aa067046ee6afba6a8995142457c88434876..ae1f010970884e1196f402ed82e8721dc8fd04d3 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.445 2008/07/01 18:26:50 danielk1977 Exp $
+** $Id: select.c,v 1.446 2008/07/02 13:13:52 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -3085,12 +3085,13 @@ static void substSelect(
 ** the subquery before this routine runs.
 */
 static int flattenSubquery(
-  sqlite3 *db,         /* Database connection */
+  Parse *pParse,       /* Parsing context */
   Select *p,           /* The parent or outer SELECT statement */
   int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */
   int isAgg,           /* True if outer SELECT uses aggregate functions */
   int subqueryIsAgg    /* True if the subquery uses aggregate functions */
 ){
+  const char *zSavedAuthContext = pParse->zAuthContext;
   Select *pParent;
   Select *pSub;       /* The inner query or "subquery" */
   Select *pSub1;      /* Pointer to the rightmost select in sub-query */
@@ -3101,6 +3102,7 @@ static int flattenSubquery(
   int i;              /* Loop counter */
   Expr *pWhere;                    /* The WHERE clause */
   struct SrcList_item *pSubitem;   /* The subquery */
+  sqlite3 *db = pParse->db;
 
   /* Check to see if flattening is permitted.  Return 0 if not.
   */
@@ -3185,6 +3187,10 @@ static int flattenSubquery(
     }
   }
 
+  pParse->zAuthContext = pSubitem->zName;
+  sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
+  pParse->zAuthContext = zSavedAuthContext;
+
   /* If the sub-query is a compound SELECT statement, then it must be
   ** a UNION ALL and the parent query must be of the form:
   **
@@ -3787,11 +3793,12 @@ int sqlite3Select(
     SelectDest dest;
     Select *pSub = pItem->pSelect;
     int isAggSub;
+    char *zName = pItem->zName;
 
     if( pSub==0 || pItem->isPopulated ) continue;
-    if( pItem->zName!=0 ){   /* An sql view */
+    if( zName!=0 ){   /* An sql view */
       const char *zSavedAuthContext = pParse->zAuthContext;
-      pParse->zAuthContext = pItem->zName;
+      pParse->zAuthContext = zName;
       rc = sqlite3SelectResolve(pParse, pSub, 0);
       pParse->zAuthContext = zSavedAuthContext;
       if( rc ){
@@ -3810,7 +3817,7 @@ int sqlite3Select(
 
     /* Check to see if the subquery can be absorbed into the parent. */
     isAggSub = pSub->isAgg;
-    if( flattenSubquery(db, p, i, isAgg, isAggSub) ){
+    if( flattenSubquery(pParse, p, i, isAgg, isAggSub) ){
       if( isAggSub ){
         p->isAgg = isAgg = 1;
       }
@@ -3819,7 +3826,7 @@ int sqlite3Select(
       sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
       sqlite3Select(pParse, pSub, &dest, p, i, &isAgg, 0);
     }
-    if( db->mallocFailed ){
+    if( pParse->nErr || db->mallocFailed ){
       goto select_end;
     }
     pParse->nHeight -= sqlite3SelectExprHeight(p);
index 82032a0bac5b9dc4e8d3700b2277974a179cb7eb..ada28d2d0c513d1552137b8f54554e9f6f745e64 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the sqlite3_set_authorizer() API
 # and related functionality.
 #
-# $Id: auth.test,v 1.42 2008/04/15 14:36:42 drh Exp $
+# $Id: auth.test,v 1.43 2008/07/02 13:13:52 danielk1977 Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -2251,7 +2251,7 @@ do_test auth-4.3 {
   SQLITE_SELECT {}     {} {}   v1 \
   SQLITE_READ   t2     a  main v1 \
   SQLITE_READ   t2     b  main v1 \
-  SQLITE_SELECT {}     {} {}   v1 \
+  SQLITE_SELECT {}     {} {}   {} \
   SQLITE_READ   v1     x  main v1 \
 ]
 do_test auth-4.4 {
@@ -2275,7 +2275,7 @@ do_test auth-4.5 {
   SQLITE_SELECT {}     {} {}   v1 \
   SQLITE_READ   t2     a  main v1 \
   SQLITE_READ   t2     b  main v1 \
-  SQLITE_SELECT {}     {} {}   v1 \
+  SQLITE_SELECT {}     {} {}   {} \
   SQLITE_READ   v1     x  main v1 \
 ]
 
index d02c0f006c1026fe301743461a1c6bba27dd8893..98270ae73aebe024049e60f110efdc5fb97e8e46 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the sqlite3_set_authorizer() API
 # and related functionality.
 #
-# $Id: auth2.test,v 1.2 2007/10/12 20:42:30 drh Exp $
+# $Id: auth2.test,v 1.3 2008/07/02 13:13:53 danielk1977 Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -131,11 +131,11 @@ do_test auth2-2.3 {
 } {SQLITE_SELECT {} {} {} {}
 SQLITE_READ v2 a main {}
 SQLITE_READ v2 b main {}
-SQLITE_SELECT {} {} {} v2
 SQLITE_READ t2 x main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
 }
 do_test auth2-2.4 {
   db2 eval {
@@ -149,19 +149,19 @@ do_test auth2-2.4 {
 } {SQLITE_SELECT {} {} {} {}
 SQLITE_READ v2 b main {}
 SQLITE_READ v2 a main {}
-SQLITE_SELECT {} {} {} v2
 SQLITE_READ t2 x main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
 SQLITE_SELECT {} {} {} {}
 SQLITE_READ v2 b main {}
 SQLITE_READ v2 a main {}
-SQLITE_SELECT {} {} {} v2
 SQLITE_READ t2 x main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 y main v2
 SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
 }
 db2 close