Commit daba4136 authored by Ondrej Sury's avatar Ondrej Sury

New upstream version 0.4

parents
This diff is collapsed.
Package: RPostgreSQL
Version: 0.4
Date: $Date: 2013-03-27 15:32:53 +0900 (Wed, 27 Mar 2013) $
Title: R interface to the PostgreSQL database system
Author: Joe Conway, Dirk Eddelbuettel, Tomoaki Nishiyama, Sameer Kumar
Prayaga (during 2008), Neil Tiffin
Maintainer: Tomoaki Nishiyama <tomoakin@staff.kanazawa-u.ac.jp>
Description: Database interface and PostgreSQL driver for R This
package provides a Database Interface (DBI) compliant driver
for R to access PostgreSQL database systems.
.
In order to build and install this package from source, PostgreSQL
itself must be present your system to provide PostgreSQL
functionality via its libraries and header files. These files
are provided as postgresql-devel package under some Linux
distributions.
.
On Microsoft Windows system the attached libpq library source will be
used.
.
A wiki and issue tracking system for the package are available at
Google Code at https://code.google.com/p/rpostgresql/ .
LazyLoad: true
Depends: R (>= 2.9.0), methods, DBI (>= 0.1-4)
License: GPL-2 | file LICENSE
Copyright: Authors listed above, PostgreSQL Global Development Group,
and The Regents of the University of California
Collate: S4R.R zzz.R PostgreSQLSupport.R dbObjectId.R PostgreSQL.R
URL: https://code.google.com/p/rpostgresql/,
http://www.stat.bell-labs.com/RS-DBI, http://www.postgresql.org
Packaged: 2013-03-27 07:24:02 UTC; tomoaki
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-03-27 09:34:11
This package as a whole is distributed under GPL-2 (GNU GENERAL PUBLIC LICENSE
version 2). See the file COPYING in the top level of the R directory
tree for further details.
The files under src/libpq/ and libpq.dll are distributed under the
PostgreSQL License (see below). That is, if you take only that part out of the
package you may redistribute only under the restriction of
PostgreSQL License. Most of this package are distributed under GPL-2
and if you redistribute any part of this, you must follow GPL-2.
PostgreSQL License:
PostgreSQL Database Management System
(formerly known as Postgres, then as Postgres95)
Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this
paragraph and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
This diff is collapsed.
import(methods)
import(DBI)
useDynLib(RPostgreSQL)
## Classes
exportClasses(
dbObjectId,
PostgreSQLObject,
PostgreSQLDriver,
PostgreSQLConnection,
PostgreSQLResult
)
## Methods/Generics
exportMethods(
coerce,
dbApply,
dbCallProc,
dbClearResult,
dbColumnInfo,
dbCommit,
dbConnect,
dbDataType,
dbDisconnect,
# dbEscapeStrings,
dbExistsTable,
dbGetException,
dbGetInfo,
dbGetQuery,
dbGetRowCount,
dbGetRowsAffected,
dbGetStatement,
dbHasCompleted,
dbListConnections,
dbListFields,
dbListResults,
dbListTables,
# dbMoreResults,
# dbNextResult,
dbReadTable,
dbRemoveTable,
dbRollback,
dbSendQuery,
dbUnloadDriver,
dbWriteTable,
fetch,
format,
initialize,
isSQLKeyword,
make.db.names,
show,
SQLKeywords,
summary
)
## regular functions (most of these will be made private)
export(
PostgreSQL,
postgresqlBuildTableDefinition,
isPostgresqlIdCurrent,
.PostgreSQLKeywords,
postgresqlInitDriver,
postgresqlCloseDriver,
postgresqlDescribeDriver,
postgresqlDriverInfo,
postgresqlNewConnection,
postgresqlCloneConnection,
postgresqlDescribeConnection,
postgresqlConnectionInfo,
postgresqlCloseConnection,
postgresqlExecStatement,
postgresqlpqExec,
postgresqlCopyIn,
postgresqlCopyInDataframe,
postgresqlgetResult,
postgresqlQuickSQL,
postgresqlDBApply,
postgresqlFetch,
postgresqlResultInfo,
postgresqlDescribeResult,
postgresqlDescribeFields,
postgresqlCloseResult,
postgresqlImportFile,
postgresqlReadTable,
postgresqlWriteTable,
postgresqlEscapeStrings,
postgresqlDataType,
postgresqlQuoteId,
postgresqlTableRef
)
## constants
#export(
# CLIENT_LONG_PASSWORD,
# CLIENT_FOUND_ROWS,
# CLIENT_LONG_FLAG,
# CLIENT_CONNECT_WITH_DB,
# CLIENT_NO_SCHEMA,
# CLIENT_COMPRESS,
# CLIENT_ODBC,
# CLIENT_LOCAL_FILES,
# CLIENT_IGNORE_SPACE,
# CLIENT_PROTOCOL_41,
# CLIENT_INTERACTIVE,
# CLIENT_SSL,
# CLIENT_IGNORE_SIGPIPE,
# CLIENT_TRANSACTIONS,
# CLIENT_RESERVED,
# CLIENT_SECURE_CONNECTION,
# CLIENT_MULTI_STATEMENTS,
# CLIENT_MULTI_RESULTS
#)
This diff is collapsed.
This diff is collapsed.
## R/S-Plus compatibility
## $Id: S4R.R 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
## 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.
## Code from RMySQL package was reused with the permission from the authors.
## Also Thanks to my GSoC mentor Dirk Eddelbuettel for helping me in the development.
usingR <- function(major=0, minor=0){
if(is.null(version$language))
return(FALSE)
if(version$language!="R")
return(FALSE)
version$major>=major && version$minor>=minor
}
## constant holding the appropriate error class returned by try()
if(usingR()){
ErrorClass <- "try-error"
} else {
ErrorClass <- "Error"
}
## Class: dbObjectId
## $Id: dbObjectId.R 220 2011-12-03 12:50:46Z tomoakin@kenroku.kanazawa-u.ac.jp $
## 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.
## Code from RMySQL package was reused with the permission from the authors.
## Also Thanks to my GSoC mentor Dirk Eddelbuettel for helping me in the development.
##
## This mixin helper class is NOT part of the database interface definition,
## but it is extended by the Oracle, MySQL,PostgreSQL and SQLite implementations
## to allow us to conviniently (and portably)
## implement all database foreign objects methods (i.e., methods for show(),
## print() format() the dbManger, dbConnection, dbResultSet, etc.)
## A dbObjectId is an identifier into an actual remote database objects.
## This class and its derived classes <driver-manager>Object need to
## be VIRTUAL to avoid coercion (green book, p.293) during method dispatching.
setClass("dbObjectId", representation(Id = "integer", "VIRTUAL"))
## coercion methods
setAs("dbObjectId", "integer",
def = function(from) as(slot(from,"Id"), "integer")
)
setAs("dbObjectId", "numeric",
def = function(from) as(slot(from, "Id"), "integer")
)
setAs("dbObjectId", "character",
def = function(from) as(slot(from, "Id"), "character")
)
## formating, showing, printing,...
setMethod("format", "dbObjectId",
def = function(x, ...) {
paste("(", paste(as(x, "integer"), collapse=","), ")", sep="")
},
valueClass = "character"
)
setMethod("show", "dbObjectId", def = function(object) print(object))
setMethod("print", "dbObjectId",
def = function(x, ...){
expired <- if(isPostgresqlIdCurrent(x)) "" else "Expired "
str <- paste("<", expired, class(x), ":", format(x), ">", sep="")
cat(str, "\n")
invisible(NULL)
}
)
## verify that obj refers to a currently open/loaded database
isPostgresqlIdCurrent <- function(obj) {
obj <- as(obj, "integer")
.Call("RS_DBI_validHandle", obj, PACKAGE = .PostgreSQLPkgName)
}
## zzz.R
## $Id: zzz.R 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
## 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.
## Code from RMySQL package was reused with the permission from the authors.
## Also Thanks to my GSoC mentor Dirk Eddelbuettel for helping me in the development.
.onLoad <- function(lib, pkg) {
library.dynam("RPostgreSQL", pkg, lib)
}
rm -f config.log config.status
rm -rf autom4te.cache
rm -rf src/*.o src/*.so src/Makevars
rm -rf .RData typeTest.r.Rout
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Process this file with autoconf to produce a configure script.
#
# Configure.in for RPostgreSQL
# Copyright (C) 2008 Dirk Eddelbuettel and licensed under GNU GPL
#
# This file draws heavily on configure.in files from littler, RMySQL, and RdbiPgSQL
# Set the name and version -- the version set here will propagate to other files from here
AC_INIT(RPostgreSQL, 0.2)
# Checks for common programs using default macros
AC_PROG_CC
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
case "${host_os}" in
darwin*)
R_OS_TYPE="darwin"
;;
esac
# Check for non-standard programs: pg_config(1) to configure PostgreSQL builds
AC_PATH_PROG([PG_CONFIG], [pg_config])
# By default, we will not use the accompanied libpq
ENABLE_LIBPQ=
# If pg_config was found, let's use it
if test "${PG_CONFIG}" != ""; then
# Use pg_config for header and linker arguments
PG_INCDIR=`${PG_CONFIG} --includedir`
PG_LIBDIR=`${PG_CONFIG} --libdir`
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
for dir in \
/usr/include \
/usr/include/pgsql \
/usr/include/postgresql \
/usr/local/include \
/usr/local/include/pgsql \
/usr/local/include/postgresql \
/usr/local/pgsql/include \
/usr/local/postgresql/include \
/opt/include \
/opt/include/pgsql \
/opt/include/postgresql \
/opt/local/include \
/opt/local/include/postgresql \
/opt/local/include/postgresql84 \
/sw/opt/postgresql-8.4/include \
/Library/PostgresPlus/8.4SS/include \
/sw/include/postgresql
do
AC_MSG_NOTICE([Checking include ${dir}.])
if test -f ${dir}/libpq-fe.h
then
PG_INCDIR=${dir}
break
fi
done
fi
# likewise, let's look around for libpq.so
if ! test $PG_LIBDIR
then
for dir in \
/usr/lib \
/usr/lib/pgsql \
/usr/lib/postgresql \
/usr/local/lib \
/usr/local/lib/pgsql \
/usr/local/lib/postgresql \
/usr/local/pgsql/lib \
/usr/local/postgresql/lib \
/opt/lib \
/opt/lib/pgsql \
/opt/lib/postgresql \
/opt/local/lib \
/opt/local/lib/postgresql \
/opt/local/lib/postgresql84 \
/sw/opt/postgresql-8.4/lib \
/Library/PostgresPlus/8.4SS/lib \
/sw/lib
do
AC_MSG_NOTICE([Checking lib ${dir}.])
if test -f ${dir}/libpq.so
then
PG_LIBDIR=${dir}
break
fi
if test -f ${dir}/libpq.dylib
then
PG_LIBDIR=${dir}
break
fi
done
fi
if ! test $PG_LIBDIR
then
if test "$R_OS_TYPE" = "darwin" ; then
# in case we cannot find any libpq library we will use the accompanied libpq
# This content would be written into src/Makevars at the end of this script
ENABLE_LIBPQ='
PKG_CPPFLAGS=-Ilibpq
PKG_LIBS=libpq/libpq.a
.PHONY: all
all: $(SHLIB)
$(SHLIB): libpq/libpq.5.dylib
libpq/libpq.5.dylib:
(cd libpq; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -f Makefile.darwin)
clean:
(cd libpq; $(MAKE) -f Makefile.darwin clean)
'
fi
fi
fi
# Expand into arguments
PKG_CPPFLAGS="-I${PG_INCDIR}"
PKG_LIBS="-L${PG_LIBDIR} -lpq"
# Test for sanity by looking for libpq-fe.h, no explicit action on found, error on failure
AC_CHECK_FILE(["${PG_INCDIR}/libpq-fe.h"],
,
AC_SUBST(R_OS_TYPE))
# Now substitute these two variable in src/Makevars.in to create src/Makevars
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(PKG_LIBS)
AC_SUBST(ENABLE_LIBPQ)
AC_OUTPUT(src/Makevars)
RPostgreSQL version 0.4
We are pround to announce the availability of the RPostgreSQL package on CRAN
and its mirrors. This package provides an a DBI-compliant interface between
PostgreSQL and R.
RPostgreSQL was developed as part of the Google Summer of Code 2008 program
by Sameer Kumar Prayaga <sameer.bits@gmail.com>.
Some highlights:
o Initial support for prepared statement.
Known bugs/deficiencies:
o Arrays are not converted vector or other datastructure.
o Active issue list is at http://code.google.com/p/rpostgresql/issues/list
RPostgreSQL is hosted on Google Code, for more information see
http://rpostgresql.googlecode.com/
For any suggestions and queries, please contact:
rpostgresql-dev@googlegroups.com
For security issues that should not directly go to public,
you may contact:
Tomoaki Nishiyama <tomoakin@kenroku.kanazawa-u.ac.jp>
Neil Tiffin <neilt@neiltiffin.com>
Joe Conway <mail@joeconway.com>
Dirk Eddelbuettel <edd@debian.org>
Version 0.4 -- 2013-03-27
o Initial implementation of prepared statement
o Use system libpq library when available on OS X (darwin)
o Force ISO datestyle for PostgreSQL-R communication by default
o Time zone aware Timestamp POSIXct conversion
Version 0.3-3 -- 2012-10-05
o Bugfix on dbColumnInfo and others reproducible by gctorture(TRUE)
o Do not implicitly make new connections, which interfere with transaction.
o Change the notation of the LICENSE
Version 0.3-2 -- 2012-01-10
o Adapt to the new windows toolchain.
o Do not make libpq.dll on windows but just make libpq.a and link it,
so that libpq.dll need not copied anymore.
Version 0.3-1 -- 2011-12-31
o Remove GNU make dependency.
Version 0.3-0 -- 2011-12-29
o The bundled libpq source codes are used under darwin as well.
o More compatibility to other database drivers under DBI and sqldf.
dbBeginTransaction, safe.write, make.db.names are removed.
dbBuildTableDefinition is renamed to postgresqlBuildTableDefinition.
isIdCurrent is renamed to isPostgresqlIdCurrent.
row.names is now integer.
Version 0.2-1 -- 2011-11-16
o libpq source codes are bundled for Windows.
In other envirionment, this code is not used and existence of libpq as
specified by PG_HOME is still required.
Version 0.2-0 -- 2011-10-04
o Error check for dbWriteTable
o dbWriteTable does not write a temporary file.
Control characters in strings are properly escaped for dbWriteTable.
o Remove warning for enum and arrays etc. The value are still transferred
as string and not converted to arrays etc.
o use c('schema', 'table') to specify schema
o Integer is mapped to integer in postgresql rather than bigint.
Version 0.1-7 -- 2010-10-17
o Several potential buffer overruns were fixed
o dbWriteTable now writes a data.frame to database through a network
connection rather than a temporary file. Note that row_names may be
changed in future releases. Also, passing in filenames instead of
data.frame is not supported at this time.
o When no host is specified, a connection to the PostgreSQL server
is made via UNIX domain socket (just like psql does)
o Table and column names are case sensitive, and identifiers are escaped
or quoted appropriately, so that any form of table/column names can be
created, searched, or removed, including upper-, lower- and mixed-case.
o nullOk in dbColumnInfo has a return value of NA when the column does
not correspond to a column in the table. The utility of nullOk is
doubtful but not removed at this time.
o Correct Windows getpid() declaration (with thanks to Brian D. Ripley)
o A call of as.POSIXct() with a time format string wrongly passed to TZ
has been corrected; this should help with intra-day timestamps (with
thanks to Steve Eick)
o Usage of tmpdir has been improved on similarly to Linux (with thanks
to Robert McGehee)
Version 0.1-6 -- 2009-10-19
o Added missing paste() call to dbGetQuery() for dbListTables
Version 0.1-5 -- 2009-10-13
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 -- 2008-10-21
o First Release
o This 'RPostgreSQL' package was developed as a part of Google Summer of
Code 2008 program.
o Its implements all the features in the DBI (and a few extra like those
related to transaction management)
About the RPostgreSQL package:
Database Interface between R and PostgreSQL
For details, see the Adobe PDF file "DBI.pdf" in the doc folder or see the
documentation using help(PostgreSQL). Examples provided in the devTests
folder illustrate some of the functionality.
=============================================================================
Basic usage:
## initialize the driver to PostgreSQL
drv <- dbDriver("PostgreSQL")
## create a connection to a PostgreSQL server
con <- dbConnect(drv, user="userName", password="123456",
dbname="gsoc", host="10.23.34.23")
## run a query, and get the result set as a dataframe
dFrame <- dbGetQuery(con, "select * from someTable LIMIT 50")
## run a query, leave results in the library*
## note current implementation does not leave the result in the Server
## and there is no benefit using dbSendQuery() fetch() pair other than
## compatibility.
rs <- dbSendQuery(con, "select * from someTable")
## fetch up to, say, 50 records
dFrame <- fetch(rs, n = 50)
## close resultSet rs
dbClearResult(rs)
## close connection con
dbDisconnect(con)
## Unload the driver drv
dbUnloadDriver(drv)
For a more complete example, refer to the file demo.r in the devTests folder.
=============================================================================
Important Information:
1. The present version of RPostgreSQL can handle only one resultset per connection.
Thus dbSendQuery/fetch usually do not have speed merit over dbGetQuery.
=============================================================================
Frequently Asked Questions (FAQ):
1. What is Database Interface(DBI) ?
The Data Base Interface (DBI) provides a layer of abstraction between R
and relational databases. All the classes in the DBI package are virtual
and need to be implemented using the various DBMS libraries. The vendor
has written some functions for communicating with the database in some
language like C, compiled the functions and the compiled code is the
library. We write a C program that calls the functions in the library,
when it wants to access the database. Every database library is
different. The names of the functions vary, and the order in
which you call them varies, and the details of passing queries to the
functions and getting the data back out will vary. To manage this, DBI
was extended for individual database back-ends MySQL, SQLite, Oracle,
PostgreSQL via R packages ROracle, RMySQL, RSQLite and RPostgreSQL.
DBI for R-language was initially developed at Bell Labs by David James.
2. What is RPostgreSQL ?
The RPostgreSQL package provides a glue between the PostgreSQL database
and the DBI of R. The C programming interface called libpq was used for
communicating with PostgreSQL.
3 What is libpq ?
libpq is the C application programmer’s interface to PostgreSQL. libpq is
a cross platform library providing set of library functions that allow
client programs to pass queries to the PostgreSQL backend server and to
receive the results of these queries.