CREATE TEMP TABLE copy_simd_repro (a text);

 SET statement_timeout = '10s';

 COPY copy_simd_repro FROM PROGRAM $cmd$
 perl -e '
     $SIG{PIPE} = sub { exit 0 };
     my $data = ("a" x 65524) . "\n\\.\n" . ("x" x 8);
     my $offset = 0;

     die "payload is not 65536 bytes" unless length($data) == 65536;
     while ($offset < length($data))
     {
         my $written =
           syswrite(STDOUT, $data, length($data) - $offset, $offset);
         die "write failed: $!" unless defined($written);
         $offset += $written;
     }

     while (1)
     {
         select(undef, undef, undef, 0.05);
         syswrite(STDOUT, "x");
     }
 '
 $cmd$;

 RESET statement_timeout;

 SELECT count(*) AS rows_copied, min(length(a)) AS row_length
 FROM copy_simd_repro;
