SQL replace() function in PDO
Would it be something like this?

db_update('system')-&gt;
  expression('filename', 'replace(filename, :old, :new)', array(
    ':old' =&gt; 'sites/all/modules/contrib',
    ':new' =&gt; 'profiles/distroname/modules/contrib'
  ))
  -&gt;execute();