diff options
Diffstat (limited to 'ext/oci8/oci8_lob.c')
-rw-r--r-- | ext/oci8/oci8_lob.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index d05e053919..bd5b7065f4 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -70,9 +70,9 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ descriptor = ecalloc(1, sizeof(php_oci_descriptor)); descriptor->type = type; descriptor->connection = connection; - zend_list_addref(descriptor->connection->rsrc_id); + 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(OCIDESCRIPTORALLOC, OCI_G(errcode), 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); @@ -109,7 +109,8 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ } return descriptor; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_length() Get length of the LOB. The length is cached so we don't need to ask Oracle every time */ @@ -124,7 +125,7 @@ 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)); + PHP_OCI_CALL_RETURN(OCILOBFILEOPEN, 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_HANDLE_ERROR(connection, connection->errcode); @@ -132,7 +133,7 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D } } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length)); + PHP_OCI_CALL_RETURN(OCILOBGETLENGTH, connection->errcode, 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); @@ -143,7 +144,7 @@ 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(OCILOBFILECLOSE, connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -153,7 +154,8 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D } } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_callback() Append LOB portion to a memory buffer */ @@ -203,7 +205,8 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) } /* }}} */ -/* {{{ php_oci_lob_calculate_buffer() */ +/* {{{ php_oci_lob_calculate_buffer() + Work out the size for LOB buffering */ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, long read_length TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; @@ -214,7 +217,7 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, l } if (!descriptor->chunk_size) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size)); + PHP_OCI_CALL_RETURN(OCILOBGETCHUNKSIZE, connection->errcode, 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); @@ -286,7 +289,7 @@ 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(OCILOBFILEOPEN, 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); @@ -296,7 +299,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } else { ub2 charset_id = 0; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); + PHP_OCI_CALL_RETURN(OCILOBCHARSETID, connection->errcode, 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); @@ -310,7 +313,7 @@ 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(OCINLSNUMERICINFOGET, connection->errcode, 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); @@ -337,7 +340,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(OCILOBREAD2, connection->errcode, OCILobRead2, ( connection->svc, connection->err, @@ -370,7 +373,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(OCILOBREAD, connection->errcode, OCILobRead, ( connection->svc, connection->err, @@ -405,7 +408,7 @@ 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(OCILOBFILECLOSE, connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -420,7 +423,8 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write() Write data to the LOB */ @@ -447,7 +451,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(OCILOBWRITE, connection->errcode, OCILobWrite, ( connection->svc, connection->err, @@ -483,7 +487,8 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_set_buffering() Turn buffering off/onn for this particular LOB */ @@ -502,9 +507,9 @@ 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(OCILOBENABLEBUFFERING, connection->errcode, 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(OCILOBDISABLEBUFFERING, connection->errcode, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor)); } if (connection->errcode != OCI_SUCCESS) { @@ -514,7 +519,8 @@ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS } descriptor->buffering = on_off ? PHP_OCI_LOB_BUFFER_ENABLED : PHP_OCI_LOB_BUFFER_DISABLED; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_buffering() Return current buffering state for the LOB */ @@ -525,7 +531,8 @@ int php_oci_lob_get_buffering (php_oci_descriptor *descriptor) } else { return 0; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_copy() Copy one LOB (or its part) to another one */ @@ -553,7 +560,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(OCILOBCOPY, connection->errcode, OCILobCopy, ( connection->svc, connection->err, @@ -572,7 +579,8 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_close() Close LOB */ @@ -581,7 +589,7 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_connection *connection = descriptor->connection; if (descriptor->is_open) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBCLOSE, connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); } if (connection->errcode != OCI_SUCCESS) { @@ -595,7 +603,8 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_temp_lob_close() Close Temporary LOB */ @@ -604,7 +613,7 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_connection *connection = descriptor->connection; int is_temporary; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); + PHP_OCI_CALL_RETURN(OCILOBISTEMPORARY, connection->errcode, 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); @@ -613,7 +622,7 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } if (is_temporary) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBFREETEMPORARY, connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -622,8 +631,8 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } } return 0; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_lob_flush() Flush buffers for the LOB (only if they have been used) */ @@ -654,7 +663,7 @@ 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(OCILOBFLUSHBUFFER, connection->errcode, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -665,7 +674,8 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) /* marking buffer as enabled and not used */ descriptor->buffering = PHP_OCI_LOB_BUFFER_ENABLED; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_free() Close LOB descriptor and free associated resources */ @@ -707,11 +717,12 @@ void php_oci_lob_free (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_temp_lob_close(descriptor TSRMLS_CC); } - PHP_OCI_CALL(OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); - zend_list_delete(descriptor->connection->rsrc_id); + zend_list_delete(descriptor->connection->id); efree(descriptor); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_import() Import LOB contents from the given file */ @@ -739,7 +750,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(OCILOBWRITE, connection->errcode, OCILobWrite, ( connection->svc, @@ -768,7 +779,8 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC close(fp); return 0; -} /* }}} */ +} + /* }}} */ /* {{{ php_oci_lob_append() Append data to the end of the LOB */ @@ -791,7 +803,7 @@ 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(OCILOBAPPEND, connection->errcode, 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); @@ -799,7 +811,8 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_truncate() Truncate LOB to the given length */ @@ -827,7 +840,7 @@ 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(OCILOBTRIM, connection->errcode, 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); @@ -837,7 +850,8 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS descriptor->lob_size = new_lob_length; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_erase() Erase (or fill with whitespaces, depending on LOB type) the LOB (or its part) */ @@ -861,7 +875,7 @@ 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(OCILOBERASE, connection->errcode, 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); @@ -871,7 +885,8 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length, *bytes_erased = length; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_is_equal() Compare two LOB descriptors and figure out if they are pointing to the same LOB */ @@ -881,7 +896,7 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript OCILobLocator *first_lob = descriptor_first->descriptor; OCILobLocator *second_lob = descriptor_second->descriptor; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); + PHP_OCI_CALL_RETURN(OCILOBISEQUAL, connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); if (connection->errcode) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -889,7 +904,8 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write_tmp() Create temporary LOB and write data to it */ @@ -914,7 +930,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(OCILOBCREATETEMPORARY, connection->errcode, OCILobCreateTemporary, ( connection->svc, connection->err, @@ -933,7 +949,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); + PHP_OCI_CALL_RETURN(OCILOBOPEN, connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); if (connection->errcode) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -944,7 +960,8 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data descriptor->is_open = 1; return php_oci_lob_write(descriptor, 0, data, data_len, &bytes_written TSRMLS_CC); -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ |