File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
src/test/modules/injection_points Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,16 @@ RETURNS bigint
8585AS ' MODULE_PATHNAME' , ' injection_points_stats_numcalls'
8686LANGUAGE C STRICT;
8787
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+
8898--
8999-- injection_points_stats_fixed()
90100--
Original file line number Diff line number Diff line change @@ -197,3 +197,22 @@ injection_points_stats_numcalls(PG_FUNCTION_ARGS)
197197
198198 PG_RETURN_INT64 (entry -> numcalls );
199199}
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 6969 " SELECT * FROM injection_points_stats_fixed();" );
7070is($fixedstats , ' 0|0|0|0|0' , ' fixed stats after crash' );
7171
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+
7285# Stop the server, disable the module, then restart. The server
7386# should be able to come up.
7487$node -> stop;
You can’t perform that action at this time.
0 commit comments