SQLite

Check-in [5ee625b198]
Login

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

Overview
Comment:Add tests to check that attempting to DROP a virtual table while it is use does not cause problems.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | nVDestroy
Files: files | file ages | folders
SHA1: 5ee625b1980f9fab6294d308349dfd9ba960b60b
User & Date: dan 2015-03-24 14:57:21.959
Context
2015-03-24
16:43
Prevent a virtual table from being destroyed while it is in use. Also: replace Vdbe.inVtabMethod with sqlite3.nVDestroy. Simplify the EXPLAIN output for P4.pVtab to only show the sqlite3_vtab pointer. (check-in: cbeb9a1aed user: drh tags: trunk)
14:57
Add tests to check that attempting to DROP a virtual table while it is use does not cause problems. (Closed-Leaf check-in: 5ee625b198 user: dan tags: nVDestroy)
14:05
More defenses against virtual table being deleted out from under a running statement. (check-in: 116c998230 user: drh tags: nVDestroy)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/vtab1.test.
1433
1434
1435
1436
1437
1438
1439






















































1440
  } {SQLITE_DONE}
  
  do_test 22.4.2 {
    sqlite3_finalize $stmt
  } {SQLITE_OK}
}























































finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
  } {SQLITE_DONE}
  
  do_test 22.4.2 {
    sqlite3_finalize $stmt
  } {SQLITE_OK}
}


#-------------------------------------------------------------------------
# The following tests verify that a DROP TABLE command on a virtual
# table does not cause other operations to crash.
#
#   23.1: Dropping a vtab while a SELECT is running on it.
#
#   23.2: Dropping a vtab while a SELECT that will, but has not yet,
#         open a cursor on the vtab, is running. In this case the
#         DROP TABLE succeeds and the SELECT hits an error.
#   
#   23.3: Dropping a vtab from within a user-defined-function callback
#         in the middle of an "INSERT INTO vtab SELECT ..." statement.
#
reset_db
load_static_extension db wholenumber
load_static_extension db eval
register_echo_module db

do_test 23.1 {
  execsql { CREATE VIRTUAL TABLE t1 USING wholenumber }
  set res ""
  db eval { SELECT value FROM t1 WHERE value<10 } {
    if {$value == 5} {
      set res [catchsql { DROP TABLE t1 }]
    }
  }
  set res
} {1 {database table is locked}}

do_test 23.2 {
  execsql { 
    CREATE TABLE t2(value);
    INSERT INTO t2 VALUES(1), (2), (3);
  }

  set res2 [list [catch {
    db eval {
      SELECT value FROM t2 UNION ALL 
      SELECT value FROM t1 WHERE value<10
    } {
      if {$value == 2} { set res1 [catchsql { DROP TABLE t1 }] }
    }
  } msg] $msg]
  list $res1 $res2
} {{0 {}} {1 {database table is locked}}}

do_test 23.3.1 {
  execsql { CREATE VIRTUAL TABLE t1e USING echo(t2) }
  execsql { INSERT INTO t1e SELECT 4 }
  catchsql { INSERT INTO t1e SELECT eval('DROP TABLE t1e') }
} {1 {database table is locked}}
do_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4}

finish_test