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