Re: [R] crash on multiple queries to postgresql db
Dylan Beaudette wrote: Subsequent calls to: conn <- dbConnect(PgSQL(), host="localhost", dbname="xxx", user="xxx") query <- dbSendQuery(conn, query_text) res <- dbGetResult(query) are resulting in this: *** glibc detected *** /usr/local/lib/R/bin/exec/R: realloc(): invalid other attached packages: [1] RdbiPgSQL_1.8.0 Rdbi_1.8.0 lattice_0.17-20 Any ideas? Well, first off, since you are apparently using RdbiPgSQL from bioconductor, you should probably try asking there. But in any case, you might try the latest release from bioconductor: http://www.bioconductor.org/packages/release/bioc/src/contrib/RdbiPgSQL_1.16.0.tar.gz or else try the recently released PostgreSQL DBI package on CRAN: http://cran.stat.ucla.edu/src/contrib/RPostgreSQL_0.1-3.tar.gz HTH, Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RPostgreSQL segfault with LEFT JOIN
Dylan Beaudette wrote: After some further investigation, I see that the query works fine if I *do not use column aliases* : Looks like *any* query using a column alias will segfault unless the alias exactly matches the column name (in which case why bother). The code starting at line 423 in RS-PostgreSQL.c looks like: 8<--- if(PQftablecol(my_result,j) !=0) { /* Code to find whether a row can be nullable or not */ sprintf(buff, "select attnotnull from pg_attribute where attrelid=%d and attname='%s'", PQftable(my_result,j),(char*)PQfname(my_result,j)); res = PQexec (conn, buff ); if(strcmp(PQgetvalue(res,0,0),"f")==0) { 8<--- The crash occurs at line 430 (the strcmp()) because PQgetvalue(res,0,0) returns NULL. PQfname() will return the column alias, not the actual column name, therefore the PQexec() here returns no results. At the very least, PQresultStatus(res) or perhaps PQntuples(res) should be used immediately after PQexec() to ensure you have a good result before trying to use it in strcmp(). In any case, I think the simple fix (untested) is something like: 8<--- if(PQftablecol(my_result,j) !=0) { /* Code to find whether a row can be nullable or not */ sprintf(buff, "select attnotnull from pg_attribute where attrelid=%d and attnum=%d", PQftable(my_result,j),PQftablecol(my_result,j)); 8<--- i.e. use the table column number and pg_attribute.attnum field. This is beyond what is appropriate for r-help, so I suggest any further discussion go off-list (or is there somewhere more appropriate, e.g. r-devel?) HTH, Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RPostgreSQL package and libpq.dll file
Lore M wrote: > Dear all, I'd like to use the package RPostgreSQL. I'm using R > version 2.8.1 and I've download the last version RPostgreSQL. When I > load the package, I get something like "the file LIBPQ.DLL is > missing". Do you have any idea about what I'm suppose to do ? Thanks > everyone. libpq.dll is the PostgreSQL client library. You should be able to get it here: http://www.postgresql.org/download/windows HTH Joe signature.asc Description: OpenPGP digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.