CVS update: php3/functions

From: Date: Wed, 10 Feb 1999 14:36:13 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-4024@lists.php.net to get a copy of this message
Date: Wednesday February 10, 1999 @ 9:36 Author: thies Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv22724 Modified Files: oci8.c php3_oci8.h Log Message: ok, i believe we're "clean" now..... Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.33 php3/functions/oci8.c:1.34 *** php3/functions/oci8.c:1.33 Wed Feb 10 06:32:09 1999 --- php3/functions/oci8.c Wed Feb 10 09:36:12 1999 *************** *** 32,38 **** +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.33 1999/02/10 11:32:09 thies Exp $ */ #include "php.h" #include "internal_functions.h" --- 32,38 ---- +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.34 1999/02/10 14:36:12 thies Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 130,136 **** /* static int oci8_ping(oci8_connection *conn); XXX NYI */ static void oci8_debug(const char *format,...); static void oci8_close_conn(oci8_connection *connection); ! static void oci8_free_descr(dvoid *descr); static void oci8_free_stmt(oci8_statement *statement); static oci8_connection *oci8_get_conn(int, const char *, HashTable *, HashTable *); --- 130,136 ---- /* static int oci8_ping(oci8_connection *conn); XXX NYI */ static void oci8_debug(const char *format,...); static void oci8_close_conn(oci8_connection *connection); ! static void oci8_free_descr(oci8_descriptor *descr); static void oci8_free_stmt(oci8_statement *statement); static oci8_connection *oci8_get_conn(int, const char *, HashTable *, HashTable *); *************** *** 263,273 **** OCI8_GLOBAL(php3_oci8_module).num_persistent = 0; - /* - OCI8_GLOBAL(php3_oci8_module).le_descr = - register_list_destructors(oci8_free_descr, NULL); - */ - OCI8_GLOBAL(php3_oci8_module).le_conn = register_list_destructors(oci8_close_conn, NULL); --- 263,268 ---- *************** *** 388,396 **** oci8_debug("oci8_free_column:"); if (column->data) { ! if (column->is_descr && column->data) { ! oci8_debug("oci8_free_column: freeing descriptor %x",column->data); ! OCIDescriptorFree(column->data, OCI_DTYPE_LOB); } else { efree(column->data); } --- 383,390 ---- oci8_debug("oci8_free_column:"); if (column->data) { ! if (column->is_descr) { ! _php3_hash_index_del(column->statement->conn->descriptors,(int) column->data); } else { efree(column->data); } *************** *** 439,451 **** /* {{{ oci8_free_descr() */ static void ! oci8_free_descr(dvoid *descr) { OCI8_TLS_VARS; ! oci8_debug("oci8_free_descr: %x",descr); ! // OCIDescriptorFree(&descr, OCI_DTYPE_LOB); } /* }}} */ --- 433,445 ---- /* {{{ oci8_free_descr() */ static void ! oci8_free_descr(oci8_descriptor *descr) { OCI8_TLS_VARS; ! oci8_debug("oci8_free_descr: %x",descr->lob); ! OCIDescriptorFree(descr->lob, descr->type); } /* }}} */ *************** *** 459,468 **** oci8_debug("oci8_close_conn:"); ! if (connection->descriptors) { ! _php3_hash_destroy(connection->descriptors); ! efree(connection->descriptors); ! } connection->open = 0; oci8_error(connection->pError, "OCILogoff", --- 453,460 ---- oci8_debug("oci8_close_conn:"); ! _php3_hash_destroy(connection->descriptors); ! efree(connection->descriptors); connection->open = 0; oci8_error(connection->pError, "OCILogoff", *************** *** 620,625 **** --- 612,618 ---- if (column->is_descr) { statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list); object_init(value); + add_property_long(value, "connection", statement->conn->id); add_property_long(value, "descriptor", (long) column->data); add_method(value, "save", php3_oci8_savelob); *************** *** 690,695 **** --- 683,690 ---- oci8_out_column *outcol; oci8_out_column column; OCIParam *param; + oci8_descriptor descr; + oci8_descriptor *pdescr; int counter; sword error, def_error; ub2 define_type; *************** *** 741,746 **** --- 736,742 ---- /* out of memory */ return 0; } + outcol->statement = statement; /* get data type */ /* XXX can get OCI_ATTR_TYPE_NAME instead */ *************** *** 774,786 **** case SQLT_CLOB: /* character LOB */ case SQLT_BFILE: /* binary file LOB */ outcol->is_descr = 1; ! OCIDescriptorAlloc(statement->conn->pEnv,&(outcol->data), OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0); define_type = outcol->type; def_error = OCIDefineByPos(statement->pStmt, (OCIDefine **)&outcol->pDefine, statement->pError, counter, ! (dvoid *)&(outcol->data), (sb4)-1, define_type, (dvoid *)0, --- 770,791 ---- case SQLT_CLOB: /* character LOB */ case SQLT_BFILE: /* binary file LOB */ outcol->is_descr = 1; ! descr.type = OCI_DTYPE_LOB; ! OCIDescriptorAlloc(statement->conn->pEnv,(dvoid *)&(descr.lob), OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0); ! ! _php3_hash_index_update(statement->conn->descriptors, ! statement->conn->descriptors_count,&descr,sizeof(oci8_descriptor),(void **)&pdescr); ! ! outcol->data = (void *)(void *) statement->conn->descriptors_count++; ! ! oci8_debug("OCIExecute: new descriptor for %d -> %x",outcol->data,descr.lob); ! define_type = outcol->type; def_error = OCIDefineByPos(statement->pStmt, (OCIDefine **)&outcol->pDefine, statement->pError, counter, ! (dvoid *)&(pdescr->lob), (sb4)-1, define_type, (dvoid *)0, *************** *** 1016,1021 **** --- 1021,1027 ---- pval *stmt, *name, *var, *maxlen, *tmp,*type; oci8_statement *statement; oci8_bind *bind, *tmp_bind; + oci8_descriptor *descr; sword error; ub2 ocitype; sb4 ocimaxlen; *************** *** 1036,1057 **** WRONG_PARAM_COUNT; } switch (var->type) { case IS_OBJECT : if (_php3_hash_find(var->value.ht, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) { ! php3_error(E_WARNING, "unable to find my locator property"); RETURN_FALSE; } ! /* ! mydescr = (dvoid *) php3_list_find(tmp->value.lval, &descr_type); ! if (!mydescr || descr_type != OCI8_GLOBAL(php3_oci8_module).le_descr) { ! php3_error(E_WARNING, "unable to find identifier (%d)", tmp->value.lval); ! RETURN_FALSE; ! } ! */ ! mydescr = (dvoid *) tmp->value.lval; if (! mydescr) { RETURN_FALSE; --- 1042,1065 ---- WRONG_PARAM_COUNT; } + statement = oci8_get_stmt(stmt->value.lval, "OCIBindByName", list); + if (statement == NULL) { + RETURN_FALSE; + } + switch (var->type) { case IS_OBJECT : if (_php3_hash_find(var->value.ht, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) { ! php3_error(E_WARNING, "unable to find my descriptor property"); RETURN_FALSE; } ! if (_php3_hash_index_find(statement->conn->descriptors, tmp->value.lval, (void **)&descr) == FAILURE) { ! php3_error(E_WARNING, "unable to find my descriptor"); ! RETURN_FALSE; ! } ! mydescr = (dvoid *) descr->lob; if (! mydescr) { RETURN_FALSE; *************** *** 1069,1078 **** convert_to_long(stmt); convert_to_string(name); - statement = oci8_get_stmt(stmt->value.lval, "OCIBindByName", list); - if (statement == NULL) { - RETURN_FALSE; - } bind = ecalloc(1,sizeof(oci8_bind)); if (!bind) { /* out of memory */ --- 1077,1082 ---- *************** *** 1135,1152 **** void php3_oci8_freelob(INTERNAL_FUNCTION_PARAMETERS) { ! pval *id, *tmp; OCI8_TLS_VARS; if (getThis(&id) == SUCCESS) { ! if (_php3_hash_find(id->value.ht, "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) { php3_error(E_WARNING, "unable to find my locator property"); RETURN_FALSE; } ! php3_list_delete(tmp->value.lval); RETURN_TRUE; } --- 1139,1169 ---- void php3_oci8_freelob(INTERNAL_FUNCTION_PARAMETERS) { ! pval *id, *conn, *desc; ! oci8_connection *connection; OCI8_TLS_VARS; if (getThis(&id) == SUCCESS) { ! if (_php3_hash_find(id->value.ht, "connection", sizeof("connection"), (void **)&conn) == FAILURE) { ! php3_error(E_WARNING, "unable to find my statement property"); ! RETURN_FALSE; ! } ! ! connection = oci8_get_conn(conn->value.lval, "OCISaveLob", list, plist); ! if (connection == NULL) { ! RETURN_FALSE; ! } ! ! if (_php3_hash_find(id->value.ht, "descriptor", sizeof("descriptor"), (void **)&desc) == FAILURE) { php3_error(E_WARNING, "unable to find my locator property"); RETURN_FALSE; } ! oci8_debug("OCOFreeLob: descr=%d",desc->value.lval); + _php3_hash_index_del(connection->descriptors,desc->value.lval); + RETURN_TRUE; } *************** *** 1161,1166 **** --- 1178,1184 ---- pval *id, *tmp, *conn, *arg; OCILobLocator *mylob; oci8_connection *connection; + oci8_descriptor *descr; sword ociresult; ub4 loblen; *************** *** 1182,1199 **** RETURN_FALSE; } ! /* ! id_to_find = tmp->value.lval; ! mylob = (OCILobLocator *) php3_list_find(id_to_find, &lob_type); - if (!mylob || lob_type != OCI8_GLOBAL(php3_oci8_module).le_descr) { - php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find); - RETURN_FALSE; - } - */ - mylob = (OCILobLocator *) tmp->value.lval; - if (! mylob) { RETURN_FALSE; } --- 1200,1212 ---- RETURN_FALSE; } ! if (_php3_hash_index_find(connection->descriptors, tmp->value.lval, (void **)&descr) == FAILURE) { ! php3_error(E_WARNING, "unable to find my descriptor %d",tmp->value.lval); ! RETURN_FALSE; ! } ! mylob = (OCILobLocator *) descr->lob; if (! mylob) { RETURN_FALSE; } *************** *** 1244,1249 **** --- 1257,1263 ---- pval *id, *tmp, *conn; OCILobLocator *mylob; oci8_connection *connection; + oci8_descriptor *descr; sword ociresult; char *buffer; ub4 loblen; *************** *** 1252,1262 **** if (getThis(&id) == SUCCESS) { if (_php3_hash_find(id->value.ht, "connection", sizeof("connection"), (void **)&conn) == FAILURE) { ! php3_error(E_WARNING, "unable to find my connection property"); RETURN_FALSE; } ! connection = oci8_get_conn(conn->value.lval, "OCILoadLob", list, plist); if (connection == NULL) { RETURN_FALSE; } --- 1266,1276 ---- if (getThis(&id) == SUCCESS) { if (_php3_hash_find(id->value.ht, "connection", sizeof("connection"), (void **)&conn) == FAILURE) { ! php3_error(E_WARNING, "unable to find my statement property"); RETURN_FALSE; } ! connection = oci8_get_conn(conn->value.lval, "OCISaveLob", list, plist); if (connection == NULL) { RETURN_FALSE; } *************** *** 1266,1286 **** RETURN_FALSE; } ! /* ! id_to_find = tmp->value.lval; ! mylob = (OCILobLocator *) php3_list_find(id_to_find, &lob_type); ! if (!mylob || lob_type != OCI8_GLOBAL(php3_oci8_module).le_descr) { ! php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find); ! RETURN_FALSE; ! } ! */ ! mylob = (OCILobLocator *) tmp->value.lval; if (! mylob) { RETURN_FALSE; } ociresult = OCILobGetLength(connection->pServiceContext, connection->pError, mylob, &loblen); if (ociresult) { --- 1280,1298 ---- RETURN_FALSE; } ! if (_php3_hash_index_find(connection->descriptors, tmp->value.lval, (void **)&descr) == FAILURE) { ! php3_error(E_WARNING, "unable to find my descriptor %d",tmp->value.lval); ! RETURN_FALSE; ! } ! mylob = (OCILobLocator *) descr->lob; if (! mylob) { RETURN_FALSE; } + oci8_debug("OCILoadLob: found lob %x of type %d",descr->lob,descr->type); + ociresult = OCILobGetLength(connection->pServiceContext, connection->pError, mylob, &loblen); if (ociresult) { *************** *** 1329,1336 **** pval *conn; sword ociresult; oci8_connection *connection; ! OCILobLocator *mylob; ! ub4 type = OCI_DTYPE_LOB; OCI8_TLS_VARS; if (getParameters(ht, 1, &conn) == FAILURE) { --- 1341,1349 ---- pval *conn; sword ociresult; oci8_connection *connection; ! oci8_descriptor descr; ! int mylob; ! OCI8_TLS_VARS; if (getParameters(ht, 1, &conn) == FAILURE) { *************** *** 1342,1364 **** if (connection == NULL) { RETURN_FALSE; } ! ! ociresult = OCIDescriptorAlloc(connection->pEnv,(dvoid*)&(mylob), type, (size_t) 0, (dvoid **) 0); if (ociresult) { ! oci8_error(connection->pError,"OCIDescriptorAlloc %d",ociresult),type; RETURN_FALSE; } - - // _php3_hash_next_index_insert(connection->descriptors, &mylob, sizeof(void *),(void **) &mylob); object_init(return_value); add_property_long(return_value, "descriptor", (long) mylob); add_property_long(return_value, "connection", conn->value.lval); add_method(return_value, "free", php3_oci8_freelob); 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) --- 1355,1381 ---- if (connection == NULL) { RETURN_FALSE; } ! ! descr.type = OCI_DTYPE_LOB; ! ociresult = OCIDescriptorAlloc(connection->pEnv,(dvoid*)&(descr.lob), descr.type, (size_t) 0, (dvoid **) 0); if (ociresult) { ! oci8_error(connection->pError,"OCIDescriptorAlloc %d",ociresult); RETURN_FALSE; } + _php3_hash_index_update(connection->descriptors, connection->descriptors_count,&descr,sizeof(oci8_descriptor),NULL); + + mylob = connection->descriptors_count++; + + oci8_debug("OCINewDescriptor: new descriptor for %d -> %x",mylob,descr.lob); + object_init(return_value); add_property_long(return_value, "descriptor", (long) mylob); add_property_long(return_value, "connection", conn->value.lval); add_method(return_value, "free", php3_oci8_freelob); add_method(return_value, "save", php3_oci8_savelob); add_method(return_value, "load", php3_oci8_loadlob); } /* {{{ proto string OCIRollback(int stmt) *************** *** 1879,1890 **** /* non persistent, simply add to list */ connection->id = php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn); ! connection->descriptors = emalloc(sizeof(HashTable)); if (!connection->descriptors || ! _php3_hash_init(connection->descriptors, 13, NULL, ! (void (*)(void *))oci8_free_descr, 0) == FAILURE) { ! /* out of memory */ ! RETURN_FALSE; } RETVAL_LONG(connection->id); --- 1896,1907 ---- /* non persistent, simply add to list */ connection->id = php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn); ! ! connection->descriptors = emalloc(sizeof(HashTable)); if (!connection->descriptors || ! _php3_hash_init(connection->descriptors, 13, NULL,(void (*)(void *))oci8_free_descr, 0) == FAILURE) { ! /* out of memory */ ! RETURN_FALSE; } RETVAL_LONG(connection->id); Index: php3/functions/php3_oci8.h diff -c php3/functions/php3_oci8.h:1.20 php3/functions/php3_oci8.h:1.21 *** php3/functions/php3_oci8.h:1.20 Wed Feb 10 06:32:09 1999 --- php3/functions/php3_oci8.h Wed Feb 10 09:36:12 1999 *************** *** 64,77 **** OCISvcCtx *pServiceContext; OCIError *pError; OCISession *pSession; - /* - HashTable *statements; - */ HashTable *descriptors; int open; } oci8_connection; typedef struct { int id; oci8_connection *conn; OCIError *pError; --- 64,80 ---- OCISvcCtx *pServiceContext; OCIError *pError; OCISession *pSession; HashTable *descriptors; + int descriptors_count; int open; } oci8_connection; typedef struct { + OCILobLocator *lob; + ub4 type; + } oci8_descriptor; + + typedef struct { int id; oci8_connection *conn; OCIError *pError; *************** *** 92,107 **** } oci8_bind; typedef struct { OCIDefine *pDefine; text *name; ub4 name_len; ub2 type; ub2 size; ub2 storage_size; - void *data; sb2 indicator; ub2 retcode; ub2 is_descr; } oci8_out_column; typedef struct { --- 95,112 ---- } oci8_bind; typedef struct { + oci8_statement *statement; OCIDefine *pDefine; text *name; ub4 name_len; ub2 type; ub2 size; ub2 storage_size; sb2 indicator; ub2 retcode; ub2 is_descr; + int descr; + void *data; } oci8_out_column; 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 (#4024) next »