CVS update: php3/functions
| From: | thies | Date: | Thu, 27 May 1999 12:09:57 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6060@lists.php.net to get a copy of this message | ||
Date: Thursday May 27, 1999 @ 8:09
Author: thies
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv28843/functions
Modified Files:
php3_oci8.h oci8.c
Log Message:
fixed LONG/RAW/LONG RAW support > 64K (using piecewise operations)
Index: php3/functions/php3_oci8.h
diff -u php3/functions/php3_oci8.h:1.49 php3/functions/php3_oci8.h:1.50
--- php3/functions/php3_oci8.h:1.49 Sun May 23 10:40:50 1999
+++ php3/functions/php3_oci8.h Thu May 27 08:09:57 1999
@@ -137,6 +137,12 @@
int stmtid;
void *data;
oci8_define *define;
+
+ /* for piecewise read */
+ int piecewise;
+ int cursize;
+ int curoffs;
+ ub4 piecesize;
} oci8_out_column;
typedef struct {
@@ -172,8 +178,8 @@
#define oci8_module_ptr &oci8_module_entry
#define OCI8_MAX_NAME_LEN 64
-#define OCI8_MAX_DATA_SIZE ((64*1024)-1) /* XXX we need piecewise operations!! */
-
+#define OCI8_MAX_DATA_SIZE INT_MAX
+#define OCI8_PIECE_SIZE (64*1024)-1
# define OCI8_CONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_conn)
# define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt)
Index: php3/functions/oci8.c
diff -u php3/functions/oci8.c:1.102 php3/functions/oci8.c:1.103
--- php3/functions/oci8.c:1.102 Sat May 22 05:42:31 1999
+++ php3/functions/oci8.c Thu May 27 08:09:57 1999
@@ -33,22 +33,17 @@
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
-/* $Id: oci8.c,v 1.102 1999/05/22 09:42:31 thies Exp $ */
+/* $Id: oci8.c,v 1.103 1999/05/27 12:09:57 thies Exp $ */
/* TODO list:
*
- * - better oracle-error handling.
- * - Commit/Rollback testing.....
* - php.ini flags
* - Error mode (print or shut up?)
- * - returning refcursors as statement handles
* - OCIPasswordChange()
* - Prefetching control
- * - LONG, LONG RAW, RAW is now limited to 2MB (should be user-settable);
* - binding of arrays
* - Truncate input values to the bind size
* - Character sets for NCLOBS
- * - piecewise operation for longs, lobs etc
* - split the module into an upper (php-callable) and lower (c-callable) layer!
* - make_pval needs some cleanup....
* - NULLS (retcode/indicator) needs some more work for describing & binding
@@ -940,7 +935,11 @@
if (column->rlen <= 0) {
size = 1; /* XXX this is our "oci-bug" */
} else {
- size = column->rlen;
+ if (column->piecewise) {
+ size = (column->cursize - column->piecesize) + column->rlen;
+ } else {
+ size = column->rlen;
+ }
}
break;
@@ -948,7 +947,11 @@
/*
oci8_debugcol(column,"OK");
*/
- size = column->rlen;
+ if (column->piecewise) {
+ size = (column->cursize - column->piecesize) + column->rlen;
+ } else {
+ size = column->rlen;
+ }
break;
default: /* XXX we SHOULD maybe have a different behaviour for unknown results! */
@@ -1174,6 +1177,7 @@
return 0; /* XXX we loose memory!!! */
}
+
statement->error =
oci8_error(statement->pError,
"OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_DATA_SIZE",
@@ -1238,11 +1242,15 @@
case SQLT_BIN:
define_type = SQLT_BIN;
outcol->storage_size4 = OCI8_MAX_DATA_SIZE;
+ outcol->piecewise = 1;
+ outcol->piecesize = OCI8_PIECE_SIZE;
break;
case SQLT_LNG:
define_type = SQLT_STR;
outcol->storage_size4 = OCI8_MAX_DATA_SIZE;
+ outcol->piecewise = 1;
+ outcol->piecesize = OCI8_PIECE_SIZE;
break;
default:
@@ -1260,27 +1268,28 @@
oci8_error(statement->pError,
"OCIDefineByPos",
OCIDefineByPos(statement->pStmt, /* IN/OUT handle to the requested SQL query */
- (OCIDefine **)&outcol->pDefine, /* IN/OUT pointer to a pointer to a define
handle */
- statement->pError, /* IN/OUT An error handle */
+ (OCIDefine **)&outcol->pDefine,/* IN/OUT pointer to a pointer to a define handle
*/
+ statement->pError, /* IN/OUT An error handle */
counter, /* IN position in the select list */
- (dvoid *)0, /* IN/OUT pointer to a buffer */
- outcol->storage_size4, /* IN The size of each valuep buffer in bytes */
- define_type, /* IN The data type */
+ (dvoid *)0, /* IN/OUT pointer to a buffer */
+ outcol->storage_size4, /* IN The size of each valuep buffer in bytes */
+ define_type, /* IN The data type */
(dvoid *)&outcol->indicator, /* IN pointer to an indicator variable or arr */
- (ub2 *)&outcol->size2, /* IN/OUT Pointer to array of length of data fetched
*/
+ (ub2 *)&outcol->size2, /* IN/OUT Pointer to array of length of data fetched */
(ub2 *)&outcol->retcode, /* OUT Pointer to array of column-level return codes
*/
OCI_DYNAMIC_FETCH)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
if (statement->error) {
return 0; /* XXX we loose memory!!! */
}
-
+
statement->error =
oci8_error(statement->pError,
"OCIDefineDynamic",
OCIDefineDynamic(outcol->pDefine,
statement->pError,
- outcol,
- oci8_define_callback));
+ (dvoid *) outcol,
+ (OCICallbackDefine)oci8_define_callback));
+
if (statement->error) {
return 0; /* XXX we loose memory!!! */
}
@@ -1300,6 +1309,26 @@
pval *pval;
OCI8_TLS_VARS;
+ /* first we need to reset our piecewise fetch-infos */
+ for (i = 0; i < statement->ncolumns; i++) {
+ column = oci8_get_col(statement, i + 1, 0, "OCIFetch");
+ if (column == NULL) { /* should not happen... */
+ continue;
+ }
+
+ if (column->define && column->define->pval) { /* make sure the defined columns
get "cleared" */
+ convert_to_string(column->define->pval);
+ column->define->pval->value.str.len = 0;
+ }
+
+ if (column->piecewise) {
+ if (column->curoffs) {
+ column->cursize = column->piecesize;
+ column->curoffs = 0;
+ }
+ }
+ }
+
statement->error =
OCIStmtFetch(statement->pStmt,
statement->pError, nrows,
@@ -1351,10 +1380,15 @@
}
pval->value.str.len = column->indicator - 1; /* when value is truncated indicator
contains the lenght */
} else {
- pval->value.str.len = column->rlen;
+
+ if (column->piecewise) {
+ pval->value.str.len = (column->cursize - column->piecesize) + column->rlen;
+ } else {
+ pval->value.str.len = column->rlen;
+ }
}
}
-
+
pval->value.str.val[ pval->value.str.len ] = 0;
}
}
@@ -1588,37 +1622,62 @@
outcol->rlen = -1;
*bufpp = outcol->pdescr->ocidescr;
} else { /* "normal variable" */
+
+ /* check if the user has used ocidefinebyname for this column */
if (define) {
pval = define->pval;
convert_to_string(pval);
if (pval->value.str.val) {
+ oci8_debug("--- %x,%x,
%d,%d",pval->value.str.val,define->data,pval->value.str.len,outcol->cursize);
+
if ((pval->value.str.val==undefined_variable_string) ||
(pval->value.str.val==empty_string)) {
/* value was empty -> allocate it... */
pval->value.str.val = 0;
- } else if (pval->value.str.val != define->data) {
+ outcol->data = 0;
+ } else if ((pval->value.str.val != define->data) ||
+ (pval->value.str.len >= outcol->cursize)) {
/* value has changed - and is maybe too small -> reallocate it! */
efree(pval->value.str.val);
pval->value.str.val = 0;
+ outcol->data = 0;
}
- }
+ }
+ }
- if (pval->value.str.val == 0) {
- pval->value.str.val = emalloc(outcol->storage_size4);
- define->data = pval->value.str.val;
- }
- outcol->data = pval->value.str.val;
- } else if (! outcol->data) {
- outcol->data = (text *) emalloc(outcol->storage_size4);
+ if (! outcol->data) {
+ if (outcol->piecewise) {
+ outcol->data = (text *) emalloc(outcol->piecesize);
+ outcol->cursize = outcol->piecesize;
+ outcol->curoffs = 0;
+ } else {
+ outcol->data = (text *) emalloc(outcol->storage_size4);
+ outcol->cursize = outcol->storage_size4;
+ }
}
-
+
if (! outcol->data) {
php3_error(E_WARNING, "OCIFetch: cannot allocate %d bytes!",outcol->storage_size4);
return OCI_ERROR;
}
-
- outcol->rlen = outcol->storage_size4;
- *bufpp = outcol->data;
+
+ if (outcol->piecewise) {
+ if ((outcol->curoffs + outcol->piecesize) > outcol->cursize) {
+ outcol->cursize += outcol->piecesize;
+ outcol->data = erealloc(outcol->data,outcol->cursize);
+ }
+ outcol->rlen = outcol->piecesize;
+ *bufpp = ((char*)outcol->data) + outcol->curoffs;
+ outcol->curoffs += outcol->piecesize;
+ } else {
+ outcol->rlen = outcol->storage_size4;
+ *bufpp = outcol->data;
+ }
+
+ if (define) {
+ pval->value.str.val = outcol->data;
+ define->data = pval->value.str.val;
+ }
}
outcol->indicator = 0;
@@ -3505,6 +3564,11 @@
outcol = oci8_get_col(statement, -1, col, "OCIResult");
if (outcol == NULL) {
+ RETURN_FALSE;
+ }
+
+ if (outcol->define) {
+ php3_error(E_WARNING, "%s has been defined with OCIDefineByName, OCIResult is
undefined",outcol->name);
RETURN_FALSE;
}
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net