2
2
* pltcl.c - PostgreSQL support for Tcl as
3
3
* procedural language (PL)
4
4
*
5
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.114 2007/09/28 22:33:20 momjian Exp $
5
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.115 2007/10/05 17:06:11 tgl Exp $
6
6
*
7
7
**********************************************************************/
8
8
@@ -76,7 +76,8 @@ PG_MODULE_MAGIC;
76
76
**********************************************************************/
77
77
typedef struct pltcl_proc_desc
78
78
{
79
- char * proname ;
79
+ char * user_proname ;
80
+ char * internal_proname ;
80
81
TransactionId fn_xmin ;
81
82
ItemPointerData fn_tid ;
82
83
bool fn_readonly ;
@@ -549,7 +550,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
549
550
************************************************************/
550
551
Tcl_DStringInit (& tcl_cmd );
551
552
Tcl_DStringInit (& list_tmp );
552
- Tcl_DStringAppendElement (& tcl_cmd , prodesc -> proname );
553
+ Tcl_DStringAppendElement (& tcl_cmd , prodesc -> internal_proname );
553
554
554
555
/************************************************************
555
556
* Add all call arguments to the command
@@ -636,9 +637,10 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
636
637
UTF_BEGIN ;
637
638
ereport (ERROR ,
638
639
(errmsg ("%s" , interp -> result ),
639
- errcontext ("%s" ,
640
+ errcontext ("%s\nin PL/Tcl function \"%s\" " ,
640
641
UTF_U2E (Tcl_GetVar (interp , "errorInfo" ,
641
- TCL_GLOBAL_ONLY )))));
642
+ TCL_GLOBAL_ONLY )),
643
+ prodesc -> user_proname )));
642
644
UTF_END ;
643
645
}
644
646
@@ -723,7 +725,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
723
725
PG_TRY ();
724
726
{
725
727
/* The procedure name */
726
- Tcl_DStringAppendElement (& tcl_cmd , prodesc -> proname );
728
+ Tcl_DStringAppendElement (& tcl_cmd , prodesc -> internal_proname );
727
729
728
730
/* The trigger name for argument TG_name */
729
731
Tcl_DStringAppendElement (& tcl_cmd , trigdata -> tg_trigger -> tgname );
@@ -865,9 +867,10 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
865
867
UTF_BEGIN ;
866
868
ereport (ERROR ,
867
869
(errmsg ("%s" , interp -> result ),
868
- errcontext ("%s" ,
870
+ errcontext ("%s\nin PL/Tcl function \"%s\" " ,
869
871
UTF_U2E (Tcl_GetVar (interp , "errorInfo" ,
870
- TCL_GLOBAL_ONLY )))));
872
+ TCL_GLOBAL_ONLY )),
873
+ prodesc -> user_proname )));
871
874
UTF_END ;
872
875
}
873
876
@@ -1085,7 +1088,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1085
1088
(errcode (ERRCODE_OUT_OF_MEMORY ),
1086
1089
errmsg ("out of memory" )));
1087
1090
MemSet (prodesc , 0 , sizeof (pltcl_proc_desc ));
1088
- prodesc -> proname = strdup (internal_proname );
1091
+ prodesc -> user_proname = strdup (NameStr (procStruct -> proname ));
1092
+ prodesc -> internal_proname = strdup (internal_proname );
1089
1093
prodesc -> fn_xmin = HeapTupleHeaderGetXmin (procTup -> t_data );
1090
1094
prodesc -> fn_tid = procTup -> t_self ;
1091
1095
@@ -1101,7 +1105,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1101
1105
0 , 0 , 0 );
1102
1106
if (!HeapTupleIsValid (langTup ))
1103
1107
{
1104
- free (prodesc -> proname );
1108
+ free (prodesc -> user_proname );
1109
+ free (prodesc -> internal_proname );
1105
1110
free (prodesc );
1106
1111
elog (ERROR , "cache lookup failed for language %u" ,
1107
1112
procStruct -> prolang );
@@ -1126,7 +1131,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1126
1131
0 , 0 , 0 );
1127
1132
if (!HeapTupleIsValid (typeTup ))
1128
1133
{
1129
- free (prodesc -> proname );
1134
+ free (prodesc -> user_proname );
1135
+ free (prodesc -> internal_proname );
1130
1136
free (prodesc );
1131
1137
elog (ERROR , "cache lookup failed for type %u" ,
1132
1138
procStruct -> prorettype );
@@ -1140,15 +1146,17 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1140
1146
/* okay */ ;
1141
1147
else if (procStruct -> prorettype == TRIGGEROID )
1142
1148
{
1143
- free (prodesc -> proname );
1149
+ free (prodesc -> user_proname );
1150
+ free (prodesc -> internal_proname );
1144
1151
free (prodesc );
1145
1152
ereport (ERROR ,
1146
1153
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1147
1154
errmsg ("trigger functions can only be called as triggers" )));
1148
1155
}
1149
1156
else
1150
1157
{
1151
- free (prodesc -> proname );
1158
+ free (prodesc -> user_proname );
1159
+ free (prodesc -> internal_proname );
1152
1160
free (prodesc );
1153
1161
ereport (ERROR ,
1154
1162
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
@@ -1159,7 +1167,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1159
1167
1160
1168
if (typeStruct -> typtype == TYPTYPE_COMPOSITE )
1161
1169
{
1162
- free (prodesc -> proname );
1170
+ free (prodesc -> user_proname );
1171
+ free (prodesc -> internal_proname );
1163
1172
free (prodesc );
1164
1173
ereport (ERROR ,
1165
1174
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
@@ -1187,7 +1196,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1187
1196
0 , 0 , 0 );
1188
1197
if (!HeapTupleIsValid (typeTup ))
1189
1198
{
1190
- free (prodesc -> proname );
1199
+ free (prodesc -> user_proname );
1200
+ free (prodesc -> internal_proname );
1191
1201
free (prodesc );
1192
1202
elog (ERROR , "cache lookup failed for type %u" ,
1193
1203
procStruct -> proargtypes .values [i ]);
@@ -1197,7 +1207,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1197
1207
/* Disallow pseudotype argument */
1198
1208
if (typeStruct -> typtype == TYPTYPE_PSEUDO )
1199
1209
{
1200
- free (prodesc -> proname );
1210
+ free (prodesc -> user_proname );
1211
+ free (prodesc -> internal_proname );
1201
1212
free (prodesc );
1202
1213
ereport (ERROR ,
1203
1214
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
@@ -1305,7 +1316,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1305
1316
Tcl_DStringFree (& proc_internal_def );
1306
1317
if (tcl_rc != TCL_OK )
1307
1318
{
1308
- free (prodesc -> proname );
1319
+ free (prodesc -> user_proname );
1320
+ free (prodesc -> internal_proname );
1309
1321
free (prodesc );
1310
1322
elog (ERROR , "could not create internal procedure \"%s\": %s" ,
1311
1323
internal_proname , interp -> result );
@@ -1315,7 +1327,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
1315
1327
* Add the proc description block to the hashtable
1316
1328
************************************************************/
1317
1329
hashent = Tcl_CreateHashEntry (pltcl_proc_hash ,
1318
- prodesc -> proname , & hashnew );
1330
+ prodesc -> internal_proname , & hashnew );
1319
1331
Tcl_SetHashValue (hashent , (ClientData ) prodesc );
1320
1332
}
1321
1333
0 commit comments