Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,69 @@
C:\strawberry\perl\bin\dbilogstrip
C:\strawberry\perl\bin\dbilogstrip.bat
C:\strawberry\perl\bin\dbiprof
C:\strawberry\perl\bin\dbiprof.bat
C:\strawberry\perl\bin\dbiproxy
C:\strawberry\perl\bin\dbiproxy.bat
C:\strawberry\perl\vendor\lib\Bundle\DBI.pm
C:\strawberry\perl\vendor\lib\DBD\DBM.pm
C:\strawberry\perl\vendor\lib\DBD\ExampleP.pm
C:\strawberry\perl\vendor\lib\DBD\File.pm
C:\strawberry\perl\vendor\lib\DBD\File\Developers.pod
C:\strawberry\perl\vendor\lib\DBD\File\HowTo.pod
C:\strawberry\perl\vendor\lib\DBD\File\Roadmap.pod
C:\strawberry\perl\vendor\lib\DBD\Gofer.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Policy\Base.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Policy\classic.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Policy\pedantic.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Policy\rush.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Transport\Base.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Transport\corostream.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Transport\null.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Transport\pipeone.pm
C:\strawberry\perl\vendor\lib\DBD\Gofer\Transport\stream.pm
C:\strawberry\perl\vendor\lib\DBD\Mem.pm
C:\strawberry\perl\vendor\lib\DBD\NullP.pm
C:\strawberry\perl\vendor\lib\DBD\Proxy.pm
C:\strawberry\perl\vendor\lib\DBD\Sponge.pm
C:\strawberry\perl\vendor\lib\DBI.pm
C:\strawberry\perl\vendor\lib\DBI\Changes.pm
C:\strawberry\perl\vendor\lib\DBI\Const\GetInfoReturn.pm
C:\strawberry\perl\vendor\lib\DBI\Const\GetInfoType.pm
C:\strawberry\perl\vendor\lib\DBI\Const\GetInfo\ANSI.pm
C:\strawberry\perl\vendor\lib\DBI\Const\GetInfo\ODBC.pm
C:\strawberry\perl\vendor\lib\DBI\DBD.pm
C:\strawberry\perl\vendor\lib\DBI\DBD\Metadata.pm
C:\strawberry\perl\vendor\lib\DBI\DBD\SqlEngine.pm
C:\strawberry\perl\vendor\lib\DBI\DBD\SqlEngine\Developers.pod
C:\strawberry\perl\vendor\lib\DBI\DBD\SqlEngine\HowTo.pod
C:\strawberry\perl\vendor\lib\DBI\Gofer\Execute.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Request.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Response.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Serializer\Base.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Serializer\DataDumper.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Serializer\Storable.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Transport\Base.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Transport\pipeone.pm
C:\strawberry\perl\vendor\lib\DBI\Gofer\Transport\stream.pm
C:\strawberry\perl\vendor\lib\DBI\Profile.pm
C:\strawberry\perl\vendor\lib\DBI\ProfileData.pm
C:\strawberry\perl\vendor\lib\DBI\ProfileDumper.pm
C:\strawberry\perl\vendor\lib\DBI\ProfileDumper\Apache.pm
C:\strawberry\perl\vendor\lib\DBI\ProfileSubs.pm
C:\strawberry\perl\vendor\lib\DBI\ProxyServer.pm
C:\strawberry\perl\vendor\lib\DBI\PurePerl.pm
C:\strawberry\perl\vendor\lib\DBI\SQL\Nano.pm
C:\strawberry\perl\vendor\lib\DBI\Util\CacheMemory.pm
C:\strawberry\perl\vendor\lib\DBI\Util\_accessor.pm
C:\strawberry\perl\vendor\lib\DBI\W32ODBC.pm
C:\strawberry\perl\vendor\lib\Win32\DBIODBC.pm
C:\strawberry\perl\vendor\lib\auto\DBI\DBI.xs.dll
C:\strawberry\perl\vendor\lib\auto\DBI\DBIXS.h
C:\strawberry\perl\vendor\lib\auto\DBI\Driver.xst
C:\strawberry\perl\vendor\lib\auto\DBI\Driver_xst.h
C:\strawberry\perl\vendor\lib\auto\DBI\dbd_xsh.h
C:\strawberry\perl\vendor\lib\auto\DBI\dbi_sql.h
C:\strawberry\perl\vendor\lib\auto\DBI\dbipport.h
C:\strawberry\perl\vendor\lib\auto\DBI\dbivport.h
C:\strawberry\perl\vendor\lib\auto\DBI\dbixs_rev.h
C:\strawberry\perl\vendor\lib\dbixs_rev.pl

Binary file not shown.

View File

