Skip to content

Commit b1baf1f

Browse files
committed
Add get_func_rettype() to general-use lsyscache routines,
since it's now needed in both optimizer and parser.
1 parent bab13a7 commit b1baf1f

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/backend/utils/cache/lsyscache.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.32 1999/08/09 03:13:30 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.33 1999/08/16 02:06:25 tgl Exp $
1010
*
1111
* NOTES
1212
* Eventually, the index information should go through here, too.
@@ -15,6 +15,7 @@
1515
#include "postgres.h"
1616

1717
#include "catalog/pg_operator.h"
18+
#include "catalog/pg_proc.h"
1819
#include "catalog/pg_type.h"
1920
#include "utils/lsyscache.h"
2021
#include "utils/syscache.h"
@@ -453,6 +454,31 @@ get_oprjoin(Oid opno)
453454
return (RegProcedure) NULL;
454455
}
455456

457+
/* ---------- FUNCTION CACHE ---------- */
458+
459+
/*
460+
* get_func_rettype
461+
* Given procedure id, return the function's result type.
462+
*/
463+
Oid
464+
get_func_rettype(Oid funcid)
465+
{
466+
HeapTuple func_tuple;
467+
Oid funcrettype;
468+
469+
func_tuple = SearchSysCacheTuple(PROOID,
470+
ObjectIdGetDatum(funcid),
471+
0, 0, 0);
472+
473+
if (!HeapTupleIsValid(func_tuple))
474+
elog(ERROR, "Function OID %u does not exist", funcid);
475+
476+
funcrettype = (Oid)
477+
((Form_pg_proc) GETSTRUCT(func_tuple))->prorettype;
478+
479+
return funcrettype;
480+
}
481+
456482
/* ---------- RELATION CACHE ---------- */
457483

458484
/*

src/include/utils/lsyscache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: lsyscache.h,v 1.19 1999/08/09 03:13:28 tgl Exp $
8+
* $Id: lsyscache.h,v 1.20 1999/08/16 02:06:23 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -32,6 +32,7 @@ extern HeapTuple get_operator_tuple(Oid opno);
3232
extern Oid get_negator(Oid opid);
3333
extern RegProcedure get_oprrest(Oid opid);
3434
extern RegProcedure get_oprjoin(Oid opid);
35+
extern Oid get_func_rettype(Oid funcid);
3536
extern int get_relnatts(Oid relid);
3637
extern char *get_rel_name(Oid relid);
3738
extern struct varlena *get_relstub(Oid relid, int no, bool *islast);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy