Emmanuel BENOîT
3e109b13bc
* Added user mapping on the "remote" logging database for the administrative user. This allows calls to sys.write_sql_log() to succeed when they are executed by code with administrative privileges. * Added test suites for both the link to the database and the function itself. * Replaced RAISE NOTICE with actual logging in the universe generator
32 lines
No EOL
1 KiB
PL/PgSQL
32 lines
No EOL
1 KiB
PL/PgSQL
/*
|
|
* Test the sys.write_sql_log( ) function
|
|
*/
|
|
BEGIN;
|
|
DELETE FROM sys.logs;
|
|
SELECT plan( 4 );
|
|
|
|
SELECT diag_test_name( 'sys.write_sql_log( ) - Initial call' );
|
|
SELECT lives_ok(
|
|
$$ SELECT sys.write_sql_log( 'test' , 'WARNING'::log_level , 'test' ) $$
|
|
);
|
|
SELECT diag_test_name( 'sys.write_sql_log( ) - Contents of system log after call' );
|
|
SELECT is( COUNT(*)::INT , 1 ) FROM sys.logs;
|
|
DELETE FROM sys.logs;
|
|
|
|
SELECT diag_test_name( 'sys.write_sql_log( ) - Two calls in sequence' );
|
|
SELECT lives_ok(
|
|
$$ SELECT sys.write_sql_log( 'test' , 'WARNING'::log_level , 'test' );
|
|
SELECT sys.write_sql_log( 'test' , 'WARNING'::log_level , 'test' ) $$
|
|
);
|
|
DELETE FROM sys.logs;
|
|
|
|
SELECT diag_test_name( 'sys.write_sql_log( ) - Calling and rolling back' );
|
|
SAVEPOINT before_log;
|
|
SELECT sys.write_sql_log( 'test' , 'WARNING'::log_level , 'test' );
|
|
SELECT sys.write_log( 'test' , 'WARNING'::log_level , 'test' );
|
|
ROLLBACK TO SAVEPOINT before_log;
|
|
SELECT is( COUNT(*)::INT , 1 ) FROM sys.logs;
|
|
DELETE FROM sys.logs;
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |