📄 dbixs.h
字号:
/* $Id: DBIXS.h 9659 2007-06-18 14:19:45Z timbo $ * * Copyright (c) 1994-2002 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/* first pull in the standard Perl header files for extensions */#define PERL_POLLUTE#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 */#include "dbipport.h"/* DBI SQL_* type definitions */#include "dbi_sql.h"/* The DBIXS_VERSION value will be incremented whenever new code is * added to the interface (this file) or significant changes are made. * It's primary goal is to allow newer drivers to compile against an * older installed DBI. This is mainly an issue whilst the API grows * and learns from the needs of various drivers. See also the * DBISTATE_VERSION macro below. You can think of DBIXS_VERSION as * being a compile time check and DBISTATE_VERSION as a runtime check. * By contract, DBIXS_REVISION is a driver source compatibility tool. */#define DBIXS_VERSION 93#ifdef NEED_DBIXS_VERSION#if NEED_DBIXS_VERSION > DBIXS_VERSIONerror 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 pad; /* keep binary compat */ 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)#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)#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(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: true if flags match & DBI level>=flaglevel, or if DBI level>level This is the main trace testing macro to be used by drivers. (Drivers should define their own DBDtf_* macros for the top 8 bits: 0xFF000000) 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) )#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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -