-
Notifications
You must be signed in to change notification settings - Fork 3
/
pg_comment_stats.h
86 lines (72 loc) · 2.32 KB
/
pg_comment_stats.h
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
76
77
78
79
80
81
82
83
84
85
86
#ifndef PGSK_AGGREGATED_STATS
#define PGSK_AGGREGATED_STATS
#include "postgres.h"
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifndef HAVE_GETRUSAGE
#define HAVE_GETRUSAGE
#endif
#include "funcapi.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "utils/jsonb.h"
#include "executor/execdesc.h"
#include "nodes/execnodes.h"
#include "storage/ipc.h"
#include "utils/builtins.h"
#include "catalog/pg_type.h"
#include "pg_stat_kcache/pg_stat_kcache.h"
#include "pg_time_buffer/pg_time_buffer.h"
#include "pg_comment_stats_constants.h"
typedef struct pgcsStringFromId {
int id;
char string[max_parameter_length];
int counter;
slock_t mutex; /* protects the counter only */
} pgcsStringFromId;
typedef struct pgcsIdFromString {
char string[max_parameter_length];
int id;
} pgcsIdFromString;
typedef struct pgcsCompositeKey {
int keyValues[max_parameters_count];
} pgcsCompositeKey;
typedef struct pgcsBucketItem {
pgcsCompositeKey compositeKey;
Oid database;
Oid user;
} pgcsBucketItem;
Datum get_jsonb_datum_from_key(pgcsCompositeKey *);
typedef struct global_info {
char commentKeys[max_parameters_count][max_parameter_length];
char excluded_keys[max_parameters_count][max_parameter_length];
int excluded_keys_count;
int keys_count;
int currents_strings_count;
int items_count;
int bucket_duration;
int strings_overflow_by;
slock_t overflow_mutex; /* protects strings_overflow_by counter */
bool keys_overflow;
bool out_of_shared_memory;
LWLock lock;
bool max_strings_count_achieved;
pgcsBucketItem buckets[FLEXIBLE_ARRAY_MEMBER];
} GlobalInfo;
void pgcs_register_bgworker(void);
extern void pgtb_init(const char*,
void (*add)(void*, void*),
void (*on_delete)(void*, void*),
int,
uint64_t,
uint64_t,
uint64_t
);
extern bool pgtb_put(const char*, void*, void*);
extern void pgtb_tick(const char*);
extern void pgtb_get_stats(const char*, void*, int*, TimestampTz*, TimestampTz*);
extern void pgtb_get_stats_time_interval(const char*, TimestampTz*, TimestampTz*, void*, int*);
extern int pgtb_get_items_count(uint64_t, uint64_t, uint64_t);
bool pgcs_enabled;
#endif