typedef struct sqlite3_qrf_spec sqlite3_qrf_spec;
struct sqlite3_qrf_spec {
unsigned char iVersion; /* Version number of this structure */
- unsigned char eFormat; /* Output format */
- unsigned char bShowCNames; /* True to show column names */
- unsigned char eEscape; /* How to deal with control characters */
+ unsigned char eStyle; /* Formatting style. "box", "csv", etc... */
+ unsigned char eEsc; /* How to escape control characters in text */
unsigned char eText; /* Quoting style for text */
unsigned char eBlob; /* Quoting style for BLOBs */
+ unsigned char bColumnNames; /* True to show column names */
unsigned char bWordWrap; /* Try to wrap on word boundaries */
- unsigned char bTxtJsonb; /* Render JSONB blobs as JSON text */
+ unsigned char bTextJsonb; /* Render JSONB blobs as JSON text */
short int mxWidth; /* Maximum width of any column */
int nWidth; /* Number of column width parameters */
short int *aWidth; /* Column widths */
const char *zRowSep; /* Alternative row separator */
const char *zTableName; /* Output table name */
const char *zNull; /* Rendering of NULL */
- const char *zFloatFmt; /* printf-style string for rendering floats */
char *(*xRender)(void*,sqlite3_value*); /* Render a value */
ssize_t (*xWrite)(void*,const unsigned char*,size_t); /* Write callback */
void *pRenderArg; /* First argument to the xRender callback */
### 2.3 Output Format
-The sqlite3_qrf_spec.eFormat field is an integer code that defines the
+The sqlite3_qrf_spec.eStyle field is an integer code that defines the
specific output format that will be generated. See the
output format describes below for additional detail.
Other fields in sqlite3_qrf_spec may be used or may be
-ignored, depending on the value of eFormat.
+ignored, depending on the value of eStyle.
-### 2.4 Show Column Names (bShowCNames)
+### 2.4 Show Column Names (bColumnNames)
-The sqlite3_qrf_spec.bShowCNames field is a boolean. If true, then column
+The sqlite3_qrf_spec.bColumnNames field is a boolean. If true, then column
names appear in the output. If false, column names are omitted.
-### 2.5 Control Character Escapes (eEscape)
+### 2.5 Control Character Escapes (eEsc)
-The sqlite3_qrf_spec.eEscape determines how ASCII control characters are
+The sqlite3_qrf_spec.eEsc determines how ASCII control characters are
formatted when displaying TEXT values in the result. These are the allowed
values:
#define QRF_ESC_Off 2 /* Do not escape control characters */
~~~
-If the value of eEscape is zero, then the control character
+If the value of eEsc is zero, then the control character
with value X is displayed as ^Y where Y is X+0x40. Hence, a
backspace character (U+0008) is shown as "^H". This is the
default.
-If eEscape is one, then control characters in the range of U+0001
+If eEsc is one, then control characters in the range of U+0001
through U+001f are mapped into U+2401 through U+241f, respectively.
-If the value of eEscape is two, then no translation occurs
+If the value of eEsc is two, then no translation occurs
and control characters that appear in TEXT string are transmitted
to the formatted output as-is. This an be dangerous in applications,
since an adversary who can control TEXT values might be able to
The sqlite3_qrf_spec.eText field can have one of the following values:
> ~~~
-#define QRF_TXT_Off 0 /* Literal text */
-#define QRF_TXT_Sql 1 /* Quote as an SQL literal */
-#define QRF_TXT_Csv 2 /* CSV-style quoting */
-#define QRF_TXT_Html 3 /* HTML-style quoting */
-#define QRF_TXT_Tcl 4 /* C/Tcl quoting */
-#define QRF_TXT_Json 5 /* JSON quoting */
+#define QRF_TEXT_Off 0 /* Literal text */
+#define QRF_TEXT_Sql 1 /* Quote as an SQL literal */
+#define QRF_TEXT_Csv 2 /* CSV-style quoting */
+#define QRF_TEXT_Html 3 /* HTML-style quoting */
+#define QRF_TEXT_Tcl 4 /* C/Tcl quoting */
+#define QRF_TEXT_Json 5 /* JSON quoting */
~~~
-A value of QRF_TXT_Off means that text value appear in the output exactly
+A value of QRF_TEXT_Off means that text value appear in the output exactly
as they are found in the database file, with no translation.
-A value of QRF_TXT_Sql means that text values are escaped so that they
+A value of QRF_TEXT_Sql means that text values are escaped so that they
appears as SQL literals. That means the value will be surrounded by
single-quotes (U+0027) and any single-quotes contained within the text
will be doubled.
-A value of QRF_TXT_Csv means that text values are escaped in accordance
+A value of QRF_TEXT_Csv means that text values are escaped in accordance
with RFC 4180, which defines Comma-Separated-Value or CSV files.
Text strings that contain no special values appears as-is. Text strings
that contain special values are contained in double-quotes (U+0022) and
any double-quotes within the value are doubled.
-A value of QRF_TXT_Html means that text values are escaped for use in
+A value of QRF_TEXT_Html means that text values are escaped for use in
HTML. Special characters "<", "&", ">", """, and "'"
are displayed as "&lt;", "&amp;", "&gt;", "&quot;",
and "&#39;", respectively.
-A value of QRF_TXT_Tcl means that text values are displayed inside of
+A value of QRF_TEXT_Tcl means that text values are displayed inside of
double-quotes and special characters within the string are escaped using
backslash escape, as in ANSI-C or TCL or Perl or other popular programming
languages.
-A value of QRF_TXT_Json gives similar results as QRF_TXT_Tcl except that the
+A value of QRF_TEXT_Json gives similar results as QRF_TEXT_Tcl except that the
rules are adjusted so that the displayed string is strictly conforming
the JSON specification.
-### 2.7 How to display BLOB values (eBlob and bTxtJsonb)
+### 2.7 How to display BLOB values (eBlob and bTextJsonb)
-If the sqlite3_qrf_spec.bTxtJsonb flag is true and if the value to be
+If the sqlite3_qrf_spec.bTextJsonb flag is true and if the value to be
displayed is JSONB, then the JSONB is translated into text JSON and the
text is shown according to the sqlite3_qrf_spec.eText setting as
described in the previous section.
-If the bTxtJsonb flag is false (the usual case) or if the BLOB value to
+If the bTextJsonb flag is false (the usual case) or if the BLOB value to
be displayed is not JSONB, then the sqlite3_qrf_spec.eBlob field determines
how the BLOB value is formatted. The following options are available;
~~~
A value of QRF_BLOB_Auto means that display format is selected automatically
-by sqlite3_format_query_result() based on eFormat and eText.
+by sqlite3_format_query_result() based on eStyle and eText.
A value of QRF_BLOB_Text means that BLOB values are interpreted as UTF8
-text and are displayed using formatting results set by eEscape and
+text and are displayed using formatting results set by eEsc and
eText.
A value of QRF_BLOB_Sql means that BLOB values are shown as SQL BLOB
### 2.8 Word Wrapping In Columnar Modes (mxWidth and bWordWrap)
-When using columnar formatting modes (QRF_MODE_Box, QRF_MODE_Column,
-QRF_MODE_Markdown, or QRF_MODE_Table) and with sqlite3_qrf_spec.mxWidth
+When using columnar formatting modes (QRF_STYLE_Box, QRF_STYLE_Column,
+QRF_STYLE_Markdown, or QRF_STYLE_Table) and with sqlite3_qrf_spec.mxWidth
set to some non-zero value, then when an output is two wide to be
displayed in just mxWidth standard character widths, the output is
split into multiple lines, where each line is a maximum of
The sqlite3_qrf_spec.aWidth field is a pointer to an array of
signed 16-bit integers that control column widths and alignments
-in columnar output modes (QRF_MODE_Box, QRF_MODE_Column,
-QRF_MODE_Markdown, or QRF_MODE_Table). The sqlite3_qrf_spec.nWidth
+in columnar output modes (QRF_STYLE_Box, QRF_STYLE_Column,
+QRF_STYLE_Markdown, or QRF_STYLE_Table). The sqlite3_qrf_spec.nWidth
field is the number of integers in the aWidth array.
If aWidth is a NULL pointer or nWidth is zero, then the array is
### 2.11 The Output Table Name
The sqlite3_qrf_spec.zTableName value is the name of the output table
-when eFormat is QRF_MODE_Insert.
+when eStyle is QRF_STYLE_Insert.
### 2.12 The Rendering Of NULL
will take responsibility for freeing the string returned by xRender
after it has finished using it.
-The eText, eBlob, and eEscape settings above become no-ops if the xRender
+The eText, eBlob, and eEsc settings above become no-ops if the xRender
routine returns non-NULL. In other words, the application-supplied
xRender routine is expected to do all of its own quoting and formatting.
## 4.0 Output Modes
The result formatter supports a variety of output modes. The
-output mode used is determined by the eFormat setting of the
+output mode used is determined by the eStyle setting of the
sqlite3_qrf_spec object. The set of supported output modes
might increase in future versions.
The following output modes are currently defined:
> ~~~
-#define QRF_MODE_List 0 /* One record per line with a separator */
-#define QRF_MODE_Line 1 /* One column per line. */
-#define QRF_MODE_Html 2 /* Generate an XHTML table */
-#define QRF_MODE_Json 3 /* Output is a list of JSON objects */
-#define QRF_MODE_Insert 4 /* Generate SQL "insert" statements */
-#define QRF_MODE_Csv 5 /* Comma-separated-value */
-#define QRF_MODE_Quote 6 /* SQL-quoted, comma-separated */
-#define QRF_MODE_Explain 7 /* EXPLAIN output */
-#define QRF_MODE_ScanExp 8 /* EXPLAIN output with vm stats */
-#define QRF_MODE_EQP 9 /* Format EXPLAIN QUERY PLAN output */
-#define QRF_MODE_Markdown 10 /* Markdown formatting */
-#define QRF_MODE_Column 11 /* One record per line in neat columns */
-#define QRF_MODE_Table 12 /* MySQL-style table formatting */
-#define QRF_MODE_Box 13 /* Unicode box-drawing characters */
-#define QRF_MODE_Count 14 /* Output only a count of the rows of output */
-#define QRF_MODE_Off 15 /* No query output shown */
+#define QRF_STYLE_List 0 /* One record per line with a separator */
+#define QRF_STYLE_Line 1 /* One column per line. */
+#define QRF_STYLE_Html 2 /* Generate an XHTML table */
+#define QRF_STYLE_Json 3 /* Output is a list of JSON objects */
+#define QRF_STYLE_Insert 4 /* Generate SQL "insert" statements */
+#define QRF_STYLE_Csv 5 /* Comma-separated-value */
+#define QRF_STYLE_Quote 6 /* SQL-quoted, comma-separated */
+#define QRF_STYLE_Explain 7 /* EXPLAIN output */
+#define QRF_STYLE_ScanExp 8 /* EXPLAIN output with vm stats */
+#define QRF_STYLE_EQP 9 /* Format EXPLAIN QUERY PLAN output */
+#define QRF_STYLE_Markdown 10 /* Markdown formatting */
+#define QRF_STYLE_Column 11 /* One record per line in neat columns */
+#define QRF_STYLE_Table 12 /* MySQL-style table formatting */
+#define QRF_STYLE_Box 13 /* Unicode box-drawing characters */
+#define QRF_STYLE_Count 14 /* Output only a count of the rows of output */
+#define QRF_STYLE_Off 15 /* No query output shown */
~~~
### 5.0 Source Code Files
}
memset(&spec, 0, sizeof(spec));
spec.iVersion = 1;
- spec.eFormat = QRF_MODE_List;
+ spec.eStyle = QRF_STYLE_List;
spec.xWrite = testWriter;
pBuf = sqlite3_str_new(0);
rc = sqlite3_open(":memory:", &db);
}
sqlite3_str_reset(pBuf);
}else
- if( strncmp(zLine, "--eFormat=", 10)==0 ){
- const struct { const char *z; int e; } aFmt[] = {
- { "box", QRF_MODE_Box, },
- { "csv", QRF_MODE_Csv, },
- { "column", QRF_MODE_Column, },
- { "count", QRF_MODE_Count, },
- { "eqp", QRF_MODE_EQP, },
- { "explain", QRF_MODE_Explain, },
- { "html", QRF_MODE_Html, },
- { "insert", QRF_MODE_Insert, },
- { "json", QRF_MODE_Json, },
- { "line", QRF_MODE_Line, },
- { "list", QRF_MODE_List, },
- { "markdown", QRF_MODE_Markdown, },
- { "off", QRF_MODE_Off, },
- { "quote", QRF_MODE_Quote, },
- { "table", QRF_MODE_Table, },
- { "scanexp", QRF_MODE_ScanExp, },
+ if( strncmp(zLine, "--eStyle=", 9)==0 ){
+ const struct { const char *z; int e; } aStyle[] = {
+ { "box", QRF_STYLE_Box, },
+ { "csv", QRF_STYLE_Csv, },
+ { "column", QRF_STYLE_Column, },
+ { "count", QRF_STYLE_Count, },
+ { "eqp", QRF_STYLE_EQP, },
+ { "explain", QRF_STYLE_Explain, },
+ { "html", QRF_STYLE_Html, },
+ { "insert", QRF_STYLE_Insert, },
+ { "json", QRF_STYLE_Json, },
+ { "line", QRF_STYLE_Line, },
+ { "list", QRF_STYLE_List, },
+ { "markdown", QRF_STYLE_Markdown, },
+ { "off", QRF_STYLE_Off, },
+ { "quote", QRF_STYLE_Quote, },
+ { "table", QRF_STYLE_Table, },
+ { "scanexp", QRF_STYLE_ScanExp, },
};
int i;
- for(i=0; i<COUNT(aFmt); i++){
- if( strcmp(aFmt[i].z,&zLine[10])==0 ){
- spec.eFormat = aFmt[i].e;
+ for(i=0; i<COUNT(aStyle); i++){
+ if( strcmp(aStyle[i].z,&zLine[9])==0 ){
+ spec.eStyle = aStyle[i].e;
break;
}
}
- if( i>=COUNT(aFmt) ){
+ if( i>=COUNT(aStyle) ){
sqlite3_str *pMsg = sqlite3_str_new(0);
- for(i=0; i<COUNT(aFmt); i++){
- sqlite3_str_appendf(pMsg, " %s", aFmt[i].z);
+ for(i=0; i<COUNT(aStyle); i++){
+ sqlite3_str_appendf(pMsg, " %s", aStyle[i].z);
}
- fprintf(stderr, "%s:%d: no such format: \"%s\"\nChoices: %s\n",
- zSrc, lineNum, &zLine[10], sqlite3_str_value(pMsg));
+ fprintf(stderr, "%s:%d: no such style: \"%s\"\nChoices: %s\n",
+ zSrc, lineNum, &zLine[9], sqlite3_str_value(pMsg));
sqlite3_free(sqlite3_str_finish(pMsg));
}
}else
- if( strncmp(zLine, "--eText=", 9)==0 ){
+ if( strncmp(zLine, "--eText=", 8)==0 ){
const struct { const char *z; int e; } aQuote[] = {
- { "csv", QRF_TXT_Csv },
- { "html", QRF_TXT_Html },
- { "json", QRF_TXT_Json },
- { "off", QRF_TXT_Off },
- { "sql", QRF_TXT_Sql },
- { "tcl", QRF_TXT_Tcl },
+ { "csv", QRF_TEXT_Csv },
+ { "html", QRF_TEXT_Html },
+ { "json", QRF_TEXT_Json },
+ { "off", QRF_TEXT_Off },
+ { "sql", QRF_TEXT_Sql },
+ { "tcl", QRF_TEXT_Tcl },
};
int i;
for(i=0; i<COUNT(aQuote); i++){
- if( strcmp(aQuote[i].z,&zLine[9])==0 ){
+ if( strcmp(aQuote[i].z,&zLine[8])==0 ){
spec.eText = aQuote[i].e;
break;
}
for(i=0; i<COUNT(aQuote); i++){
sqlite3_str_appendf(pMsg, " %s", aQuote[i].z);
}
- fprintf(stderr, "%s:%d: no such quoting style: \"%s\"\nChoices: %s\n",
- zSrc, lineNum, &zLine[9], sqlite3_str_value(pMsg));
+ fprintf(stderr, "%s:%d: no such text-style: \"%s\"\nChoices: %s\n",
+ zSrc, lineNum, &zLine[8], sqlite3_str_value(pMsg));
sqlite3_free(sqlite3_str_finish(pMsg));
}
}else
for(i=0; i<COUNT(aBlob); i++){
sqlite3_str_appendf(pMsg, " %s", aBlob[i].z);
}
- fprintf(stderr, "%s:%d: no such blob style: \"%s\"\nChoices: %s\n",
+ fprintf(stderr, "%s:%d: no such blob-style: \"%s\"\nChoices: %s\n",
zSrc, lineNum, &zLine[8], sqlite3_str_value(pMsg));
sqlite3_free(sqlite3_str_finish(pMsg));
}
}else
- if( strncmp(zLine, "--eEscape=", 10)==0 ){
+ if( strncmp(zLine, "--eEsc=", 7)==0 ){
const struct { const char *z; int e; } aEscape[] = {
{ "ascii", QRF_ESC_Ascii },
{ "off", QRF_ESC_Off },
};
int i;
for(i=0; i<COUNT(aEscape); i++){
- if( strcmp(aEscape[i].z,&zLine[10])==0 ){
- spec.eEscape = aEscape[i].e;
+ if( strcmp(aEscape[i].z,&zLine[7])==0 ){
+ spec.eEsc = aEscape[i].e;
break;
}
}
sqlite3_free(sqlite3_str_finish(pMsg));
}
}else
- if( strncmp(zLine, "--bShowCNames=", 14)==0 ){
- spec.bShowCNames = atoi(&zLine[14])!=0;
+ if( strncmp(zLine, "--bColumnNames=", 15)==0 ){
+ spec.bColumnNames = atoi(&zLine[15])!=0;
}else
- if( strncmp(zLine, "--bTxtJsonb=", 12)==0 ){
- spec.bTxtJsonb = atoi(&zLine[12])!=0;
+ if( strncmp(zLine, "--bTextJsonb=", 13)==0 ){
+ spec.bTextJsonb = atoi(&zLine[13])!=0;
}else
if( strncmp(zLine, "--zNull=", 8)==0 ){
spec.zNull = tempStrdup(&zLine[8]);
if( strncmp(zLine, "--use-render=",13)==0 ){
spec.xRender = (atoi(&zLine[13])!=0) ? testBlobRender : 0;
}else
+ if( strncmp(zLine, "--",2)==0 && !isspace(zLine[2]) ){
+ fprintf(stderr, "%s:%d: Unrecognized command: \"%s\"\n",
+ zSrc, lineNum, zLine);
+ }else
{
if( sqlite3_str_length(pBuf) ) sqlite3_str_append(pBuf, "\n", 1);
sqlite3_str_appendall(pBuf, zLine);
int iErr; /* Error code */
int nCol; /* Number of output columns */
union {
- struct { /* Content for QRF_MODE_Line */
+ struct { /* Content for QRF_STYLE_Line */
int mxColWth; /* Maximum display width of any column */
const char **azCol; /* Names of output columns (MODE_Line) */
} sLine;
EQPGraph *pGraph; /* EQP graph (MODE_EQP) */
- struct { /* Content for QRF_MODE_Explain */
+ struct { /* Content for QRF_STYLE_Explain */
int nIndent; /* Slots allocated for aiIndent */
int iIndent; /* Current slot */
int *aiIndent; /* Indentation for each opcode */
/*
** Escape the input string if it is needed and in accordance with
-** eEscape, which is either QRF_ESC_Ascii or QRF_ESC_Symbol.
+** eEsc, which is either QRF_ESC_Ascii or QRF_ESC_Symbol.
**
** Escaping is needed if the string contains any control characters
** other than \t, \n, and \r\n
** to reclaim memory.
*/
static void qrfEscape(
- int eEscape, /* QRF_ESC_Ascii or QRF_ESC_Symbol */
+ int eEsc, /* QRF_ESC_Ascii or QRF_ESC_Symbol */
sqlite3_str *pStr, /* String to be escaped */
int iStart /* Begin escapding on this byte of pStr */
){
/* Make space to hold the escapes. Copy the original text to the end
** of the available space. */
sz = sqlite3_str_length(pStr) - iStart;
- if( eEscape==QRF_ESC_Symbol ) nCtrl *= 2;
+ if( eEsc==QRF_ESC_Symbol ) nCtrl *= 2;
sqlite3_str_appendchar(pStr, nCtrl, ' ');
zOut = (unsigned char*)sqlite3_str_value(pStr);
if( zOut==0 ) return;
}
zIn += i+1;
i = -1;
- if( eEscape==QRF_ESC_Symbol ){
+ if( eEsc==QRF_ESC_Symbol ){
zOut[j++] = 0xe2;
zOut[j++] = 0x90;
zOut[j++] = 0x80+c;
static void qrfEncodeText(Qrf *p, sqlite3_str *pOut, const char *zTxt){
int iStart = sqlite3_str_length(pOut);
switch( p->spec.eText ){
- case QRF_TXT_Sql: {
+ case QRF_TEXT_Sql: {
sqlite3_str_appendf(pOut, "%Q", zTxt);
break;
}
- case QRF_TXT_Csv: {
+ case QRF_TEXT_Csv: {
unsigned int i;
for(i=0; zTxt[i]; i++){
if( qrfCsvQuote[((const unsigned char*)zTxt)[i]] ){
}
break;
}
- case QRF_TXT_Html: {
+ case QRF_TEXT_Html: {
const unsigned char *z = (const unsigned char*)zTxt;
while( *z ){
unsigned int i = 0;
}
break;
}
- case QRF_TXT_Tcl:
- case QRF_TXT_Json: {
+ case QRF_TEXT_Tcl:
+ case QRF_TEXT_Json: {
const unsigned char *z = (const unsigned char*)zTxt;
sqlite3_str_append(pOut, "\"", 1);
while( *z ){
case '\r': sqlite3_str_append(pOut, "\\r", 2); break;
case '\t': sqlite3_str_append(pOut, "\\t", 2); break;
default: {
- if( p->spec.eText==QRF_TXT_Json ){
+ if( p->spec.eText==QRF_TEXT_Json ){
sqlite3_str_appendf(pOut, "\\u%04x", z[i]);
}else{
sqlite3_str_appendf(pOut, "\\%03o", z[i]);
break;
}
}
- if( p->spec.eEscape!=QRF_ESC_Off ){
- qrfEscape(p->spec.eEscape, pOut, iStart);
+ if( p->spec.eEsc!=QRF_ESC_Off ){
+ qrfEscape(p->spec.eEsc, pOut, iStart);
}
}
break;
}
case SQLITE_BLOB: {
- if( p->spec.bTxtJsonb ){
+ if( p->spec.bTextJsonb ){
const char *zJson = qrfJsonbToJson(p, iCol);
if( zJson ){
qrfEncodeText(p, pOut, zJson);
}
/*
-** Draw a horizontal separator for a QRF_MODE_Box table.
+** Draw a horizontal separator for a QRF_STYLE_Box table.
*/
static void qrfBoxSeparator(
Qrf *p,
if( sqlite3_is_interrupted(p->db) ) goto qrf_column_end;
/* Generate the column titles */
- switch( p->spec.eFormat ){
- case QRF_MODE_Column: {
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_Column: {
colSep = " ";
rowSep = "\n";
- if( p->spec.bShowCNames ){
+ if( p->spec.bColumnNames ){
for(i=0; i<nColumn; i++){
w = p->actualWidth[i];
if( i<p->spec.nWidth && p->spec.aWidth[i]<0 ) w = -w;
}
break;
}
- case QRF_MODE_Table: {
+ case QRF_STYLE_Table: {
colSep = " | ";
rowSep = " |\n";
qrfRowSeparator(p, "+");
qrfRowSeparator(p, "+");
break;
}
- case QRF_MODE_Markdown: {
+ case QRF_STYLE_Markdown: {
colSep = " | ";
rowSep = " |\n";
sqlite3_str_append(p->pOut, "| ", 2);
qrfRowSeparator(p, "|");
break;
}
- case QRF_MODE_Box: {
+ case QRF_STYLE_Box: {
colSep = " " BOX_13 " ";
rowSep = " " BOX_13 "\n";
qrfBoxSeparator(p, BOX_23, BOX_234, BOX_34);
/* Render the body of the table */
nTotal = nColumn*(nRow+1);
for(i=nColumn, j=0; i<nTotal; i++, j++){
- if( j==0 && p->spec.eFormat!=QRF_MODE_Column ){
+ if( j==0 && p->spec.eStyle!=QRF_STYLE_Column ){
sqlite3_str_appendall(p->pOut,
- p->spec.eFormat==QRF_MODE_Box ? BOX_13" " : "| ");
+ p->spec.eStyle==QRF_STYLE_Box ? BOX_13" " : "| ");
}
z = azData[i];
if( z==0 ) z = "";
if( j==nColumn-1 ){
sqlite3_str_appendall(p->pOut, rowSep);
if( bMultiLineRowExists && abRowDiv[i/nColumn-1] && i+1<nTotal ){
- switch( p->spec.eFormat ){
- case QRF_MODE_Table:
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_Table:
qrfRowSeparator(p, "+");
break;
- case QRF_MODE_Box:
+ case QRF_STYLE_Box:
qrfBoxSeparator(p, BOX_123, BOX_1234, BOX_134);
break;
- case QRF_MODE_Column:
+ case QRF_STYLE_Column:
sqlite3_str_append(p->pOut, "\n", 1);
break;
}
sqlite3_str_appendall(p->pOut, colSep);
}
}
- if( p->spec.eFormat==QRF_MODE_Table ){
+ if( p->spec.eStyle==QRF_STYLE_Table ){
qrfRowSeparator(p, "+");
- }else if( p->spec.eFormat==QRF_MODE_Box ){
+ }else if( p->spec.eStyle==QRF_STYLE_Box ){
qrfBoxSeparator(p, BOX_12, BOX_124, BOX_14);
}
qrfWrite(p);
int nWidth = sizeof(aExplainWidth)/sizeof(int);
int iIndent = 1;
int nArg = p->nCol;
- if( p->spec.eFormat==QRF_MODE_ScanExp ){
+ if( p->spec.eStyle==QRF_STYLE_ScanExp ){
aWidth = aScanExpWidth;
aMap = aScanExpMap;
nWidth = sizeof(aScanExpWidth)/sizeof(int);
sz = sizeof(sqlite3_qrf_spec);
memcpy(&p->spec, pSpec, sz);
if( p->spec.zNull==0 ) p->spec.zNull = "";
- switch( p->spec.eFormat ){
- case QRF_MODE_List: {
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_List: {
if( p->spec.zColumnSep==0 ) p->spec.zColumnSep = "|";
if( p->spec.zRowSep==0 ) p->spec.zRowSep = "\n";
break;
}
- case QRF_MODE_Line: {
+ case QRF_STYLE_Line: {
if( p->spec.zColumnSep==0 ) p->spec.zColumnSep = "\n";
if( p->spec.zRowSep==0 ) p->spec.zRowSep = "\n";
break;
}
- case QRF_MODE_Json: {
+ case QRF_STYLE_Json: {
p->spec.zColumnSep = ",";
- p->spec.eText = QRF_TXT_Json;
+ p->spec.eText = QRF_TEXT_Json;
p->spec.eBlob = QRF_BLOB_Json;
p->spec.zNull = "null";
break;
}
- case QRF_MODE_Html: {
- p->spec.eText = QRF_TXT_Html;
+ case QRF_STYLE_Html: {
+ p->spec.eText = QRF_TEXT_Html;
p->spec.zNull = "null";
break;
}
- case QRF_MODE_Insert: {
- p->spec.eText = QRF_TXT_Sql;
+ case QRF_STYLE_Insert: {
+ p->spec.eText = QRF_TEXT_Sql;
p->spec.eBlob = QRF_BLOB_Sql;
if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
p->spec.zTableName = "tab";
}
break;
}
- case QRF_MODE_Csv: {
- p->spec.eFormat = QRF_MODE_List;
- p->spec.eText = QRF_TXT_Csv;
+ case QRF_STYLE_Csv: {
+ p->spec.eStyle = QRF_STYLE_List;
+ p->spec.eText = QRF_TEXT_Csv;
p->spec.eBlob = QRF_BLOB_Tcl;
p->spec.zColumnSep = ",";
p->spec.zRowSep = "\r\n";
break;
}
- case QRF_MODE_Quote: {
- p->spec.eText = QRF_TXT_Sql;
+ case QRF_STYLE_Quote: {
+ p->spec.eText = QRF_TEXT_Sql;
p->spec.eBlob = QRF_BLOB_Sql;
p->spec.zColumnSep = ",";
p->spec.zRowSep = "\n";
break;
}
- case QRF_MODE_EQP: {
+ case QRF_STYLE_EQP: {
if( sqlite3_stmt_isexplain(p->pStmt)!=2 ){
/* If EQP mode is requested, but the statement is not an EXPLAIN QUERY
** PLAN statement, then convert the mode to a comma-separate list of
** mode is EQP, so do not leave the mode in EQP if the statement is
** not an EQP statement.
*/
- p->spec.eFormat = QRF_MODE_Quote;
- p->spec.bShowCNames = 1;
- p->spec.eText = QRF_TXT_Sql;
+ p->spec.eStyle = QRF_STYLE_Quote;
+ p->spec.bColumnNames = 1;
+ p->spec.eText = QRF_TEXT_Sql;
p->spec.eBlob = QRF_BLOB_Sql;
p->spec.zColumnSep = ",";
p->spec.zRowSep = "\n";
}
break;
}
- case QRF_MODE_Explain: {
+ case QRF_STYLE_Explain: {
if( sqlite3_stmt_isexplain(p->pStmt)!=1 ){
/* If Explain mode is requested, but the statement is not an EXPLAIN
** tatement, then convert the mode to a comma-separate list of
** mode is Explain, so do not leave the mode in Explain if the
** statement is not an EXPLAIN statement.
*/
- p->spec.eFormat = QRF_MODE_Quote;
- p->spec.bShowCNames = 1;
- p->spec.eText = QRF_TXT_Sql;
+ p->spec.eStyle = QRF_STYLE_Quote;
+ p->spec.bColumnNames = 1;
+ p->spec.eText = QRF_TEXT_Sql;
p->spec.eBlob = QRF_BLOB_Sql;
p->spec.zColumnSep = ",";
p->spec.zRowSep = "\n";
}
if( p->spec.eBlob==QRF_BLOB_Auto ){
switch( p->spec.eText ){
- case QRF_TXT_Sql: p->spec.eBlob = QRF_BLOB_Sql; break;
- case QRF_TXT_Csv: p->spec.eBlob = QRF_BLOB_Tcl; break;
- case QRF_TXT_Tcl: p->spec.eBlob = QRF_BLOB_Tcl; break;
- case QRF_TXT_Json: p->spec.eBlob = QRF_BLOB_Json; break;
+ case QRF_TEXT_Sql: p->spec.eBlob = QRF_BLOB_Sql; break;
+ case QRF_TEXT_Csv: p->spec.eBlob = QRF_BLOB_Tcl; break;
+ case QRF_TEXT_Tcl: p->spec.eBlob = QRF_BLOB_Tcl; break;
+ case QRF_TEXT_Json: p->spec.eBlob = QRF_BLOB_Json; break;
default: p->spec.eBlob = QRF_BLOB_Text; break;
}
}
- switch( p->spec.eFormat ){
- case QRF_MODE_List: {
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_List: {
if( p->spec.zColumnSep==0 ) p->spec.zColumnSep = "|";
if( p->spec.zRowSep==0 ) p->spec.zRowSep = "\n";
break;
*/
static void qrfOneSimpleRow(Qrf *p){
int i;
- switch( p->spec.eFormat ){
- case QRF_MODE_Off:
- case QRF_MODE_Count: {
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_Off:
+ case QRF_STYLE_Count: {
/* No-op */
break;
}
- case QRF_MODE_Json: {
+ case QRF_STYLE_Json: {
if( p->nRow==0 ){
sqlite3_str_append(p->pOut, "[{", 2);
}else{
qrfWrite(p);
break;
}
- case QRF_MODE_Html: {
- if( p->nRow==0 && p->spec.bShowCNames ){
+ case QRF_STYLE_Html: {
+ if( p->nRow==0 && p->spec.bColumnNames ){
sqlite3_str_append(p->pOut, "<TR>", 4);
for(i=0; i<p->nCol; i++){
const char *zCName = sqlite3_column_name(p->pStmt, i);
qrfWrite(p);
break;
}
- case QRF_MODE_Insert: {
+ case QRF_STYLE_Insert: {
sqlite3_str_appendf(p->pOut,"INSERT INTO %s VALUES(",p->spec.zTableName);
for(i=0; i<p->nCol; i++){
if( i>0 ) sqlite3_str_append(p->pOut, ",", 1);
qrfWrite(p);
break;
}
- case QRF_MODE_Line: {
+ case QRF_STYLE_Line: {
if( p->u.sLine.azCol==0 ){
p->u.sLine.azCol = sqlite3_malloc64( p->nCol*sizeof(char*) );
if( p->u.sLine.azCol==0 ){
qrfWrite(p);
break;
}
- case QRF_MODE_EQP: {
+ case QRF_STYLE_EQP: {
const char *zEqpLine = (const char*)sqlite3_column_text(p->pStmt,3);
int iEqpId = sqlite3_column_int(p->pStmt, 0);
int iParentId = sqlite3_column_int(p->pStmt, 1);
qrfEqpAppend(p, iEqpId, iParentId, zEqpLine);
break;
}
- default: { /* QRF_MODE_List */
- if( p->nRow==0 && p->spec.bShowCNames ){
+ default: { /* QRF_STYLE_List */
+ if( p->nRow==0 && p->spec.bColumnNames ){
for(i=0; i<p->nCol; i++){
const char *zCName = sqlite3_column_name(p->pStmt, i);
if( i>0 ) sqlite3_str_appendall(p->pOut, p->spec.zColumnSep);
** Finish rendering the results
*/
static void qrfFinalize(Qrf *p){
- switch( p->spec.eFormat ){
- case QRF_MODE_Count: {
+ switch( p->spec.eStyle ){
+ case QRF_STYLE_Count: {
sqlite3_str_appendf(p->pOut, "%lld\n", p->nRow);
qrfWrite(p);
break;
}
- case QRF_MODE_Json: {
+ case QRF_STYLE_Json: {
sqlite3_str_append(p->pOut, "}]\n", 3);
qrfWrite(p);
break;
}
- case QRF_MODE_Line: {
+ case QRF_STYLE_Line: {
if( p->u.sLine.azCol ) sqlite3_free(p->u.sLine.azCol);
break;
}
- case QRF_MODE_EQP: {
+ case QRF_STYLE_EQP: {
qrfEqpRender(p, 0);
qrfWrite(p);
break;
if( pStmt==0 ) return SQLITE_OK; /* No-op */
if( pSpec==0 ) return SQLITE_MISUSE;
qrfInitialize(&qrf, pStmt, pSpec, pzErr);
- switch( qrf.spec.eFormat ){
- case QRF_MODE_Box:
- case QRF_MODE_Column:
- case QRF_MODE_Markdown:
- case QRF_MODE_Table: {
+ switch( qrf.spec.eStyle ){
+ case QRF_STYLE_Box:
+ case QRF_STYLE_Column:
+ case QRF_STYLE_Markdown:
+ case QRF_STYLE_Table: {
/* Columnar modes require that the entire query be evaluated and the
** results stored in memory, so that we can compute column widths */
qrfColumnar(&qrf);
break;
}
- case QRF_MODE_Explain: {
+ case QRF_STYLE_Explain: {
qrfExplain(&qrf);
break;
}
** Header file for the Result-Format or "resfmt" utility library for SQLite.
** See the resfmt.md documentation for additional information.
*/
+#ifndef SQLITE_QRF_H
+#define SQLITE_QRF_H
#include <stdlib.h>
#include "sqlite3.h"
typedef struct sqlite3_qrf_spec sqlite3_qrf_spec;
struct sqlite3_qrf_spec {
unsigned char iVersion; /* Version number of this structure */
- unsigned char eFormat; /* Output format */
- unsigned char bShowCNames; /* True to show column names */
- unsigned char eEscape; /* How to deal with control characters */
+ unsigned char eStyle; /* Formatting style. "box", "csv", etc... */
+ unsigned char eEsc; /* How to escape control characters in text */
unsigned char eText; /* Quoting style for text */
unsigned char eBlob; /* Quoting style for BLOBs */
+ unsigned char bColumnNames; /* True to show column names */
unsigned char bWordWrap; /* Try to wrap on word boundaries */
- unsigned char bTxtJsonb; /* Render JSONB blobs as JSON text */
+ unsigned char bTextJsonb; /* Render JSONB blobs as JSON text */
short int mxWidth; /* Maximum width of any column */
int nWidth; /* Number of column width parameters */
short int *aWidth; /* Column widths */
/*
** Output styles:
*/
-#define QRF_MODE_List 0 /* One record per line with a separator */
-#define QRF_MODE_Line 1 /* One column per line. */
-#define QRF_MODE_Html 2 /* Generate an XHTML table */
-#define QRF_MODE_Json 3 /* Output is a list of JSON objects */
-#define QRF_MODE_Insert 4 /* Generate SQL "insert" statements */
-#define QRF_MODE_Csv 5 /* Comma-separated-value */
-#define QRF_MODE_Quote 6 /* SQL-quoted, comma-separated */
-#define QRF_MODE_Explain 7 /* EXPLAIN output */
-#define QRF_MODE_ScanExp 8 /* EXPLAIN output with vm stats */
-#define QRF_MODE_EQP 9 /* Format EXPLAIN QUERY PLAN output */
-#define QRF_MODE_Markdown 10 /* Markdown formatting */
-#define QRF_MODE_Column 11 /* One record per line in neat columns */
-#define QRF_MODE_Table 12 /* MySQL-style table formatting */
-#define QRF_MODE_Box 13 /* Unicode box-drawing characters */
-#define QRF_MODE_Count 14 /* Output only a count of the rows of output */
-#define QRF_MODE_Off 15 /* No query output shown */
+#define QRF_STYLE_List 0 /* One record per line with a separator */
+#define QRF_STYLE_Line 1 /* One column per line. */
+#define QRF_STYLE_Html 2 /* Generate an XHTML table */
+#define QRF_STYLE_Json 3 /* Output is a list of JSON objects */
+#define QRF_STYLE_Insert 4 /* Generate SQL "insert" statements */
+#define QRF_STYLE_Csv 5 /* Comma-separated-value */
+#define QRF_STYLE_Quote 6 /* SQL-quoted, comma-separated */
+#define QRF_STYLE_Explain 7 /* EXPLAIN output */
+#define QRF_STYLE_ScanExp 8 /* EXPLAIN output with vm stats */
+#define QRF_STYLE_EQP 9 /* Format EXPLAIN QUERY PLAN output */
+#define QRF_STYLE_Markdown 10 /* Markdown formatting */
+#define QRF_STYLE_Column 11 /* One record per line in neat columns */
+#define QRF_STYLE_Table 12 /* MySQL-style table formatting */
+#define QRF_STYLE_Box 13 /* Unicode box-drawing characters */
+#define QRF_STYLE_Count 14 /* Output only a count of the rows of output */
+#define QRF_STYLE_Off 15 /* No query output shown */
/*
** Quoting styles for text.
** Allowed values for sqlite3_qrf_spec.eText
*/
-#define QRF_TXT_Off 0 /* Literal text */
-#define QRF_TXT_Sql 1 /* Quote as an SQL literal */
-#define QRF_TXT_Csv 2 /* CSV-style quoting */
-#define QRF_TXT_Html 3 /* HTML-style quoting */
-#define QRF_TXT_Tcl 4 /* C/Tcl quoting */
-#define QRF_TXT_Json 5 /* JSON quoting */
+#define QRF_TEXT_Off 0 /* Literal text */
+#define QRF_TEXT_Sql 1 /* Quote as an SQL literal */
+#define QRF_TEXT_Csv 2 /* CSV-style quoting */
+#define QRF_TEXT_Html 3 /* HTML-style quoting */
+#define QRF_TEXT_Tcl 4 /* C/Tcl quoting */
+#define QRF_TEXT_Json 5 /* JSON quoting */
/*
** Quoting styles for BLOBs
#define QRF_ESC_Off 0 /* Do not escape control characters */
#define QRF_ESC_Ascii 1 /* Unix-style escapes. Ex: U+0007 shows ^G */
#define QRF_ESC_Symbol 2 /* Unicode escapes. Ex: U+0007 shows U+2407 */
+
+#endif /* !defined(SQLITE_QRF_H) */
-C Documentation\stweaks.\s\sChange\sthe\sname\sof\sthe\seQuote\ssetting\sto\seText\sfor\nconsistency.
-D 2025-10-29T11:19:04.940
+C Striving\sfor\sbetter\snames\sfor\sfields\sin\sthe\sspec\sstructure.
+D 2025-10-29T13:03:35.207
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F ext/misc/windirent.h 02211ce51f3034c675f2dbf4d228194d51b3ee05734678bad5106fff6292e60c
F ext/misc/zipfile.c 09e6e3a3ff40a99677de3c0bc6569bd5f4709b1844ac3d1c1452a456c5a62f1c
F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
-F ext/qrf/README.md eed6b838d175133845c296946704dba1a520edc2ca342a717c4e0b3bbbc279db
-F ext/qrf/qrf-tester.c 7f6300f453c8f18cf67eb932782a091b7f8b17d97bf04bf2fc4ee9d836ac4f54
-F ext/qrf/qrf.c f0fbb2001c812e12fe7d09e025c0bcba07055c9b07959ba0ff8983b85ad9038a
-F ext/qrf/qrf.h 8bfc1d366289d4e603534387f4abf330f30c793092292a610932e074aceda749
+F ext/qrf/README.md 1aa6f58a9442d329eff1d890dd33f565df636a47d8d0e878dbbf5c0ecba3b4c3
+F ext/qrf/qrf-tester.c ad66aeabe6a6c8e84a89e0d919702e8ba9216d6a2a42148116e659ab1967dff6
+F ext/qrf/qrf.c a9ac7d717486647534eaa87549befc440b1cb5da54f656c9b10bf3a3e13f9747
+F ext/qrf/qrf.h f2eb71d2d6b2b2bca68aac38a7b1a72ba55cecb93ea7673d38fdfe8898cbdc24
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
F ext/rbu/rbu10.test 7c22caa32c2ff26983ca8320779a31495a6555737684af7aba3daaf762ef3363
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 3fcf9ecb039a903cefcf4eeaf43974de0cbd48d899dc189b8f70c3745addc11a
-R e9aaf7cf4bd5afd48dd614b11ebf167f
+P 612326750155ff15c9a73fde938aa035490cdd95b364452c1e6b19b521508dfe
+R 3452c6d9695f9963544bfa0adc8f850c
U drh
-Z f49b32220e1ae28c461c3583de771e18
+Z 0c2b15c1da467d14875b4078a5b0ceb1
# Remove this line to create a well-formed Fossil manifest.
-612326750155ff15c9a73fde938aa035490cdd95b364452c1e6b19b521508dfe
+9644e2a8db4d97a85aa7660a1536894ab971abca52fb32f946c01de30eb40de3