xref: /PHP-8.3/ext/pdo_oci/php_pdo_oci_int.h (revision 80b4c730)
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   | https://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 #ifndef PHP_PDO_OCI_INT_H
18 #define PHP_PDO_OCI_INT_H
19 
20 #include "zend_portability.h"
21 
22 ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
23 #include <oci.h>
24 ZEND_DIAGNOSTIC_IGNORED_END
25 
26 typedef struct {
27 	const char *file;
28 	int line;
29 	sb4 errcode;
30 	char *errmsg;
31 } pdo_oci_error_info;
32 
33 /* stuff we use in an OCI database handle */
34 typedef struct {
35 	OCIServer	*server;
36 	OCISession	*session;
37 	OCIEnv		*env;
38 	OCIError	*err;
39 	OCISvcCtx	*svc;
40 	/* OCI9; 0 == use NLS_LANG */
41 	ub4			prefetch;
42 	ub2			charset;
43 	sword		last_err;
44 	sb4			max_char_width;
45 
46 	unsigned	attached:1;
47 	unsigned	_reserved:31;
48 
49 	pdo_oci_error_info einfo;
50 } pdo_oci_db_handle;
51 
52 typedef struct {
53 	OCIDefine	*def;
54 	ub2			fetched_len;
55 	ub2			retcode;
56 	sb2			indicator;
57 
58 	char *data;
59 	ub4 datalen;
60 
61 	ub2 dtype;
62 
63 } pdo_oci_column;
64 
65 typedef struct {
66 	pdo_oci_db_handle *H;
67 	OCIStmt		*stmt;
68 	OCIError	*err;
69 	sword		last_err;
70 	ub2			stmt_type;
71 	ub4			exec_type;
72 	pdo_oci_column *cols;
73 	pdo_oci_error_info einfo;
74 	unsigned int have_blobs:1;
75 } pdo_oci_stmt;
76 
77 typedef struct {
78 	OCIBind		*bind;	/* allocated by OCI */
79 	sb2			oci_type;
80 	sb2			indicator;
81 	ub2			retcode;
82 
83 	ub4			actual_len;
84 
85 	dvoid		*thing;	/* for LOBS, REFCURSORS etc. */
86 
87 	unsigned used_for_output;
88 } pdo_oci_bound_param;
89 
90 extern const ub4 PDO_OCI_INIT_MODE;
91 extern const pdo_driver_t pdo_oci_driver;
92 extern OCIEnv *pdo_oci_Env;
93 
94 ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, sword status, int isinit, const char *file, int line);
95 #define oci_init_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__)
96 #define oci_drv_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__)
97 #define oci_stmt_error(w)	_oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__)
98 
99 extern const struct pdo_stmt_methods oci_stmt_methods;
100 
101 /* Default prefetch size in number of rows */
102 #define PDO_OCI_PREFETCH_DEFAULT 100
103 
104 /* Arbitrary assumed row length for prefetch memory limit calcuation */
105 #define PDO_OCI_PREFETCH_ROWSIZE 1024
106 
107 
108 enum {
109 	PDO_OCI_ATTR_ACTION = PDO_ATTR_DRIVER_SPECIFIC,
110 	PDO_OCI_ATTR_CLIENT_INFO,
111 	PDO_OCI_ATTR_CLIENT_IDENTIFIER,
112 	PDO_OCI_ATTR_MODULE,
113 	PDO_OCI_ATTR_CALL_TIMEOUT
114 };
115 
116 #endif	/* PHP_PDO_OCI_INT_H */
117