Julien Rouhaud <rjuju...@gmail.com> writes: > As an alternative, maybe we could expose a simple SRF that would take care of > rewriting the query and deparsing the resulting query tree(s)?
I'm not really excited by this, as it seems like it's exposing internal decisions we could change someday; to wit, first that there is any such thing as a separate rewriting pass, and second that its output is interpretable as pure SQL. (TBH, I'm not 100% sure that the second assumption is true even today, although I know there are ancient comments that claim that.) It's not very hard to imagine someday moving view expansion into the planner on efficiency grounds, leaving the rewriter handling only the rare uses of INSERT/UPDATE/DELETE rules. If there's functions in ruleutils.c that we'd need to make public to let somebody write a debugging extension that does this kind of thing, I'd be happier with that approach than with creating a core-server SQL function for it. There might be more than one use-case for the exposed bits. regards, tom lane