mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
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.
This commit is contained in:
@ -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");
|
||||
|
Reference in New Issue
Block a user