drop type "public"."usr_username"; set check_function_bodies = off; CREATE OR REPLACE FUNCTION public.create_newtype_text(qualified_name text) RETURNS void LANGUAGE plpgsql AS $function$ begin execute concat('create type ', qualified_name, ' as (str text);'); execute concat( 'create function ' , qualified_name || '_to_string(val ' || qualified_name || ')' , E' returns text language sql as \'select (val.str);\';' ); execute concat( 'create function ' , qualified_name || '_of_string(val text)' , ' returns ' || qualified_name || E' language sql as \'select row(val);\';' ); end; $function$ ; CREATE OR REPLACE FUNCTION public.usr_username_of_string(val text) RETURNS usr_username LANGUAGE sql AS $function$select row(val);$function$ ; CREATE OR REPLACE FUNCTION public.usr_username_to_string(val usr_username) RETURNS text LANGUAGE sql AS $function$select (val.str);$function$ ; create type "public"."usr_username" as ("str" text);