Department of second thoughts: even if we can't run the full parser on
a SQL function with polymorphic inputs, we can at least run the raw parser to catch silly syntactic errors.
This commit is contained in:
parent
c5faf2cf3c
commit
f973b74583
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.98 2003/07/01 00:04:37 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.99 2003/07/01 01:28:32 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -639,24 +639,32 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We can't precheck the function definition if there are any polymorphic
|
|
||||||
* input types, because actual datatypes of expression results will be
|
|
||||||
* unresolvable. The check will be done at runtime instead.
|
|
||||||
*/
|
|
||||||
if (!haspolyarg)
|
|
||||||
{
|
|
||||||
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
|
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't do full prechecking of the function definition if there are
|
||||||
|
* any polymorphic input types, because actual datatypes of expression
|
||||||
|
* results will be unresolvable. The check will be done at runtime
|
||||||
|
* instead.
|
||||||
|
*
|
||||||
|
* We can run the text through the raw parser though; this will at
|
||||||
|
* least catch silly syntactic errors.
|
||||||
|
*/
|
||||||
|
if (!haspolyarg)
|
||||||
|
{
|
||||||
querytree_list = pg_parse_and_rewrite(prosrc,
|
querytree_list = pg_parse_and_rewrite(prosrc,
|
||||||
proc->proargtypes,
|
proc->proargtypes,
|
||||||
proc->pronargs);
|
proc->pronargs);
|
||||||
check_sql_fn_retval(proc->prorettype, functyptype, querytree_list);
|
check_sql_fn_retval(proc->prorettype, functyptype, querytree_list);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
querytree_list = pg_parse_query(prosrc);
|
||||||
|
}
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user