--
-- Make sure strings are validated
-- Should fail for all encodings, as nul bytes are never permitted.
--
CREATE OR REPLACE FUNCTION perl_zerob() RETURNS TEXT AS $$
  return "abcd\0efg";
$$ LANGUAGE plperl;
SELECT perl_zerob();
ERROR:  invalid byte sequence for encoding "UTF8": 0x00
CONTEXT:  PL/Perl function "perl_zerob"
