Question

I have a function that has a very useful name: has_useful_state(param).

I have a second function that will be returning a SETOF RECORDs of these results:

CREATE OR REPLACE FUNCTION set_of_useful_things(param TEXT, OUT has_useful_state) RETURNS SETOF RECORD AS $_$
BEGIN
    SELECT some_key, COUNT(has_useful_state(some_key)) FROM ....

At any rate, here's where it goes off the rails. The function, where has_useful_state is by far the best name for both the return column name and for the function that provides it, fails to compile with an error like this:

SELECT some_key, COUNT( $1 (some_key)) FROM ....

Obviously the function name is being treated as an alias... so how can I avoid this and still keep my useful function and column names?

Was it helpful?

Solution

You may as well insist on having two variables by the same name, but most of the time we have to put up with their nasty habit of shadowing each other.

In short, no, you can't, you'll have to change one of those (my guess is that you will sacrifice a parameter).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top