xref: /PHP-8.2/ext/oci8/php_oci8_int.h (revision 6af3f5d5)
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    | Authors: Stig Sæther Bakken <ssb@php.net>                            |
14    |          Thies C. Arntzen <thies@thieso.net>                         |
15    |                                                                      |
16    | Collection support by Andy Sautins <asautins@veripost.net>           |
17    | Temporary LOB support by David Benson <dbenson@mancala.com>          |
18    | ZTS per process OCIPLogon by Harald Radi <harald.radi@nme.at>        |
19    |                                                                      |
20    | Redesigned by: Antony Dovgal <antony@zend.com>                       |
21    |                Andi Gutmans <andi@php.net>                           |
22    |                Wez Furlong <wez@omniti.com>                          |
23    +----------------------------------------------------------------------+
24 */
25 
26 #ifdef HAVE_OCI8
27 # ifndef PHP_OCI8_INT_H
28 #  define PHP_OCI8_INT_H
29 
30 /* {{{ misc defines */
31 # if (defined(__osf__) && defined(__alpha))
32 #  ifndef A_OSF
33 #	define A_OSF
34 #  endif
35 #  ifndef OSF1
36 #	define OSF1
37 #  endif
38 #  ifndef _INTRINSICS
39 #	define _INTRINSICS
40 #  endif
41 # endif /* osf alpha */
42 
43 #ifdef HAVE_OCI8_DTRACE
44 #include "oci8_dtrace_gen.h"
45 #endif
46 
47 #if defined(min)
48 #undef min
49 #endif
50 #if defined(max)
51 #undef max
52 #endif
53 /* }}} */
54 
55 #include "ext/standard/php_string.h"
56 #include <oci.h>
57 
58 #if !defined(OCI_MAJOR_VERSION) || OCI_MAJOR_VERSION < 11 || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
59 #error This version of PHP OCI8 requires Oracle Client libraries from 11.2 or later.
60 #endif
61 
62 extern int le_connection;
63 extern int le_pconnection;
64 extern int le_statement;
65 extern int le_descriptor;
66 extern int le_collection;
67 extern int le_server;
68 extern int le_session;
69 
70 extern zend_class_entry *oci_lob_class_entry_ptr;
71 extern zend_class_entry *oci_coll_class_entry_ptr;
72 
73 /* {{{ constants */
74 #define PHP_OCI_SEEK_SET 0
75 #define PHP_OCI_SEEK_CUR 1
76 #define PHP_OCI_SEEK_END 2
77 
78 #define PHP_OCI_MAX_NAME_LEN  64
79 #define PHP_OCI_MAX_DATA_SIZE INT_MAX
80 #define PHP_OCI_PIECE_SIZE	  ((64*1024)-1)
81 #define PHP_OCI_LOB_BUFFER_SIZE 1048576l  /* 1Mb seems to be the most reasonable buffer size for LOB reading */
82 
83 #define PHP_OCI_ASSOC				(1<<0)
84 #define PHP_OCI_NUM					(1<<1)
85 #define PHP_OCI_BOTH				(PHP_OCI_ASSOC|PHP_OCI_NUM)
86 
87 #define PHP_OCI_RETURN_NULLS		(1<<2)
88 #define PHP_OCI_RETURN_LOBS			(1<<3)
89 
90 #define PHP_OCI_FETCHSTATEMENT_BY_COLUMN	(1<<4)
91 #define PHP_OCI_FETCHSTATEMENT_BY_ROW		(1<<5)
92 #define PHP_OCI_FETCHSTATEMENT_BY			(PHP_OCI_FETCHSTATEMENT_BY_COLUMN | PHP_OCI_FETCHSTATEMENT_BY_ROW)
93 
94 #define PHP_OCI_LOB_BUFFER_DISABLED 0
95 #define PHP_OCI_LOB_BUFFER_ENABLED  1
96 #define PHP_OCI_LOB_BUFFER_USED     2
97 
98 #ifdef OCI_ERROR_MAXMSG_SIZE2
99 /* Bigger size is defined from 11.2.0.3 onwards */
100 #define PHP_OCI_ERRBUF_LEN OCI_ERROR_MAXMSG_SIZE2
101 #else
102 #define PHP_OCI_ERRBUF_LEN OCI_ERROR_MAXMSG_SIZE
103 #endif
104 
105 /* The mode parameter for oci_connect() is overloaded and accepts both
106  * privilege and external authentication flags OR'd together.
107  * PHP_OCI_CRED_EXT must be distinct from the OCI_xxx privilege
108  * values.
109  */
110 #define PHP_OCI_CRED_EXT                    (1u<<31)
111 #if ((PHP_OCI_CRED_EXT == OCI_DEFAULT) || (PHP_OCI_CRED_EXT & (OCI_SYSOPER | OCI_SYSDBA)))
112 #error Invalid value for PHP_OCI_CRED_EXT
113 #endif
114 
115 #define PHP_OCI_IMPRES_UNKNOWN			0
116 #define PHP_OCI_IMPRES_NO_CHILDREN		1
117 #define PHP_OCI_IMPRES_HAS_CHILDREN		2
118 #define PHP_OCI_IMPRES_IS_CHILD			3
119 
120 /*
121  * Name passed to Oracle for tracing.  Note some DB views only show
122  * the first nine characters of the driver name.
123  */
124 #define PHP_OCI8_DRIVER_NAME     "PHP OCI8 : " PHP_OCI8_VERSION
125 
126 /* }}} */
127 
128 /* {{{ php_oci_spool */
129 typedef struct {
130 	zend_resource *id;					/* resource id */
131 	OCIEnv		 *env;					/* env of this session pool */
132 	OCIError	 *err;					/* pool's error handle	*/
133 	OCISPool	 *poolh;				/* pool handle */
134 	void		 *poolname;				/* session pool name */
135 	unsigned int  poolname_len;			/* length of session pool name */
136 	zend_string	 *spool_hash_key;		/* Hash key for session pool in plist */
137 } php_oci_spool;
138 /* }}} */
139 
140 /* {{{ php_oci_connection */
141 typedef struct {
142 	zend_resource  *id;							/* resource ID */
143 	OCIEnv		   *env;						/* private env handle */
144 	ub2				charset;					/* charset ID */
145 	OCIServer	   *server;						/* private server handle */
146 	OCISvcCtx	   *svc;						/* private service context handle */
147 	OCISession	   *session;					/* private session handle */
148 	OCIAuthInfo	   *authinfo;					/* Cached authinfo handle for OCISessionGet */
149 	OCIError	   *err;						/* private error handle */
150 	php_oci_spool  *private_spool;				/* private session pool (for persistent) */
151 	sb4				errcode;					/* last ORA- error number */
152 
153 	HashTable	   *descriptors;				/* descriptors hash, used to flush all the LOBs using this connection on commit */
154 	zend_ulong		descriptor_count;			/* used to index the descriptors hash table.  Not an accurate count */
155 	unsigned		is_open:1;					/* hels to determine if the connection is dead or not */
156 	unsigned		is_attached:1;				/* hels to determine if we should detach from the server when closing/freeing the connection */
157 	unsigned		is_persistent:1;			/* self-descriptive */
158 	unsigned		used_this_request:1;		/* helps to determine if we should reset connection's next ping time and check its timeout */
159 	unsigned		rb_on_disconnect:1;			/* helps to determine if we should rollback this connection on close/shutdown */
160 	unsigned		passwd_changed:1;			/* helps determine if a persistent connection hash should be invalidated after a password change */
161 	unsigned		is_stub:1;					/* flag to keep track whether the connection structure has a real OCI connection associated */
162 	unsigned		using_spool:1;				/* Is this connection from session pool? */
163 	time_t			idle_expiry;				/* time when the connection will be considered as expired */
164 	time_t		   *next_pingp;					/* (pointer to) time of the next ping */
165 	zend_string	   *hash_key;					/* hashed details of the connection */
166 #ifdef HAVE_OCI8_DTRACE
167 	char		   *client_id;					/* The oci_set_client_identifier() value */
168 #endif
169 
170 	zval		    taf_callback;				/* The Oracle TAF callback function in the userspace */
171 } php_oci_connection;
172 /* }}} */
173 
174 /* {{{ php_oci_descriptor */
175 typedef struct {
176 	zend_resource		*id;
177 	zend_ulong				 index;		            /* descriptors hash table index */
178 	php_oci_connection	*connection;			/* parent connection handle */
179 	dvoid				*descriptor;			/* OCI descriptor handle */
180 	ub4					 type;					/* descriptor type (FILE/LOB) */
181 	ub4					 lob_current_position;	/* LOB internal pointer */
182 	int					 lob_size;				/* cached LOB size. -1 = Lob wasn't initialized yet */
183 	int					 buffering;				/* cached buffering flag. 0 - off, 1 - on, 2 - on and buffer was used */
184 	ub4					 chunk_size;			/* chunk size of the LOB. 0 - unknown */
185 	ub1					 charset_form;			/* charset form, required for NCLOBs */
186 	ub2					 charset_id;			/* charset ID */
187 	unsigned			 is_open:1;				/* helps to determine if lob is open or not */
188 } php_oci_descriptor;
189 /* }}} */
190 
191 /* {{{ php_oci_lob_ctx */
192 typedef struct {
193 	char			   **lob_data;				/* address of pointer to LOB data */
194 	ub4					*lob_len;				/* address of LOB length variable (bytes) */
195 	ub4					 alloc_len;
196 } php_oci_lob_ctx;
197 /* }}} */
198 
199 /* {{{ php_oci_collection */
200 typedef struct {
201 	zend_resource		*id;
202 	php_oci_connection	*connection;			/* parent connection handle */
203 	OCIType				*tdo;					/* collection's type handle */
204 	OCITypeCode			 coll_typecode;			/* collection's typecode handle */
205 	OCIRef				*elem_ref;				/* element's reference handle */
206 	OCIType				*element_type;			/* element's type handle */
207 	OCITypeCode			 element_typecode;		/* element's typecode handle */
208 	OCIColl				*collection;			/* collection handle */
209 } php_oci_collection;
210 /* }}} */
211 
212 /* {{{ php_oci_define */
213 typedef struct {
214 	zval		 val;			/* zval used in define */
215 	text		*name;			/* placeholder's name */
216 	ub4			 name_len;		/* placeholder's name length */
217 	ub4			 type;			/* define type */
218 } php_oci_define;
219 /* }}} */
220 
221 /* {{{ php_oci_statement */
222 typedef struct {
223 	zend_resource		*id;
224 	zend_resource	 	*parent_stmtid;			/* parent statement id */
225 	struct php_oci_statement *impres_child_stmt;/* child of current Implicit Result Set statement handle */
226 	ub4                  impres_count;          /* count of remaining Implicit Result children on parent statement handle */
227 	php_oci_connection	*connection;			/* parent connection handle */
228 	sb4					 errcode;				/* last ORA- error number */
229 	OCIError			*err;					/* private error handle */
230 	OCIStmt				*stmt;					/* statement handle */
231 	char				*last_query;			/* last query issued. also used to determine if this is a statement or a refcursor received from Oracle */
232 	char                 impres_flag;           /* PHP_OCI_IMPRES_*_ */
233 	zend_long			 last_query_len;		/* last query length */
234 	HashTable			*columns;				/* hash containing all the result columns */
235 	HashTable			*binds;					/* binds hash */
236 	HashTable			*defines;				/* defines hash */
237 	int					 ncolumns;				/* number of columns in the result */
238 	unsigned			 executed:1;			/* statement executed flag */
239 	unsigned			 has_data:1;			/* statement has more data flag */
240 	unsigned			 has_descr:1;			/* statement has at least one descriptor or cursor column */
241 	ub2					 stmttype;				/* statement type */
242 	ub4                  prefetch_count;        /* row prefetch count */
243 	ub4                  prefetch_lob_size;     /* LOB prefetch size */
244 } php_oci_statement;
245 /* }}} */
246 
247 /* {{{ php_oci_bind */
248 typedef struct {
249 	OCIBind				*bind;					/* bind handle */
250 	zval				val;					/* value */
251 	dvoid				*descriptor;			/* used for binding of LOBS etc */
252 	OCIStmt				*statement;				/* used for binding REFCURSORs */
253 	php_oci_statement	*parent_statement;		/* pointer to the parent statement */
254 	ub2 type;						/* bind type */
255 	struct {
256 		void	*elements;
257 		sb2		*indicators;
258 		ub2		*element_lengths;
259 		ub4		 current_length;
260 		ub4		 old_length;
261 		ub4		 max_length;
262 		zend_long	 type;
263 	} array;
264 	sb2					 indicator;				/* -1 means NULL */
265 	ub2					 retcode;
266 	ub4					 dummy_len;				/* a dummy var to store alenpp value in bind OUT callback */
267 } php_oci_bind;
268 /* }}} */
269 
270 /* {{{ php_oci_out_column */
271 typedef struct {
272 	php_oci_statement	*statement;				/* statement handle. used when fetching REFCURSORS */
273 	php_oci_statement	*nested_statement;		/* statement handle. used when fetching REFCURSORS */
274 	OCIDefine			*oci_define;			/* define handle */
275 	char				*name;					/* column name */
276 	ub4					 name_len;				/* column name length */
277 	ub2					 data_type;				/* column data type */
278 	ub2					 data_size;				/* data size */
279 	ub4					 storage_size4;			/* size used when allocating buffers */
280 	sb2					 indicator;
281 	ub2					 retcode;				/* code returned when fetching this particular column */
282 	ub2					 retlen;
283 	ub4					 retlen4;
284 	ub2					 is_descr;				/* column contains a descriptor */
285 	ub2					 is_cursor;				/* column contains a cursor */
286 	zend_resource		*stmtid;				/* statement id for cursors */
287 	zend_resource		*descid;				/* descriptor id for descriptors */
288 	void				*data;
289 	php_oci_define		*define;				/* define handle */
290 	int					 piecewise;				/* column is fetched piece-by-piece */
291 	ub4					 cb_retlen;
292 	sb1					 scale;					/* column scale */
293 	sb2					 precision;				/* column precision */
294 	ub1					 charset_form;			/* charset form, required for NCLOBs */
295 	ub2					 charset_id;			/* charset ID */
296 	ub4					 chunk_size;			/* LOB chunk size */
297 } php_oci_out_column;
298 /* }}} */
299 
300 /* {{{ macros */
301 
302 #define PHP_OCI_CALL(func, params)								\
303 	do {																\
304 		OCI_G(in_call) = 1;												\
305 		func params;													\
306 		OCI_G(in_call) = 0;												\
307 	} while (0)
308 
309 #define PHP_OCI_CALL_RETURN(__retval, func, params)			\
310 	do {																\
311 		OCI_G(in_call) = 1;												\
312 		__retval = func params;											\
313 		OCI_G(in_call) = 0;												\
314 	} while (0)
315 
316 /* Check for errors that indicate the connection to the DB is no
317  * longer valid.  If it isn't, then the PHP connection is marked to be
318  * reopened by the next PHP OCI8 connect command.  This is most useful
319  * for persistent connections.	The error number list is not
320  * exclusive.  The error number comparisons and the
321  * OCI_ATTR_SERVER_STATUS check are done for maximum cross-version
322  * compatibility. In the far future, only the attribute check will be
323  * needed.
324  */
325 #define PHP_OCI_HANDLE_ERROR(connection, errcode) \
326 	do {										  \
327 		ub4 serverStatus = OCI_SERVER_NORMAL;	  \
328 		switch (errcode) {						  \
329 			case  1013:							  \
330 				zend_bailout();					  \
331 				break;							  \
332 			case	22:							  \
333 			case	28:							  \
334 			case   378:							  \
335 			case   602:							  \
336 			case   603:							  \
337 			case   604:							  \
338 			case   609:							  \
339 			case  1012:							  \
340 			case  1033:							  \
341 			case  1041:							  \
342 			case  1043:							  \
343 			case  1089:							  \
344 			case  1090:							  \
345 			case  1092:							  \
346 			case  3113:							  \
347 			case  3114:							  \
348 			case  3122:							  \
349 			case  3135:							  \
350 			case  3136:							  \
351 			case 12153:							  \
352 			case 12161:							  \
353 			case 27146:							  \
354 			case 28511:							  \
355 				(connection)->is_open = 0;		  \
356 				break;							  \
357 			default:										\
358 			{												\
359 				PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \
360 										  (ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \
361 				if (serverStatus != OCI_SERVER_NORMAL) {	\
362 					(connection)->is_open = 0;				\
363 				}											\
364 			}												\
365 			break;											\
366 		}													\
367 		php_oci_dtrace_check_connection(connection, errcode, serverStatus); \
368 	} while (0)
369 
370 #define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \
371 	do { \
372 		resource->id = zend_register_resource(resource, le_resource); \
373 	} while (0)
374 
375 #define PHP_OCI_ZVAL_TO_CONNECTION(zval, connection) \
376 	if ((connection = (php_oci_connection *)zend_fetch_resource2(Z_RES_P(zval), "oci8 connection", le_connection, le_pconnection)) == NULL) { \
377 		RETURN_THROWS(); \
378 	}
379 
380 #define PHP_OCI_ZVAL_TO_STATEMENT(zval, statement) \
381 	if ((statement = (php_oci_statement *)zend_fetch_resource(Z_RES_P(zval), "oci8 statement", le_statement)) == NULL) { \
382 		RETURN_THROWS(); \
383 	}
384 
385 #define PHP_OCI_ZVAL_TO_DESCRIPTOR(zval, descriptor) \
386 	if ((descriptor = (php_oci_descriptor *)zend_fetch_resource(Z_RES_P(zval), "oci8 descriptor", le_descriptor)) == NULL) { \
387 		RETURN_THROWS(); \
388 	}
389 
390 #define PHP_OCI_ZVAL_TO_COLLECTION(zval, collection) \
391 	if ((collection = (php_oci_collection *)zend_fetch_resource(Z_RES_P(zval), "oci8 collection", le_collection)) == NULL) { \
392 		RETURN_THROWS(); \
393 	}
394 
395 #define PHP_OCI_FETCH_RESOURCE_EX(zval, var, type, name, resource_type)						 \
396 	do { \
397 		var = (type) zend_fetch_resource(Z_RES_P(zval), name, resource_type);                \
398 		if (!var) {																			 \
399 			return 1;																		 \
400 		} \
401 	} while (0)
402 
403 #define PHP_OCI_ZVAL_TO_CONNECTION_EX(zval, connection) \
404 	PHP_OCI_FETCH_RESOURCE_EX(zval, connection, php_oci_connection *, "oci8 connection", le_connection)
405 
406 #define PHP_OCI_ZVAL_TO_STATEMENT_EX(zval, statement) \
407 	PHP_OCI_FETCH_RESOURCE_EX(zval, statement, php_oci_statement *, "oci8 statement", le_statement)
408 
409 #define PHP_OCI_ZVAL_TO_DESCRIPTOR_EX(zval, descriptor) \
410 	PHP_OCI_FETCH_RESOURCE_EX(zval, descriptor, php_oci_descriptor *, "oci8 descriptor", le_descriptor)
411 
412 #define PHP_OCI_ZVAL_TO_COLLECTION_EX(zval, collection) \
413 	PHP_OCI_FETCH_RESOURCE_EX(zval, collection, php_oci_collection *, "oci8 collection", le_collection)
414 
415 /* }}} */
416 
417 /* PROTOS */
418 
419 /* {{{ main prototypes */
420 
421 void php_oci_column_hash_dtor(zval *data);
422 void php_oci_define_hash_dtor(zval *data);
423 void php_oci_bind_hash_dtor(zval *data);
424 void php_oci_descriptor_flush_hash_dtor(zval *data);
425 void php_oci_connection_descriptors_free(php_oci_connection *connection);
426 sb4 php_oci_error(OCIError *err_p, sword status);
427 sb4 php_oci_fetch_errmsg(OCIError *error_handle, text *error_buf, size_t error_buf_size);
428 int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, ub2 *error_offset);
429 void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclusive);
430 php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, zend_long session_mode, int persistent, int exclusive);
431 int php_oci_connection_rollback(php_oci_connection *connection);
432 int php_oci_connection_commit(php_oci_connection *connection);
433 int php_oci_connection_release(php_oci_connection *connection);
434 int php_oci_password_change(php_oci_connection *connection, char *user, int user_len, char *pass_old, int pass_old_len, char *pass_new, int pass_new_len);
435 void php_oci_client_get_version(char *version, size_t version_size);
436 int php_oci_server_get_version(php_oci_connection *connection, char *version, size_t version_size);
437 void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args);
438 int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode);
439 void php_oci_dtrace_check_connection(php_oci_connection *connection, sb4 errcode, ub4 serverStatus);
440 
441 /* }}} */
442 
443 /* {{{ lob related prototypes */
444 
445 php_oci_descriptor *php_oci_lob_create(php_oci_connection *connection, zend_long type);
446 int php_oci_lob_get_length(php_oci_descriptor *descriptor, ub4 *length);
447 int php_oci_lob_read(php_oci_descriptor *descriptor, zend_long read_length, zend_long inital_offset, char **data, ub4 *data_len);
448 int php_oci_lob_write(php_oci_descriptor *descriptor, ub4 offset, char *data, int data_len, ub4 *bytes_written);
449 int php_oci_lob_flush(php_oci_descriptor *descriptor, zend_long flush_flag);
450 int php_oci_lob_set_buffering(php_oci_descriptor *descriptor, int on_off);
451 int php_oci_lob_get_buffering(php_oci_descriptor *descriptor);
452 int php_oci_lob_copy(php_oci_descriptor *descriptor, php_oci_descriptor *descriptor_from, zend_long length);
453 int php_oci_lob_close(php_oci_descriptor *descriptor);
454 int php_oci_temp_lob_close(php_oci_descriptor *descriptor);
455 int php_oci_lob_write_tmp(php_oci_descriptor *descriptor, zend_long type, char *data, int data_len);
456 void php_oci_lob_free(php_oci_descriptor *descriptor);
457 int php_oci_lob_import(php_oci_descriptor *descriptor, char *filename);
458 int php_oci_lob_append(php_oci_descriptor *descriptor_dest, php_oci_descriptor *descriptor_from);
459 int php_oci_lob_truncate(php_oci_descriptor *descriptor, zend_long new_lob_length);
460 int php_oci_lob_erase(php_oci_descriptor *descriptor, zend_long offset, ub4 length, ub4 *bytes_erased);
461 int php_oci_lob_is_equal(php_oci_descriptor *descriptor_first, php_oci_descriptor *descriptor_second, boolean *result);
462 sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp);
463 /* }}} */
464 
465 /* {{{ collection related prototypes */
466 
467 php_oci_collection *php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len);
468 int php_oci_collection_size(php_oci_collection *collection, sb4 *size);
469 int php_oci_collection_max(php_oci_collection *collection, zend_long *max);
470 int php_oci_collection_trim(php_oci_collection *collection, zend_long trim_size);
471 int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len);
472 int php_oci_collection_element_get(php_oci_collection *collection, zend_long index, zval *result_element);
473 int php_oci_collection_element_set(php_oci_collection *collection, zend_long index, char *value, int value_len);
474 int php_oci_collection_element_set_null(php_oci_collection *collection, zend_long index);
475 int php_oci_collection_element_set_date(php_oci_collection *collection, zend_long index, char *date, int date_len);
476 int php_oci_collection_element_set_number(php_oci_collection *collection, zend_long index, char *number, int number_len);
477 int php_oci_collection_element_set_string(php_oci_collection *collection, zend_long index, char *element, int element_len);
478 int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from);
479 void php_oci_collection_close(php_oci_collection *collection);
480 int php_oci_collection_append_null(php_oci_collection *collection);
481 int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len);
482 int php_oci_collection_append_number(php_oci_collection *collection, char *number, int number_len);
483 int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len);
484 
485 
486 /* }}} */
487 
488 /* {{{ statement related prototypes */
489 
490 php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len);
491 php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement);
492 int php_oci_statement_set_prefetch(php_oci_statement *statement, ub4 prefetch);
493 int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows);
494 php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, zend_long column_index, char *column_name, int column_name_len);
495 int php_oci_statement_execute(php_oci_statement *statement, ub4 mode);
496 int php_oci_statement_cancel(php_oci_statement *statement);
497 void php_oci_statement_free(php_oci_statement *statement);
498 int php_oci_bind_pre_exec(zval *data, void *result);
499 int php_oci_bind_post_exec(zval *data);
500 int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long maxlength, ub2 type);
501 sb4 php_oci_bind_in_callback(dvoid *ictxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp);
502 sb4 php_oci_bind_out_callback(dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcodepp);
503 php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data);
504 int php_oci_cleanup_pre_fetch(zval *data);
505 int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type);
506 int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows);
507 int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, size_t name_len, zval *var, zend_long max_table_length, zend_long maxlength, zend_long type);
508 php_oci_bind *php_oci_bind_array_helper_number(zval *var, zend_long max_table_length);
509 php_oci_bind *php_oci_bind_array_helper_double(zval *var, zend_long max_table_length);
510 php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_length, zend_long maxlength);
511 php_oci_bind *php_oci_bind_array_helper_date(zval *var, zend_long max_table_length, php_oci_connection *connection);
512 
513 /* }}} */
514 
515 ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ Module globals */
516 	sb4			 errcode;						/* global last ORA- error number. Used when connect fails, for example */
517 	OCIError	*err;							/* global error handle */
518 
519 	zend_long		 max_persistent;				/* maximum number of persistent connections per process */
520 	zend_long		 num_persistent;				/* number of existing persistent connections */
521 	zend_long		 num_links;						/* non-persistent + persistent connections */
522 	zend_long		 num_statements;				/* number of statements open */
523 	zend_long		 ping_interval;					/* time interval between pings */
524 	zend_long		 persistent_timeout;			/* time period after which idle persistent connection is considered expired */
525 	zend_long		 statement_cache_size;			/* statement cache size. used with 9i+ clients only*/
526 	zend_long		 default_prefetch;				/* default prefetch setting */
527 	zend_long	 	 prefetch_lob_size;				/* amount of LOB data to read when initially getting a LOB locator */
528 	bool	 privileged_connect;			/* privileged connect flag (On/Off) */
529 	bool	 old_oci_close_semantics;		/* old_oci_close_semantics flag (to determine the way oci_close() should behave) */
530 	int			 shutdown;						/* in shutdown flag */
531 
532 	OCIEnv		*env;							/* global environment handle */
533 
534 	bool	 in_call;
535 	char		*connection_class;
536 	bool	 events;
537 	char		*edition;
538 ZEND_END_MODULE_GLOBALS(oci) /* }}} */
539 
540 /* {{{ transparent failover related prototypes */
541 
542 int php_oci_register_taf_callback(php_oci_connection *connection, zval *callback);
543 int php_oci_unregister_taf_callback(php_oci_connection *connection);
544 
545 /* }}} */
546 
547 #ifdef ZTS
548 #define OCI_G(v) TSRMG(oci_globals_id, zend_oci_globals *, v)
549 #else
550 #define OCI_G(v) (oci_globals.v)
551 #endif
552 
553 /* Allow install from PECL on PHP < 7.3 */
554 #ifndef GC_ADDREF
555 # define GC_ADDREF(p) (++GC_REFCOUNT(p))
556 #endif
557 #ifndef GC_DELREF
558 # define GC_DELREF(p) (GC_REFCOUNT(p)--)
559 #endif
560 
561 ZEND_EXTERN_MODULE_GLOBALS(oci)
562 
563 # endif /* !PHP_OCI8_INT_H */
564 #else /* !HAVE_OCI8 */
565 
566 # define oci8_module_ptr NULL
567 
568 #endif /* HAVE_OCI8 */
569