/ Check-in [e21afb82]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 Unified Diffs Show Whitespace Changes Patch

Changes to src/shell.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
921
922
923
924
925
926
927









928
929
930
931
932
933
934
...
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.65 2003/01/18 17:05:01 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
  while( z[0]=='-' && z[1]=='-' ){
    z += 2;
    while( *z && *z!='\n' ){ z++; }
    while( isspace(*z) ){ z++; }
  }
  return z;
}










/*
** Read input from *in and process it.  If *in==0 then input
** is interactive - the user is typing it it.  Otherwise, input
** is coming from a file or device.  A prompt is issued and history
** is saved only if input is interactive.  An interrupt signal will
** cause this routine to exit immediately, unless input is interactive.
................................................................................
        exit(1);
      }
      strcpy(&zSql[nSql++], "\n");
      strcpy(&zSql[nSql], zLine);
      nSql += len;
    }
    free(zLine);
    if( zSql && sqlite_complete(zSql) ){
      p->cnt = 0;
      rc = sqlite_exec(db, zSql, callback, p, &zErrMsg);
      if( rc || zErrMsg ){
        if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
        if( zErrMsg!=0 ){
          printf("SQL error: %s\n", zErrMsg);
          free(zErrMsg);







|







 







>
>
>
>
>
>
>
>
>







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
...
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.66 2003/02/05 14:06:20 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
  while( z[0]=='-' && z[1]=='-' ){
    z += 2;
    while( *z && *z!='\n' ){ z++; }
    while( isspace(*z) ){ z++; }
  }
  return z;
}

/*
** Return TRUE if the last non-whitespace character in z[] is a semicolon.
** z[] is N characters long.
*/
static int _ends_with_semicolon(const char *z, int N){
  while( N>0 && isspace(z[N-1]) ){ N--; }
  return N>0 && z[N-1]==';';
}

/*
** Read input from *in and process it.  If *in==0 then input
** is interactive - the user is typing it it.  Otherwise, input
** is coming from a file or device.  A prompt is issued and history
** is saved only if input is interactive.  An interrupt signal will
** cause this routine to exit immediately, unless input is interactive.
................................................................................
        exit(1);
      }
      strcpy(&zSql[nSql++], "\n");
      strcpy(&zSql[nSql], zLine);
      nSql += len;
    }
    free(zLine);
    if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite_complete(zSql) ){
      p->cnt = 0;
      rc = sqlite_exec(db, zSql, callback, p, &zErrMsg);
      if( rc || zErrMsg ){
        if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
        if( zErrMsg!=0 ){
          printf("SQL error: %s\n", zErrMsg);
          free(zErrMsg);