/ Check-in [e21afb82]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make the shell run much faster for inputs where a single SQL statement spans thousands of lines by avoiding the call to sqlite_complete() unless the input ends in a semicolon. (CVS 860)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e21afb82b53eade9ee267a97c58db0606f0c0a41
User & Date: drh 2003-02-05 14:06:20
Context
2003-02-11
14:55
Modify the journal format to be more robust against garbage that might appear in the file after a power failure. The changes are mostly working but more testing is still required. This check-in is to checkpoint the changes so far. (CVS 861) check-in: 8ec56325 user: drh tags: trunk
2003-02-05
14:06
Make the shell run much faster for inputs where a single SQL statement spans thousands of lines by avoiding the call to sqlite_complete() unless the input ends in a semicolon. (CVS 860) check-in: e21afb82 user: drh tags: trunk
2003-02-02
12:41
Make the GROUP BY clause work even if there are no aggregate functions. (CVS 859) check-in: b6879231 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.65 2003/01/18 17:05:01 drh Exp $
           15  +** $Id: shell.c,v 1.66 2003/02/05 14:06:20 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include "sqlite.h"
    21     21   #include <ctype.h>
    22     22   
................................................................................
   921    921     while( z[0]=='-' && z[1]=='-' ){
   922    922       z += 2;
   923    923       while( *z && *z!='\n' ){ z++; }
   924    924       while( isspace(*z) ){ z++; }
   925    925     }
   926    926     return z;
   927    927   }
          928  +
          929  +/*
          930  +** Return TRUE if the last non-whitespace character in z[] is a semicolon.
          931  +** z[] is N characters long.
          932  +*/
          933  +static int _ends_with_semicolon(const char *z, int N){
          934  +  while( N>0 && isspace(z[N-1]) ){ N--; }
          935  +  return N>0 && z[N-1]==';';
          936  +}
   928    937   
   929    938   /*
   930    939   ** Read input from *in and process it.  If *in==0 then input
   931    940   ** is interactive - the user is typing it it.  Otherwise, input
   932    941   ** is coming from a file or device.  A prompt is issued and history
   933    942   ** is saved only if input is interactive.  An interrupt signal will
   934    943   ** cause this routine to exit immediately, unless input is interactive.
................................................................................
   967    976           exit(1);
   968    977         }
   969    978         strcpy(&zSql[nSql++], "\n");
   970    979         strcpy(&zSql[nSql], zLine);
   971    980         nSql += len;
   972    981       }
   973    982       free(zLine);
   974         -    if( zSql && sqlite_complete(zSql) ){
          983  +    if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite_complete(zSql) ){
   975    984         p->cnt = 0;
   976    985         rc = sqlite_exec(db, zSql, callback, p, &zErrMsg);
   977    986         if( rc || zErrMsg ){
   978    987           if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
   979    988           if( zErrMsg!=0 ){
   980    989             printf("SQL error: %s\n", zErrMsg);
   981    990             free(zErrMsg);