/ Check-in [f29680c4]
Login

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

Overview
Comment:Merge updates from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | configReadOnly
Files: files | file ages | folders
SHA1: f29680c468d5635e5ea7711f12f56ff467824241
User & Date: mistachkin 2013-01-08 17:24:25
Context
2013-01-08
17:24
Merge updates from trunk. Closed-Leaf check-in: f29680c4 user: mistachkin tags: configReadOnly
12:48
Do not raise an error if an unknown SQL function is found in a CHECK constraint while parsing the schema of an existing database. check-in: cda79028 user: drh tags: trunk
2013-01-07
17:31
Merge updates from trunk. check-in: bf90f1fb user: mistachkin tags: configReadOnly
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

   607    607         int n = pList ? pList->nExpr : 0;    /* Number of arguments */
   608    608         int no_such_func = 0;       /* True if no such function exists */
   609    609         int wrong_num_args = 0;     /* True if wrong number of arguments */
   610    610         int is_agg = 0;             /* True if is an aggregate function */
   611    611         int auth;                   /* Authorization to use the function */
   612    612         int nId;                    /* Number of characters in function name */
   613    613         const char *zId;            /* The function name. */
          614  +      FuncDef *pDef;              /* Information about the function */
   614    615         u8 enc = ENC(pParse->db);   /* The database encoding */
   615    616   
   616    617         testcase( pExpr->op==TK_CONST_FUNC );
   617    618         assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
   618    619         zId = pExpr->u.zToken;
   619    620         nId = sqlite3Strlen30(zId);
   620         -      if( pParse->db->init.busy==0 ){
   621         -        FuncDef *pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
          621  +      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
          622  +      if( pDef==0 ){
          623  +        pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
   622    624           if( pDef==0 ){
   623         -          pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
   624         -          if( pDef==0 ){
   625         -            no_such_func = 1;
   626         -          }else{
   627         -            wrong_num_args = 1;
   628         -          }
          625  +          no_such_func = 1;
   629    626           }else{
   630         -          is_agg = pDef->xFunc==0;
          627  +          wrong_num_args = 1;
   631    628           }
          629  +      }else{
          630  +        is_agg = pDef->xFunc==0;
          631  +      }
   632    632   #ifndef SQLITE_OMIT_AUTHORIZATION
   633         -        if( pDef ){
   634         -          auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
   635         -          if( auth!=SQLITE_OK ){
   636         -            if( auth==SQLITE_DENY ){
   637         -              sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
   638         -                  pDef->zName);
   639         -              pNC->nErr++;
   640         -            }
   641         -            pExpr->op = TK_NULL;
   642         -            return WRC_Prune;
          633  +      if( pDef ){
          634  +        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
          635  +        if( auth!=SQLITE_OK ){
          636  +          if( auth==SQLITE_DENY ){
          637  +            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
          638  +                                    pDef->zName);
          639  +            pNC->nErr++;
   643    640             }
          641  +          pExpr->op = TK_NULL;
          642  +          return WRC_Prune;
   644    643           }
          644  +      }
   645    645   #endif
   646         -      }
   647    646         if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
   648    647           sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
   649    648           pNC->nErr++;
   650    649           is_agg = 0;
   651         -      }else if( no_such_func ){
          650  +      }else if( no_such_func && pParse->db->init.busy==0 ){
   652    651           sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
   653    652           pNC->nErr++;
   654    653         }else if( wrong_num_args ){
   655    654           sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
   656    655                nId, zId);
   657    656           pNC->nErr++;
   658    657         }