...
 
Commits (8)
2017-06-19 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
* new libpq from postgresql-9.6.3 and Makefiles generated on Sierra (macOS 10.12)
2014-02-08 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Update tests docs for CRAN submission.
A bug in postgresqlNewConnection() was identified and fixed during the
test rewrite.
* inst/ANNOUNCEMENT
* inst/NEWS
* man/dbConnect-methods.Rd: explanation of the parameters.
* R/PostgreSQLSupport.R: newConnection do not emit error on NULL
argument but convert to empty string which is a valid value.
* src/RS-PostgreSQL.c: RS_PostgreSQL_newConnection() don't checkk for
empty string.
* tests: Write more appropriate comments. Tell when the test is
skipped.
2014-02-06 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
* config.sub, config.guess, install-sh move to src subdirectory
* man/postgresqlBuildTableDefinition.Rd: Shorten usage line
* man/postgresqlSupport.Rd: Shorten usage line
2014-02-04 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
* ChangeLog
* inst/News
* src/libpq: update to libpq from postgresql-9.3.2
* configure.in: change the condition to use accompanied libpq
* configure
* tests/bytea.R: test both standard_conforming_strings states; add PASS response
2014-01-30 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Support hex conversion for unescaping.
Prevent segfault on unknown type to dbWriteTable.
Add minimal description of the escapebytea and unescapebytea.
* ChangeLog
* man/postgresqlSupport.Rd
* src/RS-PQescape.c
* src/RS-pgsql-copy.c
* R/PostgreSQLSupport.R: separate message body from heading
* tests/bytea.R: remove E prefix for postgresql version 9, though this
cause warning on 8.X.
* DESCRIPTION: forward the version to 0.5-1
* R/PostgreSQL.R: forward the version to 0.5-1
2014-01-29 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Initial support for Bytea data type.
* ChangeLog
* src/RS-PQescape.c
* R/PostgreSQLSupport.R
* NAMESPACE
* tests/bytea.R
2013-11-12 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Prepare for release
* inst/NEWS
* man/postgresqlBuildTableDefinition.Rd: line length
* man/postgresqlSupport.Rd: line length
2013-10-27 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Strange path support for OS X 10.9 Marvericks
* configure.in
* configure
* src/RS-PostgreSQL.c: keep declaration on the top of a block.
2013-08-22 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Memory leak detected by valgrind.
* src/RS-PostgreSQL.c
* src/RS-pgsql-copy.c
* src/RS-pgsql-getResult.c
* src/RS-pgsql-pqexec.c
* src/RS-pgsql-pqexecparams.c
2013-06-21 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
* postgresqlWriteTable: send column names at COPY;
* dbWriteTableTest.R: test for append=T
2013-06-12 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Close the socket on failure of opening connection
* src/RS-PostgreSQL.c
2013-03-27 Tomoaki NISHIYAMA <tomoakin@staff.kanazawa-u.ac.jp>
Document synchronization and testoutputs.
......
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
Version: 0.6-2
Date: 2017-06-24
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/ .
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 'macOS' and 'Microsoft Windows' system the attached 'libpq' library source will be used.
LazyLoad: true
Depends: R (>= 2.9.0), methods, DBI (>= 0.1-4)
Depends: R (>= 2.9.0), methods, DBI (>= 0.3)
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
URL: https://github.com/tomoakin/RPostgreSQL,
https://cran.r-project.org/package=DBI,
http://www.postgresql.org
NeedsCompilation: yes
Packaged: 2017-06-24 03:16:20 UTC; tomoaki
Repository: CRAN
Date/Publication: 2013-03-27 09:34:11
Date/Publication: 2017-06-24 07:17:52 UTC
This diff is collapsed.
import(methods)
import(DBI)
importFrom("utils", "count.fields", "read.table")
useDynLib(RPostgreSQL)
useDynLib(RPostgreSQL, .registration = TRUE)
## Classes
exportClasses(
......@@ -17,6 +18,7 @@ exportClasses(
exportMethods(
coerce,
dbApply,
dbBegin,
dbCallProc,
dbClearResult,
dbColumnInfo,
......@@ -86,6 +88,8 @@ export(
postgresqlReadTable,
postgresqlWriteTable,
postgresqlEscapeStrings,
postgresqlEscapeBytea,
postgresqlUnescapeBytea,
postgresqlDataType,
postgresqlQuoteId,
postgresqlTableRef
......
## PostgreSQL.R
## $Id: PostgreSQL.R 223 2011-12-29 11:31:45Z tomoakin@kenroku.kanazawa-u.ac.jp $
## $Id$
## 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.
......@@ -12,7 +12,7 @@
##.PostgreSQLRCS <- "$Id: PostgreSQL.R,v 0.1 2008/06/10 14:00:00$"
.PostgreSQLPkgName <- "RPostgreSQL"
.PostgreSQLVersion <- "0.3-0" ##package.description(.PostgreSQLPkgName, fields = "Version")
.PostgreSQLVersion <- "0.6-1" ##package.description(.PostgreSQLPkgName, fields = "Version")
.PostgreSQL.NA.string <- "\\N" ## on input, PostgreSQL interprets \N as NULL (NA)
setOldClass("data.frame") ## to appease setMethod's signature warnings...
......@@ -107,8 +107,7 @@ setMethod("dbGetException", "PostgreSQLConnection",
def = function(conn, ...){
if(!isPostgresqlIdCurrent(conn))
stop(paste("expired", class(conn)))
.Call("RS_PostgreSQL_getException", as(conn, "integer"),
PACKAGE = .PostgreSQLPkgName)
.Call(RS_PostgreSQL_getException, as(conn, "integer"))
},
valueClass = "list"
)
......@@ -200,6 +199,31 @@ setMethod("dbRemoveTable",
valueClass = "logical"
)
setMethod("dbBegin",
signature(conn="PostgreSQLConnection"),
def = function(conn, ...){
rc <- try(dbGetQuery(conn, "BEGIN"))
!inherits(rc, ErrorClass)
},
valueClass = "logical"
)
setMethod("dbCommit",
signature(conn="PostgreSQLConnection"),
def = function(conn, ...){
rc <- try(dbGetQuery(conn, "COMMIT"))
!inherits(rc, ErrorClass)
},
valueClass = "logical"
)
setMethod("dbRollback",
signature(conn="PostgreSQLConnection"),
def = function(conn, ...){
rc <- try(dbGetQuery(conn, "ROLLBACK"))
!inherits(rc, ErrorClass)
},
valueClass = "logical"
)
## return field names (no metadata)
setMethod("dbListFields",
signature(conn="PostgreSQLConnection", name="character"),
......@@ -337,7 +361,7 @@ setMethod("dbHasCompleted", "PostgreSQLResult",
setMethod("dbGetException", "PostgreSQLResult",
def = function(conn, ...){
id <- as(conn, "integer")[1:2]
.Call("RS_PostgreSQL_getException", id, PACKAGE = .PostgreSQLPkgName)
.Call(RS_PostgreSQL_getException, id)
},
valueClass = "list" ## TODO: should be a DBIException?
)
......
This diff is collapsed.
## R/S-Plus compatibility
## $Id: S4R.R 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
## $Id$
## 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.
......
## Class: dbObjectId
## $Id: dbObjectId.R 220 2011-12-03 12:50:46Z tomoakin@kenroku.kanazawa-u.ac.jp $
## $Id$
## 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.
......@@ -52,7 +52,7 @@ setMethod("print", "dbObjectId",
## verify that obj refers to a currently open/loaded database
isPostgresqlIdCurrent <- function(obj) {
obj <- as(obj, "integer")
.Call("RS_DBI_validHandle", obj, PACKAGE = .PostgreSQLPkgName)
.Call(RS_DBI_validHandle, obj)
}
## zzz.R
## $Id: zzz.R 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
## $Id$
## 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.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,7 +6,9 @@
# 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)
AC_INIT(RPostgreSQL, 0.5)
AC_CONFIG_AUX_DIR(src)
# Checks for common programs using default macros
AC_PROG_CC
......@@ -36,12 +38,12 @@ if test "${PG_CONFIG}" != ""; then
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 \
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include \
/usr/include/pgsql \
/usr/include/postgresql \
/usr/local/include \
......@@ -54,9 +56,6 @@ else
/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}.])
......@@ -67,7 +66,7 @@ else
fi
done
fi
# likewise, let's look around for libpq.so
if ! test $PG_LIBDIR
then
......@@ -85,9 +84,6 @@ else
/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}.])
......@@ -103,8 +99,11 @@ else
fi
done
fi
if ! test $PG_LIBDIR
if test $PG_LIBDIR && test $PG_INCDIR
then
echo $PG_LIBDIR
echo $PG_INCDIR
else
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
......@@ -118,7 +117,7 @@ all: $(SHLIB)
$(SHLIB): libpq/libpq.5.dylib
libpq/libpq.5.dylib:
(cd libpq; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -f Makefile.darwin)
(cd libpq; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -f Makefile.darwin pg_config.h pg_config_os.h all)
clean:
(cd libpq; $(MAKE) -f Makefile.darwin clean)
......@@ -128,8 +127,16 @@ clean:
fi
# Expand into arguments
# make sure we use the included libpq-fe.h if it was not previously found
if ! test $PG_INCDIR ; then
AC_MSG_NOTICE([Using internal package libpq-fe.h])
PG_INCDIR="src/libpq"
fi
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"],
,
......
r-cran-rpostgresql (0.4-2) UNRELEASED; urgency=medium
r-cran-rpostgresql (0.6-2-1) UNRELEASED; urgency=medium
* Team upload.
* New upstream version
* Take over package into r-pkg team maintenance
* Add watch file
* Canonical homepage for CRAN packages
* Convert from cdbs to dh-r
* Standards-Version: 4.1.3
* debhelper 11
-- Andreas Tille <tille@debian.org> Tue, 13 Mar 2018 19:30:28 +0100
......
Source: r-cran-rpostgresql
Section: gnu-r
Priority: optional
Maintainer: Debian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Uploaders: Ondřej Surý <ondrej@debian.org>
Build-Depends: autotools-dev,
cdbs,
debhelper (>= 9),
Section: gnu-r
Priority: optional
Build-Depends: debhelper (>= 11~),
dh-r,
r-base-dev,
r-cran-dbi
Standards-Version: 3.9.6
Standards-Version: 4.1.3
Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-rpostgresql
Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-rpostgresql.git
Homepage: https://code.google.com/p/rpostgresql/
Homepage: https://cran.r-project.org/package=RPostgreSQL
Package: r-cran-rpostgresql
Architecture: any
Depends: ${R:Depends},
${misc:Depends},
${misc:Depends},
${shlibs:Depends}
Recommends: ${R:Recommends}
Suggests: ${R:Suggests}
Description: GNU R package providing database interface and driver for PostgreSQL
This package provides a Database Interface (DBI) compliant driver
for R to access PostgreSQL database systems.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: r-cran-rpostgresql
Source: http://cran.r-project.org/web/packages/RPostgreSQL/index.html
Upstream-Contact: Tomoaki Nishiyama <tomoakin@staff.kanazawa-u.ac.jp>
Source: https://cran.r-project.org/package=RPostgreSQL
Files: *
Copyright: 2008-2013 Joe Conway
......
#!/usr/bin/make -f
include /usr/share/R/debian/r-cran.mk
%:
dh $@ --buildsystem R
version=4
https://cran.r-project.org/src/contrib/RPostgreSQL_([-\d.]*)\.tar\.gz
RPostgreSQL version 0.4
RPostgreSQL version 0.5
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
......@@ -10,7 +10,7 @@ by Sameer Kumar Prayaga <sameer.bits@gmail.com>.
Some highlights:
o Initial support for prepared statement.
o Binary data store in PostgreSQL bytea datatype.
Known bugs/deficiencies:
......@@ -18,13 +18,7 @@ Known bugs/deficiencies:
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
RPostgreSQL is hosted on Github https://github.com/tomoakin/RPostgreSQL
For security issues that should not directly go to public,
you may contact:
......
Version 0.6-2
o dbGetQuery do not return NULL.
o use registration mechanism to call native routines.
Version 0.5-3
o Update the libpq library so that the package can be compiled in new versions of R and macOS.
Version 0.5-2
o Support dbBegin() API
version 0.5-1 --2014-02-08
o Remove segmentationfault when NULL is passed as host argument.
o Conversion routine for raw in R and bytea in PostgreSQL
o Use accompanied libpq when either of libpq and header is not found on darwin
Version 0.5 -- 2013-10-12
o postgresqlWriteTable: send column names at COPY
o System library header search path for OS X 10.9 (Mavericks)
o Memory leak was reduced
o Close the socket on failure
Version 0.4 -- 2013-03-27
o Initial implementation of prepared statement
......
......@@ -16,3 +16,4 @@ Things yet to be completed:
5. Check the working of DBI extension "dbApply".
6. Binary data transfer to store IEEE754 floating point data without loss of precision.
......@@ -63,7 +63,7 @@ The most important parameters are \code{user}, \code{password},
}
\author{David A. James}
\section{References}{
See \url{stat.bell-labs.com/RS-DBI}
See \url{https://cran.r-project.org/package=DBI}
for more details on the R/S-Plus database interface.
See the documentation at the PostgreSQL Web site
......
......@@ -16,6 +16,7 @@ Class \code{"dbObjectId"}, by class "PostgreSQLObject".
\section{Methods}{
\describe{
\item{\link{coerce}}{\code{signature(from = "PostgreSQLConnection", to = "PostgreSQLResult")}: ... }
\item{\link[DBI]{dbBegin}}{\code{signature(conn = "PostgreSQLConnection")}: ... }
\item{\link[DBI]{dbCallProc}}{\code{signature(conn = "PostgreSQLConnection")}: ... }
\item{\link[DBI]{dbCommit}}{\code{signature(conn = "PostgreSQLConnection")}: ... }
\item{\link[DBI]{dbConnect}}{\code{signature(drv = "PostgreSQLConnection")}: ... }
......
......@@ -18,7 +18,7 @@
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or
\url{http://stat.bell-labs.com/RS-DBI}.
\url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}}
......
......@@ -21,7 +21,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
% $Id: dbCommit-methods.Rd,v 0.1 2008/08/10 18:04:01 psk Exp $
\name{dbCommit-methods}
\docType{methods}
\alias{dbCommit-methods}
\alias{dbRollback-methods}
\alias{dbBegin-method}
\alias{dbCommit-method}
\alias{dbRollback-method}
\alias{PostgreSQLConnection-method}
\alias{dbBegin,PostgreSQLConnection-method}
\alias{dbCommit,PostgreSQLConnection-method}
\alias{dbRollback,PostgreSQLConnection-method}
\title{
DBMS Transaction Management
}
\description{
Commits or roll backs the current transaction
Transaction related commands.
Start a transaction, commit or roll back the current transaction
in an PostgreSQL connection.
\code{dbBegin} starts a transaction.
\code{dbCommit} and \code{dbRollback} commit and rollback the
transaction, respectively.
......@@ -26,10 +30,11 @@
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or
\url{http://stat.bell-labs.com/RS-DBI}.
\url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
\code{\link[DBI]{dbBegin}},
\code{\link[DBI]{dbConnect}},
\code{\link[DBI]{dbSendQuery}},
\code{\link[DBI]{dbGetQuery}},
......@@ -43,7 +48,7 @@ drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="postgres")
dbGetQuery(con, "select count(*) from sales")
dbGetQuery(con, "BEGIN TRANSACTION")
dbBegin(con)
rs <- dbSendQuery(con,
"Delete * from sales as p where p.cost>10")
if(dbGetInfo(rs, what = "rowsAffected") > 250){
......
......@@ -22,19 +22,19 @@
\item{conn}{
an \code{PostgreSQLConnection} object as produced by \code{dbConnect}.
}
\item{host}{Name or the numeric IPaddress of the host to connect to. If address is specified, it should be in the standard IPv4 address format, e.g., 172.28.40.9 or if your machine supports IPv6, you can also use those addresses. The default is to connect to localhost.
\item{host}{Name or the numeric IPaddress of the host to connect to. If address is specified, it should be in the standard IPv4 address format, e.g., 172.28.40.9 or if your machine supports IPv6, you can also use those addresses. The default is to connect to localhost by a UNIX domain socket.
}
\item{dbname}{The database name. Defaults to 'template1' i.e if this argument is not specified, it is taken as dbname="template1".
\item{dbname}{The database name. Defaults to "", which is interpreted as PostgreSQL default.
}
\item{user}{PostgreSQL user name to connect as. Defaults to be the same as the operating system name of the user running the application.
}
\item{password}{Password to be used if the server demands password authentication.
}
\item{port}{Port number to connect to at the server host, or socket file name extension for Unix-domain connections.
\item{port}{Port number to connect to at the server host.
}
\item{tty}{Ignored (formerly, this specified where to send server debug output).
}
\item{options}{Command-line options to be sent to the server
\item{options}{Command-line options to be sent to the server.
}
\item{forceISOdate}{logical if the communication of date (time stamp) from PostgreSQL is forced to ISO style at conection.
}
......@@ -48,7 +48,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -27,7 +27,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link[DBI]{isSQLKeyword}}
......
......@@ -34,7 +34,7 @@ the size of the connection table. Default is \code{FALSE}.}
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or
\url{http://stat.bell-labs.com/RS-DBI}.
\url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -36,7 +36,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -28,7 +28,7 @@
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or
\url{http://stat.bell-labs.com/RS-DBI}.
\url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -112,7 +112,7 @@ the backend raw_names may change in future versions.
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -31,7 +31,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -25,7 +25,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -35,7 +35,7 @@
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -61,7 +61,7 @@
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -7,7 +7,8 @@
input data.frame
}
\usage{
postgresqlBuildTableDefinition(dbObj, name, obj, field.types = NULL, row.names = TRUE, ...)
postgresqlBuildTableDefinition(dbObj, name, obj,
field.types = NULL, row.names = TRUE, ...)
}
\arguments{
\item{dbObj}{any DBI object (used only to dispatch according to the
......@@ -31,7 +32,7 @@ postgresqlBuildTableDefinition(dbObj, name, obj, field.types = NULL, row.names =
\references{
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://stat.bell-labs.com/RS-DBI}.
or \url{https://cran.r-project.org/package=DBI}.
}
\seealso{
\code{\link{PostgreSQL}},
......
......@@ -23,6 +23,8 @@
\alias{postgresqlCopyInDataframe}
\alias{postgresqlgetResult}
\alias{postgresqlEscapeStrings}
\alias{postgresqlEscapeBytea}
\alias{postgresqlUnescapeBytea}
\alias{postgresqlQuoteId}
\alias{postgresqlTableRef}
\alias{postgresqlImportFile}
......@@ -48,7 +50,8 @@
postgresqlCloseDriver(drv, ...)
## PostgreSQLConnection-related
postgresqlNewConnection(drv, user, password, host, dbname, port, tty, options, forceISOdate = TRUE)
postgresqlNewConnection(drv, user, password, host, dbname, port,
tty, options, forceISOdate = TRUE)
postgresqlCloneConnection(con, ...)
postgresqlConnectionInfo(obj, what, ...)
postgresqlDescribeConnection(obj, verbose = FALSE, ...)
......@@ -72,6 +75,8 @@
postgresqlCopyIn(con, filename)
postgresqlgetResult(con)
postgresqlEscapeStrings(con, preescapedstring)
postgresqlEscapeBytea(con, raw_data)
postgresqlUnescapeBytea(escapedbytea)
postgresqlQuoteId(identifiers)
postgresqlTableRef(identifiers)
postgresqlImportFile(con, name, value, field.types, overwrite=FALSE,
......@@ -213,6 +218,8 @@ Command-line options to be sent to the server
to modify column names to make them legal PostgreSQL identifiers.
}
\item{preescapedstring}{character string to be escaped}
\item{raw_data}{RAW data to be escaped}
\item{escapedbytea}{'escaped' or hex encoded binary data as character}
\item{identifiers}{one or more character strings to be used as identfier in SQL statement}
\item{filename}{character string indicating the file which contains the data to be copied to the PostgreSQL backend}
\item{\dots}{
......@@ -288,6 +295,16 @@ Command-line options to be sent to the server
so that it can be surrounded with a single quote and used as literal in SQL.
The escape procedure is dependent on the character encoding of the connection.
\code{postgresqlEscapeBytea} returns a character string which represents the
raw data proper escape so that it can be surrounded
with a single quote and used as literal in SQL. Note that on 8.X connection E prefix
should exist before the first quote. However this changes the behaviour in 9.0, where
the E should not exist.
\code{postgresqlUnescapeBytea} returns a raw data specified by the character string.
The character string should contain the 'escaped' bytea or hex encoded bytea
that was output from the database server.
\code{postgresqlQuoteId} returns a character string which is quoted as identifier. Returns vector on vector arguemnt.
\code{postgresqlTableRef} returns a character string which is quoted as identifier.
......
/*
* RS-DBI.c
*
* $Id: RS-DBI.c 245 2012-12-19 13:06:53Z tomoakin@kenroku.kanazawa-u.ac.jp $
* $Id$
*
* 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.
......
......@@ -4,7 +4,7 @@
/*
* RS-DBI.h
*
* $Id: RS-DBI.h 227 2012-02-27 09:58:29Z tomoakin@kenroku.kanazawa-u.ac.jp $
* $Id$
*
* 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.
......
/*
* RS-PQescape.c
*
* $Id: RS-PQescape.c 212 2011-11-22 10:58:50Z tomoakin@kenroku.kanazawa-u.ac.jp $
* $Id$
*/
#include "RS-PostgreSQL.h"
/*
* Adapter function to PQescapeStringConn()
* This function should properly escape the string argument
......@@ -14,7 +13,6 @@
* connection.
* Note the single quote is not attached in the return val.
*/
SEXP
RS_PostgreSQL_escape(SEXP conHandle, SEXP preescapestring)
{
......@@ -30,8 +28,85 @@ RS_PostgreSQL_escape(SEXP conHandle, SEXP preescapestring)
length = strlen(statement_cstr);
escapedstring = R_alloc(length * 2 + 1, 1);
PQescapeStringConn(my_connection, escapedstring, statement_cstr, length, NULL);
output = allocVector(STRSXP, 1);
PROTECT(output = allocVector(STRSXP, 1));
SET_STRING_ELT(output, 0, mkChar(escapedstring));
UNPROTECT(1);
return output;
}
/*
* Adapter function to PQescapeByteaConn()
* This function should properly escape the raw argument
* appropriately depending on connection.
* Note the single quote is not attached in the return val.
* The returned string could differ depending on the environment.
* Especially standard_conforming_strings parameter
* is possibly influencial.
* http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
*/
SEXP
RS_PostgreSQL_escape_bytea(SEXP conHandle, SEXP raw_data)
{
S_EVALUATOR PGconn * my_connection;
RS_DBI_connection *con;
SEXP output;
size_t length;
char *escapedstring;
size_t escaped_length;
con = RS_DBI_getConnection(conHandle);
my_connection = (PGconn *) con->drvConnection;
length = LENGTH(raw_data);
escapedstring = (char *)PQescapeByteaConn(my_connection, RAW(raw_data), length, &escaped_length);
/* explicit cast to make clang silent for difference in signedness*/
PROTECT(output = allocVector(STRSXP, 1));
SET_STRING_ELT(output, 0, mkChar(escapedstring));
free(escapedstring);
UNPROTECT(1);
return output;
}
static inline unsigned char
hex2n(unsigned char h)
{
if (h >= '0' && h <= '9') return h-'0';
if (h >= 'a' && h <= 'f') return h-'a' + 10;
if (h >= 'A' && h <= 'F') return h-'A' + 10;
return h;
}
/*
* Adapter function to PQunescapeBytea()
* This function should properly unescape the charactor representation
* of the binary data returned from PostgreSQL and return raw binary data.
*/
SEXP
RS_PostgreSQL_unescape_bytea(SEXP escapedstring)
{
SEXP output;
size_t raw_length;
const char* strbuffer;
unsigned char* rawbuffer;
strbuffer = CHAR(STRING_ELT(escapedstring, 0));
if(!strbuffer) RS_DBI_errorMessage("strbuffer is NULL!", RS_DBI_ERROR);
if (strbuffer[0] == '\\' && strbuffer[1] == 'x'){
/* the new hex fomat */
int i;
size_t enc_length = LENGTH(STRING_ELT(escapedstring, 0));
raw_length = enc_length / 2 - 1;
output = allocVector(RAWSXP, raw_length);
rawbuffer = RAW(output);
for(i = 0; i < raw_length; i++){
rawbuffer[i] = (hex2n(strbuffer[2+ i*2]) << 4) + hex2n(strbuffer[2+i*2+1]);
}
return output;
}else{ /* the old escape format */
rawbuffer = PQunescapeBytea((const unsigned char*) strbuffer, &raw_length);
/* explicit cast to suppress warning on signedness by clang */
if(!rawbuffer) RS_DBI_errorMessage("PQunescapeByea Failed", RS_DBI_ERROR);
output = allocVector(RAWSXP, raw_length);
memcpy(RAW(output), rawbuffer, raw_length);
free(rawbuffer);
return output;
}
}
This diff is collapsed.
......@@ -4,7 +4,7 @@
/*
* RS-PostgreSQL.h
*
* $Id: RS-PostgreSQL.h 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
* $Id$
*
* 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.
......@@ -22,6 +22,7 @@ extern "C" {
# include "libpq-fe.h"
# include <string.h>
# include <R_ext/Rdynload.h>
# include "RS-DBI.h"
/* Note that the default number of maximum connections to the PostgreSQL server is typically 100
......@@ -71,6 +72,22 @@ extern "C" {
s_object *RS_PostgreSQL_closeResultSet(Res_Handle * rsHandle);
s_object *RS_PostgreSQL_copyin(Con_Handle * conHandle, s_object * filename);
s_object *RS_PostgreSQL_CopyIn(Con_Handle * conHandle, s_object * filename);
SEXP RS_PostgreSQL_CopyInDataframe(Con_Handle * conHandle, SEXP x, SEXP nrow, SEXP ncol);
s_object * RS_PostgreSQL_dbApply(s_object * rsHandle, s_object * s_group_field, s_object * s_funs, s_object * rho, s_object * s_batch_size, s_object * s_max_rec);
SEXP RS_PostgreSQL_escape(SEXP conHandle, SEXP preescapestring);
SEXP RS_PostgreSQL_escape_bytea(SEXP conHandle, SEXP raw_data);
SEXP RS_PostgreSQL_unescape_bytea(SEXP escapedstring);
s_object * RS_PostgreSQL_getResult(Con_Handle * conHandle);
SEXP RS_PostgreSQL_pqexec(Con_Handle * conHandle, s_object * statement);
SEXP RS_PostgreSQL_pqexecparams(SEXP args);
s_object *RS_PostgreSQL_validHandle(Db_Handle * handle); /* boolean */
......
/*
* RS-pgsql-copy.c
*
* $Id: RS-pgsql-copy.c 212 2011-11-22 10:58:50Z tomoakin@kenroku.kanazawa-u.ac.jp $
* $Id$
*/
#include "RS-PostgreSQL.h"
......@@ -133,10 +133,26 @@ static Rboolean isna(SEXP x, int indx)
/* a version of EncodeElement with different escaping of char strings */
static const char
*EncodeElementS(SEXP x, int indx,
*EncodeElementSconn(PGconn* my_connection, SEXP x, int indx,
R_StringBuffer *buff, char cdec)
{
buff->data[0]='\0';
switch(TYPEOF(x)) {
case RAWSXP:{
const unsigned char*rawdata;
unsigned char* escapedstring;
int len;
size_t escaped_length;
len = LENGTH(x);
rawdata=RAW(x);
escapedstring = PQescapeByteaConn(my_connection, rawdata, len, &escaped_length);
memcpy(buff->data, escapedstring, escaped_length);
buff->data[escaped_length]='\0';
free(escapedstring);
return buff->data;
}
case STRSXP:
{
const char *s = translateCharUTF8(STRING_ELT(x, indx));
......@@ -211,9 +227,9 @@ static const char
return buff->data;
}
default:
return NULL;
return buff->data;
}
return NULL;
return buff->data;
}
static inline void
......@@ -224,13 +240,9 @@ chkpqcopydataerr(PGconn *my_connection, int pqretcode)
char * rserrmsg;
char * format = "PQputCopyData failed: %s";
size_t len = strlen(pqerrmsg) + strlen(format) + 1;
rserrmsg = malloc(len);
if(rserrmsg){
snprintf(rserrmsg, len, format, pqerrmsg);
RS_DBI_errorMessage(rserrmsg, RS_DBI_ERROR);
}else{
RS_DBI_errorMessage("malloc failed while reporting error in PQputCopyData", RS_DBI_ERROR);
}
rserrmsg = R_alloc(len, 1);
snprintf(rserrmsg, len, format, pqerrmsg);
RS_DBI_errorMessage(rserrmsg, RS_DBI_ERROR);
}
}
......@@ -284,15 +296,15 @@ RS_PostgreSQL_CopyInDataframe(Con_Handle * conHandle, SEXP x, SEXP nrow, SEXP nc
if(!isNull(levels[j])) {
/* We cannot assume factors have integer levels */
if(TYPEOF(xj) == INTSXP){
tmp = EncodeElementS(levels[j], INTEGER(xj)[i] - 1,
tmp = EncodeElementSconn(my_connection, levels[j], INTEGER(xj)[i] - 1,
&rstrbuf, cdec);
}else if(TYPEOF(xj) == REALSXP){
tmp = EncodeElementS(levels[j], REAL(xj)[i] - 1,
tmp = EncodeElementSconn(my_connection, levels[j], REAL(xj)[i] - 1,
&rstrbuf, cdec);
}else
error("column %s claims to be a factor but does not have numeric codes", j+1);
} else {
tmp = EncodeElementS(xj, i,
tmp = EncodeElementSconn(my_connection, xj, i,
&rstrbuf, cdec);
}
}
......
/*
* RS-pgsql-copy.c
*
* $Id: RS-pgsql-getResult.c 237 2012-10-04 14:54:29Z tomoakin@kenroku.kanazawa-u.ac.jp $
* $Id$
*/
#include "RS-PostgreSQL.h"
......@@ -65,22 +65,19 @@ RS_PostgreSQL_getResult(Con_Handle * conHandle)
size_t len;
omsg = PQerrorMessage(my_connection);
len = strlen(omsg);
errResultMsg = malloc(len + 80); /* 80 should be larger than the length of "could not ..."*/
errResultMsg = R_alloc(len + 80, 1); /* 80 should be larger than the length of "could not ..."*/
snprintf(errResultMsg, len + 80, "could not Retrieve the result : %s", omsg);
PQclear(my_result);
my_result = NULL;
RS_DBI_errorMessage(errResultMsg, RS_DBI_ERROR);
free(errResultMsg);
/* Frees the storage associated with a PGresult.
* void PQclear(PGresult *res); */
PQclear(my_result);
}
PQclear(my_result);
/* we now create the wrapper and copy values */
PROTECT(rsHandle = RS_DBI_allocResultSet(conHandle));
result = RS_DBI_getResultSet(rsHandle);
result->drvResultSet = (void *) my_result;
result->drvResultSet = (void *) NULL;
result->rowCount = (Sint) 0;
result->isSelect = 0;
result->rowsAffected = 0;
......
/*
* RS-PostgreSQL.c
*
* $Id: RS-pgsql-pqexec.c 190 2011-10-01 14:27:35Z dirk.eddelbuettel $
* $Id$
*
* 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.
......@@ -64,10 +64,9 @@ RS_PostgreSQL_pqexec(Con_Handle * conHandle, s_object * statement)
omsg = PQerrorMessage(my_connection);
len = strlen(omsg);
free(dyn_statement);
errMsg = malloc(len + 80); /* 80 should be larger than the length of "could not ..."*/
errMsg = R_alloc(len + 80, 1); /* 80 should be larger than the length of "could not ..."*/
snprintf(errMsg, len + 80, "could not run statement: %s", omsg);
RS_DBI_errorMessage(errMsg, RS_DBI_ERROR);
free(errMsg);
}
......@@ -79,23 +78,20 @@ RS_PostgreSQL_pqexec(Con_Handle * conHandle, s_object * statement)
}
if (strcmp(PQresultErrorMessage(my_result), "") != 0) {
free(dyn_statement);
char *errResultMsg;
const char *omsg;
size_t len;
omsg = PQerrorMessage(my_connection);
len = strlen(omsg);
errResultMsg = malloc(len + 80); /* 80 should be larger than the length of "could not ..."*/
errResultMsg = R_alloc(len + 80, 1); /* 80 should be larger than the length of "could not ..."*/
snprintf(errResultMsg, len + 80, "could not Retrieve the result : %s", omsg);
RS_DBI_errorMessage(errResultMsg, RS_DBI_ERROR);
free(errResultMsg);
/* Frees the storage associated with a PGresult.
* void PQclear(PGresult *res); */
PQclear(my_result);
RS_DBI_errorMessage(errResultMsg, RS_DBI_ERROR);
}
/* Frees the storage associated with a PGresult.*/
PQclear(my_result);
free(dyn_statement);
PROTECT(retval = allocVector(LGLSXP, 1));
LOGICAL(retval)[0] = is_select;
......
......@@ -40,7 +40,7 @@ RS_PostgreSQL_pqexecparams(SEXP args)
my_connection = (PGconn *) con->drvConnection;
dyn_statement = CHR_EL(statement, 0);
nparams = length(params);
pqparams = calloc(nparams, sizeof(char*));
pqparams = Calloc(nparams, const char*);
for (R_len_t i = 0; i < nparams; i++){
pqparams[i] = CHR_EL(params, i);
......@@ -57,16 +57,16 @@ RS_PostgreSQL_pqexecparams(SEXP args)
* int resultFormat);
*/
my_result = PQexecParams(my_connection, dyn_statement, nparams, NULL, pqparams, NULL, NULL, 0);
Free(pqparams);
if (my_result == NULL) {
char *errMsg;
const char *omsg;
size_t len;
omsg = PQerrorMessage(my_connection);
len = strlen(omsg);
errMsg = malloc(len + 80); /* 80 should be larger than the length of "could not ..."*/
errMsg = R_alloc(len + 80, 1); /* 80 should be larger than the length of "could not ..."*/
snprintf(errMsg, len + 80, "could not run statement: %s", omsg);
RS_DBI_errorMessage(errMsg, RS_DBI_ERROR);
free(errMsg);
}
......@@ -84,14 +84,12 @@ RS_PostgreSQL_pqexecparams(SEXP args)
size_t len;
omsg = PQerrorMessage(my_connection);
len = strlen(omsg);
errResultMsg = malloc(len + 80); /* 80 should be larger than the length of "could not ..."*/
errResultMsg = R_alloc(len + 80, 1); /* 80 should be larger than the length of "could not ..."*/
snprintf(errResultMsg, len + 80, "could not Retrieve the result : %s", omsg);
RS_DBI_errorMessage(errResultMsg, RS_DBI_ERROR);
free(errResultMsg);
/* Frees the storage associated with a PGresult.
* void PQclear(PGresult *res); */
PQclear(my_result);
RS_DBI_errorMessage(errResultMsg, RS_DBI_ERROR);
}
/* we now create the wrapper and copy values */
......@@ -103,8 +101,8 @@ RS_PostgreSQL_pqexecparams(SEXP args)
result->isSelect = is_select;
/* Returns the number of rows affected by the SQL command.
* * char *PQcmdTuples(PGresult *res);
* */
* char *PQcmdTuples(PGresult *res);
*/
if (!is_select) {
result->rowsAffected = (Sint) atoi(PQcmdTuples(my_result));
......
/* $Id: S4R.h 189 2011-10-01 13:16:39Z dirk.eddelbuettel $
/* $Id$
*
* S4 (Splus5+) and R portability macros.
*
......
......@@ -2,30 +2,30 @@
#
# Makefile for src/interfaces/libpq library
#
# Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
# Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# src/interfaces/libpq/Makefile
#
#-------------------------------------------------------------------------
subdir = ./libpq
top_builddir = ..
include Makefile.global.darwin
all: pg_config.h pg_config_os.h
all: pg_config.h pg_config_os.h all-lib
pg_config.h: pg_config.h.darwin
cp pg_config.h.darwin pg_config.h
pg_config_os.h: pg_config_os.h.darwin
cp pg_config_os.h.darwin pg_config_os.h
pg_config_paths.h: pg_config_paths.h.darwin
cp pg_config_paths.h.darwin pg_config_paths.h
# shared library parameters
NAME= pq
SO_MAJOR_VERSION= 5
SO_MINOR_VERSION= 4
SO_MINOR_VERSION= 9
override CPPFLAGS := -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS)
override CPPFLAGS := -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I.
ifneq ($(PORTNAME), win32)
override CFLAGS += $(PTHREAD_CFLAGS)
endif
......@@ -38,17 +38,22 @@ LIBS := $(LIBS:-lpgport=)
# We can't use Makefile variables here because the MSVC build system scrapes
# OBJS from this file.
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o fe-secure.o \
libpq-events.o
# libpgport C files we always use
OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o thread.o
OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o pqsignal.o \
thread.o
# libpgport C files that are needed if identified by configure
OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o win32setlocale.o, $(LIBOBJS))
OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o system.o snprintf.o strerror.o strlcpy.o win32error.o win32setlocale.o, $(LIBOBJS))
# backend/libpq
OBJS += ip.o md5.o
# utils/mb
OBJS += encnames.o wchar.o
ifeq ($(with_openssl),yes)
OBJS += fe-secure-openssl.o
endif
ifeq ($(PORTNAME), cygwin)
override shlib = cyg$(NAME)$(DLSUFFIX)
endif
......@@ -75,15 +80,33 @@ else
SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
endif
ifeq ($(PORTNAME), win32)
SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
SHLIB_LINK += -lshell32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
endif
SHLIB_EXPORTS = exports.txt
all: all-lib
# Shared library stuff
include Makefile.shlib
include Makefile.shlib.darwin
backend_src = $(top_srcdir)/src/backend
# We use several libpgport and backend modules verbatim, but since we need
# to compile with appropriate options to build a shared lib, we can't
# necessarily use the same object files built for libpgport and the backend.
# Instead, symlink the source files in here and build our own object files.
# For some libpgport modules, this only happens if configure decides
# the module is needed (see filter hack in OBJS, above).
chklocale.c crypt.c getaddrinfo.c getpeereid.c inet_aton.c inet_net_ntop.c noblock.c open.c system.c pgsleep.c pgstrcasecmp.c pqsignal.c snprintf.c strerror.c strlcpy.c thread.c win32error.c win32setlocale.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
ip.c md5.c: % : $(backend_src)/libpq/%
rm -f $@ && $(LN_S) $< .
encnames.c wchar.c: % : $(backend_src)/utils/mb/%
rm -f $@ && $(LN_S) $< .
distprep: libpq-dist.rc
......@@ -93,9 +116,13 @@ libpq.rc libpq-dist.rc: libpq.rc.in
# Depend on Makefile.global to force rebuild on re-run of configure.
# (But libpq-dist.rc is shipped in the distribution for shell-less
# installations and is only updated by distprep.)
libpq.rc: Makefile.global.darwin
fe-connect.o: fe-connect.c pg_config_paths.h
fe-connect.o: fe-connect.c $(top_builddir)/$(subdir)/pg_config_paths.h
fe-misc.o: fe-misc.c $(top_builddir)/$(subdir)/pg_config_paths.h
#$(top_builddir)/src/port/pg_config_paths.h:
# $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
install: all installdirs install-lib
$(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
......@@ -104,8 +131,11 @@ install: all installdirs install-lib
$(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
installcheck:
$(MAKE) -C test $@
installdirs: installdirs-lib
$(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)'
$(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)' '$(DESTDIR)$(datadir)'
uninstall: uninstall-lib
rm -f '$(DESTDIR)$(includedir)/libpq-fe.h'
......@@ -115,12 +145,16 @@ uninstall: uninstall-lib
rm -f '$(DESTDIR)$(datadir)/pg_service.conf.sample'
clean distclean: clean-lib
$(MAKE) -C test $@
rm -f $(OBJS) pthread.h libpq.rc
rm -f libpq.dylib libpq.$(SO_MAJOR_VERSION).dylib libpq.$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).dylib
# Might be left over from a Win32 client-only build
rm -f pg_config.h
rm -f pg_config_os.h
rm -f pg_config_paths.h
rm -f inet_net_ntop.c noblock.c pgstrcasecmp.c pqsignal.c thread.c
rm -f chklocale.c crypt.c getaddrinfo.c getpeereid.c inet_aton.c open.c system.c snprintf.c strerror.c strlcpy.c win32error.c win32setlocale.c
rm -f pgsleep.c
rm -f md5.c ip.c
rm -f encnames.c wchar.c
maintainer-clean: distclean maintainer-clean-lib
$(MAKE) -C test $@
rm -f libpq-dist.rc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,14 +2,15 @@
#
# Makefile for src/interfaces/libpq library
#
# Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
# Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# src/interfaces/libpq/Makefile
#
#-------------------------------------------------------------------------
subdir = src/interfaces/libpq
subdir = src/libpq
top_builddir = ..
ifeq "$(WIN)" "64"
......@@ -18,22 +19,25 @@ else
include Makefile.global.win32
endif
all: pg_config.h pg_config_os.h
include $(R_HOME)/etc/$(R_ARCH)/Makeconf
WINDRES=$(RESCOMP)
all: libpq.a
pg_config.h: pg_config.h.win
cp pg_config.h.win pg_config.h
pg_config_ext.h: pg_config_ext.h.win32
cp pg_config_ext.h.win32 pg_config_ext.h
pg_config_os.h: pg_config_os.h.win
cp pg_config_os.h.win pg_config_os.h
pg_config_paths.h: pg_config_paths.h.win
cp pg_config_paths.h.win pg_config_paths.h
# shared library parameters