php_oci8_int.h 24 KB

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