MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / sqlite3_expert_sql

Function sqlite3_expert_sql

modules/dasSQLITE/sqlite/shell.c:12109–12152  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

12107** Add an SQL statement to the analysis.
12108*/
12109int sqlite3_expert_sql(
12110 sqlite3expert *p, /* From sqlite3_expert_new() */
12111 const char *zSql, /* SQL statement to add */
12112 char **pzErr /* OUT: Error message (if any) */
12113){
12114 IdxScan *pScanOrig = p->pScan;
12115 IdxStatement *pStmtOrig = p->pStatement;
12116 int rc = SQLITE_OK;
12117 const char *zStmt = zSql;
12118
12119 if( p->bRun ) return SQLITE_MISUSE;
12120
12121 while( rc==SQLITE_OK && zStmt && zStmt[0] ){
12122 sqlite3_stmt *pStmt = 0;
12123 rc = sqlite3_prepare_v2(p->dbv, zStmt, -1, &pStmt, &zStmt);
12124 if( rc==SQLITE_OK ){
12125 if( pStmt ){
12126 IdxStatement *pNew;
12127 const char *z = sqlite3_sql(pStmt);
12128 int n = STRLEN(z);
12129 pNew = (IdxStatement*)idxMalloc(&rc, sizeof(IdxStatement) + n+1);
12130 if( rc==SQLITE_OK ){
12131 pNew->zSql = (char*)&pNew[1];
12132 memcpy(pNew->zSql, z, n+1);
12133 pNew->pNext = p->pStatement;
12134 if( p->pStatement ) pNew->iId = p->pStatement->iId+1;
12135 p->pStatement = pNew;
12136 }
12137 sqlite3_finalize(pStmt);
12138 }
12139 }else{
12140 idxDatabaseError(p->dbv, pzErr);
12141 }
12142 }
12143
12144 if( rc!=SQLITE_OK ){
12145 idxScanFree(p->pScan, pScanOrig);
12146 idxStatementFree(p->pStatement, pStmtOrig);
12147 p->pScan = pScanOrig;
12148 p->pStatement = pStmtOrig;
12149 }
12150
12151 return rc;
12152}
12153
12154int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){
12155 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