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

Function dump_callback

ThirdParty/sqlite/vtksqlite/shell.c:24649–24761  ·  view source on GitHub ↗

** This is a different callback routine used for dumping the database. ** Each row received by this callback consists of a table name, ** the table type ("index" or "table") and SQL to create the table. ** This routine should print text sufficient to recreate the table. */

Source from the content-addressed store, hash-verified

24647** This routine should print text sufficient to recreate the table.
24648*/
24649static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){
24650 int rc;
24651 const char *zTable;
24652 const char *zType;
24653 const char *zSql;
24654 ShellState *p = (ShellState *)pArg;
24655 int dataOnly;
24656 int noSys;
24657
24658 UNUSED_PARAMETER(azNotUsed);
24659 if( nArg!=3 || azArg==0 ) return 0;
24660 zTable = azArg[0];
24661 zType = azArg[1];
24662 zSql = azArg[2];
24663 if( zTable==0 ) return 0;
24664 if( zType==0 ) return 0;
24665 dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
24666 noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
24667
24668 if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
24669 /* no-op */
24670 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
24671 if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out);
24672 }else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){
24673 return 0;
24674 }else if( dataOnly ){
24675 /* no-op */
24676 }else if( cli_strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
24677 char *zIns;
24678 if( !p->writableSchema ){
24679 sqlite3_fputs("PRAGMA writable_schema=ON;\n", p->out);
24680 p->writableSchema = 1;
24681 }
24682 zIns = sqlite3_mprintf(
24683 "INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)"
24684 "VALUES('table','%q','%q',0,'%q');",
24685 zTable, zTable, zSql);
24686 shell_check_oom(zIns);
24687 sqlite3_fprintf(p->out, "%s\n", zIns);
24688 sqlite3_free(zIns);
24689 return 0;
24690 }else{
24691 printSchemaLine(p->out, zSql, ";\n");
24692 }
24693
24694 if( cli_strcmp(zType, "table")==0 ){
24695 ShellText sSelect;
24696 ShellText sTable;
24697 char **azCol;
24698 int i;
24699 char *savedDestTable;
24700 int savedMode;
24701
24702 azCol = tableColumnList(p, zTable);
24703 if( azCol==0 ){
24704 p->nErr++;
24705 return 0;
24706 }

Callers

nothing calls this directly

Calls 14

cli_strcmpFunction · 0.85
sqlite3_fputsFunction · 0.85
cli_strncmpFunction · 0.85
shell_check_oomFunction · 0.85
sqlite3_fprintfFunction · 0.85
printSchemaLineFunction · 0.85
tableColumnListFunction · 0.85
initTextFunction · 0.85
appendTextFunction · 0.85
quoteCharFunction · 0.85
freeColumnListFunction · 0.85
shell_execFunction · 0.85

Tested by

no test coverage detected