# title: ExtConnPoolLifeTime acts as countdown for activity in MOST RECENT database (of several) rather then separate for each of used databases
# decription:
# We create one main ('head') DB (only for make single attach to it) and four test databases for making EDS connections to each of them from main DB.
# Special user is created using LEGACY plugin because of comment in the ticket by hvlad 06/Nov/19 01:36 PM.
# ~~~~~~
# Then we do subsequent connections to each of these databases using EDS mechanism, with delay betnwe them (and also with final delay).
# Total sum of seconds that execution was paused is 4 * TDELAY - must be GREATER than config parameter ExtConnPoolLifeTime.
# After last delay will elapsed, we again establish connections to each of these databases and try to execute DROP DATABASE statements.
#
# Main idea: FIRST of this databases (which was firstly used to EDS connection) must have NO any attachments in its ExtPool and DROP must pass w/o any problems.
#
# ::: NOTE ::: ATTENTION ::: ACHTUNG :::
#
# We can not issue 'DROP DATABASE' immediately becase if some connection remains in ExtPool then FDB will raise exception that can not be catched.
# For this reason we have to kill all attachments using 'DELETE FROM MON$ATTACHMENTS' statement. Number of attachments that were deleted will show
# whether there was some 'auxiliary' connections or not. For the first of checked databases this number must be 0 (zero).
# Otherwise one can state that the problem with ExtPool still exists.
#
# Checked on:
# 4.0.0.1646 SS/SC: ~19s (most of time is idle because of delays that is necessary for check that connections disappeared from ExtPool)
# 4.0.0.1646 CS: 21.339s - but this test is not needed for this acrh.
# ('select cast(? as varchar(128)) as connect_from_db, current_user, mon$database_name as connect_to_db, cast(''now'' as timestamp) from mon$database')
# ( rdb$get_context('SYSTEM', 'DB_NAME') )
# on external
# 'localhost:' || a_target_db
# as
# user '%(EDS_USER)s'
# password '%(EDS_PSWD)s'
# into who_is_connecting, source_db, target_db, target_dts
# do
# suspend;
# end
# ^
# set term ;^
# commit;
# grant execute on procedure sp_do_eds to %(EDS_USER)s;