cvs: php4 /ext/interbase interbase.c

From: Date: Fri, 19 Jul 2002 09:21:30 +0000
Subject: cvs: php4 /ext/interbase interbase.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12882@lists.php.net to get a copy of this message
derick Fri Jul 19 05:21:30 2002 EDT Modified files: /php4/ext/interbase interbase.c Log: Unify error messages

Index: php4/ext/interbase/interbase.c diff -u php4/ext/interbase/interbase.c:1.87 php4/ext/interbase/interbase.c:1.88 --- php4/ext/interbase/interbase.c:1.87 Wed Jun 26 03:54:50 2002 +++ php4/ext/interbase/interbase.c Fri Jul 19 05:21:29 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.87 2002/06/26 07:54:50 sas Exp $ */ +/* $Id: interbase.c,v 1.88 2002/07/19 09:21:29 derick Exp $ */ /* TODO: Arrays, roles? @@ -213,7 +213,7 @@ } else if (Z_TYPE_P(blob_arg) != IS_STRING\ || Z_STRLEN_P(blob_arg) != sizeof(ibase_blob_handle)\ || ((ibase_blob_handle *)(Z_STRVAL_P(blob_arg)))->bl_handle != 0){\ - _php_ibase_module_error("invalid blob id");\ + _php_ibase_module_error("Invalid blob id");\ RETURN_FALSE;\ } else {\ ib_blob = (ibase_blob_handle *)Z_STRVAL_P(blob_arg);\ @@ -262,13 +262,12 @@ } /* }}} */ -/* {{{ _php_ibase_error() +/* {{{ _php_ibase_error(TSRMLS_D) print interbase error and save it for ibase_errmsg() */ -static void _php_ibase_error(void) +static void _php_ibase_error(TSRMLS_D) { char *s; ISC_STATUS *statusp; - TSRMLS_FETCH(); s = IBG(errmsg); statusp = IB_STATUS; @@ -276,7 +275,7 @@ strcat(IBG(errmsg), " "); s = IBG(errmsg) + strlen(IBG(errmsg)); } - php_error(E_WARNING, "InterBase: %s", IBG(errmsg)); + php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), IBG(errmsg)); } /* }}} */ @@ -292,7 +291,7 @@ vsnprintf(IBG(errmsg), MAX_ERRMSG, msg, ap); va_end(ap); - php_error(E_WARNING, "InterBase module: %s", IBG(errmsg)); + php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), IBG(errmsg)); } /* }}} */ @@ -330,7 +329,7 @@ if (link->trans[0] != NULL) { /* commit default */ IBDEBUG("Committing default transaction..."); if (isc_commit_transaction(IB_STATUS, &link->trans[0])) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } link->trans[0] = NULL; } @@ -338,7 +337,7 @@ if (link->trans[i] != NULL) { IBDEBUG("Rolling back other transactions..."); if (isc_rollback_transaction(IB_STATUS, &link->trans[i])) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } link->trans[i] = NULL; } @@ -396,7 +395,7 @@ if ( !(IB_STATUS[0] && IB_STATUS[1]) && ib_result->drop_stmt && ib_result->stmt ) { IBDEBUG("Dropping statement handle (free_result)..."); if (isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, DSQL_drop)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } } else { /* Shouldn't be here unless query was select and had parameter @@ -438,7 +437,7 @@ if ( !(IB_STATUS[0] && IB_STATUS[1]) && ib_query->stmt) { IBDEBUG("Dropping statement handle (free_query)..."); if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)){ - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } } if (ib_query->in_array) { @@ -489,7 +488,7 @@ if (ib_link->trans[ib_trans->trans_num] != NULL) { IBDEBUG("Rolling back unhandled transaction..."); if (isc_rollback_transaction(IB_STATUS, &ib_link->trans[ib_trans->trans_num])) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } ib_link->trans[ib_trans->trans_num] = NULL; } @@ -608,7 +607,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Interbase Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.87 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.88 $"); #ifdef COMPILE_DL_INTERBASE php_info_print_table_row(2, "Dynamic Module", "yes"); #endif @@ -692,7 +691,7 @@ dpb_length = dpb - dpb_buffer; if (isc_attach_database(IB_STATUS, (short) strlen(server), server, db, (short) dpb_length, dpb_buffer)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } return SUCCESS; @@ -975,7 +974,7 @@ if (isc_array_lookup_bounds(IB_STATUS, &link, &trans, var->relname, var->sqlname, ar_desc)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); efree(IB_ARRAY); IB_ARRAY = NULL; return FAILURE; @@ -1014,7 +1013,7 @@ IB_ARRAY[ar_cnt].el_size = ar_desc->array_desc_length+sizeof(short); break; default: - _php_ibase_module_error("unexpected array type %d in relation '%s' column '%s')", + _php_ibase_module_error("Unexpected array type %d in relation '%s' column '%s'", ar_desc->array_desc_dtype, var->relname, var->sqlname); efree(IB_ARRAY); IB_ARRAY = NULL; @@ -1059,7 +1058,7 @@ IB_QUERY->dialect = dialect; if (isc_dsql_allocate_statement(IB_STATUS, &link, &IB_QUERY->stmt)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); goto _php_ibase_alloc_query_error; } @@ -1068,7 +1067,7 @@ IB_QUERY->out_sqlda->version = SQLDA_VERSION1; if (isc_dsql_prepare(IB_STATUS, &IB_QUERY->trans, &IB_QUERY->stmt, 0, query, dialect, IB_QUERY->out_sqlda)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); goto _php_ibase_alloc_query_error; } @@ -1078,7 +1077,7 @@ IB_QUERY->out_sqlda->sqln = IB_QUERY->out_sqlda->sqld; IB_QUERY->out_sqlda->version = SQLDA_VERSION1; if (isc_dsql_describe(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, IB_QUERY->out_sqlda)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); goto _php_ibase_alloc_query_error; } } @@ -1088,7 +1087,7 @@ IB_QUERY->in_sqlda->sqln = 0; IB_QUERY->in_sqlda->version = SQLDA_VERSION1; if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, IB_QUERY->in_sqlda)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); goto _php_ibase_alloc_query_error; } @@ -1098,7 +1097,7 @@ IB_QUERY->in_sqlda->sqln = IB_QUERY->in_sqlda->sqld; IB_QUERY->in_sqlda->version = SQLDA_VERSION1; if (isc_dsql_describe_bind(IB_STATUS, &IB_QUERY->stmt, SQLDA_VERSION1, IB_QUERY->in_sqlda)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); goto _php_ibase_alloc_query_error; } } @@ -1178,7 +1177,7 @@ case SQL_SHORT: convert_to_long(b_var); if (Z_LVAL_P(b_var) > SHRT_MAX || Z_LVAL_P(b_var) < SHRT_MIN) { - _php_ibase_module_error("field %*s overflow", var->aliasname_length, var->aliasname); + _php_ibase_module_error("Field %*s overflow", var->aliasname_length, var->aliasname); return FAILURE; } buf[i].val.sval = (short)Z_LVAL_P(b_var); @@ -1244,7 +1243,7 @@ n = sscanf(Z_STRVAL_P(b_var), "%d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d", &t.tm_mon, &t.tm_mday, &t.tm_year, &t.tm_hour, &t.tm_min, &t.tm_sec); if(n != 3 && n != 6){ - _php_ibase_module_error("invalid date/time format: Expected 3 or 6 fields, got %d. Use format m/d/Y H:i:s. You gave '%s'", n, Z_STRVAL_P(b_var)); + _php_ibase_module_error("Invalid date/time format: Expected 3 or 6 fields, got %d. Use format m/d/Y H:i:s. You gave '%s'", n, Z_STRVAL_P(b_var)); return FAILURE; } t.tm_year -= 1900; @@ -1311,22 +1310,22 @@ ib_blob->bl_handle = NULL; if (isc_create_blob(IB_STATUS, &ib_blob->link, &ib_blob->trans_handle, &ib_blob->bl_handle, &ib_blob->bl_qd)) { efree(ib_blob); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } convert_to_string(b_var); if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, (unsigned short) Z_STRLEN_P(b_var), Z_STRVAL_P(b_var))) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } if (isc_close_blob(IB_STATUS, &ib_blob->bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } ib_blob_id = ib_blob; var->sqldata = (void ISC_FAR *)&ib_blob_id->bl_qd; /* - _php_ibase_module_error("invalid blob id string"); + _php_ibase_module_error("Invalid blob id string"); return FAILURE; */ } else { @@ -1337,7 +1336,7 @@ } break; case SQL_ARRAY: - _php_ibase_module_error("binding arrays not supported yet"); + _php_ibase_module_error("Binding arrays not supported yet"); return FAILURE; break; } /*switch*/ @@ -1439,21 +1438,21 @@ if (ib_query->in_sqlda) { /* has placeholders */ IBDEBUG("Query wants XSQLDA for input"); if (ib_query->in_sqlda->sqld != argc) { - _php_ibase_module_error("placeholders (%d) and variables (%d) mismatch", ib_query->in_sqlda->sqld, argc); + _php_ibase_module_error("Placeholders (%d) and variables (%d) mismatch", ib_query->in_sqlda->sqld, argc); goto _php_ibase_exec_error; /* yes mommy, goto! */ } in_sqlda = emalloc(XSQLDA_LENGTH(ib_query->in_sqlda->sqld)); memcpy(in_sqlda, ib_query->in_sqlda, XSQLDA_LENGTH(ib_query->in_sqlda->sqld)); bind_buf = emalloc(sizeof(BIND_BUF) * ib_query->in_sqlda->sqld); if (_php_ibase_bind(in_sqlda, args, bind_buf, ib_query) == FAILURE) { - IBDEBUG("Could not bind input XSQLDA... (_php_ibase_exec)"); + IBDEBUG("Could not bind input XSQLDA"); goto _php_ibase_exec_error; } } if (isc_dsql_execute(IB_STATUS, &ib_query->trans, &ib_query->stmt, ib_query->dialect, in_sqlda)) { - IBDEBUG("Could not execute query... (_php_ibase_exec)"); - _php_ibase_error(); + IBDEBUG("Could not execute query"); + _php_ibase_error(TSRMLS_C); goto _php_ibase_exec_error; } @@ -1555,12 +1554,12 @@ && ib_link->trans[trans_n]; trans_n++) ; if (trans_n == IBASE_TRANS_ON_LINK) { - _php_ibase_module_error("too many transactions on link"); + _php_ibase_module_error("Too many transactions on link"); RETURN_FALSE; } if (isc_start_transaction(IB_STATUS, &ib_link->trans[trans_n], 1, &ib_link->link, tpb_len, tpbp)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -1579,7 +1578,7 @@ if (trans_n == 0 && ib_link->trans[0] == NULL) { if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } } @@ -1621,12 +1620,12 @@ if (commit) { if (isc_commit_transaction(IB_STATUS, &ib_link->trans[trans_n])) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } } else { if (isc_rollback_transaction(IB_STATUS, &ib_link->trans[trans_n])) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } } @@ -1694,7 +1693,7 @@ query = Z_STRVAL_PP(args[i]); i++; /* next arg */ } else { - _php_ibase_module_error("query argument missed"); + _php_ibase_module_error("Query argument missed"); efree(args); RETURN_FALSE; } @@ -1895,7 +1894,7 @@ if (dim > 16) { /* InterBase limit */ - _php_ibase_module_error("php module internal error in %s %d", __FILE__, __LINE__); + _php_ibase_module_error("Too many dimensions"); return FAILURE; } @@ -1968,7 +1967,7 @@ ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, "InterBase result", le_result); if (ib_result->out_sqlda == NULL) { - _php_ibase_module_error("trying to fetch results from a non-select query"); + _php_ibase_module_error("Trying to fetch results from a non-select query"); RETURN_FALSE; } @@ -1977,7 +1976,7 @@ } if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */ - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2018,13 +2017,13 @@ char bl_items[1], *bl_data, bl_info[20], *p; if (isc_open_blob(IB_STATUS, &ib_result->link, &ib_result->trans, &bl_handle, (ISC_QUAD ISC_FAR *) var->sqldata)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } bl_items[0] = isc_info_blob_total_length; if (isc_blob_info(IB_STATUS, &bl_handle, sizeof(bl_items), bl_items, sizeof(bl_info), bl_info)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2048,20 +2047,20 @@ cur_len += seg_len; if (cur_len > max_len) { /* never!*/ efree(bl_data); - _php_ibase_module_error("php module internal error in %s %d", __FILE__, __LINE__); + _php_ibase_module_error("PHP module internal error"); RETURN_FALSE; } } if (IB_STATUS[0] && IB_STATUS[1] && (IB_STATUS[1] != isc_segstr_eof)) { efree(bl_data); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } bl_data[cur_len] = '\0'; if (isc_close_blob(IB_STATUS, &bl_handle)) { efree(bl_data); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } Z_TYPE_P(tmp) = IS_STRING; @@ -2096,7 +2095,7 @@ if (isc_array_get_slice(IB_STATUS, &ib_result->link, &ib_result->trans, &ar_qd, &ib_array->ar_desc, ar_data, &ib_array->ar_size)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2278,7 +2277,7 @@ IBDEBUG("Implicitly closing a cursor"); if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_close)){ efree(args); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); } } @@ -2318,11 +2317,11 @@ } /* }}} */ +#if HAVE_STRFTIME /* {{{ proto int ibase_timefmt(string format) Sets the format of timestamp, date and time columns returned from queries */ PHP_FUNCTION(ibase_timefmt) { -#if HAVE_STRFTIME pval ***args; char *fmt = NULL; int type = PHP_IBASE_TIMESTAMP; @@ -2369,12 +2368,9 @@ efree(args); RETURN_TRUE; -#else - _php_ibase_module_error("ibase_timefmt not supported on this platform"); - RETURN_FALSE; -#endif } /* }}} */ +#endif /* {{{ proto int ibase_num_fields(int result) Get the number of fields in result */ @@ -2392,7 +2388,7 @@ ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result, -1, "InterBase result", le_result); if (ib_result->out_sqlda == NULL) { - _php_ibase_module_error("trying to get num fields from a non-select query"); + _php_ibase_module_error("Trying to get the number of fields from a non-select query"); RETURN_FALSE; } @@ -2420,7 +2416,7 @@ ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, "InterBase result", le_result); if (ib_result->out_sqlda == NULL) { - _php_ibase_module_error("trying to get field info from a non-select query"); + _php_ibase_module_error("Trying to get field info from a non-select query"); RETURN_FALSE; } @@ -2500,7 +2496,7 @@ bl_info->bl_stream = 0; if (isc_blob_info(IB_STATUS, &bl_handle, sizeof(bl_items), bl_items, sizeof(bl_inf), bl_inf)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); return FAILURE; } @@ -2527,7 +2523,7 @@ break; case isc_info_truncated: case isc_info_error: /* hmm. don't think so...*/ - _php_ibase_module_error("php module internal error in %s %d", __FILE__, __LINE__); + _php_ibase_module_error("PHP module internal error"); return FAILURE; } /*switch*/ p += item_len; @@ -2575,7 +2571,7 @@ if (isc_create_blob(IB_STATUS, &ib_blob->link, &ib_blob->trans_handle, &ib_blob->bl_handle, &ib_blob->bl_qd)) { efree(ib_blob); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2611,7 +2607,7 @@ ib_blob->bl_handle = NULL; if (isc_open_blob(IB_STATUS, &ib_blob->link, &ib_blob->trans_handle, &ib_blob->bl_handle, &ib_blob->bl_qd)) { efree(ib_blob); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2637,7 +2633,7 @@ convert_to_string(string_arg); if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, (unsigned short) Z_STRLEN_P(string_arg), Z_STRVAL_P(string_arg))) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } RETURN_TRUE; @@ -2674,7 +2670,7 @@ cur_len += seg_len; if (cur_len > max_len) { /* never!*/ efree(bl_data); - _php_ibase_module_error("php module internal error in %s %d", __FILE__, __LINE__); + _php_ibase_module_error("PHP module internal error"); RETURN_FALSE; } } @@ -2682,7 +2678,7 @@ bl_data[cur_len] = '\0'; if (IB_STATUS[0] && (IB_STATUS[1] != isc_segstr_eof && IB_STATUS[1] != isc_segment)) { efree(bl_data); - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } RETURN_STRINGL(bl_data, cur_len, 0); @@ -2713,7 +2709,7 @@ if (bl_end == BLOB_CLOSE) { /* return id here */ if (ib_blob->bl_qd.gds_quad_high || ib_blob->bl_qd.gds_quad_low) { /*not null ?*/ if (isc_close_blob(IB_STATUS, &ib_blob->bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } } @@ -2722,7 +2718,7 @@ zend_list_delete(Z_LVAL_P(blob_arg)); } else { /* discard created blob */ if (isc_cancel_blob(IB_STATUS, &ib_blob->bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } ib_blob->bl_handle = NULL; @@ -2771,7 +2767,7 @@ if (ib_blob_id->bl_qd.gds_quad_high || ib_blob_id->bl_qd.gds_quad_low) { /*not null ?*/ if (isc_open_blob(IB_STATUS, &ib_blob_id->link, &ib_blob_id->trans_handle, &ib_blob_id->bl_handle, &ib_blob_id->bl_qd)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2779,7 +2775,7 @@ RETURN_FALSE; } if (isc_close_blob(IB_STATUS, &ib_blob_id->bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } ib_blob_id->bl_handle = NULL; @@ -2842,7 +2838,7 @@ if (isc_open_blob(IB_STATUS, &ib_blob_id->link, &ib_blob_id->trans_handle, &ib_blob_id->bl_handle, &ib_blob_id->bl_qd)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2852,12 +2848,12 @@ } if (IB_STATUS[0] && (IB_STATUS[1] != isc_segstr_eof)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } if (isc_close_blob(IB_STATUS, &ib_blob_id->bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } ib_blob_id->bl_handle = NULL; @@ -2923,7 +2919,7 @@ ib_blob.bl_qd.gds_quad_low = 0; if (isc_create_blob(IB_STATUS, &ib_blob.link, &ib_blob.trans_handle, &ib_blob.bl_handle, &ib_blob.bl_qd)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -2931,7 +2927,7 @@ while(b = php_stream_read(stream, bl_data, sizeof(bl_data)) > 0) { if (isc_put_segment(IB_STATUS, &ib_blob.bl_handle, b, bl_data)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } size += b; @@ -2939,7 +2935,7 @@ } if (isc_close_blob(IB_STATUS, &ib_blob.bl_handle)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -3043,7 +3039,7 @@ if (isc_service_attach(IB_STATUS, 0, service_name, &service_handle, spb_length, spb_buffer)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); RETURN_FALSE; } else { @@ -3089,7 +3085,7 @@ if (isc_service_start(IB_STATUS, &service_handle, NULL, (unsigned short) (p - request), request)) { - _php_ibase_error(); + _php_ibase_error(TSRMLS_C); isc_service_detach(IB_STATUS, &service_handle); RETURN_FALSE; }
« previous php.cvs (#12882) next »