2 @message |
Server crashed ?
firebird.driver.types.DatabaseError: Error writing data to the connection.
LOG DETAILS:
2025-02-26 14:01:59.797
2025-02-26 14:01:59.805 act = <firebird.qa.plugin.Action object at [hex]>
2025-02-26 14:01:59.816 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-02-26 14:01:59.829 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-26 14:01:59.839
2025-02-26 14:01:59.851 @pytest.mark.version('>=3.0.4')
2025-02-26 14:01:59.861 def test_1(act: Action, tmp_user: User, capsys):
2025-02-26 14:01:59.868
2025-02-26 14:01:59.874 init_ddl = [
2025-02-26 14:01:59.880 """
2025-02-26 14:01:59.887 set bail on;
2025-02-26 14:01:59.893 recreate sequence g;
2025-02-26 14:01:59.898 create table test(id int primary key, measure int, iter_no int);
2025-02-26 14:01:59.903
2025-02-26 14:01:59.909 create view v_test1 as select * from test;
2025-02-26 14:01:59.914 """
2025-02-26 14:01:59.920 ,'\n'.join( ['create view v_test%s as select * from v_test%s;' % (str(i), str(i-1)) for i in range(2,NESTED_LIMIT+1) ] )
2025-02-26 14:01:59.926 ,f"""
2025-02-26 14:01:59.932 commit;
2025-02-26 14:01:59.938
2025-02-26 14:01:59.943 set term ^;
2025-02-26 14:01:59.949 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-02-26 14:01:59.956 begin
2025-02-26 14:01:59.962 while ( n_iterations > 0 ) do
2025-02-26 14:01:59.968 begin
2025-02-26 14:01:59.973 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-02-26 14:01:59.979 n_iterations = n_iterations - 1;
2025-02-26 14:01:59.985 end
2025-02-26 14:01:59.991
2025-02-26 14:01:59.998 end
2025-02-26 14:02:00.005 ^
2025-02-26 14:02:00.012 set term ;^
2025-02-26 14:02:00.019 commit;
2025-02-26 14:02:00.025
2025-02-26 14:02:00.032 grant execute on procedure sp_run to {tmp_user.name};
2025-02-26 14:02:00.038 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-02-26 14:02:00.046 grant usage on sequence g to {tmp_user.name};
2025-02-26 14:02:00.053 commit;
2025-02-26 14:02:00.060
2025-02-26 14:02:00.066 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-02-26 14:02:00.073 commit;
2025-02-26 14:02:00.080 """
2025-02-26 14:02:00.087 ]
2025-02-26 14:02:00.094
2025-02-26 14:02:00.100 act.expected_stdout = ''
2025-02-26 14:02:00.106 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-02-26 14:02:00.113 assert act.clean_stdout == act.clean_expected_stdout
2025-02-26 14:02:00.119 act.reset()
2025-02-26 14:02:00.125
2025-02-26 14:02:00.130 #------------------------------------------------------------
2025-02-26 14:02:00.137
2025-02-26 14:02:00.144 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-02-26 14:02:00.152 with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-02-26 14:02:00.158 cur_sysdba = con_sysdba.cursor()
2025-02-26 14:02:00.165 cur_nondba = con_nondba.cursor()
2025-02-26 14:02:00.172 cur_sysdba.execute(pid_sttm)
2025-02-26 14:02:00.179 cur_nondba.execute(pid_sttm)
2025-02-26 14:02:00.185 pid_sysdba = cur_sysdba.fetchone()[0]
2025-02-26 14:02:00.191 pid_nondba = cur_nondba.fetchone()[0]
2025-02-26 14:02:00.198
2025-02-26 14:02:00.204 sp_time = {}
2025-02-26 14:02:00.211 for who in (act.db.user, tmp_user.name):
2025-02-26 14:02:00.216 fb_pid = pid_sysdba if who == act.db.user else pid_nondba
2025-02-26 14:02:00.222 con = con_sysdba if who == act.db.user else con_nondba
2025-02-26 14:02:00.228 cur = cur_sysdba if who == act.db.user else cur_nondba
2025-02-26 14:02:00.234
2025-02-26 14:02:00.240 for iter_no in range(0, N_MEASURES):
2025-02-26 14:02:00.246 fb_info_init = psutil.Process(fb_pid).cpu_times()
2025-02-26 14:02:00.252 > cur.callproc( 'sp_run', (iter_no, N_COUNT_PER_MEASURE,) )
2025-02-26 14:02:00.258
2025-02-26 14:02:00.264 tests/bugs/gh_6220_test.py:147:
2025-02-26 14:02:00.270 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:00.276
2025-02-26 14:02:00.282 self = <firebird.driver.core.Cursor object at [hex]>
2025-02-26 14:02:00.289 proc_name = 'sp_run', parameters = (18, 100)
2025-02-26 14:02:00.295
2025-02-26 14:02:00.301 def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
2025-02-26 14:02:00.307 """Executes a stored procedure with the given name.
2025-02-26 14:02:00.314
2025-02-26 14:02:00.319 Arguments:
2025-02-26 14:02:00.325 proc_name: Stored procedure name.
2025-02-26 14:02:00.333 parameters: Sequence of parameters. Must contain one entry for each argument
2025-02-26 14:02:00.340 that the procedure expects.
2025-02-26 14:02:00.346
2025-02-26 14:02:00.352 .. note::
2025-02-26 14:02:00.358
2025-02-26 14:02:00.364 If stored procedure does have output parameters, you must retrieve their values
2025-02-26 14:02:00.370 saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
2025-02-26 14:02:00.375 but conforms to Python DB API 2.0. If you don't require conformance to Python
2025-02-26 14:02:00.381 DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
2025-02-26 14:02:00.387 instead.
2025-02-26 14:02:00.393 """
2025-02-26 14:02:00.400 params = [] if parameters is None else parameters
2025-02-26 14:02:00.406 sql = ('EXECUTE PROCEDURE ' + proc_name + ' '
2025-02-26 14:02:00.414 + ','.join('?' * len(params)))
2025-02-26 14:02:00.421 > self.execute(sql, params)
2025-02-26 14:02:00.427
2025-02-26 14:02:00.434 ../lib/python3.11/site-packages/firebird/driver/core.py:3682:
2025-02-26 14:02:00.441 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:00.446
2025-02-26 14:02:00.452 self = <firebird.driver.core.Cursor object at [hex]>
2025-02-26 14:02:00.459 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
2025-02-26 14:02:00.465
2025-02-26 14:02:00.471 def execute(self, operation: Union[str, Statement], parameters: Sequence[Any]=None) -> Cursor:
2025-02-26 14:02:00.478 """Executes SQL command or prepared `Statement`.
2025-02-26 14:02:00.485
2025-02-26 14:02:00.491 Starts new transaction if transaction manager associated with cursor is not active.
2025-02-26 14:02:00.496
2025-02-26 14:02:00.501 Arguments:
2025-02-26 14:02:00.506 operation: SQL command or prepared `Statement`.
2025-02-26 14:02:00.513 parameters: Sequence of parameters. Must contain one entry for each argument
2025-02-26 14:02:00.520 that the operation expects.
2025-02-26 14:02:00.527
2025-02-26 14:02:00.534 Returns:
2025-02-26 14:02:00.541 `self` so call to execute could be used as iterator over returned rows.
2025-02-26 14:02:00.548
2025-02-26 14:02:00.556 Note:
2025-02-26 14:02:00.565 If `operation` is a string with SQL command that is exactly the same as the
2025-02-26 14:02:00.573 last executed command, the internally prepared `Statement` from last execution
2025-02-26 14:02:00.582 is reused.
2025-02-26 14:02:00.590
2025-02-26 14:02:00.599 If cursor is open, it's closed before new statement is executed.
2025-02-26 14:02:00.607 """
2025-02-26 14:02:00.614 > self._execute(operation, parameters)
2025-02-26 14:02:00.622
2025-02-26 14:02:00.629 ../lib/python3.11/site-packages/firebird/driver/core.py:3755:
2025-02-26 14:02:00.636 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:00.644
2025-02-26 14:02:00.654 self = <firebird.driver.core.Cursor object at [hex]>
2025-02-26 14:02:00.666 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
2025-02-26 14:02:00.678 flags = <CursorFlag.NONE: 0>
2025-02-26 14:02:00.692
2025-02-26 14:02:00.703 def _execute(self, operation: Union[str, Statement],
2025-02-26 14:02:00.713 parameters: Sequence=None, flags: CursorFlag=CursorFlag.NONE) -> None:
2025-02-26 14:02:00.720 if not self._transaction.is_active():
2025-02-26 14:02:00.725 self._transaction.begin()
2025-02-26 14:02:00.731 if isinstance(operation, Statement):
2025-02-26 14:02:00.740 if operation._connection() is not self._connection:
2025-02-26 14:02:00.752 raise InterfaceError('Cannot execute Statement that was created by different Connection.')
2025-02-26 14:02:00.761 self.close()
2025-02-26 14:02:00.769 self._stmt = operation
2025-02-26 14:02:00.777 self.__internal = False
2025-02-26 14:02:00.784 elif self._stmt is not None and self._stmt.sql == operation:
2025-02-26 14:02:00.791 # We should execute the same SQL string again
2025-02-26 14:02:00.798 self._clear()
2025-02-26 14:02:00.804 else:
2025-02-26 14:02:00.810 self.close()
2025-02-26 14:02:00.816 self._stmt = self._connection._prepare(operation, self._transaction)
2025-02-26 14:02:00.822 self.__internal = True
2025-02-26 14:02:00.827 self._cursor_flags = flags
2025-02-26 14:02:00.833 in_meta = None
2025-02-26 14:02:00.838 # Execute the statement
2025-02-26 14:02:00.845 try:
2025-02-26 14:02:00.851 if self._stmt._in_cnt > 0:
2025-02-26 14:02:00.857 in_meta, self._stmt._in_buffer = self._pack_input(self._stmt._in_meta,
2025-02-26 14:02:00.872 self._stmt._in_buffer,
2025-02-26 14:02:00.882 parameters)
2025-02-26 14:02:00.893 if self._stmt.has_cursor():
2025-02-26 14:02:00.901 # Statement returns multiple rows
2025-02-26 14:02:00.911 self._result = self._stmt._istmt.open_cursor(self._transaction._tra,
2025-02-26 14:02:00.919 in_meta, self._stmt._in_buffer,
2025-02-26 14:02:00.926 self._stmt._out_meta,
2025-02-26 14:02:00.935 flags)
2025-02-26 14:02:00.948 else:
2025-02-26 14:02:00.956 # Statement may return single row
2025-02-26 14:02:00.964 > self._stmt._istmt.execute(self._transaction._tra, in_meta,
2025-02-26 14:02:00.970 self._stmt._in_buffer,
2025-02-26 14:02:00.976 self._stmt._out_meta, self._stmt._out_buffer)
2025-02-26 14:02:00.982
2025-02-26 14:02:00.988 ../lib/python3.11/site-packages/firebird/driver/core.py:3643:
2025-02-26 14:02:00.994 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:01.002
2025-02-26 14:02:01.015 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-02-26 14:02:01.023 transaction = <firebird.driver.interfaces.iTransaction object at [hex]>
2025-02-26 14:02:01.030 in_meta = <firebird.driver.interfaces.iMessageMetadata object at [hex]>
2025-02-26 14:02:01.039 in_buffer = <ctypes.c_char_Array_10 object at [hex]>, out_meta = None
2025-02-26 14:02:01.046 out_buffer = None
2025-02-26 14:02:01.052
2025-02-26 14:02:01.057 def execute(self, transaction: iTransaction, in_meta: iMessageMetadata, in_buffer: bytes,
2025-02-26 14:02:01.063 out_meta: iMessageMetadata, out_buffer: bytes) -> None:
2025-02-26 14:02:01.077 """Executes any SQL statement except returning multiple rows of data.
2025-02-26 14:02:01.086 Partial analogue of `isc_dsql_execute2()` - in and out XSLQDAs replaced with input
2025-02-26 14:02:01.094 and output messages with appropriate buffers."""
2025-02-26 14:02:01.100 result = self.vtable.execute(self, self.status, transaction, in_meta, in_buffer, out_meta, out_buffer)
2025-02-26 14:02:01.106 > self._check()
2025-02-26 14:02:01.113
2025-02-26 14:02:01.119 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:778:
2025-02-26 14:02:01.136 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:01.146
2025-02-26 14:02:01.157 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-02-26 14:02:01.172
2025-02-26 14:02:01.179 def _check(self) -> None:
2025-02-26 14:02:01.185 state = self.status.get_state()
2025-02-26 14:02:01.191 if StateFlag.ERRORS in state:
2025-02-26 14:02:01.200 > raise self.__report(DatabaseError, self.status.get_errors())
2025-02-26 14:02:01.208 E firebird.driver.types.DatabaseError: Error reading data from the connection.
2025-02-26 14:02:01.216
2025-02-26 14:02:01.223 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-02-26 14:02:01.231
2025-02-26 14:02:01.244 During handling of the above exception, another exception occurred:
2025-02-26 14:02:01.254
2025-02-26 14:02:01.264 act = <firebird.qa.plugin.Action object at [hex]>
2025-02-26 14:02:01.278 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-02-26 14:02:01.292 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-26 14:02:01.306
2025-02-26 14:02:01.317 @pytest.mark.version('>=3.0.4')
2025-02-26 14:02:01.331 def test_1(act: Action, tmp_user: User, capsys):
2025-02-26 14:02:01.342
2025-02-26 14:02:01.349 init_ddl = [
2025-02-26 14:02:01.355 """
2025-02-26 14:02:01.361 set bail on;
2025-02-26 14:02:01.377 recreate sequence g;
2025-02-26 14:02:01.386 create table test(id int primary key, measure int, iter_no int);
2025-02-26 14:02:01.395
2025-02-26 14:02:01.403 create view v_test1 as select * from test;
2025-02-26 14:02:01.409 """
2025-02-26 14:02:01.417 ,'\n'.join( ['create view v_test%s as select * from v_test%s;' % (str(i), str(i-1)) for i in range(2,NESTED_LIMIT+1) ] )
2025-02-26 14:02:01.424 ,f"""
2025-02-26 14:02:01.431 commit;
2025-02-26 14:02:01.442
2025-02-26 14:02:01.450 set term ^;
2025-02-26 14:02:01.458 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-02-26 14:02:01.464 begin
2025-02-26 14:02:01.470 while ( n_iterations > 0 ) do
2025-02-26 14:02:01.477 begin
2025-02-26 14:02:01.486 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-02-26 14:02:01.492 n_iterations = n_iterations - 1;
2025-02-26 14:02:01.498 end
2025-02-26 14:02:01.506
2025-02-26 14:02:01.514 end
2025-02-26 14:02:01.524 ^
2025-02-26 14:02:01.534 set term ;^
2025-02-26 14:02:01.542 commit;
2025-02-26 14:02:01.550
2025-02-26 14:02:01.564 grant execute on procedure sp_run to {tmp_user.name};
2025-02-26 14:02:01.577 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-02-26 14:02:01.586 grant usage on sequence g to {tmp_user.name};
2025-02-26 14:02:01.594 commit;
2025-02-26 14:02:01.603
2025-02-26 14:02:01.610 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-02-26 14:02:01.619 commit;
2025-02-26 14:02:01.627 """
2025-02-26 14:02:01.634 ]
2025-02-26 14:02:01.640
2025-02-26 14:02:01.651 act.expected_stdout = ''
2025-02-26 14:02:01.661 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-02-26 14:02:01.669 assert act.clean_stdout == act.clean_expected_stdout
2025-02-26 14:02:01.677 act.reset()
2025-02-26 14:02:01.686
2025-02-26 14:02:01.694 #------------------------------------------------------------
2025-02-26 14:02:01.701
2025-02-26 14:02:01.708 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-02-26 14:02:01.715 > with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-02-26 14:02:01.721
2025-02-26 14:02:01.727 tests/bugs/gh_6220_test.py:131:
2025-02-26 14:02:01.735 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:01.742
2025-02-26 14:02:01.749 self = Connection[5434]
2025-02-26 14:02:01.755 exc_type = <class 'firebird.driver.types.DatabaseError'>
2025-02-26 14:02:01.762 exc_value = DatabaseError('Error reading data from the connection.')
2025-02-26 14:02:01.769 traceback = <traceback object at [hex]>
2025-02-26 14:02:01.776
2025-02-26 14:02:01.784 def __exit__(self, exc_type, exc_value, traceback) -> None:
2025-02-26 14:02:01.791 > self.close()
2025-02-26 14:02:01.798
2025-02-26 14:02:01.806 ../lib/python3.11/site-packages/firebird/driver/core.py:1666:
2025-02-26 14:02:01.813 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:01.819
2025-02-26 14:02:01.825 self = Connection[5434]
2025-02-26 14:02:01.830
2025-02-26 14:02:01.836 def close(self) -> None:
2025-02-26 14:02:01.841 """Close the connection and release all associated resources.
2025-02-26 14:02:01.847
2025-02-26 14:02:01.854 Closes all event collectors, transaction managers (with rollback) and statements
2025-02-26 14:02:01.861 associated with this connection before attempt (see Hooks) to close the
2025-02-26 14:02:01.866 connection itself.
2025-02-26 14:02:01.872
2025-02-26 14:02:01.879 Hooks:
2025-02-26 14:02:01.885 Event `.ConnectionHook.DETACH_REQUEST`: Executed before connection
2025-02-26 14:02:01.891 is closed. Hook must have signature::
2025-02-26 14:02:01.896
2025-02-26 14:02:01.902 hook_func(connection: Connection) -> bool
2025-02-26 14:02:01.907
2025-02-26 14:02:01.913 .. note::
2025-02-26 14:02:01.918
2025-02-26 14:02:01.928 If any hook function returns True, connection is NOT closed.
2025-02-26 14:02:01.937
2025-02-26 14:02:01.947 Event `.ConnectionHook.CLOSED`: Executed after connection is closed.
2025-02-26 14:02:01.956 Hook must have signature::
2025-02-26 14:02:01.967
2025-02-26 14:02:01.977 hook_func(connection: Connection) -> None
2025-02-26 14:02:01.987
2025-02-26 14:02:01.997 Any value returned by hook is ignored.
2025-02-26 14:02:02.006
2025-02-26 14:02:02.015 Important:
2025-02-26 14:02:02.023 Closed connection SHALL NOT be used anymore.
2025-02-26 14:02:02.032 """
2025-02-26 14:02:02.040 if not self.is_closed():
2025-02-26 14:02:02.052 retain = False
2025-02-26 14:02:02.061 try:
2025-02-26 14:02:02.069 > self._close()
2025-02-26 14:02:02.078
2025-02-26 14:02:02.091 ../lib/python3.11/site-packages/firebird/driver/core.py:1854:
2025-02-26 14:02:02.106 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.117
2025-02-26 14:02:02.128 self = Connection[5434]
2025-02-26 14:02:02.137
2025-02-26 14:02:02.148 def _close(self) -> None:
2025-02-26 14:02:02.158 if self.__schema is not None:
2025-02-26 14:02:02.168 self.__schema._set_internal(False)
2025-02-26 14:02:02.178 self.__schema.close()
2025-02-26 14:02:02.189 if self.__monitor is not None:
2025-02-26 14:02:02.198 self.__monitor._set_internal(False)
2025-02-26 14:02:02.206 self.__monitor.close()
2025-02-26 14:02:02.214 self._ic.close()
2025-02-26 14:02:02.224 for collector in self.__ecollectors:
2025-02-26 14:02:02.234 collector.close()
2025-02-26 14:02:02.242 > self.main_transaction._finish(DefaultAction.ROLLBACK)
2025-02-26 14:02:02.249
2025-02-26 14:02:02.257 ../lib/python3.11/site-packages/firebird/driver/core.py:1691:
2025-02-26 14:02:02.264 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.272
2025-02-26 14:02:02.279 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-02-26 14:02:02.286 default_action = <DefaultAction.ROLLBACK: 2>
2025-02-26 14:02:02.293
2025-02-26 14:02:02.301 def _finish(self, default_action: DefaultAction=None) -> None:
2025-02-26 14:02:02.311 try:
2025-02-26 14:02:02.320 if self._tra is not None:
2025-02-26 14:02:02.327 if default_action is None:
2025-02-26 14:02:02.334 default_action = self.default_action
2025-02-26 14:02:02.340 if default_action == DefaultAction.COMMIT:
2025-02-26 14:02:02.347 self.commit()
2025-02-26 14:02:02.353 else:
2025-02-26 14:02:02.361 > self.rollback()
2025-02-26 14:02:02.368
2025-02-26 14:02:02.375 ../lib/python3.11/site-packages/firebird/driver/core.py:2399:
2025-02-26 14:02:02.384 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.397
2025-02-26 14:02:02.405 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-02-26 14:02:02.413
2025-02-26 14:02:02.426 def rollback(self, *, retaining: bool=False, savepoint: str=None) -> None:
2025-02-26 14:02:02.435 """Rolls back the transaction managed by this instance.
2025-02-26 14:02:02.443
2025-02-26 14:02:02.450 Arguments:
2025-02-26 14:02:02.456 retaining: When True, the transaction context is retained after rollback.
2025-02-26 14:02:02.461 savepoint: When specified, the transaction is rolled back to savepoint with given name.
2025-02-26 14:02:02.468
2025-02-26 14:02:02.474 Raises:
2025-02-26 14:02:02.481 InterfaceError: When both retaining and savepoint parameters are specified.
2025-02-26 14:02:02.492 """
2025-02-26 14:02:02.501 assert not self.__closed
2025-02-26 14:02:02.508 assert self.is_active()
2025-02-26 14:02:02.515 if retaining and savepoint:
2025-02-26 14:02:02.523 raise InterfaceError("Can't rollback to savepoint while retaining context")
2025-02-26 14:02:02.531 if savepoint:
2025-02-26 14:02:02.541 self.execute_immediate(f'rollback to {savepoint}')
2025-02-26 14:02:02.551 else:
2025-02-26 14:02:02.558 if retaining:
2025-02-26 14:02:02.572 self._tra.rollback_retaining()
2025-02-26 14:02:02.584 else:
2025-02-26 14:02:02.592 > self._close_cursors()
2025-02-26 14:02:02.600
2025-02-26 14:02:02.611 ../lib/python3.11/site-packages/firebird/driver/core.py:2486:
2025-02-26 14:02:02.625 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.636
2025-02-26 14:02:02.644 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-02-26 14:02:02.651
2025-02-26 14:02:02.658 def _close_cursors(self) -> None:
2025-02-26 14:02:02.664 for cursor in self._cursors:
2025-02-26 14:02:02.670 c = cursor()
2025-02-26 14:02:02.677 if c:
2025-02-26 14:02:02.684 > c.close()
2025-02-26 14:02:02.691
2025-02-26 14:02:02.697 ../lib/python3.11/site-packages/firebird/driver/core.py:2388:
2025-02-26 14:02:02.710 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.725
2025-02-26 14:02:02.737 self = <firebird.driver.core.Cursor object at [hex]>
2025-02-26 14:02:02.745
2025-02-26 14:02:02.752 def close(self) -> None:
2025-02-26 14:02:02.759 """Close the cursor and release all associated resources.
2025-02-26 14:02:02.767
2025-02-26 14:02:02.775 The result set (if any) from last executed statement is released, and if executed
2025-02-26 14:02:02.782 `Statement` was not supplied externally, it's released as well.
2025-02-26 14:02:02.788
2025-02-26 14:02:02.795 Note:
2025-02-26 14:02:02.805 The closed cursor could be used to execute further SQL commands.
2025-02-26 14:02:02.814 """
2025-02-26 14:02:02.822 self._clear()
2025-02-26 14:02:02.829 if self._stmt is not None:
2025-02-26 14:02:02.834 if self.__internal:
2025-02-26 14:02:02.845 > self._stmt.free()
2025-02-26 14:02:02.858
2025-02-26 14:02:02.867 ../lib/python3.11/site-packages/firebird/driver/core.py:3791:
2025-02-26 14:02:02.880 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:02.890
2025-02-26 14:02:02.898 self = Statement[EXECUTE PROCEDURE sp_run ?,?]
2025-02-26 14:02:02.910
2025-02-26 14:02:02.921 def free(self) -> None:
2025-02-26 14:02:02.933 """Release the statement and all associated resources.
2025-02-26 14:02:02.945
2025-02-26 14:02:02.953 Important:
2025-02-26 14:02:02.960 The statement SHALL NOT be used after call to this method.
2025-02-26 14:02:02.967 """
2025-02-26 14:02:02.975 if self._in_meta is not None:
2025-02-26 14:02:02.987 self._in_meta.release()
2025-02-26 14:02:02.996 self._in_meta = None
2025-02-26 14:02:03.006 if self._out_meta is not None:
2025-02-26 14:02:03.015 self._out_meta.release()
2025-02-26 14:02:03.026 self._out_meta = None
2025-02-26 14:02:03.035 if self._istmt is not None:
2025-02-26 14:02:03.042 > self._istmt.free()
2025-02-26 14:02:03.049
2025-02-26 14:02:03.055 ../lib/python3.11/site-packages/firebird/driver/core.py:2736:
2025-02-26 14:02:03.062 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:03.069
2025-02-26 14:02:03.076 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-02-26 14:02:03.084
2025-02-26 14:02:03.092 def free(self) -> None:
2025-02-26 14:02:03.100 "Free statement, releases interface on success"
2025-02-26 14:02:03.108 self.vtable.free(self, self.status)
2025-02-26 14:02:03.115 > self._check()
2025-02-26 14:02:03.125
2025-02-26 14:02:03.140 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:832:
2025-02-26 14:02:03.150 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-26 14:02:03.157
2025-02-26 14:02:03.164 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-02-26 14:02:03.170
2025-02-26 14:02:03.177 def _check(self) -> None:
2025-02-26 14:02:03.184 state = self.status.get_state()
2025-02-26 14:02:03.190 if StateFlag.ERRORS in state:
2025-02-26 14:02:03.203 > raise self.__report(DatabaseError, self.status.get_errors())
2025-02-26 14:02:03.213 E firebird.driver.types.DatabaseError: Error writing data to the connection.
2025-02-26 14:02:03.221
2025-02-26 14:02:03.228 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-02-26 14:02:03.236 ---------------------------- Captured stdout setup -----------------------------
2025-02-26 14:02:03.244 Creating db: localhost:/var/tmp/qa_2024/test_11415/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
2025-02-26 14:02:03.253 CREATE user: TMP$GH_6220 PLUGIN: Srp
2025-02-26 14:02:03.261 --------------------------- Captured stdout teardown ---------------------------
2025-02-26 14:02:03.275 DROP user: TMP$GH_6220 PLUGIN: Srp
|
3 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
tmp_user = <firebird.qa.plugin.User pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.version('>=3.0.4')
def test_1(act: Action, tmp_user: User, capsys):
init_ddl = [
"""
set bail on;
recreate sequence g;
create table test(id int primary key, measure int, iter_no int);
create view v_test1 as select * from test;
"""
,'\n'.join( ['create view v_test%s as select * from v_test%s;' % (str(i), str(i-1)) for i in range(2,NESTED_LIMIT+1) ] )
,f"""
commit;
set term ^;
create procedure sp_run(a_measure smallint, n_iterations int) as
begin
while ( n_iterations > 0 ) do
begin
execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
n_iterations = n_iterations - 1;
end
end
^
set term ;^
commit;
grant execute on procedure sp_run to {tmp_user.name};
grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
grant usage on sequence g to {tmp_user.name};
commit;
insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
commit;
"""
]
act.expected_stdout = ''
act.isql(input = '\n'.join(init_ddl), combine_output = True)
assert act.clean_stdout == act.clean_expected_stdout
act.reset()
#------------------------------------------------------------
pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
cur_sysdba = con_sysdba.cursor()
cur_nondba = con_nondba.cursor()
cur_sysdba.execute(pid_sttm)
cur_nondba.execute(pid_sttm)
pid_sysdba = cur_sysdba.fetchone()[0]
pid_nondba = cur_nondba.fetchone()[0]
sp_time = {}
for who in (act.db.user, tmp_user.name):
fb_pid = pid_sysdba if who == act.db.user else pid_nondba
con = con_sysdba if who == act.db.user else con_nondba
cur = cur_sysdba if who == act.db.user else cur_nondba
for iter_no in range(0, N_MEASURES):
fb_info_init = psutil.Process(fb_pid).cpu_times()
> cur.callproc( 'sp_run', (iter_no, N_COUNT_PER_MEASURE,) )
tests/bugs/gh_6220_test.py:147:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.Cursor pytest object at [hex]>
proc_name = 'sp_run', parameters = (18, 100)
def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
"""Executes a stored procedure with the given name.
Arguments:
proc_name: Stored procedure name.
parameters: Sequence of parameters. Must contain one entry for each argument
that the procedure expects.
.. note::
If stored procedure does have output parameters, you must retrieve their values
saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
but conforms to Python DB API 2.0. If you don't require conformance to Python
DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
instead.
"""
params = [] if parameters is None else parameters
sql = ('EXECUTE PROCEDURE ' + proc_name + ' '
+ ','.join('?' * len(params)))
> self.execute(sql, params)
../lib/python3.11/site-packages/firebird/driver/core.py:3682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.Cursor pytest object at [hex]>
operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
def execute(self, operation: Union[str, Statement], parameters: Sequence[Any]=None) -> Cursor:
"""Executes SQL command or prepared `Statement`.
Starts new transaction if transaction manager associated with cursor is not active.
Arguments:
operation: SQL command or prepared `Statement`.
parameters: Sequence of parameters. Must contain one entry for each argument
that the operation expects.
Returns:
`self` so call to execute could be used as iterator over returned rows.
Note:
If `operation` is a string with SQL command that is exactly the same as the
last executed command, the internally prepared `Statement` from last execution
is reused.
If cursor is open, it's closed before new statement is executed.
"""
> self._execute(operation, parameters)
../lib/python3.11/site-packages/firebird/driver/core.py:3755:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.Cursor pytest object at [hex]>
operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
flags = <CursorFlag.NONE: 0>
def _execute(self, operation: Union[str, Statement],
parameters: Sequence=None, flags: CursorFlag=CursorFlag.NONE) -> None:
if not self._transaction.is_active():
self._transaction.begin()
if isinstance(operation, Statement):
if operation._connection() is not self._connection:
raise InterfaceError('Cannot execute Statement that was created by different Connection.')
self.close()
self._stmt = operation
self.__internal = False
elif self._stmt is not None and self._stmt.sql == operation:
# We should execute the same SQL string again
self._clear()
else:
self.close()
self._stmt = self._connection._prepare(operation, self._transaction)
self.__internal = True
self._cursor_flags = flags
in_meta = None
# Execute the statement
try:
if self._stmt._in_cnt > 0:
in_meta, self._stmt._in_buffer = self._pack_input(self._stmt._in_meta,
self._stmt._in_buffer,
parameters)
if self._stmt.has_cursor():
# Statement returns multiple rows
self._result = self._stmt._istmt.open_cursor(self._transaction._tra,
in_meta, self._stmt._in_buffer,
self._stmt._out_meta,
flags)
else:
# Statement may return single row
> self._stmt._istmt.execute(self._transaction._tra, in_meta,
self._stmt._in_buffer,
self._stmt._out_meta, self._stmt._out_buffer)
../lib/python3.11/site-packages/firebird/driver/core.py:3643:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.interfaces.iStatement pytest object at [hex]>
transaction = <firebird.driver.interfaces.iTransaction pytest object at [hex]>
in_meta = <firebird.driver.interfaces.iMessageMetadata pytest object at [hex]>
in_buffer = <ctypes.c_char_Array_10 pytest object at [hex]>, out_meta = None
out_buffer = None
def execute(self, transaction: iTransaction, in_meta: iMessageMetadata, in_buffer: bytes,
out_meta: iMessageMetadata, out_buffer: bytes) -> None:
"""Executes any SQL statement except returning multiple rows of data.
Partial analogue of `isc_dsql_execute2()` - in and out XSLQDAs replaced with input
and output messages with appropriate buffers."""
result = self.vtable.execute(self, self.status, transaction, in_meta, in_buffer, out_meta, out_buffer)
> self._check()
../lib/python3.11/site-packages/firebird/driver/interfaces.py:778:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.interfaces.iStatement 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: Error reading data from the connection.
../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
During handling of the above exception, another exception occurred:
act = <firebird.qa.plugin.Action pytest object at [hex]>
tmp_user = <firebird.qa.plugin.User pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.version('>=3.0.4')
def test_1(act: Action, tmp_user: User, capsys):
init_ddl = [
"""
set bail on;
recreate sequence g;
create table test(id int primary key, measure int, iter_no int);
create view v_test1 as select * from test;
"""
,'\n'.join( ['create view v_test%s as select * from v_test%s;' % (str(i), str(i-1)) for i in range(2,NESTED_LIMIT+1) ] )
,f"""
commit;
set term ^;
create procedure sp_run(a_measure smallint, n_iterations int) as
begin
while ( n_iterations > 0 ) do
begin
execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
n_iterations = n_iterations - 1;
end
end
^
set term ;^
commit;
grant execute on procedure sp_run to {tmp_user.name};
grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
grant usage on sequence g to {tmp_user.name};
commit;
insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
commit;
"""
]
act.expected_stdout = ''
act.isql(input = '\n'.join(init_ddl), combine_output = True)
assert act.clean_stdout == act.clean_expected_stdout
act.reset()
#------------------------------------------------------------
pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
> with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
tests/bugs/gh_6220_test.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Connection[5434]
exc_type = <class 'firebird.driver.types.DatabaseError'>
exc_value = DatabaseError('Error reading data from the connection.')
traceback = <traceback pytest object at [hex]>
def __exit__(self, exc_type, exc_value, traceback) -> None:
> self.close()
../lib/python3.11/site-packages/firebird/driver/core.py:1666:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Connection[5434]
def close(self) -> None:
"""Close the connection and release all associated resources.
Closes all event collectors, transaction managers (with rollback) and statements
associated with this connection before attempt (see Hooks) to close the
connection itself.
Hooks:
Event `.ConnectionHook.DETACH_REQUEST`: Executed before connection
is closed. Hook must have signature::
hook_func(connection: Connection) -> bool
.. note::
If any hook function returns True, connection is NOT closed.
Event `.ConnectionHook.CLOSED`: Executed after connection is closed.
Hook must have signature::
hook_func(connection: Connection) -> None
Any value returned by hook is ignored.
Important:
Closed connection SHALL NOT be used anymore.
"""
if not self.is_closed():
retain = False
try:
> self._close()
../lib/python3.11/site-packages/firebird/driver/core.py:1854:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Connection[5434]
def _close(self) -> None:
if self.__schema is not None:
self.__schema._set_internal(False)
self.__schema.close()
if self.__monitor is not None:
self.__monitor._set_internal(False)
self.__monitor.close()
self._ic.close()
for collector in self.__ecollectors:
collector.close()
> self.main_transaction._finish(DefaultAction.ROLLBACK)
../lib/python3.11/site-packages/firebird/driver/core.py:1691:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.TransactionManager pytest object at [hex]>
default_action = <DefaultAction.ROLLBACK: 2>
def _finish(self, default_action: DefaultAction=None) -> None:
try:
if self._tra is not None:
if default_action is None:
default_action = self.default_action
if default_action == DefaultAction.COMMIT:
self.commit()
else:
> self.rollback()
../lib/python3.11/site-packages/firebird/driver/core.py:2399:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.TransactionManager pytest object at [hex]>
def rollback(self, *, retaining: bool=False, savepoint: str=None) -> None:
"""Rolls back the transaction managed by this instance.
Arguments:
retaining: When True, the transaction context is retained after rollback.
savepoint: When specified, the transaction is rolled back to savepoint with given name.
Raises:
InterfaceError: When both retaining and savepoint parameters are specified.
"""
assert not self.__closed
assert self.is_active()
if retaining and savepoint:
raise InterfaceError("Can't rollback to savepoint while retaining context")
if savepoint:
self.execute_immediate(f'rollback to {savepoint}')
else:
if retaining:
self._tra.rollback_retaining()
else:
> self._close_cursors()
../lib/python3.11/site-packages/firebird/driver/core.py:2486:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.TransactionManager pytest object at [hex]>
def _close_cursors(self) -> None:
for cursor in self._cursors:
c = cursor()
if c:
> c.close()
../lib/python3.11/site-packages/firebird/driver/core.py:2388:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.core.Cursor pytest object at [hex]>
def close(self) -> None:
"""Close the cursor and release all associated resources.
The result set (if any) from last executed statement is released, and if executed
`Statement` was not supplied externally, it's released as well.
Note:
The closed cursor could be used to execute further SQL commands.
"""
self._clear()
if self._stmt is not None:
if self.__internal:
> self._stmt.free()
../lib/python3.11/site-packages/firebird/driver/core.py:3791:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Statement[EXECUTE PROCEDURE sp_run ?,?]
def free(self) -> None:
"""Release the statement and all associated resources.
Important:
The statement SHALL NOT be used after call to this method.
"""
if self._in_meta is not None:
self._in_meta.release()
self._in_meta = None
if self._out_meta is not None:
self._out_meta.release()
self._out_meta = None
if self._istmt is not None:
> self._istmt.free()
../lib/python3.11/site-packages/firebird/driver/core.py:2736:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.interfaces.iStatement pytest object at [hex]>
def free(self) -> None:
"Free statement, releases interface on success"
self.vtable.free(self, self.status)
> self._check()
../lib/python3.11/site-packages/firebird/driver/interfaces.py:832:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <firebird.driver.interfaces.iStatement 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: Error writing data to the connection.
../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
|