File tree 3 files changed +42
-0
lines changed
src/test/modules/injection_points 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,16 @@ RETURNS bigint
85
85
AS ' MODULE_PATHNAME' , ' injection_points_stats_numcalls'
86
86
LANGUAGE C STRICT;
87
87
88
+ --
89
+ -- injection_points_stats_drop()
90
+ --
91
+ -- Drop all statistics of injection points.
92
+ --
93
+ CREATE FUNCTION injection_points_stats_drop ()
94
+ RETURNS void
95
+ AS ' MODULE_PATHNAME' , ' injection_points_stats_drop'
96
+ LANGUAGE C STRICT;
97
+
88
98
--
89
99
-- injection_points_stats_fixed()
90
100
--
Original file line number Diff line number Diff line change @@ -197,3 +197,22 @@ injection_points_stats_numcalls(PG_FUNCTION_ARGS)
197
197
198
198
PG_RETURN_INT64 (entry -> numcalls );
199
199
}
200
+
201
+ /* Only used by injection_points_stats_drop() */
202
+ static bool
203
+ match_inj_entries (PgStatShared_HashEntry * entry , Datum match_data )
204
+ {
205
+ return entry -> key .kind == PGSTAT_KIND_INJECTION ;
206
+ }
207
+
208
+ /*
209
+ * SQL function that drops all injection point statistics.
210
+ */
211
+ PG_FUNCTION_INFO_V1 (injection_points_stats_drop );
212
+ Datum
213
+ injection_points_stats_drop (PG_FUNCTION_ARGS )
214
+ {
215
+ pgstat_drop_matching_entries (match_inj_entries , 0 );
216
+
217
+ PG_RETURN_VOID ();
218
+ }
Original file line number Diff line number Diff line change 69
69
" SELECT * FROM injection_points_stats_fixed();" );
70
70
is($fixedstats , ' 0|0|0|0|0' , ' fixed stats after crash' );
71
71
72
+ # On drop all stats are gone
73
+ $node -> safe_psql(' postgres' ,
74
+ " SELECT injection_points_attach('stats-notice', 'notice');" );
75
+ $node -> safe_psql(' postgres' , " SELECT injection_points_run('stats-notice');" );
76
+ $node -> safe_psql(' postgres' , " SELECT injection_points_run('stats-notice');" );
77
+ $numcalls = $node -> safe_psql(' postgres' ,
78
+ " SELECT injection_points_stats_numcalls('stats-notice');" );
79
+ is($numcalls , ' 2' , ' number of stats calls' );
80
+ $node -> safe_psql(' postgres' , " SELECT injection_points_stats_drop();" );
81
+ $numcalls = $node -> safe_psql(' postgres' ,
82
+ " SELECT injection_points_stats_numcalls('stats-notice');" );
83
+ is($numcalls , ' ' , ' no stats after drop via SQL function' );
84
+
72
85
# Stop the server, disable the module, then restart. The server
73
86
# should be able to come up.
74
87
$node -> stop;
You can’t perform that action at this time.
0 commit comments