File: connection_gc_test.R

package info (click to toggle)
r-cran-rsqlite 0.11.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,288 kB
  • ctags: 9,498
  • sloc: ansic: 89,625; sh: 17; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
test_connections_are_finalized <- function()
{
    drv <- SQLite()
    dbs <- lapply(1:50, function(x) {
        dbConnect(drv, dbname = ":memory:")
    })
    checkEquals(50L, dbGetInfo(SQLite())$num_con)
    rm(dbs)
    gc(verbose = FALSE)
    checkEquals(0L, dbGetInfo(SQLite())$num_con)
}

test_connections_are_held_by_result_set <- function()
{
    db <- dbConnect(SQLite(), dbname = ":memory:")
    res <- dbSendQuery(db, "create table t1 (a text, b text)")
    rm(db)
    gc(verbose = FALSE)
    checkEquals(1L, dbGetInfo(SQLite())$num_con)
    dbClearResult(res)
    ## clearing a result set means that result set no loner
    ## protects the connection
    gc(verbose = FALSE)
    checkEquals(0L, dbGetInfo(SQLite())$num_con)
}