🌐 AI搜索 & 代理 主页
Skip to content

Commit d52c24b

Browse files
committed
injection_points: Remove portions related to custom pgstats
The test module injection_points has been used as a landing spot to provide coverage for the custom pgstats APIs, for both fixed-sized and variable-sized stats kinds. Some recent work related to pgstats is proving that this structure makes the implementation of new tests harder. This commit removes the code related to pgstats from injection_points, and an equivalent will be reintroduced as a separate test module in a follow-up commit. This removal is done in its own commit for clarity. Using injection_points for this test coverage was perhaps not the best way to design things, but this was good enough while working on the first flavor of the custom pgstats APIs. Using a new test module will make easier the introduction of new tests, and we will not need to worry about the impact of new changes related to custom pgstats could have with the internals of injection_points. Author: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAA5RZ0sJgO6GAwgFxmzg9MVP=rM7Us8KKcWpuqxe-f5qxmpE0g@mail.gmail.com
1 parent f68597e commit d52c24b

File tree

10 files changed

+0
-697
lines changed

10 files changed

+0
-697
lines changed

doc/src/sgml/xfunc.sgml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,12 +3933,6 @@ extern bool InjectionPointDetach(const char *name);
39333933
using <literal>InjectionPointDetach</literal>.
39343934
</para>
39353935

3936-
<para>
3937-
An example can be found in
3938-
<filename>src/test/modules/injection_points</filename> in the PostgreSQL
3939-
source tree.
3940-
</para>
3941-
39423936
<para>
39433937
Enabling injection points requires
39443938
<option>--enable-injection-points</option> with

src/test/modules/injection_points/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ MODULE_big = injection_points
44
OBJS = \
55
$(WIN32RES) \
66
injection_points.o \
7-
injection_stats.o \
8-
injection_stats_fixed.o \
97
regress_injection.o
108
EXTENSION = injection_points
119
DATA = injection_points--1.0.sql
@@ -23,8 +21,6 @@ ISOLATION = basic \
2321
reindex-concurrently-upsert-on-constraint \
2422
reindex-concurrently-upsert-partitioned
2523

26-
TAP_TESTS = 1
27-
2824
# The injection points are cluster-wide, so disable installcheck
2925
NO_INSTALLCHECK = 1
3026

src/test/modules/injection_points/injection_points--1.0.sql

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -101,49 +101,6 @@ RETURNS SETOF record
101101
AS 'MODULE_PATHNAME', 'injection_points_list'
102102
LANGUAGE C STRICT VOLATILE PARALLEL RESTRICTED;
103103

104-
--
105-
-- injection_points_stats_numcalls()
106-
--
107-
-- Reports statistics, if any, related to the given injection point.
108-
--
109-
CREATE FUNCTION injection_points_stats_numcalls(IN point_name TEXT)
110-
RETURNS bigint
111-
AS 'MODULE_PATHNAME', 'injection_points_stats_numcalls'
112-
LANGUAGE C STRICT;
113-
114-
--
115-
-- injection_points_stats_count()
116-
--
117-
-- Return the number of entries stored in the pgstats hash table.
118-
--
119-
CREATE FUNCTION injection_points_stats_count()
120-
RETURNS bigint
121-
AS 'MODULE_PATHNAME', 'injection_points_stats_count'
122-
LANGUAGE C STRICT;
123-
124-
--
125-
-- injection_points_stats_drop()
126-
--
127-
-- Drop all statistics of injection points.
128-
--
129-
CREATE FUNCTION injection_points_stats_drop()
130-
RETURNS void
131-
AS 'MODULE_PATHNAME', 'injection_points_stats_drop'
132-
LANGUAGE C STRICT;
133-
134-
--
135-
-- injection_points_stats_fixed()
136-
--
137-
-- Reports fixed-numbered statistics for injection points.
138-
CREATE FUNCTION injection_points_stats_fixed(OUT numattach int8,
139-
OUT numdetach int8,
140-
OUT numrun int8,
141-
OUT numcached int8,
142-
OUT numloaded int8)
143-
RETURNS record
144-
AS 'MODULE_PATHNAME', 'injection_points_stats_fixed'
145-
LANGUAGE C STRICT;
146-
147104
--
148105
-- regress_injection.c functions
149106
--

src/test/modules/injection_points/injection_points.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "fmgr.h"
2121
#include "funcapi.h"
22-
#include "injection_stats.h"
2322
#include "miscadmin.h"
2423
#include "nodes/pg_list.h"
2524
#include "nodes/value.h"
@@ -107,15 +106,6 @@ extern PGDLLEXPORT void injection_wait(const char *name,
107106
/* track if injection points attached in this process are linked to it */
108107
static bool injection_point_local = false;
109108

110-
/*
111-
* GUC variable
112-
*
113-
* This GUC is useful to control if statistics should be enabled or not
114-
* during a test with injection points, like for example if a test relies
115-
* on a callback run in a critical section where no allocation should happen.
116-
*/
117-
bool inj_stats_enabled = false;
118-
119109
/* Shared memory init callbacks */
120110
static shmem_request_hook_type prev_shmem_request_hook = NULL;
121111
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
@@ -235,9 +225,6 @@ injection_points_cleanup(int code, Datum arg)
235225
char *name = strVal(lfirst(lc));
236226

237227
(void) InjectionPointDetach(name);
238-
239-
/* Remove stats entry */
240-
pgstat_drop_inj(name);
241228
}
242229
}
243230

