【问题标题】:R crashes when establishing a database connection via RPostgreSQL通过 RPostgreSQL 建立数据库连接时 R 崩溃
【发布时间】:2018-09-21 18:15:35
【问题描述】:

我正在使用如下所示的 R 版本:

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.70 (7463) x86_64-apple-darwin15.6.0]

我使用的是 macOS Sierra 版本 10.12.6 (16G1314)。使用 3.1 GHz Intel Core i7 处理器,内存 16 GB 1867 MHz DDR3,显卡是 Intel Iris Graphics 6100 1536 MB。

这是我崩溃的 R 代码。出于安全原因,我删除了主机名、端口、数据库名称、用户名和密码。 con 分配是崩溃的原因。我正在尝试使用组织内的代码示例连接到 Redshift 集群。

library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(
    drv,
    host = "<host name>",
    port = "<four digit port>"
    dbname = "'dbname = <database name> ssl=require'",
    user = "<user name>",
    password = "<password>"
)

这是我在分配 con 之前的 R 会话信息

R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] RPostgreSQL_0.6-2 DBI_0.8          

loaded via a namespace (and not attached):
[1] compiler_3.4.3

这是崩溃报告,出于安全原因删除了一些内容:

 *** caught segfault ***
address 0x0, cause 'memory not mapped'

Traceback:
 1: .Call(RS_PostgreSQL_newConnection, drvId, con.params)
 2: postgresqlNewConnection(drv, ...)
 3: dbConnect(drv, host = "<hostname>", port = "<port>",     dbname = "'dbname = <database name> ssl=require'", user = "<user name>",     password = "<password>")
 4: dbConnect(drv, host = "<hostname>", port = "<port>",     dbname = "'dbname = <database name> ssl=require'", user = "<user name>",     password = "<password>")

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

我已经用两个 Redshift 集群尝试过,但遇到了同样的问题。

问题:如何解决此问题,以便通过 R 连接到我的 Redshift 集群?

额外问题:是我自己还是最近 R 版本有问题?

【问题讨论】:

  • 把它作为一个答案。然后我会测试它,如果它有效,请检查你的答案

标签: r segmentation-fault rpostgresql


【解决方案1】:

我迅速搜索并浏览了 Amazon 文档中的 Redshift。他们建议您使用 JDBC 或 ODBC 驱动程序。 RPostgreSQL 包使用 libpq 驱动程序,所以我不希望它与 Redshift 一起使用。

我建议您使用RODBCRJDBCodbc,具体取决于哪个最适合您的设置。

【讨论】:

    猜你喜欢
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多