2 @message |
Server crashed ?
firebird.driver.types.DatabaseError: Error writing data to the connection.
LOG DETAILS:
2025-03-27 14:22:00.374
2025-03-27 14:22:00.384 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-27 14:22:00.390 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-27 14:22:00.396 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-27 14:22:00.402
2025-03-27 14:22:00.409 @pytest.mark.version('>=3.0.4')
2025-03-27 14:22:00.416 def test_1(act: Action, tmp_user: User, capsys):
2025-03-27 14:22:00.422
2025-03-27 14:22:00.429 init_ddl = [
2025-03-27 14:22:00.436 """
2025-03-27 14:22:00.442 set bail on;
2025-03-27 14:22:00.452 recreate sequence g;
2025-03-27 14:22:00.463 create table test(id int primary key, measure int, iter_no int);
2025-03-27 14:22:00.472
2025-03-27 14:22:00.479 create view v_test1 as select * from test;
2025-03-27 14:22:00.485 """
2025-03-27 14:22:00.496 ,'\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-27 14:22:00.506 ,f"""
2025-03-27 14:22:00.516 commit;
2025-03-27 14:22:00.526
2025-03-27 14:22:00.532 set term ^;
2025-03-27 14:22:00.538 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-27 14:22:00.544 begin
2025-03-27 14:22:00.550 while ( n_iterations > 0 ) do
2025-03-27 14:22:00.555 begin
2025-03-27 14:22:00.562 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-27 14:22:00.568 n_iterations = n_iterations - 1;
2025-03-27 14:22:00.573 end
2025-03-27 14:22:00.579
2025-03-27 14:22:00.585 end
2025-03-27 14:22:00.591 ^
2025-03-27 14:22:00.597 set term ;^
2025-03-27 14:22:00.603 commit;
2025-03-27 14:22:00.608
2025-03-27 14:22:00.614 grant execute on procedure sp_run to {tmp_user.name};
2025-03-27 14:22:00.620 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-27 14:22:00.626 grant usage on sequence g to {tmp_user.name};
2025-03-27 14:22:00.632 commit;
2025-03-27 14:22:00.638
2025-03-27 14:22:00.644 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-27 14:22:00.650 commit;
2025-03-27 14:22:00.655 """
2025-03-27 14:22:00.661 ]
2025-03-27 14:22:00.667
2025-03-27 14:22:00.673 act.expected_stdout = ''
2025-03-27 14:22:00.679 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-27 14:22:00.685 assert act.clean_stdout == act.clean_expected_stdout
2025-03-27 14:22:00.691 act.reset()
2025-03-27 14:22:00.697
2025-03-27 14:22:00.703 #------------------------------------------------------------
2025-03-27 14:22:00.709
2025-03-27 14:22:00.715 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-27 14:22:00.722 with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-27 14:22:00.728 cur_sysdba = con_sysdba.cursor()
2025-03-27 14:22:00.736 cur_nondba = con_nondba.cursor()
2025-03-27 14:22:00.741 cur_sysdba.execute(pid_sttm)
2025-03-27 14:22:00.747 cur_nondba.execute(pid_sttm)
2025-03-27 14:22:00.754 pid_sysdba = cur_sysdba.fetchone()[0]
2025-03-27 14:22:00.760 pid_nondba = cur_nondba.fetchone()[0]
2025-03-27 14:22:00.766
2025-03-27 14:22:00.772 sp_time = {}
2025-03-27 14:22:00.778 for who in (act.db.user, tmp_user.name):
2025-03-27 14:22:00.788 fb_pid = pid_sysdba if who == act.db.user else pid_nondba
2025-03-27 14:22:00.797 con = con_sysdba if who == act.db.user else con_nondba
2025-03-27 14:22:00.805 cur = cur_sysdba if who == act.db.user else cur_nondba
2025-03-27 14:22:00.810
2025-03-27 14:22:00.822 for iter_no in range(0, N_MEASURES):
2025-03-27 14:22:00.833 fb_info_init = psutil.Process(fb_pid).cpu_times()
2025-03-27 14:22:00.842 > cur.callproc( 'sp_run', (iter_no, N_COUNT_PER_MEASURE,) )
2025-03-27 14:22:00.850
2025-03-27 14:22:00.861 tests/bugs/gh_6220_test.py:147:
2025-03-27 14:22:00.868 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:00.875
2025-03-27 14:22:00.886 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-27 14:22:00.893 proc_name = 'sp_run', parameters = (17, 100)
2025-03-27 14:22:00.903
2025-03-27 14:22:00.914 def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
2025-03-27 14:22:00.920 """Executes a stored procedure with the given name.
2025-03-27 14:22:00.926
2025-03-27 14:22:00.932 Arguments:
2025-03-27 14:22:00.938 proc_name: Stored procedure name.
2025-03-27 14:22:00.946 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-27 14:22:00.958 that the procedure expects.
2025-03-27 14:22:00.964
2025-03-27 14:22:00.971 .. note::
2025-03-27 14:22:00.978
2025-03-27 14:22:00.988 If stored procedure does have output parameters, you must retrieve their values
2025-03-27 14:22:00.998 saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
2025-03-27 14:22:01.006 but conforms to Python DB API 2.0. If you don't require conformance to Python
2025-03-27 14:22:01.017 DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
2025-03-27 14:22:01.030 instead.
2025-03-27 14:22:01.038 """
2025-03-27 14:22:01.044 params = [] if parameters is None else parameters
2025-03-27 14:22:01.050 sql = ('EXECUTE PROCEDURE ' + proc_name + ' '
2025-03-27 14:22:01.056 + ','.join('?' * len(params)))
2025-03-27 14:22:01.063 > self.execute(sql, params)
2025-03-27 14:22:01.071
2025-03-27 14:22:01.078 ../lib/python3.11/site-packages/firebird/driver/core.py:3682:
2025-03-27 14:22:01.085 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:01.091
2025-03-27 14:22:01.098 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-27 14:22:01.106 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (17, 100)
2025-03-27 14:22:01.111
2025-03-27 14:22:01.117 def execute(self, operation: Union[str, Statement], parameters: Sequence[Any]=None) -> Cursor:
2025-03-27 14:22:01.123 """Executes SQL command or prepared `Statement`.
2025-03-27 14:22:01.130
2025-03-27 14:22:01.136 Starts new transaction if transaction manager associated with cursor is not active.
2025-03-27 14:22:01.142
2025-03-27 14:22:01.151 Arguments:
2025-03-27 14:22:01.158 operation: SQL command or prepared `Statement`.
2025-03-27 14:22:01.165 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-27 14:22:01.171 that the operation expects.
2025-03-27 14:22:01.177
2025-03-27 14:22:01.183 Returns:
2025-03-27 14:22:01.190 `self` so call to execute could be used as iterator over returned rows.
2025-03-27 14:22:01.196
2025-03-27 14:22:01.202 Note:
2025-03-27 14:22:01.209 If `operation` is a string with SQL command that is exactly the same as the
2025-03-27 14:22:01.215 last executed command, the internally prepared `Statement` from last execution
2025-03-27 14:22:01.221 is reused.
2025-03-27 14:22:01.226
2025-03-27 14:22:01.233 If cursor is open, it's closed before new statement is executed.
2025-03-27 14:22:01.239 """
2025-03-27 14:22:01.246 > self._execute(operation, parameters)
2025-03-27 14:22:01.252
2025-03-27 14:22:01.258 ../lib/python3.11/site-packages/firebird/driver/core.py:3755:
2025-03-27 14:22:01.264 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:01.270
2025-03-27 14:22:01.282 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-27 14:22:01.291 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (17, 100)
2025-03-27 14:22:01.298 flags = <CursorFlag.NONE: 0>
2025-03-27 14:22:01.306
2025-03-27 14:22:01.314 def _execute(self, operation: Union[str, Statement],
2025-03-27 14:22:01.321 parameters: Sequence=None, flags: CursorFlag=CursorFlag.NONE) -> None:
2025-03-27 14:22:01.327 if not self._transaction.is_active():
2025-03-27 14:22:01.333 self._transaction.begin()
2025-03-27 14:22:01.339 if isinstance(operation, Statement):
2025-03-27 14:22:01.346 if operation._connection() is not self._connection:
2025-03-27 14:22:01.352 raise InterfaceError('Cannot execute Statement that was created by different Connection.')
2025-03-27 14:22:01.358 self.close()
2025-03-27 14:22:01.365 self._stmt = operation
2025-03-27 14:22:01.371 self.__internal = False
2025-03-27 14:22:01.376 elif self._stmt is not None and self._stmt.sql == operation:
2025-03-27 14:22:01.383 # We should execute the same SQL string again
2025-03-27 14:22:01.390 self._clear()
2025-03-27 14:22:01.397 else:
2025-03-27 14:22:01.402 self.close()
2025-03-27 14:22:01.413 self._stmt = self._connection._prepare(operation, self._transaction)
2025-03-27 14:22:01.421 self.__internal = True
2025-03-27 14:22:01.428 self._cursor_flags = flags
2025-03-27 14:22:01.436 in_meta = None
2025-03-27 14:22:01.444 # Execute the statement
2025-03-27 14:22:01.452 try:
2025-03-27 14:22:01.459 if self._stmt._in_cnt > 0:
2025-03-27 14:22:01.466 in_meta, self._stmt._in_buffer = self._pack_input(self._stmt._in_meta,
2025-03-27 14:22:01.474 self._stmt._in_buffer,
2025-03-27 14:22:01.481 parameters)
2025-03-27 14:22:01.489 if self._stmt.has_cursor():
2025-03-27 14:22:01.495 # Statement returns multiple rows
2025-03-27 14:22:01.501 self._result = self._stmt._istmt.open_cursor(self._transaction._tra,
2025-03-27 14:22:01.507 in_meta, self._stmt._in_buffer,
2025-03-27 14:22:01.513 self._stmt._out_meta,
2025-03-27 14:22:01.520 flags)
2025-03-27 14:22:01.526 else:
2025-03-27 14:22:01.532 # Statement may return single row
2025-03-27 14:22:01.542 > self._stmt._istmt.execute(self._transaction._tra, in_meta,
2025-03-27 14:22:01.549 self._stmt._in_buffer,
2025-03-27 14:22:01.555 self._stmt._out_meta, self._stmt._out_buffer)
2025-03-27 14:22:01.561
2025-03-27 14:22:01.569 ../lib/python3.11/site-packages/firebird/driver/core.py:3643:
2025-03-27 14:22:01.576 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:01.583
2025-03-27 14:22:01.590 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-27 14:22:01.597 transaction = <firebird.driver.interfaces.iTransaction object at [hex]>
2025-03-27 14:22:01.603 in_meta = <firebird.driver.interfaces.iMessageMetadata object at [hex]>
2025-03-27 14:22:01.610 in_buffer = <ctypes.c_char_Array_10 object at [hex]>, out_meta = None
2025-03-27 14:22:01.616 out_buffer = None
2025-03-27 14:22:01.622
2025-03-27 14:22:01.629 def execute(self, transaction: iTransaction, in_meta: iMessageMetadata, in_buffer: bytes,
2025-03-27 14:22:01.637 out_meta: iMessageMetadata, out_buffer: bytes) -> None:
2025-03-27 14:22:01.644 """Executes any SQL statement except returning multiple rows of data.
2025-03-27 14:22:01.651 Partial analogue of `isc_dsql_execute2()` - in and out XSLQDAs replaced with input
2025-03-27 14:22:01.658 and output messages with appropriate buffers."""
2025-03-27 14:22:01.666 result = self.vtable.execute(self, self.status, transaction, in_meta, in_buffer, out_meta, out_buffer)
2025-03-27 14:22:01.673 > self._check()
2025-03-27 14:22:01.680
2025-03-27 14:22:01.687 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:778:
2025-03-27 14:22:01.694 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:01.700
2025-03-27 14:22:01.705 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-27 14:22:01.710
2025-03-27 14:22:01.715 def _check(self) -> None:
2025-03-27 14:22:01.721 state = self.status.get_state()
2025-03-27 14:22:01.728 if StateFlag.ERRORS in state:
2025-03-27 14:22:01.734 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-27 14:22:01.740 E firebird.driver.types.DatabaseError: Error reading data from the connection.
2025-03-27 14:22:01.745
2025-03-27 14:22:01.750 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-27 14:22:01.756
2025-03-27 14:22:01.763 During handling of the above exception, another exception occurred:
2025-03-27 14:22:01.769
2025-03-27 14:22:01.776 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-27 14:22:01.782 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-27 14:22:01.789 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-27 14:22:01.794
2025-03-27 14:22:01.799 @pytest.mark.version('>=3.0.4')
2025-03-27 14:22:01.805 def test_1(act: Action, tmp_user: User, capsys):
2025-03-27 14:22:01.810
2025-03-27 14:22:01.816 init_ddl = [
2025-03-27 14:22:01.822 """
2025-03-27 14:22:01.829 set bail on;
2025-03-27 14:22:01.835 recreate sequence g;
2025-03-27 14:22:01.841 create table test(id int primary key, measure int, iter_no int);
2025-03-27 14:22:01.847
2025-03-27 14:22:01.852 create view v_test1 as select * from test;
2025-03-27 14:22:01.857 """
2025-03-27 14:22:01.863 ,'\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-27 14:22:01.868 ,f"""
2025-03-27 14:22:01.874 commit;
2025-03-27 14:22:01.880
2025-03-27 14:22:01.886 set term ^;
2025-03-27 14:22:01.892 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-27 14:22:01.898 begin
2025-03-27 14:22:01.904 while ( n_iterations > 0 ) do
2025-03-27 14:22:01.910 begin
2025-03-27 14:22:01.916 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-27 14:22:01.921 n_iterations = n_iterations - 1;
2025-03-27 14:22:01.927 end
2025-03-27 14:22:01.933
2025-03-27 14:22:01.940 end
2025-03-27 14:22:01.946 ^
2025-03-27 14:22:01.952 set term ;^
2025-03-27 14:22:01.957 commit;
2025-03-27 14:22:01.963
2025-03-27 14:22:01.969 grant execute on procedure sp_run to {tmp_user.name};
2025-03-27 14:22:01.976 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-27 14:22:01.982 grant usage on sequence g to {tmp_user.name};
2025-03-27 14:22:01.988 commit;
2025-03-27 14:22:01.994
2025-03-27 14:22:02.001 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-27 14:22:02.007 commit;
2025-03-27 14:22:02.014 """
2025-03-27 14:22:02.020 ]
2025-03-27 14:22:02.027
2025-03-27 14:22:02.033 act.expected_stdout = ''
2025-03-27 14:22:02.039 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-27 14:22:02.044 assert act.clean_stdout == act.clean_expected_stdout
2025-03-27 14:22:02.049 act.reset()
2025-03-27 14:22:02.054
2025-03-27 14:22:02.060 #------------------------------------------------------------
2025-03-27 14:22:02.067
2025-03-27 14:22:02.074 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-27 14:22:02.080 > with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-27 14:22:02.087
2025-03-27 14:22:02.092 tests/bugs/gh_6220_test.py:131:
2025-03-27 14:22:02.098 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.103
2025-03-27 14:22:02.109 self = Connection[5442]
2025-03-27 14:22:02.114 exc_type = <class 'firebird.driver.types.DatabaseError'>
2025-03-27 14:22:02.120 exc_value = DatabaseError('Error reading data from the connection.')
2025-03-27 14:22:02.125 traceback = <traceback object at [hex]>
2025-03-27 14:22:02.130
2025-03-27 14:22:02.135 def __exit__(self, exc_type, exc_value, traceback) -> None:
2025-03-27 14:22:02.140 > self.close()
2025-03-27 14:22:02.145
2025-03-27 14:22:02.151 ../lib/python3.11/site-packages/firebird/driver/core.py:1666:
2025-03-27 14:22:02.157 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.162
2025-03-27 14:22:02.168 self = Connection[5442]
2025-03-27 14:22:02.173
2025-03-27 14:22:02.178 def close(self) -> None:
2025-03-27 14:22:02.183 """Close the connection and release all associated resources.
2025-03-27 14:22:02.189
2025-03-27 14:22:02.194 Closes all event collectors, transaction managers (with rollback) and statements
2025-03-27 14:22:02.199 associated with this connection before attempt (see Hooks) to close the
2025-03-27 14:22:02.204 connection itself.
2025-03-27 14:22:02.209
2025-03-27 14:22:02.214 Hooks:
2025-03-27 14:22:02.219 Event `.ConnectionHook.DETACH_REQUEST`: Executed before connection
2025-03-27 14:22:02.225 is closed. Hook must have signature::
2025-03-27 14:22:02.230
2025-03-27 14:22:02.236 hook_func(connection: Connection) -> bool
2025-03-27 14:22:02.241
2025-03-27 14:22:02.247 .. note::
2025-03-27 14:22:02.252
2025-03-27 14:22:02.259 If any hook function returns True, connection is NOT closed.
2025-03-27 14:22:02.265
2025-03-27 14:22:02.270 Event `.ConnectionHook.CLOSED`: Executed after connection is closed.
2025-03-27 14:22:02.275 Hook must have signature::
2025-03-27 14:22:02.280
2025-03-27 14:22:02.286 hook_func(connection: Connection) -> None
2025-03-27 14:22:02.291
2025-03-27 14:22:02.296 Any value returned by hook is ignored.
2025-03-27 14:22:02.301
2025-03-27 14:22:02.307 Important:
2025-03-27 14:22:02.313 Closed connection SHALL NOT be used anymore.
2025-03-27 14:22:02.318 """
2025-03-27 14:22:02.324 if not self.is_closed():
2025-03-27 14:22:02.331 retain = False
2025-03-27 14:22:02.338 try:
2025-03-27 14:22:02.345 > self._close()
2025-03-27 14:22:02.351
2025-03-27 14:22:02.358 ../lib/python3.11/site-packages/firebird/driver/core.py:1854:
2025-03-27 14:22:02.365 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.371
2025-03-27 14:22:02.377 self = Connection[5442]
2025-03-27 14:22:02.384
2025-03-27 14:22:02.390 def _close(self) -> None:
2025-03-27 14:22:02.397 if self.__schema is not None:
2025-03-27 14:22:02.403 self.__schema._set_internal(False)
2025-03-27 14:22:02.409 self.__schema.close()
2025-03-27 14:22:02.415 if self.__monitor is not None:
2025-03-27 14:22:02.421 self.__monitor._set_internal(False)
2025-03-27 14:22:02.428 self.__monitor.close()
2025-03-27 14:22:02.434 self._ic.close()
2025-03-27 14:22:02.440 for collector in self.__ecollectors:
2025-03-27 14:22:02.446 collector.close()
2025-03-27 14:22:02.453 > self.main_transaction._finish(DefaultAction.ROLLBACK)
2025-03-27 14:22:02.459
2025-03-27 14:22:02.465 ../lib/python3.11/site-packages/firebird/driver/core.py:1691:
2025-03-27 14:22:02.471 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.478
2025-03-27 14:22:02.484 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-27 14:22:02.490 default_action = <DefaultAction.ROLLBACK: 2>
2025-03-27 14:22:02.496
2025-03-27 14:22:02.502 def _finish(self, default_action: DefaultAction=None) -> None:
2025-03-27 14:22:02.508 try:
2025-03-27 14:22:02.514 if self._tra is not None:
2025-03-27 14:22:02.521 if default_action is None:
2025-03-27 14:22:02.527 default_action = self.default_action
2025-03-27 14:22:02.532 if default_action == DefaultAction.COMMIT:
2025-03-27 14:22:02.537 self.commit()
2025-03-27 14:22:02.544 else:
2025-03-27 14:22:02.552 > self.rollback()
2025-03-27 14:22:02.559
2025-03-27 14:22:02.566 ../lib/python3.11/site-packages/firebird/driver/core.py:2399:
2025-03-27 14:22:02.574 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.583
2025-03-27 14:22:02.591 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-27 14:22:02.599
2025-03-27 14:22:02.608 def rollback(self, *, retaining: bool=False, savepoint: str=None) -> None:
2025-03-27 14:22:02.615 """Rolls back the transaction managed by this instance.
2025-03-27 14:22:02.625
2025-03-27 14:22:02.637 Arguments:
2025-03-27 14:22:02.650 retaining: When True, the transaction context is retained after rollback.
2025-03-27 14:22:02.660 savepoint: When specified, the transaction is rolled back to savepoint with given name.
2025-03-27 14:22:02.667
2025-03-27 14:22:02.674 Raises:
2025-03-27 14:22:02.681 InterfaceError: When both retaining and savepoint parameters are specified.
2025-03-27 14:22:02.687 """
2025-03-27 14:22:02.693 assert not self.__closed
2025-03-27 14:22:02.699 assert self.is_active()
2025-03-27 14:22:02.704 if retaining and savepoint:
2025-03-27 14:22:02.709 raise InterfaceError("Can't rollback to savepoint while retaining context")
2025-03-27 14:22:02.714 if savepoint:
2025-03-27 14:22:02.721 self.execute_immediate(f'rollback to {savepoint}')
2025-03-27 14:22:02.727 else:
2025-03-27 14:22:02.733 if retaining:
2025-03-27 14:22:02.740 self._tra.rollback_retaining()
2025-03-27 14:22:02.745 else:
2025-03-27 14:22:02.751 > self._close_cursors()
2025-03-27 14:22:02.756
2025-03-27 14:22:02.763 ../lib/python3.11/site-packages/firebird/driver/core.py:2486:
2025-03-27 14:22:02.769 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.775
2025-03-27 14:22:02.781 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-27 14:22:02.788
2025-03-27 14:22:02.794 def _close_cursors(self) -> None:
2025-03-27 14:22:02.801 for cursor in self._cursors:
2025-03-27 14:22:02.806 c = cursor()
2025-03-27 14:22:02.811 if c:
2025-03-27 14:22:02.816 > c.close()
2025-03-27 14:22:02.821
2025-03-27 14:22:02.827 ../lib/python3.11/site-packages/firebird/driver/core.py:2388:
2025-03-27 14:22:02.832 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.837
2025-03-27 14:22:02.842 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-27 14:22:02.847
2025-03-27 14:22:02.853 def close(self) -> None:
2025-03-27 14:22:02.859 """Close the cursor and release all associated resources.
2025-03-27 14:22:02.865
2025-03-27 14:22:02.871 The result set (if any) from last executed statement is released, and if executed
2025-03-27 14:22:02.877 `Statement` was not supplied externally, it's released as well.
2025-03-27 14:22:02.883
2025-03-27 14:22:02.890 Note:
2025-03-27 14:22:02.897 The closed cursor could be used to execute further SQL commands.
2025-03-27 14:22:02.904 """
2025-03-27 14:22:02.910 self._clear()
2025-03-27 14:22:02.917 if self._stmt is not None:
2025-03-27 14:22:02.924 if self.__internal:
2025-03-27 14:22:02.930 > self._stmt.free()
2025-03-27 14:22:02.937
2025-03-27 14:22:02.944 ../lib/python3.11/site-packages/firebird/driver/core.py:3791:
2025-03-27 14:22:02.951 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:02.958
2025-03-27 14:22:02.968 self = Statement[EXECUTE PROCEDURE sp_run ?,?]
2025-03-27 14:22:02.979
2025-03-27 14:22:02.987 def free(self) -> None:
2025-03-27 14:22:02.994 """Release the statement and all associated resources.
2025-03-27 14:22:03.000
2025-03-27 14:22:03.005 Important:
2025-03-27 14:22:03.011 The statement SHALL NOT be used after call to this method.
2025-03-27 14:22:03.018 """
2025-03-27 14:22:03.025 if self._in_meta is not None:
2025-03-27 14:22:03.031 self._in_meta.release()
2025-03-27 14:22:03.037 self._in_meta = None
2025-03-27 14:22:03.044 if self._out_meta is not None:
2025-03-27 14:22:03.050 self._out_meta.release()
2025-03-27 14:22:03.056 self._out_meta = None
2025-03-27 14:22:03.063 if self._istmt is not None:
2025-03-27 14:22:03.069 > self._istmt.free()
2025-03-27 14:22:03.075
2025-03-27 14:22:03.083 ../lib/python3.11/site-packages/firebird/driver/core.py:2736:
2025-03-27 14:22:03.095 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:03.104
2025-03-27 14:22:03.111 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-27 14:22:03.120
2025-03-27 14:22:03.133 def free(self) -> None:
2025-03-27 14:22:03.141 "Free statement, releases interface on success"
2025-03-27 14:22:03.148 self.vtable.free(self, self.status)
2025-03-27 14:22:03.154 > self._check()
2025-03-27 14:22:03.159
2025-03-27 14:22:03.165 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:832:
2025-03-27 14:22:03.171 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-27 14:22:03.177
2025-03-27 14:22:03.183 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-27 14:22:03.189
2025-03-27 14:22:03.194 def _check(self) -> None:
2025-03-27 14:22:03.200 state = self.status.get_state()
2025-03-27 14:22:03.206 if StateFlag.ERRORS in state:
2025-03-27 14:22:03.211 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-27 14:22:03.217 E firebird.driver.types.DatabaseError: Error writing data to the connection.
2025-03-27 14:22:03.222
2025-03-27 14:22:03.228 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-27 14:22:03.234 ---------------------------- Captured stdout setup -----------------------------
2025-03-27 14:22:03.240 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-27 14:22:03.245 CREATE user: TMP$GH_6220 PLUGIN: Srp
2025-03-27 14:22:03.251 --------------------------- Captured stdout teardown ---------------------------
2025-03-27 14:22:03.258 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 = (17, 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 = (17, 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 = (17, 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
|