SQLite

Check-in [f84d9dab11]
Login

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

Overview
Comment:Make sure pParse->rc gets set whenever sqlite3ErrorMsg() is called. This is added insurance that parsing will stop quickly after an error. This change did make the parser stop faster in some cases, which required some revisions to tests. (CVS 4010)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f84d9dab110c4415d9b772f8043397640162b6b2
User & Date: drh 2007-05-15 16:51:37.000
Context
2007-05-15
18:35
Additional tests for malformed UTF-8. (CVS 4011) (check-in: 448d3ef670 user: drh tags: trunk)
16:51
Make sure pParse->rc gets set whenever sqlite3ErrorMsg() is called. This is added insurance that parsing will stop quickly after an error. This change did make the parser stop faster in some cases, which required some revisions to tests. (CVS 4010) (check-in: f84d9dab11 user: drh tags: trunk)
14:40
Remove the alternative UTF-16 implementation of SUBSTR(). It does not work anymore and the UTF-8 version can do everything that the UTF-16 version does. (CVS 4009) (check-in: 9b91502ef0 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/parse.y.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** the parser.  Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.227 2007/05/15 00:09:13 drh Exp $
*/

// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** the parser.  Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.228 2007/05/15 16:51:37 drh Exp $
*/

// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  if( !pParse->parseError ){
    if( TOKEN.z[0] ){
      sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
    }else{
      sqlite3ErrorMsg(pParse, "incomplete SQL statement");
    }
    pParse->parseError = 1;
    pParse->rc = SQLITE_ERROR;
  }
}
%stack_overflow {
  sqlite3ErrorMsg(pParse, "parser stack overflow");
  pParse->parseError = 1;
}








<







35
36
37
38
39
40
41

42
43
44
45
46
47
48
  if( !pParse->parseError ){
    if( TOKEN.z[0] ){
      sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
    }else{
      sqlite3ErrorMsg(pParse, "incomplete SQL statement");
    }
    pParse->parseError = 1;

  }
}
%stack_overflow {
  sqlite3ErrorMsg(pParse, "parser stack overflow");
  pParse->parseError = 1;
}

Changes to src/sqliteInt.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.567 2007/05/15 11:55:09 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
#include "limits.h"


#if defined(SQLITE_TCL) || defined(TCLSH)













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.568 2007/05/15 16:51:37 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
#include "limits.h"


#if defined(SQLITE_TCL) || defined(TCLSH)
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
  int rc;              /* Return code from execution */
  char *zErrMsg;       /* An error message */
  Vdbe *pVdbe;         /* An engine for executing database bytecode */
  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */
  u8 nameClash;        /* A permanent table name clashes with temp table name */
  u8 checkSchema;      /* Causes schema cookie check after an error */
  u8 nested;           /* Number of nested calls to the parser/code generator */
  u8 parseError;       /* True if a parsing error has been seen */
  int nErr;            /* Number of errors seen */
  int nTab;            /* Number of previously allocated VDBE cursors */
  int nMem;            /* Number of memory cells used so far */
  int nSet;            /* Number of sets used so far */
  int ckOffset;        /* Stack offset to data used by CHECK constraints */
  u32 writeMask;       /* Start a write transaction on these databases */
  u32 cookieMask;      /* Bitmask of schema verified databases */







|







1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
  int rc;              /* Return code from execution */
  char *zErrMsg;       /* An error message */
  Vdbe *pVdbe;         /* An engine for executing database bytecode */
  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */
  u8 nameClash;        /* A permanent table name clashes with temp table name */
  u8 checkSchema;      /* Causes schema cookie check after an error */
  u8 nested;           /* Number of nested calls to the parser/code generator */
  u8 parseError;       /* True after a parsing error.  Ticket #1794 */
  int nErr;            /* Number of errors seen */
  int nTab;            /* Number of previously allocated VDBE cursors */
  int nMem;            /* Number of memory cells used so far */
  int nSet;            /* Number of sets used so far */
  int ckOffset;        /* Stack offset to data used by CHECK constraints */
  u32 writeMask;       /* Start a write transaction on these databases */
  u32 cookieMask;      /* Bitmask of schema verified databases */
