Re: [HACKERS] Projecting attributes of function return values
От | Bruce Momjian |
---|---|
Тема | Re: [HACKERS] Projecting attributes of function return values |
Дата | |
Msg-id | 199812130418.XAA13869@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Projecting attributes of function return values ("Hiroshi Inoue" <Inoue@tpf.co.jp>) |
Ответы |
Re: [HACKERS] Projecting attributes of function return values
|
Список | 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@tpf.co.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@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
В списке pgsql-hackers по дате отправления: