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
40 lines
No EOL
1.1 KiB
PL/PgSQL
40 lines
No EOL
1.1 KiB
PL/PgSQL
/*
|
|
* Test the presence and configuration of the dblink
|
|
* extension
|
|
*/
|
|
BEGIN;
|
|
SELECT plan( 6 );
|
|
|
|
SELECT diag_test_name( 'dblink - dblink_connect() exists' );
|
|
SELECT has_function( 'dblink_connect' );
|
|
|
|
SELECT diag_test_name( 'dblink - Foreign data wrapper defined' );
|
|
SELECT is( p.proname , 'postgresql_fdw_validator' )
|
|
FROM pg_foreign_data_wrapper w
|
|
INNER JOIN pg_proc p ON w.fdwvalidator = p.oid
|
|
WHERE w.fdwname = 'pgsql';
|
|
|
|
SELECT diag_test_name( 'dblink - Foreign server defined' );
|
|
SELECT is ( w.fdwname , 'pgsql' )
|
|
FROM pg_foreign_server s
|
|
INNER JOIN pg_foreign_data_wrapper w
|
|
ON s.srvfdw = w.oid
|
|
WHERE s.srvname = 'srv_logging';
|
|
|
|
SELECT diag_test_name( 'dblink - Connection' );
|
|
SELECT lives_ok(
|
|
$$ SELECT dblink_connect( 'cn_logging' , 'srv_logging' ) $$
|
|
);
|
|
|
|
SELECT diag_test_name( 'dblink - Remote user is not the administrator' );
|
|
SELECT isnt( username , current_user::TEXT )
|
|
FROM dblink( 'cn_logging' , 'SELECT current_user' )
|
|
AS ( username TEXT );
|
|
|
|
SELECT diag_test_name( 'dblink - Disconnection' );
|
|
SELECT lives_ok(
|
|
$$ SELECT dblink_disconnect( 'cn_logging' ) $$
|
|
);
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |