Minor improvements in regprocout() and oidvectortypes().

This commit is contained in:
Tom Lane 2000-02-27 03:30:27 +00:00
parent 66fe0fc87e
commit f884130241
1 changed files with 37 additions and 22 deletions

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.52 2000/02/18 09:28:48 inoue Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.53 2000/02/27 03:30:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -165,6 +165,13 @@ regprocout(RegProcedure proid)
result = (char *) palloc(NAMEDATALEN); result = (char *) palloc(NAMEDATALEN);
if (proid == InvalidOid)
{
result[0] = '-';
result[1] = '\0';
return result;
}
if (!IsBootstrapProcessingMode()) if (!IsBootstrapProcessingMode())
{ {
proctup = SearchSysCacheTuple(PROCOID, proctup = SearchSysCacheTuple(PROCOID,
@ -231,14 +238,19 @@ regprocout(RegProcedure proid)
} }
/* /*
* int8typeout - converts int8 type oids to "typname" list * oidvectortypes - converts a vector of type OIDs to "typname" list
*
* The interface for this function is wrong: it should be told how many
* OIDs are significant in the input vector, so that trailing InvalidOid
* argument types can be recognized.
*/ */
text * text *
oidvectortypes(Oid *oidArray) oidvectortypes(Oid *oidArray)
{ {
HeapTuple typetup; HeapTuple typetup;
text *result; text *result;
int num; int numargs,
num;
if (oidArray == NULL) if (oidArray == NULL)
{ {
@ -247,13 +259,18 @@ oidvectortypes(Oid *oidArray)
return result; return result;
} }
result = (text *) palloc(NAMEDATALEN * FUNC_MAX_ARGS + /* Try to guess how many args there are :-( */
FUNC_MAX_ARGS + VARHDRSZ + 1); numargs = 0;
*VARDATA(result) = '\0';
for (num = 0; num < FUNC_MAX_ARGS; num++) for (num = 0; num < FUNC_MAX_ARGS; num++)
{ {
if (oidArray[num] != InvalidOid) if (oidArray[num] != InvalidOid)
numargs = num+1;
}
result = (text *) palloc((NAMEDATALEN + 1) * numargs + VARHDRSZ + 1);
*VARDATA(result) = '\0';
for (num = 0; num < numargs; num++)
{ {
typetup = SearchSysCacheTuple(TYPEOID, typetup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(oidArray[num]), ObjectIdGetDatum(oidArray[num]),
@ -267,7 +284,8 @@ oidvectortypes(Oid *oidArray)
NAMEDATALEN); NAMEDATALEN);
strcat(VARDATA(result), " "); strcat(VARDATA(result), " ");
} }
} else
strcat(VARDATA(result), "- ");
} }
VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ;
return result; return result;
@ -290,6 +308,3 @@ regproctooid(RegProcedure rp)
} }
/* (see int.c for comparison/operation routines) */ /* (see int.c for comparison/operation routines) */
/* ========== PRIVATE ROUTINES ========== */