Index: contrib/dblink/expected/dblink.out =================================================================== RCS file: /opt/src/cvs/pgsql-server/contrib/dblink/expected/dblink.out,v retrieving revision 1.1 diff -c -r1.1 dblink.out *** contrib/dblink/expected/dblink.out 14 Sep 2002 20:28:54 -0000 1.1 --- contrib/dblink/expected/dblink.out 14 Sep 2002 21:11:21 -0000 *************** *** 3,8 **** --- 3,25 ---- -- Turn off echoing so that expected file does not depend on -- contents of dblink.sql. -- + CREATE FUNCTION conditional_drop() RETURNS text AS ' + DECLARE + dbname text; + BEGIN + SELECT INTO dbname datname FROM pg_database WHERE datname = ''regression_slave''; + IF FOUND THEN + DROP DATABASE regression_slave; + END IF; + RETURN ''OK''; + END; + ' LANGUAGE 'plpgsql'; + SELECT conditional_drop(); + conditional_drop + ------------------ + OK + (1 row) + CREATE DATABASE regression_slave; \connect regression_slave \set ECHO none *************** *** 219,259 **** OK (1 row) - -- now wait for the connection to the slave to be cleared before - -- we try to drop the database - CREATE FUNCTION wait() RETURNS TEXT AS ' - DECLARE - rec record; - cntr int; - BEGIN - cntr = 0; - - select into rec d.datname - from pg_database d, - (select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b - where d.oid = b.dbid and d.datname = ''regression_slave''; - - WHILE FOUND LOOP - cntr = cntr + 1; - - select into rec d.datname - from pg_database d, - (select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b - where d.oid = b.dbid and d.datname = ''regression_slave''; - - -- safety valve - if cntr > 1000 THEN - EXIT; - end if; - END LOOP; - RETURN ''OK''; - END; - ' LANGUAGE 'plpgsql'; - SELECT wait(); - wait - ------ - OK - (1 row) - - -- OK, safe to drop the slave - DROP DATABASE regression_slave; --- 236,238 ---- Index: contrib/dblink/sql/dblink.sql =================================================================== RCS file: /opt/src/cvs/pgsql-server/contrib/dblink/sql/dblink.sql,v retrieving revision 1.1 diff -c -r1.1 dblink.sql *** contrib/dblink/sql/dblink.sql 14 Sep 2002 20:28:54 -0000 1.1 --- contrib/dblink/sql/dblink.sql 14 Sep 2002 21:11:15 -0000 *************** *** 3,8 **** --- 3,20 ---- -- Turn off echoing so that expected file does not depend on -- contents of dblink.sql. -- + CREATE FUNCTION conditional_drop() RETURNS text AS ' + DECLARE + dbname text; + BEGIN + SELECT INTO dbname datname FROM pg_database WHERE datname = ''regression_slave''; + IF FOUND THEN + DROP DATABASE regression_slave; + END IF; + RETURN ''OK''; + END; + ' LANGUAGE 'plpgsql'; + SELECT conditional_drop(); CREATE DATABASE regression_slave; \connect regression_slave \set ECHO none *************** *** 112,149 **** -- close the persistent connection select dblink_disconnect(); - - -- now wait for the connection to the slave to be cleared before - -- we try to drop the database - CREATE FUNCTION wait() RETURNS TEXT AS ' - DECLARE - rec record; - cntr int; - BEGIN - cntr = 0; - - select into rec d.datname - from pg_database d, - (select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b - where d.oid = b.dbid and d.datname = ''regression_slave''; - - WHILE FOUND LOOP - cntr = cntr + 1; - - select into rec d.datname - from pg_database d, - (select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b - where d.oid = b.dbid and d.datname = ''regression_slave''; - - -- safety valve - if cntr > 1000 THEN - EXIT; - end if; - END LOOP; - RETURN ''OK''; - END; - ' LANGUAGE 'plpgsql'; - SELECT wait(); - - -- OK, safe to drop the slave - DROP DATABASE regression_slave; --- 124,126 ----