CVS update: php3/functions

From: Date: Fri, 28 May 1999 07:50:55 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6122@lists.php.net to get a copy of this message
Date: Friday May 28, 1999 @ 3:50 Author: thies Update of /repository/php3/functions In directory php:/tmp/cvs-serv28594/functions Modified Files: oci8.c php3_oci8.h Log Message: cleanup the OCIDefineByName stuff Index: php3/functions/oci8.c diff -u php3/functions/oci8.c:1.103 php3/functions/oci8.c:1.104 --- php3/functions/oci8.c:1.103 Thu May 27 08:09:57 1999 +++ php3/functions/oci8.c Fri May 28 03:50:53 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.103 1999/05/27 12:09:57 thies Exp $ */ +/* $Id: oci8.c,v 1.104 1999/05/28 07:50:53 thies Exp $ */ /* TODO list: * @@ -172,7 +172,7 @@ static oci8_statement *oci8_get_stmt(int, const char *, HashTable *); static oci8_out_column *oci8_get_col(oci8_statement *, int, pval *, char *); -static int oci8_make_pval(pval *,oci8_statement *,oci8_out_column *, char *,HashTable *, int mode); +static int oci8_make_pval(pval *,oci8_statement *,oci8_out_column *, char *, int mode); static int oci8_parse(oci8_connection *, char *, int, HashTable *); static int oci8_execute(oci8_statement *, char *,ub4 mode,HashTable *); static int oci8_fetch(oci8_statement *, ub4, char *); @@ -584,7 +584,7 @@ if (column->is_descr) { _php3_hash_index_del(column->statement->conn->descriptors,(int) column->data); } else { - if ((! column->define) && column->data) { + if (column->data) { efree(column->data); } } @@ -867,17 +867,17 @@ /* {{{ oci8_make_pval() */ static int -oci8_make_pval(pval *value,oci8_statement *statement,oci8_out_column *column, char *func,HashTable *list, int mode) +oci8_make_pval(pval *value,oci8_statement *statement,oci8_out_column *column, char *func, int mode) { size_t size; oci8_descriptor *descr; ub4 loblen; char *buffer; - /* - oci8_debug("oci8_make_pval: %16s,rlen = %4d,storage_size4 = %4d,size2 = %4d,indicator %4d, retcode = %4d", - column->name,column->rlen,column->storage_size4,column->size2,column->indicator,column->retcode); - */ + if (column->indicator || column->retcode) + if ((column->indicator != -1) && (column->retcode != 1405)) /* "normal" NULL column -> no interest for us! */ + oci8_debug("oci8_make_pval: %16s,rlen = %4d,storage_size4 = %4d,size2 = %4d,indicator %4d, retcode = %4d", + column->name,column->rlen,column->storage_size4,column->size2,column->indicator,column->retcode); memset(value,0,sizeof(pval)); @@ -928,12 +928,15 @@ } else { switch (column->retcode) { case 1406: /* ORA-01406 XXX truncated value */ + /* this seems to be a BUG in oracle with 1-digit numbers */ - /* - oci8_debugcol(column,"truncated"); - */ + if (column->rlen <= 0) { - size = 1; /* XXX this is our "oci-bug" */ + if (column->indicator > 0) { /* XXX this is our "oci-bug" */ + size = column->indicator; + } else { + size = 1; + } } else { if (column->piecewise) { size = (column->cursize - column->piecesize) + column->rlen; @@ -1011,17 +1014,17 @@ #if 0 /* testing */ { - ub4 prefetch = 5*1024; + ub4 prefetch = 512*1024; statement->error = oci8_error(statement->pError, - "OCIAttrSet OCI_ATTR_PREFETCH_ROWS", + "OCIAttrSet OCI_ATTR_PREFETCH_MEMORY", OCIAttrSet(statement->pStmt, OCI_HTYPE_STMT, - &prefetch, - 0, + 512*1024, //&prefetch, + 0, OCI_ATTR_PREFETCH_MEMORY, - &statement->pError)); + statement->pError)); } #endif @@ -1306,7 +1309,6 @@ { int i; oci8_out_column *column; - pval *pval; OCI8_TLS_VARS; /* first we need to reset our piecewise fetch-infos */ @@ -1315,11 +1317,6 @@ 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) { @@ -1356,41 +1353,14 @@ if (column == NULL) { /* should not happen... */ continue; } - - if ((column->define) && (! column->is_descr)) { - pval = column->define->pval; - if (! column->define->data) { /* oracle has NOT called our define_callback (column value is NULL) */ - pval->value.str.val = emalloc(column->storage_size4); - column->define->data = pval->value.str.val; - } - - if (column->indicator == -1) { /* NULL */ - pval->value.str.len = 0; - } else { - if (column->retcode == 1406) { /*XXX ORA-01406 truncated value */ - /* this seems to be a BUG in oracle with 1-digit numbers */ - /* - oci8_debugcol(column,"truncated"); - */ - if (column->rlen <= 0) { - pval->value.str.len = 1; /* XXX this is our "oci-bug" */ - } else { - pval->value.str.len = column->rlen; - } - pval->value.str.len = column->indicator - 1; /* when value is truncated indicator contains the lenght */ - } else { - - 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; + if (! column->define) { + continue; } + + pval_destructor(column->define->pval); + + oci8_make_pval(column->define->pval,statement,column,"OCIFetch",0); } return 1; @@ -1568,27 +1538,15 @@ ub2 **rcodep) { oci8_out_column *outcol; - oci8_define *define; - pval *pval, *tmp; oci8_descriptor *pdescr, descr; outcol = (oci8_out_column *)octxp; - define = outcol->define; if (outcol->is_cursor) { /* REFCURSOR */ outcol->rlen = -1; *bufpp = outcol->pstmt->pStmt; } else if (outcol->is_descr) { /* LOB or FILE */ - if (define && (! outcol->pdescr)) { /* column has been user-defined */ - if (_php3_hash_find(define->pval->value.ht, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) { - php3_error(E_WARNING, "unable to find my descriptor property"); - return OCI_ERROR; - } else if (_php3_hash_index_find(outcol->statement->conn->descriptors, tmp->value.lval, (void **)&pdescr) == FAILURE) { - php3_error(E_WARNING, "unable to find my descriptor"); - return OCI_ERROR; - } - outcol->pdescr = pdescr; - } else if (! outcol->pdescr) { /* we got no define value and the descriptor hasn't been allocated yet */ + if (! outcol->pdescr) { /* we got no define value and the descriptor hasn't been allocated yet */ if (outcol->type == SQLT_BFILE) { descr.type = OCI_DTYPE_FILE; } else if (outcol->type == SQLT_RDD ) { @@ -1622,29 +1580,6 @@ 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; - 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 (! outcol->data) { if (outcol->piecewise) { outcol->data = (text *) emalloc(outcol->piecesize); @@ -1673,11 +1608,6 @@ 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; @@ -3202,7 +3132,7 @@ #endif if ((mode & OCI_NUM) || (! (mode & OCI_ASSOC))) { /* OCI_NUM is default */ - oci8_make_pval(element,statement,column, "OCIFetchInto",list,mode); + oci8_make_pval(element,statement,column, "OCIFetchInto",mode); #if PHP_API_VERSION >= 19990421 _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval*), NULL); #else @@ -3211,7 +3141,7 @@ } if (mode & OCI_ASSOC) { - oci8_make_pval(element,statement,column, "OCIFetchInto",list,mode); + oci8_make_pval(element,statement,column, "OCIFetchInto",mode); #if PHP_API_VERSION >= 19990421 _php3_hash_update(array->value.ht, column->name, column->name_len+1, (void *)&element, sizeof(pval*), NULL); @@ -3283,7 +3213,7 @@ while (oci8_fetch(statement, nrows, "OCIFetchStatement")) { for (i = 0; i < statement->ncolumns; i++) { - oci8_make_pval(&element,statement,columns[ i ], "OCIFetchStatement",list,OCI_RETURN_LOBS); + oci8_make_pval(&element,statement,columns[ i ], "OCIFetchStatement",OCI_RETURN_LOBS); _php3_hash_index_update(outarrs[ i ]->value.ht, rows, (void *)&element, sizeof(pval), NULL); } rows++; @@ -3566,13 +3496,8 @@ 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; - } - oci8_make_pval(return_value,statement,outcol, "OCIResult",list,0); + oci8_make_pval(return_value,statement,outcol, "OCIResult",0); } /* }}} */ Index: php3/functions/php3_oci8.h diff -u php3/functions/php3_oci8.h:1.50 php3/functions/php3_oci8.h:1.51 --- php3/functions/php3_oci8.h:1.50 Thu May 27 08:09:57 1999 +++ php3/functions/php3_oci8.h Fri May 28 03:50:53 1999 @@ -90,7 +90,6 @@ text *name; ub4 name_len; ub4 type; - char *data; /* for pval cache */ } oci8_define; typedef struct { -- 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

« previous php.dev (#6122) next »