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

Function arRemoveCommand

modules/dasSQLITE/sqlite/shell.c:22304–22340  ·  view source on GitHub ↗

** Implementation of .ar "Remove" command. */

Source from the content-addressed store, hash-verified

22302** Implementation of .ar "Remove" command.
22303*/
22304static int arRemoveCommand(ArCommand *pAr){
22305 int rc = 0;
22306 char *zSql = 0;
22307 char *zWhere = 0;
22308
22309 if( pAr->nArg ){
22310 /* Verify that args actually exist within the archive before proceeding.
22311 ** And formulate a WHERE clause to match them. */
22312 rc = arCheckEntries(pAr);
22313 arWhereClause(&rc, pAr, &zWhere);
22314 }
22315 if( rc==SQLITE_OK ){
22316 zSql = sqlite3_mprintf("DELETE FROM %s WHERE %s;",
22317 pAr->zSrcTable, zWhere);
22318 if( pAr->bDryRun ){
22319 utf8_printf(pAr->p->out, "%s\n", zSql);
22320 }else{
22321 char *zErr = 0;
22322 rc = sqlite3_exec(pAr->db, "SAVEPOINT ar;", 0, 0, 0);
22323 if( rc==SQLITE_OK ){
22324 rc = sqlite3_exec(pAr->db, zSql, 0, 0, &zErr);
22325 if( rc!=SQLITE_OK ){
22326 sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0);
22327 }else{
22328 rc = sqlite3_exec(pAr->db, "RELEASE ar;", 0, 0, 0);
22329 }
22330 }
22331 if( zErr ){
22332 utf8_printf(stdout, "ERROR: %s\n", zErr);
22333 sqlite3_free(zErr);
22334 }
22335 }
22336 }
22337 sqlite3_free(zWhere);
22338 sqlite3_free(zSql);
22339 return rc;
22340}
22341
22342/*
22343** Implementation of .ar "eXtract" command.

Callers 1

arDotCommandFunction · 0.85

Calls 4

arCheckEntriesFunction · 0.85
arWhereClauseFunction · 0.85
utf8_printfFunction · 0.85
sqlite3_execFunction · 0.85

Tested by

no test coverage detected