mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Add UtilityReturnsTuples() support for CALL
This ensures that prepared statements for CALL can return tuples.
This commit is contained in:
parent
cccf81d259
commit
ec67b89816
@ -51,6 +51,7 @@
|
|||||||
#include "commands/proclang.h"
|
#include "commands/proclang.h"
|
||||||
#include "executor/execdesc.h"
|
#include "executor/execdesc.h"
|
||||||
#include "executor/executor.h"
|
#include "executor/executor.h"
|
||||||
|
#include "funcapi.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/var.h"
|
#include "optimizer/var.h"
|
||||||
@ -2340,3 +2341,26 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
|
|||||||
|
|
||||||
FreeExecutorState(estate);
|
FreeExecutorState(estate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct the tuple descriptor for a CALL statement return
|
||||||
|
*/
|
||||||
|
TupleDesc
|
||||||
|
CallStmtResultDesc(CallStmt *stmt)
|
||||||
|
{
|
||||||
|
FuncExpr *fexpr;
|
||||||
|
HeapTuple tuple;
|
||||||
|
TupleDesc tupdesc;
|
||||||
|
|
||||||
|
fexpr = stmt->funcexpr;
|
||||||
|
|
||||||
|
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fexpr->funcid));
|
||||||
|
if (!HeapTupleIsValid(tuple))
|
||||||
|
elog(ERROR, "cache lookup failed for procedure %u", fexpr->funcid);
|
||||||
|
|
||||||
|
tupdesc = build_function_result_tupdesc_t(tuple);
|
||||||
|
|
||||||
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
|
return tupdesc;
|
||||||
|
}
|
||||||
|
@ -1744,6 +1744,12 @@ UtilityReturnsTuples(Node *parsetree)
|
|||||||
{
|
{
|
||||||
switch (nodeTag(parsetree))
|
switch (nodeTag(parsetree))
|
||||||
{
|
{
|
||||||
|
case T_CallStmt:
|
||||||
|
{
|
||||||
|
CallStmt *stmt = (CallStmt *) parsetree;
|
||||||
|
|
||||||
|
return (stmt->funcexpr->funcresulttype == RECORDOID);
|
||||||
|
}
|
||||||
case T_FetchStmt:
|
case T_FetchStmt:
|
||||||
{
|
{
|
||||||
FetchStmt *stmt = (FetchStmt *) parsetree;
|
FetchStmt *stmt = (FetchStmt *) parsetree;
|
||||||
@ -1794,6 +1800,9 @@ UtilityTupleDescriptor(Node *parsetree)
|
|||||||
{
|
{
|
||||||
switch (nodeTag(parsetree))
|
switch (nodeTag(parsetree))
|
||||||
{
|
{
|
||||||
|
case T_CallStmt:
|
||||||
|
return CallStmtResultDesc((CallStmt *) parsetree);
|
||||||
|
|
||||||
case T_FetchStmt:
|
case T_FetchStmt:
|
||||||
{
|
{
|
||||||
FetchStmt *stmt = (FetchStmt *) parsetree;
|
FetchStmt *stmt = (FetchStmt *) parsetree;
|
||||||
|
@ -64,6 +64,7 @@ extern void IsThereFunctionInNamespace(const char *proname, int pronargs,
|
|||||||
oidvector *proargtypes, Oid nspOid);
|
oidvector *proargtypes, Oid nspOid);
|
||||||
extern void ExecuteDoStmt(DoStmt *stmt, bool atomic);
|
extern void ExecuteDoStmt(DoStmt *stmt, bool atomic);
|
||||||
extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest);
|
extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest);
|
||||||
|
extern TupleDesc CallStmtResultDesc(CallStmt *stmt);
|
||||||
extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
|
extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
|
||||||
extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok);
|
extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok);
|
||||||
extern void interpret_function_parameter_list(ParseState *pstate,
|
extern void interpret_function_parameter_list(ParseState *pstate,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user