@@ -0,0 +1,575 @@
/* vim: ts=8:sw=4:expandtab
*
* $Id$
*
* Copyright (c) 1994-2010 Tim Bunce Ireland
*
* See COPYRIGHT section in DBI.pm for usage and distribution rights.
*/
/* DBI Interface Definitions for DBD Modules */
#ifndef DBIXS_VERSION /* prevent multiple inclusion */
#ifndef DBIS
#define DBIS dbis /* default name for dbistate_t variable */
#endif
/* Here for backwards compat. PERL_POLLUTE was removed in perl 5.13.3 */
#define PERL_POLLUTE
/* first pull in the standard Perl header files for extensions */
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#ifdef debug /* causes problems with DBIS->debug */
#undef debug
#endif
#ifdef std /* causes problems with STLport <tscheresky@micron.com> */
#undef std
#endif
/* define DBIXS_REVISION */
#include "dbixs_rev.h"
/* Perl backwards compatibility definitions */
#define NEED_sv_2pv_flags
#include "dbipport.h"
/* DBI SQL_* type definitions */
#include "dbi_sql.h"
#define DBIXS_VERSION 93 /* superseded by DBIXS_REVISION */
#ifdef NEED_DBIXS_VERSION
#if NEED_DBIXS_VERSION > DBIXS_VERSION
error You_need_to_upgrade_your_DBI_module_before_building_this_driver
#endif
#else
#define NEED_DBIXS_VERSION DBIXS_VERSION
#endif
#define DBI_LOCK
#define DBI_UNLOCK
#ifndef DBI_NO_THREADS
#ifdef USE_ITHREADS
#define DBI_USE_THREADS
#endif /* USE_ITHREADS */
#endif /* DBI_NO_THREADS */
/* forward struct declarations */
typedef struct dbistate_st dbistate_t;
/* implementor needs to define actual struct { dbih_??c_t com; ... }*/
typedef struct imp_drh_st imp_drh_t; /* driver */
typedef struct imp_dbh_st imp_dbh_t; /* database */
typedef struct imp_sth_st imp_sth_t; /* statement */
typedef struct imp_fdh_st imp_fdh_t; /* field descriptor */
typedef struct imp_xxh_st imp_xxh_t; /* any (defined below) */
#define DBI_imp_data_ imp_xxh_t /* friendly for take_imp_data */
/* --- DBI Handle Common Data Structure (all handles have one) --- */
/* Handle types. Code currently assumes child = parent + 1. */
#define DBIt_DR 1
#define DBIt_DB 2
#define DBIt_ST 3
#define DBIt_FD 4
/* component structures */
typedef struct dbih_com_std_st {
U32 flags;
int call_depth; /* used by DBI to track nested calls (int) */
U16 type; /* DBIt_DR, DBIt_DB, DBIt_ST */
HV *my_h; /* copy of outer handle HV (not refcounted) */
SV *parent_h; /* parent inner handle (ref to hv) (r.c.inc) */
imp_xxh_t *parent_com; /* parent com struct shortcut */
PerlInterpreter * thr_user; /* thread that owns the handle */
HV *imp_stash; /* who is the implementor for this handle */
SV *imp_data; /* optional implementors data (for perl imp's) */
I32 kids; /* count of db's for dr's, st's for db's etc */
I32 active_kids; /* kids which are currently DBIc_ACTIVE */
U32 pid; /* pid of process that created handle */
dbistate_t *dbistate;
} dbih_com_std_t;
typedef struct dbih_com_attr_st {
/* These are copies of the Hash values (ref.cnt.inc'd) */
/* Many of the hash values are themselves references */
SV *TraceLevel;
SV *State; /* Standard SQLSTATE, 5 char string */
SV *Err; /* Native engine error code */
SV *Errstr; /* Native engine error message */
UV ErrCount;
U32 LongReadLen; /* auto read length for long/blob types */
SV *FetchHashKeyName; /* for fetchrow_hashref */
/* (NEW FIELDS?... DON'T FORGET TO UPDATE dbih_clearcom()!) */
} dbih_com_attr_t;
struct dbih_com_st { /* complete core structure (typedef'd above) */
dbih_com_std_t std;
dbih_com_attr_t attr;
};
/* This 'implementors' type the DBI defines by default as a way to */
/* refer to the imp_??h data of a handle without considering its type. */
struct imp_xxh_st { struct dbih_com_st com; };
/* Define handle-type specific structures for implementors to include */
/* at the start of their private structures. */
typedef struct { /* -- DRIVER -- */
dbih_com_std_t std;
dbih_com_attr_t attr;
HV *_old_cached_kids; /* not used, here for binary compat */
} dbih_drc_t;
typedef struct { /* -- DATABASE -- */
dbih_com_std_t std; /* \__ standard structure */
dbih_com_attr_t attr; /* / plus... (nothing else right now) */
HV *_old_cached_kids; /* not used, here for binary compat */
} dbih_dbc_t;
typedef struct { /* -- STATEMENT -- */
dbih_com_std_t std; /* \__ standard structure */
dbih_com_attr_t attr; /* / plus ... */
int num_params; /* number of placeholders */
int num_fields; /* NUM_OF_FIELDS, must be set */
AV *fields_svav; /* special row buffer (inc bind_cols) */
IV row_count; /* incremented by get_fbav() */
AV *fields_fdav; /* not used yet, may change */
I32 spare1;
void *spare2;
} dbih_stc_t;
/* XXX THIS STRUCTURE SHOULD NOT BE USED */
typedef struct { /* -- FIELD DESCRIPTOR -- */
dbih_com_std_t std; /* standard structure (not fully setup) */
/* core attributes (from DescribeCol in ODBC) */
char *col_name; /* see dbih_make_fdsv */
I16 col_name_len;
I16 col_sql_type;
I16 col_precision;
I16 col_scale;
I16 col_nullable;
/* additional attributes (from ColAttributes in ODBC) */
I32 col_length;
I32 col_disp_size;
I32 spare1;
void *spare2;
} dbih_fdc_t;
#define _imp2com(p,f) ((p)->com.f) /* private */
#define DBIc_FLAGS(imp) _imp2com(imp, std.flags)
#define DBIc_TYPE(imp) _imp2com(imp, std.type)
#define DBIc_CALL_DEPTH(imp) _imp2com(imp, std.call_depth)
#define DBIc_MY_H(imp) _imp2com(imp, std.my_h)
#define DBIc_PARENT_H(imp) _imp2com(imp, std.parent_h)
#define DBIc_PARENT_COM(imp) _imp2com(imp, std.parent_com)
#define DBIc_THR_COND(imp) _imp2com(imp, std.thr_cond)
#define DBIc_THR_USER(imp) _imp2com(imp, std.thr_user)
#define DBIc_THR_USER_NONE (0xFFFF)
#define DBIc_IMP_STASH(imp) _imp2com(imp, std.imp_stash)
#define DBIc_IMP_DATA(imp) _imp2com(imp, std.imp_data)
#define DBIc_DBISTATE(imp) _imp2com(imp, std.dbistate)
#define DBIc_LOGPIO(imp) DBIc_DBISTATE(imp)->logfp
#define DBIc_KIDS(imp) _imp2com(imp, std.kids)
#define DBIc_ACTIVE_KIDS(imp) _imp2com(imp, std.active_kids)
#define DBIc_LAST_METHOD(imp) _imp2com(imp, std.last_method)
/* d = DBD flags, l = DBD level (needs to be shifted down)
* D - DBI flags, r = reserved, L = DBI trace level
* Trace level bit allocation: 0xddlDDDrL */
#define DBIc_TRACE_LEVEL_MASK 0x0000000F
#define DBIc_TRACE_FLAGS_MASK 0xFF0FFF00 /* includes DBD flag bits for DBIc_TRACE */
#define DBIc_TRACE_SETTINGS(imp) (DBIc_DBISTATE(imp)->debug)
#define DBIc_TRACE_LEVEL(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_LEVEL_MASK)
#define DBIc_TRACE_FLAGS(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_FLAGS_MASK)
/* DBI defined trace flags */
#define DBIf_TRACE_SQL 0x00000100
#define DBIf_TRACE_CON 0x00000200
#define DBIf_TRACE_ENC 0x00000400
#define DBIf_TRACE_DBD 0x00000800
#define DBIf_TRACE_TXN 0x00001000
#define DBDc_TRACE_LEVEL_MASK 0x00F00000
#define DBDc_TRACE_LEVEL_SHIFT 20
#define DBDc_TRACE_LEVEL(imp) ( (DBIc_TRACE_SETTINGS(imp) & DBDc_TRACE_LEVEL_MASK) >> DBDc_TRACE_LEVEL_SHIFT )
#define DBDc_TRACE_LEVEL_set(imp, l) ( DBIc_TRACE_SETTINGS(imp) |= (((l) << DBDc_TRACE_LEVEL_SHIFT) & DBDc_TRACE_LEVEL_MASK ))
/* DBIc_TRACE_MATCHES(this, crnt): true if this 'matches' (is within) crnt
DBIc_TRACE_MATCHES(foo, DBIc_TRACE_SETTINGS(imp))
*/
#define DBIc_TRACE_MATCHES(this, crnt) \
( ((crnt & DBIc_TRACE_LEVEL_MASK) >= (this & DBIc_TRACE_LEVEL_MASK)) \
|| ((crnt & DBIc_TRACE_FLAGS_MASK) & (this & DBIc_TRACE_FLAGS_MASK)) )
/* DBIc_TRACE(imp, flags, flag_level, fallback_level)
True if flags match the handle trace flags & handle trace level >= flag_level,
OR if handle trace_level > fallback_level (typically > flag_level).
This is the main trace testing macro to be used by drivers.
(Drivers should define their own DBDf_TRACE_* macros for the top 8 bits: 0xFF000000)
DBIc_TRACE(imp, 0, 0, 4) = if trace level >= 4
DBIc_TRACE(imp, DBDf_TRACE_FOO, 2, 4) = if tracing DBDf_FOO & level>=2 or level>=4
DBIc_TRACE(imp, DBDf_TRACE_FOO, 2, 0) = as above but never trace just due to level
e.g.
if (DBIc_TRACE(imp_xxh, DBIf_TRACE_SQL|DBIf_TRACE_xxx, 2, 0)) {
PerlIO_printf(DBIc_LOGPIO(imp_sth), "\tThe %s wibbled the %s\n", ...);
}
*/
#define DBIc_TRACE(imp, flags, flaglevel, level) \
( (flags && (DBIc_TRACE_FLAGS(imp) & flags) && (DBIc_TRACE_LEVEL(imp) >= flaglevel)) \
|| (level && DBIc_TRACE_LEVEL(imp) >= level) )
#define DBIc_DEBUG(imp) (_imp2com(imp, attr.TraceLevel)) /* deprecated */
#define DBIc_DEBUGIV(imp) SvIV(DBIc_DEBUG(imp)) /* deprecated */
#define DBIc_STATE(imp) SvRV(_imp2com(imp, attr.State))
#define DBIc_ERR(imp) SvRV(_imp2com(imp, attr.Err))
#define DBIc_ERRSTR(imp) SvRV(_imp2com(imp, attr.Errstr))
#define DBIc_ErrCount(imp) _imp2com(imp, attr.ErrCount)
#define DBIc_LongReadLen(imp) _imp2com(imp, attr.LongReadLen)
#define DBIc_LongReadLen_init 80 /* may change */
#define DBIc_FetchHashKeyName(imp) (_imp2com(imp, attr.FetchHashKeyName))
/* handle sub-type specific fields */
/* dbh & drh */
#define DBIc_CACHED_KIDS(imp) Nullhv /* no longer used, here for src compat */
/* sth */
#define DBIc_NUM_FIELDS(imp) _imp2com(imp, num_fields)
#define DBIc_NUM_PARAMS(imp) _imp2com(imp, num_params)
#define DBIc_NUM_PARAMS_AT_EXECUTE -9 /* see Driver.xst */
#define DBIc_ROW_COUNT(imp) _imp2com(imp, row_count)
#define DBIc_FIELDS_AV(imp) _imp2com(imp, fields_svav)
#define DBIc_FDESC_AV(imp) _imp2com(imp, fields_fdav)
#define DBIc_FDESC(imp, i) ((imp_fdh_t*)(void*)SvPVX(AvARRAY(DBIc_FDESC_AV(imp))[i]))
/* XXX --- DO NOT CHANGE THESE VALUES AS THEY ARE COMPILED INTO DRIVERS --- XXX */
#define DBIcf_COMSET 0x000001 /* needs to be clear'd before free'd */
#define DBIcf_IMPSET 0x000002 /* has implementor data to be clear'd */
#define DBIcf_ACTIVE 0x000004 /* needs finish/disconnect before clear */
#define DBIcf_IADESTROY 0x000008 /* do DBIc_ACTIVE_off before DESTROY */
#define DBIcf_WARN 0x000010 /* warn about poor practice etc */
#define DBIcf_COMPAT 0x000020 /* compat/emulation mode (eg oraperl) */
#define DBIcf_ChopBlanks 0x000040 /* rtrim spaces from fetch char columns */
#define DBIcf_RaiseError 0x000080 /* throw exception (croak) on error */
#define DBIcf_PrintError 0x000100 /* warn() on error */
#define DBIcf_AutoCommit 0x000200 /* dbh only. used by drivers */
#define DBIcf_LongTruncOk 0x000400 /* truncation to LongReadLen is okay */
#define DBIcf_MultiThread 0x000800 /* allow multiple threads to enter */
#define DBIcf_HandleSetErr 0x001000 /* has coderef HandleSetErr attribute */
#define DBIcf_ShowErrorStatement 0x002000 /* include Statement in error */
#define DBIcf_BegunWork 0x004000 /* between begin_work & commit/rollback */
#define DBIcf_HandleError 0x008000 /* has coderef in HandleError attribute */
#define DBIcf_Profile 0x010000 /* profile activity on this handle */
#define DBIcf_TaintIn 0x020000 /* check inputs for taintedness */
#define DBIcf_TaintOut 0x040000 /* taint outgoing data */
#define DBIcf_Executed 0x080000 /* do/execute called since commit/rollb */
#define DBIcf_PrintWarn 0x100000 /* warn() on warning (err="0") */
#define DBIcf_Callbacks 0x200000 /* has Callbacks attribute hash */
#define DBIcf_AIADESTROY 0x400000 /* auto DBIcf_IADESTROY if pid changes */
#define DBIcf_RaiseWarn 0x800000 /* throw exception (croak) on warn */
/* NOTE: new flags may require clone() to be updated */
#define DBIcf_INHERITMASK /* what NOT to pass on to children */ \
(U32)( DBIcf_COMSET | DBIcf_IMPSET | DBIcf_ACTIVE | DBIcf_IADESTROY \
| DBIcf_AutoCommit | DBIcf_BegunWork | DBIcf_Executed | DBIcf_Callbacks )
/* general purpose bit setting and testing macros */
#define DBIbf_is( bitset,flag) ((bitset) & (flag))
#define DBIbf_has(bitset,flag) DBIbf_is(bitset, flag) /* alias for _is */
#define DBIbf_on( bitset,flag) ((bitset) |= (flag))
#define DBIbf_off(bitset,flag) ((bitset) &= ~(flag))
#define DBIbf_set(bitset,flag,on) ((on) ? DBIbf_on(bitset, flag) : DBIbf_off(bitset,flag))
/* as above, but specifically for DBIc_FLAGS imp flags (except ACTIVE) */
#define DBIc_is(imp, flag) DBIbf_is( DBIc_FLAGS(imp), flag)
#define DBIc_has(imp,flag) DBIc_is(imp, flag) /* alias for DBIc_is */
#define DBIc_on(imp, flag) DBIbf_on( DBIc_FLAGS(imp), flag)
#define DBIc_off(imp,flag) DBIbf_off(DBIc_FLAGS(imp), flag)
#define DBIc_set(imp,flag,on) DBIbf_set(DBIc_FLAGS(imp), flag, on)
#define DBIc_COMSET(imp) DBIc_is(imp, DBIcf_COMSET)
#define DBIc_COMSET_on(imp) DBIc_on(imp, DBIcf_COMSET)
#define DBIc_COMSET_off(imp) DBIc_off(imp,DBIcf_COMSET)
#define DBIc_IMPSET(imp) DBIc_is(imp, DBIcf_IMPSET)
#define DBIc_IMPSET_on(imp) DBIc_on(imp, DBIcf_IMPSET)
#define DBIc_IMPSET_off(imp) DBIc_off(imp,DBIcf_IMPSET)
#define DBIc_ACTIVE(imp) (DBIc_FLAGS(imp) & DBIcf_ACTIVE)
#define DBIc_ACTIVE_on(imp) /* adjust parent's active kid count */ \
do { \
imp_xxh_t *ph_com = DBIc_PARENT_COM(imp); \
if (!DBIc_ACTIVE(imp) && ph_com && !PL_dirty \
&& ++DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com)) \
croak("panic: DBI active kids (%ld) > kids (%ld)", \
(long)DBIc_ACTIVE_KIDS(ph_com), \
(long)DBIc_KIDS(ph_com)); \
DBIc_FLAGS(imp) |= DBIcf_ACTIVE; \
} while(0)
#define DBIc_ACTIVE_off(imp) /* adjust parent's active kid count */ \
do { \
imp_xxh_t *ph_com = DBIc_PARENT_COM(imp); \
if (DBIc_ACTIVE(imp) && ph_com && !PL_dirty \
&& (--DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com) \
|| DBIc_ACTIVE_KIDS(ph_com) < 0) ) \
croak("panic: DBI active kids (%ld) < 0 or > kids (%ld)", \
(long)DBIc_ACTIVE_KIDS(ph_com), \
(long)DBIc_KIDS(ph_com)); \
DBIc_FLAGS(imp) &= ~DBIcf_ACTIVE; \
} while(0)
#define DBIc_IADESTROY(imp) (DBIc_FLAGS(imp) & DBIcf_IADESTROY)
#define DBIc_IADESTROY_on(imp) (DBIc_FLAGS(imp) |= DBIcf_IADESTROY)
#define DBIc_IADESTROY_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_IADESTROY)
#define DBIc_AIADESTROY(imp) (DBIc_FLAGS(imp) & DBIcf_AIADESTROY)
#define DBIc_AIADESTROY_on(imp) (DBIc_FLAGS(imp) |= DBIcf_AIADESTROY)
#define DBIc_AIADESTROY_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_AIADESTROY)
#define DBIc_WARN(imp) (DBIc_FLAGS(imp) & DBIcf_WARN)
#define DBIc_WARN_on(imp) (DBIc_FLAGS(imp) |= DBIcf_WARN)
#define DBIc_WARN_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_WARN)
#define DBIc_COMPAT(imp) (DBIc_FLAGS(imp) & DBIcf_COMPAT)
#define DBIc_COMPAT_on(imp) (DBIc_FLAGS(imp) |= DBIcf_COMPAT)
#define DBIc_COMPAT_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_COMPAT)
#ifdef IN_DBI_XS /* get Handle Common Data Structure */
#define DBIh_COM(h) (dbih_getcom2(aTHX_ h, 0))
#else
#define DBIh_COM(h) (DBIS->getcom(h))
#define neatsvpv(sv,len) (DBIS->neat_svpv(sv,len))
#endif
/* --- For sql_type_cast_svpv() --- */
#define DBIstcf_DISCARD_STRING 0x0001
#define DBIstcf_STRICT 0x0002
/* --- Implementors Private Data Support --- */
#define D_impdata(name,type,h) type *name = (type*)(DBIh_COM(h))
#define D_imp_drh(h) D_impdata(imp_drh, imp_drh_t, h)
#define D_imp_dbh(h) D_impdata(imp_dbh, imp_dbh_t, h)
#define D_imp_sth(h) D_impdata(imp_sth, imp_sth_t, h)
#define D_imp_xxh(h) D_impdata(imp_xxh, imp_xxh_t, h)
#define D_imp_from_child(name,type,child) \
type *name = (type*)(DBIc_PARENT_COM(child))
#define D_imp_drh_from_dbh D_imp_from_child(imp_drh, imp_drh_t, imp_dbh)
#define D_imp_dbh_from_sth D_imp_from_child(imp_dbh, imp_dbh_t, imp_sth)
#define DBI_IMP_SIZE(n,s) sv_setiv(get_sv((n), GV_ADDMULTI), (s)) /* XXX */
/* --- Event Support (VERY LIABLE TO CHANGE) --- */
#define DBIh_EVENTx(h,t,a1,a2) /* deprecated XXX */ &PL_sv_no
#define DBIh_EVENT0(h,t) DBIh_EVENTx((h), (t), &PL_sv_undef, &PL_sv_undef)
#define DBIh_EVENT1(h,t, a1) DBIh_EVENTx((h), (t), (a1), &PL_sv_undef)
#define DBIh_EVENT2(h,t, a1,a2) DBIh_EVENTx((h), (t), (a1), (a2))
#define ERROR_event "ERROR"
#define WARN_event "WARN"
#define MSG_event "MESSAGE"
#define DBEVENT_event "DBEVENT"
#define UNKNOWN_event "UNKNOWN"
#define DBIh_SET_ERR_SV(h,i, err, errstr, state, method) \
(DBIc_DBISTATE(i)->set_err_sv(h,i, err, errstr, state, method))
#define DBIh_SET_ERR_CHAR(h,i, err_c, err_i, errstr, state, method) \
(DBIc_DBISTATE(i)->set_err_char(h,i, err_c, err_i, errstr, state, method))
/* --- Handy Macros --- */
#define DBIh_CLEAR_ERROR(imp_xxh) (void)( \
(void)SvOK_off(DBIc_ERR(imp_xxh)), \
(void)SvOK_off(DBIc_ERRSTR(imp_xxh)), \
(void)SvOK_off(DBIc_STATE(imp_xxh)) \
)
/* --- DBI State Structure --- */
struct dbistate_st {
/* DBISTATE_VERSION is checked at runtime via DBISTATE_INIT and check_version.
* It should be incremented on incompatible changes to dbistate_t structure.
* Additional function pointers being assigned from spare padding, where the
* size of the structure doesn't change, doesn't require an increment.
* Incrementing forces all XS drivers to need to be recompiled.
* (See also DBIXS_REVISION as a driver source compatibility tool.)
*/
#define DBISTATE_VERSION 94 /* ++ on incompatible dbistate_t changes */
/* this must be the first member in structure */
void (*check_version) _((const char *name,
int dbis_cv, int dbis_cs, int need_dbixs_cv,
int drc_s, int dbc_s, int stc_s, int fdc_s));
/* version and size are used to check for DBI/DBD version mis-match */
U16 version; /* version of this structure */
U16 size;
U16 xs_version; /* version of the overall DBIXS / DBD interface */
U16 spare_pad;
I32 debug;
PerlIO *logfp;
/* pointers to DBI functions which the DBD's will want to use */
char * (*neat_svpv) _((SV *sv, STRLEN maxlen));
imp_xxh_t * (*getcom) _((SV *h)); /* see DBIh_COM macro */
void (*clearcom) _((imp_xxh_t *imp_xxh));
SV * (*event) _((SV *h, const char *name, SV*, SV*));
int (*set_attr_k) _((SV *h, SV *keysv, int dbikey, SV *valuesv));
SV * (*get_attr_k) _((SV *h, SV *keysv, int dbikey));
AV * (*get_fbav) _((imp_sth_t *imp_sth));
SV * (*make_fdsv) _((SV *sth, const char *imp_class, STRLEN imp_size, const char *col_name));
int (*bind_as_num) _((int sql_type, int p, int s, int *t, void *v)); /* XXX deprecated */
I32 (*hash) _((const char *string, long i));
SV * (*preparse) _((SV *sth, char *statement, IV ps_return, IV ps_accept, void *foo));
SV *neatsvpvlen; /* only show dbgpvlen chars when debugging pv's */
PerlInterpreter * thr_owner; /* thread that owns this dbistate */
int (*logmsg) _((imp_xxh_t *imp_xxh, const char *fmt, ...));
int (*set_err_sv) _((SV *h, imp_xxh_t *imp_xxh, SV *err, SV *errstr, SV *state, SV *method));
int (*set_err_char) _((SV *h, imp_xxh_t *imp_xxh, const char *err, IV err_i, const char *errstr, const char *state, const char *method));
int (*bind_col) _((SV *sth, SV *col, SV *ref, SV *attribs));
IO *logfp_ref; /* keep ptr to filehandle for refcounting */
int (*sql_type_cast_svpv) _((pTHX_ SV *sv, int sql_type, U32 flags, void *v));
/* WARNING: Only add new structure members here, and reduce pad2 to keep */
/* the memory footprint exactly the same */
void *pad2[3];
};
/* macros for backwards compatibility */
#define set_attr(h, k, v) set_attr_k(h, k, 0, v)
#define get_attr(h, k) get_attr_k(h, k, 0)
#define DBILOGFP (DBIS->logfp)
#ifdef IN_DBI_XS
#define DBILOGMSG (dbih_logmsg)
#else
#define DBILOGMSG (DBIS->logmsg)
#endif
/* --- perl object (ActiveState) / multiplicity hooks and hoops --- */
/* note that USE_ITHREADS implies MULTIPLICITY */
typedef dbistate_t** (*_dbi_state_lval_t)(pTHX);
# define _DBISTATE_DECLARE_COMMON \
static _dbi_state_lval_t dbi_state_lval_p = 0; \
static dbistate_t** dbi_get_state(pTHX) { \
if (!dbi_state_lval_p) { \
CV *cv = get_cv("DBI::_dbi_state_lval", 0); \
if (!cv) \
croak("Unable to get DBI state function. DBI not loaded."); \
dbi_state_lval_p = (_dbi_state_lval_t)CvXSUB(cv); \
} \
return dbi_state_lval_p(aTHX); \
} \
typedef int dummy_dbistate /* keep semicolon from feeling lonely */
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || defined(PERL_CAPI)
# define DBISTATE_DECLARE _DBISTATE_DECLARE_COMMON
# define _DBISTATE_INIT_DBIS
# undef DBIS
# define DBIS (*dbi_get_state(aTHX))
# define dbis DBIS /* temp for old drivers using 'dbis' instead of 'DBIS' */
#else /* plain and simple non perl object / multiplicity case */
# define DBISTATE_DECLARE \
static dbistate_t *DBIS; \
_DBISTATE_DECLARE_COMMON
# define _DBISTATE_INIT_DBIS DBIS = *dbi_get_state(aTHX);
#endif
# define DBISTATE_INIT { /* typically use in BOOT: of XS file */ \
_DBISTATE_INIT_DBIS \
if (DBIS == NULL) \
croak("Unable to get DBI state. DBI not loaded."); \
DBIS->check_version(__FILE__, DBISTATE_VERSION, sizeof(*DBIS), NEED_DBIXS_VERSION, \
sizeof(dbih_drc_t), sizeof(dbih_dbc_t), sizeof(dbih_stc_t), sizeof(dbih_fdc_t) \
); \
}
/* --- Assorted Utility Macros --- */
#define DBD_ATTRIB_OK(attribs) /* is this a usable attrib value */ \
(attribs && SvROK(attribs) && SvTYPE(SvRV(attribs))==SVt_PVHV)
/* If attribs value supplied then croak if it's not a hash ref. */
/* Also map undef to Null. Should always be called to pre-process the */
/* attribs value. One day we may add some extra magic in here. */
#define DBD_ATTRIBS_CHECK(func, h, attribs) \
if ((attribs) && SvOK(attribs)) { \
if (!SvROK(attribs) || SvTYPE(SvRV(attribs))!=SVt_PVHV) \
croak("%s->%s(...): attribute parameter '%s' is not a hash ref", \
SvPV_nolen(h), func, SvPV_nolen(attribs)); \
} else (attribs) = Nullsv
#define DBD_ATTRIB_GET_SVP(attribs, key,klen) \
(DBD_ATTRIB_OK(attribs) \
? hv_fetch((HV*)SvRV(attribs), key,klen, 0) \
: (SV **)Nullsv)
#define DBD_ATTRIB_GET_IV(attribs, key,klen, svp, var) \
if ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \
var = SvIV(*svp)
#define DBD_ATTRIB_GET_UV(attribs, key,klen, svp, var) \
if ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \
var = SvUV(*svp)
#define DBD_ATTRIB_GET_BOOL(attribs, key,klen, svp, var) \
if ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \
var = SvTRUE(*svp)
#define DBD_ATTRIB_TRUE(attribs, key,klen, svp) \
( ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \
? SvTRUE(*svp) : 0 )
#define DBD_ATTRIB_GET_PV(attribs, key,klen, svp, dflt) \
(((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \
? SvPV_nolen(*svp) : (dflt))
#define DBD_ATTRIB_DELETE(attribs, key, klen) \
hv_delete((HV*)SvRV(attribs), key, klen, G_DISCARD)
#endif /* DBIXS_VERSION */
/* end of DBIXS.h */

View File

@@ -0,0 +1,851 @@
# $Id$
# Copyright (c) 1997-2002 Tim Bunce Ireland
# Copyright (c) 2002 Jonathan Leffler
#
# 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 "Driver_xst.h"
# Historically dbd_db_do4, dbd_st_execute, and dbd_st_rows returned an 'int' type.
# That's only 32 bits (31+sign) so isn't sufficient for very large row counts
# So now instead of defining those macros, drivers can define dbd_db_do4_iv,
# dbd_st_execute_iv, and dbd_st_rows_iv to be the names of functions that
# return an 'IV' type. They could also set DBIc_ROW_COUNT(imp_sth).
#
# To save a mess of #ifdef's we arrange for dbd_st_execute (etc) to work
# as dbd_st_execute_iv if that's defined
#
#if defined(dbd_st_execute_iv)
#undef dbd_st_execute
#define dbd_st_execute dbd_st_execute_iv
#endif
#if defined(dbd_st_rows_iv)
#undef dbd_st_rows
#define dbd_st_rows dbd_st_rows_iv
#endif
#if defined(dbd_db_do4_iv)
#undef dbd_db_do4
#define dbd_db_do4 dbd_db_do4_iv
#endif
MODULE = DBD::~DRIVER~ PACKAGE = DBD::~DRIVER~
REQUIRE: 1.929
PROTOTYPES: DISABLE
BOOT:
PERL_UNUSED_VAR(items);
DBISTATE_INIT;
/* XXX this interface will change: */
DBI_IMP_SIZE("DBD::~DRIVER~::dr::imp_data_size", sizeof(imp_drh_t));
DBI_IMP_SIZE("DBD::~DRIVER~::db::imp_data_size", sizeof(imp_dbh_t));
DBI_IMP_SIZE("DBD::~DRIVER~::st::imp_data_size", sizeof(imp_sth_t));
dbd_init(DBIS);
# ------------------------------------------------------------
# driver level interface
# ------------------------------------------------------------
MODULE = DBD::~DRIVER~ PACKAGE = DBD::~DRIVER~::dr
void
dbixs_revision(...)
PPCODE:
ST(0) = sv_2mortal(newSViv(DBIXS_REVISION));
#ifdef dbd_discon_all
# disconnect_all renamed and ALIAS'd to avoid length clash on VMS :-(
bool
discon_all_(drh)
SV * drh
ALIAS:
disconnect_all = 1
CODE:
D_imp_drh(drh);
PERL_UNUSED_VAR(ix);
RETVAL = dbd_discon_all(drh, imp_drh);
OUTPUT:
RETVAL
#endif /* dbd_discon_all */
#ifdef dbd_dr_data_sources
void
data_sources(drh, attr = Nullsv)
SV *drh
SV *attr
PPCODE:
{
D_imp_drh(drh);
AV *av = dbd_dr_data_sources(drh, imp_drh, attr);
if (av) {
int i;
int n = AvFILL(av)+1;
EXTEND(sp, n);
for (i = 0; i < n; ++i) {
PUSHs(AvARRAY(av)[i]);
}
}
}
#endif
# ------------------------------------------------------------
# database level interface
# ------------------------------------------------------------
MODULE = DBD::~DRIVER~ PACKAGE = DBD::~DRIVER~::db
bool
_login(dbh, dbname, username, password, attribs=Nullsv)
SV * dbh
SV * dbname
SV * username
SV * password
SV * attribs
CODE:
{
D_imp_dbh(dbh);
#if !defined(dbd_db_login6_sv)
STRLEN lna;
char *u = (SvOK(username)) ? SvPV(username,lna) : (char*)"";
char *p = (SvOK(password)) ? SvPV(password,lna) : (char*)"";
#endif
#ifdef dbd_db_login6_sv
RETVAL = dbd_db_login6_sv(dbh, imp_dbh, dbname, username, password, attribs);
#elif defined(dbd_db_login6)
RETVAL = dbd_db_login6(dbh, imp_dbh, SvPV_nolen(dbname), u, p, attribs);
#else
PERL_UNUSED_ARG(attribs);
RETVAL = dbd_db_login( dbh, imp_dbh, SvPV_nolen(dbname), u, p);
#endif
}
OUTPUT:
RETVAL
void
selectall_arrayref(...)
PREINIT:
SV *sth;
SV **maxrows_svp;
SV **tmp_svp;
SV *tmp_sv;
SV *attr = &PL_sv_undef;
imp_sth_t *imp_sth;
CODE:
if (items > 2) {
attr = ST(2);
if (SvROK(attr) &&
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp))
) {
/* fallback to perl implementation */
SV *tmp =dbixst_bounce_method("DBD::~DRIVER~::db::SUPER::selectall_arrayref", items);
SPAGAIN;
ST(0) = tmp;
XSRETURN(1);
}
}
/* --- prepare --- */
if (SvROK(ST(1))) {
MAGIC *mg;
sth = ST(1);
/* switch to inner handle if not already */
if ( (mg = mg_find(SvRV(sth),'P')) )
sth = mg->mg_obj;
}
else {
sth = dbixst_bounce_method("prepare", 3);
SPAGAIN; SP -= items; /* because stack might have been realloc'd */
if (!SvROK(sth))
XSRETURN_UNDEF;
/* switch to inner handle */
sth = mg_find(SvRV(sth),'P')->mg_obj;
}
imp_sth = (imp_sth_t*)(DBIh_COM(sth));
/* --- bind_param --- */
if (items > 3) { /* need to bind params before execute */
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
XSRETURN_UNDEF;
}
}
/* --- execute --- */
DBIc_ROW_COUNT(imp_sth) = 0;
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
XSRETURN_UNDEF;
}
/* --- fetchall --- */
maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7);
tmp_sv = dbdxst_fetchall_arrayref(sth, &PL_sv_undef, (maxrows_svp) ? *maxrows_svp : &PL_sv_undef);
SPAGAIN;
ST(0) = tmp_sv;
void
selectrow_arrayref(...)
ALIAS:
selectrow_array = 1
PREINIT:
int is_selectrow_array = (ix == 1);
imp_sth_t *imp_sth;
SV *sth;
AV *row_av;
PPCODE:
if (SvROK(ST(1))) {
MAGIC *mg;
sth = ST(1);
/* switch to inner handle if not already */
if ( (mg = mg_find(SvRV(sth),'P')) )
sth = mg->mg_obj;
}
else {
/* --- prepare --- */
sth = dbixst_bounce_method("prepare", 3);
SPAGAIN; SP -= items; /* because stack might have been realloc'd */
if (!SvROK(sth)) {
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
/* switch to inner handle */
sth = mg_find(SvRV(sth),'P')->mg_obj;
}
imp_sth = (imp_sth_t*)(DBIh_COM(sth));
/* --- bind_param --- */
if (items > 3) { /* need to bind params before execute */
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
}
/* --- execute --- */
DBIc_ROW_COUNT(imp_sth) = 0;
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
/* --- fetchrow_arrayref --- */
row_av = dbd_st_fetch(sth, imp_sth);
if (!row_av) {
if (GIMME == G_SCALAR)
PUSHs(&PL_sv_undef);
}
else if (is_selectrow_array) {
int i;
int num_fields = AvFILL(row_av)+1;
if (GIMME == G_SCALAR)
num_fields = 1; /* return just first field */
EXTEND(sp, num_fields);
for(i=0; i < num_fields; ++i) {
PUSHs(AvARRAY(row_av)[i]);
}
}
else {
PUSHs( sv_2mortal(newRV((SV *)row_av)) );
}
/* --- finish --- */
#ifdef dbd_st_finish3
dbd_st_finish3(sth, imp_sth, 0);
#else
dbd_st_finish(sth, imp_sth);
#endif
#if defined(dbd_db_do6) || defined(dbd_db_do4)
void
do(dbh, statement, params = Nullsv, ...)
SV * dbh
SV * statement
SV * params
CODE:
{
D_imp_dbh(dbh);
IV retval;
#ifdef dbd_db_do6
/* items is a number of arguments passed to XSUB, supplied by xsubpp compiler */
/* ax contains stack base offset used by ST() macro, supplied by xsubpp compiler */
I32 offset = (items >= 3) ? 3 : items;
retval = dbd_db_do6(dbh, imp_dbh, statement, params, items-offset, ax+offset);
#else
if (items > 3)
croak_xs_usage(cv, "dbh, statement, params = Nullsv");
retval = dbd_db_do4(dbh, imp_dbh, SvPV_nolen(statement), params); /* might be dbd_db_do4_iv via macro */
#endif
/* remember that dbd_db_do* must return <= -2 for error */
if (retval == 0) /* ok with no rows affected */
XST_mPV(0, "0E0"); /* (true but zero) */
else if (retval < -1) /* -1 == unknown number of rows */
XST_mUNDEF(0); /* <= -2 means error */
else
XST_mIV(0, retval); /* typically 1, rowcount or -1 */
}
#endif
#ifdef dbd_db_last_insert_id
void
last_insert_id(dbh, catalog=&PL_sv_undef, schema=&PL_sv_undef, table=&PL_sv_undef, field=&PL_sv_undef, attr=Nullsv)
SV * dbh
SV * catalog
SV * schema
SV * table
SV * field
SV * attr
CODE:
{
D_imp_dbh(dbh);
SV *ret = dbd_db_last_insert_id(dbh, imp_dbh, catalog, schema, table, field, attr);
ST(0) = ret;
}
#endif
bool
commit(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
warn("commit ineffective with AutoCommit enabled");
RETVAL = dbd_db_commit(dbh, imp_dbh);
OUTPUT:
RETVAL
bool
rollback(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
warn("rollback ineffective with AutoCommit enabled");
RETVAL = dbd_db_rollback(dbh, imp_dbh);
OUTPUT:
RETVAL
bool
disconnect(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if ( !DBIc_ACTIVE(imp_dbh) ) {
XSRETURN_YES;
}
/* 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) && !PL_dirty) {
STRLEN lna;
char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : (char*)"s";
warn("%s->disconnect invalidates %d active statement handle%s %s",
SvPV(dbh,lna), (int)DBIc_ACTIVE_KIDS(imp_dbh), plural,
"(either destroy statement handles or call finish on them before disconnecting)");
}
RETVAL = dbd_db_disconnect(dbh, imp_dbh);
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
OUTPUT:
RETVAL
void
STORE(dbh, keysv, valuesv)
SV * dbh
SV * keysv
SV * valuesv
CODE:
D_imp_dbh(dbh);
if (SvGMAGICAL(valuesv))
mg_get(valuesv);
ST(0) = &PL_sv_yes;
if (!dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv))
if (!DBIc_DBISTATE(imp_dbh)->set_attr(dbh, keysv, valuesv))
ST(0) = &PL_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 = DBIc_DBISTATE(imp_dbh)->get_attr(dbh, keysv);
ST(0) = valuesv; /* dbd_db_FETCH_attrib did sv_2mortal */
void
DESTROY(dbh)
SV * dbh
PPCODE:
/* keep in sync with default DESTROY in DBI.xs */
D_imp_dbh(dbh);
ST(0) = &PL_sv_yes;
if (!DBIc_IMPSET(imp_dbh)) { /* was never fully set up */
STRLEN lna;
if (DBIc_WARN(imp_dbh) && !PL_dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2)
PerlIO_printf(DBIc_LOGPIO(imp_dbh),
" DESTROY for %s ignored - handle not initialised\n",
SvPV(dbh,lna));
}
else {
if (DBIc_IADESTROY(imp_dbh)) { /* wants ineffective destroy */
DBIc_ACTIVE_off(imp_dbh);
if (DBIc_DBISTATE(imp_dbh)->debug)
PerlIO_printf(DBIc_LOGPIO(imp_dbh), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(dbh));
}
if (DBIc_ACTIVE(imp_dbh)) {
if (!DBIc_has(imp_dbh,DBIcf_AutoCommit)) {
/* Application is using transactions and hasn't explicitly disconnected.
Some databases will automatically commit on graceful disconnect.
Since we're about to gracefully disconnect as part of the DESTROY
we want to be sure we're not about to implicitly commit changes
that are incomplete and should be rolled back. (The DESTROY may
be due to a RaiseError, for example.) So we rollback here.
This will be harmless if the application has issued a commit,
XXX Could add an attribute flag to indicate that the driver
doesn't have this problem. Patches welcome.
*/
if (DBIc_WARN(imp_dbh) /* only warn if likely to be useful... */
&& DBIc_is(imp_dbh, DBIcf_Executed) /* has not just called commit/rollback */
/* && !DBIc_is(imp_dbh, DBIcf_ReadOnly) -- is not read only */
&& (!PL_dirty || DBIc_DBISTATE(imp_dbh)->debug >= 3)
) {
warn("Issuing rollback() due to DESTROY without explicit disconnect() of %s handle %s",
SvPV_nolen(*hv_fetch((HV*)SvRV(dbh), "ImplementorClass", 16, 1)),
SvPV_nolen(*hv_fetch((HV*)SvRV(dbh), "Name", 4, 1))
);
}
dbd_db_rollback(dbh, imp_dbh); /* ROLLBACK! */
}
dbd_db_disconnect(dbh, imp_dbh);
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
}
dbd_db_destroy(dbh, imp_dbh);
}
#ifdef dbd_take_imp_data
void
take_imp_data(h)
SV * h
CODE:
D_imp_xxh(h);
/* dbd_take_imp_data() returns &sv_no (or other defined but false value)
* to indicate "preparations complete, now call SUPER::take_imp_data" for me.
* Anything else is returned to the caller via sv_2mortal(sv), typically that
* would be &sv_undef for error or an SV holding the imp_data.
*/
SV *sv = dbd_take_imp_data(h, imp_xxh, NULL);
if (SvOK(sv) && !SvTRUE(sv)) {
SV *tmp = dbixst_bounce_method("DBD::~DRIVER~::db::SUPER::take_imp_data", items);
SPAGAIN;
ST(0) = tmp;
} else {
ST(0) = sv_2mortal(sv);
}
#endif
#ifdef dbd_db_data_sources
void
data_sources(dbh, attr = Nullsv)
SV *dbh
SV *attr
PPCODE:
{
D_imp_dbh(dbh);
AV *av = dbd_db_data_sources(dbh, imp_dbh, attr);
if (av) {
int i;
int n = AvFILL(av)+1;
EXTEND(sp, n);
for (i = 0; i < n; ++i) {
PUSHs(AvARRAY(av)[i]);
}
}
}
#endif
# -- end of DBD::~DRIVER~::db
# ------------------------------------------------------------
# statement interface
# ------------------------------------------------------------
MODULE = DBD::~DRIVER~ PACKAGE = DBD::~DRIVER~::st
bool
_prepare(sth, statement, attribs=Nullsv)
SV * sth
SV * statement
SV * attribs
CODE:
{
D_imp_sth(sth);
DBD_ATTRIBS_CHECK("_prepare", sth, attribs);
#ifdef dbd_st_prepare_sv
RETVAL = dbd_st_prepare_sv(sth, imp_sth, statement, attribs);
#else
RETVAL = dbd_st_prepare(sth, imp_sth, SvPV_nolen(statement), attribs);
#endif
}
OUTPUT:
RETVAL
#ifdef dbd_st_rows
void
rows(sth)
SV * sth
CODE:
D_imp_sth(sth);
XST_mIV(0, dbd_st_rows(sth, imp_sth));
#endif /* dbd_st_rows */
#ifdef dbd_st_bind_col
bool
bind_col(sth, col, ref, attribs=Nullsv)
SV * sth
SV * col
SV * ref
SV * attribs
CODE:
{
IV sql_type = 0;
D_imp_sth(sth);
if (SvGMAGICAL(ref))
mg_get(ref);
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_col", sth, attribs);
/* XXX we should perhaps complain if TYPE is not SvNIOK */
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
}
}
switch(dbd_st_bind_col(sth, imp_sth, col, ref, sql_type, attribs)) {
case 2: RETVAL = TRUE; /* job done completely */
break;
case 1: /* fallback to DBI default */
RETVAL = DBIc_DBISTATE(imp_sth)->bind_col(sth, col, ref, attribs);
break;
default: RETVAL = FALSE; /* dbd_st_bind_col has called set_err */
break;
}
}
OUTPUT:
RETVAL
#endif /* dbd_st_bind_col */
bool
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 (SvGMAGICAL(value))
mg_get(value);
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);
}
}
RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0);
}
OUTPUT:
RETVAL
bool
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);
SV *value;
if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG)
croak("bind_param_inout needs a reference to a scalar value");
value = SvRV(value_ref);
if (SvREADONLY(value))
croak("Modification of a read-only value attempted");
if (SvGMAGICAL(value))
mg_get(value);
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);
}
}
RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, TRUE, maxlen);
}
OUTPUT:
RETVAL
void
execute(sth, ...)
SV * sth
CODE:
D_imp_sth(sth);
IV retval;
if (items > 1) { /* need to bind params */
if (!dbdxst_bind_params(sth, imp_sth, items, ax) ) {
XSRETURN_UNDEF;
}
}
/* XXX this code is duplicated in selectrow_arrayref above */
DBIc_ROW_COUNT(imp_sth) = 0;
retval = dbd_st_execute(sth, imp_sth); /* might be dbd_st_execute_iv via macro */
/* remember that dbd_st_execute must return <= -2 for error */
if (retval == 0) /* ok with no rows affected */
XST_mPV(0, "0E0"); /* (true but zero) */
else if (retval < -1) /* -1 == unknown number of rows */
XST_mUNDEF(0); /* <= -2 means error */
else
XST_mIV(0, retval); /* typically 1, rowcount or -1 */
#ifdef dbd_st_execute_for_fetch
void
execute_for_fetch(sth, fetch_tuple_sub, tuple_status = Nullsv)
SV * sth
SV * fetch_tuple_sub
SV * tuple_status
CODE:
{
D_imp_sth(sth);
SV *ret = dbd_st_execute_for_fetch(sth, imp_sth, fetch_tuple_sub, tuple_status);
ST(0) = ret;
}
#endif
#ifdef dbd_st_last_insert_id
void
last_insert_id(sth, catalog=&PL_sv_undef, schema=&PL_sv_undef, table=&PL_sv_undef, field=&PL_sv_undef, attr=Nullsv)
SV * sth
SV * catalog
SV * schema
SV * table
SV * field
SV * attr
CODE:
{
D_imp_sth(sth);
SV *ret = dbd_st_last_insert_id(sth, imp_sth, catalog, schema, table, field, attr);
ST(0) = ret;
}
#endif
void
fetchrow_arrayref(sth)
SV * sth
ALIAS:
fetch = 1
CODE:
D_imp_sth(sth);
AV *av;
PERL_UNUSED_VAR(ix);
av = dbd_st_fetch(sth, imp_sth);
ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_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 i;
int num_fields = AvFILL(av)+1;
EXTEND(sp, num_fields);
for(i=0; i < num_fields; ++i) {
PUSHs(AvARRAY(av)[i]);
}
PERL_UNUSED_VAR(ix);
}
void
fetchall_arrayref(sth, slice=&PL_sv_undef, batch_row_count=&PL_sv_undef)
SV * sth
SV * slice
SV * batch_row_count
CODE:
if (SvOK(slice)) { /* fallback to perl implementation */
SV *tmp = dbixst_bounce_method("DBD::~DRIVER~::st::SUPER::fetchall_arrayref", 3);
SPAGAIN;
ST(0) = tmp;
}
else {
SV *tmp = dbdxst_fetchall_arrayref(sth, slice, batch_row_count);
SPAGAIN;
ST(0) = tmp;
}
bool
finish(sth)
SV * sth
CODE:
D_imp_sth(sth);
D_imp_dbh_from_sth;
if (!DBIc_ACTIVE(imp_sth)) {
/* No active statement to finish */
XSRETURN_YES;
}
if (!DBIc_ACTIVE(imp_dbh)) {
/* Either an explicit disconnect() or global destruction */
/* has disconnected us from the database. Finish is meaningless */
DBIc_ACTIVE_off(imp_sth);
XSRETURN_YES;
}
#ifdef dbd_st_finish3
RETVAL = dbd_st_finish3(sth, imp_sth, 0);
#else
RETVAL = dbd_st_finish(sth, imp_sth);
#endif
OUTPUT:
RETVAL
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(sv_2mortal(newSV(0))));
if (dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset))
ST(0) = SvRV(destrv);
else ST(0) = &PL_sv_undef;
}
void
STORE(sth, keysv, valuesv)
SV * sth
SV * keysv
SV * valuesv
CODE:
D_imp_sth(sth);
if (SvGMAGICAL(valuesv))
mg_get(valuesv);
ST(0) = &PL_sv_yes;
if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv))
if (!DBIc_DBISTATE(imp_sth)->set_attr(sth, keysv, valuesv))
ST(0) = &PL_sv_no;
# FETCH renamed and ALIAS'd 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;
PERL_UNUSED_VAR(ix);
valuesv = dbd_st_FETCH_attrib(sth, imp_sth, keysv);
if (!valuesv)
valuesv = DBIc_DBISTATE(imp_sth)->get_attr(sth, keysv);
ST(0) = valuesv; /* dbd_st_FETCH_attrib did sv_2mortal */
void
DESTROY(sth)
SV * sth
PPCODE:
/* keep in sync with default DESTROY in DBI.xs */
D_imp_sth(sth);
ST(0) = &PL_sv_yes;
if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */
STRLEN lna;
if (DBIc_WARN(imp_sth) && !PL_dirty && DBIc_DBISTATE(imp_sth)->debug >= 2)
PerlIO_printf(DBIc_LOGPIO(imp_sth),
" DESTROY for %s ignored - handle not initialised\n",
SvPV(sth,lna));
}
else {
if (DBIc_IADESTROY(imp_sth)) { /* wants ineffective destroy */
DBIc_ACTIVE_off(imp_sth);
if (DBIc_DBISTATE(imp_sth)->debug)
PerlIO_printf(DBIc_LOGPIO(imp_sth), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(sth));
}
if (DBIc_ACTIVE(imp_sth)) {
D_imp_dbh_from_sth;
if (!PL_dirty && DBIc_ACTIVE(imp_dbh)) {
#ifdef dbd_st_finish3
dbd_st_finish3(sth, imp_sth, 1);
#else
dbd_st_finish(sth, imp_sth);
#endif
}
else {
DBIc_ACTIVE_off(imp_sth);
}
}
dbd_st_destroy(sth, imp_sth);
}
# end of ~DRIVER~.xst
# vim:ts=8:sw=4:et

