I was having this exact error! That is, submitting the db 1.3.7 to 1.3.8 upgrade form and having it hang until I quit the browser.
Running the 'mysql_upgrade_zencart_137_to_138.php' update script line by line through my MySQL client (MySQL server version 5.0.45-community-nt), I found that line 62, which reads...
INSERT INTO query_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');
...was causing the script to hang every time.
I commented out that line and the upgrade script was able to complete successfully. I then added the query_builder record manually through my MySQL client.
Hope this helps any that are having a similar issue!