upgrade.pl: prettify a query