aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vdbeaux.c14
-rw-r--r--src/vdbetrace.c13
2 files changed, 18 insertions, 9 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 6eeb325b1..b04a1d23f 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -85,12 +85,14 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){
#ifdef SQLITE_OMIT_TRACE
return 0;
#else
- Vdbe *p = (Vdbe *)pStmt;
- char *z;
- if( p==0 || p->zSql==0 ) return 0;
- sqlite3_mutex_enter(p->db->mutex);
- z = sqlite3VdbeExpandSql(p, p->zSql);
- sqlite3_mutex_leave(p->db->mutex);
+ char *z = 0;
+ const char *zSql = sqlite3_sql(pStmt);
+ if( zSql ){
+ Vdbe *p = (Vdbe *)pStmt;
+ sqlite3_mutex_enter(p->db->mutex);
+ z = sqlite3VdbeExpandSql(p, zSql);
+ sqlite3_mutex_leave(p->db->mutex);
+ }
return z;
#endif
}
diff --git a/src/vdbetrace.c b/src/vdbetrace.c
index 7311bc35c..8a1c23bc3 100644
--- a/src/vdbetrace.c
+++ b/src/vdbetrace.c
@@ -81,6 +81,9 @@ char *sqlite3VdbeExpandSql(
int i; /* Loop counter */
Mem *pVar; /* Value of a host parameter */
StrAccum out; /* Accumulate the output here */
+#ifndef SQLITE_OMIT_UTF16
+ Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */
+#endif
char zBase[100]; /* Initial working space */
db = p->db;
@@ -135,12 +138,16 @@ char *sqlite3VdbeExpandSql(
int nOut; /* Number of bytes of the string text to include in output */
#ifndef SQLITE_OMIT_UTF16
u8 enc = ENC(db);
- Mem utf8;
if( enc!=SQLITE_UTF8 ){
memset(&utf8, 0, sizeof(utf8));
utf8.db = db;
- sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
- sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
+ if( SQLITE_NOMEM== sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC)
+ || SQLITE_NOMEM== sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8)
+ ){
+ sqlite3StrAccumReset(&out);
+ sqlite3VdbeMemRelease(&utf8);
+ return 0;
+ }
pVar = &utf8;
}
#endif