1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Change SQLITE_TRACE_STMT to return unexpanded SQL text in the X argument.

Add documentation on how and when to use sqlite3_expanded_sql(P) to compute
the expanded text for legacy sqlite3_trace() compatibility.

FossilOrigin-Name: 163e15229d837a5471007cffb8d41faafd081737
This commit is contained in:
drh
2016-07-25 02:31:48 +00:00
parent 087ec072ef
commit bd441f7700
5 changed files with 21 additions and 15 deletions

View File

@@ -6785,21 +6785,24 @@ case OP_Init: { /* jump */
char *z;
#ifndef SQLITE_OMIT_TRACE
/* If the P4 argument is not NULL, then it must be an SQL comment string.
** The "--" string is broken up to prevent false-positives with srcck1.c */
assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 );
if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
&& !p->doingRerun
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
){
z = sqlite3VdbeExpandSql(p, zTrace);
#ifndef SQLITE_OMIT_DEPRECATED
if( db->mTrace & SQLITE_TRACE_LEGACY ){
void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
z = sqlite3VdbeExpandSql(p, zTrace);
x(db->pTraceArg, z);
sqlite3_free(z);
}else
#endif
{
(void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z);
(void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
}
sqlite3_free(z);
}
#ifdef SQLITE_USE_FCNTL_TRACE
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);