PostgreSQL Source Code git master
Loading...
Searching...
No Matches
test_checksums.c
Go to the documentation of this file.
1/*--------------------------------------------------------------------------
2 *
3 * test_checksums.c
4 * Test data checksums
5 *
6 * Copyright (c) 2026, PostgreSQL Global Development Group
7 *
8 * IDENTIFICATION
9 * src/test/modules/test_checksums/test_checksums.c
10 *
11 * -------------------------------------------------------------------------
12 */
13#include "postgres.h"
14
15#include "funcapi.h"
16#include "miscadmin.h"
18#include "storage/latch.h"
20#include "utils/wait_event.h"
21
23
24extern PGDLLEXPORT void dc_delay_barrier(const char *name, const void *private_data, void *arg);
25extern PGDLLEXPORT void dc_modify_db_result(const char *name, const void *private_data, void *arg);
26extern PGDLLEXPORT void dc_fake_temptable(const char *name, const void *private_data, void *arg);
27
28/*
29 * Test for delaying emission of procsignalbarriers.
30 */
31void
32dc_delay_barrier(const char *name, const void *private_data, void *arg)
33{
34 (void) name;
35 (void) private_data;
36
37 (void) WaitLatch(MyLatch,
39 (3 * 1000),
40 WAIT_EVENT_PG_SLEEP);
41}
42
46{
47#ifdef USE_INJECTION_POINTS
48 bool attach = PG_GETARG_BOOL(0);
49
50 if (attach)
51 InjectionPointAttach("datachecksums-enable-checksums-delay",
52 "test_checksums",
53 "dc_delay_barrier",
54 NULL,
55 0);
56 else
57 InjectionPointDetach("datachecksums-enable-checksums-delay");
58#else
59 elog(ERROR,
60 "test is not working as intended when injection points are disabled");
61#endif
63}
64
68{
69#ifdef USE_INJECTION_POINTS
70 bool attach = PG_GETARG_BOOL(0);
71
72 if (attach)
73 InjectionPointAttach("datachecksumsworker-launcher-delay",
74 "test_checksums",
75 "dc_delay_barrier",
76 NULL,
77 0);
78 else
79 InjectionPointDetach("datachecksumsworker-launcher-delay");
80#else
81 elog(ERROR,
82 "test is not working as intended when injection points are disabled");
83#endif
85}
86
90{
91#ifdef USE_INJECTION_POINTS
92 bool attach = PG_GETARG_BOOL(0);
93
94 if (attach)
95 InjectionPointAttach("datachecksumsworker-startup-delay",
96 "test_checksums",
97 "dc_delay_barrier",
98 NULL,
99 0);
100 else
101 InjectionPointDetach("datachecksumsworker-startup-delay");
102#else
103 elog(ERROR,
104 "test is not working as intended when injection points are disabled");
105#endif
107}
#define PGDLLEXPORT
Definition c.h:1436
Datum arg
Definition elog.c:1322
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define PG_RETURN_VOID()
Definition fmgr.h:350
#define PG_FUNCTION_INFO_V1(funcname)
Definition fmgr.h:417
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
struct Latch * MyLatch
Definition globals.c:65
bool InjectionPointDetach(const char *name)
void InjectionPointAttach(const char *name, const char *library, const char *function, const void *private_data, int private_data_size)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition latch.c:172
uint64_t Datum
Definition postgres.h:70
PGDLLEXPORT void dc_fake_temptable(const char *name, const void *private_data, void *arg)
Datum dcw_inject_delay_barrier(PG_FUNCTION_ARGS)
Datum dcw_inject_startup_delay(PG_FUNCTION_ARGS)
PG_MODULE_MAGIC
Datum dcw_inject_launcher_delay(PG_FUNCTION_ARGS)
PGDLLEXPORT void dc_delay_barrier(const char *name, const void *private_data, void *arg)
PGDLLEXPORT void dc_modify_db_result(const char *name, const void *private_data, void *arg)
const char * name
#define WL_TIMEOUT
#define WL_EXIT_ON_PM_DEATH
#define WL_LATCH_SET