/ Check-in [ef8eb580]
Login

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

Overview
Comment:Fix the sqlite_complete() routine so that it recognizes /*...*/ comments. Ticket #277. (CVS 937)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ef8eb580fc6c40264219c2ae77a9c4f8a5803c8b
User & Date: drh 2003-04-26 02:31:54
Context
2003-04-26
02:40
Do not use the return value of fcntl() to find the reason that it failed. Use errno instead. Tickets #240 and #270. (CVS 938) check-in: acf9e980 user: drh tags: trunk
02:31
Fix the sqlite_complete() routine so that it recognizes /*...*/ comments. Ticket #277. (CVS 937) check-in: ef8eb580 user: drh tags: trunk
2003-04-25
17:52
Report the correct authorization context in the authorization callback when coding an INSTEAD OF trigger on an update or delete. (CVS 936) check-in: 67746833 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
594
595
596
597
598
599
600













601
602
603
604
605
606
607
...
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.127 2003/04/23 12:25:24 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information
................................................................................
        isComplete = 0;
        seenText = 1;
        seenCreate = 0;
        zSql++;
        while( *zSql && *zSql!=c ){ zSql++; }
        if( *zSql==0 ) return 0;
        break;













      }
      case '-': {
        if( zSql[1]!='-' ){
          isComplete = 0;
          seenCreate = 0;
          break;
        }
................................................................................
        seenText = 1;
        isComplete = 0;
        break;
      }
    }
    zSql++;
  }
  return seenText && isComplete && requireEnd==0;
}

/*
** Rollback all database files.
*/
void sqliteRollbackAll(sqlite *db){
  int i;







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
...
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.128 2003/04/26 02:31:54 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information
................................................................................
        isComplete = 0;
        seenText = 1;
        seenCreate = 0;
        zSql++;
        while( *zSql && *zSql!=c ){ zSql++; }
        if( *zSql==0 ) return 0;
        break;
      }
      case '/': {
        if( zSql[1]!='*' ){
          isComplete = 0;
          seenText = 1;
          seenCreate = 0;
          break;
        }
        zSql += 2;
        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
        if( zSql[0]==0 ) return 0;
        zSql += 2;
        break;
      }
      case '-': {
        if( zSql[1]!='-' ){
          isComplete = 0;
          seenCreate = 0;
          break;
        }
................................................................................
        seenText = 1;
        isComplete = 0;
        break;
      }
    }
    zSql++;
  }
  return /* seenText && */ isComplete && requireEnd==0;
}

/*
** Rollback all database files.
*/
void sqliteRollbackAll(sqlite *db){
  int i;

Changes to test/main.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
154
155
156
157
158
159
160







































161
162
163
164
165
166
167
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is exercising the code in main.c.
#
# $Id: main.test,v 1.12 2003/04/16 02:17:36 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Tests of the sqlite_complete() function.
#
do_test main-1.1 {
  db complete {This is a test}
} {0}
do_test main-1.2 {
  db complete {
  }
} {0}
do_test main-1.3 {
  db complete {
     -- a comment ;
  }
} {0}
do_test main-1.4 {
  db complete {
     -- a comment ;
     ;
  }
} {1}
do_test main-1.5 {
................................................................................
do_test main-1.29 {
  db complete {
    CREATE TRIGGER xyz AFTER DELETE backend BEGIN
       UPDATE pqr SET a=5;
       EXPLAIN select * from xyz;
  }
} {0}









































# Try to open a database with a corrupt database file.
#
do_test main-2.0 {
  catch {db close}
  file delete -force test.db







|












|




|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is exercising the code in main.c.
#
# $Id: main.test,v 1.13 2003/04/26 02:31:54 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Tests of the sqlite_complete() function.
#
do_test main-1.1 {
  db complete {This is a test}
} {0}
do_test main-1.2 {
  db complete {
  }
} {1}
do_test main-1.3 {
  db complete {
     -- a comment ;
  }
} {1}
do_test main-1.4 {
  db complete {
     -- a comment ;
     ;
  }
} {1}
do_test main-1.5 {
................................................................................
do_test main-1.29 {
  db complete {
    CREATE TRIGGER xyz AFTER DELETE backend BEGIN
       UPDATE pqr SET a=5;
       EXPLAIN select * from xyz;
  }
} {0}
do_test main-1.30 {
  db complete {
     CREATE TABLE /* In comment ; */
  }
} {0}
do_test main-1.31 {
  db complete {
     CREATE TABLE /* In comment ; */ hi;
  }
} {1}
do_test main-1.32 {
  db complete {
     stuff;
     /*
       CREATE TABLE
       multiple lines
       of text
     */
  }
} {1}
do_test main-1.33 {
  db complete {
     /*
       CREATE TABLE
       multiple lines
       of text;
  }
} {0}
do_test main-1.34 {
  db complete {
     /*
       CREATE TABLE
       multiple lines "*/
       of text;
  }
} {1}
do_test main-1.35 {
  db complete {hi /**/ there;}
} {1}


# Try to open a database with a corrupt database file.
#
do_test main-2.0 {
  catch {db close}
  file delete -force test.db