diff options
author | dan <dan@noemail.net> | 2018-06-18 17:36:41 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2018-06-18 17:36:41 +0000 |
commit | f87e10c75ebb107c98ebf441d0cc753ec2442a54 (patch) | |
tree | f566deb9c98d6f8c2489425d414f4d1367fde5e4 /src | |
parent | 660af939b00f8a8d44d67f0dce5824ee07750d45 (diff) | |
download | sqlite-f87e10c75ebb107c98ebf441d0cc753ec2442a54.tar.gz sqlite-f87e10c75ebb107c98ebf441d0cc753ec2442a54.zip |
Ensure that all four callbacks are provided when registering a window function
(otherwise SQLITE_MISUSE is returned).
FossilOrigin-Name: 5720dcd8b111b1f8712c8fb4b441ccb129e838db8c26a6e9e0f095dc6a851f6b
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/test_window.c | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c index 9f6061bea..78a8d61aa 100644 --- a/src/main.c +++ b/src/main.c @@ -1696,6 +1696,7 @@ int sqlite3CreateFunc( (xSFunc && (xFinal || xStep)) || (!xSFunc && (xFinal && !xStep)) || (!xSFunc && (!xFinal && xStep)) || + ((xValue || xInverse) && (!xStep || !xFinal || !xValue || !xInverse)) || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) || (255<(nName = sqlite3Strlen30( zFunctionName))) ){ return SQLITE_MISUSE_BKPT; diff --git a/src/test_window.c b/src/test_window.c index e04de5eb0..31dcb8e1e 100644 --- a/src/test_window.c +++ b/src/test_window.c @@ -176,6 +176,49 @@ static int SQLITE_TCLAPI test_create_window( return TCL_OK; } +static int SQLITE_TCLAPI test_create_window_misuse( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3 *db; + int rc; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + + rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0, + 0, testWindowFinal, testWindowValue, testWindowInverse, + 0 + ); + if( rc!=SQLITE_MISUSE ) goto error; + rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0, + testWindowStep, 0, testWindowValue, testWindowInverse, + 0 + ); + if( rc!=SQLITE_MISUSE ) goto error; + rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0, + testWindowStep, testWindowFinal, 0, testWindowInverse, + 0 + ); + if( rc!=SQLITE_MISUSE ) goto error; + rc = sqlite3_create_window_function(db, "fff", -1, SQLITE_UTF8, 0, + testWindowStep, testWindowFinal, testWindowValue, 0, + 0 + ); + if( rc!=SQLITE_MISUSE ) goto error; + + return TCL_OK; + + error: + Tcl_SetObjResult(interp, Tcl_NewStringObj("misuse test error", -1)); + return TCL_ERROR; +} + int Sqlitetest_window_Init(Tcl_Interp *interp){ static struct { char *zName; @@ -183,6 +226,7 @@ int Sqlitetest_window_Init(Tcl_Interp *interp){ int clientData; } aObjCmd[] = { { "sqlite3_create_window_function", test_create_window, 0 }, + { "test_create_window_function_misuse", test_create_window_misuse, 0 }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |