> A bit shameless to ask a question under top HN record, but I always wondered why do not SQL engines give access to their SQL AST to generate queries.
A number of reasons from the PostgreSQL POV (work on it):
- our internal parser representation isn't stable and frequently changes from major release to major release, occasionally even in minor releases.
- we'd need a lot of additional verbose error checking code to make sure only sensible AST can be submitted
- there's two forms of parser AST "raw" and "analyzed". The former is produced without access to the database, the latter has done validity checks, type lookups, etc. The former is what you could validly produce remotely - but it's also more cumbersome to deal with.
I think there's arguments for supporting a useful different representation than SQL, but I think doing this with the already existing AST isn't going to fly. And a new proper language / representation would be a lot of work...
Edit: formatting