1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Rework custom scans to work more like the new extensible node stuff.

Per discussion, the new extensible node framework is thought to be
better designed than the custom path/scan/scanstate stuff we added
in PostgreSQL 9.5.  Rework the latter to be more like the former.

This is not backward-compatible, but we generally don't promise that
for C APIs, and there probably aren't many people using this yet
anyway.

KaiGai Kohei, reviewed by Petr Jelinek and me.  Some further
cosmetic changes by me.
This commit is contained in:
Robert Haas
2016-03-29 11:00:18 -04:00
parent 534da37927
commit f9143d102f
10 changed files with 184 additions and 117 deletions

View File

@ -1827,8 +1827,7 @@ static CustomScan *
_readCustomScan(void)
{
READ_LOCALS(CustomScan);
char *library_name;
char *symbol_name;
char *custom_name;
const CustomScanMethods *methods;
ReadCommonScan(&local_node->scan);
@ -1840,19 +1839,11 @@ _readCustomScan(void)
READ_NODE_FIELD(custom_scan_tlist);
READ_BITMAPSET_FIELD(custom_relids);
/*
* Reconstruction of methods using library and symbol name
*/
/* Lookup CustomScanMethods by CustomName */
token = pg_strtok(&length); /* skip methods: */
token = pg_strtok(&length); /* LibraryName */
library_name = nullable_string(token, length);
token = pg_strtok(&length); /* SymbolName */
symbol_name = nullable_string(token, length);
methods = (const CustomScanMethods *)
load_external_function(library_name, symbol_name, true, NULL);
Assert(strcmp(methods->LibraryName, library_name) == 0 &&
strcmp(methods->SymbolName, symbol_name) == 0);
token = pg_strtok(&length); /* CustomName */
custom_name = nullable_string(token, length);
methods = GetCustomScanMethods(custom_name, false);
local_node->methods = methods;
READ_DONE();