xref: /PHP-7.2/ext/pdo_oci/php_pdo_oci_int.h (revision 38363f48)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2018 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 	ub4			prefetch;
39 	ub2			charset;
40 	sword		last_err;
41 	sb4			max_char_width;
42 
43 	unsigned	attached:1;
44 	unsigned	_reserved:31;
45 
46 	pdo_oci_error_info einfo;
47 } pdo_oci_db_handle;
48 
49 typedef struct {
50 	OCIDefine	*def;
51 	ub2			fetched_len;
52 	ub2			retcode;
53 	sb2			indicator;
54 
55 	char *data;
56 	ub4 datalen;
57 
58 	ub2 dtype;
59 
60 } pdo_oci_column;
61 
62 typedef struct {
63 	pdo_oci_db_handle *H;
64 	OCIStmt		*stmt;
65 	OCIError	*err;
66 	sword		last_err;
67 	ub2			stmt_type;
68 	ub4			exec_type;
69 	pdo_oci_column *cols;
70 	pdo_oci_error_info einfo;
71 	unsigned int have_blobs:1;
72 } pdo_oci_stmt;
73 
74 typedef struct {
75 	OCIBind		*bind;	/* allocated by OCI */
76 	sb2			oci_type;
77 	sb2			indicator;
78 	ub2			retcode;
79 
80 	ub4			actual_len;
81 
82 	dvoid		*thing;	/* for LOBS, REFCURSORS etc. */
83 
84 	unsigned used_for_output;
85 } pdo_oci_bound_param;
86 
87 extern const ub4 PDO_OCI_INIT_MODE;
88 extern pdo_driver_t pdo_oci_driver;
89 extern OCIEnv *pdo_oci_Env;
90 
91 ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, sword status, int isinit, const char *file, int line);
92 #define oci_init_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__)
93 #define oci_drv_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__)
94 #define oci_stmt_error(w)	_oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__)
95 
96 extern struct pdo_stmt_methods oci_stmt_methods;
97 
98 /* Default prefetch size in number of rows */
99 #define PDO_OCI_PREFETCH_DEFAULT 100
100 
101 /* Arbitrary assumed row length for prefetch memory limit calcuation */
102 #define PDO_OCI_PREFETCH_ROWSIZE 1024
103 
104 
105 enum {
106 	PDO_OCI_ATTR_ACTION = PDO_ATTR_DRIVER_SPECIFIC,
107 	PDO_OCI_ATTR_CLIENT_INFO,
108 	PDO_OCI_ATTR_CLIENT_IDENTIFIER,
109 	PDO_OCI_ATTR_MODULE
110 };
111