diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/where.c b/src/where.c index 25ad18b28..d3e04808f 100644 --- a/src/where.c +++ b/src/where.c @@ -836,7 +836,8 @@ static void explainAutomaticIndex( const char *zSep = ""; char *zText = 0; int ii = 0; - zText = sqlite3_mprintf("CREATE AUTOMATIC INDEX ON %s(", pTab->zName); + sqlite3_str *pStr = sqlite3_str_new(pParse->db); + sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName); assert( pIdx->nColumn>1 ); assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID ); for(ii=0; ii<(pIdx->nColumn-1); ii++){ @@ -844,13 +845,18 @@ static void explainAutomaticIndex( int iCol = pIdx->aiColumn[ii]; zName = pTab->aCol[iCol].zCnName; - zText = sqlite3_mprintf("%z%s%s", zText, zSep, zName); + sqlite3_str_appendf(pStr, "%s%s", zSep, zName); zSep = ", "; } - *pAddrExplain = sqlite3VdbeExplain( - pParse, 0, "%s)%s", zText, (bPartial ? " WHERE <expr>" : "") - ); - sqlite3_free(zText); + zText = sqlite3_str_finish(pStr); + if( zText==0 ){ + sqlite3OomFault(pParse->db); + }else{ + *pAddrExplain = sqlite3VdbeExplain( + pParse, 0, "%s)%s", zText, (bPartial ? " WHERE <expr>" : "") + ); + sqlite3_free(zText); + } } } #else |