View File

@@ -0,0 +1,122 @@
/*
# $Id$
# Copyright (c) 2002 Tim Bunce Ireland
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
*/
/* This is really just a workaround for SUPER:: not working right for XS code.
* It would be better if we setup perl's context so SUPER:: did the right thing
* (borrowing the relevant magic from pp_entersub in perl pp_hot.c).
* Then we could just use call_method("SUPER::foo") instead.
* XXX remember to call SPAGAIN in the calling code after calling this!
*/
static SV *
dbixst_bounce_method(char *methname, int params)
{
dTHX;
/* XXX this 'magic' undoes the dMARK embedded in the dXSARGS of our caller */
/* so that the dXSARGS below can set things up as they were for our caller */
void *xxx = PL_markstack_ptr++;
dXSARGS; /* declares sp, ax, mark, items */
int i;
SV *sv;
int debug = 0;
D_imp_xxh(ST(0));
if (debug >= 3) {
PerlIO_printf(DBIc_LOGPIO(imp_xxh),
" -> %s (trampoline call with %d (%ld) params)\n", methname, params, (long)items);
PERL_UNUSED_VAR(xxx);
}
EXTEND(SP, params);
PUSHMARK(SP);
for (i=0; i < params; ++i) {
sv = (i >= items) ? &PL_sv_undef : ST(i);
PUSHs(sv);
}
PUTBACK;
i = call_method(methname, G_SCALAR);
SPAGAIN;
sv = (i) ? POPs : &PL_sv_undef;
PUTBACK;
if (debug >= 3)
PerlIO_printf(DBIc_LOGPIO(imp_xxh),
" <- %s= %s (trampoline call return)\n", methname, neatsvpv(sv,0));
return sv;
}
static int
dbdxst_bind_params(SV *sth, imp_sth_t *imp_sth, I32 items, I32 ax)
{
/* Handle binding supplied values to placeholders. */
/* items = one greater than the number of params */
/* ax = ax from calling sub, maybe adjusted to match items */
dTHX;
int i;
SV *idx;
if (items-1 != DBIc_NUM_PARAMS(imp_sth)
&& DBIc_NUM_PARAMS(imp_sth) != DBIc_NUM_PARAMS_AT_EXECUTE
) {
char errmsg[99];
/* clear any previous ParamValues before error is generated */
SV **svp = hv_fetch((HV*)DBIc_MY_H(imp_sth),"ParamValues",11,FALSE);
if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) {
HV *hv = (HV*)SvRV(*svp);
hv_clear(hv);
}
sprintf(errmsg,"called with %d bind variables when %d are needed",
(int)items-1, DBIc_NUM_PARAMS(imp_sth));
DBIh_SET_ERR_CHAR(sth, (imp_xxh_t*)imp_sth, "-1", -1, errmsg, Nullch, Nullch);
return 0;
}
idx = sv_2mortal(newSViv(0));
for(i=1; i < items ; ++i) {
SV* value = ST(i);
if (SvGMAGICAL(value))
mg_get(value); /* trigger magic to FETCH the value */
sv_setiv(idx, i);
if (!dbd_bind_ph(sth, imp_sth, idx, value, 0, Nullsv, FALSE, 0)) {
return 0; /* dbd_bind_ph already registered error */
}
}
return 1;
}
#ifndef dbd_fetchall_arrayref
static SV *
dbdxst_fetchall_arrayref(SV *sth, SV *slice, SV *batch_row_count)
{
dTHX;
D_imp_sth(sth);
SV *rows_rvav;
if (SvOK(slice)) { /* should never get here */
char errmsg[99];
sprintf(errmsg,"slice param not supported by XS version of fetchall_arrayref");
DBIh_SET_ERR_CHAR(sth, (imp_xxh_t*)imp_sth, "-1", -1, errmsg, Nullch, Nullch);
return &PL_sv_undef;
}
else {
IV maxrows = SvOK(batch_row_count) ? SvIV(batch_row_count) : -1;
AV *fetched_av;
AV *rows_av = newAV();
if ( !DBIc_ACTIVE(imp_sth) && maxrows>0 ) {
/* to simplify application logic we return undef without an error */
/* if we've fetched all the rows and called with a batch_row_count */
return &PL_sv_undef;
}
av_extend(rows_av, (maxrows>0) ? maxrows : 31);
while ( (maxrows < 0 || maxrows-- > 0)
&& (fetched_av = dbd_st_fetch(sth, imp_sth))
) {
AV *copy_row_av = av_make(AvFILL(fetched_av)+1, AvARRAY(fetched_av));
av_push(rows_av, newRV_noinc((SV*)copy_row_av));
}
rows_rvav = sv_2mortal(newRV_noinc((SV *)rows_av));
}
return rows_rvav;
}
#endif

