diff options
author | drh <drh@noemail.net> | 2019-08-15 20:04:09 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-08-15 20:04:09 +0000 |
commit | 42d2fce7f5b5e5776f3e881b4685deae2e0266ff (patch) | |
tree | a4f50bf4bc48899b6c53de834a91112d4a164e3e /src/tclsqlite.c | |
parent | 725dd72400872da94dcfb6af48128905b93d57fe (diff) | |
download | sqlite-42d2fce7f5b5e5776f3e881b4685deae2e0266ff.tar.gz sqlite-42d2fce7f5b5e5776f3e881b4685deae2e0266ff.zip |
Provide the SQLITE_DIRECTONLY flag for app-defined functions that prohibits
the use of those functions within triggers or views.
FossilOrigin-Name: fc745845d8d76adc165575e2192f4176e3c28e614c72571d56f4011560499fe1
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index a78d5676c..511a9c8a6 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2741,10 +2741,16 @@ deserialize_error: } /* - ** $db function NAME [-argcount N] [-deterministic] SCRIPT + ** $db function NAME [OPTIONS] SCRIPT ** ** Create a new SQL function called NAME. Whenever that function is ** called, invoke SCRIPT to evaluate the function. + ** + ** Options: + ** --argcount N Function has exactly N arguments + ** --deterministic The function is pure + ** --directonly Prohibit use inside triggers and views + ** --returntype TYPE Specify the return type of the function */ case DB_FUNCTION: { int flags = SQLITE_UTF8; @@ -2777,6 +2783,9 @@ deserialize_error: if( n>1 && strncmp(z, "-deterministic",n)==0 ){ flags |= SQLITE_DETERMINISTIC; }else + if( n>1 && strncmp(z, "-directonly",n)==0 ){ + flags |= SQLITE_DIRECTONLY; + }else if( n>1 && strncmp(z, "-returntype", n)==0 ){ const char *azType[] = {"integer", "real", "text", "blob", "any", 0}; assert( SQLITE_INTEGER==1 && SQLITE_FLOAT==2 && SQLITE_TEXT==3 ); @@ -2792,7 +2801,8 @@ deserialize_error: eType++; }else{ Tcl_AppendResult(interp, "bad option \"", z, - "\": must be -argcount, -deterministic or -returntype", (char*)0 + "\": must be -argcount, -deterministic, -directonly," + " or -returntype", (char*)0 ); return TCL_ERROR; } |