1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Provide a namespace.c function for lookup of an operator with exact

input datatypes given, and use this before trying OpernameGetCandidates.
This is faster than the old method when there's an exact match, and it
does not seem materially slower when there's not.  And it definitely
makes some of the callers cleaner, because they didn't really want to
know about a list of candidates anyway.  Per discussion with Atsushi Ogawa.
This commit is contained in:
Tom Lane
2006-05-01 23:22:43 +00:00
parent 82a2881c5b
commit a65a49429f
4 changed files with 190 additions and 138 deletions

View File

@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.97 2006/03/05 15:58:43 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.98 2006/05/01 23:22:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -598,12 +598,10 @@ Datum
regoperatorin(PG_FUNCTION_ARGS)
{
char *opr_name_or_oid = PG_GETARG_CSTRING(0);
Oid result = InvalidOid;
Oid result;
List *names;
int nargs;
Oid argtypes[FUNC_MAX_ARGS];
char oprkind;
FuncCandidateList clist;
/* '0' ? */
if (strcmp(opr_name_or_oid, "0") == 0)
@ -642,28 +640,13 @@ regoperatorin(PG_FUNCTION_ARGS)
errmsg("too many arguments"),
errhint("Provide two argument types for operator.")));
if (argtypes[0] == InvalidOid)
oprkind = 'l';
else if (argtypes[1] == InvalidOid)
oprkind = 'r';
else
oprkind = 'b';
result = OpernameGetOprid(names, argtypes[0], argtypes[1]);
clist = OpernameGetCandidates(names, oprkind);
for (; clist; clist = clist->next)
{
if (memcmp(clist->args, argtypes, 2 * sizeof(Oid)) == 0)
break;
}
if (clist == NULL)
if (!OidIsValid(result))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("operator does not exist: %s", opr_name_or_oid)));
result = clist->oid;
PG_RETURN_OID(result);
}