mirror of
https://github.com/postgres/postgres.git
synced 2025-11-16 15:02:33 +03:00
Third round of fmgr updates: eliminate calls using fmgr() and
fmgr_faddr() in favor of new-style calls. Lots of cleanup of sloppy casts to use XXXGetDatum and DatumGetXXX ...
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.53 2000/05/29 21:02:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.54 2000/05/30 04:24:50 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -441,7 +441,10 @@ _ReadArrayStr(char *arrayStr,
|
||||
*q = '\0';
|
||||
if (i >= nitems)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
values[i] = (*fmgr_faddr(inputproc)) (p, typelem, typmod);
|
||||
values[i] = (char *) FunctionCall3(inputproc,
|
||||
CStringGetDatum(p),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(typmod));
|
||||
p = ++q;
|
||||
if (!eoArray)
|
||||
|
||||
@@ -669,21 +672,33 @@ array_out(ArrayType *v, Oid element_type)
|
||||
switch (typlen)
|
||||
{
|
||||
case 1:
|
||||
values[i] = (*fmgr_faddr(&outputproc)) (*p, typelem, -1);
|
||||
values[i] = DatumGetCString(FunctionCall3(&outputproc,
|
||||
CharGetDatum(*p),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(-1)));
|
||||
break;
|
||||
case 2:
|
||||
values[i] = (*fmgr_faddr(&outputproc)) (*(int16 *) p, typelem, -1);
|
||||
values[i] = DatumGetCString(FunctionCall3(&outputproc,
|
||||
Int16GetDatum(*(int16 *) p),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(-1)));
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
values[i] = (*fmgr_faddr(&outputproc)) (*(int32 *) p, typelem, -1);
|
||||
values[i] = DatumGetCString(FunctionCall3(&outputproc,
|
||||
Int32GetDatum(*(int32 *) p),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(-1)));
|
||||
break;
|
||||
}
|
||||
p += typlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = (*fmgr_faddr(&outputproc)) (p, typelem, -1);
|
||||
values[i] = DatumGetCString(FunctionCall3(&outputproc,
|
||||
PointerGetDatum(p),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(-1)));
|
||||
if (typlen > 0)
|
||||
p += typlen;
|
||||
else
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* out of its tuple
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.49 2000/05/30 00:49:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.50 2000/05/30 04:24:51 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -1647,7 +1647,6 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
StringInfo buf = context->buf;
|
||||
HeapTuple typetup;
|
||||
Form_pg_type typeStruct;
|
||||
FmgrInfo finfo_output;
|
||||
char *extval;
|
||||
char *valptr;
|
||||
|
||||
@@ -1673,10 +1672,10 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
return;
|
||||
}
|
||||
|
||||
fmgr_info(typeStruct->typoutput, &finfo_output);
|
||||
extval = (char *) (*fmgr_faddr(&finfo_output)) (constval->constvalue,
|
||||
typeStruct->typelem,
|
||||
-1);
|
||||
extval = DatumGetCString(OidFunctionCall3(typeStruct->typoutput,
|
||||
constval->constvalue,
|
||||
ObjectIdGetDatum(typeStruct->typelem),
|
||||
Int32GetDatum(-1)));
|
||||
|
||||
switch (constval->consttype)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.67 2000/05/28 17:56:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.68 2000/05/30 04:24:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "catalog/pg_statistic.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/cost.h"
|
||||
#include "parser/parse_func.h"
|
||||
#include "parser/parse_oper.h"
|
||||
@@ -157,11 +158,13 @@ eqsel(Oid opid,
|
||||
|
||||
/* be careful to apply operator right way 'round */
|
||||
if (flag & SEL_RIGHT)
|
||||
mostcommon = (bool)
|
||||
DatumGetUInt8(fmgr(eqproc, commonval, value));
|
||||
mostcommon = DatumGetBool(OidFunctionCall2(eqproc,
|
||||
commonval,
|
||||
value));
|
||||
else
|
||||
mostcommon = (bool)
|
||||
DatumGetUInt8(fmgr(eqproc, value, commonval));
|
||||
mostcommon = DatumGetBool(OidFunctionCall2(eqproc,
|
||||
value,
|
||||
commonval));
|
||||
|
||||
if (mostcommon)
|
||||
{
|
||||
@@ -1278,8 +1281,10 @@ getattstatistics(Oid relid,
|
||||
{
|
||||
char *strval = textout(val);
|
||||
|
||||
*commonval = (Datum)
|
||||
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
|
||||
*commonval = FunctionCall3(&inputproc,
|
||||
CStringGetDatum(strval),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(typmod));
|
||||
pfree(strval);
|
||||
}
|
||||
}
|
||||
@@ -1287,7 +1292,7 @@ getattstatistics(Oid relid,
|
||||
if (loval)
|
||||
{
|
||||
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
|
||||
Anum_pg_statistic_staloval,
|
||||
Anum_pg_statistic_staloval,
|
||||
&isnull);
|
||||
|
||||
if (isnull)
|
||||
@@ -1299,8 +1304,10 @@ getattstatistics(Oid relid,
|
||||
{
|
||||
char *strval = textout(val);
|
||||
|
||||
*loval = (Datum)
|
||||
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
|
||||
*loval = FunctionCall3(&inputproc,
|
||||
CStringGetDatum(strval),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(typmod));
|
||||
pfree(strval);
|
||||
}
|
||||
}
|
||||
@@ -1320,8 +1327,10 @@ getattstatistics(Oid relid,
|
||||
{
|
||||
char *strval = textout(val);
|
||||
|
||||
*hival = (Datum)
|
||||
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
|
||||
*hival = FunctionCall3(&inputproc,
|
||||
CStringGetDatum(strval),
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(typmod));
|
||||
pfree(strval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.41 2000/05/29 01:59:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.42 2000/05/30 04:24:53 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -420,6 +420,8 @@ fmgr_sql(PG_FUNCTION_ARGS)
|
||||
return 0; /* keep compiler happy */
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* Interface routine for functions using fmgr_faddr
|
||||
*/
|
||||
@@ -510,6 +512,8 @@ fmgr(Oid procedureId,...)
|
||||
return (char *) result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Support routines for callers of fmgr-compatible functions
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.9 2000/04/12 17:16:12 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.10 2000/05/30 04:24:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1694,7 +1694,6 @@ comparetup_heap(Tuplesortstate *state, const void *a, const void *b)
|
||||
rattr;
|
||||
bool isnull1,
|
||||
isnull2;
|
||||
int result;
|
||||
|
||||
lattr = heap_getattr(ltup, attno, tupDesc, &isnull1);
|
||||
rattr = heap_getattr(rtup, attno, tupDesc, &isnull2);
|
||||
@@ -1708,17 +1707,21 @@ comparetup_heap(Tuplesortstate *state, const void *a, const void *b)
|
||||
return -1;
|
||||
else if (scanKey->sk_flags & SK_COMMUTE)
|
||||
{
|
||||
if (!(result = -(int) (*fmgr_faddr(&scanKey->sk_func)) (rattr, lattr)))
|
||||
result = (int) (*fmgr_faddr(&scanKey->sk_func)) (lattr, rattr);
|
||||
if (result)
|
||||
return result;
|
||||
if (DatumGetBool(FunctionCall2(&scanKey->sk_func,
|
||||
rattr, lattr)))
|
||||
return -1; /* a < b after commute */
|
||||
if (DatumGetBool(FunctionCall2(&scanKey->sk_func,
|
||||
lattr, rattr)))
|
||||
return 1; /* a > b after commute */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(result = -(int) (*fmgr_faddr(&scanKey->sk_func)) (lattr, rattr)))
|
||||
result = (int) (*fmgr_faddr(&scanKey->sk_func)) (rattr, lattr);
|
||||
if (result)
|
||||
return result;
|
||||
if (DatumGetBool(FunctionCall2(&scanKey->sk_func,
|
||||
lattr, rattr)))
|
||||
return -1; /* a < b */
|
||||
if (DatumGetBool(FunctionCall2(&scanKey->sk_func,
|
||||
rattr, lattr)))
|
||||
return 1; /* a > b */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1846,8 +1849,8 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
|
||||
}
|
||||
else
|
||||
{
|
||||
compare = (int32) FMGR_PTR2(&entry->sk_func,
|
||||
attrDatum1, attrDatum2);
|
||||
compare = DatumGetInt32(FunctionCall2(&entry->sk_func,
|
||||
attrDatum1, attrDatum2));
|
||||
}
|
||||
|
||||
if (compare != 0)
|
||||
@@ -1950,13 +1953,13 @@ comparetup_datum(Tuplesortstate *state, const void *a, const void *b)
|
||||
return -1;
|
||||
else
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!(result = -(int) (*fmgr_faddr(&state->sortOpFn)) (ltup->val,
|
||||
rtup->val)))
|
||||
result = (int) (*fmgr_faddr(&state->sortOpFn)) (rtup->val,
|
||||
ltup->val);
|
||||
return result;
|
||||
if (DatumGetBool(FunctionCall2(&state->sortOpFn,
|
||||
ltup->val, rtup->val)))
|
||||
return -1; /* a < b */
|
||||
if (DatumGetBool(FunctionCall2(&state->sortOpFn,
|
||||
rtup->val, ltup->val)))
|
||||
return 1; /* a > b */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user