Changes to src/util.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.202 2007/05/08 20:37:40 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <stdarg.h>
#include <ctype.h>









|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.203 2007/05/15 16:51:37 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <stdarg.h>
#include <ctype.h>


79
80
81
82
83
84
85



86
87
88
89
90
91
92
void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
  va_list ap;
  pParse->nErr++;
  sqliteFree(pParse->zErrMsg);
  va_start(ap, zFormat);
  pParse->zErrMsg = sqlite3VMPrintf(zFormat, ap);
  va_end(ap);



}

/*
** Clear the error message in pParse, if any
*/
void sqlite3ErrorClear(Parse *pParse){
  sqliteFree(pParse->zErrMsg);







>
>
>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
  va_list ap;
  pParse->nErr++;
  sqliteFree(pParse->zErrMsg);
  va_start(ap, zFormat);
  pParse->zErrMsg = sqlite3VMPrintf(zFormat, ap);
  va_end(ap);
  if( pParse->rc==SQLITE_OK ){
    pParse->rc = SQLITE_ERROR;
  }
}

/*
** Clear the error message in pParse, if any
*/
void sqlite3ErrorClear(Parse *pParse){
  sqliteFree(pParse->zErrMsg);
Changes to test/alter.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2004 November 10
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 script is testing the ALTER TABLE statement.
#
# $Id: alter.test,v 1.24 2007/05/15 14:34:32 drh Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2004 November 10
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 script is testing the ALTER TABLE statement.
#
# $Id: alter.test,v 1.25 2007/05/15 16:51:37 drh Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
698
699
700
701
702
703
704


705
706
707
708

709
710
711
712
713
714
715
716
717

718
719
720
721
722
723
724
725
726
727

728
729
730
731
732
733
734
735
736

737
738
739
740
741
742
743
744
745
746

747
748
749
  execsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}


do_test alter-11.2 {
  execsql {INSERT INTO t11 VALUES(1,2)}
  sqlite3_exec db {SELECT %c6%c6 AS xyz, abc FROM t11}
} {0 {xyz abc 1 2}}

do_test alter-11.3 {
  sqlite3_exec db {CREATE TABLE t11b("%81%82%83" text)}
  execsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}

do_test alter-11.4 {
  execsql {INSERT INTO t11b VALUES(3,4)}
  sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11b}
} {0 {xyz abc 3 4}}
do_test alter-11.5 {
  sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11b}
} {0 {xyz abc 3 4}}
do_test alter-11.6 {
  sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11b}
} {0 {xyz abc 3 4}}

do_test alter-11.7 {
  sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}
  execsql {
    ALTER TABLE t11c ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11c ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}

do_test alter-11.8 {
  execsql {INSERT INTO t11c VALUES(5,6)}
  sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11c}
} {0 {xyz abc 5 6}}
do_test alter-11.9 {
  sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c}
} {0 {xyz abc 5 6}}
do_test alter-11.10 {
  sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c}
} {0 {xyz abc 5 6}}



finish_test







>
>
|
|
|
|
>









>
|
|
|
|
|
|
|
|
|
|
>









>
|
|
|
|
|
|
|
|
|
|
>



698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
  execsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}
set isutf16 [regexp 16 [db one {PRAGMA encoding}]]
if {!$isutf16} {
  do_test alter-11.2 {
    execsql {INSERT INTO t11 VALUES(1,2)}
    sqlite3_exec db {SELECT %c6%c6 AS xyz, abc FROM t11}
  } {0 {xyz abc 1 2}}
}
do_test alter-11.3 {
  sqlite3_exec db {CREATE TABLE t11b("%81%82%83" text)}
  execsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}
if {!$isutf16} {
  do_test alter-11.4 {
    execsql {INSERT INTO t11b VALUES(3,4)}
    sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11b}
  } {0 {xyz abc 3 4}}
  do_test alter-11.5 {
    sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11b}
  } {0 {xyz abc 3 4}}
  do_test alter-11.6 {
    sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11b}
  } {0 {xyz abc 3 4}}
}
do_test alter-11.7 {
  sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}
  execsql {
    ALTER TABLE t11c ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11c ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}
