         'SELECT pg_catalog.quote_ident($1) AS foo',
         'TEXT'
     );
-    my $quoted = spi_exec_query(
+    my $quoted = spi_exec_prepared(
         $plan,
         $_[0]
     )->{rows}[0]{foo};

warn "In shadow_trigger_function, the trigger payload is\n". Dump(\$_TD) if $_SHARED{debug};
my $rv = spi_exec_query($query);

my $table = $_TD->{relname};
warn "Raw table name is $table";
warn "In trigger on $table, action is $_TD->{new}{iud_action}" if $_SHARED{debug};

    \z                  # End of string.
}
{$1}sx;
$table = $remote_schema . "." . $table if defined $remote_schema;
warn "Cooked table name is $table";

my $iud = {
