Fallback to subquery if database user does not have write-access
Background
We sometimes want to use a read only user to fetch data from the database. Read-only users do not have access to creating temporary tables. However, in some queries, we rely on temporary tables. We still may want to use these as a read-only user, but in those cases, we need a fallback solution where we don't use temporary tables.
Implementation
Modify ExtendedQuery.temp_table
to check if user has write access, and return as subquery if user does not have write access.
Edited by Øyvind Evju