Check firebird.log [no messages found for interval when this test was running]
Jump to: output_first_mismatch    outcomes_full_history    elapsed_time_chart
Show cross-report outcomes.

Annotation type Annotation details
2 @message
Permission error
I/O error

firebird.driver.types.DatabaseError: I/O error during "CreateFile (open)" operation for file "gh_8429_alias_c"
-Error while trying to open file
-The process cannot access the file because it is being used by another process.

LOG DETAILS:

2025-02-25 08:27:48.137
2025-02-25 08:27:48.137 act_a = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:27:48.137 act_b = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:27:48.137 act_c = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:27:48.137 usr_x = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:27:48.137 usr_y = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:27:48.138 usr_z = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:27:48.138 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 08:27:48.138
2025-02-25 08:27:48.138     @pytest.mark.es_eds
2025-02-25 08:27:48.138     @pytest.mark.encryption
2025-02-25 08:27:48.138     @pytest.mark.version('>=4.0.6')
2025-02-25 08:27:48.138     def test_1(act_a: Action, act_b: Action, act_c: Action, usr_x: User, usr_y: User, usr_z: User, capsys):
2025-02-25 08:27:48.138
2025-02-25 08:27:48.138         dbfile_a = get_filename_by_alias(act_a)
2025-02-25 08:27:48.138         dbfile_b = get_filename_by_alias(act_b)
2025-02-25 08:27:48.138         dbfile_c = get_filename_by_alias(act_c)
2025-02-25 08:27:48.138
2025-02-25 08:27:48.138         dbfile_a.unlink(missing_ok = True)
2025-02-25 08:27:48.138         dbfile_b.unlink(missing_ok = True)
2025-02-25 08:27:48.138         dbfile_c.unlink(missing_ok = True)
2025-02-25 08:27:48.138
2025-02-25 08:27:48.138         with create_database(act_a.db.db_path, user = act_a.db.user, password = act_a.db.password) as con_a, \
2025-02-25 08:27:48.138             create_database(act_b.db.db_path, user = act_b.db.user, password = act_b.db.password) as con_b, \
2025-02-25 08:27:48.138             create_database(act_c.db.db_path, user = act_c.db.user, password = act_c.db.password) as con_c:
2025-02-25 08:27:48.139
2025-02-25 08:27:48.139             sql = f"""
2025-02-25 08:27:48.139                 create procedure sp_a (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 08:27:48.139                 begin
2025-02-25 08:27:48.139                     -- e1-meta.sql:
2025-02-25 08:27:48.139                     execute statement 'select * from sp_b(''' || a_who || ''')' as user '{usr_x.name}' password '{usr_x.password}' on external 'gh_8429_alias_b' into o_info;
2025-02-25 08:27:48.139                     suspend;
2025-02-25 08:27:48.139                 end
2025-02-25 08:27:48.139                 ^
2025-02-25 08:27:48.139                 grant execute on procedure sp_a to public
2025-02-25 08:27:48.139                 ^
2025-02-25 08:27:48.139                 alter database set linger to 0
2025-02-25 08:27:48.139                 ^
2025-02-25 08:27:48.139             """
2025-02-25 08:27:48.139             for x in sql.split('^'):
2025-02-25 08:27:48.139                 if (s := x.strip()):
2025-02-25 08:27:48.139                     con_a.execute_immediate(s)
2025-02-25 08:27:48.139             con_a.commit()
2025-02-25 08:27:48.139
2025-02-25 08:27:48.140             # ..................................................
2025-02-25 08:27:48.140
2025-02-25 08:27:48.140             sql = f"""
2025-02-25 08:27:48.140                 create procedure sp_b (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 08:27:48.140                 begin
2025-02-25 08:27:48.140                     execute statement 'select * from sp_c' as user a_who password a_who on external 'gh_8429_alias_c' into o_info;
2025-02-25 08:27:48.140                     suspend;
2025-02-25 08:27:48.140                 end
2025-02-25 08:27:48.140                 ^
2025-02-25 08:27:48.140                 grant execute on procedure sp_b to public
2025-02-25 08:27:48.140                 ^
2025-02-25 08:27:48.140                 alter database set linger to 0
2025-02-25 08:27:48.140                 ^
2025-02-25 08:27:48.140             """
2025-02-25 08:27:48.140             for x in sql.split('^'):
2025-02-25 08:27:48.140                 if (s := x.strip()):
2025-02-25 08:27:48.140                     con_b.execute_immediate(s)
2025-02-25 08:27:48.140             con_b.commit()
2025-02-25 08:27:48.140
2025-02-25 08:27:48.141             # ..................................................
2025-02-25 08:27:48.141
2025-02-25 08:27:48.141             sql = f"""
2025-02-25 08:27:48.141                 create procedure sp_c returns (o_info varchar(512)) as
2025-02-25 08:27:48.141                 begin
2025-02-25 08:27:48.141                     o_info = lower(current_user);
2025-02-25 08:27:48.141                     -- o_info = lower(rdb$get_context('SYSTEM', 'DB_NAME')) || ':' || lower(current_user);
2025-02-25 08:27:48.141                     suspend;
2025-02-25 08:27:48.141                 end
2025-02-25 08:27:48.141                 ^
2025-02-25 08:27:48.141                 grant execute on procedure sp_c to public
2025-02-25 08:27:48.141                 ^
2025-02-25 08:27:48.141                 alter database set linger to 0
2025-02-25 08:27:48.141                 ^
2025-02-25 08:27:48.141             """
2025-02-25 08:27:48.141             for x in sql.split('^'):
2025-02-25 08:27:48.141                 if (s := x.strip()):
2025-02-25 08:27:48.142                     con_c.execute_immediate(s)
2025-02-25 08:27:48.142             con_c.commit()
2025-02-25 08:27:48.142
2025-02-25 08:27:48.142             ############################################
2025-02-25 08:27:48.142             ###   E N C R Y P T    D A T A B A S E   ###
2025-02-25 08:27:48.142             ############################################
2025-02-25 08:27:48.142 >           run_encr_decr(act_c, 'encrypt', MAX_WAITING_ENCR_FINISH, capsys)
2025-02-25 08:27:48.142
2025-02-25 08:27:48.142 tests\bugs\gh_8429_test.py:272:
2025-02-25 08:27:48.142 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:27:48.142
2025-02-25 08:27:48.142 act = <firebird.qa.plugin.Action object at [hex]>, mode = 'encrypt'
2025-02-25 08:27:48.142 max_wait_encr_thread_finish = 10000
2025-02-25 08:27:48.142 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 08:27:48.142
2025-02-25 08:27:48.142     def run_encr_decr(act: Action, mode, max_wait_encr_thread_finish, capsys):
2025-02-25 08:27:48.142         if mode == 'encrypt':
2025-02-25 08:27:48.142             # See letter from Alex, 15.12.2023 16:16 demo-plugin can not transfer named key over network.
2025-02-25 08:27:48.142             # Because of that, we have to use 'ALTER DATABASE ENCRYPT WITH <plugin>'  _WITHOUT_ adding 'key "{ENCRYPTION_KEY}"'.
2025-02-25 08:27:48.143             # ::: NB ::: One need to be sure that $FB_HOME/plugins.conf contains following lines:
2025-02-25 08:27:48.143             # Plugin = KH2 {
2025-02-25 08:27:48.143             #     Module = $(dir_plugins)/fbSampleKeyHolder
2025-02-25 08:27:48.143             #     RegisterName = fbSampleKeyHolder
2025-02-25 08:27:48.143             #     Config = KH2
2025-02-25 08:27:48.143             # }
2025-02-25 08:27:48.143             #  Config = KH2 {
2025-02-25 08:27:48.143             #     Auto = false
2025-02-25 08:27:48.143             # }
2025-02-25 08:27:48.143             # Otherwise error will raise:
2025-02-25 08:27:48.143             # unsuccessful metadata update
2025-02-25 08:27:48.143             # -ALTER DATABASE failed
2025-02-25 08:27:48.143             # -Missing database encryption key for your attachment
2025-02-25 08:27:48.143             # -Plugin fbSampleDbCrypt:
2025-02-25 08:27:48.143             # -Crypt key not set
2025-02-25 08:27:48.143             #
2025-02-25 08:27:48.143             alter_db_sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}"' # <<< ::: NB ::: DO NOT add '... key "{ENCRYPTION_KEY}"' here!
2025-02-25 08:27:48.143             wait_for_state = 'Database encrypted'
2025-02-25 08:27:48.143         elif mode == 'decrypt':
2025-02-25 08:27:48.144             alter_db_sttm = 'alter database decrypt'
2025-02-25 08:27:48.144             wait_for_state = 'Database not encrypted'
2025-02-25 08:27:48.144
2025-02-25 08:27:48.144
2025-02-25 08:27:48.144         e_thread_finished = False
2025-02-25 08:27:48.144
2025-02-25 08:27:48.144         # 0 = non crypted;
2025-02-25 08:27:48.144         # 1 = has been encrypted;
2025-02-25 08:27:48.144         # 2 = is DEcrypting;
2025-02-25 08:27:48.144         # 3 = is Encrypting;
2025-02-25 08:27:48.144         #
2025-02-25 08:27:48.144         REQUIRED_CRYPT_STATE = 1 if mode == 'encrypt' else 0
2025-02-25 08:27:48.144         current_crypt_state = -1
2025-02-25 08:27:48.144         d1 = py_dt.timedelta(0)
2025-02-25 08:27:48.144 >       with act.db.connect() as con:
2025-02-25 08:27:48.144
2025-02-25 08:27:48.144 tests\bugs\gh_8429_test.py:147:
2025-02-25 08:27:48.144 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:27:48.144
2025-02-25 08:27:48.145 database = 'gh_8429_alias_c'
2025-02-25 08:27:48.145
2025-02-25 08:27:48.145     def connect(database: str, *, user: str=None, password: str=None, role: str=None,
2025-02-25 08:27:48.145                 no_gc: bool=None, no_db_triggers: bool=None, dbkey_scope: DBKeyScope=None,
2025-02-25 08:27:48.145                 crypt_callback: iCryptKeyCallbackImpl=None, charset: str=None,
2025-02-25 08:27:48.145                 auth_plugin_list: str=None, session_time_zone: str=None) -> Connection:
2025-02-25 08:27:48.145         """Establishes a connection to the database.
2025-02-25 08:27:48.145
2025-02-25 08:27:48.145         Arguments:
2025-02-25 08:27:48.145             database: DSN or Database configuration name.
2025-02-25 08:27:48.145             user: User name.
2025-02-25 08:27:48.145             password: User password.
2025-02-25 08:27:48.145             role: User role.
2025-02-25 08:27:48.145             no_gc: Do not perform garbage collection for this connection.
2025-02-25 08:27:48.145             no_db_triggers: Do not execute database triggers for this connection.
2025-02-25 08:27:48.145             dbkey_scope: DBKEY scope override for connection.
2025-02-25 08:27:48.145             crypt_callback: Callback that provides encryption key for the database.
2025-02-25 08:27:48.145             charset: Character set for connection.
2025-02-25 08:27:48.145             auth_plugin_list: List of authentication plugins override
2025-02-25 08:27:48.145             session_time_zone: Session time zone [Firebird 4]
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146         Hooks:
2025-02-25 08:27:48.146             Event `.ConnectionHook.ATTACH_REQUEST`: Executed after all parameters
2025-02-25 08:27:48.146             are preprocessed and before `Connection` is created. Hook
2025-02-25 08:27:48.146             must have signature::
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146                 hook_func(dsn: str, dpb: bytes) -> Optional[Connection]
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146             Hook may return `Connection` instance or None.
2025-02-25 08:27:48.146             First instance returned by any hook will become the return value
2025-02-25 08:27:48.146             of this function and other hooks are not called.
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146             Event `.ConnectionHook.ATTACHED`: Executed before `Connection` instance is
2025-02-25 08:27:48.146             returned. Hook must have signature::
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146                 hook_func(connection: Connection) -> None
2025-02-25 08:27:48.146
2025-02-25 08:27:48.146             Any value returned by hook is ignored.
2025-02-25 08:27:48.146         """
2025-02-25 08:27:48.147         db_config = driver_config.get_database(database)
2025-02-25 08:27:48.147         if db_config is None:
2025-02-25 08:27:48.147             db_config = driver_config.db_defaults
2025-02-25 08:27:48.147         else:
2025-02-25 08:27:48.147             database = db_config.database.value
2025-02-25 08:27:48.147         if db_config.server.value is None:
2025-02-25 08:27:48.147             srv_config = driver_config.server_defaults
2025-02-25 08:27:48.147         else:
2025-02-25 08:27:48.147             srv_config = driver_config.get_server(db_config.server.value)
2025-02-25 08:27:48.147             if srv_config is None:
2025-02-25 08:27:48.147                 raise ValueError(f"Configuration for server '{db_config.server.value}' not found")
2025-02-25 08:27:48.147         if user is None:
2025-02-25 08:27:48.147             user = db_config.user.value
2025-02-25 08:27:48.147             if user is None:
2025-02-25 08:27:48.147                 user = srv_config.user.value
2025-02-25 08:27:48.147         if password is None:
2025-02-25 08:27:48.147             password = db_config.password.value
2025-02-25 08:27:48.147             if password is None:
2025-02-25 08:27:48.147                 password = srv_config.password.value
2025-02-25 08:27:48.148         if role is None:
2025-02-25 08:27:48.148             role = db_config.role.value
2025-02-25 08:27:48.148         if charset is None:
2025-02-25 08:27:48.148             charset = db_config.charset.value
2025-02-25 08:27:48.148         if charset:
2025-02-25 08:27:48.148             charset = charset.upper()
2025-02-25 08:27:48.148         if auth_plugin_list is None:
2025-02-25 08:27:48.148             auth_plugin_list = db_config.auth_plugin_list.value
2025-02-25 08:27:48.148         if session_time_zone is None:
2025-02-25 08:27:48.148             session_time_zone = db_config.session_time_zone.value
2025-02-25 08:27:48.148         dsn = _connect_helper(db_config.dsn.value, srv_config.host.value, srv_config.port.value,
2025-02-25 08:27:48.148                               database, db_config.protocol.value)
2025-02-25 08:27:48.148         dpb = DPB(user=user, password=password, role=role, trusted_auth=db_config.trusted_auth.value,
2025-02-25 08:27:48.148                   sql_dialect=db_config.sql_dialect.value, timeout=db_config.timeout.value,
2025-02-25 08:27:48.148                   charset=charset, cache_size=db_config.cache_size.value,
2025-02-25 08:27:48.148                   no_linger=db_config.no_linger.value, utf8filename=db_config.utf8filename.value,
2025-02-25 08:27:48.148                   no_gc=no_gc, no_db_triggers=no_db_triggers, dbkey_scope=dbkey_scope,
2025-02-25 08:27:48.148                   dummy_packet_interval=db_config.dummy_packet_interval.value,
2025-02-25 08:27:48.148                   config=db_config.config.value, auth_plugin_list=auth_plugin_list,
2025-02-25 08:27:48.149                   session_time_zone=session_time_zone, set_bind=db_config.set_bind.value,
2025-02-25 08:27:48.149                   decfloat_round=db_config.decfloat_round.value,
2025-02-25 08:27:48.149                   decfloat_traps=db_config.decfloat_traps.value,
2025-02-25 08:27:48.149                   parallel_workers=db_config.parallel_workers.value)
2025-02-25 08:27:48.149 >       return __make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(),
2025-02-25 08:27:48.149                                  db_config.sql_dialect.value, charset, crypt_callback)
2025-02-25 08:27:48.149
2025-02-25 08:27:48.149 C:\Python3x\Lib\site-packages\firebird\driver\core.py:2149:
2025-02-25 08:27:48.149 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:27:48.149
2025-02-25 08:27:48.149 create = False, dsn = 'localhost/33337:gh_8429_alias_c', utf8filename = False
2025-02-25 08:27:48.149 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00', sql_dialect = 3
2025-02-25 08:27:48.149 charset = None, crypt_callback = None
2025-02-25 08:27:48.149
2025-02-25 08:27:48.149     def __make_connection(create: bool, dsn: str, utf8filename: bool, dpb: bytes,
2025-02-25 08:27:48.149                           sql_dialect: int, charset: str,
2025-02-25 08:27:48.149                           crypt_callback: iCryptKeyCallbackImpl) -> Connection:
2025-02-25 08:27:48.149         with a.get_api().master.get_dispatcher() as provider:
2025-02-25 08:27:48.149             if crypt_callback is not None:
2025-02-25 08:27:48.149                 provider.set_dbcrypt_callback(crypt_callback)
2025-02-25 08:27:48.150             if create:
2025-02-25 08:27:48.150                 att = provider.create_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 08:27:48.150                 con = Connection(att, dsn, dpb, sql_dialect, charset)
2025-02-25 08:27:48.150             else:
2025-02-25 08:27:48.150                 con = None
2025-02-25 08:27:48.150                 for hook in get_callbacks(ConnectionHook.ATTACH_REQUEST, Connection):
2025-02-25 08:27:48.150                     try:
2025-02-25 08:27:48.150                         con = hook(dsn, dpb)
2025-02-25 08:27:48.150                     except Exception as e:
2025-02-25 08:27:48.150                         raise InterfaceError("Error in DATABASE_ATTACH_REQUEST hook.", *e.args) from e
2025-02-25 08:27:48.150                     if con is not None:
2025-02-25 08:27:48.150                         break
2025-02-25 08:27:48.150                 if con is None:
2025-02-25 08:27:48.150 >                   att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 08:27:48.150
2025-02-25 08:27:48.150 C:\Python3x\Lib\site-packages\firebird\driver\core.py:2064:
2025-02-25 08:27:48.150 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:27:48.150
2025-02-25 08:27:48.150 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 08:27:48.151 filename = 'localhost/33337:gh_8429_alias_c'
2025-02-25 08:27:48.151 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00'
2025-02-25 08:27:48.151 encoding = 'utf-8'
2025-02-25 08:27:48.151
2025-02-25 08:27:48.151     def attach_database(self, filename: str, dpb: Optional[bytes] = None, encoding: str = 'ascii') -> iAttachment:
2025-02-25 08:27:48.151         "Replaces `isc_attach_database()`"
2025-02-25 08:27:48.151         result = self.vtable.attachDatabase(self, self.status, filename.encode(encoding),
2025-02-25 08:27:48.151                                             0 if dpb is None else len(dpb), dpb)
2025-02-25 08:27:48.151 >       self._check()
2025-02-25 08:27:48.151
2025-02-25 08:27:48.151 C:\Python3x\Lib\site-packages\firebird\driver\interfaces.py:1295:
2025-02-25 08:27:48.151 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:27:48.151
2025-02-25 08:27:48.151 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 08:27:48.151
2025-02-25 08:27:48.151     def _check(self) -> None:
2025-02-25 08:27:48.151         state = self.status.get_state()
2025-02-25 08:27:48.151         if StateFlag.ERRORS in state:
2025-02-25 08:27:48.151 >           raise self.__report(DatabaseError, self.status.get_errors())
2025-02-25 08:27:48.152 E           firebird.driver.types.DatabaseError: I/O error during "CreateFile (open)" operation for file "gh_8429_alias_c"
2025-02-25 08:27:48.152 E           -Error while trying to open file
2025-02-25 08:27:48.152 E           -The process cannot access the file because it is being used by another process.
2025-02-25 08:27:48.152
2025-02-25 08:27:48.152 C:\Python3x\Lib\site-packages\firebird\driver\interfaces.py:113: DatabaseError
2025-02-25 08:27:48.152 ---------------------------- Captured stdout setup ----------------------------
2025-02-25 08:27:48.152 Creating db: localhost:H:\QA\temp\qa2024.tmp\fbqa\test_11596\test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
2025-02-25 08:27:48.152 CREATE user: TMP_8429_X PLUGIN: Srp
2025-02-25 08:27:48.152 CREATE user: TMP_8429_Y PLUGIN: Srp
2025-02-25 08:27:48.152 CREATE user: TMP_8429_Z PLUGIN: Srp
2025-02-25 08:27:48.152 -------------------------- Captured stdout teardown ---------------------------
2025-02-25 08:27:48.152 DROP user: TMP_8429_Z PLUGIN: Srp
2025-02-25 08:27:48.152 DROP user: TMP_8429_Y PLUGIN: Srp
2025-02-25 08:27:48.152 DROP user: TMP_8429_X PLUGIN: Srp
3 #text
act_a = <firebird.qa.plugin.Action pytest object at [hex]>
act_b = <firebird.qa.plugin.Action pytest object at [hex]>
act_c = <firebird.qa.plugin.Action pytest object at [hex]>
usr_x = <firebird.qa.plugin.User pytest object at [hex]>
usr_y = <firebird.qa.plugin.User pytest object at [hex]>
usr_z = <firebird.qa.plugin.User pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>

    @pytest.mark.es_eds
    @pytest.mark.encryption
    @pytest.mark.version('>=4.0.6')
    def test_1(act_a: Action, act_b: Action, act_c: Action, usr_x: User, usr_y: User, usr_z: User, capsys):
    
        dbfile_a = get_filename_by_alias(act_a)
        dbfile_b = get_filename_by_alias(act_b)
        dbfile_c = get_filename_by_alias(act_c)
    
        dbfile_a.unlink(missing_ok = True)
        dbfile_b.unlink(missing_ok = True)
        dbfile_c.unlink(missing_ok = True)
    
        with create_database(act_a.db.db_path, user = act_a.db.user, password = act_a.db.password) as con_a, \
            create_database(act_b.db.db_path, user = act_b.db.user, password = act_b.db.password) as con_b, \
            create_database(act_c.db.db_path, user = act_c.db.user, password = act_c.db.password) as con_c:
    
            sql = f"""
                create procedure sp_a (a_who varchar(31)) returns (o_info varchar(512)) as
                begin
                    -- e1-meta.sql:
                    execute statement 'select * from sp_b(''' || a_who || ''')' as user '{usr_x.name}' password '{usr_x.password}' on external 'gh_8429_alias_b' into o_info;
                    suspend;
                end
                ^
                grant execute on procedure sp_a to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_a.execute_immediate(s)
            con_a.commit()
    
            # ..................................................
    
            sql = f"""
                create procedure sp_b (a_who varchar(31)) returns (o_info varchar(512)) as
                begin
                    execute statement 'select * from sp_c' as user a_who password a_who on external 'gh_8429_alias_c' into o_info;
                    suspend;
                end
                ^
                grant execute on procedure sp_b to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_b.execute_immediate(s)
            con_b.commit()
    
            # ..................................................
    
            sql = f"""
                create procedure sp_c returns (o_info varchar(512)) as
                begin
                    o_info = lower(current_user);
                    -- o_info = lower(rdb$get_context('SYSTEM', 'DB_NAME')) || ':' || lower(current_user);
                    suspend;
                end
                ^
                grant execute on procedure sp_c to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_c.execute_immediate(s)
            con_c.commit()
    
            ############################################
            ###   E N C R Y P T    D A T A B A S E   ###
            ############################################
>           run_encr_decr(act_c, 'encrypt', MAX_WAITING_ENCR_FINISH, capsys)

tests\bugs\gh_8429_test.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

act = <firebird.qa.plugin.Action pytest object at [hex]>, mode = 'encrypt'
max_wait_encr_thread_finish = 10000
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>

    def run_encr_decr(act: Action, mode, max_wait_encr_thread_finish, capsys):
        if mode == 'encrypt':
            # See letter from Alex, 15.12.2023 16:16 demo-plugin can not transfer named key over network.
            # Because of that, we have to use 'ALTER DATABASE ENCRYPT WITH <plugin>'  _WITHOUT_ adding 'key "{ENCRYPTION_KEY}"'.
            # ::: NB ::: One need to be sure that $FB_HOME/plugins.conf contains following lines:
            # Plugin = KH2 {
            #     Module = $(dir_plugins)/fbSampleKeyHolder
            #     RegisterName = fbSampleKeyHolder
            #     Config = KH2
            # }
            #  Config = KH2 {
            #     Auto = false
            # }
            # Otherwise error will raise:
            # unsuccessful metadata update
            # -ALTER DATABASE failed
            # -Missing database encryption key for your attachment
            # -Plugin fbSampleDbCrypt:
            # -Crypt key not set
            #
            alter_db_sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}"' # <<< ::: NB ::: DO NOT add '... key "{ENCRYPTION_KEY}"' here!
            wait_for_state = 'Database encrypted'
        elif mode == 'decrypt':
            alter_db_sttm = 'alter database decrypt'
            wait_for_state = 'Database not encrypted'
    
    
        e_thread_finished = False
    
        # 0 = non crypted;
        # 1 = has been encrypted;
        # 2 = is DEcrypting;
        # 3 = is Encrypting;
        #
        REQUIRED_CRYPT_STATE = 1 if mode == 'encrypt' else 0
        current_crypt_state = -1
        d1 = py_dt.timedelta(0)
>       with act.db.connect() as con:

tests\bugs\gh_8429_test.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

database = 'gh_8429_alias_c'

    def connect(database: str, *, user: str=None, password: str=None, role: str=None,
                no_gc: bool=None, no_db_triggers: bool=None, dbkey_scope: DBKeyScope=None,
                crypt_callback: iCryptKeyCallbackImpl=None, charset: str=None,
                auth_plugin_list: str=None, session_time_zone: str=None) -> Connection:
        """Establishes a connection to the database.
    
        Arguments:
            database: DSN or Database configuration name.
            user: User name.
            password: User password.
            role: User role.
            no_gc: Do not perform garbage collection for this connection.
            no_db_triggers: Do not execute database triggers for this connection.
            dbkey_scope: DBKEY scope override for connection.
            crypt_callback: Callback that provides encryption key for the database.
            charset: Character set for connection.
            auth_plugin_list: List of authentication plugins override
            session_time_zone: Session time zone [Firebird 4]
    
        Hooks:
            Event `.ConnectionHook.ATTACH_REQUEST`: Executed after all parameters
            are preprocessed and before `Connection` is created. Hook
            must have signature::
    
                hook_func(dsn: str, dpb: bytes) -> Optional[Connection]
    
            Hook may return `Connection` instance or None.
            First instance returned by any hook will become the return value
            of this function and other hooks are not called.
    
            Event `.ConnectionHook.ATTACHED`: Executed before `Connection` instance is
            returned. Hook must have signature::
    
                hook_func(connection: Connection) -> None
    
            Any value returned by hook is ignored.
        """
        db_config = driver_config.get_database(database)
        if db_config is None:
            db_config = driver_config.db_defaults
        else:
            database = db_config.database.value
        if db_config.server.value is None:
            srv_config = driver_config.server_defaults
        else:
            srv_config = driver_config.get_server(db_config.server.value)
            if srv_config is None:
                raise ValueError(f"Configuration for server '{db_config.server.value}' not found")
        if user is None:
            user = db_config.user.value
            if user is None:
                user = srv_config.user.value
        if password is None:
            password = db_config.password.value
            if password is None:
                password = srv_config.password.value
        if role is None:
            role = db_config.role.value
        if charset is None:
            charset = db_config.charset.value
        if charset:
            charset = charset.upper()
        if auth_plugin_list is None:
            auth_plugin_list = db_config.auth_plugin_list.value
        if session_time_zone is None:
            session_time_zone = db_config.session_time_zone.value
        dsn = _connect_helper(db_config.dsn.value, srv_config.host.value, srv_config.port.value,
                              database, db_config.protocol.value)
        dpb = DPB(user=user, password=password, role=role, trusted_auth=db_config.trusted_auth.value,
                  sql_dialect=db_config.sql_dialect.value, timeout=db_config.timeout.value,
                  charset=charset, cache_size=db_config.cache_size.value,
                  no_linger=db_config.no_linger.value, utf8filename=db_config.utf8filename.value,
                  no_gc=no_gc, no_db_triggers=no_db_triggers, dbkey_scope=dbkey_scope,
                  dummy_packet_interval=db_config.dummy_packet_interval.value,
                  config=db_config.config.value, auth_plugin_list=auth_plugin_list,
                  session_time_zone=session_time_zone, set_bind=db_config.set_bind.value,
                  decfloat_round=db_config.decfloat_round.value,
                  decfloat_traps=db_config.decfloat_traps.value,
                  parallel_workers=db_config.parallel_workers.value)
>       return __make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(),
                                 db_config.sql_dialect.value, charset, crypt_callback)

C:\Python3x\Lib\site-packages\firebird\driver\core.py:2149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

create = False, dsn = 'localhost/33337:gh_8429_alias_c', utf8filename = False
dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00', sql_dialect = 3
charset = None, crypt_callback = None

    def __make_connection(create: bool, dsn: str, utf8filename: bool, dpb: bytes,
                          sql_dialect: int, charset: str,
                          crypt_callback: iCryptKeyCallbackImpl) -> Connection:
        with a.get_api().master.get_dispatcher() as provider:
            if crypt_callback is not None:
                provider.set_dbcrypt_callback(crypt_callback)
            if create:
                att = provider.create_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
                con = Connection(att, dsn, dpb, sql_dialect, charset)
            else:
                con = None
                for hook in get_callbacks(ConnectionHook.ATTACH_REQUEST, Connection):
                    try:
                        con = hook(dsn, dpb)
                    except Exception as e:
                        raise InterfaceError("Error in DATABASE_ATTACH_REQUEST hook.", *e.args) from e
                    if con is not None:
                        break
                if con is None:
>                   att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)

C:\Python3x\Lib\site-packages\firebird\driver\core.py:2064: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <firebird.driver.interfaces.iProvider pytest object at [hex]>
filename = 'localhost/33337:gh_8429_alias_c'
dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00'
encoding = 'utf-8'

    def attach_database(self, filename: str, dpb: Optional[bytes] = None, encoding: str = 'ascii') -> iAttachment:
        "Replaces `isc_attach_database()`"
        result = self.vtable.attachDatabase(self, self.status, filename.encode(encoding),
                                            0 if dpb is None else len(dpb), dpb)
>       self._check()

C:\Python3x\Lib\site-packages\firebird\driver\interfaces.py:1295: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <firebird.driver.interfaces.iProvider pytest object at [hex]>

    def _check(self) -> None:
        state = self.status.get_state()
        if StateFlag.ERRORS in state:
>           raise self.__report(DatabaseError, self.status.get_errors())
E           firebird.driver.types.DatabaseError: I/O error during "CreateFile (open)" operation for file "gh_8429_alias_c"
E           -Error while trying to open file
E           -The process cannot access the file because it is being used by another process.

C:\Python3x\Lib\site-packages\firebird\driver\interfaces.py:113: DatabaseError
Full history of outcomes and elapsed time, ms:
NN SNAP_INFO CS_outcome SS_outcome CS_run_time SS_run_time CS_run_beg CS_run_end SS_run_beg SS_run_end
1 4.0.6.3215 2025.06.25 6461d P P 3520 2240 2025.06.26 07:58:50.262 2025.06.26 07:58:53.782 2025.06.26 06:54:00.407 2025.06.26 06:54:02.647
2 4.0.6.3214 2025.06.21 e11f6 P P 3364 2389 2025.06.25 12:38:03.261 2025.06.25 12:38:06.625 2025.06.25 11:38:08.338 2025.06.25 11:38:10.727
3 4.0.6.3213 2025.06.14 f015c P P 3423 2279 2025.06.21 07:38:30.854 2025.06.21 07:38:34.277 2025.06.21 06:38:30.976 2025.06.21 06:38:33.255
4 4.0.6.3212 2025.06.11 bc50d P P 3389 2276 2025.06.14 08:06:24.009 2025.06.14 08:06:27.398 2025.06.14 07:05:52.578 2025.06.14 07:05:54.854
5 4.0.6.3208 2025.06.10 19fe3 P P 3396 2246 2025.06.11 06:33:24.731 2025.06.11 06:33:28.127 2025.06.11 05:33:36.713 2025.06.11 05:33:38.959
6 4.0.6.3207 2025.06.07 205ff P P 3480 2275 2025.06.10 06:34:37.856 2025.06.10 06:34:41.336 2025.06.10 05:34:17.561 2025.06.10 05:34:19.836
7 4.0.6.3206 2025.05.22 d7d10 P P 3369 2237 2025.06.06 06:28:32.666 2025.06.06 06:28:36.035 2025.06.06 05:29:26.821 2025.06.06 05:29:29.058
8 4.0.6.3205 2025.05.07 00148 P P 3296 2214 2025.05.18 06:15:56.529 2025.05.18 06:15:59.825 2025.05.18 05:19:02.025 2025.05.18 05:19:04.239
9 4.0.6.3204 2025.05.06 35b85 P P 3346 2227 2025.05.07 06:24:13.044 2025.05.07 06:24:16.390 2025.05.07 05:25:41.453 2025.05.07 05:25:43.680
10 4.0.6.3203 2025.05.05 c2cbd P P 3543 2243 2025.05.06 06:24:33.021 2025.05.06 06:24:36.564 2025.05.06 05:25:49.942 2025.05.06 05:25:52.185
11 4.0.6.3200 2025.04.18 7ef56 P P 3336 2282 2025.04.26 06:29:05.757 2025.04.26 06:29:09.093 2025.04.26 05:30:02.447 2025.04.26 05:30:04.729
12 4.0.6.3199 2025.04.14 33a10 P P 3311 2385 2025.04.17 06:26:28.488 2025.04.17 06:26:31.799 2025.04.17 05:27:32.388 2025.04.17 05:27:34.773
13 4.0.6.3198 2025.04.13 64a7f P P 3436 2267 2025.04.14 06:24:50.459 2025.04.14 06:24:53.895 2025.04.14 05:25:44.873 2025.04.14 05:25:47.140
14 4.0.6.3195 2025.04.12 82cb5 P P 3284 2214 2025.04.13 06:10:10.610 2025.04.13 06:10:13.894 2025.04.13 05:13:24.775 2025.04.13 05:13:26.989
15 4.0.6.3195 2025.03.28 b9faf P P 3343 2200 2025.04.12 06:29:52.598 2025.04.12 06:29:55.941 2025.04.12 05:29:54.692 2025.04.12 05:29:56.892
16 4.0.6.3194 2025.03.27 ab754 P P 3471 2345 2025.03.28 06:42:08.789 2025.03.28 06:42:12.260 2025.03.28 05:41:46.819 2025.03.28 05:41:49.164
17 4.0.6.3194 2025.03.26 912aa P P 3517 2436 2025.03.27 06:32:20.373 2025.03.27 06:32:23.890 2025.03.27 05:30:48.831 2025.03.27 05:30:51.267
18 4.0.6.3193 2025.03.20 80234 P P 3567 2434 2025.03.24 06:32:53.747 2025.03.24 06:32:57.314 2025.03.24 05:30:54.504 2025.03.24 05:30:56.938
19 4.0.6.3192 2025.03.13 2a9da P P 3331 2249 2025.03.20 06:20:34.228 2025.03.20 06:20:37.559 2025.03.20 05:20:38.292 2025.03.20 05:20:40.541
20 4.0.6.3191 2025.03.10 3d9fd P P 3445 2347 2025.03.13 06:27:45.364 2025.03.13 06:27:48.809 2025.03.13 05:26:29.950 2025.03.13 05:26:32.297
21 4.0.6.3190 2025.02.25 c9928 P P 3501 2418 2025.03.09 06:24:36.749 2025.03.09 06:24:40.250 2025.03.09 05:23:27.591 2025.03.09 05:23:30.009
22 4.0.6.3189 2025.02.22 3fb0b P F 2957 1750 2025.02.25 06:13:50.701 2025.02.25 06:13:53.658 2025.02.25 05:14:09.763 2025.02.25 05:14:11.513

Elapsed time, ms. Chart for last 22 runs:

Last commits information (all timestamps in UTC):