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

Function run_table_dump_query

src/database/cppsqlite3.cpp:1035–1058  ·  view source on GitHub ↗

** Execute a query statement that has a single result column. Print ** that result column on a line by itself with a semicolon terminator. ** ** This is used, for example, to show the schema of the database by ** querying the SQLITE_MASTER table. */

Source from the content-addressed store, hash-verified

1033** querying the SQLITE_MASTER table.
1034*/
1035static int run_table_dump_query(
1036 FILE *out, /* Send output here */
1037 sqlite3 *db, /* Database to query */
1038 const char *zSelect, /* SELECT statement to extract content */
1039 const char *zFirstRow /* Print before first row, if not NULL */
1040 )
1041{
1042 sqlite3_stmt *pSelect;
1043 int rc;
1044 rc = sqlite3_prepare(db, zSelect, -1, &pSelect, 0);
1045 if( rc!=SQLITE_OK || !pSelect ){
1046 return rc;
1047 }
1048 rc = sqlite3_step(pSelect);
1049 while( rc==SQLITE_ROW ){
1050 if( zFirstRow ){
1051 fprintf(out, "%s", zFirstRow);
1052 zFirstRow = 0;
1053 }
1054 fprintf(out, "%s;\n", sqlite3_column_text(pSelect, 0));
1055 rc = sqlite3_step(pSelect);
1056 }
1057 return sqlite3_finalize(pSelect);
1058}
1059
1060/*
1061** This is a different callback routine used for dumping the database.

Callers 2

dump_callbackFunction · 0.85
dumpMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected