CVS update: php3/functions
| From: | ssb | Date: | Thu, 10 Sep 1998 09:56:42 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-898@lists.php.net to get a copy of this message | ||
Date: Thursday September 10, 1998 @ 5:56
Author: ssb
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv22479
Modified Files:
oci8.c php3_oci8.h
Log Message:
Made OCI8 changes: make OCIExecute() aware of LOB types
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.4 php3/functions/oci8.c:1.5
*** php3/functions/oci8.c:1.4 Wed Sep 9 14:33:21 1998
--- php3/functions/oci8.c Thu Sep 10 05:56:40 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.4 1998/09/09 18:33:21 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.5 1998/09/10 09:56:40 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 126,131 ****
--- 126,132 ----
void php3_oci8_columnname(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS);
+ void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS);
/* }}} */
/* {{{ extension definition structures */
***************
*** 140,145 ****
--- 141,147 ----
{"ocicolumnname", php3_oci8_columnname, NULL},
{"ocicolumnsize", php3_oci8_columnsize, NULL},
{"ocicolumntype", php3_oci8_columntype, NULL},
+ {"ocinumcols", php3_oci8_numcols, NULL},
{NULL, NULL, NULL}
};
***************
*** 337,343 ****
php3i_oci8_error(OCIError *err_p, char *what, sword status)
{
text errbuf[512];
! ub4 errcode;
switch (status) {
case OCI_SUCCESS:
--- 339,345 ----
php3i_oci8_error(OCIError *err_p, char *what, sword status)
{
text errbuf[512];
! ub4 errcode = 0;
switch (status) {
case OCI_SUCCESS:
***************
*** 459,465 ****
RETURN_FALSE;
}
! connection = (oci8_connection *)emalloc(sizeof(oci8_connection));
if (connection == NULL) {
RETURN_OUT_OF_MEMORY;
--- 461,467 ----
RETURN_FALSE;
}
! connection = (oci8_connection *)ecalloc(1,sizeof(oci8_connection));
if (connection == NULL) {
RETURN_OUT_OF_MEMORY;
***************
*** 550,556 ****
query = arg2->value.str.val;
query_len = arg2->value.str.len;
! statement = emalloc(sizeof(oci8_statement));
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pStmt,
OCI_HTYPE_STMT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
--- 552,558 ----
query = arg2->value.str.val;
query_len = arg2->value.str.len;
! statement = ecalloc(1,sizeof(oci8_statement));
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pStmt,
OCI_HTYPE_STMT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
***************
*** 578,584 ****
oci8_out_column *outcol;
OCIParam *param;
int stmt, type, counter;
! sword error;
if (getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
--- 580,587 ----
oci8_out_column *outcol;
OCIParam *param;
int stmt, type, counter;
! sword error, def_error;
! ub2 define_type;
if (getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
***************
*** 613,625 ****
(dvoid *)¶m, counter);
php3i_oci8_error(statement->pError, "OCIParamGet", error);
while (error == OCI_SUCCESS) {
! outcol = emalloc(sizeof(oci8_out_column));
if (_php3_hash_index_update(statement->columns, counter, outcol,
sizeof(oci8_out_column), NULL) == FAILURE) {
efree(outcol->data);
efree(outcol);
efree(statement->columns);
RETURN_OUT_OF_MEMORY;
}
efree(outcol);
_php3_hash_index_find(statement->columns, counter, (void **)&outcol);
--- 616,630 ----
(dvoid *)¶m, counter);
php3i_oci8_error(statement->pError, "OCIParamGet", 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->data);
efree(outcol);
efree(statement->columns);
RETURN_OUT_OF_MEMORY;
+ } else {
+ OCI8_DEBUG("added info about column %d", counter);
}
efree(outcol);
_php3_hash_index_find(statement->columns, counter, (void **)&outcol);
***************
*** 641,667 ****
(ub4 *)&outcol->name_len,
(ub4)OCI_ATTR_NAME, statement->pError));
outcol->data = (text *)emalloc(outcol->max_size + 1);
! if (php3i_oci8_error(statement->pError, "OCIDefineByPos",
! OCIDefineByPos(statement->pStmt,
! (OCIDefine **)&outcol->pDefine,
! statement->pError, counter,
! (dvoid *)outcol->data,
! outcol->max_size, SQLT_STR,
! (dvoid *)0, (ub2 *)0, (ub2 *)0,
! OCI_DEFAULT))) {
efree(outcol->data);
efree(outcol);
efree(statement->columns);
RETURN_FALSE;
}
!
counter++;
error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT,
statement->pError, (dvoid *)¶m, counter);
}
-
RETURN_TRUE;
}
--- 646,693 ----
(ub4 *)&outcol->name_len,
(ub4)OCI_ATTR_NAME, statement->pError));
+ /* "Scalar" data types are stored directly in strings,
+ * while others, like large objects (LOBs) need to be
+ * handled specially.
+ */
+ switch (outcol->type) {
+ case SQLT_BLOB:
+ case SQLT_CLOB:
+ case SQLT_BFILEE:
+ case SQLT_CFILEE:
+ define_type = outcol->type;
+ break;
+ default:
+ define_type = SQLT_STR;
+ break;
+ }
outcol->data = (text *)emalloc(outcol->max_size + 1);
+ if (outcol->data == NULL) {
+ efree(outcol);
+ efree(statement->columns);
+ RETURN_OUT_OF_MEMORY;
+ }
+
+ def_error = OCIDefineByPos(statement->pStmt,
+ (OCIDefine **)&outcol->pDefine,
+ statement->pError, counter,
+ (dvoid *)outcol->data,
+ outcol->max_size, define_type,
+ (dvoid *)0, (ub2 *)0, (ub2 *)0,
+ OCI_DEFAULT);
! if (def_error) {
! php3i_oci8_error(statement->pError, "OCIDefineByPos", def_error);
efree(outcol->data);
efree(outcol);
efree(statement->columns);
RETURN_FALSE;
}
! statement->ncolumns = counter;
counter++;
error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT,
statement->pError, (dvoid *)¶m, counter);
}
RETURN_TRUE;
}
***************
*** 750,757 ****
RETURN_FALSE;
}
! RETVAL_LONG(outcol->type);
}
#endif
--- 776,838 ----
RETURN_FALSE;
}
! switch (outcol->type) {
! case SQLT_DAT:
! RETVAL_STRING("DATE",1);
! break;
! case SQLT_NUM:
! RETVAL_STRING("NUMBER",1);
! break;
! case SQLT_LNG:
! RETVAL_STRING("LONG",1);
! break;
! case SQLT_BIN:
! RETVAL_STRING("RAW",1);
! break;
! case SQLT_LBI:
! RETVAL_STRING("LONG RAW",1);
! break;
! case SQLT_CHR:
! RETVAL_STRING("VARCHAR",1);
! break;
! case SQLT_AFC:
! RETVAL_STRING("CHAR",1);
! break;
! case SQLT_BLOB:
! RETVAL_STRING("BLOB",1);
! break;
! case SQLT_CLOB:
! RETVAL_STRING("CLOB",1);
! break;
! case SQLT_BFILE:
! RETVAL_STRING("BFILE",1);
! break;
! default:
! RETVAL_LONG(outcol->type);
! }
}
+
+
+ void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *arg;
+ oci8_statement *statement;
+ int stmt, type;
+
+ if (getParameters(ht, 1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(arg);
+ stmt = arg->value.lval;
+
+ statement = (oci8_statement *)php3_list_find(stmt, &type);
+ if (!statement || !OCI8_STMT_TYPE(type)) {
+ php3_error(E_WARNING, "Invalid statement handle (%d).", stmt);
+ RETURN_FALSE;
+ }
+ RETVAL_LONG(statement->ncolumns);
+ }
+
#endif
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.3 php3/functions/php3_oci8.h:1.4
*** php3/functions/php3_oci8.h:1.3 Wed Sep 9 14:33:21 1998
--- php3/functions/php3_oci8.h Thu Sep 10 05:56:41 1998
***************
*** 68,73 ****
--- 68,74 ----
OCIStmt *pStmt;
text *last_query;
HashTable *columns;
+ int ncolumns;
HashTable *binds;
} oci8_statement;
***************
*** 94,101 ****
int le_conn;
/* int le_pconn;*/
int le_stmt;
- HashTable *list;
- HashTable *plist;
} oci8_module;
extern php3_module_entry oci8_module_entry;
--- 95,100 ----
--
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