Thread: SETOF / SETS_FIXED?

SETOF / SETS_FIXED?

From
"Joshua b. Jore"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd like to write a sort of functional API for my database by writing
custome functions. It looks like if I want to return a result set I need
to declare the return type as a 'SETOF tablename'. The resultset appears
(please confirm this for me) to be oids where the appropriate syntax to
use the result is 'SELECT username(UserRetrieve(id)),
accesslevel(UserRetrieve(id))' from the function 'UserRetrive (int)'.

I'm ok with that though the syntax for using the result set is pretty
weird. While I was poking throug the source to figure this out I ran
across the SETS_FIXED declaration. It looks like that's been set on my
OpenBSD installation but isn't in the stock 7.1.3. Is it ok to use
functions this way or is it still reserved for developers only?

Joshua b. Jore
http://www.greentechnologist.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (OpenBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8YA75fexLsowstzcRAmdyAJ4yOSVkRbKc8Qrflq81+BBygJyZ3QCgqirj
6IM0GyRUMazAuAHsoUcmzc4=
=C/o0
-----END PGP SIGNATURE-----


Re: SETOF / SETS_FIXED?

From
Tom Lane
Date:
"Joshua b. Jore" <josh@greentechnologist.org> writes:
> While I was poking throug the source to figure this out I ran
> across the SETS_FIXED declaration. It looks like that's been set on my
> OpenBSD installation but isn't in the stock 7.1.3.

I would certainly hope that SETS_FIXED is NOT set in *any* distribution.
That covers some code we disabled years ago because it was broken;
I see little prospect that it will ever be resurrected.

The behavior you want is not a "set" in Berkeley's terminology,
anyway.  That had to do with fields (attributes) whose values were
actually references to functions to call to produce the implied
set-of-rows value.

AFAIR, the existing support for functions-returning-SETOF only works
for SQL-language functions, or suitably coded C functions.

            regards, tom lane

Re: SETOF / SETS_FIXED?

From
"Joshua b. Jore"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ah, then I've been misled. I grepped my source and SETS_FIXED is never
defined. If you read the source and some of the (hard to find) docs
regarding the SETOF operator you run into comments like "this probably
doesn't work" and the like. It looked like the SETOF operations were
being handled by the code under SETS_FIXED hence my original question.

Joshua b. Jore
http://www.greentechnologist.org

On Tue, 5 Feb 2002, Tom Lane wrote:

> "Joshua b. Jore" <josh@greentechnologist.org> writes:
> > While I was poking throug the source to figure this out I ran
> > across the SETS_FIXED declaration. It looks like that's been set on my
> > OpenBSD installation but isn't in the stock 7.1.3.
>
> I would certainly hope that SETS_FIXED is NOT set in *any* distribution.
> That covers some code we disabled years ago because it was broken;
> I see little prospect that it will ever be resurrected.
>
> The behavior you want is not a "set" in Berkeley's terminology,
> anyway.  That had to do with fields (attributes) whose values were
> actually references to functions to call to produce the implied
> set-of-rows value.
>
> AFAIR, the existing support for functions-returning-SETOF only works
> for SQL-language functions, or suitably coded C functions.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (OpenBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8Y997fexLsowstzcRAoeIAJ91gRdLOcxRbtfEExsO+UEEhlRtwgCguQrT
Ra4hldGhMbgnStWMaimjIso=
=VK7R
-----END PGP SIGNATURE-----