cvs: /php3 ChangeLog /php3/functions oci8.c php3_oci8.h
| From: | Thies C . Arntzen | Date: | Mon, 13 Sep 1999 15:19:29 +0000 |
| Subject: | cvs: /php3 ChangeLog /php3/functions oci8.c php3_oci8.h | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-10853@lists.php.net to get a copy of this message | ||
thies Mon Sep 13 11:19:29 1999 EDT
Modified files:
/php3 ChangeLog
/php3/functions oci8.c php3_oci8.h
Log:
got rid of the define-callback stuff there's a bug in oracle-oci8!
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.759 php3/ChangeLog:1.760
--- php3/ChangeLog:1.759 Mon Sep 13 07:51:49 1999
+++ php3/ChangeLog Mon Sep 13 11:19:27 1999
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
???? ??, 1999, Version 3.0.13
+- OCI8 doesn't use define callbacks any longer. (Thies)
- Safe-Mode fix for oci8 savefile() function. (Thies)
- Added ldap_get_values_len function (Stig Venaas)
- Added more functions to posix module.
Index: php3/functions/oci8.c
diff -u php3/functions/oci8.c:1.122 php3/functions/oci8.c:1.123
--- php3/functions/oci8.c:1.122 Mon Sep 13 07:51:49 1999
+++ php3/functions/oci8.c Mon Sep 13 11:19:27 1999
@@ -33,7 +33,7 @@
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
-/* $Id: oci8.c,v 1.122 1999/09/13 11:51:49 thies Exp $ */
+/* $Id: oci8.c,v 1.123 1999/09/13 15:19:27 thies Exp $ */
/* TODO list:
*
@@ -209,9 +209,6 @@
static sb4 oci8_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *, dvoid **);
static sb4 oci8_bind_out_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 **, ub1 *, dvoid **,
ub2 **);
-/* define callback function */
-static sb4 oci8_define_callback(dvoid *, OCIDefine *, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2
**);
-
#if 0
/* failover callback function */
static sb4 oci8_failover_callback(dvoid *svchp,dvoid* envhp,dvoid *fo_ctx,ub4 fo_type, ub4
fo_event);
@@ -895,8 +892,8 @@
if (column->indicator || column->retcode)
if ((column->indicator != -1) && (column->retcode != 1405))
- oci8_debug("oci8_make_pval: %16s,retlen = %4d,cb_retlen = %d,storage_size4 = %4d,indicator
%4d, retcode = %4d",
-
column->name,column->retlen,column->cb_retlen,column->storage_size4,column->indicator,column->retcode);
+ oci8_debug("oci8_make_pval: %16s,retlen = %4d,retlen4 = %d,storage_size4 = %4d,indicator
%4d, retcode = %4d",
+
column->name,column->retlen,column->retlen4,column->storage_size4,column->indicator,column->retcode);
/*
memset(value,0,sizeof(pval));
@@ -950,7 +947,7 @@
oci8_debugcol(column,"OK");
*/
if (column->piecewise) {
- size = (column->cursize - column->piecesize) + column->cb_retlen;
+ size = column->retlen4;
} else {
size = column->retlen;
}
@@ -1239,19 +1236,9 @@
define_type = outcol->data_type;
outcol->is_cursor = 1;
outcol->storage_size4 = -1;
- dynamic = OCI_DYNAMIC_FETCH;
-
-#if 0 /* doesn't work!! */
- outcol->stmtid = oci8_parse(statement->conn,0,0,list);
- outcol->pstmt = oci8_get_stmt(outcol->stmtid, "OCIExecute",list);
-
- define_type = outcol->data_type;
- outcol->is_cursor = 1;
- outcol->storage_size4 = -1;
outcol->retlen = -1;
dynamic = OCI_DEFAULT;
- buf = outcol->pstmt->pStmt;
-#endif
+ buf = &(outcol->pstmt->pStmt);
break;
case SQLT_RDD: /* ROWID */
@@ -1288,15 +1275,6 @@
oci8_debug("OCIExecute: new descriptor for %s",outcol->name);
break;
-#if 0 /* RAW (can be up to 2K) is now handled as STRING! */
- case SQLT_BIN:
- define_type = SQLT_BIN;
- outcol->storage_size4++;
- buf = outcol->data = (text *) emalloc(outcol->storage_size4);
- dynamic = OCI_DEFAULT;
- break;
-#endif
-
case SQLT_LNG:
case SQLT_LBI:
if (outcol->data_type == SQLT_LBI) {
@@ -1306,7 +1284,6 @@
}
outcol->storage_size4 = OCI8_MAX_DATA_SIZE;
outcol->piecewise = 1;
- outcol->piecesize = OCI8_PIECE_SIZE;
dynamic = OCI_DYNAMIC_FETCH;
break;
@@ -1334,13 +1311,13 @@
(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 *)buf, /* IN/OUT pointer to a buffer */
+ (dvoid *)NULL, /* 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 *)NULL, /* IN/OUT Pointer to array of length of data fetched */
(ub2 *)NULL, /* OUT Pointer to array of column-level return codes */
- dynamic)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
+ OCI_DYNAMIC_FETCH)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
} else {
statement->error =
oci8_error(statement->pError,
@@ -1355,25 +1332,11 @@
(dvoid *)&outcol->indicator, /* IN pointer to an indicator variable or arr
*/
(ub2 *)&outcol->retlen, /* IN/OUT Pointer to array of length of data fetched
*/
(ub2 *)&outcol->retcode, /* OUT Pointer to array of column-level return
codes */
- dynamic)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
+ OCI_DEFAULT)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
}
if (statement->error) {
return 0; /* XXX we loose memory!!! */
}
-
- if (dynamic == OCI_DYNAMIC_FETCH) {
- statement->error =
- oci8_error(statement->pError,
- "OCIDefineDynamic",
- OCIDefineDynamic(outcol->pDefine,
- statement->pError,
- (dvoid *) outcol,
- (OCICallbackDefine)oci8_define_callback));
-
- if (statement->error) {
- return 0; /* XXX we loose memory!!! */
- }
- }
}
}
@@ -1398,10 +1361,7 @@
}
if (column->piecewise) {
- if (column->curoffs) {
- column->cursize = column->piecesize;
- column->curoffs = 0;
- }
+ column->retlen4 = 0;
}
}
@@ -1425,6 +1385,45 @@
return 0;
}
+
+ while (statement->error == OCI_NEED_DATA) {
+ for (i = 0; i < statement->ncolumns; i++) {
+ column = oci8_get_col(statement, i + 1, 0, "OCIFetch");
+ if (column->piecewise) {
+ if (! column->data) {
+ column->data = (text *) emalloc(OCI8_PIECE_SIZE);
+ } else {
+ column->data = erealloc(column->data,column->retlen4 +
OCI8_PIECE_SIZE);
+ }
+
+ column->cb_retlen = OCI8_PIECE_SIZE;
+
+ OCIStmtSetPieceInfo((void *) column->pDefine,
+ OCI_HTYPE_DEFINE,
+ statement->pError,
+ ((char*)column->data) + column->retlen4,
+ &(column->cb_retlen),
+ OCI_NEXT_PIECE,
+ NULL,
+ NULL);
+ }
+ }
+
+ statement->error =
+ OCIStmtFetch(statement->pStmt,
+ statement->pError, nrows,
+ OCI_FETCH_NEXT,
+ OCI_DEFAULT);
+
+ for (i = 0; i < statement->ncolumns; i++) {
+ column = oci8_get_col(statement, i + 1, 0, "OCIFetch");
+ if (column->piecewise) {
+ column->retlen4 += column->cb_retlen;
+ }
+ }
+ }
+
+
if (statement->error == OCI_SUCCESS_WITH_INFO || statement->error == OCI_SUCCESS) {
/* do the stuff needed for OCIDefineByName */
for (i = 0; i < statement->ncolumns; i++) {
@@ -1603,67 +1602,6 @@
return 0;
}
#endif
-/* }}} */
-/* {{{ oci8_define_callback() */
-
-static sb4
-oci8_define_callback(dvoid *octxp,
- OCIDefine *defnp,
- ub4 iter, /* 0-based execute iteration value */
- dvoid **bufpp, /* pointer to data */
- ub4 **alenp, /* size after value/piece has been read */
- ub1 *piecep, /* which piece */
- dvoid **indpp, /* indicator value */
- ub2 **rcodep)
-{
- oci8_out_column *outcol;
-
- outcol = (oci8_out_column *)octxp;
-
- if (outcol->is_cursor) { /* REFCURSOR */
- outcol->cb_retlen = -1;
- *bufpp = outcol->pstmt->pStmt;
- } else { /* "normal variable" */
- if (! outcol->data) {
- if (outcol->piecewise) {
- outcol->data = (text *) emalloc(outcol->piecesize);
- outcol->cursize = outcol->piecesize;
- outcol->curoffs = 0;
- }
- }
-
- if (! outcol->data) {
- php3_error(E_WARNING, "OCIFetch: cannot allocate %d bytes!",outcol->storage_size4);
- return OCI_ERROR;
- }
-
- if (outcol->piecewise) {
- if ((outcol->curoffs + outcol->piecesize) > outcol->cursize) {
- outcol->cursize += outcol->piecesize;
- outcol->data = erealloc(outcol->data,outcol->cursize);
- }
- outcol->cb_retlen = outcol->piecesize;
- *bufpp = ((char*)outcol->data) + outcol->curoffs;
- outcol->curoffs += outcol->piecesize;
- }
- }
-
- outcol->indicator = 0;
- outcol->retcode = 0;
-
- *alenp = &outcol->cb_retlen;
- *indpp = &outcol->indicator;
- *rcodep = &outcol->retcode;
- *piecep = OCI_ONE_PIECE;
-
- /*
- oci8_debug("oci8_define_callback: %s,*bufpp = %x,**alenp = %d,**indpp = %d, **rcodep= %d,
*piecep = %d",
- outcol->name,*bufpp,**alenp,**(ub2**)indpp,**rcodep,*piecep);
- */
-
- return OCI_CONTINUE;
-}
-
/* }}} */
/* {{{ oci8_bind_in_callback() */
Index: php3/functions/php3_oci8.h
diff -u php3/functions/php3_oci8.h:1.53 php3/functions/php3_oci8.h:1.54
--- php3/functions/php3_oci8.h:1.53 Thu Jul 8 10:02:54 1999
+++ php3/functions/php3_oci8.h Mon Sep 13 11:19:28 1999
@@ -127,7 +127,7 @@
sb2 indicator;
ub2 retcode;
ub2 retlen;
- ub4 cb_retlen;
+ ub4 retlen4;
ub2 is_descr;
ub2 is_cursor;
int descr;
@@ -136,12 +136,8 @@
int stmtid;
void *data;
oci8_define *define;
-
- /* for piecewise read */
int piecewise;
- int cursize;
- int curoffs;
- ub4 piecesize;
+ ub4 cb_retlen;
} oci8_out_column;
typedef struct {