xref: /PHP-5.5/ext/pdo_oci/php_pdo_oci_int.h (revision 73c1be26)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2015 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Wez Furlong <wez@php.net>                                    |
16   +----------------------------------------------------------------------+
17 */
18 
19 /* $Id$ */
20 
21 #include <oci.h>
22 
23 typedef struct {
24 	const char *file;
25 	int line;
26 	sb4 errcode;
27 	char *errmsg;
28 } pdo_oci_error_info;
29 
30 /* stuff we use in an OCI database handle */
31 typedef struct {
32 	OCIServer	*server;
33 	OCISession	*session;
34 	OCIEnv		*env;
35 	OCIError	*err;
36 	OCISvcCtx	*svc;
37 	/* OCI9; 0 == use NLS_LANG */
38 	ub2			charset;
39 	sword		last_err;
40 
41 	unsigned	attached:1;
42 	unsigned	_reserved:31;
43 
44 	pdo_oci_error_info einfo;
45 } pdo_oci_db_handle;
46 
47 typedef struct {
48 	OCIDefine	*def;
49 	ub2			fetched_len;
50 	ub2			retcode;
51 	sb2			indicator;
52 
53 	char *data;
54 	ub4 datalen;
55 
56 	ub2 dtype;
57 
58 } pdo_oci_column;
59 
60 typedef struct {
61 	pdo_oci_db_handle *H;
62 	OCIStmt		*stmt;
63 	OCIError	*err;
64 	sword		last_err;
65 	ub2			stmt_type;
66 	ub4			exec_type;
67 	pdo_oci_column *cols;
68 	pdo_oci_error_info einfo;
69 	unsigned int have_blobs:1;
70 } pdo_oci_stmt;
71 
72 typedef struct {
73 	OCIBind		*bind;	/* allocated by OCI */
74 	sb2			oci_type;
75 	sb2			indicator;
76 	ub2			retcode;
77 
78 	ub4			actual_len;
79 
80 	dvoid		*thing;	/* for LOBS, REFCURSORS etc. */
81 
82 	unsigned used_for_output;
83 } pdo_oci_bound_param;
84 
85 extern const ub4 PDO_OCI_INIT_MODE;
86 extern pdo_driver_t pdo_oci_driver;
87 extern OCIEnv *pdo_oci_Env;
88 
89 ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, sword status, int isinit, const char *file, int line TSRMLS_DC);
90 #define oci_init_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__ TSRMLS_CC)
91 #define oci_drv_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)
92 #define oci_stmt_error(w)	_oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC)
93 
94 extern struct pdo_stmt_methods oci_stmt_methods;
95 
96 /* Default prefetch size in number of rows */
97 #define PDO_OCI_PREFETCH_DEFAULT 100
98 
99 /* Arbitrary assumed row length for prefetch memory limit calcuation */
100 #define PDO_OCI_PREFETCH_ROWSIZE 1024
101