php_oci8_int.h 24 KB

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