Обсуждение: Re: CustomScan in a larger structure (RE: CustomScan support on readfuncs.c)
> On Wed, Jan 27, 2016 at 9:36 PM, Robert Haas <robertmhaas@gmail.com> wrote: > > On Mon, Jan 25, 2016 at 8:06 PM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote: > >> Sorry for my late response. I've been unavailable to have enough > >> time to touch code for the last 1.5 month. > >> > >> The attached patch is a revised one to handle private data of > >> foregn/custom scan node more gracefully. > >> > >> The overall consensus upthread were: > >> - A new ExtensibleNodeMethods structure defines a unique name > >> and a set of callbacks to handle node copy, serialization, > >> deserialization and equality checks. > >> - (Foreign|Custom)(Path|Scan|ScanState) are first host of the > >> ExtensibleNodeMethods, to allow extension to define larger > >> structure to store its private fields. > >> - ExtensibleNodeMethods does not support variable length > >> structure (like a structure with an array on the tail, use > >> separately allocated array). > >> - ExtensibleNodeMethods shall be registered on _PG_init() of > >> extensions. > >> > >> The 'pgsql-v9.6-custom-private.v3.patch' is the main part of > >> this feature. As I pointed out before, it uses dynhash instead > >> of the self invented hash table. > > > > On a first read-through, I see nothing in this patch to which I would > > want to object except for the fact that the comments and documentation > > need some work from a native speaker of English. It looks like what > > we discussed, and I think it's an improvement over what we have now. > > Well, looking at this a bit more, it seems like the documentation > you've written here is really misplaced. The patch is introducing a > new facility that applies to both CustomScan and ForeignScan, but the > documentation is only to do with CustomScan. I think we need a whole > new chapter on extensible nodes, or something. I'm actually not > really keen on the fact that we keep adding SGML documentation for > this stuff; it seems like it belongs in a README in the source tree. > We don't explain nodes in general, but now we're going to have to try > to explain extensible nodes. How's that going to work? > The detail of these callbacks are not for end-users, administrators and so on except for core/extension developers. So, I loves idea not to have such a detailed description in SGML. How about an idea to have more detailed source code comments close to the definition of ExtensibleNodeMethods? I haven't seen the src/backend/nodes/README yet, and it has only 6 updates history from Postgres95 era. I guess people may forget to update README file if description is separately located from the implementation. > I think you should avoid the call to GetExtensibleNodeMethods() in the > case where extnodename is NULL. On the other hand, I think that if > extnodename is non-NULL, all four methods should be required, so that > you don't have to check if (methods && methods->nodeRead) but just if > (extnodename) { methods = GetExtensibleNodeMethods(extnodename); > methods->nodeRead( ... ); }. That seems like it would be a bit > tidier. > OK, I'll fix up. No need to have 'missing_ok' argument here. Thanks, -- NEC Business Creation Division / PG-Strom Project KaiGai Kohei <kaigai@ak.jp.nec.com>
On Wed, Feb 3, 2016 at 8:00 PM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote: >> Well, looking at this a bit more, it seems like the documentation >> you've written here is really misplaced. The patch is introducing a >> new facility that applies to both CustomScan and ForeignScan, but the >> documentation is only to do with CustomScan. I think we need a whole >> new chapter on extensible nodes, or something. I'm actually not >> really keen on the fact that we keep adding SGML documentation for >> this stuff; it seems like it belongs in a README in the source tree. >> We don't explain nodes in general, but now we're going to have to try >> to explain extensible nodes. How's that going to work? >> > The detail of these callbacks are not for end-users, administrators and > so on except for core/extension developers. So, I loves idea not to have > such a detailed description in SGML. > How about an idea to have more detailed source code comments close to > the definition of ExtensibleNodeMethods? > I haven't seen the src/backend/nodes/README yet, and it has only 6 updates > history from Postgres95 era. I guess people may forget to update README > file if description is separately located from the implementation. Hmm, that might work, although that file is so old that it may be difficult to add to. Another idea is: maybe we could have a header file for the extensible node stuff and just give it a really long header comment. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
> -----Original Message----- > From: pgsql-hackers-owner@postgresql.org > [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Robert Haas > Sent: Thursday, February 04, 2016 11:39 AM > To: Kaigai Kouhei(海外 浩平) > Cc: Andres Freund; Amit Kapila; pgsql-hackers > Subject: Re: CustomScan in a larger structure (RE: [HACKERS] CustomScan support > on readfuncs.c) > > On Wed, Feb 3, 2016 at 8:00 PM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote: > >> Well, looking at this a bit more, it seems like the documentation > >> you've written here is really misplaced. The patch is introducing a > >> new facility that applies to both CustomScan and ForeignScan, but the > >> documentation is only to do with CustomScan. I think we need a whole > >> new chapter on extensible nodes, or something. I'm actually not > >> really keen on the fact that we keep adding SGML documentation for > >> this stuff; it seems like it belongs in a README in the source tree. > >> We don't explain nodes in general, but now we're going to have to try > >> to explain extensible nodes. How's that going to work? > >> > > The detail of these callbacks are not for end-users, administrators and > > so on except for core/extension developers. So, I loves idea not to have > > such a detailed description in SGML. > > How about an idea to have more detailed source code comments close to > > the definition of ExtensibleNodeMethods? > > I haven't seen the src/backend/nodes/README yet, and it has only 6 updates > > history from Postgres95 era. I guess people may forget to update README > > file if description is separately located from the implementation. > > Hmm, that might work, although that file is so old that it may be > difficult to add to. Another idea is: maybe we could have a header > file for the extensible node stuff and just give it a really long > header comment. > At this moment, I tried to write up description at nodes/nodes.h. The amount of description is about 100lines. It is on a borderline whether we split off this chunk into another header file, in my sense. On the other hands, I noticed that we cannot omit checks for individual callbacks on CustomXXXX node type, ExtensibleNodeMethods is embedded in the CustomXXXXMethods structure, thus we may have CustomXXXX node with no extensible feature. This manner is beneficial because extension does not need to register the library and symbol name for serialization. So, CustomScan related code still checks existence of individual callbacks. Thanks, -- NEC Business Creation Division / PG-Strom Project KaiGai Kohei <kaigai@ak.jp.nec.com> > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
On Wed, Feb 3, 2016 at 11:57 PM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote: > At this moment, I tried to write up description at nodes/nodes.h. > The amount of description is about 100lines. It is on a borderline > whether we split off this chunk into another header file, in my sense. > > > On the other hands, I noticed that we cannot omit checks for individual > callbacks on CustomXXXX node type, ExtensibleNodeMethods is embedded in > the CustomXXXXMethods structure, thus we may have CustomXXXX node with > no extensible feature. > This manner is beneficial because extension does not need to register > the library and symbol name for serialization. So, CustomScan related > code still checks existence of individual callbacks. I was looking over this patch yesterday, and something was bugging me about it, but I couldn't quite put my finger on what it was. But now I think I know. I think of an extensible node type facility as something that ought to be defined to allow a user to create new types of nodes. But this is not that. What this does is allows you to have a CustomScan or ForeignScan node - that is, the existing node type - which is actually larger than a normal node of that type and has some extra data that is part of it. I'm having a really hard time being comfortable with that concept. Somehow, it seems like the node type should determine the size of the node. I can stretch my brain to the point of being able to say, well, maybe if the node tag is T_ExtensibleNode, then you can look at char *extnodename to figure out what type of node it is really, and then from there get the size. But what this does is: every time you see a T_CustomScan or T_ForeignScan node, it might not really be that kind of node but something else else, and tomorrow there might be another half-dozen node types with a similar property. And every one of those node types will have char *extnodename in a different place in the structure, so a hypothetical piece of code that wanted to find the extension methods for a node, or the size of a node, would need a switch that knows about all of those node types. It feels very awkward. So I have a slightly different proposal. Let's forget about letting T_CustomScan or T_ForeignScan or any other built-in node type vary in size. Instead, let's add T_ExtensibleNode which acts as a completely user-defined node. It has read/out/copy/equalfuncs support along the lines of what this patch implements, and that's it. It's not a scan or a path or anything like that: it's just an opaque data container that the system can input, output, copy, and test for equality, and nothing else. Isn't that useless? Not at all. If you're creating an FDW or custom scan provider and want to store some extra data, you can create a new type of extensible node and stick it in the fdw_private or custom_private field! The data won't be part of the CustomScan or ForeignScan structure itself, as in this patch, but who cares? The only objection I can see is that you still need several pointer deferences to get to the data since fdw_private is a List, but if that's actually a real performance problem we could probably fix it by just changing fdw_private to a Node instead. You'd still need one pointer dereference, but that doesn't seem too bad. Thoughts? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company