1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Change the sqlite3_create_function() family of routines to return

SQLITE_MISUSE instead of SQLITE_ERROR if their parameters are incorrect. (CVS 6617)

FossilOrigin-Name: 866f13e28c6fdb98947e1c7a89b7855bb5bbdb96
This commit is contained in:
drh
2009-05-07 13:43:49 +00:00
parent cdd0376a55
commit dff6c173dd
4 changed files with 19 additions and 36 deletions

View File

@@ -12,7 +12,7 @@
** Code for testing all sorts of SQLite interfaces. This code
** implements new SQL functions used by the test scripts.
**
** $Id: test_func.c,v 1.14 2009/03/19 18:51:07 danielk1977 Exp $
** $Id: test_func.c,v 1.15 2009/05/07 13:43:49 drh Exp $
*/
#include "sqlite3.h"
#include "tcl.h"
@@ -393,39 +393,25 @@ static int abuse_create_function(
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep,tStep,tFinal);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep, tStep, 0);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, tStep, 0, tFinal);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE) goto abuse_err;
rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, 0, 0, tFinal);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "tx", 1, SQLITE_UTF8, 0, 0, tStep, 0);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "tx", -2, SQLITE_UTF8, 0, tStep, 0, 0);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "tx", 128, SQLITE_UTF8, 0, tStep, 0, 0);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
rc = sqlite3_create_function(db, "funcxx"
"_123456789_123456789_123456789_123456789_123456789"
@@ -434,9 +420,7 @@ static int abuse_create_function(
"_123456789_123456789_123456789_123456789_123456789"
"_123456789_123456789_123456789_123456789_123456789",
1, SQLITE_UTF8, 0, tStep, 0, 0);
if( rc!=SQLITE_ERROR ) goto abuse_err;
if( sqlite3_errcode(db)!=SQLITE_ERROR ) goto abuse_err;
if( strcmp(sqlite3_errmsg(db), "bad parameters")!=0 ) goto abuse_err;
if( rc!=SQLITE_MISUSE ) goto abuse_err;
/* This last function registration should actually work. Generate
** a no-op function (that always returns NULL) and which has the