MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / printSchemaLine

Function printSchemaLine

modules/dasSQLITE/sqlite/shell.c:17231–17257  ·  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

17229** printing the result. https://sqlite.org/forum/forumpost/d7be961c5c
17230*/
17231static void printSchemaLine(FILE *out, const char *z, const char *zTail){
17232 char *zToFree = 0;
17233 if( z==0 ) return;
17234 if( zTail==0 ) return;
17235 if( zTail[0]==';' && (strstr(z, "/*")!=0 || strstr(z,"--")!=0) ){
17236 const char *zOrig = z;
17237 static const char *azTerm[] = { "", "*/", "\n" };
17238 int i;
17239 for(i=0; i<ArraySize(azTerm); i++){
17240 char *zNew = sqlite3_mprintf("%s%s;", zOrig, azTerm[i]);
17241 if( sqlite3_complete(zNew) ){
17242 size_t n = strlen(zNew);
17243 zNew[n-1] = 0;
17244 zToFree = zNew;
17245 z = zNew;
17246 break;
17247 }
17248 sqlite3_free(zNew);
17249 }
17250 }
17251 if( sqlite3_strglob("CREATE TABLE ['\"]*", z)==0 ){
17252 utf8_printf(out, "CREATE TABLE IF NOT EXISTS %s%s", z+13, zTail);
17253 }else{
17254 utf8_printf(out, "%s%s", z, zTail);
17255 }
17256 sqlite3_free(zToFree);
17257}
17258static void printSchemaLineN(FILE *out, char *z, int n, const char *zTail){
17259 char c = z[n];
17260 z[n] = 0;

Callers 3

printSchemaLineNFunction · 0.85
shell_callbackFunction · 0.85
dump_callbackFunction · 0.85

Calls 1

utf8_printfFunction · 0.85

Tested by

no test coverage detected