PostgreSQL Source Code: src/backend/utils/adt/mcxtfuncs.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
17
25
26
27
28
29
30#define MEMORY_CONTEXT_IDENT_DISPLAY_SIZE 1024
31
32
33
34
35
36
38{
42
43
44
45
46
49{
50 Datum *datum_array;
51 int length;
53
56
59
61
63}
64
65
66
67
68
69static void
72 HTAB *context_id_lookup)
73{
74#define PG_GET_BACKEND_MEMORY_CONTEXTS_COLS 10
75
80 const char *name;
81 const char *ident;
82 const char *type;
83
85
86
87
88
89
91 {
93 bool found;
94
96
97 if (!found)
98 elog(ERROR, "hash table corrupted");
100 }
101
102
103 memset(&stat, 0, sizeof(stat));
104 (*context->methods->stats) (context, NULL, NULL, &stat, true);
105
107 memset(nulls, 0, sizeof(nulls));
108
111
112
113
114
115
116 if (ident && strcmp(name, "dynahash") == 0)
117 {
120 }
121
124 else
125 nulls[0] = true;
126
128 {
129 int idlen = strlen(ident);
131
132
133
134
135
138
139 memcpy(clipped_ident, ident, idlen);
140 clipped_ident[idlen] = '\0';
142 }
143 else
144 nulls[1] = true;
145
146 switch (context->type)
147 {
148 case T_AllocSetContext:
149 type = "AllocSet";
150 break;
151 case T_GenerationContext:
152 type = "Generation";
153 break;
154 case T_SlabContext:
155 type = "Slab";
156 break;
157 case T_BumpContext:
158 type = "Bump";
159 break;
160 default:
161 type = "???";
162 break;
163 }
164
173
176}
177
178
179
180
181
184{
186 int context_id;
187 List *contexts;
189 HTAB *context_id_lookup;
190
194
195 context_id_lookup = hash_create("pg_get_backend_memory_contexts",
196 256,
199
201
202
203
204
205
206
207
208
209
210
211
213
214
215 context_id = 1;
216
218 {
220 bool found;
221
222
223
224
225
226
231
235 context_id_lookup);
236
237
238
239
240
242 contexts = lappend(contexts, c);
243 }
244
246
247 return (Datum) 0;
248}
249
250
251
252
253
254
255
256
257
258
259
260
261
262
265{
269
270
271
272
274 if (proc == NULL)
276
277
278
279
280
281
282
283
284
285
286 if (proc == NULL)
287 {
288
289
290
291
293 (errmsg("PID %d is not a PostgreSQL server process", pid)));
295 }
296
299 {
300
302 (errmsg("could not send signal to process %d: %m", pid)));
304 }
305
307}
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void hash_destroy(HTAB *hashp)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum Int64GetDatum(int64 X)
#define PG_GETARG_INT32(n)
#define PG_RETURN_BOOL(x)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
Assert(PointerIsAligned(start, uint64))
List * lappend(List *list, void *datum)
List * lcons_int(int datum, List *list)
void list_free(List *list)
int pg_mbcliplen(const char *mbstr, int len, int limit)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
struct MemoryContextId MemoryContextId
static Datum int_list_to_array(const List *list)
static void PutMemoryContextsStatsTupleStore(Tuplestorestate *tupstore, TupleDesc tupdesc, MemoryContext context, HTAB *context_id_lookup)
Datum pg_log_backend_memory_contexts(PG_FUNCTION_ARGS)
#define PG_GET_BACKEND_MEMORY_CONTEXTS_COLS
#define MEMORY_CONTEXT_IDENT_DISPLAY_SIZE
Datum pg_get_backend_memory_contexts(PG_FUNCTION_ARGS)
#define MemoryContextIsValid(context)
static int list_length(const List *l)
#define foreach_current_index(var_or_cell)
#define foreach_ptr(type, var, lst)
#define foreach_int(var, lst)
static Datum PointerGetDatum(const void *X)
static Datum Int32GetDatum(int32 X)
#define GetNumberFromPGProc(proc)
PGPROC * BackendPidGetProc(int pid)
#define INVALID_PROC_NUMBER
int SendProcSignal(pid_t pid, ProcSignalReason reason, ProcNumber procNumber)
@ PROCSIG_LOG_MEMORY_CONTEXT
PGPROC * AuxiliaryPidGetProc(int pid)
const MemoryContextMethods * methods
void(* stats)(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)
Tuplestorestate * setResult
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)