title: Using `BEFORE INSERT` trigger to change the datatype of incoming data to match the column datatype in PostgreSQL
body: <p>I have a postgres table, with a column <code>C</code> which has type <code>T</code>. People will be using <code>COPY</code> to insert data into this table. However sometimes they try to insert a value for C that isn't of type T, however I have a postgres function which can convert the value to T.</p>
  
  <p>I'm trying to write a <code>BEFORE INSERT</code> trigger on the table which will call this function on the data so that I can ensure that I get no insert type errors. However it doesn't appear to work, I'm getting errors when trying to insert the data, even with the trigger there.</p>
  
  <p>Before I spend too much time investigating, I want to find out if this is possible. Can I use triggers in this way to change the type of incoming data?</p>
  
  <p>I want this to run on postgresql 9.3, but I have noticed the error and non-functioning trigger on postgres 9.5.</p>