/ Check-in [102785b9]
Login

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

Overview
Comment:Return a better error message when problems are encountered parsing a TEMP trigger or TEMP view that references objects in other databases that have been modified or dropped. Ticket #3810. (CVS 6956)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:102785b9fbc5ab5dd740110243f080e3f3661e87
User & Date: drh 2009-08-01 16:27:00
Context
2009-08-01
18:22
Make sure all database connections are closed at the end of the test case for ticket #3810. (CVS 6957) check-in: 9bca5a0e user: drh tags: trunk
16:27
Return a better error message when problems are encountered parsing a TEMP trigger or TEMP view that references objects in other databases that have been modified or dropped. Ticket #3810. (CVS 6956) check-in: 102785b9 user: drh tags: trunk
15:54
Add a testcase for ticket #3810. (CVS 6955) check-in: 29972f74 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

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
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.129 2009/07/24 17:58:53 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
*/
static void corruptSchema(
  InitData *pData,     /* Initialization context */
  const char *zObj,    /* Object being parsed at the point of error */
  const char *zExtra   /* Error information */
){
  sqlite3 *db = pData->db;





  if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
    if( zObj==0 ) zObj = "?";
    sqlite3SetString(pData->pzErrMsg, pData->db,
       "malformed database schema (%s)", zObj);
    if( zExtra ){
      *pData->pzErrMsg = sqlite3MAppendf(pData->db, *pData->pzErrMsg, "%s - %s",
                                  *pData->pzErrMsg, zExtra);
    }
  }
  pData->rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_CORRUPT;
}

/*
** This is the callback routine for the code that initializes the







|













>
>
>
>
>


|
|

|
|







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
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.130 2009/08/01 16:27:00 drh Exp $
*/
#include "sqliteInt.h"

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
*/
static void corruptSchema(
  InitData *pData,     /* Initialization context */
  const char *zObj,    /* Object being parsed at the point of error */
  const char *zExtra   /* Error information */
){
  sqlite3 *db = pData->db;
  if( pData->iDb==1 && zObj && zExtra ){
    *pData->pzErrMsg = sqlite3MPrintf(db, "in %s: %s", zObj, zExtra);
    pData->rc = SQLITE_ERROR;
    return;
  }
  if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
    if( zObj==0 ) zObj = "?";
    sqlite3SetString(pData->pzErrMsg, db,
      "malformed database schema (%s)", zObj);
    if( zExtra ){
      *pData->pzErrMsg = sqlite3MAppendf(db, *pData->pzErrMsg, 
                                 "%s - %s", *pData->pzErrMsg, zExtra);
    }
  }
  pData->rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_CORRUPT;
}

/*
** This is the callback routine for the code that initializes the

Changes to test/tkt3810.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
42
43
44
45
46
47
48


49
50
51

52
53
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests to make sure #3810 is fixed.
#
# $Id: tkt3810.test,v 1.1 2009/08/01 15:54:26 drh Exp $

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

# Create a table using the first database connection.
#
do_test tkt3810-1 {
  execsql {
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(123);
    SELECT * FROM t1;
  }
} 123

................................................................................
#
do_test tkt3810-3 {
  execsql {DROP TABLE t1} db2
  execsql {
     CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN
       INSERT INTO t1 VALUES(2345);
     END;


     SELECT * FROM t1;
  }
} {}


finish_test







|






|







 







>
>
|

<
>


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
42
43
44
45
46
47
48
49
50
51
52

53
54
55
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests to make sure #3810 is fixed.
#
# $Id: tkt3810.test,v 1.2 2009/08/01 16:27:00 drh Exp $

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

# Create a table using the first database connection.
#
do_test tkt3810-1.1 {
  execsql {
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(123);
    SELECT * FROM t1;
  }
} 123

................................................................................
#
do_test tkt3810-3 {
  execsql {DROP TABLE t1} db2
  execsql {
     CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN
       INSERT INTO t1 VALUES(2345);
     END;
  }
  catchsql {
    SELECT * FROM t1;
  }

} {1 {in r1: no such table: t1}}

finish_test