Dimitri Fontaine <dimi...@2ndquadrant.fr> writes: > Tom Lane <t...@sss.pgh.pa.us> writes: >> Well, that's already a problem, because as Robert keeps saying, what >> goes through utility.c and what doesn't is pretty random right at the >> moment, and we shouldn't expose that behavior to users for fear of not >> being able to change it later.
> It didn't feel that random to me. In most cases, the rule is that if the > system wants to execute a command that you could have typed as a user in > the prompt, then it hacks together a parsenode and call ProcessUtility. Uh, no, there's no such "rule". In some places it was convenient to do that so people did it --- but often it's easier to just call the appropriate function directly, especially if you have any special locking or permissions requirements. I don't think there's any great consistency to it. To be a little more concrete, I looked through backend/catalog and backend/commands, which ought to pretty much cover all the places where commands do things that could be considered subcommands. I find three uses of ProcessUtility: extension.c: uses ProcessUtility to handle non-DML commands read from an extension script. schemacmds.c: CreateSchemaCommand uses ProcessUtility for any subcommand of a CREATE SCHEMA statement. This is really just direct execution of something the user typed, it's not the system "creating" a subcommand. trigger.c: ConvertTriggerToFK uses ProcessUtility to execute a consed-up ALTER TABLE ADD FOREIGN KEY command in place of a series of legacy CREATE CONSTRAINT TRIGGER commands. Now this is the very definition of ugly, and shouldn't drive our design decisions --- but I think that any user event trigger would be darn surprised to find this being emitted, especially when the two preceding CREATE CONSTRAINT TRIGGERs hadn't done any such thing, and indeed hadn't created any constraint trigger. AFAICT, everything else in those directories is using direct calls and not going through utility.c. So the only other cases where a trigger in ProcessUtility would trap subcommands are where those subcommands are things that parse_utilcmd.c generated during expansion of a CREATE TABLE or such. And that whole area is something that I feel strongly is implementation detail we don't particularly want to expose to users. For instance, the fact that a UNIQUE clause in a CREATE TABLE works that way and not at some lower level is nothing but implementation artifact. [ pokes around a bit more... ] Having now actually looked at every call point of ProcessUtility in the current code, I find myself agreeing very much with Robert: we do *not* want to expose that exact set of events to users. Except for the original top-level commands, it's almost entirely implementation artifacts that can and will change from release to release. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers