MCPcopy Create free account
hub / github.com/audacity/audacity / sqlite3_expert_sql

Function sqlite3_expert_sql

lib-src/sqlite/shell.c:10201–10244  ·  view source on GitHub ↗

** Add an SQL statement to the analysis. */

Source from the content-addressed store, hash-verified

10199** Add an SQL statement to the analysis.
10200*/
10201int sqlite3_expert_sql(
10202 sqlite3expert *p, /* From sqlite3_expert_new() */
10203 const char *zSql, /* SQL statement to add */
10204 char **pzErr /* OUT: Error message (if any) */
10205){
10206 IdxScan *pScanOrig = p->pScan;
10207 IdxStatement *pStmtOrig = p->pStatement;
10208 int rc = SQLITE_OK;
10209 const char *zStmt = zSql;
10210
10211 if( p->bRun ) return SQLITE_MISUSE;
10212
10213 while( rc==SQLITE_OK && zStmt && zStmt[0] ){
10214 sqlite3_stmt *pStmt = 0;
10215 rc = sqlite3_prepare_v2(p->dbv, zStmt, -1, &pStmt, &zStmt);
10216 if( rc==SQLITE_OK ){
10217 if( pStmt ){
10218 IdxStatement *pNew;
10219 const char *z = sqlite3_sql(pStmt);
10220 int n = STRLEN(z);
10221 pNew = (IdxStatement*)idxMalloc(&rc, sizeof(IdxStatement) + n+1);
10222 if( rc==SQLITE_OK ){
10223 pNew->zSql = (char*)&pNew[1];
10224 memcpy(pNew->zSql, z, n+1);
10225 pNew->pNext = p->pStatement;
10226 if( p->pStatement ) pNew->iId = p->pStatement->iId+1;
10227 p->pStatement = pNew;
10228 }
10229 sqlite3_finalize(pStmt);
10230 }
10231 }else{
10232 idxDatabaseError(p->dbv, pzErr);
10233 }
10234 }
10235
10236 if( rc!=SQLITE_OK ){
10237 idxScanFree(p->pScan, pScanOrig);
10238 idxStatementFree(p->pStatement, pStmtOrig);
10239 p->pScan = pScanOrig;
10240 p->pStatement = pStmtOrig;
10241 }
10242
10243 return rc;
10244}
10245
10246int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){
10247 int rc;

Callers 1

expertHandleSQLFunction · 0.85

Calls 4

idxMallocFunction · 0.85
idxDatabaseErrorFunction · 0.85
idxScanFreeFunction · 0.85
idxStatementFreeFunction · 0.85

Tested by

no test coverage detected