Fix the master subqueries crashes for temp table