SQLite

Check-in [de6e6d6846]
Login

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

Overview
Comment:Make sure the WITH stack in the Parse object is disabled following an error.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: de6e6d6846d6a41c4821454dfdc042096234df753be08c5567b79fe535d9b6ea
User & Date: drh 2019-11-09 14:38:58.070
References
2019-12-27
20:54
Do not attempt to unwind the WITH stack in the Parse object following an error. This fixes a separate case to [de6e6d68], but also causes an assertion fault at select.c:4666 for test case altertab3-22.4. (check-in: d29edef934 user: dan tags: better-error-handling-1)
Context
2019-11-09
14:44
New dbsqlfuzz test cases added. (check-in: 18c3a17dc8 user: drh tags: trunk)
14:38
Make sure the WITH stack in the Parse object is disabled following an error. (check-in: de6e6d6846 user: drh tags: trunk)
2019-11-08
20:13
When a virtual table reports orderByConsumed, that tells us nothing about whether or not the SQLITE_DISTINCTBY constraint is met. Fix for ticket [7e59041f9c4e5102]. Test cases in TH3. (check-in: b59f94e4da user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
4664
4665
4666
4667
4668
4669
4670



4671
4672
4673
4674
4675
4676
4677
){
  Parse *pParse = pWalker->pParse;
  sqlite3 *db = pParse->db;
  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */
  With *pWith;                    /* WITH clause that pCte belongs to */

  assert( pFrom->pTab==0 );




  pCte = searchWith(pParse->pWith, pFrom, &pWith);
  if( pCte ){
    Table *pTab;
    ExprList *pEList;
    Select *pSel;
    Select *pLeft;                /* Left-most SELECT statement */







>
>
>







4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
){
  Parse *pParse = pWalker->pParse;
  sqlite3 *db = pParse->db;
  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */
  With *pWith;                    /* WITH clause that pCte belongs to */

  assert( pFrom->pTab==0 );
  if( pParse->nErr ){
    return SQLITE_ERROR;
  }

  pCte = searchWith(pParse->pWith, pFrom, &pWith);
  if( pCte ){
    Table *pTab;
    ExprList *pEList;
    Select *pSel;
    Select *pLeft;                /* Left-most SELECT statement */
Changes to src/util.c.
188
189
190
191
192
193
194

195
196
197
198
199
200
201
  if( db->suppressErr ){
    sqlite3DbFree(db, zMsg);
  }else{
    pParse->nErr++;
    sqlite3DbFree(db, pParse->zErrMsg);
    pParse->zErrMsg = zMsg;
    pParse->rc = SQLITE_ERROR;

  }
}

/*
** If database connection db is currently parsing SQL, then transfer
** error code errCode to that parser if the parser has not already
** encountered some other kind of error.







>







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  if( db->suppressErr ){
    sqlite3DbFree(db, zMsg);
  }else{
    pParse->nErr++;
    sqlite3DbFree(db, pParse->zErrMsg);
    pParse->zErrMsg = zMsg;
    pParse->rc = SQLITE_ERROR;
    pParse->pWith = 0;
  }
}

/*
** If database connection db is currently parsing SQL, then transfer
** error code errCode to that parser if the parser has not already
** encountered some other kind of error.
Changes to test/with3.test.
26
27
28
29
30
31
32








33
34
35
36
37
38
39
40
#
do_catchsql_test 1.0 {
  WITH i(x) AS (
    WITH j AS (SELECT 10)
    SELECT 5 FROM t0 UNION SELECT 8 FROM m
  )
  SELECT * FROM i;








} {1 {no such table: m}}

# Additional test cases that came out of the work to
# fix for Kostya's problem.
#
do_execsql_test 2.0 {
 WITH
  x1 AS (SELECT 10),







>
>
>
>
>
>
>
>
|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
do_catchsql_test 1.0 {
  WITH i(x) AS (
    WITH j AS (SELECT 10)
    SELECT 5 FROM t0 UNION SELECT 8 FROM m
  )
  SELECT * FROM i;
} {1 {no such table: t0}}

# 2019-11-09 dbfuzzcheck find
do_catchsql_test 1.1 {
  CREATE VIEW v1(x,y) AS
    WITH t1(a,b) AS (VALUES(1,2))
    SELECT * FROM nosuchtable JOIN t1;
  SELECT * FROM v1;
} {1 {no such table: main.nosuchtable}}

# Additional test cases that came out of the work to
# fix for Kostya's problem.
#
do_execsql_test 2.0 {
 WITH
  x1 AS (SELECT 10),