File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed
Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ Thick Mode Changes
3131Common Changes
3232++++++++++++++
3333
34+ #) Error ``DPY-3027: binding a cursor from a different connection is not
35+ supported `` is now raised when attempting to bind a cursor created on a
36+ different connection. Previously, the attempt may have succeeded or may
37+ have failed with a number of different unexpected exceptions.
3438#) Error ``DPY-1006: cursor is not open `` is now raised consistently when
3539 attempting to bind a closed cursor. Previously, thin mode would result in a
3640 segfault and thick mode would result in unusual errors.
Original file line number Diff line number Diff line change @@ -286,6 +286,7 @@ def _raise_not_supported(feature: str) -> None:
286286ERR_VECTOR_FORMAT_NOT_SUPPORTED = 3024
287287ERR_OPERATION_NOT_SUPPORTED_ON_BFILE = 3025
288288ERR_OPERATION_ONLY_SUPPORTED_ON_BFILE = 3026
289+ ERR_CURSOR_DIFF_CONNECTION = 3027
289290
290291# error numbers that result in DatabaseError
291292ERR_TNS_ENTRY_NOT_FOUND = 4000
@@ -475,6 +476,9 @@ def _raise_not_supported(feature: str) -> None:
475476 "cannot connect to database (CONNECTION_ID={connection_id})."
476477 ),
477478 ERR_CONTENT_INVALID_AFTER_NUMBER : "invalid number (content after number)" ,
479+ ERR_CURSOR_DIFF_CONNECTION : (
480+ "binding a cursor from a different connection is not supported"
481+ ),
478482 ERR_CURSOR_NOT_OPEN : "cursor is not open" ,
479483 ERR_CURSOR_HAS_BEEN_CLOSED : "cursor has been closed by the database" ,
480484 ERR_DBOBJECT_ATTR_MAX_SIZE_VIOLATED : (
Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ cdef class BaseConnImpl:
134134 elif db_type_num == DB_TYPE_NUM_CURSOR:
135135 if isinstance (value, (PY_TYPE_CURSOR, PY_TYPE_ASYNC_CURSOR)):
136136 value._verify_open()
137+ if value.connection._impl is not self :
138+ errors._raise_err(errors.ERR_CURSOR_DIFF_CONNECTION)
137139 return value
138140 elif db_type_num == DB_TYPE_NUM_BOOLEAN:
139141 return bool (value)
Original file line number Diff line number Diff line change @@ -427,8 +427,8 @@ def test_1317(self):
427427 ref_cursor = self .conn .cursor ()
428428 ref_cursor .close ()
429429 with self .assertRaisesFullCode ("DPY-1006" ):
430- self .cursor .callproc (
431- "pkg_testRefCursors.TestInCursor" , [ref_cursor ]
430+ self .cursor .callfunc (
431+ "pkg_testRefCursors.TestInCursor" , str , [ref_cursor ]
432432 )
433433
434434 def test_1318 (self ):
@@ -442,6 +442,23 @@ def test_1318(self):
442442 ref_cursor = var .getvalue ()
443443 ref_cursor .fetchall ()
444444
445+ def test_1319 (self ):
446+ "1319 - test binding cursor that is not from the same connection"
447+ sql = """
448+ declare
449+ t_Cursor sys_refcursor;
450+ begin
451+ open t_Cursor for
452+ select 1319
453+ from dual;
454+ :cursor := t_Cursor;
455+ end;
456+ """
457+ conn = test_env .get_connection ()
458+ ref_cursor = conn .cursor ()
459+ with self .assertRaisesFullCode ("DPY-3027" ):
460+ self .cursor .execute (sql , [ref_cursor ])
461+
445462
446463if __name__ == "__main__" :
447464 test_env .run_test_cases ()
You can’t perform that action at this time.
0 commit comments