Date: 03/30/99
- Next message: ssb: "[PHP-DEV] CVS update: php3/functions"
- Previous message: Bug Database: "[PHP-DEV] Bug #1276 Updated: OCIBindByName with DATE variable -> error"
- Next in thread: ssb: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tuesday March 30, 1999 @ 5:20
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv16700
Modified Files:
oci8.c php3_oci8.h
Log Message:
some cleanup,
persistend connections still are NOT great!!!
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.69 php3/functions/oci8.c:1.70
*** php3/functions/oci8.c:1.69 Mon Mar 15 14:04:36 1999
--- php3/functions/oci8.c Tue Mar 30 05:20:15 1999
***************
*** 33,39 ****
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
! /* $Id: oci8.c,v 1.69 1999/03/15 19:04:36 thies Exp $ */
/* TODO list:
*
--- 33,39 ----
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
! /* $Id: oci8.c,v 1.70 1999/03/30 10:20:15 thies Exp $ */
/* TODO list:
*
***************
*** 426,431 ****
--- 426,433 ----
int php3_rshutdown_oci8()
{
+ oci8_debug("php3_rshutdown_oci8");
+ /* XXX free all statements, rollback all outstanding transactions */
return SUCCESS;
}
***************
*** 512,519 ****
{
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);
--- 514,524 ----
{
OCI8_TLS_VARS;
! oci8_debug("oci8_free_stmt: id=%d last_query=\"%s\" conn=%d persistent=%d.",
! statement->id,
! (statement->last_query?(char*)statement->last_query:"???"),
! statement->conn->id,
! statement->conn->persistent);
if (statement->pStmt) {
OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
***************
*** 590,609 ****
static void
oci8_close_conn(oci8_connection *connection)
{
- int persistent = 0;
-
OCI8_TLS_VARS;
! oci8_debug("oci8_close_conn: id=%d persistent=%d",connection->id,persistent);
!
! _php3_hash_destroy(connection->descriptors);
! if (persistent) {
! free(connection->descriptors);
! } else {
! efree(connection->descriptors);
}
connection->open = 0;
oci8_error(connection->pError,"OCISessionEnd",
--- 595,616 ----
static void
oci8_close_conn(oci8_connection *connection)
{
OCI8_TLS_VARS;
! oci8_debug("oci8_close_conn: id=%d persistent=%d",connection->id,connection->persistent);
! if (connection->descriptors) {
! _php3_hash_destroy(connection->descriptors);
}
+ if (connection->descriptors) {
+ if (connection->persistent) {
+ free(connection->descriptors);
+ } else {
+ efree(connection->descriptors);
+ }
+ }
+
connection->open = 0;
oci8_error(connection->pError,"OCISessionEnd",
***************
*** 626,632 ****
OCI8_GLOBAL(php3_oci8_module).num_links--;
! if (persistent) {
free(connection);
} else {
efree(connection);
--- 633,639 ----
OCI8_GLOBAL(php3_oci8_module).num_links--;
! if (connection->persistent) {
free(connection);
} else {
efree(connection);
***************
*** 910,916 ****
statement->conn = connection;
statement->id = php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt);
! oci8_debug("oci8_parse \"%s\" id=%d",query,statement->id);
return statement->id;
}
--- 917,927 ----
statement->conn = connection;
statement->id = php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt);
! oci8_debug("oci8_parse \"%s\" id=%d conn=%d persistent=%d",
! query,
! statement->id,
! statement->conn->id,
! statement->conn->persistent);
return statement->id;
}
***************
*** 1537,1543 ****
(ub4) OCI_ATTR_USERNAME,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_USERNAME", error);
! goto ERROR;
}
if (OCIAttrSet((dvoid *) session->pSession,
--- 1548,1554 ----
(ub4) OCI_ATTR_USERNAME,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_USERNAME", error);
! goto CLEANUP;
}
if (OCIAttrSet((dvoid *) session->pSession,
***************
*** 1547,1553 ****
(ub4) OCI_ATTR_PASSWORD,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_PASSWORD", error);
! goto ERROR;
}
if (OCIAttrSet((dvoid *) session->pServiceContext,
--- 1558,1564 ----
(ub4) OCI_ATTR_PASSWORD,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_PASSWORD", error);
! goto CLEANUP;
}
if (OCIAttrSet((dvoid *) session->pServiceContext,
***************
*** 1557,1563 ****
(ub4) OCI_ATTR_SERVER,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_SERVER", error);
! goto ERROR;
}
if (OCISessionBegin(session->pServiceContext,
--- 1568,1574 ----
(ub4) OCI_ATTR_SERVER,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_SERVER", error);
! goto CLEANUP;
}
if (OCISessionBegin(session->pServiceContext,
***************
*** 1566,1572 ****
(ub4) OCI_CRED_RDBMS,
(ub4) OCI_DEFAULT)) {
oci8_error(session->pError, "OCISessionBegin", error);
! goto ERROR;
}
if (OCIAttrSet((dvoid *) session->pServiceContext,
--- 1577,1583 ----
(ub4) OCI_CRED_RDBMS,
(ub4) OCI_DEFAULT)) {
oci8_error(session->pError, "OCISessionBegin", error);
! goto CLEANUP;
}
if (OCIAttrSet((dvoid *) session->pServiceContext,
***************
*** 1576,1590 ****
(ub4) OCI_ATTR_SESSION,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_SESSION", error);
! goto ERROR;
}
session->id = php3_list_insert(session, OCI8_GLOBAL(php3_oci8_module).le_session);
return session;
! ERROR:
efree(session);
return 0;
}
--- 1587,1602 ----
(ub4) OCI_ATTR_SESSION,
session->pError)) {
oci8_error(session->pError, "OCIAttrSet OCI_ATTR_SESSION", error);
! goto CLEANUP;
}
session->id = php3_list_insert(session, OCI8_GLOBAL(php3_oci8_module).le_session);
return session;
! CLEANUP:
efree(session);
+
return 0;
}
***************
*** 1659,1665 ****
text *username, *password, *dbname;
pval *userParam, *passParam, *dbParam;
ub4 username_len, password_len, dbname_len;
! oci8_connection *connection;
sword error;
char *hashed_details;
int hashed_details_length;
--- 1671,1677 ----
text *username, *password, *dbname;
pval *userParam, *passParam, *dbParam;
ub4 username_len, password_len, dbname_len;
! oci8_connection *connection = 0;
sword error;
char *hashed_details;
int hashed_details_length;
***************
*** 1704,1711 ****
if (_php3_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==SUCCESS) { /* got you!!! */
if (le->type != OCI8_GLOBAL(php3_oci8_module).le_pconn) {
! efree(hashed_details);
! RETURN_FALSE;
}
/* XXX we should do something like an ping here to check for dead connections!!! */
--- 1716,1722 ----
if (_php3_hash_find(plist, hashed_details, hashed_details_length+1, (void **) &le)==SUCCESS) { /* got you!!! */
if (le->type != OCI8_GLOBAL(php3_oci8_module).le_pconn) {
! goto CLEANUP;
}
/* XXX we should do something like an ping here to check for dead connections!!! */
***************
*** 1714,1732 ****
oci8_debug("oci8_do_connect: persistent connection id=%d",connection->id);
- RETVAL_LONG(connection->id);
efree(hashed_details);
! return;
} else {
if (OCI8_GLOBAL(php3_oci8_module).max_links!=-1 && OCI8_GLOBAL(php3_oci8_module).num_links>=OCI8_GLOBAL(php3_oci8_module).max_links) {
php3_error(E_WARNING,"OCI8: Too many open links (%d)",OCI8_GLOBAL(php3_oci8_module).num_links);
! efree(hashed_details);
! RETURN_FALSE;
}
if (OCI8_GLOBAL(php3_oci8_module).max_persistent!=-1 && OCI8_GLOBAL(php3_oci8_module).num_persistent>=OCI8_GLOBAL(php3_oci8_module).max_persistent) {
php3_error(E_WARNING,"OCI8: Too many open persistent links (%d)",OCI8_GLOBAL(php3_oci8_module).num_persistent);
! efree(hashed_details);
! RETURN_FALSE;
}
/* fall thru an go ahead */
--- 1725,1741 ----
oci8_debug("oci8_do_connect: persistent connection id=%d",connection->id);
efree(hashed_details);
!
! RETURN_LONG(connection->id);
} else {
if (OCI8_GLOBAL(php3_oci8_module).max_links!=-1 && OCI8_GLOBAL(php3_oci8_module).num_links>=OCI8_GLOBAL(php3_oci8_module).max_links) {
php3_error(E_WARNING,"OCI8: Too many open links (%d)",OCI8_GLOBAL(php3_oci8_module).num_links);
! goto CLEANUP;
}
if (OCI8_GLOBAL(php3_oci8_module).max_persistent!=-1 && OCI8_GLOBAL(php3_oci8_module).num_persistent>=OCI8_GLOBAL(php3_oci8_module).max_persistent) {
php3_error(E_WARNING,"OCI8: Too many open persistent links (%d)",OCI8_GLOBAL(php3_oci8_module).num_persistent);
! goto CLEANUP;
}
/* fall thru an go ahead */
***************
*** 1745,1750 ****
--- 1754,1761 ----
if (connection == NULL) {
RETURN_OUT_OF_MEMORY;
}
+
+ connection->persistent = persistent;
/* Set up the Oracle environment. */
***************
*** 1766,1796 ****
error = OCIAttrSet((dvoid *) connection->pSession,(ub4) OCI_HTYPE_SESSION, (dvoid *) username, (ub4) username_len, (ub4) OCI_ATTR_USERNAME, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_USERNAME", error);
! RETURN_FALSE;
}
error = OCIAttrSet((dvoid *) connection->pSession,(ub4) OCI_HTYPE_SESSION, (dvoid *) password, (ub4) password_len, (ub4) OCI_ATTR_PASSWORD, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_PASSWORD", error);
! RETURN_FALSE;
}
error = OCIAttrSet((dvoid *)connection->pServiceContext, (ub4) OCI_HTYPE_SVCCTX,(dvoid *) connection->pServer, (ub4) 0, (ub4) OCI_ATTR_SERVER, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_SERVER", error);
! RETURN_FALSE;
}
error = OCISessionBegin(connection->pServiceContext,connection->pError,connection->pSession, (ub4) OCI_CRED_RDBMS, (ub4) OCI_DEFAULT);
if (error) {
oci8_error(connection->pError, "OCISessionBegin", error);
! RETURN_FALSE;
}
error = OCIAttrSet((dvoid *)connection->pServiceContext,(ub4) OCI_HTYPE_SVCCTX, (dvoid *) connection->pSession, (ub4) 0, (ub4) OCI_ATTR_SESSION, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_SESSION", error);
! RETURN_FALSE;
}
connection->open = 1;
--- 1777,1807 ----
error = OCIAttrSet((dvoid *) connection->pSession,(ub4) OCI_HTYPE_SESSION, (dvoid *) username, (ub4) username_len, (ub4) OCI_ATTR_USERNAME, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_USERNAME", error);
! goto CLEANUP;
}
error = OCIAttrSet((dvoid *) connection->pSession,(ub4) OCI_HTYPE_SESSION, (dvoid *) password, (ub4) password_len, (ub4) OCI_ATTR_PASSWORD, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_PASSWORD", error);
! goto CLEANUP;
}
error = OCIAttrSet((dvoid *)connection->pServiceContext, (ub4) OCI_HTYPE_SVCCTX,(dvoid *) connection->pServer, (ub4) 0, (ub4) OCI_ATTR_SERVER, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_SERVER", error);
! goto CLEANUP;
}
error = OCISessionBegin(connection->pServiceContext,connection->pError,connection->pSession, (ub4) OCI_CRED_RDBMS, (ub4) OCI_DEFAULT);
if (error) {
oci8_error(connection->pError, "OCISessionBegin", error);
! goto CLEANUP;
}
error = OCIAttrSet((dvoid *)connection->pServiceContext,(ub4) OCI_HTYPE_SVCCTX, (dvoid *) connection->pSession, (ub4) 0, (ub4) OCI_ATTR_SESSION, connection->pError);
if (error) {
oci8_error(connection->pError, "OCIAttrSet OCI_ATTR_SESSION", error);
! goto CLEANUP;
}
connection->open = 1;
***************
*** 1804,1810 ****
if (!connection->descriptors ||
_php3_hash_init(connection->descriptors, 13, NULL,(void (*)(void *))oci8_free_descr, 0) == FAILURE) {
/* out of memory */
! RETURN_FALSE;
}
OCI8_GLOBAL(php3_oci8_module).num_links++;
--- 1815,1821 ----
if (!connection->descriptors ||
_php3_hash_init(connection->descriptors, 13, NULL,(void (*)(void *))oci8_free_descr, 0) == FAILURE) {
/* out of memory */
! goto CLEANUP;
}
OCI8_GLOBAL(php3_oci8_module).num_links++;
***************
*** 1818,1825 ****
if (_php3_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
/* XXX close connection here */
! efree(hashed_details);
! RETURN_FALSE;
}
OCI8_GLOBAL(php3_oci8_module).num_persistent++;
--- 1829,1835 ----
if (_php3_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
/* XXX close connection here */
! goto CLEANUP;
}
OCI8_GLOBAL(php3_oci8_module).num_persistent++;
***************
*** 1828,1840 ****
connection->id = php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn);
}
! oci8_debug("OCILogon: new connection id=%d",connection->id);
efree(hashed_details);
OCI8_GLOBAL(php3_oci8_module).num_links++;
! RETVAL_LONG(connection->id);
}
/* }}} */
--- 1838,1861 ----
connection->id = php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn);
}
! oci8_debug("OCILogon: new connection id=%d persistent=%d",connection->id,connection->persistent);
efree(hashed_details);
OCI8_GLOBAL(php3_oci8_module).num_links++;
+
+ RETURN_LONG(connection->id);
+
+ CLEANUP:
+ if (hashed_details) {
+ efree(hashed_details);
+ }
+
+ if (connection) {
+ oci8_close_conn(connection);
+ }
! RETURN_FALSE;
}
/* }}} */
***************
*** 1900,1906 ****
define->type = ocitype;
define->pval = var;
! RETVAL_TRUE;
}
/* }}} */
--- 1921,1927 ----
define->type = ocitype;
define->pval = var;
! RETURN_TRUE;
}
/* }}} */
***************
*** 2024,2030 ****
RETURN_FALSE;
}
! RETVAL_TRUE;
}
/* }}} */
--- 2045,2051 ----
RETURN_FALSE;
}
! RETURN_TRUE;
}
/* }}} */
***************
*** 2346,2352 ****
if (outcol == NULL) {
RETURN_FALSE;
}
! RETVAL_STRINGL(outcol->name, outcol->name_len, 1);
}
/* }}} */
--- 2367,2374 ----
if (outcol == NULL) {
RETURN_FALSE;
}
!
! RETURN_STRINGL(outcol->name, outcol->name_len, 1);
}
/* }}} */
***************
*** 2373,2379 ****
if (outcol == NULL) {
RETURN_FALSE;
}
! RETVAL_LONG(outcol->size4);
}
/* }}} */
--- 2395,2401 ----
if (outcol == NULL) {
RETURN_FALSE;
}
! RETURN_LONG(outcol->size4);
}
/* }}} */
***************
*** 2464,2472 ****
RETURN_FALSE;
}
if (outcol->indicator == -1) {
! RETVAL_TRUE;
} else {
! RETVAL_FALSE;
}
}
--- 2486,2494 ----
RETURN_FALSE;
}
if (outcol->indicator == -1) {
! RETURN_TRUE;
} else {
! RETURN_FALSE;
}
}
***************
*** 2519,2527 ****
}
if (oci8_execute(statement, "OCIExecute",execmode)) {
! RETVAL_TRUE;
} else {
! RETVAL_FALSE;
}
}
--- 2541,2549 ----
}
if (oci8_execute(statement, "OCIExecute",execmode)) {
! RETURN_TRUE;
} else {
! RETURN_FALSE;
}
}
***************
*** 2547,2555 ****
RETURN_FALSE;
}
if (oci8_fetch(statement, nrows, "OCIFetch")) {
! RETVAL_TRUE;
} else {
! RETVAL_FALSE;
}
}
--- 2569,2577 ----
RETURN_FALSE;
}
if (oci8_fetch(statement, nrows, "OCIFetch")) {
! RETURN_TRUE;
} else {
! RETURN_FALSE;
}
}
***************
*** 2616,2622 ****
}
}
! RETVAL_LONG(statement->ncolumns);
}
/* }}} */
--- 2638,2644 ----
}
}
! RETURN_LONG(statement->ncolumns);
}
/* }}} */
***************
*** 2683,2689 ****
efree(columns);
efree(outarrs);
! RETVAL_LONG(rows);
}
/* }}} */
--- 2705,2711 ----
efree(columns);
efree(outarrs);
! RETURN_LONG(rows);
}
/* }}} */
***************
*** 2708,2714 ****
php3_list_delete(stmt->value.lval);
! RETVAL_TRUE;
}
/* }}} */
--- 2730,2736 ----
php3_list_delete(stmt->value.lval);
! RETURN_TRUE;
}
/* }}} */
***************
*** 2743,2752 ****
}
if (php3_list_delete(index) == SUCCESS) {
! RETVAL_TRUE;
} else {
oci8_debug("OCILogoff: php3_list_delete failed.");
! RETVAL_FALSE;
}
}
--- 2765,2774 ----
}
if (php3_list_delete(index) == SUCCESS) {
! RETURN_TRUE;
} else {
oci8_debug("OCILogoff: php3_list_delete failed.");
! RETURN_FALSE;
}
}
***************
*** 2838,2846 ****
if (session) {
! RETVAL_LONG(session->id);
} else {
! RETVAL_FALSE;
}
}
--- 2860,2868 ----
if (session) {
! RETURN_LONG(session->id);
} else {
! RETURN_FALSE;
}
}
***************
*** 2947,2953 ****
if (statement == NULL) {
RETURN_FALSE;
}
! RETVAL_LONG(statement->ncolumns);
}
/* }}} */
--- 2969,2975 ----
if (statement == NULL) {
RETURN_FALSE;
}
! RETURN_LONG(statement->ncolumns);
}
/* }}} */
***************
*** 2973,2979 ****
RETURN_FALSE;
}
! RETVAL_LONG(oci8_parse(connection,
query->value.str.val,
query->value.str.len,
list));
--- 2995,3001 ----
RETURN_FALSE;
}
! RETURN_LONG(oci8_parse(connection,
query->value.str.val,
query->value.str.len,
list));
***************
*** 3042,3048 ****
oci8_error(connection->pError, "OCIServerVersion", error);
RETURN_FALSE;
}
! RETVAL_STRING(version,1);
}
/* }}} */
--- 3064,3070 ----
oci8_error(connection->pError, "OCIServerVersion", error);
RETURN_FALSE;
}
! RETURN_STRING(version,1);
}
/* }}} */
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.34 php3/functions/php3_oci8.h:1.35
*** php3/functions/php3_oci8.h:1.34 Mon Mar 15 14:04:36 1999
--- php3/functions/php3_oci8.h Tue Mar 30 05:20:15 1999
***************
*** 68,73 ****
--- 68,74 ----
typedef struct {
int id;
+ int persistent;
OCIEnv *pEnv;
OCIServer *pServer;
OCISvcCtx *pServiceContext;
***************
*** 166,172 ****
/* this one has to be changed to include persistent connections as well */
# define OCI8_SERVER_TYPE(x) (((x)==OCI8_GLOBAL(php3_oci8_module).le_server) || ((x)==OCI8_GLOBAL(php3_oci8_module).le_pserver))
! # define OCI8_CONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_conn)
# define OCI8_PCONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_pconn)
# define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt)
# define OCI8_DESCR_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_descr)
--- 167,173 ----
/* this one has to be changed to include persistent connections as well */
# define OCI8_SERVER_TYPE(x) (((x)==OCI8_GLOBAL(php3_oci8_module).le_server) || ((x)==OCI8_GLOBAL(php3_oci8_module).le_pserver))
! # define OCI8_CONN_TYPE(x) (((x)==OCI8_GLOBAL(php3_oci8_module).le_conn) || ((x)==OCI8_GLOBAL(php3_oci8_module).le_pconn))
# define OCI8_PCONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_pconn)
# define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt)
# define OCI8_DESCR_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_descr)
-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: ssb: "[PHP-DEV] CVS update: php3/functions"
- Previous message: Bug Database: "[PHP-DEV] Bug #1276 Updated: OCIBindByName with DATE variable -> error"
- Next in thread: ssb: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

