CVS update: php3/functions
| From: | thies | Date: | Tue, 04 May 1999 15:24:40 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5362@lists.php.net to get a copy of this message | ||
Date: Tuesday May 4, 1999 @ 11:24
Author: thies
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv14981/functions
Modified Files:
oci8.c php3_oci8.h
Log Message:
added OCINlogon function
Index: php3/functions/oci8.c
diff -u php3/functions/oci8.c:1.86 php3/functions/oci8.c:1.87
--- php3/functions/oci8.c:1.86 Sat Apr 24 13:36:30 1999
+++ php3/functions/oci8.c Tue May 4 11:24:39 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.86 1999/04/24 17:36:30 thies Exp $ */
+/* $Id: oci8.c,v 1.87 1999/05/04 15:24:39 thies Exp $ */
/* TODO list:
*
@@ -183,14 +183,14 @@
static int oci8_fetch(oci8_statement *, ub4, char *);
static ub4 oci8_loaddesc(oci8_connection *, oci8_descriptor *, char **);
-static void oci8_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent);
+static void oci8_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclusive);
/* ServerAttach/Detach */
static oci8_server *oci8_open_server(char *dbname,int persistent);
static void _oci8_close_server(oci8_server *server);
/* SessionBegin/End */
-static oci8_session *oci8_open_user(oci8_server* server,char *username,char *password,int
persistent);
+static oci8_session *oci8_open_user(oci8_server* server,char *username,char *password,int
persistent,int exclusive);
static void _oci8_close_user(oci8_session *session);
/* bind callback functions */
@@ -220,6 +220,7 @@
void php3_oci8_internaldebug(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_logout(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS);
+void php3_oci8_nlogon(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_plogon(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_error(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_freedesc(INTERNAL_FUNCTION_PARAMETERS);
@@ -227,8 +228,6 @@
void php3_oci8_loaddesc(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_commit(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_rollback(INTERNAL_FUNCTION_PARAMETERS);
-void php3_oci8_newtrans(INTERNAL_FUNCTION_PARAMETERS);
-void php3_oci8_settrans(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_newdescriptor(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS);
@@ -271,6 +270,7 @@
{"ocirowcount", php3_oci8_rowcount, NULL},
{"ocilogoff", php3_oci8_logout, NULL},
{"ocilogon", php3_oci8_logon, NULL},
+ {"ocinlogon", php3_oci8_nlogon, NULL},
{"ociplogon", php3_oci8_plogon, NULL},
{"ocierror", php3_oci8_error, NULL},
{"ocifreedescriptor",php3_oci8_freedesc, NULL},
@@ -278,8 +278,6 @@
{"ociloaddesc", php3_oci8_loaddesc, NULL},
{"ocicommit", php3_oci8_commit, NULL},
{"ocirollback", php3_oci8_rollback, NULL},
- {"ocinewtransaction",php3_oci8_newtrans, NULL},
- {"ocisettransaction",php3_oci8_settrans, NULL},
{"ocinewdescriptor", php3_oci8_newdescriptor, NULL},
{NULL, NULL, NULL}
};
@@ -454,14 +452,14 @@
{
_oci8_close_user(session);
- return 0;
+ return 1;
}
static int _server_pcleanup(oci8_server *server)
{
_oci8_close_server(server);
- return 0;
+ return 1;
}
int php3_mshutdown_oci8(SHUTDOWN_FUNC_ARGS)
@@ -508,7 +506,7 @@
_oci8_close_user(session);
- return 0;
+ return 1;
}
static int _server_cleanup(oci8_server *server)
@@ -518,7 +516,7 @@
_oci8_close_server(server);
- return 0;
+ return 1;
}
int php3_rshutdown_oci8(SHUTDOWN_FUNC_ARGS)
@@ -898,6 +896,10 @@
value->type = IS_STRING;
value->value.str.len = loblen;
value->value.str.val = buffer;
+#if PHP_API_VERSION >= 19990421
+ value->refcount = 1;
+ value->is_ref = 0;
+#endif
} else {
var_reset(value);
}
@@ -940,6 +942,11 @@
value->type = IS_STRING;
value->value.str.len = size;
value->value.str.val = estrndup(column->data,size);
+#if PHP_API_VERSION >= 19990421
+ value->refcount = 1;
+ value->is_ref = 0;
+#endif
+
}
return 0;
@@ -1661,7 +1668,7 @@
/* {{{ oci8_open_user()
*/
-static oci8_session *oci8_open_user(oci8_server* server,char *username,char *password,int
persistent)
+static oci8_session *oci8_open_user(oci8_server* server,char *username,char *password,int
persistent,int exclusive)
{
sword error;
oci8_session *session = 0;
@@ -1690,15 +1697,23 @@
SAFE_STRING(password),
SAFE_STRING(server->dbname));
- _php3_hash_find(OCI8_GLOBAL(php3_oci8_module).user, hashed_details, hashed_details_length+1,
(void **) &session);
+ if (! exclusive) {
+ _php3_hash_find(OCI8_GLOBAL(php3_oci8_module).user, hashed_details, hashed_details_length+1,
(void **) &session);
- if (session) {
- if (session->open) {
- free(hashed_details);
- return session;
- } else {
- _oci8_close_user(session);
- /* breakthru to open */
+ if (session) {
+ if (session->open) {
+ if (persistent) {
+ session->persistent = 1;
+ }
+ free(hashed_details);
+ return session;
+ } else {
+ if (session) {
+ _oci8_close_user(session);
+ free(session);
+ }
+ /* breakthru to open */
+ }
}
}
@@ -1797,12 +1812,19 @@
session->num = OCI8_GLOBAL(php3_oci8_module).user_num++;
- _php3_hash_update(OCI8_GLOBAL(php3_oci8_module).user,
- hashed_details,
- hashed_details_length+1,
- (void *) session,
- sizeof(oci8_session),
- (void **) &session);
+ if (exclusive) {
+ _php3_hash_next_index_insert(OCI8_GLOBAL(php3_oci8_module).user,
+ (void *) session,
+ sizeof(oci8_session),
+ (void **) &session);
+ } else {
+ _php3_hash_add(OCI8_GLOBAL(php3_oci8_module).user,
+ hashed_details,
+ hashed_details_length+1,
+ (void *) session,
+ sizeof(oci8_session),
+ (void **) &session);
+ }
oci8_debug("oci8_open_user new sess=%d
user=%s",session->num,session->hashed_details);
@@ -1813,7 +1835,10 @@
CLEANUP:
oci8_debug("oci8_open_user: FAILURE -> CLEANUP called");
- _oci8_close_user(session);
+ if (session) {
+ _oci8_close_user(session);
+ free(session);
+ }
return 0;
}
@@ -1892,8 +1917,6 @@
if (session->hashed_details) {
free(session->hashed_details);
}
-
- free(session);
}
/* }}} */
@@ -1946,7 +1969,10 @@
return server;
} else { /* server "died" in the meantime - try to reconnect! */
- _oci8_close_server(server);
+ if (server) {
+ _oci8_close_server(server);
+ free(server);
+ }
/* breakthru to open */
}
}
@@ -2020,7 +2046,10 @@
CLEANUP:
oci8_debug("oci8_open_server: FAILURE -> CLEANUP called");
- _oci8_close_server(server);
+ if (server) {
+ _oci8_close_server(server);
+ free(server);
+ }
return 0;
}
@@ -2069,14 +2098,14 @@
free(server->hashed_details);
}
- free(server);
+ //XXX free(server);
}
/* }}} */
/* {{{ oci8_do_connect()
Connect to an Oracle database and log on. returns a new session.
*/
-static void oci8_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
+static void oci8_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclusive)
{
text *username, *password, *dbname;
pval *userParam, *passParam, *dbParam;
@@ -2119,14 +2148,12 @@
persistent = server->persistent; /* if our server-context is not persistent we can't */
- session = oci8_open_user(server,username,password,persistent);
+ session = oci8_open_user(server,username,password,persistent,exclusive);
if (! session) {
goto CLEANUP;
}
- persistent = session->persistent; /* if our session-context is not persistent we can't */
-
/* set our session */
connection->session = session;
@@ -2641,124 +2668,6 @@
}
/* }}} */
-/* {{{ proto string OCINewTrans(int conn, string name)
- */
-
-void php3_oci8_settrans(INTERNAL_FUNCTION_PARAMETERS)
-{
-}
-
-/* }}} */
-/* {{{ proto string OCINewTrans(int conn, string name)
- */
-
-void php3_oci8_newtrans(INTERNAL_FUNCTION_PARAMETERS)
-{
- pval *conn;
- oci8_connection *connection;
- oci8_xa *trans;
- sword ociresult;
- OCI8_TLS_VARS;
-
- if (getParameters(ht, 1, &conn) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long(conn);
-
- connection = oci8_get_conn(conn->value.lval, "OCINewTrans", list);
- if (connection == NULL) {
- RETURN_FALSE;
- }
-
- trans = (oci8_xa *) ecalloc(1,sizeof(oci8_xa));
-
- ociresult = OCIHandleAlloc(OCI8_GLOBAL(php3_oci8_module).pEnv,
- (dvoid **) &trans->pTrans,
- OCI_HTYPE_TRANS,
- 0,
- 0);
-
- if (ociresult) {
- oci8_error(connection->pError, "php3_oci8_newtrans OCIHandleAlloc OCI_HTYPE_TRANS",
ociresult);
- RETURN_FALSE;
- }
-
- ociresult = OCIAttrSet((dvoid *) connection->pServiceContext,
- OCI_HTYPE_SVCCTX,
- (dvoid *)trans->pTrans,
- 0,
- OCI_ATTR_TRANS,
- connection->pError);
-
- if (ociresult) {
- oci8_error(connection->pError, "php3_oci8_newtrans OCIAttrSet OCI_ATTR_TRANS",
ociresult);
- RETURN_FALSE;
- }
-
-#if 0
- trans->xid.formatID = -1; /* format id = 1000 */
- trans->xid.gtrid_length = 1; /* gtrid = 123 */
- trans->xid.data[0] = 0;
- trans->xid.data[1] = 2;
- trans->xid.data[2] = 3;
- trans->xid.bqual_length = 1; /* bqual = 2 */
- trans->xid.data[3] = 0;
-
- ociresult = OCIAttrSet((dvoid *)trans->pTrans,
- OCI_HTYPE_TRANS,
- (dvoid *)&trans->xid,
- sizeof(XID),
- OCI_ATTR_XID,
- connection->pError);
-
- if (ociresult) {
- oci8_error(connection->pError, "php3_oci8_newtrans OCIAttrSet OCI_ATTR_XID",
ociresult);
- RETURN_FALSE;
- }
-
- strcpy(trans->xname,"hallo");
-
- ociresult = OCIAttrSet((dvoid *)trans->pTrans,
- OCI_HTYPE_TRANS,
- (dvoid *)&trans->xname,
- strlen(trans->xname),
- OCI_ATTR_TRANS_NAME,
- connection->pError);
- if (ociresult) {
- oci8_error(connection->pError, "php3_oci8_newtrans OCIAttrSet OCI_ATTR_XID",
ociresult);
- RETURN_FALSE;
- }
-
-#endif
-
- /*
-Specifies whether a new transaction is being started or an existing transaction is being resumed.
Also specifies serializiability or read-only status. More than a single value can be specified.
-By default, a read/write transaction is started. The flag values are:
-
- OCI_TRANS_NEW - starts a new transaction branch. By default starts a tightly coupled and
migratable branch.
- OCI_TRANS_TIGHT - explicitly specifies a tightly coupled branch
- OCI_TRANS_LOOSE - specifies a loosely coupled branch
- OCI_TRANS_RESUME - resumes an existing transaction branch.
- OCI_TRANS_READONLY - start a read-only transaction
- OCI_TRANS_SERIALIZABLE - start a serializable transaction
- */
-
- ociresult = OCITransStart(connection->pServiceContext,
- connection->pError,
- (uword) 60,
- (ub4) OCI_TRANS_NEW);
-
- oci8_debug("OCITransStart=%d",ociresult);
-
- if (ociresult) {
- oci8_error(connection->pError, "OCITransStart", ociresult);
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
-}
-
-/* }}} */
/* {{{ proto string OCIRollback(int conn)
rollback the current context
*/
@@ -3109,7 +3018,10 @@
}
}
+#if PHP_API_VERSION < 19990421
element = emalloc(sizeof(pval));
+#endif
+
for (i = 0; i < statement->ncolumns; i++) {
column = oci8_get_col(statement, i + 1, 0, "OCIFetchInto");
@@ -3121,19 +3033,33 @@
continue;
}
+#if PHP_API_VERSION >= 19990421
+ element = emalloc(sizeof(pval));
+#endif
+
if ((mode & OCI_NUM) || (! (mode & OCI_ASSOC))) { /* OCI_NUM is default */
oci8_make_pval(element,statement,column, "OCIFetchInto",list,mode);
+#if PHP_API_VERSION >= 19990421
+ _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval*), NULL);
+#else
_php3_hash_index_update(array->value.ht, i, (void *)element, sizeof(pval), NULL);
+#endif
}
if (mode & OCI_ASSOC) {
oci8_make_pval(element,statement,column, "OCIFetchInto",list,mode);
+#if PHP_API_VERSION >= 19990421
+ _php3_hash_update(array->value.ht, column->name, column->name_len+1, (void
*)&element, sizeof(pval*), NULL);
+#else
_php3_hash_update(array->value.ht, column->name, column->name_len+1, (void *)element,
sizeof(pval), NULL);
+#endif
}
}
+#if PHP_API_VERSION < 19990421
efree(element);
+#endif
RETURN_LONG(statement->ncolumns);
}
@@ -3278,9 +3204,23 @@
* optional third parameter is not specified, PHP uses the environment
* variable ORACLE_SID to determine which database to connect to.
*/
+void php3_oci8_nlogon(INTERNAL_FUNCTION_PARAMETERS)
+{
+ oci8_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0,1);
+}
+
+/* }}} */
+/* {{{ proto int OCILogon(string user, string pass[, string db])
+ Connect to an Oracle database and log on. returns a new session.
+ */
+
+/* Connects to an Oracle 8 database and logs on. If the
+ * optional third parameter is not specified, PHP uses the environment
+ * variable ORACLE_SID to determine which database to connect to.
+ */
void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS)
{
- oci8_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
+ oci8_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0,0);
}
/* }}} */
@@ -3294,7 +3234,7 @@
*/
void php3_oci8_plogon(INTERNAL_FUNCTION_PARAMETERS)
{
- oci8_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
+ oci8_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1,0);
}
/* }}} */
Index: php3/functions/php3_oci8.h
diff -u php3/functions/php3_oci8.h:1.42 php3/functions/php3_oci8.h:1.43
--- php3/functions/php3_oci8.h:1.42 Thu Apr 22 09:19:50 1999
+++ php3/functions/php3_oci8.h Tue May 4 11:24:39 1999
@@ -24,6 +24,7 @@
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: Stig Sæther Bakken <ssb@fast.no> |
+ | Thies C. Arntzen <thies@digicol.de> |
| |
| Initial work sponsored by Thies Arntzen <thies@digicol.de> of |
| Digital Collections, http://www.digicol.de/
|
--
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