31
31
* ENHANCEMENTS, OR MODIFICATIONS.
32
32
*
33
33
* 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 $
35
35
*
36
36
**********************************************************************/
37
37
@@ -695,11 +695,15 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
695
695
pfree (stroid );
696
696
697
697
/* A list of attribute names for argument TG_relatts */
698
- /* note: we deliberately include dropped atts here */
699
698
Tcl_DStringAppendElement (& tcl_trigtup , "" );
700
699
for (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
+ }
703
707
Tcl_DStringAppendElement (& tcl_cmd , Tcl_DStringValue (& tcl_trigtup ));
704
708
Tcl_DStringFree (& tcl_trigtup );
705
709
Tcl_DStringInit (& tcl_trigtup );
@@ -881,34 +885,36 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
881
885
siglongjmp (Warn_restart , 1 );
882
886
}
883
887
884
- i = 0 ;
885
- while (i < ret_numvals )
888
+ for (i = 0 ; i < ret_numvals ; i += 2 )
886
889
{
890
+ CONST84 char * ret_name = ret_values [i ];
891
+ CONST84 char * ret_value = ret_values [i + 1 ];
887
892
int attnum ;
888
893
HeapTuple typeTup ;
889
894
Oid typinput ;
890
895
Oid typelem ;
891
896
FmgrInfo finfo ;
892
897
893
898
/************************************************************
894
- * Ignore pseudo elements with a dot name
899
+ * Ignore ".tupno" pseudo elements (see pltcl_set_tuple_values)
895
900
************************************************************/
896
- if (* (ret_values [i ]) == '.' )
897
- {
898
- i += 2 ;
901
+ if (strcmp (ret_name , ".tupno" ) == 0 )
899
902
continue ;
900
- }
901
903
902
904
/************************************************************
903
905
* Get the attribute number
904
906
************************************************************/
905
- attnum = SPI_fnumber (tupdesc , ret_values [ i ++ ] );
907
+ attnum = SPI_fnumber (tupdesc , ret_name );
906
908
if (attnum == SPI_ERROR_NOATTRIBUTE )
907
- elog (ERROR , "invalid attribute \"%s\"" ,
908
- ret_values [-- i ]);
909
+ elog (ERROR , "invalid attribute \"%s\"" , ret_name );
909
910
if (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 ;
912
918
913
919
/************************************************************
914
920
* Lookup the attribute type in the syscache
@@ -932,7 +938,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
932
938
UTF_BEGIN ;
933
939
modvalues [attnum - 1 ] =
934
940
FunctionCall3 (& finfo ,
935
- CStringGetDatum (UTF_U2E (ret_values [ i ++ ] )),
941
+ CStringGetDatum (UTF_U2E (ret_value )),
936
942
ObjectIdGetDatum (typelem ),
937
943
Int32GetDatum (tupdesc -> attrs [attnum - 1 ]-> atttypmod ));
938
944
UTF_END ;
0 commit comments