/ Check-in [a3e3b3e1]
Login

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

Overview
Comment:Fix SQLITE_OMIT_AUTHORIZATION so that it compiles cleanly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a3e3b3e1c57178ccd38fc7375ec1de8e8ae45372
User & Date: drh 2016-09-16 11:53:10
Context
2016-09-16
14:50
Add WHERETRACE macros showing every entry and exit from whereLoopAddBtreeIndex(). check-in: e7653dec user: drh tags: trunk
11:53
Fix SQLITE_OMIT_AUTHORIZATION so that it compiles cleanly. check-in: a3e3b3e1 user: drh tags: trunk
02:52
In the shell, make ".testcase" and ".check" available in all configurations, not just SQLITE_DEBUG. All testcases to be named. Show the result of each testcase on stdout. check-in: 792afefa user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2137   2137   */
  2138   2138   int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  2139   2139     Table *pSelTab;   /* A fake table from which we get the result set */
  2140   2140     Select *pSel;     /* Copy of the SELECT that implements the view */
  2141   2141     int nErr = 0;     /* Number of errors encountered */
  2142   2142     int n;            /* Temporarily holds the number of cursors assigned */
  2143   2143     sqlite3 *db = pParse->db;  /* Database connection for malloc errors */
         2144  +#ifndef SQLITE_OMIT_AUTHORIZATION
  2144   2145     sqlite3_xauth xAuth;       /* Saved xAuth pointer */
         2146  +#endif
  2145   2147   
  2146   2148     assert( pTable );
  2147   2149   
  2148   2150   #ifndef SQLITE_OMIT_VIRTUALTABLE
  2149   2151     if( sqlite3VtabCallConnect(pParse, pTable) ){
  2150   2152       return SQLITE_ERROR;
  2151   2153     }

Changes to src/delete.c.

   208    208   void sqlite3DeleteFrom(
   209    209     Parse *pParse,         /* The parser context */
   210    210     SrcList *pTabList,     /* The table from which we should delete things */
   211    211     Expr *pWhere           /* The WHERE clause.  May be null */
   212    212   ){
   213    213     Vdbe *v;               /* The virtual database engine */
   214    214     Table *pTab;           /* The table from which records will be deleted */
   215         -  const char *zDb;       /* Name of database holding pTab */
   216    215     int i;                 /* Loop counter */
   217    216     WhereInfo *pWInfo;     /* Information about the WHERE clause */
   218    217     Index *pIdx;           /* For looping over indices of the table */
   219    218     int iTabCur;           /* Cursor number for the table */
   220    219     int iDataCur = 0;      /* VDBE cursor for the canonical data source */
   221    220     int iIdxCur = 0;       /* Cursor number of the first index */
   222    221     int nIdx;              /* Number of indices */
................................................................................
   285    284     }
   286    285   
   287    286     if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){
   288    287       goto delete_from_cleanup;
   289    288     }
   290    289     iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   291    290     assert( iDb<db->nDb );
   292         -  zDb = db->aDb[iDb].zDbSName;
   293         -  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);
          291  +  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, 
          292  +                            db->aDb[iDb].zDbSName);
   294    293     assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );
   295    294     if( rcauth==SQLITE_DENY ){
   296    295       goto delete_from_cleanup;
   297    296     }
   298    297     assert(!isView || pTrigger);
   299    298   
   300    299     /* Assign cursor numbers to the table and all its indices.

Changes to src/insert.c.

   481    481     Select *pSelect,      /* A SELECT statement to use as the data source */
   482    482     IdList *pColumn,      /* Column names corresponding to IDLIST. */
   483    483     int onError           /* How to handle constraint errors */
   484    484   ){
   485    485     sqlite3 *db;          /* The main database structure */
   486    486     Table *pTab;          /* The table to insert into.  aka TABLE */
   487    487     char *zTab;           /* Name of the table into which we are inserting */
   488         -  const char *zDb;      /* Name of the database holding this table */
   489    488     int i, j, idx;        /* Loop counters */
   490    489     Vdbe *v;              /* Generate code into this virtual machine */
   491    490     Index *pIdx;          /* For looping over indices of the table */
   492    491     int nColumn;          /* Number of columns in the data */
   493    492     int nHidden = 0;      /* Number of hidden columns if TABLE is virtual */
   494    493     int iDataCur = 0;     /* VDBE cursor that is the main data repository */
   495    494     int iIdxCur = 0;      /* First index cursor */
................................................................................
   496    495     int ipkColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */
   497    496     int endOfLoop;        /* Label for the end of the insertion loop */
   498    497     int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */
   499    498     int addrInsTop = 0;   /* Jump to label "D" */
   500    499     int addrCont = 0;     /* Top of insert loop. Label "C" in templates 3 and 4 */
   501    500     SelectDest dest;      /* Destination for SELECT on rhs of INSERT */
   502    501     int iDb;              /* Index of database holding TABLE */
   503         -  Db *pDb;              /* The database containing table being inserted into */
   504    502     u8 useTempTable = 0;  /* Store SELECT results in intermediate table */
   505    503     u8 appendFlag = 0;    /* True if the insert is likely to be an append */
   506    504     u8 withoutRowid;      /* 0 for normal table.  1 for WITHOUT ROWID table */
   507    505     u8 bIdListInOrder;    /* True if IDLIST is in table order */
   508    506     ExprList *pList = 0;  /* List of VALUES() to be inserted  */
   509    507   
   510    508     /* Register allocations */
................................................................................
   546    544     if( NEVER(zTab==0) ) goto insert_cleanup;
   547    545     pTab = sqlite3SrcListLookup(pParse, pTabList);
   548    546     if( pTab==0 ){
   549    547       goto insert_cleanup;
   550    548     }
   551    549     iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   552    550     assert( iDb<db->nDb );
   553         -  pDb = &db->aDb[iDb];
   554         -  zDb = pDb->zDbSName;
   555         -  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){
          551  +  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0,
          552  +                       db->aDb[iDb].zDbSName) ){
   556    553       goto insert_cleanup;
   557    554     }
   558    555     withoutRowid = !HasRowid(pTab);
   559    556   
   560    557     /* Figure out if we have any triggers and if the table being
   561    558     ** inserted into is a view
   562    559     */

