Closed deathwish closed 3 years ago
Is oidvectortypes()
more portable than pg_get_function_identity_arguments()
?
Yeah but pgTAP supports 9.1 and later (as of v1.1.0).
The documentation on pgtap.org is still for 1.0 and the pgTAP 1.1 README.md still reflects a minimum PostgreSQL version requirement of 8.4, I think some confusion is forgivable.
That said, my experiments suggest that pg_get_function_identity_arguments
is not the right tool as it returns any names used for parameters. For example, it would return s text, y varchar(10)
rather than text, varchar(10)
. This does not align with the definition of the regprocedure
type, which appears to be the other available argument-formatting mechanism.
In turn, regprocedure
has it's own problem for this use case: the TEXT
format of the type is relative to the current user's search path. Canonicalization or extraction of the desired parameter type string are both possible, but either are significantly messier than simply calling oidvectortypes
and getting the desired output.
As no further procedure parameter information functionality has been added to PostgreSQL to date, I think sticking with oidvectortypes
until better-suited functionality is available seems reasonable.
The documentation on pgtap.org is still for 1.0 and the pgTAP 1.1 README.md still reflects a minimum PostgreSQL version requirement of 8.4, I think some confusion is forgivable.
That's fair. I've opened theory/pgtap#262 to clean out the old cruft.
As no further procedure parameter information functionality has been added to PostgreSQL to date, I think sticking with
oidvectortypes
until better-suited functionality is available seems reasonable.
Okay, thanks for digging into that.
Currently, function body MD5 tests look up the specialization of the function being tested using the raw OIDs of it's arguments. These OIDs are only consistent between databases for built-in types. This means functions using extension types (I.E. hstore) will have differing argument OIDs on different machines, causing tests to fail. Worse, due to the structure of the query the test is not run, meaning only a plan failure results.
This PR corrects both issues in what I believe is a reasonable way for the majority of cases. Unlike the more sophisticated function introspection tools available today,
oidvectortypes
is available on all supported PG versions. And while plan failures will still result if the schema is not present, other direct failures will invariably result from such a situation. As such, I felt keeping the query simple was worth a moderate compromise in function.The duplicate name elimination is just a bonus, the only function change is shorter output. Included as I feel it makes it clearer that this test does not count overloads of the same function name.