From 246ada348ba8fa062e4e84a4f5504a32f94a4f20 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 17 Jun 2007 18:57:29 +0000 Subject: [PATCH] Revert an ill-considered portion of my patch of 12-Mar, which tried to save a few lines in sql_exec_error_callback() by using the function source string field that the patch added to SQL function cache entries. This doesn't work because the fn_extra field isn't filled in yet during init_sql_fcache(). Probably it could be made to work, but it doesn't seem appropriate to contort the main code paths to make an error-reporting path a tad faster. Per report from Pavel Stehule. --- src/backend/executor/functions.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index e115bd3282..502ba94db6 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -765,11 +765,21 @@ sql_exec_error_callback(void *arg) * If there is a syntax error position, convert to internal syntax error */ syntaxerrposition = geterrposition(); - if (syntaxerrposition > 0 && fcache->src) + if (syntaxerrposition > 0) { + bool isnull; + Datum tmp; + char *prosrc; + + tmp = SysCacheGetAttr(PROCOID, func_tuple, Anum_pg_proc_prosrc, + &isnull); + if (isnull) + elog(ERROR, "null prosrc"); + prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp)); errposition(0); internalerrposition(syntaxerrposition); - internalerrquery(fcache->src); + internalerrquery(prosrc); + pfree(prosrc); } /* -- 2.39.5