CVS update: php3/functions

From: Date: Thu, 06 May 1999 12:52:03 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-5386@lists.php.net to get a copy of this message
Date: Thursday May 6, 1999 @ 8:52 Author: thies Update of /repository/php3/functions In directory php:/tmp/cvs-serv14092/functions Modified Files: oci8.c php3_oci8.h Log Message: added select support for REFCURSORS Index: php3/functions/oci8.c diff -u php3/functions/oci8.c:1.90 php3/functions/oci8.c:1.91 --- php3/functions/oci8.c:1.90 Thu May 6 06:14:29 1999 +++ php3/functions/oci8.c Thu May 6 08:52:02 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.90 1999/05/06 10:14:29 thies Exp $ */ +/* $Id: oci8.c,v 1.91 1999/05/06 12:52:02 thies Exp $ */ /* TODO list: * @@ -179,7 +179,7 @@ static int oci8_make_pval(pval *,oci8_statement *,oci8_out_column *, char *,HashTable *, int mode); static int oci8_parse(oci8_connection *, char *, int, HashTable *); -static int oci8_execute(oci8_statement *, char *,ub4 mode); +static int oci8_execute(oci8_statement *, char *,ub4 mode,HashTable *); static int oci8_fetch(oci8_statement *, ub4, char *); static ub4 oci8_loaddesc(oci8_connection *, oci8_descriptor *, char **); @@ -214,6 +214,7 @@ void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS); +void php3_oci8_cancel(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetchstatement(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_freestatement(INTERNAL_FUNCTION_PARAMETERS); @@ -258,6 +259,7 @@ {"ocicolumnsize", php3_oci8_columnsize, NULL}, {"ocicolumntype", php3_oci8_columntype, NULL}, {"ociexecute", php3_oci8_execute, NULL}, + {"ocicancel", php3_oci8_cancel, NULL}, {"ocifetch", php3_oci8_fetch, NULL}, {"ocifetchinto", php3_oci8_fetchinto, a2_arg_force_ref}, {"ocifetchstatement",php3_oci8_fetchstatement,a2_arg_force_ref}, @@ -604,9 +606,7 @@ return; } - oci8_debug("_oci8_free_stmt: id=%d last_query=\"%s\"", - statement->id, - (statement->last_query?(char*)statement->last_query:"???")); + oci8_debug("_oci8_free_stmt: id=%d last_query=\"%s\"",statement->id,SAFE_STRING(statement->last_query)); if (statement->pStmt) { OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); @@ -885,7 +885,10 @@ return 0; } - if (column->is_descr) { + if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */ + value->type = IS_LONG; + value->value.lval = column->stmtid; + } else if (column->is_descr) { if ((column->type != SQLT_RDD) && (mode & OCI_RETURN_LOBS)) { /* OCI_RETURN_LOBS means that we want the content of the LOB back instead of the locator */ @@ -989,10 +992,17 @@ } #if 0 /* testing */ - { ub4 prefetch = 10*1024; + { + ub4 prefetch = 5*1024; - error = oci8_error(statement->pError, "OCIAttrSet OCI_ATTR_PREFETCH_ROWS", - OCIAttrSet(statement->pStmt,OCI_HTYPE_STMT,&prefetch,0,OCI_ATTR_PREFETCH_MEMORY,&statement->pError)); + error = oci8_error(statement->pError, + "OCIAttrSet OCI_ATTR_PREFETCH_ROWS", + OCIAttrSet(statement->pStmt, + OCI_HTYPE_STMT, + &prefetch, + 0, + OCI_ATTR_PREFETCH_MEMORY, + &statement->pError)); } #endif @@ -1003,7 +1013,7 @@ statement->id = php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt); oci8_debug("oci8_parse \"%s\" id=%d conn=%d", - query, + SAFE_STRING(query), statement->id, statement->conn->id); @@ -1014,7 +1024,7 @@ /* {{{ oci8_execute() */ static int -oci8_execute(oci8_statement *statement, char *func,ub4 mode) +oci8_execute(oci8_statement *statement, char *func,ub4 mode, HashTable *list) { oci8_out_column *outcol; oci8_out_column column; @@ -1198,6 +1208,14 @@ switch (outcol->type) { case SQLT_RSET: /* ref. cursor XXX NYI */ + outcol->stmtid = oci8_parse(statement->conn,0,0,list); + outcol->pstmt = oci8_get_stmt(outcol->stmtid, "OCIExecute",list); + + define_type = outcol->type; + outcol->is_cursor = 1; + outcol->storage_size4 = -1; + break; + case SQLT_RDD: /* ROWID */ case SQLT_BLOB: /* binary LOB */ case SQLT_CLOB: /* character LOB */ @@ -1225,6 +1243,7 @@ break; } + error = oci8_error( statement->pError, "OCIDefineByPos", @@ -1276,6 +1295,15 @@ OCI_FETCH_NEXT, OCI_DEFAULT); if (error == OCI_NO_DATA) { + + /* XXX this is needed for REFCURSORS! */ + if (statement->columns) { + _php3_hash_destroy(statement->columns); + efree(statement->columns); + statement->columns = 0; + } + statement->executed = 0; + return 0; } @@ -1488,9 +1516,11 @@ outcol = (oci8_out_column *)octxp; define = outcol->define; - - if (outcol->is_descr) { + 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"); @@ -2021,7 +2051,6 @@ server->open = 1; - /* server->failover.fo_ctx = (dvoid *) server; server->failover.callback_function = oci8_failover_callback; @@ -2036,7 +2065,6 @@ oci8_error(server->pError, "oci8_open_server OCIAttrSet OCI_ATTR_FOCBK", error); goto CLEANUP; } - */ oci8_debug("oci8_open_server new conn=%d dname=%s",server->num,server->dbname); @@ -2951,8 +2979,35 @@ if (statement == NULL) { RETURN_FALSE; } + + if (oci8_execute(statement, "OCIExecute",execmode,list)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} - if (oci8_execute(statement, "OCIExecute",execmode)) { +/* }}} */ +/* {{{ proto int OCICancel(int stmt) + Prepare a new row of data for reading. + */ + +void php3_oci8_cancel(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *stmt; + oci8_statement *statement; + OCI8_TLS_VARS; + + if (getParameters(ht, 1, &stmt) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(stmt); + + statement = oci8_get_stmt(stmt->value.lval, "OCICancel", list); + if (statement == NULL) { + RETURN_FALSE; + } + if (oci8_fetch(statement, 0, "OCICancel")) { RETURN_TRUE; } else { RETURN_FALSE; Index: php3/functions/php3_oci8.h diff -u php3/functions/php3_oci8.h:1.45 php3/functions/php3_oci8.h:1.46 --- php3/functions/php3_oci8.h:1.45 Thu May 6 06:14:29 1999 +++ php3/functions/php3_oci8.h Thu May 6 08:52:03 1999 @@ -131,8 +131,11 @@ ub2 retcode; ub4 rlen; ub2 is_descr; + ub2 is_cursor; int descr; oci8_descriptor *pdescr; + oci8_statement *pstmt; + int stmtid; void *data; oci8_define *define; } oci8_out_column; -- 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 (#5386) next »