Skip to content
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

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jan 9, 2025

I have a follow-up PR that removes the FCI struct for fetch.cls.

ext/pdo/pdo_stmt.c Outdated Show resolved Hide resolved
/* 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 */
Copy link
Member

@kamil-tekiela kamil-tekiela Jan 9, 2025

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.

Copy link
Member Author

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);
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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...

Copy link
Member

@nielsdos nielsdos left a 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

/* 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 */
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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...

@Girgias Girgias merged commit 8d79ed6 into php:master Jan 9, 2025
1 check passed
@Girgias Girgias deleted the pdo-function-no-fci branch January 9, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants