Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf884130

Browse files
committed
Minor improvements in regprocout() and oidvectortypes().
1 parent66fe0fc commitf884130

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

‎src/backend/utils/adt/regproc.c

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.52 2000/02/18 09:28:48 inoue Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.53 2000/02/27 03:30:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -165,6 +165,13 @@ regprocout(RegProcedure proid)
165165

166166
result= (char*)palloc(NAMEDATALEN);
167167

168+
if (proid==InvalidOid)
169+
{
170+
result[0]='-';
171+
result[1]='\0';
172+
returnresult;
173+
}
174+
168175
if (!IsBootstrapProcessingMode())
169176
{
170177
proctup=SearchSysCacheTuple(PROCOID,
@@ -231,14 +238,19 @@ regprocout(RegProcedure proid)
231238
}
232239

233240
/*
234-
*int8typeout- converts int8 type oids to "typname" list
241+
* oidvectortypes- converts a vector of type OIDs to "typname" list
242+
*
243+
* The interface for this function is wrong: it should be told how many
244+
* OIDs are significant in the input vector, so that trailing InvalidOid
245+
* argument types can be recognized.
235246
*/
236247
text*
237248
oidvectortypes(Oid*oidArray)
238249
{
239250
HeapTupletypetup;
240251
text*result;
241-
intnum;
252+
intnumargs,
253+
num;
242254

243255
if (oidArray==NULL)
244256
{
@@ -247,27 +259,33 @@ oidvectortypes(Oid *oidArray)
247259
returnresult;
248260
}
249261

250-
result= (text*)palloc(NAMEDATALEN*FUNC_MAX_ARGS+
251-
FUNC_MAX_ARGS+VARHDRSZ+1);
252-
*VARDATA(result)='\0';
253-
262+
/* Try to guess how many args there are :-( */
263+
numargs=0;
254264
for (num=0;num<FUNC_MAX_ARGS;num++)
255265
{
256266
if (oidArray[num]!=InvalidOid)
267+
numargs=num+1;
268+
}
269+
270+
result= (text*)palloc((NAMEDATALEN+1)*numargs+VARHDRSZ+1);
271+
*VARDATA(result)='\0';
272+
273+
for (num=0;num<numargs;num++)
274+
{
275+
typetup=SearchSysCacheTuple(TYPEOID,
276+
ObjectIdGetDatum(oidArray[num]),
277+
0,0,0);
278+
if (HeapTupleIsValid(typetup))
257279
{
258-
typetup=SearchSysCacheTuple(TYPEOID,
259-
ObjectIdGetDatum(oidArray[num]),
260-
0,0,0);
261-
if (HeapTupleIsValid(typetup))
262-
{
263-
char*s;
280+
char*s;
264281

265-
s=NameStr(((Form_pg_type)GETSTRUCT(typetup))->typname);
266-
StrNCpy(VARDATA(result)+strlen(VARDATA(result)),s,
267-
NAMEDATALEN);
268-
strcat(VARDATA(result)," ");
269-
}
282+
s=NameStr(((Form_pg_type)GETSTRUCT(typetup))->typname);
283+
StrNCpy(VARDATA(result)+strlen(VARDATA(result)),s,
284+
NAMEDATALEN);
285+
strcat(VARDATA(result)," ");
270286
}
287+
else
288+
strcat(VARDATA(result),"- ");
271289
}
272290
VARSIZE(result)=strlen(VARDATA(result))+VARHDRSZ;
273291
returnresult;
@@ -290,6 +308,3 @@ regproctooid(RegProcedure rp)
290308
}
291309

292310
/* (see int.c for comparison/operation routines) */
293-
294-
295-
/* ========== PRIVATE ROUTINES ========== */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp