1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Thank god for searchable mail archives.

Patch by: wieck@sapserv.debis.de (Jan Wieck)

   One  of  the design rules of PostgreSQL is extensibility. And
   to follow this rule means (at least for me) that there should
   not  only  be a builtin PL.  Instead I would prefer a defined
   interface for PL implemetations.
This commit is contained in:
PostgreSQL Daemon
1998-01-15 19:46:37 +00:00
parent 763ff8aef8
commit baef78d96b
37 changed files with 340 additions and 398 deletions

View File

@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.5 1997/10/28 15:02:24 vadim Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.6 1998/01/15 19:44:50 pgsql Exp $
#
# NOTES
# Passes any -D options on to cpp prior to generating the list
@@ -81,7 +81,7 @@ cat > $HFILE <<FuNkYfMgRsTuFf
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: Gen_fmgrtab.sh.in,v 1.5 1997/10/28 15:02:24 vadim Exp $
* $Id: Gen_fmgrtab.sh.in,v 1.6 1998/01/15 19:44:50 pgsql Exp $
*
* NOTES
* ******************************
@@ -111,16 +111,21 @@ typedef struct {
char *data[MAXFMGRARGS];
} FmgrValues;
typedef struct {
func_ptr fn_addr;
func_ptr fn_plhandler;
Oid fn_oid;
int fn_nargs;
} FmgrInfo;
/*
* defined in fmgr.c
*/
extern char *fmgr_pl(Oid func_id, int n_arguments, FmgrValues *values,
bool *isNull);
extern char *fmgr_c(func_ptr user_fn, Oid func_id, int n_arguments,
FmgrValues *values, bool *isNull);
extern void fmgr_info(Oid procedureId, func_ptr *function, int *nargs);
extern char *fmgr_c(FmgrInfo *finfo, FmgrValues *values, bool *isNull);
extern void fmgr_info(Oid procedureId, FmgrInfo *finfo);
extern func_ptr fmgr_faddr(FmgrInfo *finfo);
extern char *fmgr(Oid procedureId, ... );
extern char *fmgr_ptr(func_ptr user_fn, Oid func_id, ... );
extern char *fmgr_ptr(FmgrInfo *finfo, ... );
extern char *fmgr_array_args(Oid procedureId, int nargs,
char *args[], bool *isNull);
@@ -139,11 +144,11 @@ extern void load_file(char *filename);
* we must).
*/
#ifdef TRACE_FMGR_PTR
#define FMGR_PTR2(FP, FID, ARG1, ARG2) \
fmgr_ptr(FP, FID, 2, ARG1, ARG2)
#define FMGR_PTR2(FINFO, ARG1, ARG2) \
fmgr_ptr(FINFO, 2, ARG1, ARG2)
#else
#define FMGR_PTR2(FP, FID, ARG1, ARG2) \
((FP) ? (*((func_ptr)(FP)))(ARG1, ARG2) : fmgr(FID, ARG1, ARG2))
#define FMGR_PTR2(FINFO, ARG1, ARG2) \
(((FINFO)->fn_addr) ? (*(fmgr_faddr(FINFO)))(ARG1, ARG2) : fmgr((FINFO)->fn_oid, ARG1, ARG2))
#endif
/*
@@ -177,7 +182,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.5 1997/10/28 15:02:24 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.6 1998/01/15 19:44:50 pgsql Exp $
*
* NOTES
*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.23 1998/01/05 16:39:41 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.24 1998/01/15 19:45:01 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@
static int _ArrayCount(char *str, int dim[], int typdelim);
static char *
_ReadArrayStr(char *arrayStr, int nitems, int ndim, int dim[],
func_ptr inputproc, Oid typelem, char typdelim,
FmgrInfo *inputproc, Oid typelem, char typdelim,
int typlen, bool typbyval, char typalign,
int *nbytes);
@@ -105,10 +105,9 @@ array_in(char *string, /* input array in external form */
*p,
*q,
*r;
func_ptr inputproc;
FmgrInfo inputproc;
int i,
nitems,
dummy;
nitems;
int32 nbytes;
char *dataPtr;
ArrayType *retval = NULL;
@@ -120,7 +119,7 @@ array_in(char *string, /* input array in external form */
system_cache_lookup(element_type, true, &typlen, &typbyval, &typdelim,
&typelem, &typinput, &typalign);
fmgr_info(typinput, &inputproc, &dummy);
fmgr_info(typinput, &inputproc);
string_save = (char *) palloc(strlen(string) + 3);
strcpy(string_save, string);
@@ -208,7 +207,7 @@ array_in(char *string, /* input array in external form */
{
/* array not a large object */
dataPtr =
(char *) _ReadArrayStr(p, nitems, ndim, dim, inputproc, typelem,
(char *) _ReadArrayStr(p, nitems, ndim, dim, &inputproc, typelem,
typdelim, typlen, typbyval, typalign,
&nbytes);
nbytes += ARR_OVERHEAD(ndim);
@@ -367,7 +366,7 @@ _ReadArrayStr(char *arrayStr,
int nitems,
int ndim,
int dim[],
func_ptr inputproc, /* function used for the
FmgrInfo *inputproc, /* function used for the
* conversion */
Oid typelem,
char typdelim,
@@ -461,7 +460,7 @@ _ReadArrayStr(char *arrayStr,
*q = '\0';
if (i >= nitems)
elog(ERROR, "array_in: illformed array constant");
values[i] = (*inputproc) (p, typelem);
values[i] = (*fmgr_faddr(inputproc)) (p, typelem);
p = ++q;
if (!eoArray)
@@ -620,7 +619,7 @@ array_out(ArrayType *v, Oid element_type)
char typdelim;
Oid typoutput,
typelem;
func_ptr outputproc;
FmgrInfo outputproc;
char typalign;
char *p,
@@ -634,7 +633,6 @@ array_out(ArrayType *v, Oid element_type)
k,
indx[MAXDIM];
bool dummy_bool;
int dummy_int;
int ndim,
*dim;
@@ -662,7 +660,7 @@ array_out(ArrayType *v, Oid element_type)
system_cache_lookup(element_type, false, &typlen, &typbyval,
&typdelim, &typelem, &typoutput, &typalign);
fmgr_info(typoutput, &outputproc, &dummy_int);
fmgr_info(typoutput, &outputproc);
sprintf(delim, "%c", typdelim);
ndim = ARR_NDIM(v);
dim = ARR_DIMS(v);
@@ -688,21 +686,21 @@ array_out(ArrayType *v, Oid element_type)
switch (typlen)
{
case 1:
values[i] = (*outputproc) (*p, typelem);
values[i] = (*fmgr_faddr(&outputproc)) (*p, typelem);
break;
case 2:
values[i] = (*outputproc) (*(int16 *) p, typelem);
values[i] = (*fmgr_faddr(&outputproc)) (*(int16 *) p, typelem);
break;
case 3:
case 4:
values[i] = (*outputproc) (*(int32 *) p, typelem);
values[i] = (*fmgr_faddr(&outputproc)) (*(int32 *) p, typelem);
break;
}
p += typlen;
}
else
{
values[i] = (*outputproc) (p, typelem);
values[i] = (*fmgr_faddr(&outputproc)) (p, typelem);
if (typlen > 0)
p += typlen;
else

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.11 1998/01/05 16:40:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.12 1998/01/15 19:45:09 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -117,8 +117,8 @@ SetDefine(char *querystr, char *typename)
procrel = heap_openr(ProcedureRelationName);
RelationSetLockForWrite(procrel);
fmgr_info(ObjectIdEqualRegProcedure,
&oidKey[0].sk_func,
&oidKey[0].sk_nargs);
&oidKey[0].sk_func);
oidKey[0].sk_nargs = oidKey[0].sk_func.fn_nargs;
oidKey[0].sk_argument = ObjectIdGetDatum(setoid);
pg_proc_scan = heap_beginscan(procrel,
0,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.20 1998/01/07 21:06:08 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.21 1998/01/15 19:45:28 pgsql Exp $
*
* Notes:
* XXX This needs to use exception.h to handle recovery when
@@ -213,8 +213,8 @@ CatalogCacheInitializeCache(struct catcache * cache,
EQPROC(tupdesc->attrs[cache->cc_key[i] - 1]->atttypid);
fmgr_info(cache->cc_skey[i].sk_procedure,
(func_ptr *) &cache->cc_skey[i].sk_func,
(int *) &cache->cc_skey[i].sk_nargs);
&cache->cc_skey[i].sk_func);
cache->cc_skey[i].sk_nargs = cache->cc_skey[i].sk_func.fn_nargs;
CACHE5_elog(DEBUG, "CatalogCacheInit %16s %d %d %x",
&relation->rd_rel->relname,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.9 1998/01/07 21:06:11 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.10 1998/01/15 19:45:29 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -98,6 +98,7 @@ init_fcache(Oid foid,
* ----------------
*/
retval = (FunctionCachePtr) palloc(sizeof(FunctionCache));
memset(retval, 0, sizeof(FunctionCache));
if (!use_syscache)
elog(ERROR, "what the ????, init the fcache without the catalogs?");
@@ -281,10 +282,12 @@ init_fcache(Oid foid,
if (retval->language != SQLlanguageId)
fmgr_info(foid, &(retval->func), &(retval->nargs));
else
retval->func = (func_ptr) NULL;
if (retval->language != SQLlanguageId) {
fmgr_info(foid, &(retval->func));
retval->nargs = retval->func.fn_nargs;
} else {
retval->func.fn_addr = (func_ptr) NULL;
}
return (retval);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.33 1998/01/14 15:48:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.34 1998/01/15 19:45:31 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2014,7 +2014,8 @@ init_irels(void)
/* have to reinit the function pointers in the strategy maps */
for (i = 0; i < am->amstrategies; i++)
fmgr_info(SMD(i).sk_procedure,
&(SMD(i).sk_func), &(SMD(i).sk_nargs));
&(SMD(i).sk_func));
SMD(i).sk_nargs = SMD(i).sk_func.fn_nargs;
/*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.9 1998/01/07 21:06:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.10 1998/01/15 19:45:58 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,78 +32,64 @@
#include "commands/trigger.h"
char *
fmgr_pl(Oid func_id,
int n_arguments,
FmgrValues * values,
bool * isNull)
static FmgrInfo *fmgr_pl_finfo;
static char *
fmgr_pl(char *arg0, ...)
{
HeapTuple procedureTuple;
HeapTuple languageTuple;
Form_pg_proc procedureStruct;
Form_pg_language languageStruct;
func_ptr plcall_fn;
int plcall_nargs;
va_list pvar;
FmgrValues values;
bool isNull = false;
int i;
/* Fetch the pg_proc tuple from the syscache */
procedureTuple = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(func_id),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
{
elog(ERROR, "fmgr_pl(): Cache lookup of procedure %ld failed.",
ObjectIdGetDatum(func_id));
}
procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
memset(&values, 0, sizeof(values));
/* Fetch the pg_language tuple from the syscache */
languageTuple = SearchSysCacheTuple(LANOID,
ObjectIdGetDatum(procedureStruct->prolang),
0, 0, 0);
if (!HeapTupleIsValid(languageTuple))
{
elog(ERROR, "fmgr_pl(): Cache lookup of language %ld for procedure %ld failed.",
ObjectIdGetDatum(procedureStruct->prolang),
ObjectIdGetDatum(func_id));
}
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
/* Get the function pointer for the PL call handler */
fmgr_info(languageStruct->lanplcallfoid, &plcall_fn, &plcall_nargs);
if (plcall_fn == NULL)
{
elog(ERROR, "fmgr_pl(): failed to load PL handler for procedure %ld.",
ObjectIdGetDatum(func_id));
if (fmgr_pl_finfo->fn_nargs > 0) {
values.data[0] = arg0;
if (fmgr_pl_finfo->fn_nargs > 1) {
va_start(pvar, arg0);
for (i = 1; i < fmgr_pl_finfo->fn_nargs; i++) {
values.data[i] = va_arg(pvar, char *);
}
va_end(pvar);
}
}
/* Call the PL handler */
CurrentTriggerData = NULL;
return (*plcall_fn) (func_id,
n_arguments,
values,
isNull);
}
char *
fmgr_c(func_ptr user_fn,
Oid func_id,
int n_arguments,
FmgrValues * values,
bool * isNull)
{
char *returnValue = (char *) NULL;
return (*(fmgr_pl_finfo->fn_plhandler)) (fmgr_pl_finfo,
&values,
&isNull);
}
char *
fmgr_c(FmgrInfo *finfo,
FmgrValues * values,
bool * isNull)
{
char *returnValue = (char *) NULL;
int n_arguments = finfo->fn_nargs;
func_ptr user_fn = fmgr_faddr(finfo);
if (user_fn == (func_ptr) NULL)
{
/*
* a NULL func_ptr denotet untrusted function (in postgres 4.2).
* Untrusted functions have very limited use and is clumsy. We now
* use this feature for procedural languages.
* Untrusted functions have very limited use and is clumsy. We
* just get rid of it.
*/
return fmgr_pl(func_id, n_arguments, values, isNull);
elog(WARN, "internal error: untrusted function not supported.");
}
/*
* If finfo contains a PL handler for this function,
* call that instead.
*/
if (finfo->fn_plhandler != NULL) {
return (*(finfo->fn_plhandler))(finfo, values, isNull);
}
switch (n_arguments)
@@ -164,14 +150,14 @@ fmgr_c(func_ptr user_fn,
break;
default:
elog(ERROR, "fmgr_c: function %d: too many arguments (%d > %d)",
func_id, n_arguments, MAXFMGRARGS);
finfo->fn_oid, n_arguments, MAXFMGRARGS);
break;
}
return (returnValue);
}
void
fmgr_info(Oid procedureId, func_ptr * function, int *nargs)
fmgr_info(Oid procedureId, FmgrInfo *finfo)
{
func_ptr user_fn = NULL;
FmgrCall *fcp;
@@ -181,6 +167,10 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs)
Form_pg_language languageStruct;
Oid language;
finfo->fn_addr = NULL;
finfo->fn_plhandler = NULL;
finfo->fn_oid = procedureId;
if (!(fcp = fmgr_isbuiltin(procedureId)))
{
procedureTuple = SearchSysCacheTuple(PROOID,
@@ -191,29 +181,29 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs)
elog(ERROR, "fmgr_info: function %d: cache lookup failed\n",
procedureId);
}
procedureStruct = (FormData_pg_proc *)
GETSTRUCT(procedureTuple);
procedureStruct = (FormData_pg_proc *) GETSTRUCT(procedureTuple);
if (!procedureStruct->proistrusted)
{
*function = (func_ptr) NULL;
*nargs = procedureStruct->pronargs;
finfo->fn_addr = (func_ptr) NULL;
finfo->fn_nargs = procedureStruct->pronargs;
return;
}
language = procedureStruct->prolang;
switch (language)
{
case INTERNALlanguageId:
user_fn = fmgr_lookupByName(procedureStruct->proname.data);
if (!user_fn)
elog(ERROR, "fmgr_info: function %s: not in internal table",
procedureStruct->proname.data);
finfo->fn_addr =
fmgr_lookupByName(procedureStruct->proname.data);
if (!finfo->fn_addr)
elog(WARN, "fmgr_info: function %s: not in internal table",
procedureStruct->proname.data);
break;
case ClanguageId:
user_fn = fmgr_dynamic(procedureId, nargs);
finfo->fn_addr = fmgr_dynamic(procedureId, &(finfo->fn_nargs));
break;
case SQLlanguageId:
user_fn = (func_ptr) NULL;
*nargs = procedureStruct->pronargs;
finfo->fn_addr = (func_ptr) NULL;
finfo->fn_nargs = procedureStruct->pronargs;
break;
default:
@@ -236,8 +226,12 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs)
GETSTRUCT(languageTuple);
if (languageStruct->lanispl)
{
user_fn = (func_ptr) NULL;
*nargs = procedureStruct->pronargs;
FmgrInfo plfinfo;
fmgr_info(((Form_pg_language)GETSTRUCT(languageTuple))->lanplcallfoid, &plfinfo);
finfo->fn_addr = (func_ptr) fmgr_pl;
finfo->fn_plhandler = plfinfo.fn_addr;
finfo->fn_nargs = procedureStruct->pronargs;
}
else
{
@@ -249,10 +243,16 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs)
}
else
{
user_fn = fcp->func;
*nargs = fcp->nargs;
finfo->fn_addr = fcp->func;
finfo->fn_nargs = fcp->nargs;
}
*function = user_fn;
}
func_ptr
fmgr_faddr(FmgrInfo *finfo)
{
fmgr_pl_finfo = finfo;
return finfo->fn_addr;
}
/*
@@ -273,12 +273,13 @@ fmgr(Oid procedureId,...)
register i;
int pronargs;
FmgrValues values;
func_ptr user_fn;
FmgrInfo finfo;
bool isNull = false;
va_start(pvar, procedureId);
fmgr_info(procedureId, &user_fn, &pronargs);
fmgr_info(procedureId, &finfo);
pronargs = finfo.fn_nargs;
if (pronargs > MAXFMGRARGS)
{
@@ -290,8 +291,7 @@ fmgr(Oid procedureId,...)
va_end(pvar);
/* XXX see WAY_COOL_ORTHOGONAL_FUNCTIONS */
return (fmgr_c(user_fn, procedureId, pronargs, &values,
&isNull));
return (fmgr_c(&finfo, &values, &isNull));
}
/*
@@ -301,20 +301,26 @@ fmgr(Oid procedureId,...)
* the pointer, but it's available for use with macros in fmgr.h if you
* want this routine to do sanity-checking for you.
*
* func_ptr, func_id, n_arguments, args...
* funcinfo, n_arguments, args...
*/
#ifdef NOT_USED
char *
fmgr_ptr(func_ptr user_fn, Oid func_id,...)
fmgr_ptr(FmgrInfo *finfo, ...)
{
va_list pvar;
register i;
int n_arguments;
FmgrInfo local_finfo;
FmgrValues values;
bool isNull = false;
va_start(pvar, func_id);
local_finfo->fn_addr = finfo->fn_addr;
local_finfo->fn_plhandler = finfo->fn_plhandler;
local_finfo->fn_oid = finfo->fn_oid;
va_start(pvar, finfo);
n_arguments = va_arg(pvar, int);
local_finfo->fn_nargs = n_arguments;
if (n_arguments > MAXFMGRARGS)
{
elog(ERROR, "fmgr_ptr: function %d: too many arguments (%d > %d)",
@@ -325,8 +331,7 @@ fmgr_ptr(func_ptr user_fn, Oid func_id,...)
va_end(pvar);
/* XXX see WAY_COOL_ORTHOGONAL_FUNCTIONS */
return (fmgr_c(user_fn, func_id, n_arguments, &values,
&isNull));
return (fmgr_c(&local_finfo, &values, &isNull));
}
#endif
@@ -339,16 +344,14 @@ fmgr_ptr(func_ptr user_fn, Oid func_id,...)
char *
fmgr_array_args(Oid procedureId, int nargs, char *args[], bool * isNull)
{
func_ptr user_fn;
int true_arguments;
FmgrInfo finfo;
fmgr_info(procedureId, &user_fn, &true_arguments);
fmgr_info(procedureId, &finfo);
finfo.fn_nargs = nargs;
/* XXX see WAY_COOL_ORTHOGONAL_FUNCTIONS */
return
(fmgr_c(user_fn,
procedureId,
true_arguments,
(fmgr_c(&finfo,
(FmgrValues *) args,
isNull));
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.9 1997/09/18 05:37:30 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.10 1998/01/15 19:46:08 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
@@ -212,14 +212,14 @@ tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context)
if (context->scanKeys[nkey].sk_flags & SK_COMMUTE)
{
if (!(result =
(long) (*context->scanKeys[nkey].sk_func) (rattr, lattr)))
(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (rattr, lattr)))
result =
-(long) (*context->scanKeys[nkey].sk_func) (lattr, rattr);
-(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (lattr, rattr);
}
else if (!(result =
(long) (*context->scanKeys[nkey].sk_func) (lattr, rattr)))
(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (lattr, rattr)))
result =
-(long) (*context->scanKeys[nkey].sk_func) (rattr, lattr);
-(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (rattr, lattr);
nkey++;
}
return (result == 1);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.31 1998/01/13 04:04:57 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.32 1998/01/15 19:46:10 pgsql Exp $
*
* NOTES
* Sorts the first relation into the second relation.
@@ -1115,11 +1115,11 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup)
if (PsortKeys[nkey].sk_flags & SK_COMMUTE)
{
if (!(result = -(long) (*PsortKeys[nkey].sk_func) (rattr, lattr)))
result = (long) (*PsortKeys[nkey].sk_func) (lattr, rattr);
if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr)))
result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr);
}
else if (!(result = -(long) (*PsortKeys[nkey].sk_func) (lattr, rattr)))
result = (long) (*PsortKeys[nkey].sk_func) (rattr, lattr);
else if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr)))
result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr);
nkey++;
}
return (result);