Skip to content

Commit

Permalink
version 0.1-5
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel authored and gaborcsardi committed Oct 13, 2009
1 parent 5aaf120 commit 8f6ee8c
Show file tree
Hide file tree
Showing 31 changed files with 2,970 additions and 2,275 deletions.
21 changes: 12 additions & 9 deletions DESCRIPTION
@@ -1,15 +1,18 @@
Package: RPostgreSQL
Version: 0.1-4
Date: $Date: 2009-01-26 20:14:54 -0600 (Mon, 26 Jan 2009) $
Version: 0.1-5
Date: $Date: 2009-10-13 19:34:13 -0500 (Tue, 13 Oct 2009) $
Title: R interface to the PostgreSQL database system
Author: Sameer Kumar Prayaga <sameer.bits@gmail.com> with mentor Dirk Eddelbuettel <edd@debian.org>
Author: Sameer Kumar Prayaga <sameer.bits@gmail.com> with mentor Dirk
Eddelbuettel <edd@debian.org>
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: Database interface and PostgreSQL driver for R.
This version complies with the database interface
definition as implemented in the package DBI.
Description: Database interface and PostgreSQL driver for R This
version complies with the database interface definition as
implemented in the package DBI.
LazyLoad: true
Depends: R (>= 2.7.0), methods, DBI (>= 0.1-4)
Depends: R (>= 2.9.0), methods, DBI (>= 0.1-4)
License: GPL-2
URL: http://www.stat.bell-labs.com/RS-DBI, http://www.postgresql.org
Collate: S4R.R zzz.R PostgreSQLSupport.R dbObjectId.R PostgreSQL.R
Packaged: Tue Jan 27 19:45:32 2009; edd
Collate: S4R.R zzz.R PostgreSQLSupport.R dbObjectId.R PostgreSQL.R
Packaged: 2009-10-14 00:38:42 UTC; edd
Repository: CRAN
Date/Publication: 2009-10-14 09:33:43
25 changes: 18 additions & 7 deletions R/PostgreSQL.R
@@ -1,6 +1,6 @@

## PostgreSQL.R
## Last Modified: $Date: 2008-10-08 19:55:03 -0500 (Wed, 08 Oct 2008) $
## Last Modified: $Date: 2009-10-09 19:46:41 -0500 (Fri, 09 Oct 2009) $

