From: drh <> Date: Wed, 29 Oct 2025 13:03:35 +0000 (+0000) Subject: Striving for better names for fields in the spec structure. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03e624280263785484ced0a87f8776d59b9e9a3f;p=thirdparty%2Fsqlite.git Striving for better names for fields in the spec structure. FossilOrigin-Name: 9644e2a8db4d97a85aa7660a1536894ab971abca52fb32f946c01de30eb40de3 --- diff --git a/ext/qrf/README.md b/ext/qrf/README.md index fd30bc49ee..123e549934 100644 --- a/ext/qrf/README.md +++ b/ext/qrf/README.md @@ -38,13 +38,13 @@ formatted, and what to do with the formatted text. 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 */ @@ -52,7 +52,6 @@ struct sqlite3_qrf_spec { 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 */ @@ -88,21 +87,21 @@ non-NULL and the other must be NULL. ### 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: @@ -112,15 +111,15 @@ 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 @@ -135,50 +134,50 @@ display values, regardless of this setting. 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; @@ -192,10 +191,10 @@ 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 @@ -218,8 +217,8 @@ previous paragraph would be shown as ### 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 @@ -236,8 +235,8 @@ of words. 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 @@ -281,7 +280,7 @@ that cannot be overridden. ### 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 @@ -307,7 +306,7 @@ The sqlite3_format_query_result() function (which calls xRender) 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. @@ -326,28 +325,28 @@ free that memory by a subsequent call to sqlite3_free(). ## 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 diff --git a/ext/qrf/qrf-tester.c b/ext/qrf/qrf-tester.c index 8e7d178f8f..66aba5c6cd 100644 --- a/ext/qrf/qrf-tester.c +++ b/ext/qrf/qrf-tester.c @@ -107,7 +107,7 @@ int main(int argc, char **argv){ } 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); @@ -183,54 +183,54 @@ int main(int argc, char **argv){ } 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) ){ + if( i>=COUNT(aStyle) ){ sqlite3_str *pMsg = sqlite3_str_new(0); - for(i=0; ispec.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]] ){ @@ -507,7 +507,7 @@ static void qrfEncodeText(Qrf *p, sqlite3_str *pOut, const char *zTxt){ } break; } - case QRF_TXT_Html: { + case QRF_TEXT_Html: { const unsigned char *z = (const unsigned char*)zTxt; while( *z ){ unsigned int i = 0; @@ -532,8 +532,8 @@ static void qrfEncodeText(Qrf *p, sqlite3_str *pOut, const char *zTxt){ } 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 ){ @@ -552,7 +552,7 @@ static void qrfEncodeText(Qrf *p, sqlite3_str *pOut, const char *zTxt){ 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]); @@ -570,8 +570,8 @@ static void qrfEncodeText(Qrf *p, sqlite3_str *pOut, const char *zTxt){ 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); } } @@ -644,7 +644,7 @@ static void qrfRenderValue(Qrf *p, sqlite3_str *pOut, int iCol){ break; } case SQLITE_BLOB: { - if( p->spec.bTxtJsonb ){ + if( p->spec.bTextJsonb ){ const char *zJson = qrfJsonbToJson(p, iCol); if( zJson ){ qrfEncodeText(p, pOut, zJson); @@ -988,7 +988,7 @@ static void qrfBoxLine(sqlite3_str *pOut, int N){ } /* -** 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, @@ -1149,11 +1149,11 @@ static void qrfColumnar(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; iactualWidth[i]; if( ispec.nWidth && p->spec.aWidth[i]<0 ) w = -w; @@ -1167,7 +1167,7 @@ static void qrfColumnar(Qrf *p){ } break; } - case QRF_MODE_Table: { + case QRF_STYLE_Table: { colSep = " | "; rowSep = " |\n"; qrfRowSeparator(p, "+"); @@ -1183,7 +1183,7 @@ static void qrfColumnar(Qrf *p){ qrfRowSeparator(p, "+"); break; } - case QRF_MODE_Markdown: { + case QRF_STYLE_Markdown: { colSep = " | "; rowSep = " |\n"; sqlite3_str_append(p->pOut, "| ", 2); @@ -1198,7 +1198,7 @@ static void qrfColumnar(Qrf *p){ 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); @@ -1219,9 +1219,9 @@ static void qrfColumnar(Qrf *p){ /* Render the body of the table */ nTotal = nColumn*(nRow+1); for(i=nColumn, j=0; ispec.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 = ""; @@ -1231,14 +1231,14 @@ static void qrfColumnar(Qrf *p){ if( j==nColumn-1 ){ sqlite3_str_appendall(p->pOut, rowSep); if( bMultiLineRowExists && abRowDiv[i/nColumn-1] && i+1spec.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; } @@ -1250,9 +1250,9 @@ static void qrfColumnar(Qrf *p){ 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); @@ -1389,7 +1389,7 @@ static void qrfExplain(Qrf *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); @@ -1479,53 +1479,53 @@ static void qrfInitialize( 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 @@ -1533,16 +1533,16 @@ static void qrfInitialize( ** 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 @@ -1550,9 +1550,9 @@ static void qrfInitialize( ** 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"; @@ -1562,15 +1562,15 @@ static void qrfInitialize( } 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; @@ -1583,13 +1583,13 @@ static void qrfInitialize( */ 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{ @@ -1605,8 +1605,8 @@ static void qrfOneSimpleRow(Qrf *p){ 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, "", 4); for(i=0; inCol; i++){ const char *zCName = sqlite3_column_name(p->pStmt, i); @@ -1624,7 +1624,7 @@ static void qrfOneSimpleRow(Qrf *p){ 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; inCol; i++){ if( i>0 ) sqlite3_str_append(p->pOut, ",", 1); @@ -1634,7 +1634,7 @@ static void qrfOneSimpleRow(Qrf *p){ 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 ){ @@ -1664,7 +1664,7 @@ static void qrfOneSimpleRow(Qrf *p){ 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); @@ -1673,8 +1673,8 @@ static void qrfOneSimpleRow(Qrf *p){ 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; inCol; i++){ const char *zCName = sqlite3_column_name(p->pStmt, i); if( i>0 ) sqlite3_str_appendall(p->pOut, p->spec.zColumnSep); @@ -1699,22 +1699,22 @@ static void qrfOneSimpleRow(Qrf *p){ ** 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; @@ -1749,17 +1749,17 @@ int sqlite3_format_query_result( 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; } diff --git a/ext/qrf/qrf.h b/ext/qrf/qrf.h index fe799b2ab8..4d8164d99f 100644 --- a/ext/qrf/qrf.h +++ b/ext/qrf/qrf.h @@ -12,6 +12,8 @@ ** 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 #include "sqlite3.h" @@ -21,13 +23,13 @@ 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 */ @@ -62,33 +64,33 @@ int sqlite3_format_query_result( /* ** 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 @@ -108,3 +110,5 @@ int sqlite3_format_query_result( #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) */ diff --git a/manifest b/manifest index ff741582a3..b8b405b7a2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 @@ -416,10 +416,10 @@ F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f6 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 @@ -2175,8 +2175,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd 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. diff --git a/manifest.uuid b/manifest.uuid index bbc3514edc..011ec18956 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -612326750155ff15c9a73fde938aa035490cdd95b364452c1e6b19b521508dfe +9644e2a8db4d97a85aa7660a1536894ab971abca52fb32f946c01de30eb40de3