You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
postgres/src/test/modules/injection_points/expected/injection_points.out

302 lines
7.6 KiB

CREATE EXTENSION injection_points;
\getenv libdir PG_LIBDIR
\getenv dlsuffix PG_DLSUFFIX
\set regresslib :libdir '/regress' :dlsuffix
CREATE FUNCTION wait_pid(int)
RETURNS void
AS :'regresslib'
LANGUAGE C STRICT;
-- Non-strict checks
SELECT injection_points_run(NULL);
injection_points_run
----------------------
(1 row)
SELECT injection_points_cached(NULL);
injection_points_cached
-------------------------
(1 row)
SELECT injection_points_attach('TestInjectionBooh', 'booh');
ERROR: incorrect action "booh" for injection point creation
SELECT injection_points_attach('TestInjectionError', 'error');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_attach('TestInjectionLog', 'notice');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_attach('TestInjectionLog2', 'notice');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_run('TestInjectionBooh'); -- nothing
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog2'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog2
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog2', NULL); -- notice
NOTICE: notice triggered for injection point TestInjectionLog2
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog2', 'foobar'); -- notice + arg
NOTICE: notice triggered for injection point TestInjectionLog2 (foobar)
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionError'); -- error
ERROR: error triggered for injection point TestInjectionError
SELECT injection_points_run('TestInjectionError', NULL); -- error
ERROR: error triggered for injection point TestInjectionError
SELECT injection_points_run('TestInjectionError', 'foobar2'); -- error + arg
ERROR: error triggered for injection point TestInjectionError (foobar2)
-- Re-load cache and run again.
\c
SELECT injection_points_run('TestInjectionLog2'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog2
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionError'); -- error
ERROR: error triggered for injection point TestInjectionError
-- Remove one entry and check the remaining entries.
SELECT injection_points_detach('TestInjectionError'); -- ok
injection_points_detach
-------------------------
(1 row)
SELECT injection_points_run('TestInjectionLog'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionError'); -- nothing
injection_points_run
----------------------
(1 row)
-- More entries removed, letting TestInjectionLog2 to check the same
-- callback used in more than one point.
SELECT injection_points_detach('TestInjectionLog'); -- ok
injection_points_detach
-------------------------
(1 row)
SELECT injection_points_run('TestInjectionLog'); -- nothing
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionError'); -- nothing
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestInjectionLog2'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog2
injection_points_run
----------------------
(1 row)
SELECT injection_points_detach('TestInjectionLog'); -- fails
ERROR: could not detach injection point "TestInjectionLog"
SELECT injection_points_run('TestInjectionLog2'); -- notice
NOTICE: notice triggered for injection point TestInjectionLog2
injection_points_run
----------------------
(1 row)
SELECT injection_points_detach('TestInjectionLog2');
injection_points_detach
-------------------------
(1 row)
-- Loading
SELECT injection_points_cached('TestInjectionLogLoad'); -- nothing in cache
injection_points_cached
-------------------------
(1 row)
SELECT injection_points_load('TestInjectionLogLoad'); -- nothing
injection_points_load
-----------------------
(1 row)
SELECT injection_points_attach('TestInjectionLogLoad', 'notice');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_load('TestInjectionLogLoad'); -- nothing happens
injection_points_load
-----------------------
(1 row)
SELECT injection_points_cached('TestInjectionLogLoad'); -- runs from cache
NOTICE: notice triggered for injection point TestInjectionLogLoad
injection_points_cached
-------------------------
(1 row)
SELECT injection_points_cached('TestInjectionLogLoad', NULL); -- runs from cache
NOTICE: notice triggered for injection point TestInjectionLogLoad
injection_points_cached
-------------------------
(1 row)
SELECT injection_points_cached('TestInjectionLogLoad', 'foobar'); -- runs from cache
NOTICE: notice triggered for injection point TestInjectionLogLoad (foobar)
injection_points_cached
-------------------------
(1 row)
SELECT injection_points_run('TestInjectionLogLoad'); -- runs from cache
NOTICE: notice triggered for injection point TestInjectionLogLoad
injection_points_run
----------------------
(1 row)
SELECT injection_points_detach('TestInjectionLogLoad');
injection_points_detach
-------------------------
(1 row)
-- Runtime conditions
SELECT injection_points_attach('TestConditionError', 'error');
injection_points_attach
-------------------------
(1 row)
-- Any follow-up injection point attached will be local to this process.
SELECT injection_points_set_local();
injection_points_set_local
----------------------------
(1 row)
SELECT injection_points_attach('TestConditionLocal1', 'error');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_attach('TestConditionLocal2', 'notice');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_run('TestConditionLocal1'); -- error
ERROR: error triggered for injection point TestConditionLocal1
SELECT injection_points_run('TestConditionLocal2'); -- notice
NOTICE: notice triggered for injection point TestConditionLocal2
injection_points_run
----------------------
(1 row)
SELECT pg_backend_pid() AS oldpid \gset
-- reload, local injection points should be gone.
\c
-- Wait for the previous backend process to exit, ensuring that its local
-- injection points are cleaned up.
SELECT wait_pid(:'oldpid');
wait_pid
----------
(1 row)
SELECT injection_points_run('TestConditionLocal1'); -- nothing
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestConditionLocal2'); -- nothing
injection_points_run
----------------------
(1 row)
SELECT injection_points_run('TestConditionError'); -- error
ERROR: error triggered for injection point TestConditionError
SELECT injection_points_detach('TestConditionError');
injection_points_detach
-------------------------
(1 row)
-- Attaching injection points that use the same name as one defined locally
-- previously should work.
SELECT injection_points_attach('TestConditionLocal1', 'error');
injection_points_attach
-------------------------
(1 row)
SELECT injection_points_detach('TestConditionLocal1');
injection_points_detach
-------------------------
(1 row)
DROP EXTENSION injection_points;
DROP FUNCTION wait_pid;