1--
2-- create user defined conversion
3--
4CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE;
5SET SESSION AUTHORIZATION regress_conversion_user;
6CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
7--
8-- cannot make same name conversion in same schema
9--
10CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
11ERROR:  conversion "myconv" already exists
12--
13-- create default conversion with qualified name
14--
15CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
16--
17-- cannot make default conversion with same schema/for_encoding/to_encoding
18--
19CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
20ERROR:  default conversion for LATIN1 to UTF8 already exists
21-- test comments
22COMMENT ON CONVERSION myconv_bad IS 'foo';
23ERROR:  conversion "myconv_bad" does not exist
24COMMENT ON CONVERSION myconv IS 'bar';
25COMMENT ON CONVERSION myconv IS NULL;
26--
27-- drop user defined conversion
28--
29DROP CONVERSION myconv;
30DROP CONVERSION mydef;
31--
32-- Note: the built-in conversions are exercised in opr_sanity.sql,
33-- so there's no need to do that here.
34--
35--
36-- return to the super user
37--
38RESET SESSION AUTHORIZATION;
39DROP USER regress_conversion_user;
40