title: Convert a bytea column to OID while retaining values
body: <p>I'm trying to alter a <code>bytea</code> column to have type <code>oid</code> and still retain the values.</p>
  
  <p>I have tried using queries like:</p>
  
  <pre><code>ALTER TABLE mytable ADD COLUMN mycol_tmp oid;
  UPDATE mytable SET mycol_tmp = CAST(mycol as oid);
  ALTER TABLE mytable DROP COLUMN mycol;
  ALTER TABLE mytable RENAME mycol_tmp TO mycol;
  </code></pre>
  
  <p>But that just gives me the error:</p>
  
  <pre><code>ERROR: cannot cast type bytea to oid
  </code></pre>
  
  <p>Is there any way to achieve what I want?</p>