title: How to cast to a user defined type in postgresql
body: <p>I have to create a table with some user defined types and insert data.</p>
  
  <p>I tried this way.</p>
  
  <ol>
  <li>create type type1 as (i int);</li>
  <li>create function mycast(int) returns type1 as 'select $1;' language 'sql';</li>
  <li>create cast (int as type1) with function mycast(int) as implicit;</li>
  <li>create table table_type(t type1);</li>
  <li>insert into table_type values(1::type1);</li>
  </ol>
  
  <p>Now the values are getting inserted but wrapped in parenthesis, like this</p>
  
  <pre><code>select * from table_type;
  
    t  
  --------
   (1)
  
  (1 rows)
  </code></pre>
  
  <p>I believe there might be an error in my function. Can someone help. I wanted basically a function that returns the same output as my input (without any () ).</p>
  
  <p>Thanks.</p>