summaryrefslogtreecommitdiff
path: root/ext/odbc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/odbc')
-rw-r--r--ext/odbc/birdstep.c75
-rw-r--r--ext/odbc/php_odbc.c134
2 files changed, 58 insertions, 151 deletions
diff --git a/ext/odbc/birdstep.c b/ext/odbc/birdstep.c
index 2185933c64..cd0e04d452 100644
--- a/ext/odbc/birdstep.c
+++ b/ext/odbc/birdstep.c
@@ -236,7 +236,7 @@ PHP_FUNCTION(birdstep_connect)
long ind;
if ( php_birdstep_module.max_links != -1 && php_birdstep_module.num_links == php_birdstep_module.max_links ) {
- php_error(E_WARNING,"Birdstep: Too many open connections (%d)",php_birdstep_module.num_links);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Too many open connections (%d)",php_birdstep_module.num_links);
RETURN_FALSE;
}
if (ZEND_NUM_ARGS() != 3 || getParameters(ht,3,&serv,&user,&pass) == FAILURE ) {
@@ -250,21 +250,16 @@ PHP_FUNCTION(birdstep_connect)
Pass = Z_STRVAL_P(pass);
stat = SQLAllocConnect(henv,&hdbc);
if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Birdstep: Could not allocate connection handle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Could not allocate connection handle");
RETURN_FALSE;
}
stat = SQLConnect(hdbc,Serv,SQL_NTS,User,SQL_NTS,Pass,SQL_NTS);
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: Could not connect to server \"%s\" for %s",Serv,User);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Could not connect to server \"%s\" for %s",Serv,User);
SQLFreeConnect(hdbc);
RETURN_FALSE;
}
new = (VConn *)emalloc(sizeof(VConn));
- if ( new == NULL ) {
- php_error(E_WARNING,"Birdstep: Out of memory for store connection");
- SQLFreeConnect(hdbc);
- RETURN_FALSE;
- }
ind = birdstep_add_conn(list,new,hdbc);
php_birdstep_module.num_links++;
RETURN_LONG(ind);
@@ -284,7 +279,7 @@ PHP_FUNCTION(birdstep_close)
convert_to_long(id);
conn = birdstep_find_conn(list,Z_LVAL_P(id));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
RETURN_FALSE;
}
SQLDisconnect(conn->hdbc);
@@ -314,26 +309,22 @@ PHP_FUNCTION(birdstep_exec)
convert_to_long(ind);
conn = birdstep_find_conn(list,Z_LVAL_P(ind));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(ind));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(ind));
RETURN_FALSE;
}
convert_to_string(exec_str);
query = Z_STRVAL_P(exec_str);
res = (Vresult *)emalloc(sizeof(Vresult));
- if ( res == NULL ) {
- php_error(E_WARNING,"Birdstep: Out of memory for result");
- RETURN_FALSE;
- }
stat = SQLAllocStmt(conn->hdbc,&res->hstmt);
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: SQLAllocStmt return %d",stat);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLAllocStmt return %d",stat);
efree(res);
RETURN_FALSE;
}
stat = SQLExecDirect(res->hstmt,query,SQL_NTS);
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: Can not execute \"%s\" query",query);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Can not execute \"%s\" query",query);
SQLFreeStmt(res->hstmt,SQL_DROP);
efree(res);
RETURN_FALSE;
@@ -341,7 +332,7 @@ PHP_FUNCTION(birdstep_exec)
/* Success query */
stat = SQLNumResultCols(res->hstmt,&cols);
if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Birdstep: SQLNumResultCols return %d",stat);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLNumResultCols return %d",stat);
SQLFreeStmt(res->hstmt,SQL_DROP);
efree(res);
RETURN_FALSE;
@@ -349,7 +340,7 @@ PHP_FUNCTION(birdstep_exec)
if ( !cols ) { /* Was INSERT, UPDATE, DELETE, etc. query */
stat = SQLRowCount(res->hstmt,&rows);
if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Birdstep: SQLNumResultCols return %d",stat);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLNumResultCols return %d",stat);
SQLFreeStmt(res->hstmt,SQL_DROP);
efree(res);
RETURN_FALSE;
@@ -359,12 +350,6 @@ PHP_FUNCTION(birdstep_exec)
RETURN_LONG(rows);
} else { /* Was SELECT query */
res->values = (VResVal *)emalloc(sizeof(VResVal)*cols);
- if ( res->values == NULL ) {
- php_error(E_WARNING,"Birdstep: Out of memory for result columns");
- SQLFreeStmt(res->hstmt,SQL_DROP);
- efree(res);
- RETURN_FALSE;
- }
res->numcols = cols;
for ( i = 0; i < cols; i++ ) {
SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_NAME,
@@ -412,7 +397,7 @@ PHP_FUNCTION(birdstep_fetch)
convert_to_long(ind);
res = birdstep_find_result(list,Z_LVAL_P(ind));
if ( !res ) {
- php_error(E_WARNING,"Birdstep: Not result index (%d)",Z_LVAL_P(ind));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)",Z_LVAL_P(ind));
RETURN_FALSE;
}
stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
@@ -422,7 +407,7 @@ PHP_FUNCTION(birdstep_fetch)
RETURN_FALSE;
}
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: SQLFetch return error");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
SQLFreeStmt(res->hstmt,SQL_DROP);
birdstep_del_result(list,Z_LVAL_P(ind));
RETURN_FALSE;
@@ -451,7 +436,7 @@ PHP_FUNCTION(birdstep_result)
convert_to_long(ind);
res = birdstep_find_result(list,Z_LVAL_P(ind));
if ( !res ) {
- php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
RETURN_FALSE;
}
if ( Z_TYPE_P(col) == IS_STRING ) {
@@ -468,12 +453,12 @@ PHP_FUNCTION(birdstep_result)
}
}
if ( indx < 0 ) {
- php_error(E_WARNING, "Field %s not found",field);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %s not found",field);
RETURN_FALSE;
}
} else {
if ( indx < 0 || indx >= res->numcols ) {
- php_error(E_WARNING,"Birdstep: Field index not in range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Field index not in range");
RETURN_FALSE;
}
}
@@ -485,7 +470,7 @@ PHP_FUNCTION(birdstep_result)
RETURN_FALSE;
}
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: SQLFetch return error");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
SQLFreeStmt(res->hstmt,SQL_DROP);
birdstep_del_result(list,Z_LVAL_P(ind));
RETURN_FALSE;
@@ -501,10 +486,6 @@ PHP_FUNCTION(birdstep_result)
l1:
if ( !res->values[indx].value ) {
res->values[indx].value = emalloc(4096);
- if ( !res->values[indx].value ) {
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
}
stat = SQLGetData(res->hstmt,indx+1,sql_c_type,
res->values[indx].value,4095,&res->values[indx].vallen);
@@ -514,7 +495,7 @@ l1:
RETURN_FALSE;
}
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: SQLGetData return error");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLGetData return error");
SQLFreeStmt(res->hstmt,SQL_DROP);
birdstep_del_result(list,Z_LVAL_P(ind));
RETURN_FALSE;
@@ -545,7 +526,7 @@ PHP_FUNCTION(birdstep_freeresult)
convert_to_long(ind);
res = birdstep_find_result(list,Z_LVAL_P(ind));
if ( !res ) {
- php_error(E_WARNING,"Birdstep: Not result index (%d)",Z_LVAL_P(ind));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)",Z_LVAL_P(ind));
RETURN_FALSE;
}
SQLFreeStmt(res->hstmt,SQL_DROP);
@@ -568,12 +549,12 @@ PHP_FUNCTION(birdstep_autocommit)
convert_to_long(id);
conn = birdstep_find_conn(list,Z_LVAL_P(id));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
RETURN_FALSE;
}
stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: Set autocommit_on option failure");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_on option failure");
RETURN_FALSE;
}
RETURN_TRUE;
@@ -594,12 +575,12 @@ PHP_FUNCTION(birdstep_off_autocommit)
convert_to_long(id);
conn = birdstep_find_conn(list,Z_LVAL_P(id));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
RETURN_FALSE;
}
stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
- php_error(E_WARNING,"Birdstep: Set autocommit_off option failure");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_off option failure");
RETURN_FALSE;
}
RETURN_TRUE;
@@ -620,12 +601,12 @@ PHP_FUNCTION(birdstep_commit)
convert_to_long(id);
conn = birdstep_find_conn(list,Z_LVAL_P(id));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
RETURN_FALSE;
}
stat = SQLTransact(NULL,conn->hdbc,SQL_COMMIT);
if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Birdstep: Commit failure");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Commit failure");
RETURN_FALSE;
}
RETURN_TRUE;
@@ -646,12 +627,12 @@ PHP_FUNCTION(birdstep_rollback)
convert_to_long(id);
conn = birdstep_find_conn(list,Z_LVAL_P(id));
if ( !conn ) {
- php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
RETURN_FALSE;
}
stat = SQLTransact(NULL,conn->hdbc,SQL_ROLLBACK);
if ( stat != SQL_SUCCESS ) {
- php_error(E_WARNING,"Birdstep: Rollback failure");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Rollback failure");
RETURN_FALSE;
}
RETURN_TRUE;
@@ -672,13 +653,13 @@ PHP_FUNCTION(birdstep_fieldname)
convert_to_long(ind);
res = birdstep_find_result(list,Z_LVAL_P(ind));
if ( !res ) {
- php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
RETURN_FALSE;
}
convert_to_long(col);
indx = Z_LVAL_P(col);
if ( indx < 0 || indx >= res->numcols ) {
- php_error(E_WARNING,"Birdstep: Field index not in range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Field index not in range");
RETURN_FALSE;
}
RETURN_STRING(res->values[indx].name,TRUE);
@@ -698,7 +679,7 @@ PHP_FUNCTION(birdstep_fieldnum)
convert_to_long(ind);
res = birdstep_find_result(list,Z_LVAL_P(ind));
if ( !res ) {
- php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
RETURN_FALSE;
}
RETURN_LONG(res->numcols);
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 273ec51b95..367b9d8975 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -588,9 +588,9 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
memcpy(ODBCG(laststate), state, sizeof(state));
memcpy(ODBCG(lasterrormsg), errormsg, sizeof(errormsg));
if (func) {
- php_error(E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
} else {
- php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
}
/*
} while (SQL_SUCCEEDED(rc));
@@ -636,12 +636,6 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
result->values = (odbc_result_value *) emalloc(sizeof(odbc_result_value)*result->numcols);
- if (result->values == NULL) {
- php_error(E_WARNING, "Out of memory");
- SQLFreeStmt(result->stmt, SQL_DROP);
- return 0;
- }
-
result->longreadlen = ODBCG(defaultlrl);
result->binmode = ODBCG(defaultbinmode);
@@ -745,17 +739,17 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) > result->numcols) {
- php_error(E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) < 1) {
- php_error(E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
@@ -850,10 +844,6 @@ PHP_FUNCTION(odbc_prepare)
query = Z_STRVAL_PP(pv_query);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
result->numparams = 0;
@@ -968,13 +958,13 @@ PHP_FUNCTION(odbc_execute)
/* XXX check for already bound parameters*/
if (result->numparams > 0 && numArgs == 1) {
- php_error(E_WARNING, "No parameters to SQL statement given");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No parameters to SQL statement given");
RETURN_FALSE;
}
if (result->numparams > 0) {
if ((ne = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr))) < result->numparams) {
- php_error(E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
RETURN_FALSE;
}
@@ -983,7 +973,7 @@ PHP_FUNCTION(odbc_execute)
for(i = 1; i <= result->numparams; i++) {
if (zend_hash_get_current_data(Z_ARRVAL_PP(pv_param_arr), (void **) &tmp) == FAILURE) {
- php_error(E_WARNING,"Error getting parameter");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
efree(params);
RETURN_FALSE;
@@ -992,7 +982,7 @@ PHP_FUNCTION(odbc_execute)
otype = (*tmp)->type;
convert_to_string(*tmp);
if (Z_TYPE_PP(tmp) != IS_STRING) {
- php_error(E_WARNING,"Error converting parameter");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
efree(params);
RETURN_FALSE;
@@ -1025,7 +1015,7 @@ PHP_FUNCTION(odbc_execute)
}
if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) {
- php_error(E_WARNING,"Can't open file %s", filename);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename);
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
for(i = 0; i < result->numparams; i++) {
if (params[i].fp != -1) {
@@ -1147,10 +1137,6 @@ PHP_FUNCTION(odbc_cursor)
if (max_len > 0) {
cursorname = emalloc(max_len + 1);
- if (cursorname == NULL) {
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
char state[6]; /* Not used */
@@ -1170,7 +1156,7 @@ PHP_FUNCTION(odbc_cursor)
RETVAL_STRING(cursorname,1);
}
} else {
- php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
RETVAL_FALSE;
}
} else {
@@ -1200,7 +1186,7 @@ PHP_FUNCTION(odbc_data_source)
}
if (zend_get_parameters_ex(2, &zv_conn, &zv_fetch_type) == FAILURE) {
- php_error(E_WARNING, "%s(): Unable to get parameters", get_active_function_name(TSRMLS_C));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to get parameters");
RETURN_FALSE;
}
@@ -1275,10 +1261,6 @@ PHP_FUNCTION(odbc_exec)
query = Z_STRVAL_PP(pv_query);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -1392,7 +1374,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -1545,7 +1527,7 @@ PHP_FUNCTION(odbc_fetch_into)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -1645,7 +1627,7 @@ PHP_FUNCTION(solid_fetch_prev)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
rc = SQLFetchPrev(result->stmt);
@@ -1694,7 +1676,7 @@ PHP_FUNCTION(odbc_fetch_row)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -1756,14 +1738,14 @@ PHP_FUNCTION(odbc_result)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if ((result->numcols == 0)) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
/* get field index if the field parameter was a string */
if (field != NULL) {
if (result->values == NULL) {
- php_error(E_WARNING, "Result set contains no data");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set contains no data");
RETURN_FALSE;
}
@@ -1775,13 +1757,13 @@ PHP_FUNCTION(odbc_result)
}
if (field_ind < 0) {
- php_error(E_WARNING, "Field %s not found", field);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %s not found", field);
RETURN_FALSE;
}
} else {
/* check for limits of field_ind if the field parameter was an int */
if (field_ind >= result->numcols || field_ind < 0) {
- php_error(E_WARNING, "Field index is larger than the number of fields");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index is larger than the number of fields");
RETURN_FALSE;
}
}
@@ -1822,10 +1804,6 @@ PHP_FUNCTION(odbc_result)
/* For char data, the length of the returned string will be longreadlen - 1 */
fieldsize = (result->longreadlen <= 0) ? 4096 : result->longreadlen;
field = emalloc(fieldsize);
- if (!field) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
/* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \0.
* For binary data it is truncated to fieldsize bytes.
@@ -1866,10 +1844,7 @@ PHP_FUNCTION(odbc_result)
/* We emalloc 1 byte more for SQL_C_CHAR (trailing \0) */
fieldsize = (sql_c_type == SQL_C_CHAR) ? 4096 : 4095;
- if ((field = emalloc(fieldsize)) == NULL) {
- php_error(E_WARNING,"Out of memory");
- RETURN_FALSE;
- }
+ field = emalloc(fieldsize);
/* Call SQLGetData() until SQL_SUCCESS is returned */
while(1) {
@@ -1926,7 +1901,7 @@ PHP_FUNCTION(odbc_result_all)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
#ifdef HAVE_SQL_EXTENDED_FETCH
@@ -2218,11 +2193,6 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
len = strlen(db) + strlen(uid) + strlen(pwd) + sizeof(ODBC_TYPE) + 5;
hashed_details = emalloc(len);
- if (hashed_details == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
-
hashed_len = sprintf(hashed_details, "%s_%s_%s_%s_%d", ODBC_TYPE, db, uid, pwd, cur_opt);
/* FIXME the idea of checking to see if our connection is already persistent
@@ -2492,17 +2462,17 @@ PHP_FUNCTION(odbc_field_name)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) > result->numcols) {
- php_error(E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) < 1) {
- php_error(E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
@@ -2528,17 +2498,17 @@ PHP_FUNCTION(odbc_field_type)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) > result->numcols) {
- php_error(E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (Z_LVAL_PP(pv_num) < 1) {
- php_error(E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
@@ -2581,7 +2551,7 @@ PHP_FUNCTION(odbc_field_num)
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
if (result->numcols == 0) {
- php_error(E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -2745,7 +2715,7 @@ PHP_FUNCTION(odbc_setoption)
case 1: /* SQLSetConnectOption */
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
if (conn->persistent) {
- php_error(E_WARNING, "Unable to set option for persistent connection");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set option for persistent connection");
RETURN_FALSE;
}
rc = SQLSetConnectOption(conn->hdbc, (unsigned short)(Z_LVAL_PP(pv_opt)), Z_LVAL_PP(pv_val));
@@ -2811,10 +2781,6 @@ PHP_FUNCTION(odbc_tables)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -2899,10 +2865,6 @@ PHP_FUNCTION(odbc_columns)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -2978,10 +2940,6 @@ PHP_FUNCTION(odbc_columnprivileges)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3076,10 +3034,6 @@ PHP_FUNCTION(odbc_foreignkeys)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3155,10 +3109,6 @@ PHP_FUNCTION(odbc_gettypeinfo)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3227,10 +3177,6 @@ PHP_FUNCTION(odbc_primarykeys)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3309,10 +3255,6 @@ PHP_FUNCTION(odbc_procedurecolumns)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3391,10 +3333,6 @@ PHP_FUNCTION(odbc_procedures)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3477,10 +3415,6 @@ PHP_FUNCTION(odbc_specialcolumns)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3562,10 +3496,6 @@ PHP_FUNCTION(odbc_statistics)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
@@ -3640,10 +3570,6 @@ PHP_FUNCTION(odbc_tableprivileges)
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
- if (result == NULL) {
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {