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

Function run_schema_dump_query

lib-src/sqlite/shell.c:13975–14004  ·  view source on GitHub ↗

** Run zQuery. Use dump_callback() as the callback routine so that ** the contents of the query are output as SQL statements. ** ** If we get a SQLITE_CORRUPT error, rerun the query after appending ** "ORDER BY rowid DESC" to the end. */

Source from the content-addressed store, hash-verified

13973** "ORDER BY rowid DESC" to the end.
13974*/
13975static int run_schema_dump_query(
13976 ShellState *p,
13977 const char *zQuery
13978){
13979 int rc;
13980 char *zErr = 0;
13981 rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);
13982 if( rc==SQLITE_CORRUPT ){
13983 char *zQ2;
13984 int len = strlen30(zQuery);
13985 raw_printf(p->out, "/****** CORRUPTION ERROR *******/\n");
13986 if( zErr ){
13987 utf8_printf(p->out, "/****** %s ******/\n", zErr);
13988 sqlite3_free(zErr);
13989 zErr = 0;
13990 }
13991 zQ2 = malloc( len+100 );
13992 if( zQ2==0 ) return rc;
13993 sqlite3_snprintf(len+100, zQ2, "%s ORDER BY rowid DESC", zQuery);
13994 rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);
13995 if( rc ){
13996 utf8_printf(p->out, "/****** ERROR: %s ******/\n", zErr);
13997 }else{
13998 rc = SQLITE_CORRUPT;
13999 }
14000 sqlite3_free(zErr);
14001 free(zQ2);
14002 }
14003 return rc;
14004}
14005
14006/*
14007** Text of help messages.

Callers 1

do_meta_commandFunction · 0.85

Calls 3

strlen30Function · 0.85
utf8_printfFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected