From: drh Date: Tue, 12 May 2015 21:27:36 +0000 (+0000) Subject: Experimental API extension for recovering the current trace and profile X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25e838549c10b244b451083866d0c3382a271b81;p=thirdparty%2Fsqlite.git Experimental API extension for recovering the current trace and profile callbacks on a database connection. FossilOrigin-Name: 9de33768fff2d8952fdff552d918da96e5267e5d --- diff --git a/manifest b/manifest index 46b8084a52..91ae002aa3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sget\sDBSTAT\sto\scompile\swithout\swarnings\sacross\sall\sbuild\nconfigurations. -D 2015-05-12T19:10:18.469 +C Experimental\sAPI\sextension\sfor\srecovering\sthe\scurrent\strace\sand\sprofile\ncallbacks\son\sa\sdatabase\sconnection. +D 2015-05-12T21:27:36.902 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -196,7 +196,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 29255bbe1cfb2ce9bbff2526a5ecfddcb49b9271 -F src/main.c bf14bc6a321965e528d8ab30087e9440335f2e4b +F src/main.c a6a22e9ec8d7e54f323bf9149e7f0fdf67aa3d11 F src/malloc.c 5bc15d525811d387b37c29f2e368143460e41e96 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -233,7 +233,7 @@ F src/resolve.c 99eabf7eff0bfa65b75939b46caa82e2b2133f28 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 1b0bfc7d59e48c26b895a6b719157111a617d9e3 F src/shell.c 07dda7cd692911d2f22269953418d049f2e2c0ee -F src/sqlite.h.in bf3fe5eba3a5142477b8dae3cfce627c3e971455 +F src/sqlite.h.in 495d16a58094ca33960fcf0eedf9fe2174f05629 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d F src/sqliteInt.h c9f77bd02f419dcc8c644c5032c42eb29069a545 @@ -1258,7 +1258,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P aad3ff257a156b572334b64aa57643ff3ea231a4 -R a7da5ff564874b4b543b1f2446af493d +P c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 +R 7b971252f0e6e36e3477063424ac6a4e +T *branch * get-trace +T *sym-get-trace * +T -sym-trunk * U drh -Z 76dbe37865affc77525affd7f0404dba +Z cac1a8bc14d080a1fbd9585c6a532a77 diff --git a/manifest.uuid b/manifest.uuid index 788a18d042..4ba24aa24d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 \ No newline at end of file +9de33768fff2d8952fdff552d918da96e5267e5d \ No newline at end of file diff --git a/src/main.c b/src/main.c index 83d0b99135..3ffca40acd 100644 --- a/src/main.c +++ b/src/main.c @@ -1763,6 +1763,23 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ return pOld; } /* +** Return the curren trace function and argument. +*/ +void sqlite3_get_trace( + const sqlite3 *db, + void (**pxTrace)(void*,const char*), + void **ppArg +){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif + *pxTrace = db->xTrace; + *ppArg = db->pTraceArg; +} +/* ** Register a profile function. The pArg from the previously registered ** profile function is returned. ** @@ -1790,6 +1807,23 @@ void *sqlite3_profile( sqlite3_mutex_leave(db->mutex); return pOld; } +/* +** Return the curren trace function and argument. +*/ +void sqlite3_get_profile( + const sqlite3 *db, + void (**pxProfile)(void*,const char*,sqlite3_uint64), + void **ppArg +){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif + *pxProfile = db->xProfile; + *ppArg = db->pProfileArg; +} #endif /* SQLITE_OMIT_TRACE */ /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 4a66626b8f..dbecc99ea1 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2672,7 +2672,7 @@ int sqlite3_set_authorizer( ** CAPI3REF: Tracing And Profiling Functions ** METHOD: sqlite3 ** -** These routines register callback functions that can be used for +** These routines control callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** ** ^The callback function registered by sqlite3_trace() is invoked at @@ -2683,6 +2683,10 @@ int sqlite3_set_authorizer( ** as each triggered subprogram is entered. The callbacks for triggers ** contain a UTF-8 SQL comment that identifies the trigger.)^ ** +** ^The [sqlite3_get_trace(D,X,P)] interface writes into X and P the +** values of the trace callback and pointer set by the most recent +** [sqlite3_trace()] call on the same [database connection] D. +** ** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit ** the length of [bound parameter] expansion in the output of sqlite3_trace(). ** @@ -2693,13 +2697,21 @@ int sqlite3_set_authorizer( ** time is in units of nanoseconds, however the current implementation ** is only capable of millisecond resolution so the six least significant ** digits in the time are meaningless. Future versions of SQLite -** might provide greater resolution on the profiler callback. The -** sqlite3_profile() function is considered experimental and is -** subject to change in future versions of SQLite. +** might provide greater resolution on the profiler callback. +** +** ^The [sqlite3_get_profile(D,X,P)] interface writes into X and P the +** values of the profile callback and pointer set by the most recent +** [sqlite3_profile()] call on the same [database connection] D. +** +** All of the tracing and profile interfaces are omitted when the +** [SQLITE_OMIT_TRACE] compile-time option is used. */ void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); -SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, +void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); +void sqlite3_get_trace(const sqlite3*, void(**)(void*,const char*),void**); +void sqlite3_get_profile(const sqlite3*, + void(**)(void*,const char*,sqlite3_uint64),void**); /* ** CAPI3REF: Query Progress Callbacks