DBD-Oracle

 view release on metacpan or  search on metacpan

dbdimp.h  view on Meta::CPAN

	SV *ora_cache;
	SV *ora_cache_o;		/* for ora_open() cache override */
};

#ifdef ORA_OCI_112
typedef struct session_pool_st session_pool_t;
struct session_pool_st {
	OCIEnv		*envhp;
	OCIError 	*errhp;
	OCISPool	*poolhp;
	OraText		*pool_name;
	ub4		pool_namel;
	int		active_sessions;
};
#endif

/* Define dbh implementor data structure */
struct imp_dbh_st {
	dbih_dbc_t com;		/* MUST be first element in structure	*/

#ifdef USE_ITHREADS
	int refcnt ;		/* keep track of duped handles. MUST be first after com */
	struct imp_dbh_st * shared_dbh ; /* pointer to shared space from which to dup and keep refcnt */
	SV *				shared_dbh_priv_sv ;
#endif

	void *(*get_oci_handle) _((imp_dbh_t *imp_dbh, int handle_type, int flags));
	OCIEnv 		*envhp;		/* copy of drh pointer	*/
	OCIError 	*errhp;
	OCIServer 	*srvhp;
	OCISvcCtx 	*svchp;
	OCISession	*seshp;
#ifdef ORA_OCI_112
	session_pool_t	*pool;
	OraText		session_tag[50];
	boolean		session_tag_found;
	bool		using_drcp;
	text		*pool_class;
	ub4			pool_classl;
	ub4			pool_min;
	ub4			pool_max;
	ub4			pool_incr;
	ub4			pool_rlb;
	char		*driver_name;/*driver name user defined*/
#endif
    SV          *taf_function; /*User supplied TAF functiomn*/
    taf_callback_t taf_ctx;
    char		*client_info;  /*user defined*/
    ub4			client_infol;
	char		*module_name; /*module user defined */
	ub4			module_namel;
	char		*client_identifier;  /*user defined*/
    ub4			client_identifierl;
    char		*action;  /*user defined*/
    ub4			actionl;
	int RowCacheSize; /* both of these are defined by DBI spec*/
	int RowsInCache;	/* this vaue is RO and cannot be set*/
	int ph_type;		/* default oratype for placeholders */
	ub1 ph_csform;		/* default charset for placeholders */
	int parse_error_offset;	/* position in statement of last error */
	int max_nested_cursors;	 /* limit on cached nested cursors per stmt */
	int array_chunk_size;  /* the max size for an array bind */
    ub4 server_version; /* version of Oracle server */
};

#define DBH_DUP_OFF sizeof(dbih_dbc_t)
#define DBH_DUP_LEN (sizeof(struct imp_dbh_st) - sizeof(dbih_dbc_t))



typedef struct lob_refetch_st lob_refetch_t; /* Define sth implementor data structure */


/*statement structure */
struct imp_sth_st {

	dbih_stc_t com;		/* MUST be first element in structure	*/

	void *(*get_oci_handle) _((imp_sth_t *imp_sth, int handle_type, int flags));
	OCIEnv			*envhp;	/* copy of dbh pointer	*/
	OCIError		*errhp;	/* copy of dbh pointer	*/
	OCIServer		*srvhp;	/* copy of dbh pointer	*/
	OCISvcCtx		*svchp;	/* copy of dbh pointer	*/
	OCIStmt			*stmhp;	/* oci statement  handle */
	OCIDescribe 	*dschp; /* oci describe handle */
	int				is_child;  /* if this is child from a ref cursor or SP*/
	ub2				stmt_type;	/* OCIAttrGet OCI_ATTR_STMT_TYPE	*/
	U16				auto_lob;	/* use auto lobs*/
	int				pers_lob;	/*use dblink for lobs only for 10g Release 2. or later*/
	int				clbk_lob;	/*use dblink for lobs only for 10g Release 2. or later*/
	int				piece_lob;	/*use piece fetch for lobs*/
	ub4				piece_size;	/*used in callback to set the size of the piece to get*/
	int				has_lobs;	/*Statement has bound LOBS */
    int				ret_lobs;	/*Statement returns LOBS */
 	lob_refetch_t	*lob_refetch;
	int				nested_cursor;	/* cursors fetched from SELECTs */
	AV				*bind_tuples;	/* Bind tuples in array execute, or NULL */
	int				rowwise;		/* If true, bind_tuples is list of */
									/* tuples, otherwise list of columns. */
	/* 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				ora_pad_empty;	/* convert ""->" " when binding	*/

