1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Provide the SQLITE_DIRECTONLY flag for app-defined functions that prohibits

the use of those functions within triggers or views.

FossilOrigin-Name: fc745845d8d76adc165575e2192f4176e3c28e614c72571d56f4011560499fe1
This commit is contained in:
drh
2019-08-15 20:04:09 +00:00
parent 725dd72400
commit 42d2fce7f5
11 changed files with 131 additions and 54 deletions

View File

@@ -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;
}