/ Check-in [866f13e2]
Login

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

Overview
Comment:Change the sqlite3_create_function() family of routines to return SQLITE_MISUSE instead of SQLITE_ERROR if their parameters are incorrect. (CVS 6617)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:866f13e28c6fdb98947e1c7a89b7855bb5bbdb96
User & Date: drh 2009-05-07 13:43:49
Context
2009-05-07
14:11
If compiling FTS3 in the amalgamation, include the ctype.h header file. Ticket #3843. (CVS 6618) check-in: 660108ef user: drh tags: trunk
13:43
Change the sqlite3_create_function() family of routines to return SQLITE_MISUSE instead of SQLITE_ERROR if their parameters are incorrect. (CVS 6617) check-in: 866f13e2 user: drh tags: trunk
12:17
Make sure the iteration counter on aggregate functions is reset each time the aggregate is used in an correlated subquery. Ticket #3841. (CVS 6616) check-in: 4a86de35 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.548 2009/05/06 19:03:14 drh Exp $
           17  +** $Id: main.c,v 1.549 2009/05/07 13:43:49 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   #ifdef SQLITE_ENABLE_FTS3
    22     22   # include "fts3.h"
    23     23   #endif
    24     24   #ifdef SQLITE_ENABLE_RTREE
................................................................................
   927    927     assert( sqlite3_mutex_held(db->mutex) );
   928    928     if( zFunctionName==0 ||
   929    929         (xFunc && (xFinal || xStep)) || 
   930    930         (!xFunc && (xFinal && !xStep)) ||
   931    931         (!xFunc && (!xFinal && xStep)) ||
   932    932         (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||
   933    933         (255<(nName = sqlite3Strlen30( zFunctionName))) ){
   934         -    sqlite3Error(db, SQLITE_ERROR, "bad parameters");
   935         -    return SQLITE_ERROR;
          934  +    return SQLITE_MISUSE;
   936    935     }
   937    936     
   938    937   #ifndef SQLITE_OMIT_UTF16
   939    938     /* If SQLITE_UTF16 is specified as the encoding type, transform this
   940    939     ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
   941    940     ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
   942    941     **

Changes to src/test_func.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  This code
    13     13   ** implements new SQL functions used by the test scripts.
    14     14   **
    15         -** $Id: test_func.c,v 1.14 2009/03/19 18:51:07 danielk1977 Exp $
           15  +** $Id: test_func.c,v 1.15 2009/05/07 13:43:49 drh Exp $
    16     16   */
    17     17   #include "sqlite3.h"
    18     18   #include "tcl.h"
    19     19   #include <stdlib.h>
    20     20   #include <string.h>
    21     21   #include <assert.h>
    22     22   
................................................................................
   389    389     sqlite3 *db;
   390    390     int rc;
   391    391     int mxArg;
   392    392   
   393    393     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
   394    394   
   395    395     rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep,tStep,tFinal);
   396         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   397         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   398         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          396  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   399    397   
   400    398     rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep, tStep, 0);
   401         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   402         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   403         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          399  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   404    400   
   405    401     rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep, 0, tFinal);
   406         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   407         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   408         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          402  +  if( rc!=SQLITE_MISUSE) goto abuse_err;
   409    403   
   410    404     rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, 0, 0, tFinal);
   411         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   412         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   413         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          405  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   414    406   
   415    407     rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, 0, tStep, 0);
   416         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   417         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   418         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          408  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   419    409   
   420    410     rc = sqlite3_create_function(db, "tx", -2, SQLITE_UTF8, 0, tStep, 0, 0);
   421         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   422         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   423         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          411  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   424    412   
   425    413     rc = sqlite3_create_function(db, "tx", 128, SQLITE_UTF8, 0, tStep, 0, 0);
   426         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   427         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   428         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          414  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   429    415   
   430    416     rc = sqlite3_create_function(db, "funcxx"
   431    417          "_123456789_123456789_123456789_123456789_123456789"
   432    418          "_123456789_123456789_123456789_123456789_123456789"
   433    419          "_123456789_123456789_123456789_123456789_123456789"
   434    420          "_123456789_123456789_123456789_123456789_123456789"
   435    421          "_123456789_123456789_123456789_123456789_123456789",
   436    422          1, SQLITE_UTF8, 0, tStep, 0, 0);
   437         -  if( rc!=SQLITE_ERROR ) goto abuse_err;
   438         -  if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
   439         -  if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
          423  +  if( rc!=SQLITE_MISUSE ) goto abuse_err;
   440    424   
   441    425     /* This last function registration should actually work.  Generate
   442    426     ** a no-op function (that always returns NULL) and which has the
   443    427     ** maximum-length function name and the maximum number of parameters.
   444    428     */
   445    429     sqlite3_limit(db, SQLITE_LIMIT_FUNCTION_ARG, 10000);
   446    430     mxArg = sqlite3_limit(db, SQLITE_LIMIT_FUNCTION_ARG, -1);