Return results of join with polymorphically-defined table in pl/pgsql - Mailing list pgsql-general

From Peter Devoy
Subject Return results of join with polymorphically-defined table in pl/pgsql
Date
Msg-id CABoFc_hKAjQrQd2ZJy+nmqgr8e3GufkHg6Q_U3T-45+4+ForMQ@mail.gmail.com
Whole thread Raw
Responses Re: Return results of join with polymorphically-defined table in pl/pgsql
Re: Return results of join with polymorphically-defined table in pl/pgsql
List pgsql-general
Hi list

The example at the bottom of this
(http://stackoverflow.com/questions/11740256/11751557#11751557) answer
shows how the anyelement polymorphic type can be used to have a
function accept -- and return rows from -- an arbitrary table decided
by the user at runtime.

However, I would like to create a function which returns the resultset
of an INNER JOIN with table1 being polymorphic and table2 being a
result set of column types which do not change.  Is this possible?

I have seen a solution using CREATE TEMP VIEW but I understand this
could race if the function was called multiple times in the same
session.  Obviously there would be way to minimize that risk but
things would start to get messy.

Any ideas would be much appreciated.

Kind regards


Peter Devoy


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: A simple extension immitating pg_notify
Next
From: "David G. Johnston"
Date:
Subject: Re: Return results of join with polymorphically-defined table in pl/pgsql