View File

@@ -0,0 +1,63 @@
/* @(#)$Id$
*
* Copyright 2000-2002 Tim Bunce
* Copyright 2002 Jonathan Leffler
*
* These prototypes are for dbdimp.c funcs used in the XS file.
* These names are #defined to driver specific names by the
* dbdimp.h file in the driver source.
*/
#ifndef DBI_DBD_XSH_H
#define DBI_DBD_XSH_H
void dbd_init _((dbistate_t *dbistate));
int dbd_discon_all _((SV *drh, imp_drh_t *imp_drh));
SV *dbd_take_imp_data _((SV *h, imp_xxh_t *imp_xxh, void *foo));
/* Support for dbd_dr_data_sources and dbd_db_do added to Driver.xst in DBI v1.33 */
/* dbd_dr_data_sources: optional: defined by a driver that calls a C */
/* function to get the list of data sources */
AV *dbd_dr_data_sources(SV *drh, imp_drh_t *imp_drh, SV *attrs);
int dbd_db_login6_sv _((SV *dbh, imp_dbh_t *imp_dbh, SV *dbname, SV *uid, SV *pwd, SV*attribs));
int dbd_db_login6 _((SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, SV*attribs)); /* deprecated */
int dbd_db_login _((SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd)); /* deprecated */
/* Note: interface of dbd_db_do changed in v1.33 */
/* Old prototype: dbd_db_do _((SV *sv, char *statement)); */
/* dbd_db_do: optional: defined by a driver if the DBI default version is too slow */
int dbd_db_do4 _((SV *dbh, imp_dbh_t *imp_dbh, char *statement, SV *params)); /* deprecated */
IV dbd_db_do4_iv _((SV *dbh, imp_dbh_t *imp_dbh, char *statement, SV *params)); /* deprecated */
IV dbd_db_do6 _((SV *dbh, imp_dbh_t *imp_dbh, SV *statement, SV *params, I32 items, I32 ax));
int dbd_db_commit _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_rollback _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_disconnect _((SV *dbh, imp_dbh_t *imp_dbh));
void dbd_db_destroy _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_STORE_attrib _((SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv));
SV *dbd_db_FETCH_attrib _((SV *dbh, imp_dbh_t *imp_dbh, SV *keysv));
SV *dbd_db_last_insert_id _((SV *dbh, imp_dbh_t *imp_dbh, SV *catalog, SV *schema, SV *table, SV *field, SV *attr));
AV *dbd_db_data_sources _((SV *dbh, imp_dbh_t *imp_dbh, SV *attr));
int dbd_st_prepare _((SV *sth, imp_sth_t *imp_sth, char *statement, SV *attribs)); /* deprecated */
int dbd_st_prepare_sv _((SV *sth, imp_sth_t *imp_sth, SV *statement, SV *attribs));
int dbd_st_rows _((SV *sth, imp_sth_t *imp_sth)); /* deprecated */
IV dbd_st_rows_iv _((SV *sth, imp_sth_t *imp_sth));
int dbd_st_execute _((SV *sth, imp_sth_t *imp_sth)); /* deprecated */
IV dbd_st_execute_iv _((SV *sth, imp_sth_t *imp_sth));
SV *dbd_st_last_insert_id _((SV *sth, imp_sth_t *imp_sth, SV *catalog, SV *schema, SV *table, SV *field, SV *attr));
AV *dbd_st_fetch _((SV *sth, imp_sth_t *imp_sth));
int dbd_st_finish3 _((SV *sth, imp_sth_t *imp_sth, int from_destroy));
int dbd_st_finish _((SV *sth, imp_sth_t *imp_sth)); /* deprecated */
void dbd_st_destroy _((SV *sth, imp_sth_t *imp_sth));
int dbd_st_blob_read _((SV *sth, imp_sth_t *imp_sth,
int field, long offset, long len, SV *destrv, long destoffset));
int dbd_st_STORE_attrib _((SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv));
SV *dbd_st_FETCH_attrib _((SV *sth, imp_sth_t *imp_sth, SV *keysv));
SV *dbd_st_execute_for_fetch _((SV *sth, imp_sth_t *imp_sth, SV *fetch_tuple_sub, SV *tuple_status));
int dbd_bind_ph _((SV *sth, imp_sth_t *imp_sth,
SV *param, SV *value, IV sql_type, SV *attribs,
int is_inout, IV maxlen));
#endif /* end of dbd_xsh.h */

