[R-sig-DB] RSQLite segfault after adding column to table

Noah Hoffman no@h@ho||m@n @end|ng |rom gm@||@com
Fri Oct 26 21:35:00 CEST 2007


Hello -

I've noticed a segfault caused by attempting to select from a table
after a column of unspecified type is added. I've only tested this
using the single R installation described below.

Here's some info about my environment:
> sessionInfo()
R version 2.7.0 Under development (unstable) (2007-09-24 r42964)
x86_64-unknown-linux-gnu
...
other attached packages:
[1] RSQLite_0.6-0 DBI_0.2-3

And here's code to reproduce the segfault:

# causes segfault!
library(RSQLite)
con <- dbConnect(dbDriver("SQLite"), dbname = ":memory:")
dbGetQuery(con, "create table s (col1 INTEGER)")
dbGetQuery(con, "insert into s (col1) values (1)")
dbGetQuery(con, "select * from s")
dbGetQuery(con, "alter table s add column col2")
dbGetQuery(con, "select * from s")
 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .Call("RS_SQLite_fetch", rsId, nrec = n, PACKAGE = .SQLitePkgName)
 2: sqliteFetch(rs, n = -1, ...)
 3: sqliteQuickSQL(conn, statement, ...)
 4: dbGetQuery(con, "select * from s")
 5: dbGetQuery(con, "select * from s")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

The following code executes without errors:

# no segfault
library(RSQLite)
con <- dbConnect(dbDriver("SQLite"), dbname = ":memory:")
dbGetQuery(con, "create table s (col1 INTEGER)")
dbGetQuery(con, "insert into s (col1) values (1)")
dbGetQuery(con, "select * from s")
dbGetQuery(con, "alter table s add column col2 INTEGER")
# neither of these have a problem either:
# dbGetQuery(con, "alter table s add column col2 TEXT")
# dbGetQuery(con, "alter table s add column col2 default 0")
dbGetQuery(con, "select * from s")

Thanks,

Noah




More information about the R-sig-DB mailing list