I wrote: > What had been a 100% spec-compliant view definition is now quite > Postgres-specific. I fixed some similar problems in 0bb51aa96 (before > that, the CURRENT_TIMESTAMP part would've reverse-listed differently > too); but I didn't tackle EXTRACT(), SUBSTRING(), and other cases. > I'm not claiming that we really need to fix all of those. But if we are > going to pick nits about which data type EXTRACT() returns then I think > it's legit to worry about its reverse-list representation at the same > time ... especially if we must touch the grammar's translation anyway.
BTW, shortly after sending that I had an idea about how to do it without adding a boatload of new parsetree infrastructure, which has been the main reason why nobody has wanted to tackle it. The obvious way to do this is to make a new kind of expression node, but that cascades into lots and lots of places (see 0bb51aa96, plus the later commits that fixed oversights in it :-(). It's a lot of work for a mostly-cosmetic issue. However: suppose that we continue to translate these things into FuncExpr nodes, the same as always, but we add a new CoercionForm variant, say COERCE_SQL_SYNTAX. 99% of the system ignores FuncExpr.funcformat, and would continue to do so, but ruleutils.c would take it to mean that (1) the call should be reverse-listed as some special SQL syntax and (2) the funcid is one of a small set of built-in functions for which ruleutils.c knows what to emit. (If it doesn't recognize the funcid, it could either throw an error, or fall back to normal display of the node.) For cases such as EXTRACT, this would also represent a promise that specific arguments are Const nodes from which the desired keyword can be extracted. This is kind of an abuse of "CoercionForm", since that typedef name implies that it only talks about how to handle cast cases, but semantically it's always been a how-to-display-function-calls thing. We could either hold our noses about that or rename the typedef. If we went this way then we could easily clean up most of the other weird-SQL-syntax function call cases, incrementally over time, without a lot of additional work. regards, tom lane