summaryrefslogtreecommitdiff
path: root/ext/oci8/oci8_lob.c
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2013-09-05 18:18:29 -0700
committerChristopher Jones <sixd@php.net>2013-09-05 18:18:29 -0700
commit4b778faa8014947390d55dbc71e15ae0d7aca53a (patch)
tree64b18f29a5ae3362f790be7bd19c745ffb2a0f2b /ext/oci8/oci8_lob.c
parent6ece5503942a1d8c4a78504161f9466e9e14fed2 (diff)
downloadphp-git-4b778faa8014947390d55dbc71e15ae0d7aca53a.tar.gz
Make oci_set_*($connection,...) errors retrievable via oci_error($connection).
Improve some error handling to produce error text on some rare edge cases. Disambiguate the Oracle library function call return status values from ORA error numbers. Review and unify error data types.
Diffstat (limited to 'ext/oci8/oci8_lob.c')
-rw-r--r--ext/oci8/oci8_lob.c194
1 files changed, 115 insertions, 79 deletions
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c
index 87ce84843f..8d14dc3f50 100644
--- a/ext/oci8/oci8_lob.c
+++ b/ext/oci8/oci8_lob.c
@@ -54,6 +54,7 @@
php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long type TSRMLS_DC)
{
php_oci_descriptor *descriptor;
+ sword errstatus;
switch (type) {
case OCI_DTYPE_FILE:
@@ -72,13 +73,15 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ
descriptor->connection = connection;
zend_list_addref(descriptor->connection->id);
- PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));
+ PHP_OCI_CALL_RETURN(errstatus, OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));
- if (OCI_G(errcode) != OCI_SUCCESS) {
- OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, OCI_G(errcode));
efree(descriptor);
return NULL;
+ } else {
+ OCI_G(errcode) = 0; /* retain backwards compat with OCI8 1.4 */
}
PHP_OCI_REGISTER_RESOURCE(descriptor, le_descriptor);
@@ -117,6 +120,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ
int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_DC)
{
php_oci_connection *connection = descriptor->connection;
+ sword errstatus;
*length = 0;
@@ -125,18 +129,18 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D
return 0;
} else {
if (descriptor->type == OCI_DTYPE_FILE) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
@@ -144,14 +148,16 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D
descriptor->lob_size = *length;
if (descriptor->type == OCI_DTYPE_FILE) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
}
+
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
}
return 0;
}
@@ -211,20 +217,22 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, l
{
php_oci_connection *connection = descriptor->connection;
ub4 chunk_size;
+ sword errstatus;
if (descriptor->type == OCI_DTYPE_FILE) {
return read_length;
}
if (!descriptor->chunk_size) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return read_length; /* we have to return original length here */
}
descriptor->chunk_size = chunk_size;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
}
if ((read_length % descriptor->chunk_size) != 0) {
@@ -253,6 +261,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
#endif
int is_clob = 0;
sb4 bytes_per_char = 1;
+ sword errstatus;
*data_len = 0;
*data = NULL;
@@ -289,20 +298,20 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
offset = initial_offset;
if (descriptor->type == OCI_DTYPE_FILE) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
} else {
ub2 charset_id = 0;
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
@@ -313,10 +322,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
}
if (is_clob) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ));
+ PHP_OCI_CALL_RETURN(errstatus, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
@@ -340,7 +349,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */
bufp = (ub1 *) ecalloc(1, buffer_size);
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead2,
+ PHP_OCI_CALL_RETURN(errstatus, OCILobRead2,
(
connection->svc,
connection->err,
@@ -373,7 +382,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */
bufp = (ub1 *) ecalloc(1, buffer_size);
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead,
+ PHP_OCI_CALL_RETURN(errstatus, OCILobRead,
(
connection->svc,
connection->err,
@@ -394,8 +403,8 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
#endif
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
if (*data) {
efree(*data);
@@ -408,10 +417,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
descriptor->lob_current_position = (int)offset;
if (descriptor->type == OCI_DTYPE_FILE) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
if (*data) {
efree(*data);
@@ -422,6 +431,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
}
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -433,6 +443,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
OCILobLocator *lob = (OCILobLocator *) descriptor->descriptor;
php_oci_connection *connection = (php_oci_connection *) descriptor->connection;
ub4 lob_length;
+ sword errstatus;
*bytes_written = 0;
if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
@@ -451,7 +462,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
offset = descriptor->lob_current_position;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobWrite,
+ PHP_OCI_CALL_RETURN(errstatus, OCILobWrite,
(
connection->svc,
connection->err,
@@ -468,8 +479,8 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
)
);
- if (connection->errcode) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
*bytes_written = 0;
return 1;
@@ -486,6 +497,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
descriptor->buffering = PHP_OCI_LOB_BUFFER_USED;
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -495,6 +507,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS_DC)
{
php_oci_connection *connection = descriptor->connection;
+ sword errstatus;
if (!on_off && descriptor->buffering == PHP_OCI_LOB_BUFFER_DISABLED) {
/* disabling when it's already off */
@@ -507,17 +520,18 @@ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS
}
if (on_off) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor));
} else {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor));
}
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
descriptor->buffering = on_off ? PHP_OCI_LOB_BUFFER_ENABLED : PHP_OCI_LOB_BUFFER_DISABLED;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -540,6 +554,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d
{
php_oci_connection *connection = descriptor_dest->connection;
ub4 length_dest, length_from, copy_len;
+ sword errstatus;
if (php_oci_lob_get_length(descriptor_dest, &length_dest TSRMLS_CC)) {
return 1;
@@ -560,7 +575,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d
return 1;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobCopy,
+ PHP_OCI_CALL_RETURN(errstatus, OCILobCopy,
(
connection->svc,
connection->err,
@@ -572,12 +587,13 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d
)
);
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -587,15 +603,17 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d
int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
{
php_oci_connection *connection = descriptor->connection;
-
+ sword errstatus;
+
if (descriptor->is_open) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor));
- }
+ PHP_OCI_CALL_RETURN(errstatus, OCILobClose, (connection->svc, connection->err, descriptor->descriptor));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
- PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
- return 1;
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
+ PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
+ return 1;
+ }
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
}
if (php_oci_temp_lob_close(descriptor TSRMLS_CC)) {
@@ -612,24 +630,26 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
{
php_oci_connection *connection = descriptor->connection;
int is_temporary;
+ sword errstatus;
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
if (is_temporary) {
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -640,7 +660,8 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC)
{
OCILobLocator *lob = descriptor->descriptor;
php_oci_connection *connection = descriptor->connection;
-
+ sword errstatus;
+
if (!lob) {
return 1;
}
@@ -663,16 +684,17 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC)
return 0;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
/* marking buffer as enabled and not used */
descriptor->buffering = PHP_OCI_LOB_BUFFER_ENABLED;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -734,6 +756,7 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC
php_oci_connection *connection = descriptor->connection;
char buf[8192];
ub4 offset = 1;
+ sword errstatus;
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
/* Safe mode has been removed in PHP 5.4 */
@@ -750,7 +773,7 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC
}
while ((loblen = read(fp, &buf, sizeof(buf))) > 0) {
- PHP_OCI_CALL_RETURN(connection->errcode,
+ PHP_OCI_CALL_RETURN(errstatus,
OCILobWrite,
(
connection->svc,
@@ -768,11 +791,13 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC
)
);
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
close(fp);
return 1;
+ } else {
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
}
offset += loblen;
}
@@ -790,6 +815,7 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor
OCILobLocator *lob_dest = descriptor_dest->descriptor;
OCILobLocator *lob_from = descriptor_from->descriptor;
ub4 dest_len, from_len;
+ sword errstatus;
if (php_oci_lob_get_length(descriptor_dest, &dest_len TSRMLS_CC)) {
return 1;
@@ -803,13 +829,14 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor
return 0;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -821,6 +848,7 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS
php_oci_connection *connection = descriptor->connection;
OCILobLocator *lob = descriptor->descriptor;
ub4 lob_length;
+ sword errstatus;
if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
return 1;
@@ -840,15 +868,17 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS
return 1;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
descriptor->lob_size = new_lob_length;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
+
return 0;
}
/* }}} */
@@ -860,6 +890,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length,
php_oci_connection *connection = descriptor->connection;
OCILobLocator *lob = descriptor->descriptor;
ub4 lob_length;
+ sword errstatus;
*bytes_erased = 0;
@@ -875,15 +906,16 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length,
length = lob_length;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1));
- if (connection->errcode != OCI_SUCCESS) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus != OCI_SUCCESS) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
*bytes_erased = length;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -895,14 +927,16 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript
php_oci_connection *connection = descriptor_first->connection;
OCILobLocator *first_lob = descriptor_first->descriptor;
OCILobLocator *second_lob = descriptor_second->descriptor;
+ sword errstatus;
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobIsEqual, (connection->env, first_lob, second_lob, result));
- if (connection->errcode) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return 0;
}
/* }}} */
@@ -914,6 +948,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data
php_oci_connection *connection = descriptor->connection;
OCILobLocator *lob = descriptor->descriptor;
ub4 bytes_written = 0;
+ sword errstatus;
switch (type) {
case OCI_TEMP_BLOB:
@@ -930,7 +965,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data
return 1;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary,
+ PHP_OCI_CALL_RETURN(errstatus, OCILobCreateTemporary,
(
connection->svc,
connection->err,
@@ -943,21 +978,22 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data
)
);
- if (connection->errcode) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE));
+ PHP_OCI_CALL_RETURN(errstatus, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE));
- if (connection->errcode) {
- connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC);
+ if (errstatus) {
+ connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
descriptor->is_open = 1;
+ connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
return php_oci_lob_write(descriptor, 0, data, data_len, &bytes_written TSRMLS_CC);
}