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