diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-30 23:59:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-30 23:59:46 +0000 |
commit | 7bacf2befaa5e708ad924dfc7f37844a0013e06f (patch) | |
tree | 30d436a390835bd49d0be011b2d9e2dbc843ed97 /src/backend/executor | |
parent | 9c279355fbf332dbf6dcebbe10d38e10503bf4dd (diff) | |
download | postgresql-7bacf2befaa5e708ad924dfc7f37844a0013e06f.tar.gz postgresql-7bacf2befaa5e708ad924dfc7f37844a0013e06f.zip |
Add expected tuple descriptor to ReturnSetInfo information for table
functions, per suggestion from John Gray and Joe Conway. Also, fix
plpgsql RETURN NEXT to verify that returned values match the expected
tupdesc.
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execQual.c | 23 | ||||
-rw-r--r-- | src/backend/executor/nodeFunctionscan.c | 3 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index b422adc2061..31000ef1f2a 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.102 2002/08/30 00:28:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.103 2002/08/30 23:59:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -707,6 +707,7 @@ ExecMakeFunctionResult(FunctionCachePtr fcache, fcinfo.resultinfo = (Node *) &rsinfo; rsinfo.type = T_ReturnSetInfo; rsinfo.econtext = econtext; + rsinfo.expectedDesc = NULL; rsinfo.allowedModes = (int) SFRM_ValuePerCall; rsinfo.returnMode = SFRM_ValuePerCall; /* isDone is filled below */ @@ -851,6 +852,7 @@ ExecMakeFunctionResult(FunctionCachePtr fcache, Tuplestorestate * ExecMakeTableFunctionResult(Expr *funcexpr, ExprContext *econtext, + TupleDesc expectedDesc, TupleDesc *returnDesc) { Tuplestorestate *tupstore = NULL; @@ -859,7 +861,7 @@ ExecMakeTableFunctionResult(Expr *funcexpr, List *argList; FunctionCachePtr fcache; FunctionCallInfoData fcinfo; - ReturnSetInfo rsinfo; /* for functions returning sets */ + ReturnSetInfo rsinfo; ExprDoneCond argDone; MemoryContext callerContext; MemoryContext oldcontext; @@ -918,17 +920,14 @@ ExecMakeTableFunctionResult(Expr *funcexpr, } /* - * If function returns set, prepare a resultinfo node for - * communication + * Prepare a resultinfo node for communication. We always do this even + * if not expecting a set result, so that we can pass expectedDesc. */ - if (fcache->func.fn_retset) - { - fcinfo.resultinfo = (Node *) &rsinfo; - rsinfo.type = T_ReturnSetInfo; - rsinfo.econtext = econtext; - rsinfo.allowedModes = (int) (SFRM_ValuePerCall | SFRM_Materialize); - } - /* we set these fields always since we examine them below */ + fcinfo.resultinfo = (Node *) &rsinfo; + rsinfo.type = T_ReturnSetInfo; + rsinfo.econtext = econtext; + rsinfo.expectedDesc = expectedDesc; + rsinfo.allowedModes = (int) (SFRM_ValuePerCall | SFRM_Materialize); rsinfo.returnMode = SFRM_ValuePerCall; /* isDone is filled below */ rsinfo.setResult = NULL; diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 3d2c160fb4f..e00778f3aa1 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.8 2002/08/30 00:28:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.9 2002/08/30 23:59:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -79,6 +79,7 @@ FunctionNext(FunctionScan *node) scanstate->tuplestorestate = tuplestorestate = ExecMakeTableFunctionResult((Expr *) scanstate->funcexpr, econtext, + scanstate->tupdesc, &funcTupdesc); /* |