Changes to src/resolve.c.

   642    642       */
   643    643       case TK_FUNCTION: {
   644    644         ExprList *pList = pExpr->x.pList;    /* The argument list */
   645    645         int n = pList ? pList->nExpr : 0;    /* Number of arguments */
   646    646         int no_such_func = 0;       /* True if no such function exists */
   647    647         int wrong_num_args = 0;     /* True if wrong number of arguments */
   648    648         int is_agg = 0;             /* True if is an aggregate function */
   649         -      int auth;                   /* Authorization to use the function */
   650    649         int nId;                    /* Number of characters in function name */
   651    650         const char *zId;            /* The function name. */
   652    651         FuncDef *pDef;              /* Information about the function */
   653    652         u8 enc = ENC(pParse->db);   /* The database encoding */
   654    653   
   655    654         assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
   656    655         notValid(pParse, pNC, "functions", NC_PartIdx);
................................................................................
   686    685               ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent
   687    686               ** to likelihood(X,0.9375). */
   688    687               /* TUNING: unlikely() probability is 0.0625.  likely() is 0.9375 */
   689    688               pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;
   690    689             }             
   691    690           }
   692    691   #ifndef SQLITE_OMIT_AUTHORIZATION
   693         -        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
   694         -        if( auth!=SQLITE_OK ){
   695         -          if( auth==SQLITE_DENY ){
   696         -            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
   697         -                                    pDef->zName);
   698         -            pNC->nErr++;
          692  +        {
          693  +          int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
          694  +          if( auth!=SQLITE_OK ){
          695  +            if( auth==SQLITE_DENY ){
          696  +              sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
          697  +                                      pDef->zName);
          698  +              pNC->nErr++;
          699  +            }
          700  +            pExpr->op = TK_NULL;
          701  +            return WRC_Prune;
   699    702             }
   700         -          pExpr->op = TK_NULL;
   701         -          return WRC_Prune;
   702    703           }
   703    704   #endif
   704    705           if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
   705    706             /* For the purposes of the EP_ConstFunc flag, date and time
   706    707             ** functions and other functions that change slowly are considered
   707    708             ** constant because they are constant for the duration of one query */
   708    709             ExprSetProperty(pExpr,EP_ConstFunc);

