Re: Loading the PL/pgSQL debugger (and other plugins) - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: Loading the PL/pgSQL debugger (and other plugins) |
Date | |
Msg-id | 700.1153506529@sss.pgh.pa.us Whole thread Raw |
In response to | Re: Loading the PL/pgSQL debugger (and other plugins) (korry <korryd@enterprisedb.com>) |
Responses |
Re: Loading the PL/pgSQL debugger (and other plugins)
|
List | pgsql-hackers |
korry <korryd@enterprisedb.com> writes: >> I see no good reason to tie >> it to plpgsql; we'll just need another one for every other language. >> > Hmmm... but the plugins themselves would be language-specific. You miss my point. The plugins will be language-specific but the mechanism for selecting/loading them shouldn't be. >> When the plugin's shared library gets loaded, one way or the other, >> it should construct the function-pointer struct and then pass it to a >> function defined by plpgsql (this lets us hide/postpone the decision >> about whether there can be more than one active plugin). >> > But there's a timing issue there. If you ask the plugin to call a > call-handler function, then you can't load the plugin at backend startup > because the PL/pgSQL call-handler isn't loaded until it's required. > Since both the plugin and the call-handler are dynamically loaded, I > think one of them has to load the other. Right, but if you set up the mechanism such that each individual PL is responsible for loading plugins, then we'll have to duplicate all that code each time we instrument another PL. I want to do as much as possible of the work in the core code so that we don't end up with duplicate code to maintain. That being the case, I don't see anything wrong with having the selection mechanism pull in the selected plugin(s) and then those force loading of the language handlers so that they can call the plugin installation function. Sure, sometimes this would result in loading a plugin and handler that don't get used in the current session, but given that people would only load plugins they intend to use, I don't see that as a significant objection. I'm thinking that the cleanest way to handle this would be to add another column to pg_language containing the OID of the plugin receptor function for each PL. Then the plugin just calls that function passing its constructed function-pointer struct. This eliminates the need for hard-wired assumptions about function names and so forth, and also lets you use the existing fmgr functionality to pull in the PL's handler library. OTOH this requires extending the syntax of CREATE LANGUAGE and so on. That is all doable (it's basically the same kind of work that got done when we added validator functions for PLs) but it might be more work than we think the plugin idea is worth. To do it without a pg_language column, we'd need code in each plugin to identify the language shared library (by looking in pg_language), force loading of same (using existing fmgr code), and look up and call a plugin receptor function given an expected C-code name for it (again, most of this already exists in fmgr). It's not a huge amount of code, probably, but again duplicating it in each plugin seems unappealing. I suppose we could make fmgr export a general function to find a plugin receptor function given the PL name and the expected C symbol. Comments anyone? regards, tom lane
pgsql-hackers by date: