-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* This file and its contents are licensed under the Apache License 2.0. | ||
* Please see the included NOTICE for copyright information and | ||
* LICENSE-APACHE for a copy of the license. | ||
*/ | ||
#include <postgres.h> | ||
|
||
#include "planner/planner.h" | ||
#include "timescaledb.h" | ||
#include <c.h> | ||
|
||
/* | ||
* This file contains function and support for dealing with the ABI. See the | ||
* header file for more information. | ||
*/ | ||
|
||
/* Structure to go from old definition in mem_guard to the TimescaleDB plugin | ||
structure defined in the header file. */ | ||
static TimescaleDBPlugin plugin_callbacks = { | ||
.magic = PG_MODULE_MAGIC_DATA, | ||
.pg_version = PG_VERSION_NUM, | ||
.ts_version = TS_VERSION_NUM, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This file and its contents are licensed under the Apache License 2.0. | ||
* Please see the included NOTICE for copyright information and | ||
* LICENSE-APACHE for a copy of the license. | ||
*/ | ||
|
||
/* | ||
* File with definitions intended for plugins that want to interact with TimescaleDB. | ||
* | ||
* WARNING! Do not add variables, functions, macros, or other stuff that is | ||
* not intended for an external user, e.g., a separate plugin. | ||
*/ | ||
#pragma once | ||
|
||
#include <postgres.h> | ||
#include <fmgr.h> | ||
|
||
/* | ||
* Plugin structure with callbacks. | ||
* | ||
* Other plugins can use this to get information about the running version of | ||
* TimescaleDB as well as callbacks on particular events. | ||
* | ||
* IMPORTANT: If you extend this structure, take care to not remove any fields | ||
* and add new fields last. If you do not do this, you might break plugins | ||
* that are using the wrong version and read some field that you moved or | ||
* deleted. | ||
*/ | ||
typedef struct TimescaleDBPlugin | ||
{ | ||
size_t size; /* Size of this structure */ | ||
Pg_magic_struct magic; /* Pointer to PostgreSQL magic */ | ||
int pg_version; /* PostgreSQL version as a number */ | ||
int ts_version; /* TimescaleDB version as a number */ | ||
|
||
/* | ||
* Plugins can fill this in and get callbacks on particular events. | ||
*/ | ||
void (*bgw_job_starting)(Oid db_id, int32 job_id, Oid user_oid); | ||
void (*bgw_job_exiting)(Oid db_id, int job_id, int result); | ||
} TimescaleDBPlugin; | ||
|
||
#define TIMESCALEDB_PLUGIN_NAME "TimescaleDBPlugin" | ||
|
||
/* | ||
* Convenience macro for plugin callback. | ||
* | ||
* The expands to a check if: | ||
* | ||
* - The plugin pointer is non-zero | ||
* | ||
* - The offset of the function pointer is inside the structure | ||
* | ||
* - The function pointer is non-zero | ||
* | ||
* If either is false, this is effectively a no-op. | ||
*/ | ||
#define TS_PLUGIN_CALLBACK(PTR, FUNC, ...) \ | ||
do \ | ||
{ \ | ||
if ((PTR) && offsetof(TimescaleDBPlugin, FUNC) < (PTR)->size && (PTR)->FUNC) \ | ||
(*(PTR)->FUNC)(__VA_ARGS__); \ | ||
} while (0) |