/ Check-in [cc7ae73e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix authentication so that it works with AS aliases. Ticket #1338. (CVS 2570)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cc7ae73ed01f0b89e31dd8de48b913bbd83887b8
User & Date: drh 2005-07-29 15:36:15
Context
2005-07-29
19:43
Fix problems caused by over-agressive optimization of ORDER BY in joins. Lots more testing needed. (CVS 2571) check-in: 1a4e526d user: drh tags: trunk
15:36
Fix authentication so that it works with AS aliases. Ticket #1338. (CVS 2570) check-in: cc7ae73e user: drh tags: trunk
15:10
Optimizer now converts OR-connected WHERE-clause terms into an IN operator so that they can be used with indices. There are known problems with the ORDER BY optimization in this and in several prior check-ins. This check-in is not recommended for production use. (CVS 2569) check-in: d23c8bf8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/auth.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the sqlite3_set_authorizer()
    13     13   ** API.  This facility is an optional feature of the library.  Embedded
    14     14   ** systems that do not need this facility may omit it by recompiling
    15     15   ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
    16     16   **
    17         -** $Id: auth.c,v 1.21 2005/01/29 08:32:44 danielk1977 Exp $
           17  +** $Id: auth.c,v 1.22 2005/07/29 15:36:15 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   /*
    22     22   ** All of the code in this file may be omitted by defining a single
    23     23   ** macro.
    24     24   */
................................................................................
   110    110     Table *pTab;          /* The table being read */
   111    111     const char *zCol;     /* Name of the column of the table */
   112    112     int iSrc;             /* Index in pTabList->a[] of table being read */
   113    113     const char *zDBase;   /* Name of database being accessed */
   114    114     TriggerStack *pStack; /* The stack of current triggers */
   115    115   
   116    116     if( db->xAuth==0 ) return;
          117  +  if( pExpr->op==TK_AS ) return;
   117    118     assert( pExpr->op==TK_COLUMN );
   118    119     for(iSrc=0; pTabList && iSrc<pTabList->nSrc; iSrc++){
   119    120       if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break;
   120    121     }
   121    122     if( iSrc>=0 && pTabList && iSrc<pTabList->nSrc ){
   122    123       pTab = pTabList->a[iSrc].pTab;
   123    124     }else if( (pStack = pParse->trigStack)!=0 ){

Changes to test/auth.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the ATTACH and DETACH commands
    13     13   # and related functionality.
    14     14   #
    15         -# $Id: auth.test,v 1.28 2005/07/23 02:17:03 drh Exp $
           15  +# $Id: auth.test,v 1.29 2005/07/29 15:36:15 drh Exp $
    16     16   #
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
    22     22   # defined during compilation.
................................................................................
  2190   2190     SQLITE_SELECT {}     {} {}   v1 \
  2191   2191     SQLITE_READ   t2     a  main v1 \
  2192   2192     SQLITE_READ   t2     b  main v1 \
  2193   2193     SQLITE_INSERT v1chng {} main r3 \
  2194   2194     SQLITE_READ   v1     x  main r3]
  2195   2195   
  2196   2196   } ;# ifcapable view && trigger
         2197  +
         2198  +# Ticket #1338:  Make sure authentication works in the presence of an AS
         2199  +# clause.
         2200  +#
         2201  +do_test auth-5.1 {
         2202  +  proc auth {code arg1 arg2 arg3 arg4} {
         2203  +    return SQLITE_OK
         2204  +  }
         2205  +  execsql {
         2206  +    SELECT count(a) AS cnt FROM t4 ORDER BY cnt
         2207  +  }
         2208  +} {1}
         2209  +
  2197   2210   
  2198   2211   rename proc {}
  2199   2212   rename proc_real proc
         2213  +
  2200   2214   
  2201   2215   finish_test