diff options
author | drh <drh@noemail.net> | 2020-01-09 20:44:37 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-01-09 20:44:37 +0000 |
commit | bebce86cde221fdaaf084d296ab811af1e5a3cf2 (patch) | |
tree | 14fce64f57bc80fffa399ae283d980e06ea91a27 /src/pragma.c | |
parent | 32d184e049b5a30d39b01be1b310c563ae716d23 (diff) | |
parent | b84fda37efdd612288c1bc4933fa3ae6bcc2ffbc (diff) | |
download | sqlite-bebce86cde221fdaaf084d296ab811af1e5a3cf2.tar.gz sqlite-bebce86cde221fdaaf084d296ab811af1e5a3cf2.zip |
Merge in the untrusted-schema enhancements.
See [/doc/87aea3ab1cdda453/doc/trusted-schema.md|doc/trusted-schema.md]
for details.
FossilOrigin-Name: 5720924cb07766cd54fb042da58f4b4acf12b60029fba86a23a606ad0d0f7c68
Diffstat (limited to 'src/pragma.c')
-rw-r--r-- | src/pragma.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/pragma.c b/src/pragma.c index 9b83807c6..9c292e163 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -296,6 +296,55 @@ static const PragmaName *pragmaLocate(const char *zName){ } /* +** Create zero or more entries in the output for the SQL functions +** defined by FuncDef p. +*/ +static void pragmaFunclistLine( + Vdbe *v, /* The prepared statement being created */ + FuncDef *p, /* A particular function definition */ + int isBuiltin, /* True if this is a built-in function */ + int showInternFuncs /* True if showing internal functions */ +){ + for(; p; p=p->pNext){ + const char *zType; + static const u32 mask = + SQLITE_DETERMINISTIC | + SQLITE_DIRECTONLY | + SQLITE_SUBTYPE | + SQLITE_INNOCUOUS | + SQLITE_FUNC_INTERNAL + ; + static const char *azEnc[] = { 0, "utf8", "utf16le", "utf16be" }; + + assert( SQLITE_FUNC_ENCMASK==0x3 ); + assert( strcmp(azEnc[SQLITE_UTF8],"utf8")==0 ); + assert( strcmp(azEnc[SQLITE_UTF16LE],"utf16le")==0 ); + assert( strcmp(azEnc[SQLITE_UTF16BE],"utf16be")==0 ); + + if( p->xSFunc==0 ) continue; + if( (p->funcFlags & SQLITE_FUNC_INTERNAL)!=0 + && showInternFuncs==0 + ){ + continue; + } + if( p->xValue!=0 ){ + zType = "w"; + }else if( p->xFinalize!=0 ){ + zType = "a"; + }else{ + zType = "s"; + } + sqlite3VdbeMultiLoad(v, 1, "sissii", + p->zName, isBuiltin, + zType, azEnc[p->funcFlags&SQLITE_FUNC_ENCMASK], + p->nArg, + (p->funcFlags & mask) ^ SQLITE_INNOCUOUS + ); + } +} + + +/* ** Helper subroutine for PRAGMA integrity_check: ** ** Generate code to output a single-column result row with a value of the @@ -1259,16 +1308,16 @@ void sqlite3Pragma( int i; HashElem *j; FuncDef *p; - pParse->nMem = 2; + int showInternFunc = (db->mDbFlags & DBFLAG_InternalFunc)!=0; + pParse->nMem = 6; for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){ for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){ - if( p->funcFlags & SQLITE_FUNC_INTERNAL ) continue; - sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1); + pragmaFunclistLine(v, p, 1, showInternFunc); } } for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){ p = (FuncDef*)sqliteHashData(j); - sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0); + pragmaFunclistLine(v, p, 0, showInternFunc); } } break; |