CVS update: php3/functions

From: Date: Thu, 10 Sep 1998 17:58:01 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-907@lists.php.net to get a copy of this message
Date: Thursday September 10, 1998 @ 13:58 Author: ssb Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv26640/functions Modified Files: .cvsignore oci8.c php3_oci8.h Log Message: Added oci8_get_pval() for making pval* from a column. Added OCIColumnIsNULL() and OCIFetchInto(). Some more purify-fixes. Index: php3/functions/.cvsignore diff -c php3/functions/.cvsignore:1.1 php3/functions/.cvsignore:1.2 *** php3/functions/.cvsignore:1.1 Mon Aug 10 09:20:58 1998 --- php3/functions/.cvsignore Thu Sep 10 13:58:00 1998 *************** *** 1 **** --- 1,2 ---- ifx.c + .pure Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.8 php3/functions/oci8.c:1.9 *** php3/functions/oci8.c:1.8 Thu Sep 10 12:32:06 1998 --- php3/functions/oci8.c Thu Sep 10 13:58:00 1998 *************** *** 27,33 **** +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.8 1998/09/10 16:32:06 ssb Exp $ */ #include "php.h" #include "internal_functions.h" --- 27,33 ---- +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.9 1998/09/10 17:58:00 ssb Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 148,153 **** --- 148,154 ---- void php3_oci8_columnname(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_columnisnull(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS); *************** *** 167,172 **** --- 168,174 ---- {"ocicolumnname", php3_oci8_columnname, NULL}, {"ocicolumnsize", php3_oci8_columnsize, NULL}, {"ocicolumntype", php3_oci8_columntype, NULL}, + {"ocicolumnisnull", php3_oci8_columnisnull, NULL}, {"ocinumcols", php3_oci8_numcols, NULL}, {"ocifetch", php3_oci8_fetch, NULL}, {"ociresult", php3_oci8_result, NULL}, *************** *** 304,312 **** oci8_debug("Freeing statement handle for \"%s\".", statement->last_query); OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); OCIHandleFree(statement->pError, OCI_HTYPE_ERROR); ! OCI8_FREE(statement->last_query); ! _php3_hash_destroy(statement->columns); ! OCI8_FREE(statement->columns); OCI8_FREE(statement); } --- 306,320 ---- oci8_debug("Freeing statement handle for \"%s\".", statement->last_query); OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); OCIHandleFree(statement->pError, OCI_HTYPE_ERROR); ! if (statement->last_query) { ! OCI8_FREE(statement->last_query); ! } ! if (statement->columns) { ! _php3_hash_destroy(statement->columns); ! } ! if (statement->columns) { ! OCI8_FREE(statement->columns); ! } OCI8_FREE(statement); } *************** *** 464,469 **** --- 472,506 ---- } + static pval * + oci8_get_pval(oci8_out_column *column, char *func) + { + pval *value = OCI8_CALLOC(1,sizeof(pval)); + size_t size; + + switch (column->indicator) { + case -1: /* NULL value, return an empty string */ + var_reset(value); + return value; + case -2: /* truncated value */ + oci8_debug("%s: truncated column", func); + size = column->size; + break; + case 0: /* intact value */ + size = column->storage_size; + break; + default: + var_reset(value); + return value; + } + value->type = IS_STRING; + value->value.str.len = size; + value->value.str.val = OCI8_MALLOC(size); + memcpy(value->value.str.val, column->data, size); + return value; + } + + static int oci8_parse(oci8_connection *connection, text *query, ub4 len, HashTable *list) { *************** *** 594,601 **** statement->pError, counter, (dvoid *)outcol->data, outcol->storage_size, define_type, ! (dvoid *)0, (ub2 *)0, (ub2 *)0, ! OCI_DEFAULT); if (def_error) { oci8_error(statement->pError, func, def_error); --- 631,638 ---- statement->pError, counter, (dvoid *)outcol->data, outcol->storage_size, define_type, ! (dvoid *)&outcol->indicator, (ub2 *)0, ! (ub2 *)&outcol->retcode, OCI_DEFAULT); if (def_error) { oci8_error(statement->pError, func, def_error); *************** *** 625,640 **** if (error == OCI_NO_DATA) { return 0; } ! if (error == OCI_SUCCESS_WITH_INFO) { ! /* "Data was truncated or EOF was reached.", ! * the manual says. ! */ ! return 0; ! } ! if (error != OCI_SUCCESS) { ! oci8_error(statement->pError, func, error); ! return 0; } return 1; } --- 662,671 ---- if (error == OCI_NO_DATA) { return 0; } ! if (error == OCI_SUCCESS_WITH_INFO || error == OCI_SUCCESS) { ! return 1; } + oci8_error(statement->pError, func, error); return 1; } *************** *** 936,941 **** --- 967,1002 ---- } /* }}} */ + /* {{{ int OCIColumnIsNULL(int stmt, int col) */ + + void php3_oci8_columnisnull(INTERNAL_FUNCTION_PARAMETERS) + { + pval *stmt, *col; + oci8_statement *statement; + oci8_out_column *outcol; + OCI8_TLS_VARS; + + if (getParameters(ht, 2, &stmt, &col) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(stmt); + convert_to_long(col); + statement = oci8_get_stmt(stmt->value.lval, "OCIColumnIsNULL", list); + if (statement == NULL) { + RETURN_FALSE; + } + outcol = oci8_get_col(statement, col->value.lval, "OCIColumnIsNULL"); + if (outcol == NULL) { + RETURN_FALSE; + } + if (outcol->indicator == -1) { + RETVAL_TRUE; + } else { + RETVAL_FALSE; + } + } + + /* }}} */ /* {{{ int OCINumCols(int stmt) */ void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS) *************** *** 986,992 **** void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *col; oci8_statement *statement; oci8_out_column *outcol; OCI8_TLS_VARS; --- 1047,1053 ---- void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *col, *ret; oci8_statement *statement; oci8_out_column *outcol; OCI8_TLS_VARS; *************** *** 1003,1010 **** outcol = oci8_get_col(statement, col->value.lval, "OCIResult"); if (outcol == NULL) { RETURN_FALSE; } - RETVAL_STRING(outcol->data, 1); } /* }}} */ --- 1064,1076 ---- outcol = oci8_get_col(statement, col->value.lval, "OCIResult"); if (outcol == NULL) { RETURN_FALSE; + } + ret = oci8_get_pval(outcol, "OCIResult"); + if (ret == NULL) { + RETVAL_FALSE; + } else { + memcpy(return_value, ret, sizeof(pval)); } } /* }}} */ *************** *** 1039,1048 **** } /* }}} */ void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *array, element; oci8_statement *statement; oci8_out_column *column; ub4 nrows = 1; --- 1105,1115 ---- } /* }}} */ + /* {{{ int OCIFetchInto(int stmt, array &array) */ void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS) { ! pval *stmt, *array, *element; oci8_statement *statement; oci8_out_column *column; ub4 nrows = 1; *************** *** 1074,1088 **** if (column == NULL) { continue; } ! element.type = IS_STRING; ! element.value.str.len = column->size; ! element.value.str.val = OCI8_MALLOC(column->storage_size); ! memcpy(element.value.str.val, column->data, column->storage_size); _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval), NULL); } } #endif --- 1141,1154 ---- if (column == NULL) { continue; } ! element = oci8_get_pval(column, "OCIFetchInto"); _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval), NULL); } } + + /* }}} */ #endif Index: php3/functions/php3_oci8.h diff -c php3/functions/php3_oci8.h:1.6 php3/functions/php3_oci8.h:1.7 *** php3/functions/php3_oci8.h:1.6 Thu Sep 10 10:51:16 1998 --- php3/functions/php3_oci8.h Thu Sep 10 13:58:01 1998 *************** *** 80,85 **** --- 80,87 ---- ub2 size; ub2 storage_size; text *data; + sb2 indicator; + ub2 retcode; } oci8_out_column; typedef struct { *************** *** 100,113 **** extern php3_module_entry oci8_module_entry; # define oci8_module_ptr &oci8_module_entry ! # if 1 /* use system malloc, useful for purify */ # define OCI8_MALLOC malloc # define OCI8_CALLOC calloc # define OCI8_REALLOC realloc # define OCI8_FREE free # define OCI8_STRDUP strdup # define OCI8_STRNDUP strndup ! # else /* use PHP emalloc */ # define OCI8_MALLOC emalloc # define OCI8_CALLOC ecalloc # define OCI8_REALLOC erealloc --- 102,115 ---- extern php3_module_entry oci8_module_entry; # define oci8_module_ptr &oci8_module_entry ! # if 0 /* use system malloc, useful for purify */ # define OCI8_MALLOC malloc # define OCI8_CALLOC calloc # define OCI8_REALLOC realloc # define OCI8_FREE free # define OCI8_STRDUP strdup # define OCI8_STRNDUP strndup ! # else /* use PHP's emalloc */ # define OCI8_MALLOC emalloc # define OCI8_CALLOC ecalloc # define OCI8_REALLOC erealloc *************** *** 118,123 **** --- 120,126 ---- # define OCI8_MAX_NAME_LEN 64 + /* this one has to be changed to include persistent connections as well */ # define OCI8_CONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_conn) # define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt) -- 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 (#907) next »