mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
First round of changes for new fmgr interface. fmgr itself and the
key call sites are changed, but most called functions are still oldstyle. An exception is that the PL managers are updated (so, for example, NULL handling now behaves as expected in plperl and plpgsql functions). NOTE initdb is forced due to added column in pg_proc.
This commit is contained in:
3
src/backend/utils/cache/catcache.c
vendored
3
src/backend/utils/cache/catcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.63 2000/04/12 17:15:52 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.64 2000/05/28 17:56:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,6 +24,7 @@
|
||||
#include "catalog/indexing.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/catcache.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
56
src/backend/utils/cache/fcache.c
vendored
56
src/backend/utils/cache/fcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.30 2000/04/12 17:15:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.31 2000/05/28 17:56:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,20 +24,9 @@
|
||||
|
||||
static Oid GetDynamicFuncArgType(Var *arg, ExprContext *econtext);
|
||||
static FunctionCachePtr init_fcache(Oid foid,
|
||||
bool use_syscache,
|
||||
List *argList,
|
||||
ExprContext *econtext);
|
||||
List *argList,
|
||||
ExprContext *econtext);
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
*
|
||||
* Initialize the 'FunctionCache' given the PG_PROC oid.
|
||||
*
|
||||
*
|
||||
* NOTE: This function can be called when the system cache is being
|
||||
* initialized. Therefore, use_syscache should ONLY be true
|
||||
* when the function return type is interesting (ie: set_fcache).
|
||||
*-----------------------------------------------------------------
|
||||
*/
|
||||
#define FuncArgTypeIsDynamic(arg) \
|
||||
(IsA(arg,Var) && ((Var*)arg)->varattno == InvalidAttrNumber)
|
||||
|
||||
@ -53,7 +42,6 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
|
||||
rtid = ((Var *) arg)->varno;
|
||||
relname = (char *) getrelname(rtid, econtext->ecxt_range_table);
|
||||
|
||||
|
||||
tup = SearchSysCacheTuple(TYPENAME,
|
||||
PointerGetDatum(relname),
|
||||
0, 0, 0);
|
||||
@ -64,9 +52,14 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
|
||||
return tup->t_data->t_oid;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
*
|
||||
* Initialize a 'FunctionCache' struct given the PG_PROC oid.
|
||||
*
|
||||
*-----------------------------------------------------------------
|
||||
*/
|
||||
static FunctionCachePtr
|
||||
init_fcache(Oid foid,
|
||||
bool use_syscache,
|
||||
List *argList,
|
||||
ExprContext *econtext)
|
||||
{
|
||||
@ -79,16 +72,13 @@ init_fcache(Oid foid,
|
||||
text *tmp;
|
||||
bool isNull;
|
||||
|
||||
retval = (FunctionCachePtr) palloc(sizeof(FunctionCache));
|
||||
MemSet(retval, 0, sizeof(FunctionCache));
|
||||
|
||||
/* ----------------
|
||||
* get the procedure tuple corresponding to the given functionOid
|
||||
* ----------------
|
||||
*/
|
||||
retval = (FunctionCachePtr) palloc(sizeof(FunctionCache));
|
||||
memset(retval, 0, sizeof(FunctionCache));
|
||||
|
||||
if (!use_syscache)
|
||||
elog(ERROR, "what the ????, init the fcache without the catalogs?");
|
||||
|
||||
procedureTuple = SearchSysCacheTuple(PROCOID,
|
||||
ObjectIdGetDatum(foid),
|
||||
0, 0, 0);
|
||||
@ -114,8 +104,7 @@ init_fcache(Oid foid,
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
|
||||
/* ----------------
|
||||
* get the type length and by-value from the type tuple and
|
||||
* save the information in our one element cache.
|
||||
* get the type length and by-value flag from the type tuple
|
||||
* ----------------
|
||||
*/
|
||||
retval->typlen = typeStruct->typlen;
|
||||
@ -136,10 +125,9 @@ init_fcache(Oid foid,
|
||||
retval->foid = foid;
|
||||
retval->language = procedureStruct->prolang;
|
||||
retval->func_state = (char *) NULL;
|
||||
retval->setArg = NULL;
|
||||
retval->setArg = (Datum) 0;
|
||||
retval->hasSetArg = false;
|
||||
retval->oneResult = !procedureStruct->proretset;
|
||||
retval->istrusted = procedureStruct->proistrusted;
|
||||
|
||||
/*
|
||||
* If we are returning exactly one result then we have to copy tuples
|
||||
@ -162,9 +150,8 @@ init_fcache(Oid foid,
|
||||
slot->ttc_tupleDescriptor = (TupleDesc) NULL;
|
||||
slot->ttc_buffer = InvalidBuffer;
|
||||
slot->ttc_whichplan = -1;
|
||||
retval->funcSlot = (Pointer) slot;
|
||||
|
||||
relationTuple = (HeapTuple)
|
||||
relationTuple =
|
||||
SearchSysCacheTuple(RELNAME,
|
||||
PointerGetDatum(&typeStruct->typname),
|
||||
0, 0, 0);
|
||||
@ -177,10 +164,12 @@ init_fcache(Oid foid,
|
||||
else
|
||||
td = CreateTemplateTupleDesc(1);
|
||||
|
||||
((TupleTableSlot *) retval->funcSlot)->ttc_tupleDescriptor = td;
|
||||
slot->ttc_tupleDescriptor = td;
|
||||
|
||||
retval->funcSlot = (Pointer) slot;
|
||||
}
|
||||
else
|
||||
retval->funcSlot = (char *) NULL;
|
||||
retval->funcSlot = (Pointer) NULL;
|
||||
|
||||
nargs = procedureStruct->pronargs;
|
||||
retval->nargs = nargs;
|
||||
@ -189,8 +178,6 @@ init_fcache(Oid foid,
|
||||
{
|
||||
Oid *argTypes;
|
||||
|
||||
retval->nullVect = (bool *) palloc(retval->nargs * sizeof(bool));
|
||||
|
||||
if (retval->language == SQLlanguageId)
|
||||
{
|
||||
int i;
|
||||
@ -218,7 +205,6 @@ init_fcache(Oid foid,
|
||||
else
|
||||
{
|
||||
retval->argOidVect = (Oid *) NULL;
|
||||
retval->nullVect = (BoolPtr) NULL;
|
||||
}
|
||||
|
||||
if (procedureStruct->prolang == SQLlanguageId)
|
||||
@ -257,7 +243,7 @@ init_fcache(Oid foid,
|
||||
retval->nargs = retval->func.fn_nargs;
|
||||
}
|
||||
else
|
||||
retval->func.fn_addr = (func_ptr) NULL;
|
||||
retval->func.fn_addr = (PGFunction) NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -269,7 +255,7 @@ setFcache(Node *node, Oid foid, List *argList, ExprContext *econtext)
|
||||
Oper *onode;
|
||||
FunctionCachePtr fcache;
|
||||
|
||||
fcache = init_fcache(foid, true, argList, econtext);
|
||||
fcache = init_fcache(foid, argList, econtext);
|
||||
|
||||
if (IsA(node, Oper))
|
||||
{
|
||||
|
3
src/backend/utils/cache/relcache.c
vendored
3
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.96 2000/05/21 02:28:55 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.97 2000/05/28 17:56:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -58,6 +58,7 @@
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/smgr.h"
|
||||
#include "utils/catcache.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/temprel.h"
|
||||
|
||||
|
Reference in New Issue
Block a user