* Look up (and possibly load) a parallel worker entry point function. * * For functions contained in the core code, we use library name "postgres" * and consult the InternalParallelWorkers array. External functions are * looked up, and loaded if necessary, using load_external_function(). * * The point of this is to pass function names as strings across process * boundaries. We can't pass
| 1626 | * but that raises portability issues that are not worth addressing now. |
| 1627 | */ |
| 1628 | static parallel_worker_main_type |
| 1629 | LookupParallelWorkerFunction(const char *libraryname, const char *funcname) |
| 1630 | { |
| 1631 | /* |
| 1632 | * If the function is to be loaded from postgres itself, search the |
| 1633 | * InternalParallelWorkers array. |
| 1634 | */ |
| 1635 | if (strcmp(libraryname, "postgres") == 0) |
| 1636 | { |
| 1637 | int i; |
| 1638 | |
| 1639 | for (i = 0; i < lengthof(InternalParallelWorkers); i++) |
| 1640 | { |
| 1641 | if (strcmp(InternalParallelWorkers[i].fn_name, funcname) == 0) |
| 1642 | return InternalParallelWorkers[i].fn_addr; |
| 1643 | } |
| 1644 | |
| 1645 | /* We can only reach this by programming error. */ |
| 1646 | elog(ERROR, "internal function \"%s\" not found", funcname); |
| 1647 | } |
| 1648 | |
| 1649 | /* Otherwise load from external library. */ |
| 1650 | return (parallel_worker_main_type) |
| 1651 | load_external_function(libraryname, funcname, true, NULL); |
| 1652 | } |
| 1653 | |
| 1654 | void |
| 1655 | InitGpParallelDSMHash(void) |
no test coverage detected