CREATE OR REPLACE FUNCTION deny_updates() RETURNS trigger AS $$ BEGIN { strict->import(); } use lib '/contrib'; use lib '/extensions'; use CheckTrigger; my @column_names; my $minargc = 1; # $minargc += 2; # This should be a row level trigger */ die 'should be called as a row level trigger' unless ($_TD->{level} eq 'ROW'); # Do nothing if event is not UPDATE return if ($_TD->{event} ne 'UPDATE'); die "$_TD->{name}, takes at least $minargc arguments" unless ($_TD->{argc} >= $minargc); # my $assert = shift @{$_TD->{args}}; # my $error_text = shift @{$_TD->{args}}; # do a poor-man's quote_nullable for 8.3 and below # $assert = PLPerl::CheckTrigger::pg_quote_nullable($assert); # $error_text = PLPerl::CheckTrigger::pg_quote_nullable($error_text); my $options_arg = uc(shift @{$_TD->{args}}); my $oldtuple = $_TD->{old}; my $newtuple = $_TD->{new}; if ($_TD->{argc} > $minargc) { @column_names = @{$_TD->{args}}; } else { @column_names = (); } my $ch = new PLPerl::CheckTrigger($_TD); my $result; eval { $result = $ch->check_columns($options_arg, @column_names); }; die $@ if ($@); if (!$result) { # $error_text = PLPerl::CheckTrigger::pg_quote_nullable($ch->{errmsg}) if (($error_text eq '') || ($error_text eq 'NULL')); # my $query = "SELECT tools.assert($assert, false, $error_text)"; # my $rv = spi_exec_query($query); die $ch->{errmsg}; } return; $$ LANGUAGE plperlu;