MCPcopy Create free account
hub / github.com/activeloopai/deeplake / _PG_init

Function _PG_init

cpp/deeplake_pg/extension_init.cpp:1568–1626  ·  view source on GitHub ↗

This will be called when when extension is loaded

Source from the content-addressed store, hash-verified

1566
1567/// This will be called when when extension is loaded
1568PGDLLEXPORT void _PG_init()
1569{
1570 if (!process_shared_preload_libraries_in_progress) {
1571 ereport(ERROR,
1572 (errmsg("pg_deeplake should be loaded with shared_preload_libraries"),
1573 errhint("Add pg_deeplake to shared_preload_libraries.")));
1574 }
1575
1576 // Set up shared memory request hook (must be first)
1577 prev_shmem_request_hook = shmem_request_hook;
1578 shmem_request_hook = deeplake_shmem_request;
1579
1580 // Set up shared memory startup hook
1581 prev_shmem_startup_hook = shmem_startup_hook;
1582 shmem_startup_hook = deeplake_shmem_startup;
1583
1584 register_deeplake_executor();
1585
1586 prev_executor_start = ExecutorStart_hook;
1587 ExecutorStart_hook = executor_start;
1588
1589 prev_executor_run = ExecutorRun_hook;
1590 ExecutorRun_hook = executor_run;
1591
1592 prev_executor_end = ExecutorEnd_hook;
1593 ExecutorEnd_hook = executor_end;
1594
1595 prev_process_utility_hook = ProcessUtility_hook;
1596 ProcessUtility_hook = process_utility;
1597
1598 prev_planner_hook = planner_hook;
1599 planner_hook = deeplake_planner;
1600
1601 prev_set_rel_pathlist_hook = set_rel_pathlist_hook;
1602 set_rel_pathlist_hook = set_rel_pathlist;
1603
1604 // Initialize GUC parameters first (needed for sync worker config)
1605 ::initialize_guc_parameters();
1606
1607 // Register background sync worker for stateless multi-instance support
1608 BackgroundWorker worker;
1609 memset(&worker, 0, sizeof(worker));
1610
1611 snprintf(worker.bgw_name, BGW_MAXLEN, "pg_deeplake sync worker");
1612 snprintf(worker.bgw_type, BGW_MAXLEN, "pg_deeplake sync worker");
1613 snprintf(worker.bgw_library_name, BGW_MAXLEN, "pg_deeplake");
1614 snprintf(worker.bgw_function_name, BGW_MAXLEN, "deeplake_sync_worker_main");
1615
1616 worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION;
1617 worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
1618 worker.bgw_restart_time = 5; // Restart after 5 seconds if it crashes
1619 worker.bgw_notify_pid = 0;
1620 worker.bgw_main_arg = (Datum)0;
1621
1622 RegisterBackgroundWorker(&worker);
1623
1624 pg::install_signal_handlers();
1625 pg::deeplake_table_am_routine::initialize();

Callers

nothing calls this directly

Calls 3

install_signal_handlersFunction · 0.85

Tested by

no test coverage detected