xref: /PHP-7.4/ext/pdo_oci/php_pdo_oci_int.h (revision 38363f48)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 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 #include <oci.h>
20 
21 typedef struct {
22 	const char *file;
23 	int line;
24 	sb4 errcode;
25 	char *errmsg;
26 } pdo_oci_error_info;
27 
28 /* stuff we use in an OCI database handle */
29 typedef struct {
30 	OCIServer	*server;
31 	OCISession	*session;
32 	OCIEnv		*env;
33 	OCIError	*err;
34 	OCISvcCtx	*svc;
35 	/* OCI9; 0 == use NLS_LANG */
36 	ub4			prefetch;
37 	ub2			charset;
38 	sword		last_err;
39 	sb4			max_char_width;
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 const 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);
90 #define oci_init_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__)
91 #define oci_drv_error(w)	_oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__)
92 #define oci_stmt_error(w)	_oci_error(S->err, stmt->dbh, stmt, w, S->last_err, FALSE, __FILE__, __LINE__)
93 
94 extern const 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 
102 
103 enum {
104 	PDO_OCI_ATTR_ACTION = PDO_ATTR_DRIVER_SPECIFIC,
105 	PDO_OCI_ATTR_CLIENT_INFO,
106 	PDO_OCI_ATTR_CLIENT_IDENTIFIER,
107 	PDO_OCI_ATTR_MODULE
108 };
109