[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* $Id: DBIXS.h 11337 2008-05-28 13:01:15Z timbo $ 2 * 3 * Copyright (c) 1994-2002 Tim Bunce Ireland 4 * 5 * See COPYRIGHT section in DBI.pm for usage and distribution rights. 6 */ 7 8 /* DBI Interface Definitions for DBD Modules */ 9 10 #ifndef DBIXS_VERSION /* prevent multiple inclusion */ 11 12 #ifndef DBIS 13 #define DBIS dbis /* default name for dbistate_t variable */ 14 #endif 15 16 /* first pull in the standard Perl header files for extensions */ 17 #define PERL_POLLUTE 18 #include <EXTERN.h> 19 #include <perl.h> 20 #include <XSUB.h> 21 22 #ifdef debug /* causes problems with DBIS->debug */ 23 #undef debug 24 #endif 25 26 #ifdef std /* causes problems with STLport <tscheresky@micron.com> */ 27 #undef std 28 #endif 29 30 /* define DBIXS_REVISION */ 31 #include "dbixs_rev.h" 32 33 /* Perl backwards compatibility definitions */ 34 #include "dbipport.h" 35 36 /* DBI SQL_* type definitions */ 37 #include "dbi_sql.h" 38 39 40 /* The DBIXS_VERSION value will be incremented whenever new code is 41 * added to the interface (this file) or significant changes are made. 42 * It's primary goal is to allow newer drivers to compile against an 43 * older installed DBI. This is mainly an issue whilst the API grows 44 * and learns from the needs of various drivers. See also the 45 * DBISTATE_VERSION macro below. You can think of DBIXS_VERSION as 46 * being a compile time check and DBISTATE_VERSION as a runtime check. 47 * By contract, DBIXS_REVISION is a driver source compatibility tool. 48 */ 49 #define DBIXS_VERSION 93 50 51 #ifdef NEED_DBIXS_VERSION 52 #if NEED_DBIXS_VERSION > DBIXS_VERSION 53 error You_need_to_upgrade_your_DBI_module_before_building_this_driver 54 #endif 55 #else 56 #define NEED_DBIXS_VERSION DBIXS_VERSION 57 #endif 58 59 60 #define DBI_LOCK 61 #define DBI_UNLOCK 62 63 #ifndef DBI_NO_THREADS 64 #ifdef USE_ITHREADS 65 #define DBI_USE_THREADS 66 #endif /* USE_ITHREADS */ 67 #endif /* DBI_NO_THREADS */ 68 69 70 /* forward struct declarations */ 71 72 typedef struct dbistate_st dbistate_t; 73 /* implementor needs to define actual struct { dbih_??c_t com; ... }*/ 74 typedef struct imp_drh_st imp_drh_t; /* driver */ 75 typedef struct imp_dbh_st imp_dbh_t; /* database */ 76 typedef struct imp_sth_st imp_sth_t; /* statement */ 77 typedef struct imp_fdh_st imp_fdh_t; /* field descriptor */ 78 typedef struct imp_xxh_st imp_xxh_t; /* any (defined below) */ 79 #define DBI_imp_data_ imp_xxh_t /* friendly for take_imp_data */ 80 81 82 83 /* --- DBI Handle Common Data Structure (all handles have one) --- */ 84 85 /* Handle types. Code currently assumes child = parent + 1. */ 86 #define DBIt_DR 1 87 #define DBIt_DB 2 88 #define DBIt_ST 3 89 #define DBIt_FD 4 90 91 /* component structures */ 92 93 typedef struct dbih_com_std_st { 94 U32 flags; 95 int call_depth; /* used by DBI to track nested calls (int) */ 96 U16 type; /* DBIt_DR, DBIt_DB, DBIt_ST */ 97 HV *my_h; /* copy of outer handle HV (not refcounted) */ 98 SV *parent_h; /* parent inner handle (ref to hv) (r.c.inc) */ 99 imp_xxh_t *parent_com; /* parent com struct shortcut */ 100 PerlInterpreter * thr_user; /* thread that owns the handle */ 101 102 HV *imp_stash; /* who is the implementor for this handle */ 103 SV *imp_data; /* optional implementors data (for perl imp's) */ 104 105 I32 kids; /* count of db's for dr's, st's for db's etc */ 106 I32 active_kids; /* kids which are currently DBIc_ACTIVE */ 107 U32 pad; /* keep binary compat */ 108 dbistate_t *dbistate; 109 } dbih_com_std_t; 110 111 typedef struct dbih_com_attr_st { 112 /* These are copies of the Hash values (ref.cnt.inc'd) */ 113 /* Many of the hash values are themselves references */ 114 SV *TraceLevel; 115 SV *State; /* Standard SQLSTATE, 5 char string */ 116 SV *Err; /* Native engine error code */ 117 SV *Errstr; /* Native engine error message */ 118 UV ErrCount; 119 U32 LongReadLen; /* auto read length for long/blob types */ 120 SV *FetchHashKeyName; /* for fetchrow_hashref */ 121 /* (NEW FIELDS?... DON'T FORGET TO UPDATE dbih_clearcom()!) */ 122 } dbih_com_attr_t; 123 124 125 struct dbih_com_st { /* complete core structure (typedef'd above) */ 126 dbih_com_std_t std; 127 dbih_com_attr_t attr; 128 }; 129 130 /* This 'implementors' type the DBI defines by default as a way to */ 131 /* refer to the imp_??h data of a handle without considering its type. */ 132 struct imp_xxh_st { struct dbih_com_st com; }; 133 134 /* Define handle-type specific structures for implementors to include */ 135 /* at the start of their private structures. */ 136 137 typedef struct { /* -- DRIVER -- */ 138 dbih_com_std_t std; 139 dbih_com_attr_t attr; 140 HV *_old_cached_kids; /* not used, here for binary compat */ 141 } dbih_drc_t; 142 143 typedef struct { /* -- DATABASE -- */ 144 dbih_com_std_t std; /* \__ standard structure */ 145 dbih_com_attr_t attr; /* / plus... (nothing else right now) */ 146 HV *_old_cached_kids; /* not used, here for binary compat */ 147 } dbih_dbc_t; 148 149 typedef struct { /* -- STATEMENT -- */ 150 dbih_com_std_t std; /* \__ standard structure */ 151 dbih_com_attr_t attr; /* / plus ... */ 152 153 int num_params; /* number of placeholders */ 154 int num_fields; /* NUM_OF_FIELDS, must be set */ 155 AV *fields_svav; /* special row buffer (inc bind_cols) */ 156 IV row_count; /* incremented by get_fbav() */ 157 158 AV *fields_fdav; /* not used yet, may change */ 159 160 I32 spare1; 161 void *spare2; 162 } dbih_stc_t; 163 164 165 /* XXX THIS STRUCTURE SHOULD NOT BE USED */ 166 typedef struct { /* -- FIELD DESCRIPTOR -- */ 167 dbih_com_std_t std; /* standard structure (not fully setup) */ 168 169 /* core attributes (from DescribeCol in ODBC) */ 170 char *col_name; /* see dbih_make_fdsv */ 171 I16 col_name_len; 172 I16 col_sql_type; 173 I16 col_precision; 174 I16 col_scale; 175 I16 col_nullable; 176 177 /* additional attributes (from ColAttributes in ODBC) */ 178 I32 col_length; 179 I32 col_disp_size; 180 181 I32 spare1; 182 void *spare2; 183 } dbih_fdc_t; 184 185 186 #define _imp2com(p,f) ((p)->com.f) 187 188 #define DBIc_FLAGS(imp) _imp2com(imp, std.flags) 189 #define DBIc_TYPE(imp) _imp2com(imp, std.type) 190 #define DBIc_CALL_DEPTH(imp) _imp2com(imp, std.call_depth) 191 #define DBIc_MY_H(imp) _imp2com(imp, std.my_h) 192 #define DBIc_PARENT_H(imp) _imp2com(imp, std.parent_h) 193 #define DBIc_PARENT_COM(imp) _imp2com(imp, std.parent_com) 194 #define DBIc_THR_COND(imp) _imp2com(imp, std.thr_cond) 195 #define DBIc_THR_USER(imp) _imp2com(imp, std.thr_user) 196 #define DBIc_THR_USER_NONE (0xFFFF) 197 #define DBIc_IMP_STASH(imp) _imp2com(imp, std.imp_stash) 198 #define DBIc_IMP_DATA(imp) _imp2com(imp, std.imp_data) 199 #define DBIc_DBISTATE(imp) _imp2com(imp, std.dbistate) 200 #define DBIc_LOGPIO(imp) DBIc_DBISTATE(imp)->logfp 201 #define DBIc_KIDS(imp) _imp2com(imp, std.kids) 202 #define DBIc_ACTIVE_KIDS(imp) _imp2com(imp, std.active_kids) 203 #define DBIc_LAST_METHOD(imp) _imp2com(imp, std.last_method) 204 205 #define DBIc_TRACE_LEVEL_MASK 0x0000000F 206 #define DBIc_TRACE_FLAGS_MASK 0xFFFFFF00 207 #define DBIc_TRACE_SETTINGS(imp) (DBIc_DBISTATE(imp)->debug) 208 #define DBIc_TRACE_LEVEL(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_LEVEL_MASK) 209 #define DBIc_TRACE_FLAGS(imp) (DBIc_TRACE_SETTINGS(imp) & DBIc_TRACE_FLAGS_MASK) 210 /* DBIc_TRACE_MATCHES(this, crnt): true if this 'matches' (is within) crnt 211 DBIc_TRACE_MATCHES(foo, DBIc_TRACE_SETTINGS(imp)) 212 */ 213 #define DBIc_TRACE_MATCHES(this, crnt) \ 214 ( ((crnt & DBIc_TRACE_LEVEL_MASK) >= (this & DBIc_TRACE_LEVEL_MASK)) \ 215 || ((crnt & DBIc_TRACE_FLAGS_MASK) & (this & DBIc_TRACE_FLAGS_MASK)) ) 216 /* DBIc_TRACE: true if flags match & DBI level>=flaglevel, or if DBI level>level 217 This is the main trace testing macro to be used by drivers. 218 (Drivers should define their own DBDtf_* macros for the top 8 bits: 0xFF000000) 219 DBIc_TRACE(imp, 0, 0, 4) = if level >= 4 220 DBIc_TRACE(imp, DBDtf_FOO, 2, 4) = if tracing DBDtf_FOO & level>=2 or level>=4 221 DBIc_TRACE(imp, DBDtf_FOO, 2, 0) = as above but never trace just due to level 222 */ 223 #define DBIc_TRACE(imp, flags, flaglevel, level) \ 224 ( (flags && (DBIc_TRACE_FLAGS(imp) & flags) && (DBIc_TRACE_LEVEL(imp) >= flaglevel)) \ 225 || (level && DBIc_TRACE_LEVEL(imp) >= level) ) 226 227 #define DBIc_DEBUG(imp) (_imp2com(imp, attr.TraceLevel)) /* deprecated */ 228 #define DBIc_DEBUGIV(imp) SvIV(DBIc_DEBUG(imp)) /* deprecated */ 229 #define DBIc_STATE(imp) SvRV(_imp2com(imp, attr.State)) 230 #define DBIc_ERR(imp) SvRV(_imp2com(imp, attr.Err)) 231 #define DBIc_ERRSTR(imp) SvRV(_imp2com(imp, attr.Errstr)) 232 #define DBIc_ErrCount(imp) _imp2com(imp, attr.ErrCount) 233 #define DBIc_LongReadLen(imp) _imp2com(imp, attr.LongReadLen) 234 #define DBIc_LongReadLen_init 80 /* may change */ 235 #define DBIc_FetchHashKeyName(imp) (_imp2com(imp, attr.FetchHashKeyName)) 236 237 /* handle sub-type specific fields */ 238 /* dbh & drh */ 239 #define DBIc_CACHED_KIDS(imp) Nullhv /* no longer used, here for src compat */ 240 /* sth */ 241 #define DBIc_NUM_FIELDS(imp) _imp2com(imp, num_fields) 242 #define DBIc_NUM_PARAMS(imp) _imp2com(imp, num_params) 243 #define DBIc_NUM_PARAMS_AT_EXECUTE -9 /* see Driver.xst */ 244 #define DBIc_ROW_COUNT(imp) _imp2com(imp, row_count) 245 #define DBIc_FIELDS_AV(imp) _imp2com(imp, fields_svav) 246 #define DBIc_FDESC_AV(imp) _imp2com(imp, fields_fdav) 247 #define DBIc_FDESC(imp, i) ((imp_fdh_t*)(void*)SvPVX(AvARRAY(DBIc_FDESC_AV(imp))[i])) 248 249 /* XXX --- DO NOT CHANGE THESE VALUES AS THEY ARE COMPILED INTO DRIVERS --- XXX */ 250 #define DBIcf_COMSET 0x000001 /* needs to be clear'd before free'd */ 251 #define DBIcf_IMPSET 0x000002 /* has implementor data to be clear'd */ 252 #define DBIcf_ACTIVE 0x000004 /* needs finish/disconnect before clear */ 253 #define DBIcf_IADESTROY 0x000008 /* do DBIc_ACTIVE_off before DESTROY */ 254 #define DBIcf_WARN 0x000010 /* warn about poor practice etc */ 255 #define DBIcf_COMPAT 0x000020 /* compat/emulation mode (eg oraperl) */ 256 #define DBIcf_ChopBlanks 0x000040 /* rtrim spaces from fetch char columns */ 257 #define DBIcf_RaiseError 0x000080 /* throw exception (croak) on error */ 258 #define DBIcf_PrintError 0x000100 /* warn() on error */ 259 #define DBIcf_AutoCommit 0x000200 /* dbh only. used by drivers */ 260 #define DBIcf_LongTruncOk 0x000400 /* truncation to LongReadLen is okay */ 261 #define DBIcf_MultiThread 0x000800 /* allow multiple threads to enter */ 262 #define DBIcf_HandleSetErr 0x001000 /* has coderef HandleSetErr attribute */ 263 #define DBIcf_ShowErrorStatement 0x002000 /* include Statement in error */ 264 #define DBIcf_BegunWork 0x004000 /* between begin_work & commit/rollback */ 265 #define DBIcf_HandleError 0x008000 /* has coderef in HandleError attribute */ 266 #define DBIcf_Profile 0x010000 /* profile activity on this handle */ 267 #define DBIcf_TaintIn 0x020000 /* check inputs for taintedness */ 268 #define DBIcf_TaintOut 0x040000 /* taint outgoing data */ 269 #define DBIcf_Executed 0x080000 /* do/execute called since commit/rollb */ 270 #define DBIcf_PrintWarn 0x100000 /* warn() on warning (err="0") */ 271 #define DBIcf_Callbacks 0x200000 /* has Callbacks attribute hash */ 272 /* NOTE: new flags may require clone() to be updated */ 273 274 #define DBIcf_INHERITMASK /* what NOT to pass on to children */ \ 275 (U32)( DBIcf_COMSET | DBIcf_IMPSET | DBIcf_ACTIVE | DBIcf_IADESTROY \ 276 | DBIcf_AutoCommit | DBIcf_BegunWork | DBIcf_Executed | DBIcf_Callbacks ) 277 278 /* general purpose bit setting and testing macros */ 279 #define DBIbf_is( bitset,flag) ((bitset) & (flag)) 280 #define DBIbf_has(bitset,flag) DBIbf_is(bitset, flag) /* alias for _is */ 281 #define DBIbf_on( bitset,flag) ((bitset) |= (flag)) 282 #define DBIbf_off(bitset,flag) ((bitset) &= ~(flag)) 283 #define DBIbf_set(bitset,flag,on) ((on) ? DBIbf_on(bitset, flag) : DBIbf_off(bitset,flag)) 284 285 /* as above, but specifically for DBIc_FLAGS imp flags (except ACTIVE) */ 286 #define DBIc_is(imp, flag) DBIbf_is( DBIc_FLAGS(imp), flag) 287 #define DBIc_has(imp,flag) DBIc_is(imp, flag) /* alias for DBIc_is */ 288 #define DBIc_on(imp, flag) DBIbf_on( DBIc_FLAGS(imp), flag) 289 #define DBIc_off(imp,flag) DBIbf_off(DBIc_FLAGS(imp), flag) 290 #define DBIc_set(imp,flag,on) DBIbf_set(DBIc_FLAGS(imp), flag, on) 291 292 #define DBIc_COMSET(imp) DBIc_is(imp, DBIcf_COMSET) 293 #define DBIc_COMSET_on(imp) DBIc_on(imp, DBIcf_COMSET) 294 #define DBIc_COMSET_off(imp) DBIc_off(imp,DBIcf_COMSET) 295 296 #define DBIc_IMPSET(imp) DBIc_is(imp, DBIcf_IMPSET) 297 #define DBIc_IMPSET_on(imp) DBIc_on(imp, DBIcf_IMPSET) 298 #define DBIc_IMPSET_off(imp) DBIc_off(imp,DBIcf_IMPSET) 299 300 #define DBIc_ACTIVE(imp) (DBIc_FLAGS(imp) & DBIcf_ACTIVE) 301 #define DBIc_ACTIVE_on(imp) /* adjust parent's active kid count */ \ 302 do { \ 303 imp_xxh_t *ph_com = DBIc_PARENT_COM(imp); \ 304 if (!DBIc_ACTIVE(imp) && ph_com && !dirty \ 305 && ++DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com)) \ 306 croak("panic: DBI active kids (%ld) > kids (%ld)", \ 307 DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \ 308 DBIc_FLAGS(imp) |= DBIcf_ACTIVE; \ 309 } while(0) 310 #define DBIc_ACTIVE_off(imp) /* adjust parent's active kid count */ \ 311 do { \ 312 imp_xxh_t *ph_com = DBIc_PARENT_COM(imp); \ 313 if (DBIc_ACTIVE(imp) && ph_com && !dirty \ 314 && (--DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com) \ 315 || DBIc_ACTIVE_KIDS(ph_com) < 0) ) \ 316 croak("panic: DBI active kids (%ld) < 0 or > kids (%ld)", \ 317 DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \ 318 DBIc_FLAGS(imp) &= ~DBIcf_ACTIVE; \ 319 } while(0) 320 321 #define DBIc_IADESTROY(imp) (DBIc_FLAGS(imp) & DBIcf_IADESTROY) 322 #define DBIc_IADESTROY_on(imp) (DBIc_FLAGS(imp) |= DBIcf_IADESTROY) 323 #define DBIc_IADESTROY_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_IADESTROY) 324 325 #define DBIc_WARN(imp) (DBIc_FLAGS(imp) & DBIcf_WARN) 326 #define DBIc_WARN_on(imp) (DBIc_FLAGS(imp) |= DBIcf_WARN) 327 #define DBIc_WARN_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_WARN) 328 329 #define DBIc_COMPAT(imp) (DBIc_FLAGS(imp) & DBIcf_COMPAT) 330 #define DBIc_COMPAT_on(imp) (DBIc_FLAGS(imp) |= DBIcf_COMPAT) 331 #define DBIc_COMPAT_off(imp) (DBIc_FLAGS(imp) &= ~DBIcf_COMPAT) 332 333 334 #ifdef IN_DBI_XS /* get Handle Common Data Structure */ 335 #define DBIh_COM(h) (dbih_getcom2(aTHX_ h, 0)) 336 #else 337 #define DBIh_COM(h) (DBIS->getcom(h)) 338 #define neatsvpv(sv,len) (DBIS->neat_svpv(sv,len)) 339 #endif 340 341 342 /* --- Implementors Private Data Support --- */ 343 344 #define D_impdata(name,type,h) type *name = (type*)(DBIh_COM(h)) 345 #define D_imp_drh(h) D_impdata(imp_drh, imp_drh_t, h) 346 #define D_imp_dbh(h) D_impdata(imp_dbh, imp_dbh_t, h) 347 #define D_imp_sth(h) D_impdata(imp_sth, imp_sth_t, h) 348 #define D_imp_xxh(h) D_impdata(imp_xxh, imp_xxh_t, h) 349 350 #define D_imp_from_child(name,type,child) \ 351 type *name = (type*)(DBIc_PARENT_COM(child)) 352 #define D_imp_drh_from_dbh D_imp_from_child(imp_drh, imp_drh_t, imp_dbh) 353 #define D_imp_dbh_from_sth D_imp_from_child(imp_dbh, imp_dbh_t, imp_sth) 354 355 #define DBI_IMP_SIZE(n,s) sv_setiv(perl_get_sv((n), GV_ADDMULTI), (s)) /* XXX */ 356 357 358 359 /* --- Event Support (VERY LIABLE TO CHANGE) --- */ 360 361 #define DBIh_EVENTx(h,t,a1,a2) /* deprecated XXX */ &PL_sv_no 362 #define DBIh_EVENT0(h,t) DBIh_EVENTx((h), (t), &PL_sv_undef, &PL_sv_undef) 363 #define DBIh_EVENT1(h,t, a1) DBIh_EVENTx((h), (t), (a1), &PL_sv_undef) 364 #define DBIh_EVENT2(h,t, a1,a2) DBIh_EVENTx((h), (t), (a1), (a2)) 365 366 #define ERROR_event "ERROR" 367 #define WARN_event "WARN" 368 #define MSG_event "MESSAGE" 369 #define DBEVENT_event "DBEVENT" 370 #define UNKNOWN_event "UNKNOWN" 371 372 #define DBIh_SET_ERR_SV(h,i, err, errstr, state, method) \ 373 (DBIc_DBISTATE(i)->set_err_sv(h,i, err, errstr, state, method)) 374 #define DBIh_SET_ERR_CHAR(h,i, err_c, err_i, errstr, state, method) \ 375 (DBIc_DBISTATE(i)->set_err_char(h,i, err_c, err_i, errstr, state, method)) 376 377 378 /* --- Handy Macros --- */ 379 380 #define DBIh_CLEAR_ERROR(imp_xxh) (void)( \ 381 (void)SvOK_off(DBIc_ERR(imp_xxh)), \ 382 (void)SvOK_off(DBIc_ERRSTR(imp_xxh)), \ 383 (void)SvOK_off(DBIc_STATE(imp_xxh)) \ 384 ) 385 386 387 /* --- DBI State Structure --- */ 388 389 struct dbistate_st { 390 391 #define DBISTATE_VERSION 94 /* Must change whenever dbistate_t does */ 392 393 /* this must be the first member in structure */ 394 void (*check_version) _((const char *name, 395 int dbis_cv, int dbis_cs, int need_dbixs_cv, 396 int drc_s, int dbc_s, int stc_s, int fdc_s)); 397 398 /* version and size are used to check for DBI/DBD version mis-match */ 399 U16 version; /* version of this structure */ 400 U16 size; 401 U16 xs_version; /* version of the overall DBIXS / DBD interface */ 402 U16 spare_pad; 403 404 I32 debug; 405 PerlIO *logfp; 406 407 /* pointers to DBI functions which the DBD's will want to use */ 408 char * (*neat_svpv) _((SV *sv, STRLEN maxlen)); 409 imp_xxh_t * (*getcom) _((SV *h)); /* see DBIh_COM macro */ 410 void (*clearcom) _((imp_xxh_t *imp_xxh)); 411 SV * (*event) _((SV *h, const char *name, SV*, SV*)); 412 int (*set_attr_k) _((SV *h, SV *keysv, int dbikey, SV *valuesv)); 413 SV * (*get_attr_k) _((SV *h, SV *keysv, int dbikey)); 414 AV * (*get_fbav) _((imp_sth_t *imp_sth)); 415 SV * (*make_fdsv) _((SV *sth, const char *imp_class, STRLEN imp_size, const char *col_name)); 416 int (*bind_as_num) _((int sql_type, int p, int s, int *t, void *v)); 417 I32 (*hash) _((const char *string, long i)); 418 SV * (*preparse) _((SV *sth, char *statement, IV ps_return, IV ps_accept, void *foo)); 419 420 SV *neatsvpvlen; /* only show dbgpvlen chars when debugging pv's */ 421 422 PerlInterpreter * thr_owner; /* thread that owns this dbistate */ 423 424 int (*logmsg) _((imp_xxh_t *imp_xxh, const char *fmt, ...)); 425 int (*set_err_sv) _((SV *h, imp_xxh_t *imp_xxh, SV *err, SV *errstr, SV *state, SV *method)); 426 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)); 427 int (*bind_col) _((SV *sth, SV *col, SV *ref, SV *attribs)); 428 429 IO *logfp_ref; /* DAA keep ptr to filehandle for refcounting */ 430 431 /* WARNING: Only add new structure members here, and reduce pad2 to keep */ 432 /* the memory footprint exactly the same */ 433 void *pad2[4]; 434 }; 435 436 /* macros for backwards compatibility */ 437 #define set_attr(h, k, v) set_attr_k(h, k, 0, v) 438 #define get_attr(h, k) get_attr_k(h, k, 0) 439 440 #define DBISTATE_PERLNAME "DBI::_dbistate" 441 #define DBISTATE_ADDRSV (perl_get_sv(DBISTATE_PERLNAME, 0x05)) 442 #define DBILOGFP (DBIS->logfp) 443 #ifdef IN_DBI_XS 444 #define DBILOGMSG (dbih_logmsg) 445 #else 446 #define DBILOGMSG (DBIS->logmsg) 447 #endif 448 449 450 /* --- perl object (ActiveState) / multiplicity hooks and hoops --- */ 451 /* note that USE_ITHREADS implies MULTIPLICITY */ 452 #define DBIS_PUBLISHED_LVALUE (*(INT2PTR(dbistate_t**, &SvIVX(DBISTATE_ADDRSV)))) 453 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || defined(PERL_CAPI) 454 455 # define DBISTATE_DECLARE typedef int dummy_dbistate /* keep semicolon from feeling lonely */ 456 # define DBISTATE_INIT_DBIS typedef int dummy_dbistate2; /* keep semicolon from feeling lonely */ 457 # undef DBIS 458 # define DBIS DBIS_PUBLISHED_LVALUE 459 # define dbis DBIS_PUBLISHED_LVALUE /* temp for old drivers using 'dbis' instead of 'DBIS' */ 460 461 #else /* plain and simple non perl object / multiplicity case */ 462 463 # define DBISTATE_DECLARE static dbistate_t *DBIS 464 # define DBISTATE_INIT_DBIS (DBIS = DBIS_PUBLISHED_LVALUE) 465 #endif 466 467 # define DBISTATE_INIT { /* typically use in BOOT: of XS file */ \ 468 DBISTATE_INIT_DBIS; \ 469 if (DBIS == NULL) \ 470 croak("Unable to get DBI state from %s at %p. DBI not loaded.", DBISTATE_PERLNAME, (void*)DBISTATE_ADDRSV); \ 471 DBIS->check_version(__FILE__, DBISTATE_VERSION, sizeof(*DBIS), NEED_DBIXS_VERSION, \ 472 sizeof(dbih_drc_t), sizeof(dbih_dbc_t), sizeof(dbih_stc_t), sizeof(dbih_fdc_t) \ 473 ); \ 474 } 475 476 477 /* --- Assorted Utility Macros --- */ 478 479 #define DBD_ATTRIB_OK(attribs) /* is this a usable attrib value */ \ 480 (attribs && SvROK(attribs) && SvTYPE(SvRV(attribs))==SVt_PVHV) 481 482 /* If attribs value supplied then croak if it's not a hash ref. */ 483 /* Also map undef to Null. Should always be called to pre-process the */ 484 /* attribs value. One day we may add some extra magic in here. */ 485 #define DBD_ATTRIBS_CHECK(func, h, attribs) \ 486 if ((attribs) && SvOK(attribs)) { \ 487 if (!SvROK(attribs) || SvTYPE(SvRV(attribs))!=SVt_PVHV) \ 488 croak("%s->%s(...): attribute parameter '%s' is not a hash ref", \ 489 SvPV_nolen(h), func, SvPV_nolen(attribs)); \ 490 } else (attribs) = Nullsv 491 492 #define DBD_ATTRIB_GET_SVP(attribs, key,klen) \ 493 (DBD_ATTRIB_OK(attribs) \ 494 ? hv_fetch((HV*)SvRV(attribs), key,klen, 0) \ 495 : (SV **)Nullsv) 496 497 #define DBD_ATTRIB_GET_IV(attribs, key,klen, svp, var) \ 498 if ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \ 499 var = SvIV(*svp) 500 501 #define DBD_ATTRIB_GET_BOOL(attribs, key,klen, svp, var) \ 502 if ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \ 503 var = SvTRUE(*svp) 504 505 #define DBD_ATTRIB_TRUE(attribs, key,klen, svp) \ 506 ( ((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \ 507 ? SvTRUE(*svp) : 0 ) 508 509 #define DBD_ATTRIB_GET_PV(attribs, key,klen, svp, dflt) \ 510 (((svp=DBD_ATTRIB_GET_SVP(attribs, key,klen)) != NULL) \ 511 ? SvPV_nolen(*svp) : (dflt)) 512 513 #define DBD_ATTRIB_DELETE(attribs, key, klen) \ 514 hv_delete((HV*)attribs, key, klen, G_DISCARD) 515 516 #endif /* DBIXS_VERSION */ 517 /* end of DBIXS.h */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |