-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpercona_pg_telemetry.c
More file actions
75 lines (61 loc) · 1.68 KB
/
percona_pg_telemetry.c
File metadata and controls
75 lines (61 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*-------------------------------------------------------------------------
*
* percona_pg_telemetry.c
* Collects telemetry information for the database cluster.
*
* IDENTIFICATION
* contrib/percona_pg_telemetry/percona_pg_telemetry.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
/* General defines */
#define PT_BUILD_VERSION "1.2"
/* Init and exported functions */
void _PG_init(void);
PG_FUNCTION_INFO_V1(percona_pg_telemetry_status);
PG_FUNCTION_INFO_V1(percona_pg_telemetry_version);
/*
* Initializing everything here
*/
void
_PG_init(void)
{
if (!process_shared_preload_libraries_in_progress)
return;
elog(NOTICE, "percona_pg_telemetry has been deprecated");
}
/*
* Select the status of percona_pg_telemetry.
*/
Datum
percona_pg_telemetry_status(PG_FUNCTION_ARGS)
{
#define PT_STATUS_COLUMN_COUNT 2
TupleDesc tupdesc;
Datum values[PT_STATUS_COLUMN_COUNT];
bool nulls[PT_STATUS_COLUMN_COUNT] = {false};
HeapTuple tup;
Datum result;
tupdesc = CreateTemplateTupleDesc(PT_STATUS_COLUMN_COUNT);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "latest_output_filename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "pt_enabled", BOOLOID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc);
nulls[0] = true;
values[1] = BoolGetDatum(false);
tup = heap_form_tuple(tupdesc, values, nulls);
result = HeapTupleGetDatum(tup);
PG_RETURN_DATUM(result);
}
/*
* Select the version of percona_pg_telemetry.
*/
Datum
percona_pg_telemetry_version(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P(cstring_to_text(PT_BUILD_VERSION));
}