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