MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / dump

Method dump

src/database/cppsqlite3.cpp:1585–1631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1583}
1584
1585bool CppSQLite3DB::dump(const CString& strNewFileName)
1586{
1587 FILE* fp = fopen(strNewFileName.toLocal8Bit(), "wb");
1588 if (!fp)
1589 {
1590 TOLOG1("Failed to open file: %1", strNewFileName);
1591 return false;
1592 }
1593 //
1594 callback_data data;
1595 data.db = mpDB;
1596 data.out = fp;
1597 data.writableSchema = 0;
1598 data.cnt = 0;
1599 data.pStmt = NULL;
1600 //
1601 callback_data* p = &data;
1602 //
1603 fprintf(p->out, "PRAGMA foreign_keys=OFF;\n");
1604 fprintf(p->out, "BEGIN TRANSACTION;\n");
1605 p->writableSchema = 0;
1606 sqlite3_exec(p->db, "PRAGMA writable_schema=ON", 0, 0, 0);
1607
1608 run_schema_dump_query(p,
1609 "SELECT name, type, sql FROM sqlite_master "
1610 "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'", 0
1611 );
1612 run_schema_dump_query(p,
1613 "SELECT name, type, sql FROM sqlite_master "
1614 "WHERE name=='sqlite_sequence'", 0
1615 );
1616 run_table_dump_query(p->out, p->db,
1617 "SELECT sql FROM sqlite_master "
1618 "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0
1619 );
1620 //
1621 if( p->writableSchema ){
1622 fprintf(p->out, "PRAGMA writable_schema=OFF;\n");
1623 p->writableSchema = 0;
1624 }
1625 sqlite3_exec(p->db, "PRAGMA writable_schema=OFF", 0, 0, 0);
1626 fprintf(p->out, "COMMIT;\n");
1627 //
1628 fclose(fp);
1629
1630 return true;
1631}
1632
1633bool CppSQLite3DB::read(const CString& strNewFileName)
1634{

Callers 2

_create_dist_dmgMethod · 0.80
repairMethod · 0.80

Calls 2

run_schema_dump_queryFunction · 0.85
run_table_dump_queryFunction · 0.85

Tested by

no test coverage detected