2 @message |
Server crashed ?
firebird.driver.types.DatabaseError: Error writing data to the connection.
LOG DETAILS:
2025-03-28 14:34:27.978
2025-03-28 14:34:27.983 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-28 14:34:27.990 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-28 14:34:27.996 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-28 14:34:28.002
2025-03-28 14:34:28.008 @pytest.mark.version('>=3.0.4')
2025-03-28 14:34:28.015 def test_1(act: Action, tmp_user: User, capsys):
2025-03-28 14:34:28.022
2025-03-28 14:34:28.029 init_ddl = [
2025-03-28 14:34:28.035 """
2025-03-28 14:34:28.041 set bail on;
2025-03-28 14:34:28.047 recreate sequence g;
2025-03-28 14:34:28.053 create table test(id int primary key, measure int, iter_no int);
2025-03-28 14:34:28.059
2025-03-28 14:34:28.067 create view v_test1 as select * from test;
2025-03-28 14:34:28.077 """
2025-03-28 14:34:28.089 ,'\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-28 14:34:28.097 ,f"""
2025-03-28 14:34:28.104 commit;
2025-03-28 14:34:28.109
2025-03-28 14:34:28.115 set term ^;
2025-03-28 14:34:28.123 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-28 14:34:28.129 begin
2025-03-28 14:34:28.135 while ( n_iterations > 0 ) do
2025-03-28 14:34:28.142 begin
2025-03-28 14:34:28.148 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-28 14:34:28.156 n_iterations = n_iterations - 1;
2025-03-28 14:34:28.162 end
2025-03-28 14:34:28.171
2025-03-28 14:34:28.177 end
2025-03-28 14:34:28.182 ^
2025-03-28 14:34:28.188 set term ;^
2025-03-28 14:34:28.193 commit;
2025-03-28 14:34:28.199
2025-03-28 14:34:28.205 grant execute on procedure sp_run to {tmp_user.name};
2025-03-28 14:34:28.210 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-28 14:34:28.216 grant usage on sequence g to {tmp_user.name};
2025-03-28 14:34:28.223 commit;
2025-03-28 14:34:28.229
2025-03-28 14:34:28.235 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-28 14:34:28.242 commit;
2025-03-28 14:34:28.249 """
2025-03-28 14:34:28.256 ]
2025-03-28 14:34:28.261
2025-03-28 14:34:28.269 act.expected_stdout = ''
2025-03-28 14:34:28.276 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-28 14:34:28.283 assert act.clean_stdout == act.clean_expected_stdout
2025-03-28 14:34:28.290 act.reset()
2025-03-28 14:34:28.299
2025-03-28 14:34:28.306 #------------------------------------------------------------
2025-03-28 14:34:28.313
2025-03-28 14:34:28.320 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-28 14:34:28.327 with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-28 14:34:28.334 cur_sysdba = con_sysdba.cursor()
2025-03-28 14:34:28.341 cur_nondba = con_nondba.cursor()
2025-03-28 14:34:28.347 cur_sysdba.execute(pid_sttm)
2025-03-28 14:34:28.354 cur_nondba.execute(pid_sttm)
2025-03-28 14:34:28.361 pid_sysdba = cur_sysdba.fetchone()[0]
2025-03-28 14:34:28.370 pid_nondba = cur_nondba.fetchone()[0]
2025-03-28 14:34:28.382
2025-03-28 14:34:28.390 sp_time = {}
2025-03-28 14:34:28.399 for who in (act.db.user, tmp_user.name):
2025-03-28 14:34:28.410 fb_pid = pid_sysdba if who == act.db.user else pid_nondba
2025-03-28 14:34:28.418 con = con_sysdba if who == act.db.user else con_nondba
2025-03-28 14:34:28.430 cur = cur_sysdba if who == act.db.user else cur_nondba
2025-03-28 14:34:28.439
2025-03-28 14:34:28.452 for iter_no in range(0, N_MEASURES):
2025-03-28 14:34:28.462 fb_info_init = psutil.Process(fb_pid).cpu_times()
2025-03-28 14:34:28.468 > cur.callproc( 'sp_run', (iter_no, N_COUNT_PER_MEASURE,) )
2025-03-28 14:34:28.475
2025-03-28 14:34:28.482 tests/bugs/gh_6220_test.py:147:
2025-03-28 14:34:28.491 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:28.498
2025-03-28 14:34:28.506 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-28 14:34:28.514 proc_name = 'sp_run', parameters = (17, 100)
2025-03-28 14:34:28.522
2025-03-28 14:34:28.529 def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
2025-03-28 14:34:28.535 """Executes a stored procedure with the given name.
2025-03-28 14:34:28.541
2025-03-28 14:34:28.547 Arguments:
2025-03-28 14:34:28.553 proc_name: Stored procedure name.
2025-03-28 14:34:28.559 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-28 14:34:28.568 that the procedure expects.
2025-03-28 14:34:28.577
2025-03-28 14:34:28.584 .. note::
2025-03-28 14:34:28.592
2025-03-28 14:34:28.601 If stored procedure does have output parameters, you must retrieve their values
2025-03-28 14:34:28.609 saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
2025-03-28 14:34:28.616 but conforms to Python DB API 2.0. If you don't require conformance to Python
2025-03-28 14:34:28.624 DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
2025-03-28 14:34:28.633 instead.
2025-03-28 14:34:28.646 """
2025-03-28 14:34:28.657 params = [] if parameters is None else parameters
2025-03-28 14:34:28.666 sql = ('EXECUTE PROCEDURE ' + proc_name + ' '
2025-03-28 14:34:28.675 + ','.join('?' * len(params)))
2025-03-28 14:34:28.685 > self.execute(sql, params)
2025-03-28 14:34:28.693
2025-03-28 14:34:28.707 ../lib/python3.11/site-packages/firebird/driver/core.py:3788:
2025-03-28 14:34:28.718 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:28.725
2025-03-28 14:34:28.731 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-28 14:34:28.737 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (17, 100)
2025-03-28 14:34:28.743
2025-03-28 14:34:28.749 def execute(self, operation: Union[str, Statement], parameters: Sequence[Any]=None) -> Cursor:
2025-03-28 14:34:28.756 """Executes SQL command or prepared `Statement`.
2025-03-28 14:34:28.762
2025-03-28 14:34:28.769 Starts new transaction if transaction manager associated with cursor is not active.
2025-03-28 14:34:28.776
2025-03-28 14:34:28.784 Arguments:
2025-03-28 14:34:28.792 operation: SQL command or prepared `Statement`.
2025-03-28 14:34:28.808 parameters: Sequence of parameters. Must contain one entry for each argument
2025-03-28 14:34:28.818 that the operation expects.
2025-03-28 14:34:28.827
2025-03-28 14:34:28.835 Returns:
2025-03-28 14:34:28.845 `self` so call to execute could be used as iterator over returned rows.
2025-03-28 14:34:28.853
2025-03-28 14:34:28.862 Note:
2025-03-28 14:34:28.870 If `operation` is a string with SQL command that is exactly the same as the
2025-03-28 14:34:28.879 last executed command, the internally prepared `Statement` from last execution
2025-03-28 14:34:28.887 is reused.
2025-03-28 14:34:28.894
2025-03-28 14:34:28.902 If cursor is open, it's closed before new statement is executed.
2025-03-28 14:34:28.911 """
2025-03-28 14:34:28.919 > self._execute(operation, parameters)
2025-03-28 14:34:28.927
2025-03-28 14:34:28.935 ../lib/python3.11/site-packages/firebird/driver/core.py:3861:
2025-03-28 14:34:28.943 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:28.951
2025-03-28 14:34:28.959 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-28 14:34:28.967 operation = 'EXECUTE PROCEDURE sp_run ?,?', parameters = (17, 100)
2025-03-28 14:34:28.976 flags = <CursorFlag.NONE: 0>
2025-03-28 14:34:28.984
2025-03-28 14:34:28.992 def _execute(self, operation: Union[str, Statement],
2025-03-28 14:34:29.002 parameters: Sequence=None, flags: CursorFlag=CursorFlag.NONE) -> None:
2025-03-28 14:34:29.011 if not self._transaction.is_active():
2025-03-28 14:34:29.020 self._transaction.begin()
2025-03-28 14:34:29.029 if isinstance(operation, Statement):
2025-03-28 14:34:29.038 if operation._connection() is not self._connection:
2025-03-28 14:34:29.047 raise InterfaceError('Cannot execute Statement that was created by different Connection.')
2025-03-28 14:34:29.054 self.close()
2025-03-28 14:34:29.062 self._stmt = operation
2025-03-28 14:34:29.070 self.__internal = False
2025-03-28 14:34:29.077 elif self._stmt is not None and self._stmt.sql == operation:
2025-03-28 14:34:29.086 # We should execute the same SQL string again
2025-03-28 14:34:29.093 self._clear()
2025-03-28 14:34:29.101 else:
2025-03-28 14:34:29.108 self.close()
2025-03-28 14:34:29.116 self._stmt = self._connection._prepare(operation, self._transaction)
2025-03-28 14:34:29.123 self.__internal = True
2025-03-28 14:34:29.131 self._cursor_flags = flags
2025-03-28 14:34:29.141 in_meta = None
2025-03-28 14:34:29.151 # Execute the statement
2025-03-28 14:34:29.160 try:
2025-03-28 14:34:29.173 if self._stmt._in_cnt > 0:
2025-03-28 14:34:29.181 in_meta, self._stmt._in_buffer = self._pack_input(self._stmt._in_meta,
2025-03-28 14:34:29.190 self._stmt._in_buffer,
2025-03-28 14:34:29.198 parameters)
2025-03-28 14:34:29.206 if self._stmt.has_cursor():
2025-03-28 14:34:29.217 # Statement returns multiple rows
2025-03-28 14:34:29.227 self._result = self._stmt._istmt.open_cursor(self._transaction._tra,
2025-03-28 14:34:29.238 in_meta, self._stmt._in_buffer,
2025-03-28 14:34:29.246 self._stmt._out_meta,
2025-03-28 14:34:29.254 flags)
2025-03-28 14:34:29.262 else:
2025-03-28 14:34:29.271 # Statement may return single row
2025-03-28 14:34:29.279 > self._stmt._istmt.execute(self._transaction._tra, in_meta,
2025-03-28 14:34:29.288 self._stmt._in_buffer,
2025-03-28 14:34:29.296 self._stmt._out_meta, self._stmt._out_buffer)
2025-03-28 14:34:29.306
2025-03-28 14:34:29.316 ../lib/python3.11/site-packages/firebird/driver/core.py:3749:
2025-03-28 14:34:29.326 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:29.334
2025-03-28 14:34:29.343 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-28 14:34:29.352 transaction = <firebird.driver.interfaces.iTransaction object at [hex]>
2025-03-28 14:34:29.361 in_meta = <firebird.driver.interfaces.iMessageMetadata object at [hex]>
2025-03-28 14:34:29.370 in_buffer = <ctypes.c_char_Array_10 object at [hex]>, out_meta = None
2025-03-28 14:34:29.378 out_buffer = None
2025-03-28 14:34:29.386
2025-03-28 14:34:29.395 def execute(self, transaction: iTransaction, in_meta: iMessageMetadata, in_buffer: bytes,
2025-03-28 14:34:29.405 out_meta: iMessageMetadata, out_buffer: bytes) -> None:
2025-03-28 14:34:29.414 """Executes any SQL statement except returning multiple rows of data.
2025-03-28 14:34:29.424 Partial analogue of `isc_dsql_execute2()` - in and out XSLQDAs replaced with input
2025-03-28 14:34:29.433 and output messages with appropriate buffers."""
2025-03-28 14:34:29.442 result = self.vtable.execute(self, self.status, transaction, in_meta, in_buffer, out_meta, out_buffer)
2025-03-28 14:34:29.451 > self._check()
2025-03-28 14:34:29.461
2025-03-28 14:34:29.471 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:783:
2025-03-28 14:34:29.481 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:29.490
2025-03-28 14:34:29.499 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-28 14:34:29.509
2025-03-28 14:34:29.528 def _check(self) -> None:
2025-03-28 14:34:29.536 state = self.status.get_state()
2025-03-28 14:34:29.542 if StateFlag.ERRORS in state:
2025-03-28 14:34:29.549 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-28 14:34:29.556 E firebird.driver.types.DatabaseError: Error reading data from the connection.
2025-03-28 14:34:29.565
2025-03-28 14:34:29.574 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-28 14:34:29.583
2025-03-28 14:34:29.591 During handling of the above exception, another exception occurred:
2025-03-28 14:34:29.601
2025-03-28 14:34:29.611 act = <firebird.qa.plugin.Action object at [hex]>
2025-03-28 14:34:29.621 tmp_user = <firebird.qa.plugin.User object at [hex]>
2025-03-28 14:34:29.629 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-03-28 14:34:29.637
2025-03-28 14:34:29.646 @pytest.mark.version('>=3.0.4')
2025-03-28 14:34:29.655 def test_1(act: Action, tmp_user: User, capsys):
2025-03-28 14:34:29.665
2025-03-28 14:34:29.675 init_ddl = [
2025-03-28 14:34:29.688 """
2025-03-28 14:34:29.698 set bail on;
2025-03-28 14:34:29.709 recreate sequence g;
2025-03-28 14:34:29.720 create table test(id int primary key, measure int, iter_no int);
2025-03-28 14:34:29.731
2025-03-28 14:34:29.742 create view v_test1 as select * from test;
2025-03-28 14:34:29.751 """
2025-03-28 14:34:29.760 ,'\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-28 14:34:29.771 ,f"""
2025-03-28 14:34:29.780 commit;
2025-03-28 14:34:29.791
2025-03-28 14:34:29.801 set term ^;
2025-03-28 14:34:29.810 create procedure sp_run(a_measure smallint, n_iterations int) as
2025-03-28 14:34:29.818 begin
2025-03-28 14:34:29.828 while ( n_iterations > 0 ) do
2025-03-28 14:34:29.838 begin
2025-03-28 14:34:29.847 execute statement 'update v_test{NESTED_LIMIT} set measure = ' || a_measure || ', iter_no = ' || n_iterations;
2025-03-28 14:34:29.854 n_iterations = n_iterations - 1;
2025-03-28 14:34:29.863 end
2025-03-28 14:34:29.872
2025-03-28 14:34:29.882 end
2025-03-28 14:34:29.894 ^
2025-03-28 14:34:29.905 set term ;^
2025-03-28 14:34:29.915 commit;
2025-03-28 14:34:29.925
2025-03-28 14:34:29.935 grant execute on procedure sp_run to {tmp_user.name};
2025-03-28 14:34:29.944 grant select, update on v_test{NESTED_LIMIT} to {tmp_user.name};
2025-03-28 14:34:29.953 grant usage on sequence g to {tmp_user.name};
2025-03-28 14:34:29.960 commit;
2025-03-28 14:34:29.972
2025-03-28 14:34:29.984 insert into v_test{NESTED_LIMIT}(id, measure, iter_no) values(0,-1,-1);
2025-03-28 14:34:29.999 commit;
2025-03-28 14:34:30.014 """
2025-03-28 14:34:30.024 ]
2025-03-28 14:34:30.032
2025-03-28 14:34:30.040 act.expected_stdout = ''
2025-03-28 14:34:30.047 act.isql(input = '\n'.join(init_ddl), combine_output = True)
2025-03-28 14:34:30.055 assert act.clean_stdout == act.clean_expected_stdout
2025-03-28 14:34:30.062 act.reset()
2025-03-28 14:34:30.069
2025-03-28 14:34:30.077 #------------------------------------------------------------
2025-03-28 14:34:30.083
2025-03-28 14:34:30.090 pid_sttm = 'select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection'
2025-03-28 14:34:30.097 > with act.db.connect() as con_sysdba, act.db.connect(user = tmp_user.name, password = tmp_user.password) as con_nondba:
2025-03-28 14:34:30.104
2025-03-28 14:34:30.112 tests/bugs/gh_6220_test.py:131:
2025-03-28 14:34:30.121 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:30.128
2025-03-28 14:34:30.134 self = Connection[5442]
2025-03-28 14:34:30.140 exc_type = <class 'firebird.driver.types.DatabaseError'>
2025-03-28 14:34:30.147 exc_value = DatabaseError('Error reading data from the connection.')
2025-03-28 14:34:30.155 traceback = <traceback object at [hex]>
2025-03-28 14:34:30.164
2025-03-28 14:34:30.176 def __exit__(self, exc_type, exc_value, traceback) -> None:
2025-03-28 14:34:30.189 > self.close()
2025-03-28 14:34:30.200
2025-03-28 14:34:30.208 ../lib/python3.11/site-packages/firebird/driver/core.py:1676:
2025-03-28 14:34:30.214 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:30.220
2025-03-28 14:34:30.225 self = Connection[5442]
2025-03-28 14:34:30.231
2025-03-28 14:34:30.237 def close(self) -> None:
2025-03-28 14:34:30.244 """Close the connection and release all associated resources.
2025-03-28 14:34:30.251
2025-03-28 14:34:30.259 Closes all event collectors, transaction managers (with rollback) and statements
2025-03-28 14:34:30.267 associated with this connection before attempt (see Hooks) to close the
2025-03-28 14:34:30.275 connection itself.
2025-03-28 14:34:30.282
2025-03-28 14:34:30.289 Hooks:
2025-03-28 14:34:30.298 Event `.ConnectionHook.DETACH_REQUEST`: Executed before connection
2025-03-28 14:34:30.309 is closed. Hook must have signature::
2025-03-28 14:34:30.321
2025-03-28 14:34:30.336 hook_func(connection: Connection) -> bool
2025-03-28 14:34:30.347
2025-03-28 14:34:30.356 .. note::
2025-03-28 14:34:30.365
2025-03-28 14:34:30.374 If any hook function returns True, connection is NOT closed.
2025-03-28 14:34:30.385
2025-03-28 14:34:30.402 Event `.ConnectionHook.CLOSED`: Executed after connection is closed.
2025-03-28 14:34:30.415 Hook must have signature::
2025-03-28 14:34:30.428
2025-03-28 14:34:30.441 hook_func(connection: Connection) -> None
2025-03-28 14:34:30.451
2025-03-28 14:34:30.462 Any value returned by hook is ignored.
2025-03-28 14:34:30.471
2025-03-28 14:34:30.485 Important:
2025-03-28 14:34:30.500 Closed connection SHALL NOT be used anymore.
2025-03-28 14:34:30.514 """
2025-03-28 14:34:30.524 if not self.is_closed():
2025-03-28 14:34:30.532 retain = False
2025-03-28 14:34:30.541 try:
2025-03-28 14:34:30.551 > self._close()
2025-03-28 14:34:30.561
2025-03-28 14:34:30.569 ../lib/python3.11/site-packages/firebird/driver/core.py:1864:
2025-03-28 14:34:30.577 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:30.584
2025-03-28 14:34:30.590 self = Connection[5442]
2025-03-28 14:34:30.597
2025-03-28 14:34:30.603 def _close(self) -> None:
2025-03-28 14:34:30.610 if self.__schema is not None:
2025-03-28 14:34:30.617 self.__schema._set_internal(False)
2025-03-28 14:34:30.628 self.__schema.close()
2025-03-28 14:34:30.641 if self.__monitor is not None:
2025-03-28 14:34:30.653 self.__monitor._set_internal(False)
2025-03-28 14:34:30.663 self.__monitor.close()
2025-03-28 14:34:30.674 self._ic.close()
2025-03-28 14:34:30.685 for collector in self.__ecollectors:
2025-03-28 14:34:30.694 collector.close()
2025-03-28 14:34:30.704 > self.main_transaction._finish(DefaultAction.ROLLBACK)
2025-03-28 14:34:30.715
2025-03-28 14:34:30.724 ../lib/python3.11/site-packages/firebird/driver/core.py:1701:
2025-03-28 14:34:30.731 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:30.737
2025-03-28 14:34:30.743 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-28 14:34:30.752 default_action = <DefaultAction.ROLLBACK: 2>
2025-03-28 14:34:30.762
2025-03-28 14:34:30.770 def _finish(self, default_action: DefaultAction=None) -> None:
2025-03-28 14:34:30.779 try:
2025-03-28 14:34:30.787 if self._tra is not None:
2025-03-28 14:34:30.795 if default_action is None:
2025-03-28 14:34:30.803 default_action = self.default_action
2025-03-28 14:34:30.810 if default_action == DefaultAction.COMMIT:
2025-03-28 14:34:30.817 self.commit()
2025-03-28 14:34:30.824 else:
2025-03-28 14:34:30.831 > self.rollback()
2025-03-28 14:34:30.838
2025-03-28 14:34:30.846 ../lib/python3.11/site-packages/firebird/driver/core.py:2416:
2025-03-28 14:34:30.853 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:30.861
2025-03-28 14:34:30.868 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-28 14:34:30.876
2025-03-28 14:34:30.884 def rollback(self, *, retaining: bool=False, savepoint: str=None) -> None:
2025-03-28 14:34:30.891 """Rolls back the transaction managed by this instance.
2025-03-28 14:34:30.899
2025-03-28 14:34:30.906 Arguments:
2025-03-28 14:34:30.913 retaining: When True, the transaction context is retained after rollback.
2025-03-28 14:34:30.921 savepoint: When specified, the transaction is rolled back to savepoint with given name.
2025-03-28 14:34:30.928
2025-03-28 14:34:30.934 Raises:
2025-03-28 14:34:30.942 InterfaceError: When both retaining and savepoint parameters are specified.
2025-03-28 14:34:30.949 """
2025-03-28 14:34:30.956 assert not self.__closed
2025-03-28 14:34:30.963 assert self.is_active()
2025-03-28 14:34:30.970 if retaining and savepoint:
2025-03-28 14:34:30.976 raise InterfaceError("Can't rollback to savepoint while retaining context")
2025-03-28 14:34:30.982 if savepoint:
2025-03-28 14:34:30.989 self.execute_immediate(f'rollback to {savepoint}')
2025-03-28 14:34:30.995 else:
2025-03-28 14:34:31.002 if retaining:
2025-03-28 14:34:31.011 self._tra.rollback_retaining()
2025-03-28 14:34:31.020 else:
2025-03-28 14:34:31.029 > self._close_cursors()
2025-03-28 14:34:31.037
2025-03-28 14:34:31.049 ../lib/python3.11/site-packages/firebird/driver/core.py:2503:
2025-03-28 14:34:31.061 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:31.074
2025-03-28 14:34:31.084 self = <firebird.driver.core.TransactionManager object at [hex]>
2025-03-28 14:34:31.090
2025-03-28 14:34:31.098 def _close_cursors(self) -> None:
2025-03-28 14:34:31.105 for cursor in self._cursors:
2025-03-28 14:34:31.112 c = cursor()
2025-03-28 14:34:31.120 if c:
2025-03-28 14:34:31.128 > c.close()
2025-03-28 14:34:31.136
2025-03-28 14:34:31.143 ../lib/python3.11/site-packages/firebird/driver/core.py:2405:
2025-03-28 14:34:31.151 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:31.160
2025-03-28 14:34:31.168 self = <firebird.driver.core.Cursor object at [hex]>
2025-03-28 14:34:31.176
2025-03-28 14:34:31.184 def close(self) -> None:
2025-03-28 14:34:31.192 """Close the cursor and release all associated resources.
2025-03-28 14:34:31.200
2025-03-28 14:34:31.208 The result set (if any) from last executed statement is released, and if executed
2025-03-28 14:34:31.217 `Statement` was not supplied externally, it's released as well.
2025-03-28 14:34:31.226
2025-03-28 14:34:31.237 Note:
2025-03-28 14:34:31.252 The closed cursor could be used to execute further SQL commands.
2025-03-28 14:34:31.266 """
2025-03-28 14:34:31.277 self._clear()
2025-03-28 14:34:31.286 if self._stmt is not None:
2025-03-28 14:34:31.292 if self.__internal:
2025-03-28 14:34:31.298 > self._stmt.free()
2025-03-28 14:34:31.304
2025-03-28 14:34:31.310 ../lib/python3.11/site-packages/firebird/driver/core.py:3897:
2025-03-28 14:34:31.315 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:31.322
2025-03-28 14:34:31.330 self = Statement[EXECUTE PROCEDURE sp_run ?,?]
2025-03-28 14:34:31.339
2025-03-28 14:34:31.346 def free(self) -> None:
2025-03-28 14:34:31.355 """Release the statement and all associated resources.
2025-03-28 14:34:31.362
2025-03-28 14:34:31.369 Important:
2025-03-28 14:34:31.376 The statement SHALL NOT be used after call to this method.
2025-03-28 14:34:31.382 """
2025-03-28 14:34:31.389 if self._in_meta is not None:
2025-03-28 14:34:31.396 self._in_meta.release()
2025-03-28 14:34:31.402 self._in_meta = None
2025-03-28 14:34:31.407 if self._out_meta is not None:
2025-03-28 14:34:31.413 self._out_meta.release()
2025-03-28 14:34:31.421 self._out_meta = None
2025-03-28 14:34:31.427 if self._istmt is not None:
2025-03-28 14:34:31.435 > self._istmt.free()
2025-03-28 14:34:31.444
2025-03-28 14:34:31.457 ../lib/python3.11/site-packages/firebird/driver/core.py:2832:
2025-03-28 14:34:31.467 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:31.474
2025-03-28 14:34:31.483 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-28 14:34:31.491
2025-03-28 14:34:31.498 def free(self) -> None:
2025-03-28 14:34:31.506 "Free statement, releases interface on success"
2025-03-28 14:34:31.514 self.vtable.free(self, self.status)
2025-03-28 14:34:31.522 > self._check()
2025-03-28 14:34:31.529
2025-03-28 14:34:31.536 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:837:
2025-03-28 14:34:31.544 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-03-28 14:34:31.551
2025-03-28 14:34:31.558 self = <firebird.driver.interfaces.iStatement object at [hex]>
2025-03-28 14:34:31.566
2025-03-28 14:34:31.574 def _check(self) -> None:
2025-03-28 14:34:31.582 state = self.status.get_state()
2025-03-28 14:34:31.591 if StateFlag.ERRORS in state:
2025-03-28 14:34:31.599 > raise self.__report(DatabaseError, self.status.get_errors())
2025-03-28 14:34:31.607 E firebird.driver.types.DatabaseError: Error writing data to the connection.
2025-03-28 14:34:31.614
2025-03-28 14:34:31.621 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-03-28 14:34:31.627 ---------------------------- Captured stdout setup -----------------------------
2025-03-28 14:34:31.634 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-28 14:34:31.641 CREATE user: TMP$GH_6220 PLUGIN: Srp
2025-03-28 14:34:31.647 --------------------------- Captured stdout teardown ---------------------------
2025-03-28 14:34:31.654 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:3788:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:3861:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:3749:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:783:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:1676:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:1864:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:1701:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:2416:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:2503:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:2405:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:3897:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:2832:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:837:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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
|