PostgreSQL Source Code: src/test/modules/injection_points/injection_points.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

19

35

37

38

39#define INJ_MAX_WAIT 8

40#define INJ_NAME_MAXLEN 64

41

42

43

44

45

46

47

48

49

50

52{

56

58{

59

61

62

65

66

67

68

69

71

72

73

74

75

76

77

79{

80

82

83

85

86

88

89

92

93

95

97 const void *private_data,

98 void *arg);

100 const void *private_data,

101 void *arg);

103 const void *private_data,

104 void *arg);

105

106

108

109

110

111

112

113

114

115

117

118

121

122

123

124

125

126static void

128{

130

132 memset(state->wait_counts, 0, sizeof(state->wait_counts));

133 memset(state->name, 0, sizeof(state->name));

135}

136

137

138static void

140{

142

145

148}

149

150static void

152{

153 bool found;

154

157

158

160

163 &found);

164

165 if (!found)

166 {

167

168

169

170

172 }

173

175}

176

177

178

179

180static void

182{

183 bool found;

184

186 return;

187

191 &found);

192}

193

194

195

196

197

198

199

200static bool

202{

203 bool result = true;

204

205 switch (condition->type)

206 {

209 result = false;

210 break;

212 break;

213 }

214

215 return result;

216}

217

218

219

220

221

222static void

224{

226

227

229 return;

230

231

233 {

235

237

238

240 }

241}

242

243

244void

246{

248 char *argstr = (char *) arg;

249

251 return;

252

254

255 if (argstr)

256 elog(ERROR, "error triggered for injection point %s (%s)",

257 name, argstr);

258 else

259 elog(ERROR, "error triggered for injection point %s", name);

260}

261

262void

264{

266 char *argstr = (char *) arg;

267

269 return;

270

272

273 if (argstr)

274 elog(NOTICE, "notice triggered for injection point %s (%s)",

275 name, argstr);

276 else

277 elog(NOTICE, "notice triggered for injection point %s", name);

278}

279

280

281void

283{

284 uint32 old_wait_counts = 0;

286 uint32 injection_wait_event = 0;

288

291

293 return;

294

296

297

298

299

300

301

303

304

305

306

309 {

311 {

315 break;

316 }

317 }

319

321 elog(ERROR, "could not find free slot for wait of injection point %s ",

323

324

326 for (;;)

327 {

328 uint32 new_wait_counts;

329

333

334 if (old_wait_counts != new_wait_counts)

335 break;

337 }

339

340

344}

345

346

347

348

352{

357

358 if (strcmp(action, "error") == 0)

359 function = "injection_error";

360 else if (strcmp(action, "notice") == 0)

361 function = "injection_notice";

362 else if (strcmp(action, "wait") == 0)

364 else

365 elog(ERROR, "incorrect action \"%s\" for injection point creation", action);

366

368 {

371 }

372

376

378 {

380

381

385 }

386

387

389

391}

392

393

394

395

399{

401

404

407

409}

410

411

412

413

417{

419 char *arg = NULL;

420

424

427

430

432}

433

434

435

436

440{

442 char *arg = NULL;

443

447

450

453

455}

456

457

458

459

463{

466

469

470

473 {

475 {

477 break;

478 }

479 }

481 {

483 elog(ERROR, "could not find injection point %s to wake up", name);

484 }

487

488

491}

492

493

494

495

496

497

498

499

503{

504

506

509

510

511

512

513

515

517}

518

519

520

521

525{

527

530 elog(ERROR, "could not detach injection point \"%s\"", name);

531

532

534 {

536

540 }

541

542

544

546}

547

548

549void

551{

553 return;

554

556 "Enables statistics for injection points.",

557 NULL,

559 false,

561 0,

562 NULL,

563 NULL,

564 NULL);

565

567

568

573

576}

bool ConditionVariableCancelSleep(void)

void ConditionVariableBroadcast(ConditionVariable *cv)

void ConditionVariablePrepareToSleep(ConditionVariable *cv)

void ConditionVariableInit(ConditionVariable *cv)

void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)

void * GetNamedDSMSegment(const char *name, size_t size, void(*init_callback)(void *ptr), bool *found)

#define PG_GETARG_TEXT_PP(n)

void DefineCustomBoolVariable(const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)

void MarkGUCPrefixReserved(const char *className)

bool InjectionPointDetach(const char *name)

void InjectionPointAttach(const char *name, const char *library, const char *function, const void *private_data, int private_data_size)

#define INJECTION_POINT(name, arg)

#define INJECTION_POINT_CACHED(name, arg)

#define INJECTION_POINT_LOAD(name)

Datum injection_points_detach(PG_FUNCTION_ARGS)

static bool injection_point_local

static void injection_shmem_request(void)

PG_FUNCTION_INFO_V1(injection_points_attach)

PGDLLEXPORT void injection_wait(const char *name, const void *private_data, void *arg)

InjectionPointConditionType

static void injection_init_shmem(void)

Datum injection_points_cached(PG_FUNCTION_ARGS)

Datum injection_points_attach(PG_FUNCTION_ARGS)

struct InjectionPointCondition InjectionPointCondition

Datum injection_points_run(PG_FUNCTION_ARGS)

static List * inj_list_local

Datum injection_points_set_local(PG_FUNCTION_ARGS)

static shmem_startup_hook_type prev_shmem_startup_hook

static bool injection_point_allowed(InjectionPointCondition *condition)

static shmem_request_hook_type prev_shmem_request_hook

static void injection_points_cleanup(int code, Datum arg)

static void injection_shmem_startup(void)

PGDLLEXPORT void injection_error(const char *name, const void *private_data, void *arg)

struct InjectionPointSharedState InjectionPointSharedState

Datum injection_points_wakeup(PG_FUNCTION_ARGS)

PGDLLEXPORT void injection_notice(const char *name, const void *private_data, void *arg)

static void injection_point_init_state(void *ptr)

static InjectionPointSharedState * inj_state

Datum injection_points_load(PG_FUNCTION_ARGS)

void pgstat_report_inj(const char *name)

void pgstat_register_inj(void)

void pgstat_create_inj(const char *name)

void pgstat_drop_inj(const char *name)

void pgstat_register_inj_fixed(void)

void pgstat_report_inj_fixed(uint32 numattach, uint32 numdetach, uint32 numrun, uint32 numcached, uint32 numloaded)

void before_shmem_exit(pg_on_exit_callback function, Datum arg)

void(* shmem_startup_hook_type)(void)

shmem_startup_hook_type shmem_startup_hook

void RequestAddinShmemSpace(Size size)

List * lappend(List *list, void *datum)

List * list_delete(List *list, void *datum)

bool LWLockAcquire(LWLock *lock, LWLockMode mode)

void LWLockRelease(LWLock *lock)

char * pstrdup(const char *in)

MemoryContext TopMemoryContext

void(* shmem_request_hook_type)(void)

shmem_request_hook_type shmem_request_hook

bool process_shared_preload_libraries_in_progress

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

on_exit_nicely_callback function

size_t strlcpy(char *dst, const char *src, size_t siz)

void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)

#define SpinLockInit(lock)

#define SpinLockRelease(lock)

#define SpinLockAcquire(lock)

InjectionPointConditionType type

String * makeString(char *str)

char * text_to_cstring(const text *t)

uint32 WaitEventInjectionPointNew(const char *wait_event_name)