Re: [HACKERS] Projecting attributes of function return values

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Inoue(at)tpf(dot)co(dot)jp (Hiroshi Inoue)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Projecting attributes of function return values
Date: 1998-12-13 04:18:55
Message-ID: 199812130418.XAA13869@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have applied this to the CURRENT tree, so the fix will appear in 6.5.
I have not applied it to the RELEASE tree, so it will not be in 6.4.1.
Not sure there is going to be enough testing for that.

Thanks for the patch.

>
> Hi all
>
> I have a simple patch about the treatment of functions.
> But it may be self-satisfied.
> Please check my patch at the end of this posting.
>
> Case 1. executor evaluates functions twice
>
> create table a (elem int4);
> create function ax2(int4) returns a as
> 'select $1*2;' language 'sql';
> select elem(ax2(1));
>
> the result is
>
> elem
> ----
> 4
> (1 row)
>
> it's wrong ?
> it must be the following ?
>
> elem
> ----
> 2
> (1 row)
>
> Case 2.parser rejects functions
>
> create function elemout(a) returns int4 as
> 'select $1.elem;' language 'sql';
> select elemout(ax2(1));
>
> ERROR: Function 'elemout' has bad return type 315169
>
> this elog() is necessary ?
> In my patch I removed it and the result is
>
> elemout
> -------
> 2
> (1 row)
>
> Thanks
>
> Hiroshi Inoue
> Inoue(at)tpf(dot)co(dot)jp
>
> *** backend/parser/parse_func.c.orig Thu Dec 3 18:25:31 1998
> --- backend/parser/parse_func.c Thu Dec 3 18:39:18 1998
> ***************
> *** 1352,1358 ****
> newexpr->typeOid = funcnode->functype;
> newexpr->opType = FUNC_EXPR;
> newexpr->oper = (Node *) funcnode;
> ! newexpr->args = lcons(first_arg, NIL);
>
> return (Node *) newexpr;
> }
> --- 1352,1358 ----
> newexpr->typeOid = funcnode->functype;
> newexpr->opType = FUNC_EXPR;
> newexpr->oper = (Node *) funcnode;
> ! newexpr->args = expr->args;
>
> return (Node *) newexpr;
> }
> ***************
> *** 1359,1366 ****
>
> }
>
> - elog(ERROR, "Function '%s' has bad return type %d",
> - funcname, argtype);
> break;
> }
> case T_Param:
> --- 1359,1364 ----
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-12-13 04:20:28 Re: [HACKERS] BUG ON HAVING CLAUSE
Previous Message Bruce Momjian 1998-12-13 04:09:43 Re: [HACKERS] Bug report: PL/pgSQL and mixed case table/field names.