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

Function tryToClone

lib-src/sqlite/shell.c:15458–15478  ·  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

15456** into zNewDb.
15457*/
15458static void tryToClone(ShellState *p, const char *zNewDb){
15459 int rc;
15460 sqlite3 *newDb = 0;
15461 if( access(zNewDb,0)==0 ){
15462 utf8_printf(stderr, "File \"%s\" already exists.\n", zNewDb);
15463 return;
15464 }
15465 rc = sqlite3_open(zNewDb, &newDb);
15466 if( rc ){
15467 utf8_printf(stderr, "Cannot create output database: %s\n",
15468 sqlite3_errmsg(newDb));
15469 }else{
15470 sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0);
15471 sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0);
15472 tryToCloneSchema(p, newDb, "type='table'", tryToCloneData);
15473 tryToCloneSchema(p, newDb, "type!='table'", 0);
15474 sqlite3_exec(newDb, "COMMIT;", 0, 0, 0);
15475 sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
15476 }
15477 close_db(newDb);
15478}
15479
15480/*
15481** Change the output file back to stdout.

Callers 1

do_meta_commandFunction · 0.85

Calls 3

utf8_printfFunction · 0.85
tryToCloneSchemaFunction · 0.85
close_dbFunction · 0.85

Tested by

no test coverage detected