-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
ext/pdo: Refactor PDO::FETCH_FUNC to not rely on an FCI on the struct #17420
Conversation
ext/pdo/pdo_stmt.c
Outdated
/* TODO ArgumentCountError? */ | ||
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified"); | ||
return false; | ||
} | ||
fetch_function_param_num = stmt->column_count; /* probably less */ |
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.
Isn't this variable redundant now? You set it to 0 after the call and then use it as idx
was before.
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 follow-up PR, I'm getting rid of idx
as it only serves for a check with the SERIALIZE flag
ZVAL_COPY_VALUE(return_value, &retval); | ||
} | ||
} | ||
zend_call_known_fcc(&stmt->fetch.func.fcc, return_value, fetch_function_param_num, fetch_function_params, NULL); |
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 don't know what the difference is, so someone else will have to check if you're using this correctly. Maybe @nielsdos would like to take a look?
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.
The difference is just that we no longer store an fci, but that we construct it on the fly. This reduces the memory usage a bit overall.
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 also wonder what happens if the callback returns a reference, but that would be a pre-existing problem I suppose...
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 don't spot any obvious mistakes, please see my comments
ext/pdo/pdo_stmt.c
Outdated
/* TODO ArgumentCountError? */ | ||
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified"); | ||
return false; | ||
} | ||
/* We can probably infer items than stmt->column_count for some cases */ |
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 didn't understand this sentence. Something gramatically makes this difficult for me to understand, I guess the "than" is out of place?
ZVAL_COPY_VALUE(return_value, &retval); | ||
} | ||
} | ||
zend_call_known_fcc(&stmt->fetch.func.fcc, return_value, fetch_function_param_num, fetch_function_params, NULL); |
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.
The difference is just that we no longer store an fci, but that we construct it on the fly. This reduces the memory usage a bit overall.
ZVAL_COPY_VALUE(return_value, &retval); | ||
} | ||
} | ||
zend_call_known_fcc(&stmt->fetch.func.fcc, return_value, fetch_function_param_num, fetch_function_params, NULL); |
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 also wonder what happens if the callback returns a reference, but that would be a pre-existing problem I suppose...
I have a follow-up PR that removes the FCI struct for
fetch.cls
.