SQLite

Check-in [4f4a9ccae7]
Login

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

Overview
Comment:Also test that setting sqlite3_vtab.zErrMsg works from within the xRename method. (CVS 5520)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4f4a9ccae7d25b9856d1203f6b289d552c2b425e
User & Date: danielk1977 2008-08-01 17:51:47.000
Context
2008-08-01
18:47
Fix problems in test scripts. Add new test cases to improve test coverage. (CVS 5521) (check-in: b65f493c75 user: drh tags: trunk)
17:51
Also test that setting sqlite3_vtab.zErrMsg works from within the xRename method. (CVS 5520) (check-in: 4f4a9ccae7 user: danielk1977 tags: trunk)
17:37
Test that virtual table methods xBestIndex, xOpen, xFilter, xNext, xColumn, xRowid, xUpdate, xSync and xBegin can all return error messages using the sqlite3_vtab.zErrMsg variable. (CVS 5519) (check-in: 007359b770 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test8.c.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.70 2008/08/01 17:37:41 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

#ifndef SQLITE_OMIT_VIRTUALTABLE







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.71 2008/08/01 17:51:47 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

#ifndef SQLITE_OMIT_VIRTUALTABLE
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
*/

/*
** Errors can be provoked within the following echo virtual table methods:
**
**   xBestIndex   xOpen     xFilter   xNext   
**   xColumn      xRowid    xUpdate   xSync   
**   xBegin
**
** This is done by setting the global tcl variable:
**
**   echo_module_fail($method,$tbl)
**
** where $method is set to the name of the virtual table method to fail
** (i.e. "xBestIndex") and $tbl is the name of the table being echoed (not







|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
*/

/*
** Errors can be provoked within the following echo virtual table methods:
**
**   xBestIndex   xOpen     xFilter   xNext   
**   xColumn      xRowid    xUpdate   xSync   
**   xBegin       xRename
**
** This is done by setting the global tcl variable:
**
**   echo_module_fail($method,$tbl)
**
** where $method is set to the name of the virtual table method to fail
** (i.e. "xBestIndex") and $tbl is the name of the table being echoed (not
1213
1214
1215
1216
1217
1218
1219




1220
1221
1222
1223
1224
1225
1226
  *ppArg = interp;
  return 1;
}

static int echoRename(sqlite3_vtab *vtab, const char *zNewName){
  int rc = SQLITE_OK;
  echo_vtab *p = (echo_vtab *)vtab;





  if( p->isPattern ){
    int nThis = strlen(p->zThis);
    char *zSql = sqlite3MPrintf(0, "ALTER TABLE %s RENAME TO %s%s", 
        p->zTableName, zNewName, &p->zTableName[nThis]
    );
    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);







>
>
>
>







1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
  *ppArg = interp;
  return 1;
}

static int echoRename(sqlite3_vtab *vtab, const char *zNewName){
  int rc = SQLITE_OK;
  echo_vtab *p = (echo_vtab *)vtab;

  if( simulateVtabError(p, "xRename") ){
    return SQLITE_ERROR;
  }

  if( p->isPattern ){
    int nThis = strlen(p->zThis);
    char *zSql = sqlite3MPrintf(0, "ALTER TABLE %s RENAME TO %s%s", 
        p->zTableName, zNewName, &p->zTableName[nThis]
    );
    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
Changes to test/vtab1.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2006 June 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 file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.56 2008/08/01 17:37:41 danielk1977 Exp $

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

ifcapable !vtab||!schema_pragmas {
  finish_test
  return













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2006 June 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 file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.57 2008/08/01 17:51:47 danielk1977 Exp $

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

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
1149
1150
1151
1152
1153
1154
1155







1156
1157
1158
  do_test vtab1-16.$tn {
    set echo_module_fail($method,t2) "the $method method has failed"
    catchsql { INSERT INTO echo_t2 VALUES(7, 8, 9) }
  } "1 {echo-vtab-error: the $method method has failed}"
  unset echo_module_fail($method,t2)
  incr tn
}








unset -nocomplain echo_module_begin_fail
finish_test







>
>
>
>
>
>
>



1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
  do_test vtab1-16.$tn {
    set echo_module_fail($method,t2) "the $method method has failed"
    catchsql { INSERT INTO echo_t2 VALUES(7, 8, 9) }
  } "1 {echo-vtab-error: the $method method has failed}"
  unset echo_module_fail($method,t2)
  incr tn
}

do_test vtab1-16.$tn {
  set echo_module_fail(xRename,t2) "the xRename method has failed"
  catchsql { ALTER TABLE echo_t2 RENAME TO another_name }
} "1 {echo-vtab-error: the xRename method has failed}"
unset echo_module_fail(xRename,t2)
incr tn

unset -nocomplain echo_module_begin_fail
finish_test