Minimal infrastructure for per-backend citus initialization.

pull/1461/head
Andres Freund 2017-06-11 18:22:29 -07:00
parent 1691f780fd
commit 3483bb99eb
3 changed files with 40 additions and 1 deletions

View File

@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* shared_library_init.c
* Initialize Citus extension
* Functionality related to the initialization of the Citus extension.
*
* Copyright (c) 2012-2016, Citus Data, Inc.
*-------------------------------------------------------------------------
@ -36,6 +36,7 @@
#include "distributed/pg_dist_partition.h"
#include "distributed/placement_connection.h"
#include "distributed/remote_commands.h"
#include "distributed/shared_library_init.h"
#include "distributed/task_tracker.h"
#include "distributed/transaction_management.h"
#include "distributed/worker_manager.h"
@ -177,6 +178,20 @@ _PG_init(void)
}
/*
* StartupCitusBackend initializes per-backend infrastructure, and is called
* the first time citus is used in a database.
*
* NB: All code here has to be able to cope with this routine being called
* multiple times in the same backend. This will e.g. happen when the
* extension is created or upgraded.
*/
void
StartupCitusBackend(void)
{
}
/*
* CreateRequiredDirectories - Create directories required for Citus to
* function.

View File

@ -35,6 +35,7 @@
#include "distributed/pg_dist_partition.h"
#include "distributed/pg_dist_shard.h"
#include "distributed/pg_dist_shard_placement.h"
#include "distributed/shared_library_init.h"
#include "distributed/shardinterval_utils.h"
#include "distributed/worker_manager.h"
#include "distributed/worker_protocol.h"
@ -1118,6 +1119,13 @@ CitusHasBeenLoaded(void)
{
extensionScriptExecuted = false;
}
/*
* Whenever the extension exists, even when currently creating it,
* we need the infrastructure to run citus in this database to be
* ready.
*/
StartupCitusBackend();
}
/* we disable extension features during pg_upgrade */

View File

@ -0,0 +1,16 @@
/*-------------------------------------------------------------------------
*
* shared_library_init.h
* Functionality related to the initialization of the Citus extension.
*
* Copyright (c) 2017, Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/
#ifndef SHARED_LIBRARY_INIT_H
#define SHARED_LIBRARY_INIT_H
extern void StartupCitusBackend(void);
#endif /* SHARED_LIBRARY_INIT_H */