SQL compatibility warning:
We are going to "quote" identifiers that correspond to reserved keywords, so that the query still stays syntactically correct. An issue with automatic quoting is that quoted identifiers, beside being allowed to contain reserved words, are taken in a case-sensitive manner while the rest of SQL is case-insensitive, in the sense that they are implicitly normalized by the SQL server.
Now there are funny problem that may arise with this: if you define a table as tAbLe, it will internally be define as TABLE (if normalized to uppercase) on the server side, and requesting the table "tAbLe" will then fail with a "table not found" error.
Our choice is therefore to case-normalize reserved identifiers before quoting them.
Finally, PostGreSQL does not follow the SQL norm of normalizing identifiers to uppercase, it instead normalizes to lowercase. As long as Macaque is pgsql-only, we choose lowercase here, but that will have to be runtime-configurable in a hopeful future where Macaque gets ported to other backends.