 warn "In shadow_trigger_function, the trigger payload is\n". Dump(\$_TD) if $_SHARED{debug};
 my $rv = spi_exec_query($query);
 
+my $remote_schema = $_SHARED{get_connection_info}->({
+    data_source_id => $data_source_id
+})->{remote_schema};
 my $table = $_TD->{relname};
 warn "Raw table name is $table";
 warn "In trigger on $table, action is $_TD->{new}{iud_action}" if $_SHARED{debug};

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

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

my $iud = {
