diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-04 22:06:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-04 22:06:46 +0000 |
commit | 03b0a589d1d43c91224bc148d50c3242c6776058 (patch) | |
tree | 1521f3ea552d3b3e5eafcc094587252c34a045e7 /src/backend/commands/indexcmds.c | |
parent | 1ca0874faa235dca5f817dca04f12a29de44350c (diff) | |
download | postgresql-03b0a589d1d43c91224bc148d50c3242c6776058.tar.gz postgresql-03b0a589d1d43c91224bc148d50c3242c6776058.zip |
Consider interpreting a function call as a trivial (binary-compatible)
type coercion after failing to find an exact match in pg_proc, but before
considering interpretations that involve a function call with one or
more argument type coercions. This avoids surprises wherein what looks
like a type coercion is interpreted as coercing to some third type and
then to the destination type, as in Dave Blasby's bug report of 3-Oct-01.
See subsequent discussion in pghackers.
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 2304dd0b0cd..aaf0630a2a7 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.57 2001/08/21 16:36:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.58 2001/10/04 22:06:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -240,6 +240,7 @@ FuncIndexArgs(IndexInfo *indexInfo, List *arglist; int nargs = 0; int i; + FuncDetailCode fdresult; Oid funcid; Oid rettype; bool retset; @@ -282,9 +283,18 @@ FuncIndexArgs(IndexInfo *indexInfo, * that. So, check to make sure that the selected function has * exact-match or binary-compatible input types. */ - if (!func_get_detail(funcIndex->name, nargs, argTypes, - &funcid, &rettype, &retset, &true_typeids)) - func_error("DefineIndex", funcIndex->name, nargs, argTypes, NULL); + fdresult = func_get_detail(funcIndex->name, funcIndex->args, + nargs, argTypes, + &funcid, &rettype, &retset, + &true_typeids); + if (fdresult != FUNCDETAIL_NORMAL) + { + if (fdresult == FUNCDETAIL_COERCION) + elog(ERROR, "DefineIndex: functional index must use a real function, not a type coercion" + "\n\tTry specifying the index opclass you want to use, instead"); + else + func_error("DefineIndex", funcIndex->name, nargs, argTypes, NULL); + } if (retset) elog(ERROR, "DefineIndex: cannot index on a function returning a set"); |