Suggestion: functions that make use of 'any' pseudotype
decibel opened this issue · 5 comments
decibel commented
Just a suggestion... if you used the 'any' pseudotype (or one of it's variants), you could eliminate a lot of code and allow users to store any arbitrary type that they wanted.
za-arthur commented
Thank you for the suggestion! Didn't think about it. I will try to implement it.
decibel commented
You might find
https://github.com/decibel/variant/blob/master/src/variant.c#L107-L109,
https://github.com/decibel/variant/blob/master/src/variant.c#L1072 and
some of
https://github.com/decibel/variant/blob/master/src/variant.c#L942
helpful. Feel free to ping me with questions.
za-arthur commented
Thank you for useful links!
I remembered, I tried to use 'any' pseudotype. But I met an issue. If I try to create function:
CREATE FUNCTION pgv_get(package text, name text, strict bool default true)
RETURNS anynonarray
AS 'MODULE_PATHNAME', 'variable_get_any'
LANGUAGE C VOLATILE;I get the error:
ERROR: cannot determine result data type
DETAIL: A function returning a polymorphic type must have at least one polymorphic argument.
And the documentation confirms it.
Do you know how to handle it?
decibel commented
Yeah, the trick is to get the user to pass in a type, even if the
function doesn't actually need that. You can see an example of that in
4.2.2 at http://pgxn.org/dist/test_factory/doc/test_factory.html
za-arthur commented
Thank you for your help!
Commited.