MCPcopy Create free account
hub / github.com/MariaDB/server / print_query

Function print_query

scripts/comp_sql.c:79–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77#define MAX_COLUMN 16000
78
79static void print_query(FILE *out, const char *query)
80{
81 const char *ptr= query;
82 int column= 0;
83
84 fprintf(out, "\"");
85 while (*ptr)
86 {
87 if (column >= MAX_COLUMN)
88 {
89 /* Wrap to the next line, tabulated. */
90 fprintf(out, "\"\n \"");
91 column= 2;
92 }
93 switch(*ptr)
94 {
95 case '\n':
96 /*
97 Preserve the \n character in the query text,
98 and wrap to the next line, tabulated.
99 */
100 fprintf(out, "\\n\"\n \"");
101 column= 2;
102 break;
103 case '\r':
104 /* Skipped */
105 break;
106 case '\"':
107 fprintf(out, "\\\"");
108 column+=2;
109 break;
110 case '\\':
111 fprintf(out, "\\\\");
112 column+=2;
113 break;
114 default:
115 putc(*ptr, out);
116 column++;
117 break;
118 }
119 ptr++;
120 }
121 fprintf(out, "\\n\",\n");
122}
123
124static char query[MAX_BOOTSTRAP_QUERY_SIZE];
125

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected