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
Use pass by reference in make_partfunc_call #4438
Conversation
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.
Sounds like this is only done to avoid the warning, not because it is actually a good idea. Suggest this wording:
Passing structures by value in function calls copies the entire structure, which is inefficient, so we switch it to pass by reference to reduce the amount of copying required.
src/planner/space_constraint.c
Outdated
@@ -117,11 +117,11 @@ is_valid_scalar_space_constraint(ScalarArrayOpExpr *op, List *rtable) | |||
} | |||
|
|||
static FuncExpr * | |||
make_partfunc_call(PartitioningFunc partfunc, List *args, Oid inputcollid) | |||
make_partfunc_call(PartitioningFunc *partfunc, List *args, Oid inputcollid) |
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.
Since the intention is to only read the data, it is good to encode this in the signature.
make_partfunc_call(PartitioningFunc *partfunc, List *args, Oid inputcollid) | |
make_partfunc_call(const PartitioningFunc *partfunc, List *args, Oid inputcollid) |
Codecov Report
@@ Coverage Diff @@
## main #4438 +/- ##
=======================================
Coverage 90.85% 90.85%
=======================================
Files 221 221
Lines 40731 40731
=======================================
Hits 37006 37006
Misses 3725 3725
Continue to review full report at Codecov.
|
769f7dc
to
a953c71
Compare
Refactor make_partfunc_call to only accept fnoid and rettype instead of PartitioningFunc which also gets rid of a coverity warning about that parameter being passed by value instead of reference because that parameter was longer than 128 bytes.
a953c71
to
0c8824b
Compare
Coverity warned about usage of pass by value in this instance so
we switch it to pass by reference to reduce the amount of copying
required for the function call.