SQLite

Check-in [f29680c468]
Login

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

Overview
Comment:Merge updates from trunk.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | configReadOnly
Files: files | file ages | folders
SHA1: f29680c468d5635e5ea7711f12f56ff467824241
User & Date: mistachkin 2013-01-08 17:24:25.899
Context
2013-01-08
17:24
Merge updates from trunk. (Closed-Leaf check-in: f29680c468 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: cda790280a user: drh tags: trunk)
2013-01-07
17:31
Merge updates from trunk. (check-in: bf90f1fbf8 user: mistachkin tags: configReadOnly)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/resolve.c.
607
608
609
610
611
612
613

614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631











632
633
634
635
636
637
638
639
640
641
642
643
644












645
646
647
648
649
650
651

652
653
654
655
656
657
658
607
608
609
610
611
612
613
614
615
616
617
618
619
620












621
622
623
624
625
626
627
628
629
630
631
632












633
634
635
636
637
638
639
640
641
642
643
644
645

646
647
648
649

650
651
652
653
654
655
656
657







+






-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

-




-
+







      int n = pList ? pList->nExpr : 0;    /* Number of arguments */
      int no_such_func = 0;       /* True if no such function exists */
      int wrong_num_args = 0;     /* True if wrong number of arguments */
      int is_agg = 0;             /* True if is an aggregate function */
      int auth;                   /* Authorization to use the function */
      int nId;                    /* Number of characters in function name */
      const char *zId;            /* The function name. */
      FuncDef *pDef;              /* Information about the function */
      u8 enc = ENC(pParse->db);   /* The database encoding */

      testcase( pExpr->op==TK_CONST_FUNC );
      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
      zId = pExpr->u.zToken;
      nId = sqlite3Strlen30(zId);
      if( pParse->db->init.busy==0 ){
        FuncDef *pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
        if( pDef==0 ){
          pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
          if( pDef==0 ){
            no_such_func = 1;
          }else{
            wrong_num_args = 1;
          }
        }else{
          is_agg = pDef->xFunc==0;
        }
      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
      if( pDef==0 ){
        pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
        if( pDef==0 ){
          no_such_func = 1;
        }else{
          wrong_num_args = 1;
        }
      }else{
        is_agg = pDef->xFunc==0;
      }
#ifndef SQLITE_OMIT_AUTHORIZATION
        if( pDef ){
          auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
          if( auth!=SQLITE_OK ){
            if( auth==SQLITE_DENY ){
              sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
                  pDef->zName);
              pNC->nErr++;
            }
            pExpr->op = TK_NULL;
            return WRC_Prune;
          }
        }
      if( pDef ){
        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
        if( auth!=SQLITE_OK ){
          if( auth==SQLITE_DENY ){
            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
                                    pDef->zName);
            pNC->nErr++;
          }
          pExpr->op = TK_NULL;
          return WRC_Prune;
        }
      }
#endif
      }
      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
        pNC->nErr++;
        is_agg = 0;
      }else if( no_such_func ){
      }else if( no_such_func && pParse->db->init.busy==0 ){
        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
        pNC->nErr++;
      }else if( wrong_num_args ){
        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
             nId, zId);
        pNC->nErr++;
      }