/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.129 2007/06/28 17:49:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.130 2007/10/05 17:06:11 tgl Exp $
*
**********************************************************************/
**********************************************************************/
typedef struct plperl_proc_desc
{
- char *proname;
+ char *proname; /* user name of procedure */
TransactionId fn_xmin;
ItemPointerData fn_tid;
bool fn_readonly;
typedef struct plperl_proc_entry
{
- char proc_name[NAMEDATALEN];
+ char proc_name[NAMEDATALEN]; /* internal name, eg __PLPerl_proc_39987 */
plperl_proc_desc *proc_data;
} plperl_proc_entry;
* supplied in s, and returns a reference to the closure.
*/
static SV *
-plperl_create_sub(char *s, bool trusted)
+plperl_create_sub(char *proname, char *s, bool trusted)
{
dSP;
SV *subref;
LEAVE;
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("creation of Perl function failed: %s",
+ errmsg("creation of Perl function \"%s\" failed: %s",
+ proname,
strip_trailing_ws(SvPV(ERRSV, PL_na)))));
}
LEAVE;
/* XXX need to find a way to assign an errcode here */
ereport(ERROR,
- (errmsg("error from Perl function: %s",
+ (errmsg("error from Perl function \"%s\": %s",
+ desc->proname,
strip_trailing_ws(SvPV(ERRSV, PL_na)))));
}
LEAVE;
/* XXX need to find a way to assign an errcode here */
ereport(ERROR,
- (errmsg("error from Perl trigger function: %s",
+ (errmsg("error from Perl function \"%s\": %s",
+ desc->proname,
strip_trailing_ws(SvPV(ERRSV, PL_na)))));
}
{
HeapTuple procTup;
Form_pg_proc procStruct;
- char internal_proname[64];
+ char internal_proname[NAMEDATALEN];
plperl_proc_desc *prodesc = NULL;
int i;
plperl_proc_entry *hash_entry;
if (!uptodate)
{
- free(prodesc); /* are we leaking memory here? */
+ free(prodesc->proname);
+ free(prodesc);
prodesc = NULL;
hash_search(plperl_proc_hash, internal_proname,
- HASH_REMOVE,NULL);
+ HASH_REMOVE, NULL);
}
}
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
MemSet(prodesc, 0, sizeof(plperl_proc_desc));
- prodesc->proname = strdup(internal_proname);
+ prodesc->proname = strdup(NameStr(procStruct->proname));
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
prodesc->fn_tid = procTup->t_self;
check_interp(prodesc->lanpltrusted);
- prodesc->reference = plperl_create_sub(proc_source, prodesc->lanpltrusted);
+ prodesc->reference = plperl_create_sub(prodesc->proname,
+ proc_source,
+ prodesc->lanpltrusted);
restore_context(oldcontext);
* pltcl.c - PostgreSQL support for Tcl as
* procedural language (PL)
*
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.114 2007/09/28 22:33:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.115 2007/10/05 17:06:11 tgl Exp $
*
**********************************************************************/
**********************************************************************/
typedef struct pltcl_proc_desc
{
- char *proname;
+ char *user_proname;
+ char *internal_proname;
TransactionId fn_xmin;
ItemPointerData fn_tid;
bool fn_readonly;
************************************************************/
Tcl_DStringInit(&tcl_cmd);
Tcl_DStringInit(&list_tmp);
- Tcl_DStringAppendElement(&tcl_cmd, prodesc->proname);
+ Tcl_DStringAppendElement(&tcl_cmd, prodesc->internal_proname);
/************************************************************
* Add all call arguments to the command
UTF_BEGIN;
ereport(ERROR,
(errmsg("%s", interp->result),
- errcontext("%s",
+ errcontext("%s\nin PL/Tcl function \"%s\"",
UTF_U2E(Tcl_GetVar(interp, "errorInfo",
- TCL_GLOBAL_ONLY)))));
+ TCL_GLOBAL_ONLY)),
+ prodesc->user_proname)));
UTF_END;
}
PG_TRY();
{
/* The procedure name */
- Tcl_DStringAppendElement(&tcl_cmd, prodesc->proname);
+ Tcl_DStringAppendElement(&tcl_cmd, prodesc->internal_proname);
/* The trigger name for argument TG_name */
Tcl_DStringAppendElement(&tcl_cmd, trigdata->tg_trigger->tgname);
UTF_BEGIN;
ereport(ERROR,
(errmsg("%s", interp->result),
- errcontext("%s",
+ errcontext("%s\nin PL/Tcl function \"%s\"",
UTF_U2E(Tcl_GetVar(interp, "errorInfo",
- TCL_GLOBAL_ONLY)))));
+ TCL_GLOBAL_ONLY)),
+ prodesc->user_proname)));
UTF_END;
}
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
MemSet(prodesc, 0, sizeof(pltcl_proc_desc));
- prodesc->proname = strdup(internal_proname);
+ prodesc->user_proname = strdup(NameStr(procStruct->proname));
+ prodesc->internal_proname = strdup(internal_proname);
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
prodesc->fn_tid = procTup->t_self;
0, 0, 0);
if (!HeapTupleIsValid(langTup))
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang);
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
elog(ERROR, "cache lookup failed for type %u",
procStruct->prorettype);
/* okay */ ;
else if (procStruct->prorettype == TRIGGEROID)
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
}
else
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
if (typeStruct->typtype == TYPTYPE_COMPOSITE)
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
elog(ERROR, "cache lookup failed for type %u",
procStruct->proargtypes.values[i]);
/* Disallow pseudotype argument */
if (typeStruct->typtype == TYPTYPE_PSEUDO)
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
Tcl_DStringFree(&proc_internal_def);
if (tcl_rc != TCL_OK)
{
- free(prodesc->proname);
+ free(prodesc->user_proname);
+ free(prodesc->internal_proname);
free(prodesc);
elog(ERROR, "could not create internal procedure \"%s\": %s",
internal_proname, interp->result);
* Add the proc description block to the hashtable
************************************************************/
hashent = Tcl_CreateHashEntry(pltcl_proc_hash,
- prodesc->proname, &hashnew);
+ prodesc->internal_proname, &hashnew);
Tcl_SetHashValue(hashent, (ClientData) prodesc);
}