@@ -251,8 +238,6 @@ injection_error(const char *name, const void *private_data, void *arg)
251238
if (!injection_point_allowed(condition))
252239
return;
253240

254-
pgstat_report_inj(name);
255-
256241
if (argstr)
257242
elog(ERROR, "error triggered for injection point %s (%s)",
258243
name, argstr);
@@ -269,8 +254,6 @@ injection_notice(const char *name, const void *private_data, void *arg)
269254
if (!injection_point_allowed(condition))
270255
return;
271256

272-
pgstat_report_inj(name);
273-
274257
if (argstr)
275258
elog(NOTICE, "notice triggered for injection point %s (%s)",
276259
name, argstr);
@@ -293,8 +276,6 @@ injection_wait(const char *name, const void *private_data, void *arg)
293276
if (!injection_point_allowed(condition))
294277
return;
295278

296-
pgstat_report_inj(name);
297-
298279
/*
299280
* Use the injection point name for this custom wait event. Note that
300281
* this custom wait event name is not released, but we don't care much for
@@ -371,7 +352,6 @@ injection_points_attach(PG_FUNCTION_ARGS)
371352
condition.pid = MyProcPid;
372353
}
373354

374-
pgstat_report_inj_fixed(1, 0, 0, 0, 0);
375355
InjectionPointAttach(name, "injection_points", function, &condition,
376356
sizeof(InjectionPointCondition));
377357

@@ -385,9 +365,6 @@ injection_points_attach(PG_FUNCTION_ARGS)
385365
MemoryContextSwitchTo(oldctx);
386366
}
387367

388-
/* Add entry for stats */
389-
pgstat_create_inj(name);
390-
391368
PG_RETURN_VOID();
392369
}
393370

@@ -422,7 +399,6 @@ injection_points_attach_func(PG_FUNCTION_ARGS)
422399
private_data_size = VARSIZE_ANY_EXHDR(private_data);
423400
}
424401

425-
pgstat_report_inj_fixed(1, 0, 0, 0, 0);
426402
if (private_data != NULL)
427403
InjectionPointAttach(name, lib_name, function, VARDATA_ANY(private_data),
428404
private_data_size);
@@ -444,7 +420,6 @@ injection_points_load(PG_FUNCTION_ARGS)
444420
if (inj_state == NULL)
445421
injection_init_shmem();
446422

447-
pgstat_report_inj_fixed(0, 0, 0, 0, 1);
448423
INJECTION_POINT_LOAD(name);
449424

450425
PG_RETURN_VOID();
@@ -467,7 +442,6 @@ injection_points_run(PG_FUNCTION_ARGS)
467442
if (!PG_ARGISNULL(1))
468443
arg = text_to_cstring(PG_GETARG_TEXT_PP(1));
469444

470-
pgstat_report_inj_fixed(0, 0, 1, 0, 0);
471445
INJECTION_POINT(name, arg);
472446

473447
PG_RETURN_VOID();
@@ -490,7 +464,6 @@ injection_points_cached(PG_FUNCTION_ARGS)
490464
if (!PG_ARGISNULL(1))
491465
arg = text_to_cstring(PG_GETARG_TEXT_PP(1));
492466

493-
pgstat_report_inj_fixed(0, 0, 0, 1, 0);
494467
INJECTION_POINT_CACHED(name, arg);
495468

496469
PG_RETURN_VOID();
@@ -567,7 +540,6 @@ injection_points_detach(PG_FUNCTION_ARGS)
567540
{
568541
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
569542

570-
pgstat_report_inj_fixed(0, 1, 0, 0, 0);
571543
if (!InjectionPointDetach(name))
572544
elog(ERROR, "could not detach injection point \"%s\"", name);
573545

@@ -581,9 +553,6 @@ injection_points_detach(PG_FUNCTION_ARGS)
581553
MemoryContextSwitchTo(oldctx);
582554
}
583555

584-
/* Remove stats entry */
585-
pgstat_drop_inj(name);
586-
587556
PG_RETURN_VOID();
588557
}
589558

@@ -625,32 +594,15 @@ injection_points_list(PG_FUNCTION_ARGS)
625594
#undef NUM_INJECTION_POINTS_LIST
626595
}
627596

628-
629597
void
630598
_PG_init(void)
631599
{
632600
if (!process_shared_preload_libraries_in_progress)
633601
return;
634602

635-
DefineCustomBoolVariable("injection_points.stats",
636-
"Enables statistics for injection points.",
637-
NULL,
638-
&inj_stats_enabled,
639-
false,
640-
PGC_POSTMASTER,
641-
0,
642-
NULL,
643-
NULL,
644-
NULL);
645-
646-
MarkGUCPrefixReserved("injection_points");
647-
648603
/* Shared memory initialization */
649604
prev_shmem_request_hook = shmem_request_hook;
650605
shmem_request_hook = injection_shmem_request;
651606
prev_shmem_startup_hook = shmem_startup_hook;
652607
shmem_startup_hook = injection_shmem_startup;
653-
654-
pgstat_register_inj();
655-
pgstat_register_inj_fixed();
656608
}

0 commit comments

Comments
 (0)