summaryrefslogtreecommitdiff
path: root/ext/oci8/oci8_lob.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-03-21 15:06:50 +0000
committerAntony Dovgal <tony2001@php.net>2006-03-21 15:06:50 +0000
commit7019b978a08e5295f5528a026aa0500041c0cfa5 (patch)
tree19664bf831c22b144d5fea02f72c9766f00796ad /ext/oci8/oci8_lob.c
parent1122f647d202feef7ebecf1ba65b1ffcd7f0fe6b (diff)
downloadphp-git-7019b978a08e5295f5528a026aa0500041c0cfa5.tar.gz
reimplement php_oci_lob_read() and fix PECL bug #5995
now the function dosn't try to read data by blocks, as this is nearly impossible to do with Unicode and regular LOBs in the same time
Diffstat (limited to 'ext/oci8/oci8_lob.c')
-rw-r--r--ext/oci8/oci8_lob.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c
index 11e29f6d00..c64d06a51c 100644
--- a/ext/oci8/oci8_lob.c
+++ b/ext/oci8/oci8_lob.c
@@ -150,7 +150,6 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
{
php_oci_connection *connection = descriptor->connection;
ub4 length = 0;
- ub4 block_length = PHP_OCI_LOB_BUFFER_SIZE;
int bytes_read, bytes_total = 0, offset = 0, data_len_chars = 0;
int requested_len = read_length; /* this is by default */
@@ -178,14 +177,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
requested_len = length - initial_offset;
}
- if (requested_len == 0) {
+ if (requested_len <= 0) {
return 0;
}
- if (requested_len < block_length) {
- block_length = requested_len;
- }
-
if (descriptor->type == OCI_DTYPE_FILE) {
connection->errcode = PHP_OCI_CALL(OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
@@ -196,10 +191,14 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
}
}
- *data = (char *)emalloc(block_length + 1);
- bytes_read = block_length;
+ *data = (char *)emalloc(requested_len + 1);
+ bytes_read = requested_len;
offset = initial_offset;
-
+
+ /* TODO
+ * We need to make sure this function works with Unicode LOBs
+ * */
+
do {
connection->errcode = PHP_OCI_CALL(OCILobRead,
(
@@ -209,7 +208,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
&bytes_read, /* IN/OUT bytes toread/read */
offset + 1, /* offset (starts with 1) */
(dvoid *) ((char *) *data + *data_len),
- block_length, /* size of buffer */
+ requested_len, /* size of buffer */
(dvoid *)0,
(OCICallbackLobRead) 0, /* callback... */
(ub2) connection->charset, /* The character set ID of the buffer data. */
@@ -225,7 +224,6 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
offset = initial_offset + data_len_chars;
*data_len += bytes_read;
- block_length = PHP_OCI_LOB_BUFFER_SIZE;
if (connection->errcode != OCI_NEED_DATA) {
break;