MCPcopy Create free account
hub / github.com/Kitware/VTK / shell_exec

Function shell_exec

ThirdParty/sqlite/vtksqlite/shell.c:24363–24508  ·  view source on GitHub ↗

** Execute a statement or set of statements. Print ** any result rows/columns depending on the current mode ** set via the supplied callback. ** ** This is very similar to SQLite's built-in sqlite3_exec() ** function except it takes a slightly different callback ** and callback data argument. */

Source from the content-addressed store, hash-verified

24361** and callback data argument.
24362*/
24363static int shell_exec(
24364 ShellState *pArg, /* Pointer to ShellState */
24365 const char *zSql, /* SQL to be evaluated */
24366 char **pzErrMsg /* Error msg written here */
24367){
24368 sqlite3_stmt *pStmt = NULL; /* Statement to execute. */
24369 int rc = SQLITE_OK; /* Return Code */
24370 int rc2;
24371 const char *zLeftover; /* Tail of unprocessed SQL */
24372 sqlite3 *db = pArg->db;
24373
24374 if( pzErrMsg ){
24375 *pzErrMsg = NULL;
24376 }
24377
24378#ifndef SQLITE_OMIT_VIRTUALTABLE
24379 if( pArg->expert.pExpert ){
24380 rc = expertHandleSQL(pArg, zSql, pzErrMsg);
24381 return expertFinish(pArg, (rc!=SQLITE_OK), pzErrMsg);
24382 }
24383#endif
24384
24385 while( zSql[0] && (SQLITE_OK == rc) ){
24386 static const char *zStmtSql;
24387 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
24388 if( SQLITE_OK != rc ){
24389 if( pzErrMsg ){
24390 *pzErrMsg = save_err_msg(db, "in prepare", rc, zSql);
24391 }
24392 }else{
24393 if( !pStmt ){
24394 /* this happens for a comment or white-space */
24395 zSql = zLeftover;
24396 while( IsSpace(zSql[0]) ) zSql++;
24397 continue;
24398 }
24399 zStmtSql = sqlite3_sql(pStmt);
24400 if( zStmtSql==0 ) zStmtSql = "";
24401 while( IsSpace(zStmtSql[0]) ) zStmtSql++;
24402
24403 /* save off the prepared statement handle and reset row count */
24404 if( pArg ){
24405 pArg->pStmt = pStmt;
24406 pArg->cnt = 0;
24407 }
24408
24409 /* Show the EXPLAIN QUERY PLAN if .eqp is on */
24410 if( pArg && pArg->autoEQP && sqlite3_stmt_isexplain(pStmt)==0 ){
24411 sqlite3_stmt *pExplain;
24412 int triggerEQP = 0;
24413 disable_debug_trace_modes();
24414 sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, -1, &triggerEQP);
24415 if( pArg->autoEQP>=AUTOEQP_trigger ){
24416 sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
24417 }
24418 pExplain = pStmt;
24419 sqlite3_reset(pExplain);
24420 rc = sqlite3_stmt_explain(pExplain, 2);

Callers 4

dump_callbackFunction · 0.85
do_meta_commandFunction · 0.85
runOneSqlLineFunction · 0.85
wmainFunction · 0.85

Calls 14

expertHandleSQLFunction · 0.85
expertFinishFunction · 0.85
save_err_msgFunction · 0.85
bind_prepared_stmtFunction · 0.85
eqp_renderFunction · 0.85
eqp_appendFunction · 0.85
explain_data_prepareFunction · 0.85
exec_prepared_stmtFunction · 0.85
explain_data_deleteFunction · 0.85
display_statsFunction · 0.85

Tested by

no test coverage detected