Created
March 21, 2022 07:01
-
-
Save imfht/adb20db15f69b69d68f62c3e4d9f0f6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://stackoverflow.com/a/45537886/8591480 | |
CREATE FUNCTION is_valid_utf8(bytea) RETURNS boolean | |
LANGUAGE plpgsql AS | |
$$BEGIN | |
PERFORM convert_from($1, 'UTF8'); | |
RETURN TRUE; | |
EXCEPTION | |
WHEN character_not_in_repertoire THEN | |
RAISE WARNING '%', SQLERRM; | |
RETURN FALSE; | |
END;$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment