Re: Why I can't combine %TYPE with [] ?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruno BAGUETTE <pgsql-ml(at)baguette(dot)net>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Why I can't combine %TYPE with [] ?
Date: 2003-10-16 17:51:18
Message-ID: 200310161751.h9GHpIH26974@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


We just added this to TODO:

o Allow PL/pgSQL to handle %TYPE arrays, e.g. tab.col%TYPE[]

but that will help TYPE inside a function, not as part of the function
parameter list.

Do I need a TODO for this, or is it listed under some other item?

---------------------------------------------------------------------------

Bruno BAGUETTE wrote:
> Tom Lanes a ?crit :
>
> > pgsql-ml(at)baguette(dot)net writes:
> > > Since it's not possible to do a function with a variable number of
> > > arguments, I am wondering if it is possible to use an array as an
> > > argument in a PL/PGSQL function ?
> >
> > > CREATE OR REPLACE FUNCTION myownfunction(members.id%TYPE[],
> > > events.id%TYPE) RETURNS BOOLEAN AS '
> >
> > You can certainly use arrays as arguments, but I don't think
> > you can combine %TYPE with [] like that.
>
> I've checked in the PostgreSQL 7.3.4 sources
> (backend/parser/parse_type.c) and especially the char *
> TypeNameToString(const TypeName *typename) function.
>
> At the end of this function it seems that manages %TYPE that is combined
> with [] :
>
> if (typename->arrayBounds != NIL)
> appendStringInfo(&string, "[]");
>
> so I'm asking why I can't write a PL/PGSQL function like
>
> CREATE OR REPLACE FUNCTION myownfunction(members.id%TYPE[],
> events.id%TYPE) RETURNS BOOLEAN AS '
>
> Am I looking at the wrong place in the sources ?
>
> Regards,
>
> ---------------------------------------
> Bruno BAGUETTE - pgsql-ml(at)baguette(dot)net
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-10-16 17:59:16 Re: UPDATE table to a joined query...
Previous Message Stephen 2003-10-16 17:40:02 Re: VACUUM degrades performance significantly. Database becomes unusable!