File: logtofile_execution_hook.c

package info (click to toggle)
pgauditlogtofile 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: ansic: 1,568; makefile: 26; sql: 12; sh: 7
file content (76 lines) | stat: -rw-r--r-- 2,186 bytes parent folder | download
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
#include "logtofile_execution_hook.h"

#include "logtofile_execution_memory.h"
#include "logtofile_execution_time.h"
#include "logtofile_vars.h"

#include <executor/executor.h>

void PgAuditLogToFile_ExecutorStart_Hook(QueryDesc *queryDesc, int eflags)
{
  if (pgaudit_ltf_prev_ExecutorStart)
    pgaudit_ltf_prev_ExecutorStart(queryDesc, eflags);
  else
    standard_ExecutorStart(queryDesc, eflags);

  if (guc_pgaudit_ltf_log_execution_time)
    PgAuditLogToFile_ExecutorStart_Time(queryDesc, eflags);
  if (guc_pgaudit_ltf_log_execution_memory)
    PgAuditLogToFile_ExecutorStart_Memory(queryDesc, eflags);
}

void PgAuditLogToFile_ExecutorEnd_Hook(QueryDesc *queryDesc)
{
  if (guc_pgaudit_ltf_log_execution_time)
    PgAuditLogToFile_ExecutorEnd_Time(queryDesc);
  if (guc_pgaudit_ltf_log_execution_memory)
    PgAuditLogToFile_ExecutorEnd_Memory(queryDesc);

  if (pgaudit_ltf_prev_ExecutorEnd)
    pgaudit_ltf_prev_ExecutorEnd(queryDesc);
  else
    standard_ExecutorEnd(queryDesc);
}

#if (PG_VERSION_NUM >= 180000)
void PgAuditLogToFile_ExecutorRun_Hook(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
#else
void PgAuditLogToFile_ExecutorRun_Hook(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
#endif
{
  if (guc_pgaudit_ltf_log_execution_memory)
  {
#if (PG_VERSION_NUM >= 180000)
    PgAuditLogToFile_ExecutorRun_Memory(queryDesc, direction, count);
#else
    PgAuditLogToFile_ExecutorRun_Memory(queryDesc, direction, count, execute_once);
#endif

  }

  if (pgaudit_ltf_prev_ExecutorRun)
  {
#if (PG_VERSION_NUM >= 180000)
    pgaudit_ltf_prev_ExecutorRun(queryDesc, direction, count);
#else
    pgaudit_ltf_prev_ExecutorRun(queryDesc, direction, count, execute_once);
#endif
  }
  else
  {
    #if (PG_VERSION_NUM >= 180000)
    standard_ExecutorRun(queryDesc, direction, count);
    #else
    standard_ExecutorRun(queryDesc, direction, count, execute_once);
    #endif
  }

  if (guc_pgaudit_ltf_log_execution_memory)
  {
#if (PG_VERSION_NUM >= 180000)
    PgAuditLogToFile_ExecutorRun_Memory(queryDesc, direction, count);
#else
    PgAuditLogToFile_ExecutorRun_Memory(queryDesc, direction, count, execute_once);
#endif
  }
}