--
-- create user defined conversion
--
CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE;

SET SESSION AUTHORIZATION regress_conversion_user;

CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;

--
-- cannot make same name conversion in same schema
--
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;

--
-- create default conversion with qualified name
--
CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8'
FROM
    iso8859_1_to_utf8;

--
-- cannot make default conversion with same schema/for_encoding/to_encoding
--
CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8'
FROM
    iso8859_1_to_utf8;

-- test comments
COMMENT ON CONVERSION myconv_bad IS 'foo';

COMMENT ON CONVERSION myconv IS 'bar';

COMMENT ON CONVERSION myconv IS NULL;

--
-- drop user defined conversion
--
DROP CONVERSION myconv;

DROP CONVERSION mydef;

--
-- Note: the built-in conversions are exercised in opr_sanity.sql,
-- so there's no need to do that here.
--
--
-- return to the super user
--
RESET SESSION AUTHORIZATION;

DROP USER regress_conversion_user;

