3131 * ENHANCEMENTS, OR MODIFICATIONS.
3232 *
3333 * IDENTIFICATION
34- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.81 2004/01/06 23:55:19 tgl Exp $
34+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.82 2004/01/24 23:06:29 tgl Exp $
3535 *
3636 **********************************************************************/
3737
@@ -695,11 +695,15 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
695695pfree (stroid );
696696
697697/* A list of attribute names for argument TG_relatts */
698- /* note: we deliberately include dropped atts here */
699698Tcl_DStringAppendElement (& tcl_trigtup ,"" );
700699for (i = 0 ;i < tupdesc -> natts ;i ++ )
701- Tcl_DStringAppendElement (& tcl_trigtup ,
702- NameStr (tupdesc -> attrs [i ]-> attname ));
700+ {
701+ if (tupdesc -> attrs [i ]-> attisdropped )
702+ Tcl_DStringAppendElement (& tcl_trigtup ,"" );
703+ else
704+ Tcl_DStringAppendElement (& tcl_trigtup ,
705+ NameStr (tupdesc -> attrs [i ]-> attname ));
706+ }
703707Tcl_DStringAppendElement (& tcl_cmd ,Tcl_DStringValue (& tcl_trigtup ));
704708Tcl_DStringFree (& tcl_trigtup );
705709Tcl_DStringInit (& tcl_trigtup );
@@ -881,34 +885,36 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
881885siglongjmp (Warn_restart ,1 );
882886}
883887
884- i = 0 ;
885- while (i < ret_numvals )
888+ for (i = 0 ;i < ret_numvals ;i += 2 )
886889{
890+ CONST84 char * ret_name = ret_values [i ];
891+ CONST84 char * ret_value = ret_values [i + 1 ];
887892int attnum ;
888893HeapTuple typeTup ;
889894Oid typinput ;
890895Oid typelem ;
891896FmgrInfo finfo ;
892897
893898/************************************************************
894- * Ignore pseudo elementswith a dot name
899+ * Ignore".tupno" pseudo elements(see pltcl_set_tuple_values)
895900 ************************************************************/
896- if (* (ret_values [i ])== '.' )
897- {
898- i += 2 ;
901+ if (strcmp (ret_name ,".tupno" )== 0 )
899902continue ;
900- }
901903
902904/************************************************************
903905 * Get the attribute number
904906 ************************************************************/
905- attnum = SPI_fnumber (tupdesc ,ret_values [ i ++ ] );
907+ attnum = SPI_fnumber (tupdesc ,ret_name );
906908if (attnum == SPI_ERROR_NOATTRIBUTE )
907- elog (ERROR ,"invalid attribute \"%s\"" ,
908- ret_values [-- i ]);
909+ elog (ERROR ,"invalid attribute \"%s\"" ,ret_name );
909910if (attnum <=0 )
910- elog (ERROR ,"cannot set system attribute \"%s\"" ,
911- ret_values [-- i ]);
911+ elog (ERROR ,"cannot set system attribute \"%s\"" ,ret_name );
912+
913+ /************************************************************
914+ * Ignore dropped columns
915+ ************************************************************/
916+ if (tupdesc -> attrs [attnum - 1 ]-> attisdropped )
917+ continue ;
912918
913919/************************************************************
914920 * Lookup the attribute type in the syscache
@@ -932,7 +938,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
932938UTF_BEGIN ;
933939modvalues [attnum - 1 ]=
934940FunctionCall3 (& finfo ,
935- CStringGetDatum (UTF_U2E (ret_values [ i ++ ] )),
941+ CStringGetDatum (UTF_U2E (ret_value )),
936942ObjectIdGetDatum (typelem ),
937943Int32GetDatum (tupdesc -> attrs [attnum - 1 ]-> atttypmod ));
938944UTF_END ;