if {!$isutf16} {
  do_test alter-11.8 {
    execsql {INSERT INTO t11c VALUES(5,6)}
    sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11c}
  } {0 {xyz abc 5 6}}
  do_test alter-11.9 {
    sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c}
  } {0 {xyz abc 5 6}}
  do_test alter-11.10 {
    sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c}
  } {0 {xyz abc 5 6}}
}


finish_test
Changes to test/fuzz2.test.
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# This file checks error recovery from malformed SQL strings.
#
# $Id: fuzz2.test,v 1.2 2007/05/15 03:56:50 drh Exp $

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






do_test fuzz2-1.1 {
  catchsql {SELECT ALL "AAAAAA" . * GROUP BY LIMIT round(1), #12}
} {1 {near "#12": syntax error}}
do_test fuzz2-2.0 {
  catchsql {SELECT + #100}
} {1 {near "#100": syntax error}}
do_test fuzz2-2.1 {
  catchsql {SELECT 1 WHERE ( #61 NOT MATCH ROUND( 1 ) )}
} {1 {near "#61": syntax error}}
do_test fuzz2-2.2 {
  catchsql {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN 
    ( "AAAAAA" NOTNULL <= x'414141414141' IS NULL , ( ROUND ( 1.0 ) ) )}
} {1 {no such collation sequence: AAAAAA}}
do_test fuzz2-2.3 {
  catchsql {INSERT OR REPLACE INTO AAAAAA . "AAAAAA" ( "AAAAAA" ) SELECT DISTINCT * , ( SELECT #252 IN ( SELECT DISTINCT AAAAAA . * ) )}
} {1 {near "#252": syntax error}}
do_test fuzz2-2.4 {
  catchsql {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN round(1.0)}
} {1 {near "(": syntax error}}
do_test fuzz2-2.5 {
  catchsql {SELECT( #239 )}
} {1 {near "#239": syntax error}}
do_test fuzz2-2.6 {
  catchsql {DELETE FROM AAAAAA WHERE #65 NOT NULL}
} {1 {near "#65": syntax error}}
do_test fuzz2-2.7 {
  catchsql {ATTACH ROUND( 1.0 ) in  AAAAAA . "AAAAAA" AS #122 ISNULL}
} {1 {invalid name: "ROUND( 1.0 ) in  AAAAAA . "AAAAAA""}}
do_test fuzz2-2.8 {
  catchsql {SELECT 1 LIMIT  #122 ISNULL}
} {1 {near "#122": syntax error}}
do_test fuzz2-2.9 {
  catchsql {CREATE VIEW AAAAAA . "AAAAAA" AS SELECT DISTINCT #162 IS NULL "AAAAAA"}
} {1 {unknown database AAAAAA}}
do_test fuzz2-2.10 {
  catchsql {DELETE FROM AAAAAA WHERE #202 IS NOT NULL ISNULL}
} {1 {near "#202": syntax error}}
do_test fuzz2-2.11 {
  catchsql {UPDATE OR IGNORE "AAAAAA" . "AAAAAA" SET "AAAAAA" = NOT #96}
} {1 {near "#96": syntax error}}
do_test fuzz2-2.12 {
  catchsql {SELECT - #196}
} {1 {near "#196": syntax error}}
do_test fuzz2-3.0 {
  catchsql {CREATE TRIGGER "AAAAAA" . "AAAAAA" AFTER UPDATE OF "AAAAAA" , "AAAAAA" ON "AAAAAA" . "AAAAAA" FOR EACH ROW BEGIN UPDATE AAAAAA SET "AAAAAA" = #162;  END}
} {1 {near "#162": syntax error}}
do_test fuzz2-3.1 {
  catchsql {CREATE TRIGGER IF NOT EXISTS "AAAAAA" UPDATE ON "AAAAAA" . AAAAAA FOR EACH ROW BEGIN DELETE FROM "AAAAAA" ; INSERT INTO AAAAAA ( "AAAAAA" ) SELECT DISTINCT "AAAAAA" "AAAAAA" , #167 AAAAAA , "AAAAAA" . * ORDER BY "AAAAAA" ASC , x'414141414141' BETWEEN RAISE ( FAIL , "AAAAAA" ) AND AAAAAA ( * ) NOT NULL DESC LIMIT AAAAAA ; REPLACE INTO AAAAAA ( AAAAAA ) VALUES ( AAAAAA ( * ) ) ; END}
} {1 {near "#167": syntax error}}
do_test fuzz2-3.2 {
  catchsql {CREATE TEMP TRIGGER IF NOT EXISTS AAAAAA . "AAAAAA" BEFORE UPDATE OF "AAAAAA" ON AAAAAA . "AAAAAA" BEGIN SELECT ALL * , #175 "AAAAAA" FROM "AAAAAA" . AAAAAA;  END}
} {1 {near "#175": syntax error}}
do_test fuzz2-4.0 {
  catchsql {ATTACH DATABASE #168 AS whatever}
} {1 {near "#168": syntax error}}
do_test fuzz2-4.1 {
  catchsql {DETACH #133}
} {1 {near "#133": syntax error}}
do_test fuzz2-5.0 {
  catchsql {SELECT 1 LIMIT ( SELECT DISTINCT * , AAAAAA , * , AAAAAA , "AAAAAA" . * FROM "AAAAAA" ON ROUND( 1 ) COLLATE AAAAAA OR "AAAAAA" USING ( AAAAAA , "AAAAAA" ) WHERE ROUND( 1 ) GROUP BY ORDER BY #84 ASC , #44 DESC , ( SELECT "AAAAAA" . * , "AAAAAA" . * FROM , ( ) "AAAAAA" USING ( )}
} {1 {near ",": syntax error}}
do_test fuzz2-5.1 {
  catchsql {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
} {1 {near ",": syntax error}}
do_test fuzz2-5.2 {
  catchsql {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
} {1 {near ",": syntax error}}
do_test fuzz2-5.3 {
  catchsql {UPDATE "AAAAAA" SET "AAAAAA" = - EXISTS ( SELECT DISTINCT * , * ORDER BY #202 ASC , #147 , ~ AAAAAA . "AAAAAA" ASC LIMIT AAAAAA . "AAAAAA" , RAISE ( ABORT , AAAAAA ) UNION ALL SELECT DISTINCT AAAAAA . * , * FROM ( SELECT DISTINCT}
} {1 {near "DISTINCT": syntax error}}
do_test fuzz2-5.4 {
  catchsql {REPLACE INTO AAAAAA SELECT DISTINCT "AAAAAA" . * WHERE AAAAAA ( AAAAAA ( ) ) GROUP BY AAAAAA . AAAAAA . "AAAAAA" IN "AAAAAA" | AAAAAA ( ALL , ) ORDER BY #238, #92 DESC LIMIT 0 OFFSET - RAISE ( IGNORE ) NOT NULL > RAISE ( IGNORE ) IS NULL}
} {1 {near "#92": syntax error}}
do_test fuzz2-5.5 {
  catchsql {SELECT ALL * GROUP BY EXISTS ( SELECT "AAAAAA" . * , AAAAAA ( * ) AS AAAAAA FROM "AAAAAA" . "AAAAAA" AS "AAAAAA" USING ( AAAAAA , "AAAAAA" , "AAAAAA" ) WHERE AAAAAA ( DISTINCT ) - RAISE ( FAIL , "AAAAAA" ) HAVING "AAAAAA" . "AAAAAA" . AAAAAA ORDER BY #182 , #55 ) BETWEEN EXISTS ( SELECT ALL * FROM ( ( }
} {1 {near " ": syntax error}}

finish_test







|




>
>
>
>
>

|
|

|
|

|
|

|

|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|


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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# This file checks error recovery from malformed SQL strings.
#
# $Id: fuzz2.test,v 1.3 2007/05/15 16:51:37 drh Exp $

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


proc fuzzcatch {sql} {
  return [lindex [catchsql $sql] 0]
}

do_test fuzz2-1.1 {
  fuzzcatch {SELECT ALL "AAAAAA" . * GROUP BY LIMIT round(1), #12}
} {1}
do_test fuzz2-2.0 {
  fuzzcatch {SELECT + #100}
} {1}
do_test fuzz2-2.1 {
  fuzzcatch {SELECT 1 WHERE ( #61 NOT MATCH ROUND( 1 ) )}
} {1}
do_test fuzz2-2.2 {
  fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN 
    ( "AAAAAA" NOTNULL <= x'414141414141' IS NULL , ( ROUND ( 1.0 ) ) )}
} {1}
do_test fuzz2-2.3 {
  fuzzcatch {INSERT OR REPLACE INTO AAAAAA . "AAAAAA" ( "AAAAAA" ) SELECT DISTINCT * , ( SELECT #252 IN ( SELECT DISTINCT AAAAAA . * ) )}
} {1}
do_test fuzz2-2.4 {
  fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN round(1.0)}
} {1}
do_test fuzz2-2.5 {
  fuzzcatch {SELECT( #239 )}
} {1}
do_test fuzz2-2.6 {
  fuzzcatch {DELETE FROM AAAAAA WHERE #65 NOT NULL}
} {1}
do_test fuzz2-2.7 {
  fuzzcatch {ATTACH ROUND( 1.0 ) in  AAAAAA . "AAAAAA" AS #122 ISNULL}
} {1}
do_test fuzz2-2.8 {
  fuzzcatch {SELECT 1 LIMIT  #122 ISNULL}
} {1}
do_test fuzz2-2.9 {
  fuzzcatch {CREATE VIEW AAAAAA . "AAAAAA" AS SELECT DISTINCT #162 IS NULL "AAAAAA"}
} {1}
do_test fuzz2-2.10 {
  fuzzcatch {DELETE FROM AAAAAA WHERE #202 IS NOT NULL ISNULL}
} {1}
do_test fuzz2-2.11 {
  fuzzcatch {UPDATE OR IGNORE "AAAAAA" . "AAAAAA" SET "AAAAAA" = NOT #96}
} {1}
do_test fuzz2-2.12 {
  fuzzcatch {SELECT - #196}
} {1}
do_test fuzz2-3.0 {
  fuzzcatch {CREATE TRIGGER "AAAAAA" . "AAAAAA" AFTER UPDATE OF "AAAAAA" , "AAAAAA" ON "AAAAAA" . "AAAAAA" FOR EACH ROW BEGIN UPDATE AAAAAA SET "AAAAAA" = #162;  END}
} {1}
do_test fuzz2-3.1 {
  fuzzcatch {CREATE TRIGGER IF NOT EXISTS "AAAAAA" UPDATE ON "AAAAAA" . AAAAAA FOR EACH ROW BEGIN DELETE FROM "AAAAAA" ; INSERT INTO AAAAAA ( "AAAAAA" ) SELECT DISTINCT "AAAAAA" "AAAAAA" , #167 AAAAAA , "AAAAAA" . * ORDER BY "AAAAAA" ASC , x'414141414141' BETWEEN RAISE ( FAIL , "AAAAAA" ) AND AAAAAA ( * ) NOT NULL DESC LIMIT AAAAAA ; REPLACE INTO AAAAAA ( AAAAAA ) VALUES ( AAAAAA ( * ) ) ; END}
} {1}
do_test fuzz2-3.2 {
  fuzzcatch {CREATE TEMP TRIGGER IF NOT EXISTS AAAAAA . "AAAAAA" BEFORE UPDATE OF "AAAAAA" ON AAAAAA . "AAAAAA" BEGIN SELECT ALL * , #175 "AAAAAA" FROM "AAAAAA" . AAAAAA;  END}
} {1}
do_test fuzz2-4.0 {
  fuzzcatch {ATTACH DATABASE #168 AS whatever}
} {1}
do_test fuzz2-4.1 {
  fuzzcatch {DETACH #133}
} {1}
do_test fuzz2-5.0 {
  fuzzcatch {SELECT 1 LIMIT ( SELECT DISTINCT * , AAAAAA , * , AAAAAA , "AAAAAA" . * FROM "AAAAAA" ON ROUND( 1 ) COLLATE AAAAAA OR "AAAAAA" USING ( AAAAAA , "AAAAAA" ) WHERE ROUND( 1 ) GROUP BY ORDER BY #84 ASC , #44 DESC , ( SELECT "AAAAAA" . * , "AAAAAA" . * FROM , ( ) "AAAAAA" USING ( )}
} {1}
do_test fuzz2-5.1 {
  fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
} {1}
do_test fuzz2-5.2 {
  fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
} {1}
do_test fuzz2-5.3 {
  fuzzcatch {UPDATE "AAAAAA" SET "AAAAAA" = - EXISTS ( SELECT DISTINCT * , * ORDER BY #202 ASC , #147 , ~ AAAAAA . "AAAAAA" ASC LIMIT AAAAAA . "AAAAAA" , RAISE ( ABORT , AAAAAA ) UNION ALL SELECT DISTINCT AAAAAA . * , * FROM ( SELECT DISTINCT}
} {1}
do_test fuzz2-5.4 {
  fuzzcatch {REPLACE INTO AAAAAA SELECT DISTINCT "AAAAAA" . * WHERE AAAAAA ( AAAAAA ( ) ) GROUP BY AAAAAA . AAAAAA . "AAAAAA" IN "AAAAAA" | AAAAAA ( ALL , ) ORDER BY #238, #92 DESC LIMIT 0 OFFSET - RAISE ( IGNORE ) NOT NULL > RAISE ( IGNORE ) IS NULL}
} {1}
do_test fuzz2-5.5 {
  fuzzcatch {SELECT ALL * GROUP BY EXISTS ( SELECT "AAAAAA" . * , AAAAAA ( * ) AS AAAAAA FROM "AAAAAA" . "AAAAAA" AS "AAAAAA" USING ( AAAAAA , "AAAAAA" , "AAAAAA" ) WHERE AAAAAA ( DISTINCT ) - RAISE ( FAIL , "AAAAAA" ) HAVING "AAAAAA" . "AAAAAA" . AAAAAA ORDER BY #182 , #55 ) BETWEEN EXISTS ( SELECT ALL * FROM ( ( }
} {1}

finish_test
Changes to test/interrupt.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2004 Feb 8
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 script is the sqlite_interrupt() API.
#
# $Id: interrupt.test,v 1.13 2006/07/17 00:02:46 drh Exp $


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

# Compute a checksum on the entire database.













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2004 Feb 8
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 script is the sqlite_interrupt() API.
#
# $Id: interrupt.test,v 1.14 2007/05/15 16:51:37 drh Exp $


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

# Compute a checksum on the entire database.
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
    catchsql $sql
  } {1 interrupted}
}

# Interrupt during parsing
#
do_test interrupt-5.1 {
  proc fake_interrupt {args} {sqlite3_interrupt $::DB; return SQLITE_OK}
  db collation_needed fake_interrupt
  catchsql {
    CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC);
  }
} {1 interrupt}
do_test interrupt-5.2 {
  proc fake_interrupt {args} {db interrupt; return SQLITE_OK}
  db collation_needed fake_interrupt
  catchsql {
    CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC);
  }
} {1 interrupt}

finish_test







|
|
|
|

<
<
<







176
177
178
179
180
181
182
183
184
185
186
187



188
189
190
191
192
193
194
    catchsql $sql
  } {1 interrupted}
}

# Interrupt during parsing
#
do_test interrupt-5.1 {
  proc fake_interrupt {args} {
    db collate fake_collation no-op
    sqlite3_interrupt db
    return SQLITE_OK
  }



  db collation_needed fake_interrupt
  catchsql {
    CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC);
  }
} {1 interrupt}

finish_test