-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-15893: Pdo\Pgsql backport fixes from GH-16124 #16158
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 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -657,16 +657,14 @@ void pgsqlCopyFromArray_internal(INTERNAL_FUNCTION_PARAMETERS) | |
PGresult *pgsql_result; | ||
ExecStatusType status; | ||
|
||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sA|sss!", | ||
&table_name, &table_name_len, &pg_rows, | ||
&pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len, &pg_fields, &pg_fields_len) == FAILURE) { | ||
RETURN_THROWS(); | ||
} | ||
|
||
if ((Z_TYPE_P(pg_rows) != IS_ARRAY && !instanceof_function(Z_OBJCE_P(pg_rows), zend_ce_traversable))) { | ||
zend_argument_type_error(2, "must be of type array or Traversable"); | ||
RETURN_THROWS(); | ||
} | ||
ZEND_PARSE_PARAMETERS_START(2, 5) | ||
Z_PARAM_STRING(table_name, table_name_len) | ||
Z_PARAM_ITERABLE(pg_rows) | ||
Z_PARAM_OPTIONAL | ||
Z_PARAM_STRING(pg_delim, pg_delim_len) | ||
Z_PARAM_STRING_OR_NULL(pg_null_as, pg_null_as_len) | ||
Z_PARAM_STRING(pg_fields, pg_fields_len) | ||
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
dbh = Z_PDO_DBH_P(ZEND_THIS); | ||
PDO_CONSTRUCT_CHECK; | ||
|
@@ -712,11 +710,15 @@ void pgsqlCopyFromArray_internal(INTERNAL_FUNCTION_PARAMETERS) | |
} | ||
} ZEND_HASH_FOREACH_END(); | ||
} else { | ||
iter = Z_OBJ_P(pg_rows)->ce->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0); | ||
iter = Z_OBJCE_P(pg_rows)->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0); | ||
if (iter == NULL || EG(exception)) { | ||
RETURN_THROWS(); | ||
} | ||
|
||
if (iter->funcs->rewind) { | ||
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. I think rewind can throw too, but the exception isn't checked in this case. 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. Right, I forgot about that detail. Maybe would be nice to have some FOREACH_ITERABLE macros 🤔 |
||
iter->funcs->rewind(iter); | ||
} | ||
|
||
for (; iter->funcs->valid(iter) == SUCCESS && EG(exception) == NULL; iter->funcs->move_forward(iter)) { | ||
tmp = iter->funcs->get_current_data(iter); | ||
if (!_pdo_pgsql_send_copy_data(H, tmp)) { | ||
|
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.
In the old zpp this argument was not nullable, it was the last one. The fact this is not caught in CI also means that this case is not tested...