Changes to src/shell.c.

   892    892     UNUSED_PARAMETER(NotUsed);
   893    893     seenInterrupt++;
   894    894     if( seenInterrupt>2 ) exit(1);
   895    895     if( globalDb ) sqlite3_interrupt(globalDb);
   896    896   }
   897    897   #endif
   898    898   
          899  +#ifndef SQLITE_OMIT_AUTHORIZATION
   899    900   /*
   900    901   ** When the ".auth ON" is set, the following authorizer callback is
   901    902   ** invoked.  It always returns SQLITE_OK.
   902    903   */
   903    904   static int shellAuth(
   904    905     void *pClientData,
   905    906     int op,
................................................................................
   936    937       }else{
   937    938         raw_printf(p->out, "NULL");
   938    939       }
   939    940     }
   940    941     raw_printf(p->out, "\n");
   941    942     return SQLITE_OK;
   942    943   }
          944  +#endif
   943    945     
   944    946   
   945    947   /*
   946    948   ** This is the callback routine that the shell
   947    949   ** invokes for each row of a query result.
   948    950   */
   949    951   static int shell_callback(
................................................................................
  2129   2131     return rc;
  2130   2132   }
  2131   2133   
  2132   2134   /*
  2133   2135   ** Text of a help message
  2134   2136   */
  2135   2137   static char zHelp[] =
         2138  +#ifndef SQLITE_OMIT_AUTHORIZATION
  2136   2139     ".auth ON|OFF           Show authorizer callbacks\n"
         2140  +#endif
  2137   2141     ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
  2138   2142     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  2139   2143     ".binary on|off         Turn binary output on or off.  Default OFF\n"
  2140   2144     ".changes on|off        Show number of rows changed by SQL\n"
  2141   2145     ".check GLOB            Fail if output since .testcase does not match\n"
  2142   2146     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  2143   2147     ".databases             List names and files of attached databases\n"
................................................................................
  3246   3250   
  3247   3251     /* Process the input line.
  3248   3252     */
  3249   3253     if( nArg==0 ) return 0; /* no tokens, no error */
  3250   3254     n = strlen30(azArg[0]);
  3251   3255     c = azArg[0][0];
  3252   3256   
         3257  +#ifndef SQLITE_OMIT_AUTHORIZATION
  3253   3258     if( c=='a' && strncmp(azArg[0], "auth", n)==0 ){
  3254   3259       if( nArg!=2 ){
  3255   3260         raw_printf(stderr, "Usage: .auth ON|OFF\n");
  3256   3261         rc = 1;
  3257   3262         goto meta_command_exit;
  3258   3263       }
  3259   3264       open_db(p, 0);
  3260   3265       if( booleanValue(azArg[1]) ){
  3261   3266         sqlite3_set_authorizer(p->db, shellAuth, p);
  3262   3267       }else{
  3263   3268         sqlite3_set_authorizer(p->db, 0, 0);
  3264   3269       }
  3265   3270     }else
         3271  +#endif
  3266   3272   
  3267   3273     if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0)
  3268   3274      || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)
  3269   3275     ){
  3270   3276       const char *zDestFile = 0;
  3271   3277       const char *zDb = 0;
  3272   3278       sqlite3 *pDest;

Changes to src/trigger.c.

    92     92     Trigger *pTrigger = 0;  /* The new trigger */
    93     93     Table *pTab;            /* Table that the trigger fires off of */
    94     94     char *zName = 0;        /* Name of the trigger */
    95     95     sqlite3 *db = pParse->db;  /* The database connection */
    96     96     int iDb;                /* The database to store the trigger in */
    97     97     Token *pName;           /* The unqualified db name */
    98     98     DbFixer sFix;           /* State vector for the DB fixer */
    99         -  int iTabDb;             /* Index of the database holding pTab */
   100     99   
   101    100     assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */
   102    101     assert( pName2!=0 );
   103    102     assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );
   104    103     assert( op>0 && op<0xff );
   105    104     if( isTemp ){
   106    105       /* If TEMP was specified, then the trigger name may not be qualified. */
................................................................................
   205    204       goto trigger_cleanup;
   206    205     }
   207    206     if( !pTab->pSelect && tr_tm==TK_INSTEAD ){
   208    207       sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"
   209    208           " trigger on table: %S", pTableName, 0);
   210    209       goto trigger_cleanup;
   211    210     }
   212         -  iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   213    211   
   214    212   #ifndef SQLITE_OMIT_AUTHORIZATION
   215    213     {
          214  +    int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   216    215       int code = SQLITE_CREATE_TRIGGER;
   217    216       const char *zDb = db->aDb[iTabDb].zDbSName;
   218    217       const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;
   219    218       if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
   220    219       if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){
   221    220         goto trigger_cleanup;
   222    221       }