From: drh <> Date: Mon, 10 Nov 2025 15:56:18 +0000 (+0000) Subject: The ".www" command is now handled by QRF. So at this point, QRF handles X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57781916ad3e8e3dfceedc5897a44d1175872e00;p=thirdparty%2Fsqlite.git The ".www" command is now handled by QRF. So at this point, QRF handles all query result formatting in the CLI and the legacy formatter has been removed from the code. FossilOrigin-Name: 35d4c7151e63c3f105a11dddc853666ae19cfca190204847a42f2b2a5641e95d --- diff --git a/manifest b/manifest index 3ddcb3f09e..d120cd91ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rewrite\sthe\s".schema"\sand\s".fullschema"\scommands\sin\sthe\sCLI\sso\sas\sto\neliminate\sthe\sneed\sfor\sMODE_Pretty\sand\sMODE_Semi. -D 2025-11-10T15:01:57.916 +C The\s".www"\scommand\sis\snow\shandled\sby\sQRF.\s\sSo\sat\sthis\spoint,\sQRF\shandles\nall\squery\sresult\sformatting\sin\sthe\sCLI\sand\sthe\slegacy\sformatter\shas\sbeen\nremoved\sfrom\sthe\scode. +D 2025-11-10T15:56:18.937 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a -F src/shell.c.in 67b7893f9f9c992d616a3de8b20a0ae7b9add36f533e752497e259555c354977 +F src/shell.c.in 2de811229c16b13c38c019d9ce449ba40f93734681a4d5c6d194c44fe9c1f75c F src/sqlite.h.in 7403a952a8f1239de7525b73c4e3a0f9540ec0607ed24fec887f5832642d44b8 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 7f236ca1b175ffe03316d974ef57df79b3938466c28d2f95caef5e08c57f3a52 @@ -2173,8 +2173,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2ba92320db3c16c3c91e29ea935ae92da546261f25846d242bd2dd27e0b7e032 -R 9da3decf0638564c4eb7bbfbd4a9d2e1 +P 0eb0410f725eed44973cf8712ab2d24c16fb5cbb249b5780f8fe5d41b2193d79 +R 00bfc0527e98b76f591e01157abf37f0 U drh -Z ddcc91cce64e019052cede211043e861 +Z a342d7d49c0ab55f3ea5c8cac28ceec8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 01ed5b1348..e5fb996386 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0eb0410f725eed44973cf8712ab2d24c16fb5cbb249b5780f8fe5d41b2193d79 +35d4c7151e63c3f105a11dddc853666ae19cfca190204847a42f2b2a5641e95d diff --git a/src/shell.c.in b/src/shell.c.in index 134464aa7b..088b6d25d8 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1396,7 +1396,7 @@ static const unsigned char aQrfStyle[] = { /* box */ QRF_STYLE_Box, /* count */ QRF_STYLE_Count, /* off */ QRF_STYLE_Off, - /* www */ 108, + /* www */ QRF_STYLE_Html, }; /* @@ -1737,41 +1737,6 @@ static void output_c_string(FILE *out, const char *z){ sqlite3_fputs(zq, out); } -/* -** Output the given string with characters that are special to -** HTML escaped. -*/ -static void output_html_string(FILE *out, const char *z){ - int i; - if( z==0 ) z = ""; - while( *z ){ - for(i=0; z[i] - && z[i]!='<' - && z[i]!='&' - && z[i]!='>' - && z[i]!='\"' - && z[i]!='\''; - i++){} - if( i>0 ){ - sqlite3_fprintf(out, "%.*s",i,z); - } - if( z[i]=='<' ){ - sqlite3_fputs("<", out); - }else if( z[i]=='&' ){ - sqlite3_fputs("&", out); - }else if( z[i]=='>' ){ - sqlite3_fputs(">", out); - }else if( z[i]=='\"' ){ - sqlite3_fputs(""", out); - }else if( z[i]=='\'' ){ - sqlite3_fputs("'", out); - }else{ - break; - } - z += i + 1; - } -} - /* ** This routine runs when the user presses Ctrl-C */ @@ -2090,65 +2055,6 @@ static int progress_handler(void *pClientData) { } #endif /* SQLITE_OMIT_PROGRESS_CALLBACK */ -/* -** This is the callback routine that the shell -** invokes for each row of a query result. -*/ -static int shell_callback( - void *pArg, - int nArg, /* Number of result columns */ - char **azArg, /* Text of each result column */ - char **azCol, /* Column names */ - int *aiType /* Column types. Might be NULL */ -){ - int i; - ShellState *p = (ShellState*)pArg; - - if( azArg==0 ) return 0; - switch( p->cMode ){ - case MODE_Count: assert(0); break; - case MODE_Off: assert(0); break; - case MODE_Line: assert(0); break; - case MODE_List: assert(0); break; - case MODE_Html: assert(0); break; - case MODE_Www: { - if( p->cnt==0 && p->cMode==MODE_Www ){ - sqlite3_fputs( - "\n" - "\n" - ,p->out - ); - } - if( p->cnt==0 && (p->showHeader || p->cMode==MODE_Www) ){ - sqlite3_fputs("", p->out); - for(i=0; i", p->out); - output_html_string(p->out, azCol[i]); - sqlite3_fputs("\n", p->out); - } - sqlite3_fputs("\n", p->out); - } - p->cnt++; - if( azArg==0 ) break; - sqlite3_fputs("", p->out); - for(i=0; i", p->out); - output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue); - sqlite3_fputs("\n", p->out); - } - sqlite3_fputs("\n", p->out); - break; - } - case MODE_Tcl: assert(0); break; - case MODE_Csv: assert(0); break; - case MODE_Insert: assert(0); break; - case MODE_Json: assert(0); break; - case MODE_Quote: assert(0); break; - case MODE_Ascii: assert(0); break; - } - return 0; -} - /* ** This is the callback routine from sqlite3_exec() that appends all ** output onto the end of a ShellText object. @@ -2711,86 +2617,6 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ sqlite3_finalize(pQ); } -/* -** Run a prepared statement -*/ -static void exec_prepared_stmt( - ShellState *pArg, /* Pointer to ShellState */ - sqlite3_stmt *pStmt /* Statement to run */ -){ - int rc; - sqlite3_uint64 nRow = 0; - - assert( pArg->cMode!=MODE_Column ); - assert( pArg->cMode!=MODE_Table ); - assert( pArg->cMode!=MODE_Box ); - assert( pArg->cMode!=MODE_Markdown ); - - /* perform the first step. this will tell us if we - ** have a result set or not and how wide it is. - */ - rc = sqlite3_step(pStmt); - /* if we have a result set... */ - if( SQLITE_ROW == rc ){ - /* allocate space for col name ptr, value ptr, and type */ - int nCol = sqlite3_column_count(pStmt); - void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1); - if( !pData ){ - shell_out_of_memory(); - }else{ - char **azCols = (char **)pData; /* Names of result columns */ - char **azVals = &azCols[nCol]; /* Results */ - int *aiTypes = (int *)&azVals[nCol]; /* Result types */ - int i, x; - assert(sizeof(int) <= sizeof(char *)); - /* save off ptrs to column names */ - for(i=0; icMode==MODE_Insert || pArg->cMode==MODE_Quote) - ){ - azVals[i] = ""; - }else{ - azVals[i] = (char*)sqlite3_column_text(pStmt, i); - } - if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){ - rc = SQLITE_NOMEM; - break; /* from for */ - } - } /* end for */ - - /* if data and types extracted successfully... */ - if( SQLITE_ROW == rc ){ - /* call the supplied callback with the result row data */ - if( shell_callback(pArg, nCol, azVals, azCols, aiTypes) ){ - rc = SQLITE_ABORT; - }else{ - rc = sqlite3_step(pStmt); - } - } - } while( SQLITE_ROW == rc ); - sqlite3_free(pData); - if( pArg->cMode==MODE_Json ){ - sqlite3_fputs("]\n", pArg->out); - }else if( pArg->cMode==MODE_Www ){ - sqlite3_fputs("
\n
\n", pArg->out);
-      }else if( pArg->cMode==MODE_Count ){
-        char zBuf[200];
-        sqlite3_snprintf(sizeof(zBuf), zBuf, "%llu row%s\n",
-                         nRow, nRow!=1 ? "s" : "");
-        printf("%s", zBuf);
-      }
-    }
-  }
-}
-
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_AUTHORIZATION)
 /*
 ** This function is called to process SQL if the previous shell command
@@ -2980,7 +2806,7 @@ static int shell_exec(
     default:               spec.eEsc = QRF_ESC_Off;    break;
   }
   spec.bColumnNames = pArg->showHeader!=0 ? QRF_SW_On : QRF_SW_Off;
-  switch( pArg->cMode ){
+  switch( pArg->mode ){
     case MODE_Insert: {
       if( ShellHasFlag(pArg, SHFLG_PreserveRowid) ){
         spec.bColumnNames = QRF_SW_On;
@@ -3000,14 +2826,8 @@ static int shell_exec(
       break;
     }
   }
-  if( pArg->cMode>=0
-   && pArg->cModecMode]<100
-  ){
-    eStyle = aQrfStyle[pArg->cMode];
-  }else{
-    eStyle = 199;
-  }
+  assert( pArg->mode>=0 && pArg->modemode];
 
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_AUTHORIZATION)
   if( pArg->expert.pExpert ){
@@ -3066,11 +2886,18 @@ static int shell_exec(
       if( isExplain && pArg->autoExplain ){
         spec.eStyle = isExplain==1 ? QRF_STYLE_Explain : QRF_STYLE_Eqp;
         sqlite3_format_query_result(pStmt, &spec, pzErrMsg);
-      }else if( eStyle<100 ){
-        spec.eStyle = eStyle;
+      }else if( pArg->mode==MODE_Www ){
+        sqlite3_fprintf(pArg->out,
+              "
\n" + "\n"); + spec.eStyle = QRF_STYLE_Html; sqlite3_format_query_result(pStmt, &spec, pzErrMsg); + sqlite3_fprintf(pArg->out, + "
\n" + "
");
       }else{
-        exec_prepared_stmt(pArg, pStmt);
+        spec.eStyle = eStyle;
+        sqlite3_format_query_result(pStmt, &spec, pzErrMsg);
       }
 
       /* print usage stats if stats on */