	/* Select Column Output Details	*/
	int				done_desc;		/* have we described this sth yet ?	*/
	imp_fbh_t		*fbh;			/* array of imp_fbh_t structs	*/
	char			*fbh_cbuf;		/* memory for all field names	   */
	int				t_dbsize;	 	/* raw data width of a row		*/
	UV				long_readlen; 	/* local copy to handle oraperl	*/
	HV				*fbh_tdo_hv;	/* hash of row #(0 based) and tdo object name from ora_oci_type_names hash */
	 /* Select Row Cache Details */
	sb4				cache_rows;
	int				in_cache;
	int				next_entry;
	int				eod_errno;
	int				est_width;	/* est'd avg row width on-the-wire	*/
	/* (In/)Out Parameter Details */
	bool			has_inout_params;
	/* execute mode*/
	/* will be using this alot later me thinks  */
	ub4				exe_mode;
	/* fetch scrolling values */
	int 			fetch_orient;
	int				fetch_offset;
	int				fetch_position;
	int 			prefetch_memory;	/* OCI_PREFETCH_MEMORY*/
	int				prefetch_rows;		/* OCI_PREFETCH_ROWS */
	/* array fetch: state variables */
	int				row_cache_off;
	int 			rs_fetch_count;		/*fetch count*/
	int				rs_array_size;		/*array size local value for RowCacheSize as I do not want to change RowCacheSize */
	int				rs_array_num_rows;	/* num rows in last fetch */
	int				rs_array_idx;		/* index of current row */
	sword			rs_array_status;	/* status of last fetch */
	int 			RowCacheSize; 		/* both of these are defined by DBI spec*/
	int 			RowsInCache;		/* this vaue is RO and cannot be set*/

};
#define IMP_STH_EXECUTING	0x0001


typedef struct fb_ary_st fb_ary_t;	/* field buffer array	*/
struct fb_ary_st { 	/* field buffer array EXPERIMENTAL	*/
	ub4				bufl;		/* length of data buffer		*/
	ub4				cb_bufl;	/* length of piece of data fetched in callback.*/
	ub4				piece_count;/*# of pieces retrieved*/
	sb2				*aindp;	/* null/trunc indicator variable	*/
	ub1				*abuf;		/* data buffer (points to sv data)	*/
	ub1				*cb_abuf;	/*yet another buffer for picewise callbacks this means I only need to allocate memory once a prepare rather than at each fetch*/
	ub2				*arlen;	/* length of returned data		*/
	ub2				*arcode;	/* field level error status		*/
};


typedef struct fbh_obj_st fbh_obj_t; /*Ebbedded Object Descriptor */

struct fbh_obj_st {  /* embedded object or table will work recursively*/
	text			*type_name;			/*object's name (TDO)*/
	ub4				type_namel;			/*length of the name*/
	OCIParam		*parmdp;			/*Describe attributes of the object OCI_DTYPE_PARAM*/
	OCIParam		*parmap;			/*Describe attributes of the object OCI_ATTR_COLLECTION_ELEMENT OCI_ATTR_PARAM*/
 	OCIType	 		*tdo;				/*object's TDO handle */
	OCITypeCode 	typecode;			/*object's OCI_ATTR_TYPECODE */
	OCITypeCode 	col_typecode;		/*if collection this is its OCI_ATTR_COLLECTION_TYPECODE */
	OCITypeCode 	element_typecode;	/*if collection this is its element's OCI_ATTR_TYPECODE*/
	OCIRef			*obj_ref;			/*if an embedded object this is ref handle to its TDO*/
	OCIInd			*obj_ind;			/*Null indicator for object */
	OCIComplexObject *obj_value;		/*the actual value from the DB*/
	OCIType			*obj_type;		 	/*if an embeded object this is the  OCIType returned by a OCIObjectPin*/
	ub1				is_final_type;		/*object's OCI_ATTR_IS_FINAL_TYPE*/
	fbh_obj_t		*fields;			/*one object for each field/property*/
	ub2				field_count;		/*The number of fields Not really needed but nice to have*/
	fbh_obj_t		*next_subtype;		/*There is stored information about subtypes for inherited objects*/
	AV				*value;				/*The value to send back to Perl This way there are no memory leaks*/
	SV				*full_type_name;	/*Perl value of full type name = schema_name "." type_name*/

};