## This package was developed as a part of Summer of Code program organized by Google.
## Thanks to David A. James & Saikat DebRoy, the authors of RMySQL package.
Expand Down Expand Up @@ -138,8 +138,8 @@ setMethod("summary", "PostgreSQLConnection",
setMethod("dbListTables", "PostgreSQLConnection",
def = function(conn, ...){
out <- dbGetQuery(conn,
"select tablename from pg_tables where schemaname !='information_schema' and schemaname !='pg_catalog'",
...)
"select tablename from pg_tables where schemaname !='information_schema' ",
"and schemaname !='pg_catalog'", ...)
if (is.null(out) || nrow(out) == 0)
out <- character(0)
else
Expand Down Expand Up @@ -174,10 +174,21 @@ setMethod("dbWriteTable",
setMethod("dbExistsTable",
signature(conn="PostgreSQLConnection", name="character"),
def = function(conn, name, ...){
## TODO: find out the appropriate query to the PostgreSQL metadata
avail <- dbListTables(conn)
if(length(avail)==0) avail <- ""
match(tolower(name), tolower(avail), nomatch=0)>0
## Edd 09 Oct 2009: Fusion of patches by Joe Conway and Prasenjit Kapat
names <- strsplit(name, ".", fixed=TRUE)[[1]]
if (length(names) == 2) { # format was "public.sometable"
res <- dbGetQuery(conn,
paste("select schemaname,tablename from pg_tables where ",
"schemaname !='information_schema' ",
"and schemaname !='pg_catalog' and schemaname='",
names[1], "' and tablename='", names[2], "'", sep=""))
} else {
res <- dbGetQuery(conn,
paste("select tablename from pg_tables where ",
"schemaname !='information_schema' and schemaname !='pg_catalog' ",
"and tablename='", names[1], "'", sep=""))
}
return(as.logical(dim(res)[1]))
},
valueClass = "logical"
)
Expand Down
32 changes: 27 additions & 5 deletions R/PostgreSQLSupport.R
@@ -1,6 +1,6 @@

## PostgreSQLSupport.R
## Last Modified: $Date: 2008-10-08 19:49:52 -0500 (Wed, 08 Oct 2008) $
## Last Modified: $Date: 2009-10-09 19:51:35 -0500 (Fri, 09 Oct 2009) $

## This package was developed as a part of Summer of Code program organized by Google.
## Thanks to David A. James & Saikat DebRoy, the authors of RMySQL package.
Expand Down Expand Up @@ -79,8 +79,20 @@ postgresqlDriverInfo <- function(obj, what="", ...) {
postgresqlNewConnection <- function(drv, user="", password="",
host="",dbname = "",
port = "", tty ="",options="" ) {
if(!isIdCurrent(drv))
if (!isIdCurrent(drv))
stop("expired manager")
if (is.null(user))
stop("user argument cannot be NULL")
if (is.null(password))
stop("password argument cannot be NULL")
if (is.null(host))
stop("host argument cannot be NULL")
if (is.null(dbname))
stop("dbname argument cannot be NULL")
if (is.null(port))
stop("port argument cannot be NULL")
if (is.null(tty))
stop("tty argument cannot be NULL")
con.params <- as.character(c(user, password, host,
dbname, port,
tty,options))
Expand Down Expand Up @@ -191,11 +203,21 @@ postgresqlQuickSQL <- function(con, statement) {
if(!isIdCurrent(con))
stop(paste("expired", class(con)))
nr <- length(dbListResults(con))
if(nr>0){ ## are there resultSets pending on con?
if (nr > 0) { ## are there resultSets pending on con?
new.con <- dbConnect(con) ## yep, create a clone connection
on.exit(dbDisconnect(new.con))
rs <- dbSendQuery(new.con, statement)
} else rs <- dbSendQuery(con, statement)
rs <- try(dbSendQuery(new.con, statement))
if (inherits(rs, ErrorClass)){
warning("Could not create execute", statement)
return(NULL)
}
} else {
rs <- try(dbSendQuery(con, statement))
if (inherits(rs, ErrorClass)){
warning("Could not create execute", statement)
return(NULL)
}
}
if(dbHasCompleted(rs)){
dbClearResult(rs) ## no records to fetch, we're done
invisible()
Expand Down
2 changes: 1 addition & 1 deletion R/S4R.R
@@ -1,5 +1,5 @@
## R/S-Plus compatibility
## Last Modified: $Date#
## Last Modified: $Date: 2009-05-19 17:18:49 -0500 (Tue, 19 May 2009) $

## This package was developed as a part of Summer of Code program organized by Google.
## Thanks to David A. James & Saikat DebRoy, the authors of RMySQL package.
Expand Down
2 changes: 1 addition & 1 deletion R/dbObjectId.R
@@ -1,5 +1,5 @@
## Class: dbObjectId
## Last Modified: $Date#
## Last Modified: $Date: 2009-05-19 17:18:49 -0500 (Tue, 19 May 2009) $

## This package was developed as a part of Summer of Code program organized by Google.
## Thanks to David A. James & Saikat DebRoy, the authors of RMySQL package.
Expand Down
19 changes: 13 additions & 6 deletions configure.in
Expand Up @@ -21,9 +21,10 @@ if test "${PG_CONFIG}" != ""; then
PG_INCDIR=`${PG_CONFIG} --includedir`
PG_LIBDIR=`${PG_CONFIG} --libdir`

else
else

# let's look around -- code copied from RdbuiPgSQL but modified to use test -f
# added fink standard install location Neil 8/30/2009
AC_MSG_NOTICE([checking for PostgreSQL header files])
if ! test $PG_INCDIR
then
Expand All @@ -38,11 +39,14 @@ else
/usr/local/postgresql/include \
/opt/include \
/opt/include/pgsql \
/opt/include/postgresql
/opt/include/postgresql \
/opt/local/include \
/opt/local/include/postgresql \
/sw/include/postgresql
do

if test -f ${dir}/libpq-fe.h
then
then
PG_INCDIR=${dir}
break
fi
Expand All @@ -63,15 +67,18 @@ else
/usr/local/postgresql/lib \
/opt/lib \
/opt/lib/pgsql \
/opt/lib/postgresql
/opt/lib/postgresql \
/opt/local/lib \
/opt/local/lib/postgresql \
/sw/lib
do
if test -f ${dir}/libpq.so
then
then
PG_LIBDIR=${dir}
break
fi
if test -f ${dir}/libpq.dylib
then
then
PG_LIBDIR=${dir}
break
fi
Expand Down
49 changes: 49 additions & 0 deletions inst/ChangeLog
@@ -1,3 +1,52 @@
2009-10-13 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION: CRAN release 0.1-5
+ No new features but fixes for bugs #1, #2, #3 and #6 on the issue
tracker
+ Both #4 and #5 are feature / enhancement request for which
patch contributions are greatly appreciated.
+ Lastly #7 cannot be replicated.

[ Neil Tiffin ]
* configure.in: Added standard OS X / Fink location

* src/RS-DBI.*: Consistent formatting via use of GNU indent
* src/RS-PostgreSQL.*: idem
* src/S4R.h: idem

[ Dirk Eddelbuettel ]

* src/RS-PostgreSQL.c: Apply fix by Joe Conway for seg.fault on
alias'ed queries report as issue #1 in the issue tracker.
* src/RS-PostgreSQL.c: Remove unused variables

* R/PostgresSQL.R: Correction to dbExistsTable() to also recognise
queries of the form 'schemaname.tablename' which was reported as
issue #3 in the issue tracker following earlier emails by Prasenjit
Kapat -- thanks to Prasenjit and Joe Conway patches that I merged

* R/PostgreSQLSupport.R: In dbConnect(), stop if any one of user,
password, host, dbname, port or tty is NULL to prevent a seg.fault
which was reported as issue #2 on the issue tracker
* R/PostgreSQLSupport.R: Wrap dbSendQuery() in try() to be more
fault-tolerant an queries with errors which was reported as
issue #6, thanks to Joe Conway for the suggested fix.

* man/dbApply.Rd: Commented-out \usage thanks to new Rd parser
* man/safe.write.Rd: Fixed cross-references thanks to R 2.10.0 parser
* man/PostgreSQL.Rd: idem
* man/dbReadTable-methods.Rd: idem

* R/dbObjectId.R: Set missing SVN property Date
* R/S4R.R: idem

* tests/connectWithNull.*: added new test and comparison output
* tests/dbExistsIssue.*: idem
* tests/dbWriteTable.*: idem
* tests/selectWhereZero.*: idem
* tests/selectWithAlias.*: idem
* tests/dataTypeTests.R: Remove correct temp. table

2009-01-26 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION: CRAN release 0.1-4
Expand Down
25 changes: 23 additions & 2 deletions inst/NEWS
@@ -1,10 +1,31 @@
Version 0.1-5 -- 2009-10-13

Version 0.1-1
o Four issues reported at the Issue tracker at the Google Code site
are addressed, two more are feature requests and one cannot be
replicated

o A number of other small fixes and enhancements to code and
documentation as detailed in the ChangeLog file

Version 0.1-4 -- 2009-01-26

o Fix to one of the documentation files

Version 0.1-3 -- 2008-12-12

o Fixed a memory leak detected by Valgrind with thanks to Jeff Horner
who applied a similar fix to RMySQL

Version 0.1-2 -- 2008-11-02

o Some fixes to the regression tests and configuration

Version 0.1-1 -- 2008-10-28

o DESCRIPTION: Correct Url: field by adding http:// parts. Thanks to
Gabor for the hint.

Version 0.1-0
Version 0.1-0 -- 2008-10-21

o First Release

Expand Down
2 changes: 1 addition & 1 deletion man/PostgreSQL.Rd
Expand Up @@ -102,7 +102,7 @@ On meta-data:
\code{\link[DBI]{dbGetStatement}}
\code{\link[DBI]{dbHasCompleted}}
\code{\link[DBI]{dbGetRowCount}}
\code{\link[DBI]{dbGetAffectedRows}}
\code{\link[DBI]{dbGetRowsAffected}}
}
\examples{\dontrun{
# create a PostgreSQL instance and create one connection.
Expand Down
4 changes: 2 additions & 2 deletions man/dbReadTable-methods.Rd
Expand Up @@ -68,13 +68,13 @@

\code{header} is a logical indicating whether the first data line
(but see \code{skip}) has a header or not. If missing, it value
is determined following \code{\link[base]{read.table}} convention,
is determined following \code{\link{read.table}} convention,
namely, it is set to TRUE if and only if the first row has one
fewer field that the number of columns.

\code{row.names} is a logical to specify whether the first column
is a set of row names. If missing its default follows the
\code{\link[base]{read.table}} convention.
\code{\link{read.table}} convention.

\code{col.names} a character vector with column names (these names
will be filtered with \code{\link[DBI]{make.db.names}} to
Expand Down
2 changes: 2 additions & 0 deletions man/dbSendQuery-methods.Rd
Expand Up @@ -45,6 +45,8 @@ drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, "usr", "password", "dbname")
res <- dbSendQuery(con, "SELECT * from sales")
data <- fetch(res, n = -1)
# alternatively, use dbGetQuery
data <- dbGetQuery(con, "SELECT * from sales")
}
}
\keyword{methods}
Expand Down
8 changes: 4 additions & 4 deletions man/safe.write.Rd
Expand Up @@ -16,17 +16,17 @@ safe.write(value, file, batch, ...)
\item{\dots}{any other arguments are passed to \code{write.table}.}
}
\details{
The function has a while loop invoking \code{\link[base]{write.table}}
The function has a while loop invoking \code{\link{write.table}}
for subsets of \code{batch} rows of \code{value}. Since this is
a helper function for \code{\link[RPostgreSQL]{postsqlWriteTable}}, it has
hardcoded other arguments to \code{write.table}.
a helper function for \code{\link{postgresqlWriteTable}}, it has
hardcoded other arguments to \code{\link{write.table}}.
}
\value{
\code{NULL}, invisibly.
}
\note{No error checking whatsoever is done.}

\seealso{\code{\link[base]{write.table}}}
\seealso{\code{\link{write.table}}}

\examples{\dontrun{
ctr.file <- file("dump.sqloader", "w")
Expand Down

0 comments on commit 8f6ee8c

Please sign in to comment.