Projecting attributes of function return values
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 ----
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 iselemout
-------
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, Pennsylvania 19026
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';
It addresses a problem I've mentioned some time ago.
Functions returning sets or complex types have targetlists,
but these aren't handled correctly in the executor.
Me and Thomas G. Lockhard where discussing another rangetable
entry type lately, which is in fact a subselect. That might
cover this problem more completely in the future.
So pls let it out of the REL6_4 tree for now.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
-----Original Message-----
From: Jan Wieck [mailto:jwieck@debis.com]
Sent: Monday, December 14, 1998 6:38 PM
To: Bruce Momjian
Cc: Inoue@tpf.co.jp; pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] Projecting attributes of function return valuesI 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';It addresses a problem I've mentioned some time ago.
Functions returning sets or complex types have targetlists,
but these aren't handled correctly in the executor.
It includes the fact that func_tlist of Func node is not used to project
attributes of function return values except when functions are written
in 'sql' language ?
and
the fact that PL/pgSQL functions return different type(HeapTuple)
from 'sql' functions which return the pointer to TupleTableSlot node ?
My samples are all written in 'sql' language.
Seems the cases I mentioned are simple bugs.
Thanks.
Hiroshi Inoue
Inoue@tpf.co.jp