/ Check-in [eb65e64e]
Login

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

Overview
Comment:Use ALWAYS and NEVER macros on unchangeable conditions within func.c. (CVS 6435)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:eb65e64e7ed5edbe506365971d4d81ea037098d3
User & Date: drh 2009-04-02 13:36:37
Context
2009-04-02
14:05
Change the way that the random() SQL function prevents the maximum negative integer so that it is testable. (CVS 6436) check-in: 995f2b9b user: drh tags: trunk
13:36
Use ALWAYS and NEVER macros on unchangeable conditions within func.c. (CVS 6435) check-in: eb65e64e user: drh tags: trunk
10:16
In the built-in SQL function implementations, improve some comments, fix an off-by-one error in detecting over-size strings, and add testcase() macros to verify that boundary values have been tested. (CVS 6434) check-in: 868a487f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

    12     12   ** This file contains the C functions that implement various SQL
    13     13   ** functions of SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: func.c,v 1.228 2009/04/02 10:16:18 drh Exp $
           19  +** $Id: func.c,v 1.229 2009/04/02 13:36:37 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <stdlib.h>
    23     23   #include <assert.h>
    24     24   #include "vdbeInt.h"
    25     25   
    26     26   /*
................................................................................
  1213   1213       sqlite3VdbeMemCopy(pBest, pArg);
  1214   1214     }
  1215   1215   }
  1216   1216   static void minMaxFinalize(sqlite3_context *context){
  1217   1217     sqlite3_value *pRes;
  1218   1218     pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
  1219   1219     if( pRes ){
  1220         -    if( pRes->flags ){
         1220  +    if( ALWAYS(pRes->flags) ){
  1221   1221         sqlite3_result_value(context, pRes);
  1222   1222       }
  1223   1223       sqlite3VdbeMemRelease(pRes);
  1224   1224     }
  1225   1225   }
  1226   1226   
  1227   1227   /*
................................................................................
  1298   1298   /*
  1299   1299   ** Set the LIKEOPT flag on the 2-argument function with the given name.
  1300   1300   */
  1301   1301   static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){
  1302   1302     FuncDef *pDef;
  1303   1303     pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),
  1304   1304                                2, SQLITE_UTF8, 0);
  1305         -  if( pDef ){
         1305  +  if( ALWAYS(pDef) ){
  1306   1306       pDef->flags = flagVal;
  1307   1307     }
  1308   1308   }
  1309   1309   
  1310   1310   /*
  1311   1311   ** Register the built-in LIKE and GLOB functions.  The caseSensitive
  1312   1312   ** parameter determines whether or not the LIKE operator is case
................................................................................
  1342   1342      || pExpr->x.pList->nExpr!=2
  1343   1343     ){
  1344   1344       return 0;
  1345   1345     }
  1346   1346     assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
  1347   1347     pDef = sqlite3FindFunction(db, (char*)pExpr->token.z, pExpr->token.n, 2,
  1348   1348                                SQLITE_UTF8, 0);
  1349         -  if( pDef==0 || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
         1349  +  if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
  1350   1350       return 0;
  1351   1351     }
  1352   1352   
  1353   1353     /* The memcpy() statement assumes that the wildcard characters are
  1354   1354     ** the first three statements in the compareInfo structure.  The
  1355   1355     ** asserts() that follow verify that assumption
  1356   1356     */