错误:protect():使用 dbWriteTable (RSQLite) 写入文件时保护堆栈溢出

Posted

技术标签:

【中文标题】错误:protect():使用 dbWriteTable (RSQLite) 写入文件时保护堆栈溢出【英文标题】:Error: protect(): protection stack overflow while writing file with dbWriteTable (RSQLite) 【发布时间】:2016-07-27 11:48:12 【问题描述】:

我尝试使用 RSQLite 包中的 dbWriteTable 将包含 285,476 行和 17 列的 data.frame 写入 SQlite 数据库。我收到以下错误:

Error: evaluation nested too deeply: infinite recursion /    options(expressions=)?

然后我增加了限制

options(expressions = 500000)

又试了一次,却收到类似的错误:

Error: protect(): protection stack overflow

写入文本文件没有问题,会创建一个约 50MB 的文件。

有什么线索吗?

【问题讨论】:

使用可重现的代码提交错误 【参考方案1】:

在准备错误报告时,我发现上述问题是由在 R 3.3.0 中加载“rworldmap”包(1.3-6)和“RSQlite”包(1.0.0)引起的(运行时)在:Windows 7 x64(内部版本 7601)Service Pack 1;x86_64-w64-mingw32/x64(64 位))。只要未加载“rworldmap”或在以前的 R 版本(3.1.1;rworldmap 1.3-6;RSQLite 0.11.4)中,SQLite 上传就可以工作。

见下文:

R 3.3.0 RSQLite 错误/与 rworldmap 冲突

require(RSQLite) # load package
require(rworldmap)

# created dataframe
    my.df <- data.frame(col1 = 1:500000,
                col2 = as.character("blah"),
                col3 = as.character("blahblahblah"),
                col4 = as.character("2016-08-10 12:47:07"), 
                col5 = as.character("2016-08-10 12:47:07"), 
                col6 = as.character("2016-08-10 12:47:07"), 
                col7 = as.character("2016-08-10 12:47:07"), 
                col8 = as.character("2016-08-10 12:47:07"), 
                col9 = as.character("2016-08-10 12:47:07"), 
                col10 = as.character("2016-08-10 12:47:07"), 
                col11 = as.character("2016-08-10 12:47:07"), 
                col12 = 1,col13 = 1,col14 = 1,col15 = 1,col16 = 1,col17 = 1,col18 = 1
                )

# connect and upload to SQLite database 
        db=paste("test.sqlite",sep="")

        conLite = dbConnect(dbDriver("SQLite"),dbname = db)
        dbGetQuery(conLite,paste( "DROP TABLE IF EXISTS test"))
        dbWriteTable(conn=conLite, name = 'test', value = my.df, row.names = FALSE) 
        # R 3.3.0 gives: Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
        dbDisconnect(conLite)

用于 R 版本 3.3.0 的 sessionInfo()

R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rworldmap_1.3-6 sp_1.2-3        RSQLite_1.0.0   DBI_0.4-1      

loaded via a namespace (and not attached):
[1] foreign_0.8-66  fields_8.4-1    maps_3.1.0      maptools_0.8-39
[5] grid_3.3.0      spam_1.3-0      lattice_0.20-33

用于 R 版本 3.1.1 的 sessionInfo()

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rworldmap_1.3-6 sp_1.0-15       RSQLite_0.11.4  DBI_0.3.1      

loaded via a namespace (and not attached):
[1] fields_8.3-6    foreign_0.8-61  grid_3.1.1      lattice_0.20-29
[5] maps_2.3-9      maptools_0.8-30 spam_1.3-0

【讨论】:

以上是关于错误:protect():使用 dbWriteTable (RSQLite) 写入文件时保护堆栈溢出的主要内容,如果未能解决你的问题,请参考以下文章

RStudio 错误 - 创建大型环境对象:protect():保护堆栈溢出

latex 图表标题加入矩阵

数码相机按快门时不照相且显示write protect

使用protect_from_forgery时,Rails 403 会话响应过期

使用 Xcode 11 编译时 vm_protect 失败

protect的简介