/ Check-in [0f57effa]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Remove an incorrect ALWAYS() statement and add a test case to show when the condition is sometimes false.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0f57effa3642e66a863f32cc7fba86d167084af3
User & Date: drh 2016-08-05 15:34:42
Context
2016-08-05
16:16
Undo commit [f250166bb]. It is required to handle IO and other errors that occur within a VACUUM of a Zipvfs database. check-in: ae72513a user: dan tags: trunk
15:34
Remove an incorrect ALWAYS() statement and add a test case to show when the condition is sometimes false. check-in: 0f57effa user: drh tags: trunk
14:35
Fix a very obscure problem following OOM in sqlite3_declare_vtab(). check-in: 68eac748 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vtab.c.

803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
** This call is a no-op if zTab is not a virtual table.
*/
int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
  int rc = SQLITE_OK;
  Table *pTab;

  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
  if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
    VTable *p;
    int (*xDestroy)(sqlite3_vtab *);
    for(p=pTab->pVTable; p; p=p->pNext){
      assert( p->pVtab );
      if( p->pVtab->nRef>0 ){
        return SQLITE_LOCKED;
      }







|







803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
** This call is a no-op if zTab is not a virtual table.
*/
int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
  int rc = SQLITE_OK;
  Table *pTab;

  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
  if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){
    VTable *p;
    int (*xDestroy)(sqlite3_vtab *);
    for(p=pTab->pVTable; p; p=p->pNext){
      assert( p->pVtab );
      if( p->pVtab->nRef>0 ){
        return SQLITE_LOCKED;
      }

Changes to test/stat.test.

30
31
32
33
34
35
36


37










38
39
40
41

42
43
44
45
46
47
48
proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
db func a_string a_string

register_dbstat_vtab db
do_execsql_test stat-0.0 {
  PRAGMA table_info(dbstat);
} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}


do_execsql_test stat-0.1 {










  PRAGMA auto_vacuum = OFF;
  CREATE VIRTUAL TABLE temp.stat USING dbstat;
  SELECT * FROM stat;
} {}


if {[wal_is_capable]} {
  do_execsql_test stat-0.1 {
    PRAGMA journal_mode = WAL;
    PRAGMA journal_mode = delete;
    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
      FROM stat;







>
>

>
>
>
>
>
>
>
>
>
>




>







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
proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
db func a_string a_string

register_dbstat_vtab db
do_execsql_test stat-0.0 {
  PRAGMA table_info(dbstat);
} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}

# Attempts to drop an eponymous virtual table are a no-op.
do_execsql_test stat-0.1 {
  DROP TABLE dbstat;
  PRAGMA table_info=dbstat;
} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}

db close
forcedelete test.db
sqlite3 db test.db
db func a_string a_string
register_dbstat_vtab db
do_execsql_test stat-0.2 {
  PRAGMA auto_vacuum = OFF;
  CREATE VIRTUAL TABLE temp.stat USING dbstat;
  SELECT * FROM stat;
} {}


if {[wal_is_capable]} {
  do_execsql_test stat-0.1 {
    PRAGMA journal_mode = WAL;
    PRAGMA journal_mode = delete;
    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
      FROM stat;