struct imp_fbh_st { 	/* field buffer EXPERIMENTAL */
	imp_sth_t *imp_sth;	/* 'parent' statement	*/
	int field_num;	/* 0..n-1		*/

	/* Oracle's description of the field	*/
	OCIParam	*parmdp;
	OCIDefine	*defnp;
	void 		*desc_h;	/* descriptor if needed (LOBs, cursors etc)	*/
	ub4			desc_t;	/* OCI type of descriptor		*/
	ub4 		define_mode; /*the normal case for a define*/
	int			(*fetch_func) _((SV *sth, imp_fbh_t *fbh, SV *dest_sv));
	void 		(*fetch_cleanup) _((SV *sth, imp_fbh_t *fbh));
	ub2			dbtype;	/* actual type of field (see ftype)	*/
	ub2			dbsize;
	ub2			prec;		/* XXX docs say ub1 but ub2 is needed	*/
	sb1			scale;
	ub1			nullok;
	char 		*name;
	SV			*name_sv;	/* only set for OCI8			*/
	/* OCI docs say OCI_ATTR_CHAR_USED is ub4, they're wrong	*/
	ub1			len_char_used;	/* OCI_ATTR_CHAR_USED			*/
	ub2			len_char_size;	/* OCI_ATTR_CHAR_SIZE			*/
	ub2			csid;		/* OCI_ATTR_CHARSET_ID			*/
	ub1			csform;		/* OCI_ATTR_CHARSET_FORM		*/
	ub4			disize;		/* max display/buffer size		*/
	ub4			piece_size; /*used in callback to set the size of the piece to get*/
	char		*bless;		/* for Oracle::OCI style handle data	*/
	void		*special;	/* hook for special purposes (LOBs etc)	*/
	int			pers_lob;   /*for persistant lobs 10g Release 2. or later*/
	int			clbk_lob;   /*for persistant lobs 10g Release 2. or later*/
	int			piece_lob;  /*use piecewise fetch for lobs*/

	/* Our storage space for the field data as it's fetched	*/

	sword		ftype;		/* external datatype we wish to get	*/
	IV			req_type;	/* type passed to bind_col */
	UV			bind_flags;	/* flags passed to bind_col */
	fb_ary_t	*fb_ary ;	/* field buffer array			*/
	/* if this is an embedded object we use this */
	fbh_obj_t	*obj;


 };

 /* Placeholder structure */
 /* Note: phs_t is serialized into scalar value, and de-serialized then. */
 /* Be carefull! */

typedef struct phs_st phs_t;	/* scalar placeholder   */

struct phs_st {	/* scalar placeholder EXPERIMENTAL	*/
	imp_sth_t		*imp_sth; /* 'parent' statement			*/
	sword 			ftype;	/* external OCI field type		*/

	SV				*sv;		/* the scalar holding the value		*/
	U32 			sv_type;	/* original sv type at time of bind	*/
	ub2 			csid_orig;	/* original oracle default csid 	*/
	ub2 			csid;		/* 0 for automatic			*/
	ub1 			csform;		/* 0 for automatic			*/
	ub4 			maxdata_size;	/* set OCI_ATTR_MAXDATA_SIZE if >0	*/
	bool			is_inout;

	IV				maxlen;		/* max possible len (=allocated buffer)	*/
					/* Note: for array bind = buffer for each entry */
	OCIBind			*bndhp;
	void			*desc_h;	/* descriptor if needed (LOBs etc)	*/
	ub4				desc_t;	/* OCI type of desc_h			*/
	ub4				alen;



( run in 1.219 second using v1.01-cache-2.11-cpan-39bf76dae61 )