通过RPostgreSQL建立数据库连接时R崩溃

时间:2018-04-11 18:34:00

标签: r segmentation-fault rpostgresql

我正在使用下面提到的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>"
)

以下是我的R会话信息,直到con分配

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版本是否有错误?

1 个答案:

答案 0 :(得分:0)

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

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