View File

@@ -0,0 +1,96 @@
/* $Id$
*
* Copyright (c) 1997,1998,1999 Tim Bunce England
*
* See COPYRIGHT section in DBI.pm for usage and distribution rights.
*/
/* Some core SQL CLI standard (ODBC) declarations */
#ifndef SQL_SUCCESS /* don't clash with ODBC based drivers */
/* SQL datatype codes */
#define SQL_GUID (-11)
#define SQL_WLONGVARCHAR (-10)
#define SQL_WVARCHAR (-9)
#define SQL_WCHAR (-8)
#define SQL_BIT (-7)
#define SQL_TINYINT (-6)
#define SQL_BIGINT (-5)
#define SQL_LONGVARBINARY (-4)
#define SQL_VARBINARY (-3)
#define SQL_BINARY (-2)
#define SQL_LONGVARCHAR (-1)
#define SQL_UNKNOWN_TYPE 0
#define SQL_ALL_TYPES 0
#define SQL_CHAR 1
#define SQL_NUMERIC 2
#define SQL_DECIMAL 3
#define SQL_INTEGER 4
#define SQL_SMALLINT 5
#define SQL_FLOAT 6
#define SQL_REAL 7
#define SQL_DOUBLE 8
#define SQL_DATETIME 9
#define SQL_DATE 9
#define SQL_INTERVAL 10
#define SQL_TIME 10
#define SQL_TIMESTAMP 11
#define SQL_VARCHAR 12
#define SQL_BOOLEAN 16
#define SQL_UDT 17
#define SQL_UDT_LOCATOR 18
#define SQL_ROW 19
#define SQL_REF 20
#define SQL_BLOB 30
#define SQL_BLOB_LOCATOR 31
#define SQL_CLOB 40
#define SQL_CLOB_LOCATOR 41
#define SQL_ARRAY 50
#define SQL_ARRAY_LOCATOR 51
#define SQL_MULTISET 55
#define SQL_MULTISET_LOCATOR 56
#define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93
#define SQL_TYPE_TIME_WITH_TIMEZONE 94
#define SQL_TYPE_TIMESTAMP_WITH_TIMEZONE 95
#define SQL_INTERVAL_YEAR 101
#define SQL_INTERVAL_MONTH 102
#define SQL_INTERVAL_DAY 103
#define SQL_INTERVAL_HOUR 104
#define SQL_INTERVAL_MINUTE 105
#define SQL_INTERVAL_SECOND 106
#define SQL_INTERVAL_YEAR_TO_MONTH 107
#define SQL_INTERVAL_DAY_TO_HOUR 108
#define SQL_INTERVAL_DAY_TO_MINUTE 109
#define SQL_INTERVAL_DAY_TO_SECOND 110
#define SQL_INTERVAL_HOUR_TO_MINUTE 111
#define SQL_INTERVAL_HOUR_TO_SECOND 112
#define SQL_INTERVAL_MINUTE_TO_SECOND 113
/* Main return codes */
#define SQL_ERROR (-1)
#define SQL_SUCCESS 0
#define SQL_SUCCESS_WITH_INFO 1
#define SQL_NO_DATA_FOUND 100
/*
* for ODBC SQL Cursor Types
*/
#define SQL_CURSOR_FORWARD_ONLY 0UL
#define SQL_CURSOR_KEYSET_DRIVEN 1UL
#define SQL_CURSOR_DYNAMIC 2UL
#define SQL_CURSOR_STATIC 3UL
#define SQL_CURSOR_TYPE_DEFAULT SQL_CURSOR_FORWARD_ONLY
#endif /* SQL_SUCCESS */
/* Handy macro for testing for success and success with info. */
/* BEWARE that this macro can have side effects since rc appears twice! */
/* So DONT use it as if(SQL_ok(func(...))) { ... } */
#define SQL_ok(rc) ((rc)==SQL_SUCCESS || (rc)==SQL_SUCCESS_WITH_INFO)
/* end of dbi_sql.h */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
/* dbivport.h
Provides macros that enable greater portability between DBI versions.
This file should be *copied* and included in driver distributions
and #included into the source, after #include DBIXS.h
New driver releases should include an updated copy of dbivport.h
from the most recent DBI release.
*/
#ifndef DBI_VPORT_H
#define DBI_VPORT_H
#ifndef DBIh_SET_ERR_CHAR
/* Emulate DBIh_SET_ERR_CHAR
Only uses the err_i, errstr and state parameters.
*/
#define DBIh_SET_ERR_CHAR(h, imp_xxh, err_c, err_i, errstr, state, method) \
sv_setiv(DBIc_ERR(imp_xxh), err_i); \
(state) ? (void)sv_setpv(DBIc_STATE(imp_xxh), state) : (void)SvOK_off(DBIc_STATE(imp_xxh)); \
sv_setpv(DBIc_ERRSTR(imp_xxh), errstr)
#endif
#ifndef DBIcf_Executed
#define DBIcf_Executed 0x080000
#endif
#ifndef DBIc_TRACE_LEVEL_MASK
#define DBIc_TRACE_LEVEL_MASK 0x0000000F
#define DBIc_TRACE_FLAGS_MASK 0xFFFFFF00
#define DBIc_TRACE_SETTINGS(imp) (DBIc_DBISTATE(imp)->debug)
#define DBIc_TRACE_LEVEL(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_LEVEL_MASK)
#define DBIc_TRACE_FLAGS(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_FLAGS_MASK)
/* DBIc_TRACE_MATCHES - true if s1 'matches' s2 (c.f. trace_msg())
DBIc_TRACE_MATCHES(foo, DBIc_TRACE_SETTINGS(imp))
*/
#define DBIc_TRACE_MATCHES(s1, s2) \
( ((s1 & DBIc_TRACE_LEVEL_MASK) >= (s2 & DBIc_TRACE_LEVEL_MASK)) \
|| ((s1 & DBIc_TRACE_FLAGS_MASK) & (s2 & DBIc_TRACE_FLAGS_MASK)) )
/* DBIc_TRACE - true if flags match & DBI level>=flaglevel, or if DBI level>level
DBIc_TRACE(imp, 0, 0, 4) = if level >= 4
DBIc_TRACE(imp, DBDtf_FOO, 2, 4) = if tracing DBDtf_FOO & level>=2 or level>=4
DBIc_TRACE(imp, DBDtf_FOO, 2, 0) = as above but never trace just due to level
*/
#define DBIc_TRACE(imp, flags, flaglevel, level) \
( (flags && (DBIc_TRACE_FLAGS(imp) & flags) && (DBIc_TRACE_LEVEL(imp) >= flaglevel)) \
|| (level && DBIc_TRACE_LEVEL(imp) >= level) )
#endif
#endif /* !DBI_VPORT_H */

View File

@@ -0,0 +1,3 @@
/* Fri Jul 13 13:32:02 2012 */
/* Mixed revision working copy (15349:15353) */
#define DBIXS_REVISION 15349