freeside/install/5.005/DBD-Pg-1.22-fixvercmp Changes,NONE,1.1 MANIFEST,NONE,1.1 Makefile.PL,NONE,1.1 Pg.h,NONE,1.1 Pg.pm,NONE,1.1 Pg.xs,NONE,1.1 README,NONE,1.1 README.win32,NONE,1.1 dbd-pg.pod,NONE,1.1 dbdimp.c,NONE,1.1 dbdimp.h,NONE,1.1
ivan
ivan at pouncequick.420.am
Thu Apr 29 02:21:34 PDT 2004
- Previous message: freeside/install/5.005/DBD-Pg-1.22-fixvercmp/t 00basic.t,NONE,1.1 01connect.t,NONE,1.1 01constants.t,NONE,1.1 01setup.t,NONE,1.1 02prepare.t,NONE,1.1 03bind.t,NONE,1.1 04execute.t,NONE,1.1 05fetch.t,NONE,1.1 06disconnect.t,NONE,1.1 07reuse.t,NONE,1.1 08txn.t,NONE,1.1 09autocommit.t,NONE,1.1 11quoting.t,NONE,1.1 12placeholders.t,NONE,1.1 13pgtype.t,NONE,1.1 15funct.t,NONE,1.1 99cleanup.t,NONE,1.1
- Next message: freeside/install/5.005/DBD-Pg-1.22-fixvercmp/t/lib/App/Info/RDBMS PostgreSQL.pm,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/install/5.005/DBD-Pg-1.22-fixvercmp
In directory pouncequick:/tmp/cvs-serv10700/DBD-Pg-1.22-fixvercmp
Added Files:
Changes MANIFEST Makefile.PL Pg.h Pg.pm Pg.xs README
README.win32 dbd-pg.pod dbdimp.c dbdimp.h
Log Message:
adding DBD::Pg and DBIx::DBSchema for 5.005. argh freebsd and solaris!
--- NEW FILE: Pg.xs ---
/*
$Id: Pg.xs,v 1.1 2004/04/29 09:21:28 ivan Exp $
Copyright (c) 1997,1998,1999,2000 Edmund Mergl
Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
*/
#include "Pg.h"
#ifdef _MSC_VER
#define strncasecmp(a,b,c) _strnicmp((a),(b),(c))
#endif
DBISTATE_DECLARE;
MODULE = DBD::Pg PACKAGE = DBD::Pg
I32
constant(name=Nullch)
char *name
PROTOTYPE:
ALIAS:
PG_BOOL = 16
PG_BYTEA = 17
PG_CHAR = 18
PG_INT8 = 20
PG_INT2 = 21
PG_INT4 = 23
PG_TEXT = 25
PG_OID = 26
PG_FLOAT4 = 700
PG_FLOAT8 = 701
PG_ABSTIME = 702
PG_RELTIME = 703
PG_TINTERVAL = 704
PG_BPCHAR = 1042
PG_VARCHAR = 1043
PG_DATE = 1082
PG_TIME = 1083
PG_DATETIME = 1184
PG_TIMESPAN = 1186
PG_TIMESTAMP = 1296
CODE:
if (!ix) {
if (!name) name = GvNAME(CvGV(cv));
croak("Unknown DBD::Pg constant '%s'", name);
}
else RETVAL = ix;
OUTPUT:
RETVAL
PROTOTYPES: DISABLE
BOOT:
items = 0; /* avoid 'unused variable' warning */
DBISTATE_INIT;
/* XXX this interface will change: */
DBI_IMP_SIZE("DBD::Pg::dr::imp_data_size", sizeof(imp_drh_t));
DBI_IMP_SIZE("DBD::Pg::db::imp_data_size", sizeof(imp_dbh_t));
DBI_IMP_SIZE("DBD::Pg::st::imp_data_size", sizeof(imp_sth_t));
dbd_init(DBIS);
# ------------------------------------------------------------
# driver level interface
# ------------------------------------------------------------
MODULE = DBD::Pg PACKAGE = DBD::Pg::dr
# disconnect_all renamed and ALIASed to avoid length clash on VMS :-(
void
discon_all_(drh)
SV * drh
ALIAS:
disconnect_all = 1
CODE:
D_imp_drh(drh);
ST(0) = dbd_discon_all(drh, imp_drh) ? &sv_yes : &sv_no;
# ------------------------------------------------------------
# database level interface
# ------------------------------------------------------------
MODULE = DBD::Pg PACKAGE = DBD::Pg::db
void
_login(dbh, dbname, username, pwd)
SV * dbh
char * dbname
char * username
char * pwd
CODE:
D_imp_dbh(dbh);
ST(0) = pg_db_login(dbh, imp_dbh, dbname, username, pwd) ? &sv_yes : &sv_no;
int
_ping(dbh)
SV * dbh
CODE:
int ret;
ret = dbd_db_ping(dbh);
if (ret == 0) {
XST_mUNDEF(0);
}
else {
XST_mIV(0, ret);
}
void
getfd(dbh)
SV * dbh
CODE:
int ret;
D_imp_dbh(dbh);
ret = dbd_db_getfd(dbh, imp_dbh);
ST(0) = sv_2mortal( newSViv( ret ) );
void
pg_notifies(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
ST(0) = dbd_db_pg_notifies(dbh, imp_dbh);
void
commit(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh, DBIcf_AutoCommit)) {
warn("commit ineffective with AutoCommit enabled");
}
ST(0) = dbd_db_commit(dbh, imp_dbh) ? &sv_yes : &sv_no;
void
rollback(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh, DBIcf_AutoCommit)) {
warn("rollback ineffective with AutoCommit enabled");
}
ST(0) = dbd_db_rollback(dbh, imp_dbh) ? &sv_yes : &sv_no;
void
disconnect(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if ( !DBIc_ACTIVE(imp_dbh) ) {
XSRETURN_YES;
}
/* pre-disconnect checks and tidy-ups */
if (DBIc_CACHED_KIDS(imp_dbh)) {
SvREFCNT_dec(DBIc_CACHED_KIDS(imp_dbh));
DBIc_CACHED_KIDS(imp_dbh) = Nullhv;
}
/* Check for disconnect() being called whilst refs to cursors */
/* still exists. This possibly needs some more thought. */
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !dirty) {
char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
warn("disconnect(%s) invalidates %d active statement%s. %s",
SvPV(dbh,na), (int)DBIc_ACTIVE_KIDS(imp_dbh), plural,
"Either destroy statement handles or call finish on them before disconnecting.");
}
ST(0) = dbd_db_disconnect(dbh, imp_dbh) ? &sv_yes : &sv_no;
void
STORE(dbh, keysv, valuesv)
SV * dbh
SV * keysv
SV * valuesv
CODE:
D_imp_dbh(dbh);
ST(0) = &sv_yes;
if (!dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv)) {
if (!DBIS->set_attr(dbh, keysv, valuesv)) {
ST(0) = &sv_no;
}
}
void
FETCH(dbh, keysv)
SV * dbh
SV * keysv
CODE:
D_imp_dbh(dbh);
SV *valuesv = dbd_db_FETCH_attrib(dbh, imp_dbh, keysv);
if (!valuesv) {
valuesv = DBIS->get_attr(dbh, keysv);
}
ST(0) = valuesv; /* dbd_db_FETCH_attrib did sv_2mortal */
void
DESTROY(dbh)
SV * dbh
PPCODE:
D_imp_dbh(dbh);
ST(0) = &sv_yes;
if (!DBIc_IMPSET(imp_dbh)) { /* was never fully set up */
if (DBIc_WARN(imp_dbh) && !dirty && dbis->debug >= 2) {
warn("Database handle %s DESTROY ignored - never set up", SvPV(dbh,na));
}
}
else {
/* pre-disconnect checks and tidy-ups */
if (DBIc_CACHED_KIDS(imp_dbh)) {
SvREFCNT_dec(DBIc_CACHED_KIDS(imp_dbh));
DBIc_CACHED_KIDS(imp_dbh) = Nullhv;
}
if (DBIc_IADESTROY(imp_dbh)) { /* want's ineffective destroy */
DBIc_ACTIVE_off(imp_dbh);
}
if (DBIc_ACTIVE(imp_dbh)) {
if (DBIc_WARN(imp_dbh) && (!dirty || dbis->debug >= 3)) {
warn("Database handle destroyed without explicit disconnect");
}
/* The application has not explicitly disconnected. That's bad. */
/* To ensure integrity we *must* issue a rollback. This will be */
/* harmless if the application has issued a commit. If it hasn't */
/* then it'll ensure integrity. Consider a Ctrl-C killing perl */
/* between two statements that must be executed as a transaction. */
/* Perl will call DESTROY on the dbh and, if we don't rollback, */
/* the server will automatically commit! Bham! Corrupt database! */
if (!DBIc_has(imp_dbh,DBIcf_AutoCommit)) {
dbd_db_rollback(dbh, imp_dbh); /* ROLLBACK! */
}
dbd_db_disconnect(dbh, imp_dbh);
}
dbd_db_destroy(dbh, imp_dbh);
}
# driver specific functions
void
lo_open(dbh, lobjId, mode)
SV * dbh
unsigned int lobjId
int mode
CODE:
int ret = pg_db_lo_open(dbh, lobjId, mode);
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_close(dbh, fd)
SV * dbh
int fd
CODE:
ST(0) = (-1 != pg_db_lo_close(dbh, fd)) ? &sv_yes : &sv_no;
void
lo_read(dbh, fd, buf, len)
SV * dbh
int fd
char * buf
int len
PREINIT:
SV *bufsv = SvROK(ST(2)) ? SvRV(ST(2)) : ST(2);
int ret;
CODE:
buf = SvGROW(bufsv, len + 1);
ret = pg_db_lo_read(dbh, fd, buf, len);
if (ret > 0) {
SvCUR_set(bufsv, ret);
*SvEND(bufsv) = '\0';
sv_setpvn(ST(2), buf, ret);
SvSETMAGIC(ST(2));
}
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_write(dbh, fd, buf, len)
SV * dbh
int fd
char * buf
int len
CODE:
int ret = pg_db_lo_write(dbh, fd, buf, len);
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_lseek(dbh, fd, offset, whence)
SV * dbh
int fd
int offset
int whence
CODE:
int ret = pg_db_lo_lseek(dbh, fd, offset, whence);
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_creat(dbh, mode)
SV * dbh
int mode
CODE:
int ret = pg_db_lo_creat(dbh, mode);
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_tell(dbh, fd)
SV * dbh
int fd
CODE:
int ret = pg_db_lo_tell(dbh, fd);
ST(0) = (-1 != ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_unlink(dbh, lobjId)
SV * dbh
unsigned int lobjId
CODE:
ST(0) = (-1 != pg_db_lo_unlink(dbh, lobjId)) ? &sv_yes : &sv_no;
void
lo_import(dbh, filename)
SV * dbh
char * filename
CODE:
unsigned int ret = pg_db_lo_import(dbh, filename);
ST(0) = (ret) ? sv_2mortal(newSViv(ret)) : &sv_undef;
void
lo_export(dbh, lobjId, filename)
SV * dbh
unsigned int lobjId
char * filename
CODE:
ST(0) = (-1 != pg_db_lo_export(dbh, lobjId, filename)) ? &sv_yes : &sv_no;
void
putline(dbh, buf)
SV * dbh
char * buf
CODE:
int ret = pg_db_putline(dbh, buf);
ST(0) = (-1 != ret) ? &sv_yes : &sv_no;
void
getline(dbh, buf, len)
PREINIT:
SV *bufsv = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
INPUT:
SV * dbh
int len
char * buf = sv_grow(bufsv, len);
CODE:
int ret = pg_db_getline(dbh, buf, len);
if (*buf == '\\' && *(buf+1) == '.') {
ret = -1;
}
sv_setpv((SV*)ST(1), buf);
SvSETMAGIC(ST(1));
ST(0) = (-1 != ret) ? &sv_yes : &sv_no;
void
endcopy(dbh)
SV * dbh
CODE:
ST(0) = (-1 != pg_db_endcopy(dbh)) ? &sv_yes : &sv_no;
# -- end of DBD::Pg::db
# ------------------------------------------------------------
# statement interface
# ------------------------------------------------------------
MODULE = DBD::Pg PACKAGE = DBD::Pg::st
void
_prepare(sth, statement, attribs=Nullsv)
SV * sth
char * statement
SV * attribs
CODE:
{
D_imp_sth(sth);
D_imp_dbh_from_sth;
DBD_ATTRIBS_CHECK("_prepare", sth, attribs);
if (!strncasecmp(statement, "begin", 5) ||
!strncasecmp(statement, "end", 4) ||
!strncasecmp(statement, "commit", 6) ||
!strncasecmp(statement, "abort", 5) ||
!strncasecmp(statement, "rollback", 8) ) {
warn("please use DBI functions for transaction handling");
ST(0) = &sv_no;
} else {
ST(0) = dbd_st_prepare(sth, imp_sth, statement, attribs) ? &sv_yes : &sv_no;
}
}
void
rows(sth)
SV * sth
CODE:
D_imp_sth(sth);
XST_mIV(0, dbd_st_rows(sth, imp_sth));
void
bind_param(sth, param, value, attribs=Nullsv)
SV * sth
SV * param
SV * value
SV * attribs
CODE:
{
IV sql_type = 0;
D_imp_sth(sth);
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
/* XXX we should perhaps complain if TYPE is not SvNIOK */
DBD_ATTRIB_GET_IV(attribs, "TYPE", 4, svp, sql_type);
}
}
ST(0) = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0) ? &sv_yes : &sv_no;
}
void
bind_param_inout(sth, param, value_ref, maxlen, attribs=Nullsv)
SV * sth
SV * param
SV * value_ref
IV maxlen
SV * attribs
CODE:
{
IV sql_type = 0;
D_imp_sth(sth);
if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG) {
croak("bind_param_inout needs a reference to a scalar value");
}
if (SvREADONLY(SvRV(value_ref))) {
croak(no_modify);
}
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
DBD_ATTRIB_GET_IV(attribs, "TYPE", 4, svp, sql_type);
}
}
ST(0) = dbd_bind_ph(sth, imp_sth, param, SvRV(value_ref), sql_type, attribs, TRUE, maxlen) ? &sv_yes : &sv_no;
}
void
execute(sth, ...)
SV * sth
CODE:
D_imp_sth(sth);
int ret;
if (items > 1) {
/* Handle binding supplied values to placeholders */
int i;
SV *idx;
imp_sth->all_params_len = 0; /* used for malloc of statement string in case we have placeholders */
if (items-1 != DBIc_NUM_PARAMS(imp_sth)) {
croak("execute called with %ld bind variables, %d needed", items-1, DBIc_NUM_PARAMS(imp_sth));
XSRETURN_UNDEF;
}
idx = sv_2mortal(newSViv(0));
for(i=1; i < items ; ++i) {
sv_setiv(idx, i);
if (!dbd_bind_ph(sth, imp_sth, idx, ST(i), 0, Nullsv, FALSE, 0)) {
XSRETURN_UNDEF; /* dbd_bind_ph already registered error */
}
}
}
ret = dbd_st_execute(sth, imp_sth);
/* remember that dbd_st_execute must return <= -2 for error */
if (ret == 0) { /* ok with no rows affected */
XST_mPV(0, "0E0"); /* (true but zero) */
}
else if (ret < -1) { /* -1 == unknown number of rows */
XST_mUNDEF(0); /* <= -2 means error */
}
else {
XST_mIV(0, ret); /* typically 1, rowcount or -1 */
}
void
fetchrow_arrayref(sth)
SV * sth
ALIAS:
fetch = 1
CODE:
D_imp_sth(sth);
AV *av = dbd_st_fetch(sth, imp_sth);
ST(0) = (av) ? sv_2mortal(newRV_inc((SV *)av)) : &sv_undef;
void
fetchrow_array(sth)
SV * sth
ALIAS:
fetchrow = 1
PPCODE:
D_imp_sth(sth);
AV *av;
av = dbd_st_fetch(sth, imp_sth);
if (av) {
int num_fields = AvFILL(av)+1;
int i;
EXTEND(sp, num_fields);
for(i=0; i < num_fields; ++i) {
PUSHs(AvARRAY(av)[i]);
}
}
void
finish(sth)
SV * sth
CODE:
D_imp_sth(sth);
D_imp_dbh_from_sth;
if (!DBIc_ACTIVE(imp_dbh)) {
/* Either an explicit disconnect() or global destruction */
/* has disconnected us from the database. Finish is meaningless */
/* XXX warn */
XSRETURN_YES;
}
if (!DBIc_ACTIVE(imp_sth)) {
/* No active statement to finish */
XSRETURN_YES;
}
ST(0) = dbd_st_finish(sth, imp_sth) ? &sv_yes : &sv_no;
void
blob_read(sth, field, offset, len, destrv=Nullsv, destoffset=0)
SV * sth
int field
long offset
long len
SV * destrv
long destoffset
CODE:
{
D_imp_sth(sth);
if (!destrv) {
destrv = sv_2mortal(newRV_inc(sv_2mortal(newSViv(0))));
}
ST(0) = dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset) ? SvRV(destrv) : &sv_undef;
}
void
STORE(sth, keysv, valuesv)
SV * sth
SV * keysv
SV * valuesv
CODE:
D_imp_sth(sth);
ST(0) = &sv_yes;
if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv)) {
if (!DBIS->set_attr(sth, keysv, valuesv)) {
ST(0) = &sv_no;
}
}
# FETCH renamed and ALIASed to avoid case clash on VMS :-(
void
FETCH_attrib(sth, keysv)
SV * sth
SV * keysv
ALIAS:
FETCH = 1
CODE:
D_imp_sth(sth);
SV *valuesv = dbd_st_FETCH_attrib(sth, imp_sth, keysv);
if (!valuesv) {
valuesv = DBIS->get_attr(sth, keysv);
}
ST(0) = valuesv; /* dbd_st_FETCH_attrib did sv_2mortal */
void
DESTROY(sth)
SV * sth
PPCODE:
D_imp_sth(sth);
ST(0) = &sv_yes;
if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */
if (DBIc_WARN(imp_sth) && !dirty && dbis->debug >= 2) {
warn("Statement handle %s DESTROY ignored - never set up", SvPV(sth,na));
}
}
else {
if (DBIc_IADESTROY(imp_sth)) { /* want's ineffective destroy */
DBIc_ACTIVE_off(imp_sth);
}
if (DBIc_ACTIVE(imp_sth)) {
dbd_st_finish(sth, imp_sth);
}
dbd_st_destroy(sth, imp_sth);
}
# end of Pg.xs
--- NEW FILE: Changes ---
1.22 Wed Mar 26 22:33:44 EST 2003
- Win32 compile fix for snprintf [Joe Spears]
- Fix memory allocation problem in bytea escaping [Barrie Slaymaker]
- Add utf8 support [Dominic Mitchell <dom at semantico.com>]
- Transform Perl arrays into PostgreSQL arrays [Alexey Slynko]
- Fix for foreign_key_info() [Keith Keller]
- Fix PG_TEXT parameter binding
- Doc cleanups [turnstep]
- Fix warning from func($table, 'table_attributes') [turnstep]
- Added suppport for schemas [turnstep]
- Fix binary to a bytea field conversion [Chris Dunlop <chris at onthe.net.au>]
1.21 Sun Jan 12 21:00:44 EST 2003
- System tables no longer returned by tables(). [Dave Rolsky]
- Fix table_attributes to handle removal of pg_relcheck in 7.3,
from Ian Barwick <barwick at gmx.net>
- Properly reset transaction status after failed transaction when
autocommit is off. Properly report transaction failure message.
Kai <kai at xs4all.nl>
- New pg_bool_tf database handle that when set to true booleans are
returned as 't'/'f' rather than 1/0.
1.20 Wed Nov 27 16:19:26 2002
- Maintenance transferred to GBorg,
http://gborg.postgresql.org/project/dbdpg/projdisplay.php. Incremented
version number to reflect new management. [Bruce Momjian]
- README cleaned up. [Bruce Momjian]
- Added t/15funct.t, a series of tests that determine if the meta data
is working. [Thomas Lowery]
- Added implementations of column_info() and table_info(), and
primary_key_info(). [Thomas Lowery]
- The POD formatting was cleaned up. [David Wheeler]
- The preparser was updated to better handle escaped characters. [Rudy
Lippan]
- Removed redundant use of strlen() in pg_error() (Jason E. Stewart).
- Test suite cleaned up, converted to use Test::More, and updated to use
standard DBI environment variables for connecting to a test database.
[Jason E. Stewart]
- Added eg/lotest.pl as a demonstration of using large objects in buffers
rather than files. Contributed by Garth Webb.
- Added LISTEN/NOTIFY functionality. Congributed by Alex Pilosov.
- Added constants for common PostgreSQL data types, plus simple tests to
make sure that they work. These are exportable via "use DBD::Pg
qw(:pg_types);". [David Wheeler]
- Deprecatated the undocumented (and invalid) use of SQL_BINARY in
bind_param() and documented the correct approach: "bind_param($num,
$val { pg_type => PG_BYTEA });". Use of SQL_BINARY in bind_param() will
now issue a warning if $h->{Warn} is true. [David Wheeler]
- Removed invalid (and broken) support for SQL_BINARY in quote(). [David
Wheeler]
- Added App::Info::RDBMS::PostgreSQL to the distribution (but it won't
be installed) to help Makefile.PL find the PostgreSQL include and
library files. [David Wheeler]
- Fixed compile-time warnings. [David Wheeler and Jason E. Stewart]
2002-04-27 Jeffrey W. Baker <jwbaker at acm.org>
- dbdimp.c: Add default at end of switch statement for pg_type attrib.
- t/13pgtype.t: test for above.
2002-04-09 Jeffrey W. Baker <jwbaker at acm.org>
- Pg.pm, dbdimp.c: Applied patch from
Thomas A. Lowery <tlowery at stlowery.net> concerning metadata
in table_info and so forth.
2002-03-06 Jeffrey W. Baker <jwbaker at acm.org>
- Pg.pm (quote): Applied patch from David Wheeler <david at wheeler.net>
to simplfiy and speed up quoting.
- t/11quoting.t: Tests for above patch.
- t/12placeholders.t: Tests for placeholder parsing in quoted strings.
2002-03-06 Jeffrey W. Baker
- Version 1.10 uploaded to CPAN.
1.01 Jun 27, 2001
- fixed core dump when trying to use a BYTEA value with
a byte outside 0..127 Alex Pilosov <alex at pilosoft.com>
1.00 May 27, 2001
- Fetching all records now resets Active flag as it should.
0.99 May 24, 2001
- fix the segmentation fault in pg_error.
0.98 Apr 25, 2001
- bug-fix for core-dump after any failed function call.
- applied patch from Alex Pilosov <alex at pilosoft.com>
which adds support for the datatype bytea
0.97 Apr 20, 2001
- fix bug in connect method, which erroneously set the userid
and the password to the environment variables DBI_USER and
DBI_PASS.
- applied patch from Jan-Pieter Cornet <john at pc.xs4all.nl>,
which removed the special handling of a backslash when
used for octal presentation. Now a backslash always will
be escaped.
0.96 Apr 09, 2001
- remove memory-leak in ping function, bug-fix
from Doug Perham <dperham at wgate.com>
- correct the recognition of primary keys in
table_attributes(). Patch from Brian Powell
<brian at nicklebys.com>.
- applied patch from David D. Kilzer <ddkilzer at lubricants-oil.com>
which fixes a segmentation fault in DBD::pg::blob_read() when
reading LOBs that required perl to reallocate space for the
variable holding the scalar value
- updated test.pl to create a test blob larger than 256 bytes
(now 128 Kbytes)
- apply patch from Tom Lane, which fixes a seg-fault when
inserting large amounts of text.
- apply patch from Peter Haworth pmh at edison.ioppublishing.com,
which removes the newlines from the error messages and which
quotes date placeholders.
0.95 Jul 10, 2000
- add Win32 port from Bob Kline <bkline at rksystems.com>.
0.94 Jul 07, 2000
- applied patch from Rudy Lippan <almighty at randomc.com>
which fixes a memory-leak with failed connections.
- applied patch from Hein Roehrig <hein at acm.org>
which fixes a bug with escaping a backslash except for
octal presentation
- applied patch from Francis J. Lacoste <francis.lacoste at iNsu.COM
which fixes a segmentation fault when all binded parameters are NULL
- adapt test.pl to avoid warnings with postgresql-7.0
- added support for 'COPY FROM STDIN' and 'COPY TO STDOUT'
- added patch from Mark Stosberg <mark at summersault.com>
to enhance the table_attributes subroutine
0.93 Sep 29, 1999
- it is required now to set the environment variables POSTGRES_INCLUDE
and POSTGRES_LIB for compiling the module.
- add Win32 port from Bob Kline <bkline at rksystems.com>.
- support for all large-object functions via the func
interface.
- fixed bug with placeholders and casts spotted by
mschout at gkg.net
- replaced the method attributes by the method table_attributes,
from Scott Williams <scott at james.com>.
- fix type definitions for type_info_all().
bug spotted by "carlos" <emarcet at intramed.net.ar>.
- now the Pg-specific quote() method also evaluates the
data-type paramater.
0.92 Jun 16, 1999
- proposal from Philip Warner <pjw at rhyme.com.au>:
increase BUFSIZE from 1024 to 32768 in order to improve
I/O performance.
- bug-fix in Makefile.PL for $POSTGRES_HOME not defined
spotted by mdalphin at amgen.com (Mark Dalphin)
- bug-fix for data-type datetime in type_info_all
spotted by Alan Grover <awgrover at iconnect-inc.com>
- bug-fix for escaped 's spotted by Hankin <hankin at consultco.com>
- removed 'large objects' related tests from test.pl
0.91 Feb 14, 1999
- removed restriction for commercial use in copyright
- corrected DATA_TYPE in type_info_all()
0.90 Jan 15, 1998
- discard parameter authtype from connect string
- remove work-around for bug in the large object
interface of postgresql
0.89 Nov 05, 1998
- bug-fix from Jan Iven <j.iven at rz.uni-sb.de>:
fix problem with quoting Null in bind variables.
0.88 Oct 10, 1998
- fixed blob_read
- suppressed warning when testing DBI::errstr
0.87 Sep 05, 1998
- Pg.xs adapted to Driver.xst from DBI-1.0
- major rewrite of module documentation
- major rewrite of the test script
- use built-in DBI method for $dbh->do
- add macro dHTR in order to avoid compile errors
with threaded perl5.005
- renamed attribute AutoEscape to pg_auto_escape
- renamed attribute SIZE to pg_size
- new attribute pg_type
- added support for DBI->data_sources($driver)
- added support for $dbh->table_info
- blob_read documented and added to test.pl
- added support for attr parameter in bind_param()
0.86 Aug 21, 1998
- added /usr/lib/ to search path for libpq.
- added ChopBlanks, patch from
Victor Krasinsky <victor at rdovira.lviv.ua>
- changed test.pl to test multiple database handles
0.85 July 19, 1998
- non-printable characters in parameters will not be
converted to '.'. They are passed unchanged to the
database.
0.84 July 18, 1998
- bug-fix from Max Cohan <mcohan at adnc.net>:
check for \xxx presentation before escaping backslash
in parameters.
- introduce new database handle attribute AutoEscape, which
controls escaping of quotes and backslashes in parameters.
When set to on, all quotes except at the beginning and
at the end of a line will be escaped and all backslashes
except when used to indicate an octal presentation (\xxx)
will be escaped. Default of AutoEscape is on.
0.83 July 10, 1998
- bug-fix from Max Cohan <mcohan at adnc.net>:
using traces together with undef in place-holders dumped
core.
0.82 June 20, 1998
- bug-fix from Matthew Lenz <matthew at nocturnal.org>:
corrected include path in Makefile.PL .
- added 'use strict;' to test.pl
0.81 June 13, 1998
- bug-fix from Rolf Grossmann <grossman at securitas.net>:
undefined parameters in an execute statement will be
translated from 'undef' to 'NULL'. Also every parameter
for bind_param() will be quoted by default (escape quote
and backslash). Appropriate tests have been added to test.pl.
- change ping method to use libpq-interface.
0.80 June 07, 1998
- adapted to postgresql-6.4:
the backend protocol has changed, which needs an adapted
ping method. A ping-test has been added to the test-script.
Also some type identifiers have changed.
0.73 June 03, 1998
- changed include directives in Makefile.PL from
archlib to installarchlib and from sitearch to
installsitearch (Tony.Curtis at vcpc.univie.ac.at).
- applied patch from Junio Hamano <junio at twinsun.com>
quote method also doubles backslash.
0.72 April 20, 1998
- applied patch from Michael J Schout <mschout at gkg.net>
which fixed the bug with queries containing the cast
operator.
- applied patch from "Irving Reid" <irving at tor.securecomputing.com>
which fixed a memory leak.
0.71 April 04, 1998
- applied patch from "Irving Reid"
<irving at tor.securecomputing.com> which fixed the
the problem with the InactiveDestroy message.
0.70 March 28, 1998
- linking again with the shared version of libpq
due to problems on several operating systems.
0.69 March 6, 1998
- expanded the search path for include files
- module is now linked with static libpq.a
0.68 March 3, 1998
- return to UNIX domain sockets in test-scripts
0.67 February 21, 1998
- remove part of Driver.xst due to compile
error on some systems.
0.66 February 19, 1998
- remove defines in Pg.h so that
it compiles also with postgresql-6.2.1
- changed ping method: set RaiseError=0
0.65 February 14, 1998
- adapted to changes in DBI-0.91, so that the
default setting for AutoCommit and PrintError is
again conformant to the DBI specs.
0.64 February 01, 1998
- changed syntax of data_source (ODBC-conformant):
'dbi:Pg:dbname=dbname;host=host;port=port'
!!! PLEASE ADAPT YOUR SCRIPTS !!!
- implemented place-holders
- implemented ping-method
- added support for $dbh->{RaiseError} and $dbh->{PrintError},
note: DBI-default for PrintError is on !
- allow commit and rollback only if AutoCommit = off
- added documentation for $dbh->tables;
- new method to get meta-information about a given table:
$dbh->DBD::Pg::db::attributes($table);
- host-parameter in test.pl is set explicitly to localhost
0.63 October 05, 1997
- adapted to PostgreSQL-6.2:
o $sth->rows as well as $sth->execute
and $sth->do return the number of
affected rows even for non-Select
statements.
o support for password authorization added,
please check the man-page for pg_passwd.
- the data_source parameter of the connect
method accepts two additional parameters
which are treated as host and port:
DBI->connect("dbi:Pg:dbname:host:port", "uid", "pwd")
- support for AutoCommit, please read the
module documentation for impacts on your
scripts !
- more perl-ish handling of data type bool,
please read the module documentation for
impacts on your scripts !
0.62 August 26, 1997
- added blobs/README
0.61 August 23, 1997
- adapted to DBI-0.89/Driver.xst
- added support for blob_read
0.52 August 15, 1997
- added support for literal $sth->{'TYPE'},
pg_type.pl / pg_type.pm.
0.51 August 12, 1997
- changed attributes to be DBI conformant:
o OID_STATUS to pg_oid_status
o CMD_STATUS to pg_cmd_status
0.5 August 05, 1997
- support for user authentication
- support for bind_columns
- added $dbh->tables
0.4 Jun 24, 1997
- adapted to DBI-0.84:
o new syntax for DBI->connect !
o execute returns 0E0 -> n for SELECT stmt
-1 for non SELECT stmt
-2 on error
- new attribute $sth->{'OID_STATUS'}
- new attribute $sth->{'CMD_STATUS'}
0.3 Apr 24, 1997
- bug fix release, ( still alpha ! )
0.2 Mar 13, 1997
- complete rewrite, ( still alpha ! )
0.1 Feb 15, 1997
- creation, ( totally pre-alpha ! )
--- NEW FILE: Pg.pm ---
# $Id: Pg.pm,v 1.1 2004/04/29 09:21:28 ivan Exp $
#
# Copyright (c) 1997,1998,1999,2000 Edmund Mergl
# Copyright (c) 2002 Jeffrey W. Baker
# Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
require 5.004;
$DBD::Pg::VERSION = '1.22';
{
package DBD::Pg;
use DBI ();
[...1874 lines suppressed...]
DBD-Pg by Edmund Mergl (E.Mergl at bawue.de) and Jeffrey W. Baker
(jwbaker at acm.org). By David Wheeler <david at wheeler.net>, Jason
Stewart <jason at openinformatics.com> and Bruce Momjian
<pgman at candle.pha.pa.us> after v1.13.
Major parts of this package have been copied from DBI and DBD-Oracle.
=head1 COPYRIGHT
The DBD::Pg module is free software. You may distribute under the terms of
either the GNU General Public License or the Artistic License, as specified in
the Perl README file.
=head1 ACKNOWLEDGMENTS
See also B<DBI/ACKNOWLEDGMENTS>.
=cut
--- NEW FILE: README ---
DBD::Pg -- the DBI PostgreSQL interface for Perl
# $Id: README,v 1.1 2004/04/29 09:21:28 ivan Exp $
DESCRIPTION:
------------
This is version 1.21 of DBD-Pg. The web site for this interface is at:
http://gborg.postgresql.org/project/dbdpg/projdisplay.php
For further information about DBI look at:
http://dbi.perl.org/
For information about PostgreSQL, visit:
http://www.postgresql.org/
COPYRIGHT:
----------
Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
Copyright (c) 1997,1998,1999,2000 Edmund Mergl
Copyright (c) 2002 Jeffrey W. Baker
Copyright (c) 2002 PostgreSQL Global Development Group
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
HOW TO GET THE LATEST VERSION:
------------------------------
Use the following URL to look for new versions of this module:
http://gborg.postgresql.org/project/dbdpg/projdisplay.php
or
http://www.perl.com/CPAN/modules/by-module/DBD/
Note, that this request will be redirected automatically to the
nearest CPAN site.
IF YOU HAVE PROBLEMS:
---------------------
Please send comments and bug-reports to <dbd-general at gborg.postgresql.org>
Please include the output of perl -v and perl -V, the version of PostgreSQL,
the version of DBD-Pg, the version of DBI, and details about your platform
in your bug-report.
REQUIREMENTS:
-------------
build, test, and install Perl 5 (at least 5.005)
build, test, and install the DBI module (at least 1.30)
build, test, and install PostgreSQL (at least 7.3)
build, test, and install Test::Simple (at least 0.17)
INSTALLATION:
-------------
By default Makefile.PL uses App:Info to find the location of the
PostgreSQL library and include directories. However, if you want to
control it yourself, define the environment variables POSTGRES_INCLUDE
and POSTGRES_LIB, or POSTGRES_HOME.
1. perl Makefile.PL
2. make
3. make test
4. make install
Do steps 1 to 3 as normal user, not as root!
TESTING:
--------
The tests are designed to connect to a live database. The following
environment variables must be set for the tests to run:
DBI_DSN=dbi:Pg:dbname=<database>
DBI_USER=<username>
DBI_PASS=<password>
If you are using the shared library libpq.so check if your dynamic
loader finds libpq.so. With Linux the command /sbin/ldconfig -v should
tell you, where it finds libpq.so. If ldconfig does not find libpq.so,
either add an appropriate entry to /etc/ld.so.conf and re-run ldconfig
or add the path to the environment variable LD_LIBRARY_PATH.
A typical error message resulting from not finding libpq.so is:
install_driver(Pg) failed: Can't load './blib/arch/auto/DBD/Pg/Pg.so'
for module DBD::Pg: File not found at
If you get an error message like:
perl: error while loading shared libraries:
/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBD/Pg/Pg.so: undefined
symbol: PQconnectdb
when you call DBI->connect, then your libpq.so was probably not seen at
build-time. This should have caused 'make test' to fail; did you really
run it and look at the output? Check the setting of POSTGRES_LIB and
recompile DBD-Pg.
Some linux distributions have incomplete perl installations. If you have
compile errors like "XS_VERSION_BOOTCHECK undeclared", do:
find .../lib/perl5 -name XSUB.h -print
If this file is not present, you need to recompile and re-install perl.
SGI users: if you get segmentation faults make sure, you use the malloc
which comes with perl when compiling perl (the default is not to).
"David R. Noble" <drnoble at engsci.sandia.gov>
HP users: if you get error messages like:
can't open shared library: .../lib/libpq.sl
No such file or directory
when running the test script, try to replace the 'shared' option in the
LDDFLAGS with 'archive'. Dan Lauterbach <danla at dimensional.com>
FreeBSD users: if you get during make test the error message:
'DBD driver has not implemented the AutoCommit attribute'
recompile the DBI module and the DBD-Pg module and disable optimization.
This error message is due to the broken optimization in gcc-2.7.2.1.
If you get compiler errors like:
In function `XS_DBD__Pg__dr_discon_all_'
`sv_yes' undeclared (first use in this function)
It may be because there is a 'patchlevel.h' file from another package
(such as 'hdf') in your POSTGRES_INCLUDE dir. The presence of this file
prevents the compiler from finding the perl include file
'mach/CORE/patchlevel.h'. Do 'pg_config --includedir' to identify the
POSTGRES_INCLUDE dir. Rename patchlevel.h whilst you build DBD::Pg.
Sun Users: if you get compile errors like:
/usr/include/string.h:57: parse error before `]'
then you need to remove from pgsql/include/libpq-fe.h the define for
strerror, which clashes with the definition in the standard include
file.
Win32 Users: Running DBD-Pg scripts on Win32 needs some configuration work
on the server side:
o add a postgres user with the same name as the NT-User
(eg Administrator)
o make sure, that your pg_hba.conf on the server is configured,
such that a connection from another host will be accepted
--- NEW FILE: MANIFEST ---
Changes
MANIFEST
Makefile.PL
Pg.h
Pg.pm
Pg.xs
README
README.win32
dbd-pg.pod
dbdimp.c
dbdimp.h
eg/ApacheDBI.pl
eg/lotest.pl
eg/notify_test.patch
t/00basic.t
t/01connect.t
t/01constants.t
t/01setup.t
t/02prepare.t
t/03bind.t
t/04execute.t
t/05fetch.t
t/06disconnect.t
t/07reuse.t
t/08txn.t
t/09autocommit.t
t/11quoting.t
t/12placeholders.t
t/13pgtype.t
t/15funct.t
t/99cleanup.t
t/lib/App/Info.pm
t/lib/App/Info/Handler.pm
t/lib/App/Info/Handler/Prompt.pm
t/lib/App/Info/RDBMS.pm
t/lib/App/Info/RDBMS/PostgreSQL.pm
t/lib/App/Info/Request.pm
t/lib/App/Info/Util.pm
--- NEW FILE: dbdimp.h ---
/*
$Id: dbdimp.h,v 1.1 2004/04/29 09:21:28 ivan Exp $
Copyright (c) 1997,1998,1999,2000 Edmund Mergl
Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
*/
#ifdef WIN32
#define snprintf _snprintf
#endif
/* Define drh implementor data structure */
struct imp_drh_st {
dbih_drc_t com; /* MUST be first element in structure */
};
/* Define dbh implementor data structure */
struct imp_dbh_st {
dbih_dbc_t com; /* MUST be first element in structure */
PGconn * conn; /* connection structure */
int init_commit; /* initialize AutoCommit */
int pg_auto_escape; /* initialize AutoEscape */
int pg_bool_tf; /* do bools return 't'/'f' */
#ifdef SvUTF8_off
int pg_enable_utf8; /* should we attempt to make utf8 strings? */
#endif
};
/* Define sth implementor data structure */
struct imp_sth_st {
dbih_stc_t com; /* MUST be first element in structure */
PGresult* result; /* result structure */
int cur_tuple; /* current tuple */
int rows; /* number of affected rows */
/* Input Details */
char *statement; /* sql (see sth_scan) */
HV *all_params_hv; /* all params, keyed by name */
AV *out_params_av; /* quick access to inout params */
int pg_pad_empty; /* convert ""->" " when binding */
int all_params_len; /* length-sum of all params */
/* (In/)Out Parameter Details */
bool has_inout_params;
};
#define sword signed int
#define sb2 signed short
#define ub2 unsigned short
typedef struct phs_st phs_t; /* scalar placeholder */
struct phs_st { /* scalar placeholder EXPERIMENTAL */
sword ftype; /* external OCI field type */
SV *sv; /* the scalar holding the value */
int sv_type; /* original sv type at time of bind */
bool is_inout;
IV maxlen; /* max possible len (=allocated buffer) */
/* these will become an array */
sb2 indp; /* null indicator */
char *progv;
ub2 arcode;
IV alen; /* effective length ( <= maxlen ) */
int alen_incnull; /* 0 or 1 if alen should include null */
char name[1]; /* struct is malloc'd bigger as needed */
};
SV * dbd_db_pg_notifies (SV *dbh, imp_dbh_t *imp_dbh);
/* end of dbdimp.h */
--- NEW FILE: Pg.h ---
/*
$Id: Pg.h,v 1.1 2004/04/29 09:21:28 ivan Exp $
Copyright (c) 1997,1998,1999,2000 Edmund Mergl
Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
*/
#ifdef WIN32
static int errno;
#endif
#include "libpq-fe.h"
#ifdef NEVER
#include<sys/stat.h>
#include "libpq/libpq-fs.h"
#endif
#ifndef INV_READ
#define INV_READ 0x00040000
#endif
#ifndef INV_WRITE
#define INV_WRITE 0x00020000
#endif
#ifdef BUFSIZ
#undef BUFSIZ
#endif
/* this should improve I/O performance for large objects */
#define BUFSIZ 32768
#define NEED_DBIXS_VERSION 93
#include <DBIXS.h> /* installed by the DBI module */
#include "dbdimp.h" /* read in our implementation details */
#include <dbd_xsh.h> /* installed by the DBI module */
/* end of Pg.h */
--- NEW FILE: dbdimp.c ---
/*
$Id: dbdimp.c,v 1.1 2004/04/29 09:21:28 ivan Exp $
Copyright (c) 1997,1998,1999,2000 Edmund Mergl
Copyright (c) 2002 Jeffrey W. Baker
Portions Copyright (c) 1994,1995,1996,1997 Tim Bunce
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
*/
/*
hard-coded OIDs: (here we need the postgresql types)
pg_sql_type() 1042 (bpchar), 1043 (varchar)
ddb_st_fetch() 1042 (bpchar), 16 (bool)
ddb_preparse() 1043 (varchar)
pgtype_bind_ok()
[...1985 lines suppressed...]
default:
type_nam = "unknown";
}
av_store(av, i, newSVpv(type_nam, 0));
}
} else if (kl==13 && strEQ(key, "pg_oid_status")) {
retsv = newSVpv((char *)PQoidStatus(imp_sth->result), 0);
} else if (kl==13 && strEQ(key, "pg_cmd_status")) {
retsv = newSVpv((char *)PQcmdStatus(imp_sth->result), 0);
} else {
return Nullsv;
}
return sv_2mortal(retsv);
}
/* end of dbdimp.c */
--- NEW FILE: README.win32 ---
$Id: README.win32,v 1.1 2004/04/29 09:21:28 ivan Exp $
Here is a step-by-step procedure for getting DBD-Pg to work on Windows
NT. This Port has been done by Bob Kline <bkline at rksystems.com>.
prerequisites: (older versions might also work, but these are the
-------------- versions I used)
o Windows NT4 SP4
o Visual Studio 6.0
o ActivePerl-5_6_0_613 with DBI-1.13
o postgresql-7.0.2
o DBD-Pg-0.95
Here we assume, that perl and postgresql have been installed in C:\. Now
perform the following steps:
1. compile libpq
----------------
set POSTGRES_HOME=C:\postgresql-7.0.2
cd postgresql-7.0.2
mkdir lib
mkdir include
cd src
copy include\port\win32.h include\os.h
edit interfaces\libpq\fe-connect.c and add as first statement in connectDBStart() the following code:
#ifdef WIN32
static int WeHaveCalledWSAStartup;
if (!WeHaveCalledWSAStartup) {
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
printfPQExpBuffer(&conn->errorMessage, "WSAStartup failed: errno=%d\n", h_errno);
goto connect_errReturn;
}
WeHaveCalledWSAStartup = 1;
}
#endif
edit interfaces\libpq\win32.mak and change the flag /ML to /MD: CPP_PROJ=/nologo /MD ...
nmake /f win32.mak
cd ..
copy src\interfaces\libpq\Release\libpq.lib lib
copy src\interfaces\libpq\libpq-fe.h include
copy src\include\postgres_ext.h include
cd ..
2. build DBD-Pg
---------------
cd DBD-Pg
perl Makefile.PL CAPI=TRUE
nmake
set the environment variable PGHOST to the name of the postgresql server: set PGHOST=myserver
add on the server a postgres user with the same name as the NT-User (eg Administrator)
make sure, that your pg_hba.conf on the server is configured, such that a connection from another host will be accepted
mkdir C:\tmp
nmake test (expect to get errors concerning blobs)
nmake install
--- NEW FILE: Makefile.PL ---
# $Id: Makefile.PL,v 1.1 2004/04/29 09:21:28 ivan Exp $
use ExtUtils::MakeMaker;
use Config;
use strict;
use DBI 1.00;
use DBI::DBD;
my $lib;
BEGIN {
my %sep = (MacOS => ':',
MSWin32 => '\\',
os2 => '\\',
VMS => '\\',
NetWare => '\\',
dos => '\\');
my $s = $sep{$^O} || '/';
$lib = join $s, 't', 'lib';
}
use lib $lib;
print "Configuring Pg\n";
print "Remember to actually read the README file !\n";
my $POSTGRES_INCLUDE;
my $POSTGRES_LIB;
if ((!$ENV{POSTGRES_INCLUDE} or !$ENV{POSTGRES_LIB}) and !$ENV{POSTGRES_HOME}) {
# Use App::Info to get the data we need.
require App::Info::RDBMS::PostgreSQL;
require App::Info::Handler::Prompt;
my $p = App::Info::Handler::Prompt->new;
my $pg = App::Info::RDBMS::PostgreSQL->new(on_unknown => $p);
$POSTGRES_INCLUDE = $pg->inc_dir;
$POSTGRES_LIB = $pg->lib_dir;
} elsif ((!$ENV{POSTGRES_INCLUDE} or !$ENV{POSTGRES_LIB}) and $ENV{POSTGRES_HOME}) {
$POSTGRES_INCLUDE = "$ENV{POSTGRES_HOME}/include";
$POSTGRES_LIB = "$ENV{POSTGRES_HOME}/lib";
} else {
$POSTGRES_INCLUDE = "$ENV{POSTGRES_INCLUDE}";
$POSTGRES_LIB = "$ENV{POSTGRES_LIB}";
}
my $os = $^O;
print "OS: $os\n";
my $dbi_arch_dir;
if ($os eq 'MSWin32') {
$dbi_arch_dir = "\$(INSTALLSITEARCH)/auto/DBI";
} else {
$dbi_arch_dir = dbd_dbi_arch_dir();
}
my %opts = (
NAME => 'DBD::Pg',
VERSION_FROM => 'Pg.pm',
INC => "-I$POSTGRES_INCLUDE -I$dbi_arch_dir",
OBJECT => "Pg\$(OBJ_EXT) dbdimp\$(OBJ_EXT)",
LIBS => ["-L$POSTGRES_LIB -lpq"],
AUTHOR => 'http://gborg.postgresql.org/project/dbdpg/projdisplay.php',
ABSTRACT => 'PostgreSQL database driver for the DBI module',
PREREQ_PM => { 'Test::Simple' => 0.17 }, # Need Test::More
);
if ($os eq 'hpux') {
my $osvers = $Config{osvers};
if ($osvers < 10) {
print "Warning: Forced to build static not dynamic on $os $osvers.\a\n";
$opts{LINKTYPE} = 'static';
}
}
if ($Config{dlsrc} =~ /dl_none/) {
$opts{LINKTYPE} = 'static';
}
WriteMakefile(%opts);
exit(0);
# end of Makefile.PL
--- NEW FILE: dbd-pg.pod ---
# $Id: dbd-pg.pod,v 1.1 2004/04/29 09:21:28 ivan Exp $
=head1 NAME
DBD::Pg - PostgreSQL database driver for the DBI module
=head1 DESCRIPTION
DBD::Pg is a Perl module which works with the DBI module to provide
access to PostgreSQL databases.
=head1 DBD::Pg
=begin docbook
<!-- The following blank =head1 is to allow us to use purely =head2 headings -->
<!-- This keeps the POD fairly simple with regards to Pod::DocBook -->
=end docbook
=head1
=head2 Version
Version 0.91.
=head2 Author and Contact Details
The driver author is Edmund Mergl. He can be contacted via the
I<dbi-users> mailing list.
=head2 Supported Database Versions and Options
The DBD-Pg-0.92 module supports Postgresql 6.5.
=head2 Connect Syntax
The C<DBI-E<gt>connect()> Data Source Name, or I<DSN>, can be one of the
following:
dbi:Pg:dbname=$dbname
dbi:Pg:dbname=$dbname;host=$host;port=$port;options=$options;tty=$tty
All parameters, including the userid and password parameter of the
connect command, have a hard-coded default which can be overridden
by setting appropriate environment variables:
Parameter Environment Variable Default
--------- -------------------- --------------
dbname PGDATABASE current userid
host PGHOST localhost
port PGPORT 5432
options PGOPTIONS ""
tty PGTTY ""
username PGUSER current userid
password PGPASSWORD ""
There are no driver specific attributes for the C<DBI->connect()> method.
=head2 Numeric Data Handling
Postgresql supports the following numeric types:
Postgresql Range
---------- --------------------------
int2 -32768 to +32767
int4 -2147483648 to +2147483647
float4 6 decimal places
float8 15 decimal places
Some platforms also support the int8 type.
C<DBD::Pg> always returns all numbers as strings.
=head2 String Data Handling
Postgresql supports the following string data types:
CHAR single character
CHAR(size) fixed length blank-padded
VARCHAR(size) variable length with limit
TEXT variable length
All string data types have a limit of 4096 bytes.
The CHAR type is fixed length and blank padded.
There is no special handling for data with the 8th bit set. They
are stored unchanged in the database.
None of the character types can store embedded nulls and Unicode is
not formally supported.
Strings can be concatenated using the C<||> operator.
=head2 Date Data Handling
Postgresql supports the following date time data types:
Type Storage Recommendation Description
--------- -------- -------------------------- ----------------------------
abstime 4 bytes original date and time limited range
date 4 bytes SQL92 type wide range
datetime 8 bytes best general date and time wide range, high precision
interval 12 bytes SQL92 type equivalent to timespan
reltime 4 bytes original time interval limited range, low precision
time 4 bytes SQL92 type wide range
timespan 12 bytes best general time interval wide range, high precision
timestamp 4 bytes SQL92 type limited range
Data Type Range Resolution
---------- ---------------------------------- -----------
abstime 1901-12-14 2038-01-19 1 sec
timestamp 1901-12-14 2038-01-19 1 sec
reltime -68 years +68 years 1 sec
tinterval -178000000 years +178000000 years 1 microsec
timespan -178000000 years 178000000 years 1 microsec
date 4713 BC 32767 AD 1 day
datetime 4713 BC 1465001 AD 1 microsec
time 00:00:00:00 23:59:59:99 1 microsec
Postgresql supports a range of date formats:
Name Example
----------- ----------------------
ISO 1997-12-17 0:37:16-08
SQL 12/17/1997 07:37:16.00 PST
Postgres Wed Dec 17 07:37:16 1997 PST
European 17/12/1997 15:37:16.00 MET
NonEuropean 12/17/1997 15:37:16.00 MET
US 12/17/1997 07:37:16.00 MET
The default output format does not depend on the client/server locale.
It depends on, in increasing priority: the PGDATESTYLE environment
variable at the server, the PGDATESTYLE environment variable at the client, and
the C<SET DATESTYLE> SQL command.
All of the formats described above can be used for input. A great many
others can also be used. There is no specific default input format.
If the format of a date input is ambiguous then the current DATESTYLE
is used to help disambiguate.
If you specify a date/time value without a time component, the default
time is 00:00:00 (midnight). To specify a date/time value without a date
is not allowed.
If a date with a two digit year is input then if the year was less than
70, add 2000; otherwise, add 1900.
The currect date/time is returned by the keyword C<'now'> or C<'current'>,
which has to be casted to a valid data type. For example:
SELECT 'now'::datetime
Postgresql supports a range of date time functions for converting
between types, extracting parts of a date time value, truncating to a
given unit, etc. The usual arithmetic can be performed on date and
interval values, e.g., date-date=interval, etc.
The following SQL expression can be used to convert an integer "seconds
since 1-jan-1970 GMT" value to the corresponding database date time:
DATETIME(unixtime_field)
and to do the reverse:
DATE_PART('epoch', datetime_field)
The server stores all dates internally in GMT. Times are converted to
local time on the database server before being sent to the client
frontend, hence by default are in the server time zone.
The TZ environment variable is used by the server as default time
zone. The PGTZ environment variable on the client side is used to send
the time zone information to the backend upon connection. The SQL C<SET
TIME ZONE> command can set the time zone for the current session.
=head2 LONG/BLOB Data Handling
Postgresql handles BLOBS using a so called "large objects" type. The
handling of this type differs from all other data types. The data are
broken into chunks, which are stored in tuples in the database. Access
to large objects is given by an interface which is modelled closely
after the UNIX file system. The maximum size is limited by the file
size of the operating system.
If you just select the field, you get a "large object identifier" and
not the data itself. The I<LongReadLen> and I<LongTruncOk> attributes are
not implemented because they don't make sense in this case. The only
method implemented by the driver is the undocumented DBI method
C<blob_read()>.
=head2 Other Data Handling issues
The C<DBD::Pg> driver supports the C<type_info()> method.
Postgresql supports automatic conversions between data types wherever
it's reasonable.
=head2 Transactions, Isolation and Locking
Postgresql supports transactions.
The current default isolation transaction level is "Serializable" and
is currently implemented using table level locks. Both may change.
No other isolation levels for transactions are supported.
With AutoCommit on, a query never places a lock on a table. Readers
never block writers and writers never block readers. This behavior
changes whenever a transaction is started (AutoCommit off). Then a
query induces a shared lock on a table and blocks anyone else
until the transaction has been finished.
The C<LOCK TABLE table_name> statement can be used to apply an explicit
lock on a table. This only works inside a transaction (AutoCommit off).
To ensure that a table being selected does not change before you make
an update later in the transaction, you must explicitly lock it with a
C<LOCK TABLE> statement before executing the select.
=head2 No-Table Expression Select Syntax
To select a constant expression, that is, an expression that doesn't involve
data from a database table or view, just omit the "from" clause.
Here's an example that selects the current time as a datetime:
SELECT 'now'::datetime;
=head2 Table Join Syntax
Outer joins are not supported. Inner joins use the traditional syntax.
=head2 Table and Column Names
The max size of table and column names cannot exceed 31 charaters in
length.
Only alphanumeric characters can be used; the first character must
be a letter.
If an identifier is enclosed by double quotation marks (C<">), it can
contain any combination of characters except double quotation marks.
Postgresql converts all identifiers to lower-case unless enclosed in
double quotation marks.
National character set characters can be used, if enclosed in quotation
marks.
=head2 Case Sensitivity of LIKE Operator
Postgresql has the following string matching operators:
Glyph Description Example
----- ---------------------------------------- -----------------------------
~~ Same as SQL "LIKE" operator 'scrappy,marc' ~~ '%scrappy%'
!~~ Same as SQL "NOT LIKE" operator 'bruce' !~~ '%al%'
~ Match (regex), case sensitive 'thomas' ~ '.*thomas.*'
~* Match (regex), case insensitive 'thomas' ~* '.*Thomas.*'
!~ Does not match (regex), case sensitive 'thomas' !~ '.*Thomas.*'
!~* Does not match (regex), case insensitive 'thomas' !~ '.*vadim.*'
=head2 Row ID
The Postgresql "row id" pseudocolumn is called I<oid>, object identifier.
It can be treated as a string and used to rapidly (re)select rows.
=head2 Automatic Key or Sequence Generation
Postgresql does not support automatic key generation such as "auto
increment" or "system generated" keys.
However, Postgresql does support "sequence generators". Any number of
named sequence generators can be created in a database. Sequences
are used via functions called C<NEXTVAL> and C<CURRVAL>. Typical usage:
INSERT INTO table (k, v) VALUES (nextval('seq_name'), ?);
To get the value just inserted, you can use the corresponding C<currval()>
SQL function in the same session, or
SELECT last_value FROM seq_name
=head2 Automatic Row Numbering and Row Count Limiting
Postgresql does not support any way of automatically numbering returned rows.
=head2 Parameter Binding
Parameter binding is emulated by the driver.
Both the C<?> and C<:1> style of placeholders are supported.
The TYPE attribute of the C<bind_param()> method may be used to
influence how parameters are treated. These SQL types are bound as
VARCHAR: SQL_NUMERIC, SQL_DECIMAL, SQL_INTEGER, SQL_SMALLINT,
SQL_FLOAT, SQL_REAL, SQL_DOUBLE, SQL_VARCHAR.
The SQL_CHAR type is bound as a CHAR thus enabling fixed-width blank
padded comparison semantics.
Unsupported values of the TYPE attribute generate a warning.
=head2 Stored Procedures
C<DBD::Pg> does not support stored procedures.
=head2 Table Metadata
C<DBD::Pg> supports the C<table_info()> method.
The I<pg_attribute> table contains detailed information about all columns
of all the tables in the database, one row per table.
The I<pg_index> table contains detailed information about all indexes in
the database, one row per index.
Primary keys are implemented as unique indexes. See I<pg_index> above.
=head2 Driver-specific Attributes and Methods
There are no significant C<DBD::Pg> driver-specific database handle attributes.
C<DBD::Pg> has the following driver-specific statement handle attributes:
=over 8
=item I<pg_size>
Returns a reference to an array of integer values for each column. The
integer shows the storage (not display) size of the column in bytes.
Variable length columns are indicated by -1.
=item I<pg_type>
Returns a reference to an array of strings for each column. The string
shows the name of the data type.
=item I<pg_oid_status>
Returns the OID of the last INSERT command.
=item I<pg_cmd_status>
Returns the name of the last command type. Possible types are: INSERT,
DELETE, UPDATE, SELECT.
=back
C<DBD::Pg> has no private methods.
=head2 Positioned updates and deletes
Postgresql does not support positioned updates or deletes.
=head2 Differences from the DBI Specification
C<DBD::Pg> has no significant differences in behavior from the
current DBI specification.
Note that C<DBD::Pg> does not fully parse the statement until
it's executed. Thus attributes like I<$sth-E<gt>{NUM_OF_FIELDS}> are not
available until after C<$sth-E<gt>execute> has been called. This is valid
behaviour but is important to note when porting applications
originally written for other drivers.
=head2 URLs to More Database/Driver Specific Information
http://www.postgresql.org
=head2 Concurrent use of Multiple Handles
C<DBD::Pg> supports an unlimited number of concurrent database
connections to one or more databases.
It also supports the preparation and execution of a new statement
handle while still fetching data from another statement handle,
provided it is
associated with the same database handle.
=head2 Other Significant Database or Driver Features
Postgres offers substantial additional power by incorporating the
following four additional basic concepts in such a way that users can
easily extend the system: classes, inheritance, types, and functions.
Other features provide additional power and flexibility: constraints,
triggers, rules, transaction integrity, procedural languages, and large objects.
It's also free Open Source Software with an active community of developers.
=cut
# This driver summary for DBD::Pg is Copyright (c) 1999 Tim Bunce
# and Edmund Mergl.
# $Id: dbd-pg.pod,v 1.1 2004/04/29 09:21:28 ivan Exp $
- Previous message: freeside/install/5.005/DBD-Pg-1.22-fixvercmp/t 00basic.t,NONE,1.1 01connect.t,NONE,1.1 01constants.t,NONE,1.1 01setup.t,NONE,1.1 02prepare.t,NONE,1.1 03bind.t,NONE,1.1 04execute.t,NONE,1.1 05fetch.t,NONE,1.1 06disconnect.t,NONE,1.1 07reuse.t,NONE,1.1 08txn.t,NONE,1.1 09autocommit.t,NONE,1.1 11quoting.t,NONE,1.1 12placeholders.t,NONE,1.1 13pgtype.t,NONE,1.1 15funct.t,NONE,1.1 99cleanup.t,NONE,1.1
- Next message: freeside/install/5.005/DBD-Pg-1.22-fixvercmp/t/lib/App/Info/RDBMS PostgreSQL.pm,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list