-
Couldn't load subscription status.
- Fork 8k
Make ext/odbc default value handling more consistent #13910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1269,29 +1269,29 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) | |
| RETCODE rc; | ||
| SQLSMALLINT sql_c_type; | ||
| char *buf = NULL; | ||
| zend_long pv_row = 0; | ||
| bool pv_row_is_null = true; | ||
| zval *pv_res, tmp; | ||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| SQLULEN crow; | ||
| SQLUSMALLINT RowStatus[1]; | ||
| SQLLEN rownum; | ||
| zval *pv_res, tmp; | ||
| zend_long pv_row = -1; | ||
| #endif | ||
|
|
||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_res, &pv_row) == FAILURE) { | ||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l!", &pv_res, &pv_row, &pv_row_is_null) == FAILURE) { | ||
| RETURN_THROWS(); | ||
| } | ||
|
|
||
| rownum = pv_row; | ||
| #else | ||
| zval *pv_res, tmp; | ||
|
|
||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) { | ||
| if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) { | ||
| RETURN_THROWS(); | ||
| } | ||
| #endif | ||
|
|
||
| if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) { | ||
| RETURN_THROWS(); | ||
| /* TODO deprecate $row argument values less than 1 after PHP 8.4 */ | ||
|
|
||
| #ifndef HAVE_SQL_EXTENDED_FETCH | ||
| if (!pv_row_is_null && pv_row > 0) { | ||
| php_error_docref(NULL, E_WARNING, "Extended fetch functionality is not available, argument #3 ($row) is ignored"); | ||
| } | ||
| #endif | ||
|
|
||
| if (result->numcols == 0) { | ||
| php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); | ||
|
|
@@ -1300,8 +1300,8 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) | |
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| if (result->fetch_abs) { | ||
| if (rownum > 0) { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,rownum,&crow,RowStatus); | ||
| if (!pv_row_is_null && pv_row > 0) { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,(SQLLEN)pv_row,&crow,RowStatus); | ||
| } else { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); | ||
| } | ||
|
|
@@ -1316,8 +1316,8 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) | |
| array_init(return_value); | ||
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| if (rownum > 0 && result->fetch_abs) | ||
| result->fetched = rownum; | ||
| if (!pv_row_is_null && pv_row > 0 && result->fetch_abs) | ||
| result->fetched = (SQLLEN)pv_row; | ||
| else | ||
| #endif | ||
| result->fetched++; | ||
|
|
@@ -1430,28 +1430,28 @@ PHP_FUNCTION(odbc_fetch_into) | |
| SQLSMALLINT sql_c_type; | ||
| char *buf = NULL; | ||
| zval *pv_res, *pv_res_arr, tmp; | ||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| zend_long pv_row = 0; | ||
| bool pv_row_is_null = true; | ||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| SQLULEN crow; | ||
| SQLUSMALLINT RowStatus[1]; | ||
| SQLLEN rownum = -1; | ||
| #endif /* HAVE_SQL_EXTENDED_FETCH */ | ||
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz|l", &pv_res, &pv_res_arr, &pv_row) == FAILURE) { | ||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz|l!", &pv_res, &pv_res_arr, &pv_row, &pv_row_is_null) == FAILURE) { | ||
| RETURN_THROWS(); | ||
| } | ||
|
|
||
| rownum = pv_row; | ||
| #else | ||
| if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pv_res, &pv_res_arr) == FAILURE) { | ||
| if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) { | ||
| RETURN_THROWS(); | ||
| } | ||
| #endif /* HAVE_SQL_EXTENDED_FETCH */ | ||
|
|
||
| if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) { | ||
| RETURN_THROWS(); | ||
| /* TODO deprecate $row argument values less than 1 after PHP 8.4 */ | ||
|
|
||
| #ifndef HAVE_SQL_EXTENDED_FETCH | ||
| if (!pv_row_is_null && pv_row > 0) { | ||
| php_error_docref(NULL, E_WARNING, "Extended fetch functionality is not available, argument #3 ($row) is ignored"); | ||
| } | ||
| #endif | ||
|
|
||
| if (result->numcols == 0) { | ||
| php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); | ||
|
|
@@ -1465,8 +1465,8 @@ PHP_FUNCTION(odbc_fetch_into) | |
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| if (result->fetch_abs) { | ||
| if (rownum > 0) { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,rownum,&crow,RowStatus); | ||
| if (!pv_row_is_null && pv_row > 0) { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,(SQLLEN)pv_row,&crow,RowStatus); | ||
| } else { | ||
| rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); | ||
| } | ||
|
|
@@ -1479,8 +1479,8 @@ PHP_FUNCTION(odbc_fetch_into) | |
| } | ||
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| if (rownum > 0 && result->fetch_abs) | ||
| result->fetched = rownum; | ||
| if (!pv_row_is_null && pv_row > 0 && result->fetch_abs) | ||
| result->fetched = (SQLLEN)pv_row; | ||
| else | ||
| #endif | ||
| result->fetched++; | ||
|
|
@@ -1560,8 +1560,8 @@ PHP_FUNCTION(odbc_fetch_row) | |
| odbc_result *result; | ||
| RETCODE rc; | ||
| zval *pv_res; | ||
| zend_long pv_row; | ||
| bool pv_row_is_null = 1; | ||
| zend_long pv_row = 0; | ||
| bool pv_row_is_null = true; | ||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
| SQLULEN crow; | ||
| SQLUSMALLINT RowStatus[1]; | ||
|
|
@@ -1575,6 +1575,17 @@ PHP_FUNCTION(odbc_fetch_row) | |
| RETURN_THROWS(); | ||
| } | ||
|
|
||
| #ifndef HAVE_SQL_EXTENDED_FETCH | ||
| if (!pv_row_is_null) { | ||
| php_error_docref(NULL, E_WARNING, "Extended fetch functionality is not available, argument #3 ($row) is ignored"); | ||
| } | ||
| #else | ||
| if (!pv_row_is_null && pv_row < 1) { | ||
| php_error_docref(NULL, E_WARNING, "Argument #3 ($row) must be greater than or equal to 1"); | ||
| RETURN_FALSE; | ||
| } | ||
| #endif | ||
|
|
||
| if (result->numcols == 0) { | ||
| php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); | ||
| RETURN_FALSE; | ||
|
|
@@ -1594,12 +1605,12 @@ PHP_FUNCTION(odbc_fetch_row) | |
| if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { | ||
| RETURN_FALSE; | ||
| } | ||
|
|
||
| #ifdef HAVE_SQL_EXTENDED_FETCH | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like an omission. The result of the affected functions already used the same |
||
| if (!pv_row_is_null) { | ||
| result->fetched = (SQLLEN)pv_row; | ||
| } else { | ||
| } else | ||
| #endif | ||
| result->fetched++; | ||
| } | ||
|
|
||
| RETURN_TRUE; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that it's still possible to warn in case of
odbc_fetch_row()becausenullis already the default value since PHP 8.0 (9b50fd2#diff-36f2362bf160e8a01f19ba44e282f7a2f69b460d57a5b23d9e71c59af5de8810R1689).