As far as not all DB handle temp tables in the same way, we have right not one moodle_temptables class applied to mysql/mssql/oracle to provide cross-db handing.
The last point we need to cover is what happens with created temptables on moodle_database disposal, as far as not all DBs drop the remaining temp tables automatically (yes oracle temp tables are persistent).
- moving the temptables stuff from mysql/mssql/oracle implementations to general moodle_database.
- same for sql_generators stuff (move to parent class).
- implement pgsql_temptables class (doing nothing but registering the created/dropped temptables).
- modify moodle_database->dispose to call moodle_temptables->dispose()
- temptables->dispose() will emit one error_log() and automatically drop any temp table if necessary