CustomScan in a larger structure (RE: CustomScan support on readfuncs.c) - Mailing list pgsql-hackers
From | Kouhei Kaigai |
---|---|
Subject | CustomScan in a larger structure (RE: CustomScan support on readfuncs.c) |
Date | |
Msg-id | 9A28C8860F777E439AA12E8AEA7694F80116DD22@BPXM15GP.gisp.nec.co.jp Whole thread Raw |
Responses |
Re: CustomScan in a larger structure (RE: CustomScan
support on readfuncs.c)
|
List | pgsql-hackers |
It is a relevant topic of readfuncs support for custom-scan. Unlike CustomPath and CustomScanState, we don't allow custom-scan provider to define own and larger structure that embeds CustomScan at head of the structure, to support copyObject(). Thus, custom-scan provider needs to have own logic to pack and unpack private fields, like: https://github.com/pg-strom/devel/blob/master/src/gpujoin.c#L112 At present, only create_customscan_plan() and _copyCustomScan() can produce CustomScan node. The create_customscan_plan() invokes PlanCustomPath callback, thus, CSP can return a pointer of CustomScan field within a larger structure. So, we don't adjust this interface. On the other hands, _copyCustomScan() allocates a new node using makeNode(CustomScan), thus, here is no space for the larger structure if CSP wants to use to keep private values without packing and unpacking. Only CSP knows exact size of the larger structure, so all we can do is ask CSP to allocate a new node and copy its private fields. This patch newly adds NodeCopyCustomScan callback to support copyObject. Also, v9.6 will support nodeToString/stringToNode on plan nodes. So, we need to re-define the role of TextOutCustomScan callback that is also defined at v9.5. If CSP extends the CustomScan to save private values on the extra area, only CSP knows what values and which data types are stored, thus, all we can do is ask CSP to serialize and deserialize its private fields without inconsistency. Even though TextOutCustomScan callback shall be once ripped out to support readfuncs.c, a pair of TextOut and TextRead callback will re-define its responsibility again; when CSP defines a larger structure that embeds CustomScan, a pair of these callbacks are used to serialize/deserialize the entire custom defined objects. The attached patches are for v9.5 and v9.6. The v9.6 patch assumes the patch for readfuncs support is already applied. The v9.5 patch assumes the latest master. Thanks, -- NEC Business Creation Division / PG-Strom Project KaiGai Kohei <kaigai@ak.jp.nec.com> > -----Original Message----- > From: pgsql-hackers-owner@postgresql.org > [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Kouhei Kaigai > Sent: Tuesday, November 10, 2015 11:47 AM > To: Robert Haas > Cc: Amit Kapila; Andres Freund; pgsql-hackers > Subject: Re: [HACKERS] CustomScan support on readfuncs.c > > > On Sat, Nov 7, 2015 at 6:38 AM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote: > > > Are you suggesting to pass the object name on software build time? > > > > Yes. That's what test_shm_mq and worker_spi already do: > > > > sprintf(worker.bgw_library_name, "test_shm_mq"); > > > OK, I ripped out the portion around dfmgr.c. > > > > If so, it may load incorrect libraries when DBA renamed its filename. > > > At least, PostgreSQL cannot prevent DBA to rename library filenames > > > even if they try to deploy "pg_strom.so", "pg_strom.20151106.so" and > > > "pg_strom.20151030_bug.so" on same directory. > > > > I agree. But that's not a new problem that needs to be solved by this > > patch. It already exists - see above. > > > It still may be a potential problem, even though a corner case. > I'll try to implement an internal API to know "what is my name". > > The attached main patch (custom-scan-on-readfuncs.v3.patch) once > removes TextOutCustomScan, thus all the serialized tokens become > known to the core backend, and add _readCustomScan() at readfuncs.c. > It deserializes CustomScan nodes from cstring tokens, especially, > reloads the pointer of CustomScanMethods tables using a pair of > library name and symbol name. > Thus, it also requires custom scan providers to keep the methods > table visible from external objects. > > Thanks, > -- > NEC Business Creation Division / PG-Strom Project > KaiGai Kohei <kaigai@ak.jp.nec.com>
Attachment
pgsql-hackers by date: