preliminary version of retag.sql
fix #289; add retagging script