2 @message |
Server crashed ?
firebird.driver.types.DatabaseError: Error writing data to the connection.
LOG DETAILS:
2025-03-17 11:58:23.391
2025-03-17 11:58:23.406 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-17 11:58:23.416 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-17 11:58:23.423 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-17 11:58:23.430
2025-03-17 11:58:23.437 @pytest.mark.version('>=3.0.4')
2025-03-17 11:58:23.449 def test_1(act: Action, tmp_user: User, capsys):
2025-03-17 11:58:23.465
2025-03-17 11:58:23.476 init_ddl = [
2025-03-17 11:58:23.485 """
2025-03-17 11:58:23.492 set bail on;
2025-03-17 11:58:23.500 recreate sequence g;
2025-03-17 11:58:23.507 create table test(id int primary key, measure int, iter_no int);
2025-03-17 11:58:23.515
2025-03-17 11:58:23.529 create view v_test1 as select * from test;
2025-03-17 11:58:23.542 """
2025-03-17 11:58:23.554 ,'\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-03-17 11:58:23.567 ,f"""
2025-03-17 11:58:23.577 commit;
2025-03-17 11:58:23.587
2025-03-17 11:58:23.599 set term ^;
2025-03-17 11:58:23.609 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-17 11:58:23.623 begin
2025-03-17 11:58:23.635 while ( n_iterations > 0 ) do
2025-03-17 11:58:23.644 begin
2025-03-17 11:58:23.655 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-17 11:58:23.670 n_iterations = n_iterations - 1;
2025-03-17 11:58:23.682 end
2025-03-17 11:58:23.697
2025-03-17 11:58:23.707 end
2025-03-17 11:58:23.713 ^
2025-03-17 11:58:23.719 set term ;^
2025-03-17 11:58:23.724 commit;
2025-03-17 11:58:23.729
2025-03-17 11:58:23.735 grant execute on procedure sp_run to {tmp_user.name};
2025-03-17 11:58:23.740 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-17 11:58:23.745 grant usage on sequence g to {tmp_user.name};
2025-03-17 11:58:23.750 commit;
2025-03-17 11:58:23.755
2025-03-17 11:58:23.760 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-17 11:58:23.765 commit;
2025-03-17 11:58:23.770 """
2025-03-17 11:58:23.775 ]
2025-03-17 11:58:23.780
2025-03-17 11:58:23.785 act.expected_stdout = ''
2025-03-17 11:58:23.790 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-17 11:58:23.795 assert act.clean_stdout == act.clean_expected_stdout
2025-03-17 11:58:23.801 act.reset()
2025-03-17 11:58:23.806
2025-03-17 11:58:23.811 #------------------------------------------------------------
2025-03-17 11:58:23.816
2025-03-17 11:58:23.823 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-17 11:58:23.829 with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-17 11:58:23.834 cur_sysdba = con_sysdba.cursor()
2025-03-17 11:58:23.839 cur_nondba = con_nondba.cursor()
2025-03-17 11:58:23.844 cur_sysdba.execute(pid_sttm)
2025-03-17 11:58:23.850 cur_nondba.execute(pid_sttm)
2025-03-17 11:58:23.855 pid_sysdba = cur_sysdba.fetchone()[0]
2025-03-17 11:58:23.861 pid_nondba = cur_nondba.fetchone()[0]
2025-03-17 11:58:23.866
2025-03-17 11:58:23.871 sp_time = {}
2025-03-17 11:58:23.884 for who in (act.db.user, tmp_user.name):
2025-03-17 11:58:23.895 fb_pid = pid_sysdba if who == act.db.user else pid_nondba
2025-03-17 11:58:23.904 con = con_sysdba if who == act.db.user else con_nondba
2025-03-17 11:58:23.916 cur = cur_sysdba if who == act.db.user else cur_nondba
2025-03-17 11:58:23.928
2025-03-17 11:58:23.936 for iter_no in range(0, N_MEASURES):
2025-03-17 11:58:23.943 fb_info_init = psutil.Process(fb_pid).cpu_times()
2025-03-17 11:58:23.950 > cur.callproc( 'sp_run', (iter_no, N_COUNT_PER_MEASURE,) )
2025-03-17 11:58:23.964
2025-03-17 11:58:23.975 tests/bugs/gh_6220_test.py:147:
2025-03-17 11:58:23.985 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:23.995
2025-03-17 11:58:24.003 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-17 11:58:24.011 proc_name = 'sp_run', parameters = (18, 100)
2025-03-17 11:58:24.018
2025-03-17 11:58:24.023 def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
2025-03-17 11:58:24.028 """Executes a stored procedure with the given name.
2025-03-17 11:58:24.033
2025-03-17 11:58:24.038 Arguments:
2025-03-17 11:58:24.043 proc_name: Stored procedure name.
2025-03-17 11:58:24.048 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-17 11:58:24.053 that the procedure expects.
2025-03-17 11:58:24.058
2025-03-17 11:58:24.063 .. note::
2025-03-17 11:58:24.068
2025-03-17 11:58:24.073 If stored procedure does have output parameters, you must retrieve their values
2025-03-17 11:58:24.078 saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
2025-03-17 11:58:24.083 but conforms to Python DB API 2.0. If you don't require conformance to Python
2025-03-17 11:58:24.088 DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
2025-03-17 11:58:24.097 instead.
2025-03-17 11:58:24.111 """
2025-03-17 11:58:24.120 params = [] if parameters is None else parameters
2025-03-17 11:58:24.128 sql = ('EXECUTE PROCEDURE ' + proc_name + ' '
2025-03-17 11:58:24.136 + ','.join('?' * len(params)))
2025-03-17 11:58:24.143 > self.execute(sql, params)
2025-03-17 11:58:24.150
2025-03-17 11:58:24.158 ../lib/python3.11/site-packages/firebird/driver/core.py:3682:
2025-03-17 11:58:24.171 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:24.180
2025-03-17 11:58:24.196 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-17 11:58:24.209 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
2025-03-17 11:58:24.223
2025-03-17 11:58:24.233 def execute(self, operation: Union[str, Statement], parameters: Sequence[Any]=None) -> Cursor:
2025-03-17 11:58:24.241 """Executes SQL command or prepared `Statement`.
2025-03-17 11:58:24.247
2025-03-17 11:58:24.254 Starts new transaction if transaction manager associated with cursor is not active.
2025-03-17 11:58:24.260
2025-03-17 11:58:24.267 Arguments:
2025-03-17 11:58:24.273 operation: SQL command or prepared `Statement`.
2025-03-17 11:58:24.280 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-17 11:58:24.286 that the operation expects.
2025-03-17 11:58:24.292
2025-03-17 11:58:24.299 Returns:
2025-03-17 11:58:24.305 `self` so call to execute could be used as iterator over returned rows.
2025-03-17 11:58:24.312
2025-03-17 11:58:24.319 Note:
2025-03-17 11:58:24.325 If `operation` is a string with SQL command that is exactly the same as the
2025-03-17 11:58:24.332 last executed command, the internally prepared `Statement` from last execution
2025-03-17 11:58:24.337 is reused.
2025-03-17 11:58:24.342
2025-03-17 11:58:24.347 If cursor is open, it's closed before new statement is executed.
2025-03-17 11:58:24.352 """
2025-03-17 11:58:24.358 > self._execute(operation, parameters)
2025-03-17 11:58:24.363
2025-03-17 11:58:24.368 ../lib/python3.11/site-packages/firebird/driver/core.py:3755:
2025-03-17 11:58:24.373 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:24.378
2025-03-17 11:58:24.383 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-17 11:58:24.388 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (18, 100)
2025-03-17 11:58:24.393 flags = <CursorFlag.NONE: 0>
2025-03-17 11:58:24.399
2025-03-17 11:58:24.404 def _execute(self, operation: Union[str, Statement],
2025-03-17 11:58:24.409 parameters: Sequence=None, flags: CursorFlag=CursorFlag.NONE) -> None:
2025-03-17 11:58:24.414 if not self._transaction.is_active():
2025-03-17 11:58:24.419 self._transaction.begin()
2025-03-17 11:58:24.424 if isinstance(operation, Statement):
2025-03-17 11:58:24.429 if operation._connection() is not self._connection:
2025-03-17 11:58:24.434 raise InterfaceError('Cannot execute Statement that was created by different Connection.')
2025-03-17 11:58:24.439 self.close()
2025-03-17 11:58:24.444 self._stmt = operation
2025-03-17 11:58:24.449 self.__internal = False
2025-03-17 11:58:24.455 elif self._stmt is not None and self._stmt.sql == operation:
2025-03-17 11:58:24.460 # We should execute the same SQL string again
2025-03-17 11:58:24.465 self._clear()
2025-03-17 11:58:24.470 else:
2025-03-17 11:58:24.475 self.close()
2025-03-17 11:58:24.480 self._stmt = self._connection._prepare(operation, self._transaction)
2025-03-17 11:58:24.485 self.__internal = True
2025-03-17 11:58:24.490 self._cursor_flags = flags
2025-03-17 11:58:24.495 in_meta = None
2025-03-17 11:58:24.499 # Execute the statement
2025-03-17 11:58:24.504 try:
2025-03-17 11:58:24.509 if self._stmt._in_cnt > 0:
2025-03-17 11:58:24.514 in_meta, self._stmt._in_buffer = self._pack_input(self._stmt._in_meta,
2025-03-17 11:58:24.520 self._stmt._in_buffer,
2025-03-17 11:58:24.525 parameters)
2025-03-17 11:58:24.530 if self._stmt.has_cursor():
2025-03-17 11:58:24.535 # Statement returns multiple rows
2025-03-17 11:58:24.540 self._result = self._stmt._istmt.open_cursor(self._transaction._tra,
2025-03-17 11:58:24.546 in_meta, self._stmt._in_buffer,
2025-03-17 11:58:24.552 self._stmt._out_meta,
2025-03-17 11:58:24.557 flags)
2025-03-17 11:58:24.563 else:
2025-03-17 11:58:24.568 # Statement may return single row
2025-03-17 11:58:24.573 > self._stmt._istmt.execute(self._transaction._tra, in_meta,
2025-03-17 11:58:24.579 self._stmt._in_buffer,
2025-03-17 11:58:24.584 self._stmt._out_meta, self._stmt._out_buffer)
2025-03-17 11:58:24.589
2025-03-17 11:58:24.594 ../lib/python3.11/site-packages/firebird/driver/core.py:3643:
2025-03-17 11:58:24.599 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:24.605
2025-03-17 11:58:24.611 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-17 11:58:24.615 transaction = <firebird.driver.interfaces.iTransaction object at [hex]>
2025-03-17 11:58:24.620 in_meta = <firebird.driver.interfaces.iMessageMetadata object at [hex]>
2025-03-17 11:58:24.625 in_buffer = <ctypes.c_char_Array_10 object at [hex]>, out_meta = None
2025-03-17 11:58:24.630 out_buffer = None
2025-03-17 11:58:24.635
2025-03-17 11:58:24.641 def execute(self, transaction: iTransaction, in_meta: iMessageMetadata, in_buffer: bytes,
2025-03-17 11:58:24.646 out_meta: iMessageMetadata, out_buffer: bytes) -> None:
2025-03-17 11:58:24.651 """Executes any SQL statement except returning multiple rows of data.
2025-03-17 11:58:24.656 Partial analogue of `isc_dsql_execute2()` - in and out XSLQDAs replaced with input
2025-03-17 11:58:24.661 and output messages with appropriate buffers."""
2025-03-17 11:58:24.667 result = self.vtable.execute(self, self.status, transaction, in_meta, in_buffer, out_meta, out_buffer)
2025-03-17 11:58:24.672 > self._check()
2025-03-17 11:58:24.677
2025-03-17 11:58:24.683 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:778:
2025-03-17 11:58:24.688 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:24.694
2025-03-17 11:58:24.700 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-17 11:58:24.705
2025-03-17 11:58:24.710 def _check(self) -> None:
2025-03-17 11:58:24.715 state = self.status.get_state()
2025-03-17 11:58:24.721 if StateFlag.ERRORS in state:
2025-03-17 11:58:24.726 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-17 11:58:24.731 E firebird.driver.types.DatabaseError: Error reading data from the connection.
2025-03-17 11:58:24.736
2025-03-17 11:58:24.742 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-17 11:58:24.747
2025-03-17 11:58:24.752 During handling of the above exception, another exception occurred:
2025-03-17 11:58:24.757
2025-03-17 11:58:24.762 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-17 11:58:24.768 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-17 11:58:24.773 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-17 11:58:24.779
2025-03-17 11:58:24.784 @pytest.mark.version('>=3.0.4')
2025-03-17 11:58:24.790 def test_1(act: Action, tmp_user: User, capsys):
2025-03-17 11:58:24.795
2025-03-17 11:58:24.800 init_ddl = [
2025-03-17 11:58:24.805 """
2025-03-17 11:58:24.811 set bail on;
2025-03-17 11:58:24.817 recreate sequence g;
2025-03-17 11:58:24.822 create table test(id int primary key, measure int, iter_no int);
2025-03-17 11:58:24.827
2025-03-17 11:58:24.832 create view v_test1 as select * from test;
2025-03-17 11:58:24.838 """
2025-03-17 11:58:24.845 ,'\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-03-17 11:58:24.851 ,f"""
2025-03-17 11:58:24.856 commit;
2025-03-17 11:58:24.863
2025-03-17 11:58:24.869 set term ^;
2025-03-17 11:58:24.875 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-17 11:58:24.880 begin
2025-03-17 11:58:24.886 while ( n_iterations > 0 ) do
2025-03-17 11:58:24.892 begin
2025-03-17 11:58:24.897 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-17 11:58:24.902 n_iterations = n_iterations - 1;
2025-03-17 11:58:24.908 end
2025-03-17 11:58:24.915
2025-03-17 11:58:24.925 end
2025-03-17 11:58:24.932 ^
2025-03-17 11:58:24.939 set term ;^
2025-03-17 11:58:24.952 commit;
2025-03-17 11:58:24.962
2025-03-17 11:58:24.969 grant execute on procedure sp_run to {tmp_user.name};
2025-03-17 11:58:24.977 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-17 11:58:24.984 grant usage on sequence g to {tmp_user.name};
2025-03-17 11:58:24.990 commit;
2025-03-17 11:58:24.997
2025-03-17 11:58:25.005 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-17 11:58:25.016 commit;
2025-03-17 11:58:25.029 """
2025-03-17 11:58:25.039 ]
2025-03-17 11:58:25.052
2025-03-17 11:58:25.063 act.expected_stdout = ''
2025-03-17 11:58:25.071 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-17 11:58:25.079 assert act.clean_stdout == act.clean_expected_stdout
2025-03-17 11:58:25.092 act.reset()
2025-03-17 11:58:25.105
2025-03-17 11:58:25.117 #------------------------------------------------------------
2025-03-17 11:58:25.129
2025-03-17 11:58:25.141 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-17 11:58:25.153 > with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-17 11:58:25.162
2025-03-17 11:58:25.173 tests/bugs/gh_6220_test.py:131:
2025-03-17 11:58:25.185 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:25.192
2025-03-17 11:58:25.197 self = Connection[5442]
2025-03-17 11:58:25.203 exc_type = <class 'firebird.driver.types.DatabaseError'>
2025-03-17 11:58:25.208 exc_value = DatabaseError('Error reading data from the connection.')
2025-03-17 11:58:25.214 traceback = <traceback object at [hex]>
2025-03-17 11:58:25.219
2025-03-17 11:58:25.226 def __exit__(self, exc_type, exc_value, traceback) -> None:
2025-03-17 11:58:25.235 > self.close()
2025-03-17 11:58:25.249
2025-03-17 11:58:25.262 ../lib/python3.11/site-packages/firebird/driver/core.py:1666:
2025-03-17 11:58:25.273 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:25.282
2025-03-17 11:58:25.291 self = Connection[5442]
2025-03-17 11:58:25.306
2025-03-17 11:58:25.321 def close(self) -> None:
2025-03-17 11:58:25.331 """Close the connection and release all associated resources.
2025-03-17 11:58:25.344
2025-03-17 11:58:25.360 Closes all event collectors, transaction managers (with rollback) and statements
2025-03-17 11:58:25.374 associated with this connection before attempt (see Hooks) to close the
2025-03-17 11:58:25.385 connection itself.
2025-03-17 11:58:25.392
2025-03-17 11:58:25.399 Hooks:
2025-03-17 11:58:25.407 Event `.ConnectionHook.DETACH_REQUEST`: Executed before connection
2025-03-17 11:58:25.414 is closed. Hook must have signature::
2025-03-17 11:58:25.428
2025-03-17 11:58:25.441 hook_func(connection: Connection) -> bool
2025-03-17 11:58:25.450
2025-03-17 11:58:25.457 .. note::
2025-03-17 11:58:25.463
2025-03-17 11:58:25.470 If any hook function returns True, connection is NOT closed.
2025-03-17 11:58:25.482
2025-03-17 11:58:25.491 Event `.ConnectionHook.CLOSED`: Executed after connection is closed.
2025-03-17 11:58:25.499 Hook must have signature::
2025-03-17 11:58:25.507
2025-03-17 11:58:25.520 hook_func(connection: Connection) -> None
2025-03-17 11:58:25.536
2025-03-17 11:58:25.551 Any value returned by hook is ignored.
2025-03-17 11:58:25.564
2025-03-17 11:58:25.574 Important:
2025-03-17 11:58:25.582 Closed connection SHALL NOT be used anymore.
2025-03-17 11:58:25.589 """
2025-03-17 11:58:25.597 if not self.is_closed():
2025-03-17 11:58:25.603 retain = False
2025-03-17 11:58:25.615 try:
2025-03-17 11:58:25.629 > self._close()
2025-03-17 11:58:25.641
2025-03-17 11:58:25.656 ../lib/python3.11/site-packages/firebird/driver/core.py:1854:
2025-03-17 11:58:25.668 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:25.684
2025-03-17 11:58:25.697 self = Connection[5442]
2025-03-17 11:58:25.710
2025-03-17 11:58:25.720 def _close(self) -> None:
2025-03-17 11:58:25.729 if self.__schema is not None:
2025-03-17 11:58:25.743 self.__schema._set_internal(False)
2025-03-17 11:58:25.757 self.__schema.close()
2025-03-17 11:58:25.769 if self.__monitor is not None:
2025-03-17 11:58:25.780 self.__monitor._set_internal(False)
2025-03-17 11:58:25.795 self.__monitor.close()
2025-03-17 11:58:25.806 self._ic.close()
2025-03-17 11:58:25.822 for collector in self.__ecollectors:
2025-03-17 11:58:25.835 collector.close()
2025-03-17 11:58:25.848 > self.main_transaction._finish(DefaultAction.ROLLBACK)
2025-03-17 11:58:25.857
2025-03-17 11:58:25.870 ../lib/python3.11/site-packages/firebird/driver/core.py:1691:
2025-03-17 11:58:25.888 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:25.901
2025-03-17 11:58:25.910 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-17 11:58:25.917 default_action = <DefaultAction.ROLLBACK: 2>
2025-03-17 11:58:25.925
2025-03-17 11:58:25.931 def _finish(self, default_action: DefaultAction=None) -> None:
2025-03-17 11:58:25.938 try:
2025-03-17 11:58:25.944 if self._tra is not None:
2025-03-17 11:58:25.950 if default_action is None:
2025-03-17 11:58:25.959 default_action = self.default_action
2025-03-17 11:58:25.971 if default_action == DefaultAction.COMMIT:
2025-03-17 11:58:25.982 self.commit()
2025-03-17 11:58:25.996 else:
2025-03-17 11:58:26.006 > self.rollback()
2025-03-17 11:58:26.014
2025-03-17 11:58:26.023 ../lib/python3.11/site-packages/firebird/driver/core.py:2399:
2025-03-17 11:58:26.031 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.038
2025-03-17 11:58:26.049 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-17 11:58:26.063
2025-03-17 11:58:26.077 def rollback(self, *, retaining: bool=False, savepoint: str=None) -> None:
2025-03-17 11:58:26.088 """Rolls back the transaction managed by this instance.
2025-03-17 11:58:26.097
2025-03-17 11:58:26.110 Arguments:
2025-03-17 11:58:26.125 retaining: When True, the transaction context is retained after rollback.
2025-03-17 11:58:26.137 savepoint: When specified, the transaction is rolled back to savepoint with given name.
2025-03-17 11:58:26.152
2025-03-17 11:58:26.166 Raises:
2025-03-17 11:58:26.176 InterfaceError: When both retaining and savepoint parameters are specified.
2025-03-17 11:58:26.184 """
2025-03-17 11:58:26.192 assert not self.__closed
2025-03-17 11:58:26.199 assert self.is_active()
2025-03-17 11:58:26.206 if retaining and savepoint:
2025-03-17 11:58:26.213 raise InterfaceError("Can't rollback to savepoint while retaining context")
2025-03-17 11:58:26.223 if savepoint:
2025-03-17 11:58:26.231 self.execute_immediate(f'rollback to {savepoint}')
2025-03-17 11:58:26.238 else:
2025-03-17 11:58:26.245 if retaining:
2025-03-17 11:58:26.251 self._tra.rollback_retaining()
2025-03-17 11:58:26.260 else:
2025-03-17 11:58:26.273 > self._close_cursors()
2025-03-17 11:58:26.282
2025-03-17 11:58:26.290 ../lib/python3.11/site-packages/firebird/driver/core.py:2486:
2025-03-17 11:58:26.298 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.308
2025-03-17 11:58:26.314 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-17 11:58:26.321
2025-03-17 11:58:26.328 def _close_cursors(self) -> None:
2025-03-17 11:58:26.335 for cursor in self._cursors:
2025-03-17 11:58:26.342 c = cursor()
2025-03-17 11:58:26.348 if c:
2025-03-17 11:58:26.355 > c.close()
2025-03-17 11:58:26.364
2025-03-17 11:58:26.377 ../lib/python3.11/site-packages/firebird/driver/core.py:2388:
2025-03-17 11:58:26.387 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.395
2025-03-17 11:58:26.404 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-17 11:58:26.411
2025-03-17 11:58:26.419 def close(self) -> None:
2025-03-17 11:58:26.424 """Close the cursor and release all associated resources.
2025-03-17 11:58:26.430
2025-03-17 11:58:26.437 The result set (if any) from last executed statement is released, and if executed
2025-03-17 11:58:26.444 `Statement` was not supplied externally, it's released as well.
2025-03-17 11:58:26.450
2025-03-17 11:58:26.457 Note:
2025-03-17 11:58:26.463 The closed cursor could be used to execute further SQL commands.
2025-03-17 11:58:26.470 """
2025-03-17 11:58:26.479 self._clear()
2025-03-17 11:58:26.486 if self._stmt is not None:
2025-03-17 11:58:26.492 if self.__internal:
2025-03-17 11:58:26.497 > self._stmt.free()
2025-03-17 11:58:26.506
2025-03-17 11:58:26.521 ../lib/python3.11/site-packages/firebird/driver/core.py:3791:
2025-03-17 11:58:26.532 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.542
2025-03-17 11:58:26.555 self = Statement[EXECUTE PROCEDURE sp_run ?,?]
2025-03-17 11:58:26.566
2025-03-17 11:58:26.577 def free(self) -> None:
2025-03-17 11:58:26.588 """Release the statement and all associated resources.
2025-03-17 11:58:26.601
2025-03-17 11:58:26.613 Important:
2025-03-17 11:58:26.624 The statement SHALL NOT be used after call to this method.
2025-03-17 11:58:26.632 """
2025-03-17 11:58:26.639 if self._in_meta is not None:
2025-03-17 11:58:26.645 self._in_meta.release()
2025-03-17 11:58:26.651 self._in_meta = None
2025-03-17 11:58:26.658 if self._out_meta is not None:
2025-03-17 11:58:26.671 self._out_meta.release()
2025-03-17 11:58:26.679 self._out_meta = None
2025-03-17 11:58:26.690 if self._istmt is not None:
2025-03-17 11:58:26.702 > self._istmt.free()
2025-03-17 11:58:26.713
2025-03-17 11:58:26.722 ../lib/python3.11/site-packages/firebird/driver/core.py:2736:
2025-03-17 11:58:26.734 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.746
2025-03-17 11:58:26.759 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-17 11:58:26.773
2025-03-17 11:58:26.784 def free(self) -> None:
2025-03-17 11:58:26.800 "Free statement, releases interface on success"
2025-03-17 11:58:26.813 self.vtable.free(self, self.status)
2025-03-17 11:58:26.827 > self._check()
2025-03-17 11:58:26.844
2025-03-17 11:58:26.853 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:832:
2025-03-17 11:58:26.863 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-17 11:58:26.876
2025-03-17 11:58:26.888 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-17 11:58:26.900
2025-03-17 11:58:26.914 def _check(self) -> None:
2025-03-17 11:58:26.922 state = self.status.get_state()
2025-03-17 11:58:26.929 if StateFlag.ERRORS in state:
2025-03-17 11:58:26.936 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-17 11:58:26.944 E firebird.driver.types.DatabaseError: Error writing data to the connection.
2025-03-17 11:58:26.951
2025-03-17 11:58:26.958 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-17 11:58:26.968 ---------------------------- Captured stdout setup -----------------------------
2025-03-17 11:58:26.981 Creating db: localhost:/var/tmp/qa_2024/test_11415/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
2025-03-17 11:58:26.991 CREATE user: TMP$GH_6220 PLUGIN: Srp
2025-03-17 11:58:27.001 --------------------------- Captured stdout teardown ---------------------------
2025-03-17 11:58:27.009 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[5442]
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[5442]
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[5442]
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
|