CVS update: php3/functions

From: Date: Tue, 09 Feb 1999 13:36:21 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-4010@lists.php.net to get a copy of this message
Date: Tuesday February 9, 1999 @ 8:36 Author: thies Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv10318 Modified Files: oci8.c php3_oci8.h Log Message: ...getting there descriptors still loose memory! Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.31 php3/functions/oci8.c:1.32 *** php3/functions/oci8.c:1.31 Tue Feb 9 07:06:22 1999 --- php3/functions/oci8.c Tue Feb 9 08:36:20 1999 *************** *** 27,38 **** | Authors: Stig Sæther Bakken <ssb@guardian.no> | | Thies C. Arntzen <thies@digicol.de> | | | ! | Initial work sponsored by Thies Arntzen <thies@digicol.de> of | | Digital Collections, http://www.digicol.de/ | +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.31 1999/02/09 12:06:22 thies Exp $ */ #include "php.h" #include "internal_functions.h" --- 27,38 ---- | Authors: Stig Sæther Bakken <ssb@guardian.no> | | Thies C. Arntzen <thies@digicol.de> | | | ! | Initial work sponsored by | | Digital Collections, http://www.digicol.de/ | +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.32 1999/02/09 13:36:20 thies Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 53,63 **** * * - Error mode (print or shut up?) * - returning refcursors as statement handles - * - ability to refer to columns by name as well as number * - OCIPasswordChange() * - Prefetching control * - support LONG > 64K ! * */ /* {{{ thread safety stuff */ --- 53,62 ---- * * - Error mode (print or shut up?) * - returning refcursors as statement handles * - OCIPasswordChange() * - Prefetching control * - support LONG > 64K ! * - binding of arrays */ /* {{{ thread safety stuff */ *************** *** 137,143 **** static oci8_connection *oci8_get_conn(int, const char *, HashTable *, HashTable *); static oci8_statement *oci8_get_stmt(int, const char *, HashTable *); static oci8_out_column *oci8_get_col(oci8_statement *, int, char *); ! static pval *oci8_make_pval(int,oci8_out_column *, char *,HashTable *); static int oci8_parse(oci8_connection *, text *, ub4, HashTable *); static int oci8_execute(oci8_statement *, char *,ub4 mode); static int oci8_fetch(oci8_statement *, ub4, char *); --- 136,142 ---- static oci8_connection *oci8_get_conn(int, const char *, HashTable *, HashTable *); static oci8_statement *oci8_get_stmt(int, const char *, HashTable *); static oci8_out_column *oci8_get_col(oci8_statement *, int, char *); ! static pval *oci8_make_pval(pval *,int,oci8_out_column *, char *,HashTable *); static int oci8_parse(oci8_connection *, text *, ub4, HashTable *); static int oci8_execute(oci8_statement *, char *,ub4 mode); static int oci8_fetch(oci8_statement *, ub4, char *); *************** *** 283,291 **** --- 282,292 ---- REGISTER_LONG_CONSTANT("OCI_COMMIT_ON_SUCCESS",OCI_COMMIT_ON_SUCCESS, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OCI_EXACT_FETCH",OCI_EXACT_FETCH, CONST_CS | CONST_PERSISTENT); + /* for OCIBindByName */ REGISTER_LONG_CONSTANT("SQLT_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SQLT_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT); + /* for OCIFetchInto */ REGISTER_LONG_CONSTANT("OCI_ASSOC",OCI_ASSOC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OCI_NUM",OCI_NUM, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OCI_BOTH",OCI_BOTH, CONST_CS | CONST_PERSISTENT); *************** *** 389,399 **** efree(column->data); } } - if (column->value) { - efree(column->value); - column->value = 0; - - } return 0; } --- 390,395 ---- *************** *** 406,412 **** OCI8_TLS_VARS; oci8_debug("oci8_free_stmt: id=%d last_query=\"%s\".",statement->id, ! (char *)(statement->last_query?statement->last_query:"???")); if (statement->pStmt) { OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); --- 402,408 ---- OCI8_TLS_VARS; oci8_debug("oci8_free_stmt: id=%d last_query=\"%s\".",statement->id, ! (statement->last_query?(char*)statement->last_query:"???")); if (statement->pStmt) { OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); *************** *** 442,448 **** { OCI8_TLS_VARS; ! oci8_debug("oci8_free_descr:"); /* XXX OCIDescriptorFree(column->data, OCI_DTYPE_LOB); */ } --- 438,444 ---- { OCI8_TLS_VARS; ! oci8_debug("oci8_free_descr: %x",descr); /* XXX OCIDescriptorFree(column->data, OCI_DTYPE_LOB); */ } *************** *** 597,609 **** /* {{{ oci8_make_pval() */ static pval * ! oci8_make_pval(int stmt_ind,oci8_out_column *column, char *func,HashTable *list) ! { size_t size; ! int locator; ! oci8_statement *statement; ! pval *value = ecalloc(1,sizeof(pval)); if (column->is_descr) { statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list); --- 593,613 ---- /* {{{ oci8_make_pval() */ static pval * ! oci8_make_pval(pval *val,int stmt_ind,oci8_out_column *column, char *func,HashTable *list) ! { size_t size; ! int locator; ! oci8_statement *statement; ! pval *value; + if (val) { + value = val; + } else { + value = emalloc(sizeof(pval)); + } + + memset(value,0,sizeof(pval)); + if (column->is_descr) { statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list); *************** *** 613,618 **** --- 617,623 ---- add_property_long(value, "connection", statement->conn->id); add_method(value, "save", php3_oci8_savelob); add_method(value, "load", php3_oci8_loadlob); + oci8_debug("oci8_make_pval: new descriptor for %x",column->data); } else { switch (column->indicator) { case -1: /* NULL value, return an empty string */ *************** *** 635,641 **** --- 640,648 ---- value->value.str.val = emalloc(size); memcpy(value->value.str.val, column->data, size); } + /* column->value = value; + */ return value; } *************** *** 667,677 **** statement->conn = connection; statement->id = php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt); - /* - oci8_debug("Added statement (%d) handle for \"%s\".",statement->id, - (char *)(statement->last_query?statement->last_query:"???")); - */ - return statement->id; } --- 674,679 ---- *************** *** 682,687 **** --- 684,690 ---- oci8_execute(oci8_statement *statement, char *func,ub4 mode) { oci8_out_column *outcol; + oci8_out_column column; OCIParam *param; int counter; sword error, def_error; *************** *** 700,705 **** --- 703,709 ---- iters = 1; } /* oci8_debug("oci8_execute: stmttype=%d mode=%d", stmttype, mode); */ + error = OCIStmtExecute(statement->conn->pServiceContext, statement->pStmt, statement->pError, iters, 0, NULL, NULL, mode); *************** *** 718,751 **** } if (stmttype == OCI_STMT_SELECT) { - OCIHandleAlloc(statement->conn->pEnv, (dvoid **)&param, OCI_DTYPE_PARAM, 0, NULL); counter = 1; error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT, statement->pError, (dvoid *)&param, counter); oci8_error(statement->pError, "oci8_execute2", error); while (error == OCI_SUCCESS) { ! outcol = ecalloc(1,sizeof(oci8_out_column)); ! if (_php3_hash_index_update(statement->columns, counter, outcol, ! sizeof(oci8_out_column), NULL) == FAILURE) { ! efree(outcol); efree(statement->columns); /* out of memory */ - return 0; - } else { - /* - oci8_debug("added info about column %d", counter); - */ - } - efree(outcol); - if (_php3_hash_index_find(statement->columns, counter, - (void **)&outcol) == FAILURE || - outcol == NULL) { - php3_error(E_WARNING, "%s: inserted column lost?!", func); return 0; ! } ! outcol->name = NULL; /* get data type */ /* XXX can get OCI_ATTR_TYPE_NAME instead */ --- 722,742 ---- } if (stmttype == OCI_STMT_SELECT) { OCIHandleAlloc(statement->conn->pEnv, (dvoid **)&param, OCI_DTYPE_PARAM, 0, NULL); counter = 1; error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT, statement->pError, (dvoid *)&param, counter); oci8_error(statement->pError, "oci8_execute2", error); + while (error == OCI_SUCCESS) { ! memset(&column,0,sizeof(oci8_out_column)); ! if (_php3_hash_index_update(statement->columns, counter, &column, ! sizeof(oci8_out_column), (void**) &outcol) == FAILURE) { efree(statement->columns); /* out of memory */ return 0; ! } /* get data type */ /* XXX can get OCI_ATTR_TYPE_NAME instead */ *************** *** 1323,1328 **** --- 1314,1320 ---- add_property_long(return_value, "connection", conn->value.lval); add_method(return_value, "save", php3_oci8_savelob); add_method(return_value, "load", php3_oci8_loadlob); + oci8_debug("OCINewDescriptor: new descriptor for %x",mylob); } /* {{{ proto string OCIRollback(int stmt) *************** *** 1627,1633 **** void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *array, *element, *fmode; oci8_statement *statement; oci8_out_column *column; ub4 nrows = 1; --- 1619,1625 ---- void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *array, element, *fmode; oci8_statement *statement; oci8_out_column *column; ub4 nrows = 1; *************** *** 1665,1682 **** continue; } - /* XXX i'm not sure if we need to duplicate the element */ if (mode & OCI_NUM) { ! element = oci8_make_pval(stmt->value.lval,column, "OCIFetchInto",list); ! _php3_hash_index_update(array->value.ht, i, (void *)element, sizeof(pval), NULL); } if (mode & OCI_ASSOC) { memcpy(namebuf,column->name, column->name_len); namebuf[ column->name_len ] = 0; ! element = oci8_make_pval(stmt->value.lval,column, "OCIFetchInto",list); ! _php3_hash_update(array->value.ht, namebuf, column->name_len+1, (void *)element, sizeof(pval), NULL); } } RETVAL_LONG(statement->ncolumns); --- 1657,1673 ---- continue; } if (mode & OCI_NUM) { ! oci8_make_pval(&element,stmt->value.lval,column, "OCIFetchInto",list); ! _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval), NULL); } if (mode & OCI_ASSOC) { memcpy(namebuf,column->name, column->name_len); namebuf[ column->name_len ] = 0; ! oci8_make_pval(&element,stmt->value.lval,column, "OCIFetchInto",list); ! _php3_hash_update(array->value.ht, namebuf, column->name_len+1, (void *)&element, sizeof(pval), NULL); } } RETVAL_LONG(statement->ncolumns); *************** *** 1925,1931 **** if (outcol == NULL) { RETURN_FALSE; } ! ret = oci8_make_pval(stmt->value.lval,outcol, "OCIResult",list); if (ret == NULL) { RETVAL_FALSE; } else { --- 1916,1922 ---- if (outcol == NULL) { RETURN_FALSE; } ! ret = oci8_make_pval(0,stmt->value.lval,outcol, "OCIResult",list); if (ret == NULL) { RETVAL_FALSE; } else { Index: php3/functions/php3_oci8.h diff -c php3/functions/php3_oci8.h:1.18 php3/functions/php3_oci8.h:1.19 *** php3/functions/php3_oci8.h:1.18 Tue Feb 9 06:45:02 1999 --- php3/functions/php3_oci8.h Tue Feb 9 08:36:20 1999 *************** *** 102,108 **** sb2 indicator; ub2 retcode; ub2 is_descr; - pval *value; } oci8_out_column; typedef struct { --- 102,107 ---- -- 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 (#4010) next »