5 ms·
PostgreSQL used to have two different APIs for internal/C language SQL functions, with the older one implemented in more or less this manner, but with distinct
by dfox 5y ago
PostgreSQL used to have two different APIs for internal/C language SQL functions, with the older one implemented in more or less this manner, but with distinct types for each argument count. The actual function call was then implemented as giant switch on number of arguments which called function pointer with progressively more Datum-typed arguments.
It got deprecated sometime around 8.0 and today it is not even supported (the giant switch got replaced by error message).
- jcuenod 5y agoThis reminded me of writing a `is_set_cover_possible` PL/Python function for Postgres. I wanted to take an arbitrary number of arrays. Apparently it's not possible so I just had to overload the function and hope that I would never need to check more than n arrays... https://stackoverflow.com/questions/56623975/pl-python3-with-variadic-arrays-as-arguments/56624361 https://stackoverflow.com/questions/56623975/pl-python3-with...
- dfox 5y agoI suspect that the giant switch was exactly the reason why it was not originally possible.