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

Function printSchemaLine

ThirdParty/sqlite/vtksqlite/shell.c:22281–22308  ·  view source on GitHub ↗

** Print a schema statement. Part of MODE_Semi and MODE_Pretty output. ** ** This routine converts some CREATE TABLE statements for shadow tables ** in FTS3/4/5 into CREATE TABLE IF NOT EXISTS statements. ** ** If the schema statement in z[] contains a start-of-comment and if ** sqlite3_complete() returns false, try to terminate the comment before ** printing the result. https://sqlite.org/forum

Source from the content-addressed store, hash-verified

22279** printing the result. https://sqlite.org/forum/forumpost/d7be961c5c
22280*/
22281static void printSchemaLine(FILE *out, const char *z, const char *zTail){
22282 char *zToFree = 0;
22283 if( z==0 ) return;
22284 if( zTail==0 ) return;
22285 if( zTail[0]==';' && (strstr(z, "/*")!=0 || strstr(z,"--")!=0) ){
22286 const char *zOrig = z;
22287 static const char *azTerm[] = { "", "*/", "\n" };
22288 int i;
22289 for(i=0; i<ArraySize(azTerm); i++){
22290 char *zNew = sqlite3_mprintf("%s%s;", zOrig, azTerm[i]);
22291 shell_check_oom(zNew);
22292 if( sqlite3_complete(zNew) ){
22293 size_t n = strlen(zNew);
22294 zNew[n-1] = 0;
22295 zToFree = zNew;
22296 z = zNew;
22297 break;
22298 }
22299 sqlite3_free(zNew);
22300 }
22301 }
22302 if( sqlite3_strglob("CREATE TABLE ['\"]*", z)==0 ){
22303 sqlite3_fprintf(out, "CREATE TABLE IF NOT EXISTS %s%s", z+13, zTail);
22304 }else{
22305 sqlite3_fprintf(out, "%s%s", z, zTail);
22306 }
22307 sqlite3_free(zToFree);
22308}
22309static void printSchemaLineN(FILE *out, char *z, int n, const char *zTail){
22310 char c = z[n];
22311 z[n] = 0;

Callers 3

printSchemaLineNFunction · 0.85
shell_callbackFunction · 0.85
dump_callbackFunction · 0.85

Calls 2

shell_check_oomFunction · 0.85
sqlite3_fprintfFunction · 0.85

Tested by

no test coverage detected