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

Function tryToClone

ThirdParty/sqlite/vtksqlite/shell.c:26304–26324  ·  view source on GitHub ↗

** Open a new database file named "zNewDb". Try to recover as much information ** as possible out of the main database (which might be corrupt) and write it ** into zNewDb. */

Source from the content-addressed store, hash-verified

26302** into zNewDb.
26303*/
26304static void tryToClone(ShellState *p, const char *zNewDb){
26305 int rc;
26306 sqlite3 *newDb = 0;
26307 if( access(zNewDb,0)==0 ){
26308 sqlite3_fprintf(stderr,"File \"%s\" already exists.\n", zNewDb);
26309 return;
26310 }
26311 rc = sqlite3_open(zNewDb, &newDb);
26312 if( rc ){
26313 sqlite3_fprintf(stderr,
26314 "Cannot create output database: %s\n", sqlite3_errmsg(newDb));
26315 }else{
26316 sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0);
26317 sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0);
26318 tryToCloneSchema(p, newDb, "type='table'", tryToCloneData);
26319 tryToCloneSchema(p, newDb, "type!='table'", 0);
26320 sqlite3_exec(newDb, "COMMIT;", 0, 0, 0);
26321 sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
26322 }
26323 close_db(newDb);
26324}
26325
26326#ifndef SQLITE_SHELL_FIDDLE
26327/*

Callers 1

do_meta_commandFunction · 0.85

Calls 4

accessClass · 0.85
sqlite3_fprintfFunction · 0.85
tryToCloneSchemaFunction · 0.85
close_dbFunction · 0.85

Tested by

no test coverage detected