diff options
| author | Christopher Jones <sixd@php.net> | 2008-03-12 01:26:44 +0000 |
|---|---|---|
| committer | Christopher Jones <sixd@php.net> | 2008-03-12 01:26:44 +0000 |
| commit | b9f72771a613634973867888100a0a083d5d2e73 (patch) | |
| tree | 96067e22920657d2f1f4c3f1e6335fe856372c67 /ext/oci8/php_oci8_int.h | |
| parent | 698e0652953f0be372435b42b4f560976374aebd (diff) | |
| download | php-git-b9f72771a613634973867888100a0a083d5d2e73.tar.gz | |
MFH
Cleaned up whitespace
Fixed bug #44372 (compilation with Oracle 10gR1 libraries)
http://bugs.php.net/bug.php?id=44372
Updated updated error number list to improve re-connection
behavior after a database restart.
Guard against potential internal list corruption after ping
removes old oci_pconnect() information.
Fix ini_set("oci8.connection_class", "abc") to get an appropriate
persistent connection.
Ping at oci8.ping_interval for oci_connect() and oci_new_connect()
when DRCP connections are used. This improves non-persistent
connection reliability if a database gets restarted.
Diffstat (limited to 'ext/oci8/php_oci8_int.h')
| -rw-r--r-- | ext/oci8/php_oci8_int.h | 354 |
1 files changed, 179 insertions, 175 deletions
diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 8e381e45f6..dfb3fb6e07 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -34,13 +34,13 @@ /* misc defines {{{ */ # if (defined(__osf__) && defined(__alpha)) # ifndef A_OSF -# define A_OSF +# define A_OSF # endif # ifndef OSF1 -# define OSF1 +# define OSF1 # endif # ifndef _INTRINSICS -# define _INTRINSICS +# define _INTRINSICS # endif # endif /* osf alpha */ @@ -59,7 +59,7 @@ extern int le_connection; extern int le_pconnection; extern int le_statement; extern int le_descriptor; -#ifdef PHP_OCI8_HAVE_COLLECTIONS +#ifdef PHP_OCI8_HAVE_COLLECTIONS extern int le_collection; #endif extern int le_server; @@ -77,19 +77,19 @@ extern zend_class_entry *oci_coll_class_entry_ptr; #define PHP_OCI_MAX_NAME_LEN 64 #define PHP_OCI_MAX_DATA_SIZE INT_MAX -#define PHP_OCI_PIECE_SIZE (64*1024)-1 +#define PHP_OCI_PIECE_SIZE (64*1024)-1 #define PHP_OCI_LOB_BUFFER_SIZE 1048576l /* 1Mb seems to be the most reasonable buffer size for LOB reading */ -#define PHP_OCI_ASSOC 1<<0 -#define PHP_OCI_NUM 1<<1 -#define PHP_OCI_BOTH (PHP_OCI_ASSOC|PHP_OCI_NUM) +#define PHP_OCI_ASSOC 1<<0 +#define PHP_OCI_NUM 1<<1 +#define PHP_OCI_BOTH (PHP_OCI_ASSOC|PHP_OCI_NUM) -#define PHP_OCI_RETURN_NULLS 1<<2 -#define PHP_OCI_RETURN_LOBS 1<<3 +#define PHP_OCI_RETURN_NULLS 1<<2 +#define PHP_OCI_RETURN_LOBS 1<<3 -#define PHP_OCI_FETCHSTATEMENT_BY_COLUMN 1<<4 -#define PHP_OCI_FETCHSTATEMENT_BY_ROW 1<<5 -#define PHP_OCI_FETCHSTATEMENT_BY (PHP_OCI_FETCHSTATEMENT_BY_COLUMN | PHP_OCI_FETCHSTATEMENT_BY_ROW) +#define PHP_OCI_FETCHSTATEMENT_BY_COLUMN 1<<4 +#define PHP_OCI_FETCHSTATEMENT_BY_ROW 1<<5 +#define PHP_OCI_FETCHSTATEMENT_BY (PHP_OCI_FETCHSTATEMENT_BY_COLUMN | PHP_OCI_FETCHSTATEMENT_BY_ROW) #define PHP_OCI_LOB_BUFFER_DISABLED 0 #define PHP_OCI_LOB_BUFFER_ENABLED 1 @@ -98,142 +98,141 @@ extern zend_class_entry *oci_coll_class_entry_ptr; /* }}} */ typedef struct { /* php_oci_spool {{{ */ - OCIEnv* env; /*env of this session pool */ - OCIError* err; /* pool's error handle */ - OCISPool *poolh; /* pool handle */ - void* poolname; /* session pool name */ - unsigned int poolname_len; /* length of session pool name */ - char *spool_hash_key; /* Hash key for session pool in plist */ + OCIEnv *env; /*env of this session pool */ + OCIError *err; /* pool's error handle */ + OCISPool *poolh; /* pool handle */ + void *poolname; /* session pool name */ + unsigned int poolname_len; /* length of session pool name */ + char *spool_hash_key; /* Hash key for session pool in plist */ } php_oci_spool; /* }}} */ typedef struct { /* php_oci_connection {{{ */ - OCIEnv *env; /* private env handle */ - ub2 charset; /* charset ID */ - OCIServer *server; /* private server handle */ - OCISvcCtx *svc; /* private service context handle */ - OCISession *session; /* private session handle */ - OCIAuthInfo *authinfo; /* Cached authinfo handle for OCISessionGet */ - OCIError *err; /* private error handle */ - php_oci_spool *private_spool; /* private session pool (for persistent) */ - sword errcode; /* last errcode */ - - HashTable *descriptors; /* descriptors hash, used to flush all the LOBs using this connection on commit */ - unsigned is_open:1; /* hels to determine if the connection is dead or not */ - unsigned is_attached:1; /* hels to determine if we should detach from the server when closing/freeing the connection */ - unsigned is_persistent:1; /* self-descriptive */ - unsigned used_this_request:1; /* helps to determine if we should reset connection's next ping time and check its timeout */ - unsigned needs_commit:1; /* helps to determine if we should rollback this connection on close/shutdown */ - unsigned passwd_changed:1; /* helps determine if a persistent connection hash should be invalidated after a password change */ - unsigned is_stub:1; /* flag to keep track whether the connection structure has a real OCI connection associated */ - unsigned using_spool:1; /* Is this connection from session pool? */ - int rsrc_id; /* resource ID */ - time_t idle_expiry; /* time when the connection will be considered as expired */ - time_t next_ping; /* time of the next ping */ - char *hash_key; /* hashed details of the connection */ + OCIEnv *env; /* private env handle */ + ub2 charset; /* charset ID */ + OCIServer *server; /* private server handle */ + OCISvcCtx *svc; /* private service context handle */ + OCISession *session; /* private session handle */ + OCIAuthInfo *authinfo; /* Cached authinfo handle for OCISessionGet */ + OCIError *err; /* private error handle */ + php_oci_spool *private_spool; /* private session pool (for persistent) */ + sword errcode; /* last errcode */ + + HashTable *descriptors; /* descriptors hash, used to flush all the LOBs using this connection on commit */ + unsigned is_open:1; /* hels to determine if the connection is dead or not */ + unsigned is_attached:1; /* hels to determine if we should detach from the server when closing/freeing the connection */ + unsigned is_persistent:1; /* self-descriptive */ + unsigned used_this_request:1; /* helps to determine if we should reset connection's next ping time and check its timeout */ + unsigned needs_commit:1; /* helps to determine if we should rollback this connection on close/shutdown */ + unsigned passwd_changed:1; /* helps determine if a persistent connection hash should be invalidated after a password change */ + unsigned is_stub:1; /* flag to keep track whether the connection structure has a real OCI connection associated */ + unsigned using_spool:1; /* Is this connection from session pool? */ + int rsrc_id; /* resource ID */ + time_t idle_expiry; /* time when the connection will be considered as expired */ + time_t *next_pingp; /* (pointer to) time of the next ping */ + char *hash_key; /* hashed details of the connection */ } php_oci_connection; /* }}} */ typedef struct { /* php_oci_descriptor {{{ */ - int id; - php_oci_connection *connection; /* parent connection handle */ - dvoid *descriptor; /* OCI descriptor handle */ - ub4 type; /* descriptor type */ - int lob_current_position; /* LOB internal pointer */ - int lob_size; /* cached LOB size. -1 = Lob wasn't initialized yet */ - int buffering; /* cached buffering flag. 0 - off, 1 - on, 2 - on and buffer was used */ - ub4 chunk_size; /* chunk size of the LOB. 0 - unknown */ - ub1 charset_form; /* charset form, required for NCLOBs */ - ub2 charset_id; /* charset ID */ - unsigned is_open:1; /* helps to determine if lob is open or not */ + int id; + php_oci_connection *connection; /* parent connection handle */ + dvoid *descriptor; /* OCI descriptor handle */ + ub4 type; /* descriptor type (FILE/LOB) */ + int lob_current_position; /* LOB internal pointer */ + int lob_size; /* cached LOB size. -1 = Lob wasn't initialized yet */ + int buffering; /* cached buffering flag. 0 - off, 1 - on, 2 - on and buffer was used */ + ub4 chunk_size; /* chunk size of the LOB. 0 - unknown */ + ub1 charset_form; /* charset form, required for NCLOBs */ + ub2 charset_id; /* charset ID */ + unsigned is_open:1; /* helps to determine if lob is open or not */ } php_oci_descriptor; /* }}} */ typedef struct { /* php_oci_lob_ctx {{{ */ - char **lob_data; /* address of pointer to LOB data */ - ub4 *lob_len; /* address of LOB length variable (bytes) */ - ub4 alloc_len; + char **lob_data; /* address of pointer to LOB data */ + ub4 *lob_len; /* address of LOB length variable (bytes) */ + ub4 alloc_len; } php_oci_lob_ctx; /* }}} */ typedef struct { /* php_oci_collection {{{ */ - int id; - php_oci_connection *connection; /* parent connection handle */ - OCIType *tdo; /* collection's type handle */ - OCITypeCode coll_typecode; /* collection's typecode handle */ - OCIRef *elem_ref; /* element's reference handle */ - OCIType *element_type; /* element's type handle */ - OCITypeCode element_typecode; /* element's typecode handle */ - OCIColl *collection; /* collection handle */ + int id; + php_oci_connection *connection; /* parent connection handle */ + OCIType *tdo; /* collection's type handle */ + OCITypeCode coll_typecode; /* collection's typecode handle */ + OCIRef *elem_ref; /* element's reference handle */ + OCIType *element_type; /* element's type handle */ + OCITypeCode element_typecode; /* element's typecode handle */ + OCIColl *collection; /* collection handle */ } php_oci_collection; /* }}} */ typedef struct { /* php_oci_define {{{ */ - zval *zval; /* zval used in define */ - text *name; /* placeholder's name */ - ub4 name_len; /* placeholder's name length */ - ub4 type; /* define type */ + zval *zval; /* zval used in define */ + text *name; /* placeholder's name */ + ub4 name_len; /* placeholder's name length */ + ub4 type; /* define type */ } php_oci_define; /* }}} */ typedef struct { /* php_oci_statement {{{ */ - int id; - int parent_stmtid; /* parent statement id */ - php_oci_connection *connection; /* parent connection handle */ - sword errcode; /* last errcode*/ - OCIError *err; /* private error handle */ - OCIStmt *stmt; /* statement handle */ - char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor recieved from Oracle */ - long last_query_len; /* last query length */ - HashTable *columns; /* hash containing all the result columns */ - HashTable *binds; /* binds hash */ - HashTable *defines; /* defines hash */ - int ncolumns; /* number of columns in the result */ - unsigned executed:1; /* statement executed flag */ - unsigned has_data:1; /* statement has more data flag */ - ub2 stmttype; /* statement type */ + int id; + int parent_stmtid; /* parent statement id */ + php_oci_connection *connection; /* parent connection handle */ + sword errcode; /* last errcode*/ + OCIError *err; /* private error handle */ + OCIStmt *stmt; /* statement handle */ + char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor recieved from Oracle */ + long last_query_len; /* last query length */ + HashTable *columns; /* hash containing all the result columns */ + HashTable *binds; /* binds hash */ + HashTable *defines; /* defines hash */ + int ncolumns; /* number of columns in the result */ + unsigned executed:1; /* statement executed flag */ + unsigned has_data:1; /* statement has more data flag */ + ub2 stmttype; /* statement type */ } php_oci_statement; /* }}} */ typedef struct { /* php_oci_bind {{{ */ - OCIBind *bind; /* bind handle */ - zval *zval; /* value */ - dvoid *descriptor; /* used for binding of LOBS etc */ - OCIStmt *statement; /* used for binding REFCURSORs */ - php_oci_statement *parent_statement; /* pointer to the parent statement */ + OCIBind *bind; /* bind handle */ + zval *zval; /* value */ + dvoid *descriptor; /* used for binding of LOBS etc */ + OCIStmt *statement; /* used for binding REFCURSORs */ + php_oci_statement *parent_statement; /* pointer to the parent statement */ struct { - void *elements; - sb2 *indicators; - ub2 *element_lengths; -/* ub2 *retcodes; */ - ub4 current_length; - ub4 old_length; - ub4 max_length; - long type; + void *elements; + sb2 *indicators; + ub2 *element_lengths; + ub4 current_length; + ub4 old_length; + ub4 max_length; + long type; } array; - sb2 indicator; /* -1 means NULL */ - ub2 retcode; /* */ - ub4 dummy_len; /* a dummy var to store alenpp value in bind OUT callback */ + sb2 indicator; /* -1 means NULL */ + ub2 retcode; + ub4 dummy_len; /* a dummy var to store alenpp value in bind OUT callback */ } php_oci_bind; /* }}} */ typedef struct { /* php_oci_out_column {{{ */ - php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ - php_oci_statement *nested_statement; /* statement handle. used when fetching REFCURSORS */ - OCIDefine *oci_define; /* define handle */ - char *name; /* column name */ - ub4 name_len; /* column name length */ - ub2 data_type; /* column data type */ - ub2 data_size; /* data size */ - ub4 storage_size4; /* size used when allocating buffers */ - sb2 indicator; /* */ - ub2 retcode; /* code returned when fetching this particular column */ - ub2 retlen; /* */ - ub4 retlen4; /* */ - ub2 is_descr; /* column contains a descriptor */ - ub2 is_cursor; /* column contains a cursor */ - int stmtid; /* statement id for cursors */ - int descid; /* descriptor id for descriptors */ - void *data; /* */ - php_oci_define *define; /* define handle */ - int piecewise; /* column is fetched piece-by-piece */ - ub4 cb_retlen; /* */ - sb1 scale; /* column scale */ - sb2 precision; /* column precision */ - ub1 charset_form; /* charset form, required for NCLOBs */ - ub2 charset_id; /* charset ID */ + php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ + php_oci_statement *nested_statement; /* statement handle. used when fetching REFCURSORS */ + OCIDefine *oci_define; /* define handle */ + char *name; /* column name */ + ub4 name_len; /* column name length */ + ub2 data_type; /* column data type */ + ub2 data_size; /* data size */ + ub4 storage_size4; /* size used when allocating buffers */ + sb2 indicator; + ub2 retcode; /* code returned when fetching this particular column */ + ub2 retlen; + ub4 retlen4; + ub2 is_descr; /* column contains a descriptor */ + ub2 is_cursor; /* column contains a cursor */ + int stmtid; /* statement id for cursors */ + int descid; /* descriptor id for descriptors */ + void *data; + php_oci_define *define; /* define handle */ + int piecewise; /* column is fetched piece-by-piece */ + ub4 cb_retlen; + sb1 scale; /* column scale */ + sb2 precision; /* column precision */ + ub1 charset_form; /* charset form, required for NCLOBs */ + ub2 charset_id; /* charset ID */ } php_oci_out_column; /* }}} */ /* {{{ macros */ @@ -261,17 +260,31 @@ typedef struct { /* php_oci_out_column {{{ */ #define PHP_OCI_HANDLE_ERROR(connection, errcode) \ do { \ switch (errcode) { \ - case 1013: \ - zend_bailout(); \ - break; \ - case 22: \ - case 1012: \ - case 3113: \ - case 604: \ - case 1041: \ - case 3114: \ - connection->is_open = 0; \ - break; \ + case 1013: \ + zend_bailout(); \ + break; \ + case 22: \ + case 378: \ + case 602: \ + case 603: \ + case 604: \ + case 609: \ + case 1012: \ + case 1033: \ + case 1041: \ + case 1043: \ + case 1089: \ + case 1090: \ + case 1092: \ + case 3113: \ + case 3114: \ + case 3122: \ + case 3135: \ + case 12153: \ + case 27146: \ + case 28511: \ + connection->is_open = 0; \ + break; \ } \ } while (0) @@ -292,14 +305,14 @@ typedef struct { /* php_oci_out_column {{{ */ #define PHP_OCI_ZVAL_TO_COLLECTION(zval, collection) \ ZEND_FETCH_RESOURCE(collection, php_oci_collection *, &zval, -1, "oci8 collection", le_collection) -#define PHP_OCI_FETCH_RESOURCE_EX(zval, var, type, name, resource_type) \ +#define PHP_OCI_FETCH_RESOURCE_EX(zval, var, type, name, resource_type) \ do { \ var = (type) zend_fetch_resource(&zval TSRMLS_CC, -1, name, NULL, 1, resource_type); \ - if (!var) { \ - return 1; \ + if (!var) { \ + return 1; \ } \ } while (0) - + #define PHP_OCI_ZVAL_TO_CONNECTION_EX(zval, connection) \ PHP_OCI_FETCH_RESOURCE_EX(zval, connection, php_oci_connection *, "oci8 connection", le_connection) @@ -329,7 +342,7 @@ sb4 php_oci_fetch_errmsg(OCIError *, text ** TSRMLS_DC); #ifdef HAVE_OCI8_ATTR_STATEMENT int php_oci_fetch_sqltext_offset(php_oci_statement *, text **, ub2 * TSRMLS_DC); #endif - + void php_oci_do_connect (INTERNAL_FUNCTION_PARAMETERS, int , int); 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); @@ -338,7 +351,7 @@ int php_oci_connection_commit(php_oci_connection * TSRMLS_DC); int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC); int php_oci_password_change(php_oci_connection *, char *, int, char *, int, char *, int TSRMLS_DC); -int php_oci_server_get_version(php_oci_connection *, char ** TSRMLS_DC); +int php_oci_server_get_version(php_oci_connection *, char ** TSRMLS_DC); void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int, int); int php_oci_column_to_zval(php_oci_out_column *, zval *, int TSRMLS_DC); @@ -371,7 +384,6 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece #else sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); #endif - /* }}} */ /* collection related prototypes {{{ */ @@ -382,7 +394,7 @@ int php_oci_collection_max(php_oci_collection *, long * TSRMLS_DC); int php_oci_collection_trim(php_oci_collection *, long TSRMLS_DC); int php_oci_collection_append(php_oci_collection *, char *, int TSRMLS_DC); int php_oci_collection_element_get(php_oci_collection *, long, zval** TSRMLS_DC); -int php_oci_collection_element_set(php_oci_collection *, long, char*, int TSRMLS_DC); +int php_oci_collection_element_set(php_oci_collection *, long, char *, int TSRMLS_DC); int php_oci_collection_element_set_null(php_oci_collection *, long TSRMLS_DC); int php_oci_collection_element_set_date(php_oci_collection *, long, char *, int TSRMLS_DC); int php_oci_collection_element_set_number(php_oci_collection *, long, char *, int TSRMLS_DC); @@ -402,7 +414,7 @@ int php_oci_collection_append_string(php_oci_collection *, char *, int TSRMLS_DC php_oci_statement * php_oci_statement_create (php_oci_connection *, char *, int TSRMLS_DC); int php_oci_statement_set_prefetch (php_oci_statement *, long TSRMLS_DC); int php_oci_statement_fetch (php_oci_statement *, ub4 TSRMLS_DC); -php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, char*, int TSRMLS_DC); +php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, char *, int TSRMLS_DC); int php_oci_statement_execute (php_oci_statement *, ub4 TSRMLS_DC); int php_oci_statement_cancel (php_oci_statement * TSRMLS_DC); void php_oci_statement_free (php_oci_statement * TSRMLS_DC); @@ -424,36 +436,30 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p /* }}} */ ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ */ - sword errcode; /* global last error code (used when connect fails, for example) */ - OCIError *err; /* global error handle */ - - /* - char *default_username; - char *default_password; - char *default_dbname; - */ - - zend_bool debug_mode; /* debug mode flag */ - - long max_persistent; /* maximum number of persistent connections per process */ - long num_persistent; /* number of existing persistent connections */ - long num_links; /* non-persistent + persistent connections */ - long num_statements; /* number of statements open */ - long ping_interval; /* time interval between pings */ - long persistent_timeout; /* time period after which idle persistent connection is considered expired */ - long statement_cache_size; /* statement cache size. used with 9i+ clients only*/ - long default_prefetch; /* default prefetch setting */ - zend_bool privileged_connect; /* privileged connect flag (On/Off) */ - zend_bool old_oci_close_semantics; /* old_oci_close_semantics flag (to determine the way oci_close() should behave) */ - - int shutdown; /* in shutdown flag */ - - OCIEnv *env; /* global environment handle */ - - zend_bool in_call; - char *connection_class; - zend_bool events; -ZEND_END_MODULE_GLOBALS(oci) /* }}} */ + sword errcode; /* global last error code (used when connect fails, for example) */ + OCIError *err; /* global error handle */ + + zend_bool debug_mode; /* debug mode flag */ + + long max_persistent; /* maximum number of persistent connections per process */ + long num_persistent; /* number of existing persistent connections */ + long num_links; /* non-persistent + persistent connections */ + long num_statements; /* number of statements open */ + long ping_interval; /* time interval between pings */ + long persistent_timeout; /* time period after which idle persistent connection is considered expired */ + long statement_cache_size; /* statement cache size. used with 9i+ clients only*/ + long default_prefetch; /* default prefetch setting */ + zend_bool privileged_connect; /* privileged connect flag (On/Off) */ + zend_bool old_oci_close_semantics; /* old_oci_close_semantics flag (to determine the way oci_close() should behave) */ + + int shutdown; /* in shutdown flag */ + + OCIEnv *env; /* global environment handle */ + + zend_bool in_call; + char *connection_class; + zend_bool events; +ZEND_END_MODULE_GLOBALS(oci) /* }}} */ #ifdef ZTS #define OCI_G(v) TSRMG(oci_globals_id, zend_oci_globals *, v) @@ -476,5 +482,3 @@ ZEND_EXTERN_MODULE_GLOBALS(oci) * c-basic-offset: 4 * End: */ - - |
