BEGIN; SELECT plan( 3 ); -- -- Insertion through sys.write_log() -- CREATE OR REPLACE FUNCTION _test_this( ) RETURNS BIGINT AS $$ SELECT sys.write_log( 'test' , 'WARNING'::log_level , 'test' ); $$ LANGUAGE SQL; SELECT lives_ok( 'SELECT _test_this()' ); DROP FUNCTION _test_this( ); -- -- Direct insertion must fail -- CREATE FUNCTION _test_this( ) RETURNS VOID AS $$ INSERT INTO sys.logs( component , level , message ) VALUES ( 'test' , 'WARNING'::log_level , 'test' ); $$ LANGUAGE SQL; SELECT throws_ok( 'SELECT _test_this()' , 42501 ); DROP FUNCTION _test_this( ); -- -- Updates must fail -- CREATE OR REPLACE FUNCTION _test_this( ) RETURNS VOID AS $$ UPDATE sys.logs SET component = 'random' WHERE component = 'test'; $$ LANGUAGE SQL; SELECT throws_ok( 'SELECT _test_this()' , 42501 ); DROP FUNCTION _test_this( ); SELECT * FROM finish( ); ROLLBACK;