Thin mode: binding a nested table of objects with a None element raises ORA-00600 [kopp2ucoll233] and closes the connection
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Start with src/oracledb/impl/thin/dbobject.pyx, especially ThinDbObjectImpl._pack_value() and the object element packing branch described in the issue. Check how NULL markers are written for inline object attributes versus objects inside a Collection, then run or add a Thin mode bind test for a nested table containing None. Done means NULL elements bind successfully and the existing inline object behavior still works.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- What versions are you using?
Oracle Database: 23.26.3.0.0 (Oracle AI Database 26ai Free, aarch64)
platform.platform: Linux-aarch64-with-glibc2.41 (Debian container)
sys.maxsize > 2**32: True
platform.python_version: 3.13.5
oracledb.__version__: 26.1.0
- Is it an error or a hang or a crash?
An error. The server raises ORA-00600, and python-oracledb then closes the connection.
- What error(s) or behavior you are seeing?
Binding a nested table of objects that contains a None element fails in Thin mode:
DPY-4011: the database or network closed the connection
ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kopp2ucoll233], [], [], [], [], [], [], [], [], [], [], []
The same Collection without the None element works. Fetching a Collection with NULL object elements also works.
Probable cause. ThinDbObjectImpl._pack_value() writes TNS_OBJ_ATOMIC_NULL (253) for any None whose type is an object and not a Collection (dbobject.pyx#L260-L265). That marker is only valid for an object packed inline, as an attribute of another object. Inside a Collection, each object element is packed as an image with a length prefix (see the elif ora_type_num == ORA_TYPE_NUM_OBJECT branch below it). So a NULL element has to be a NULL length, TNS_NULL_LENGTH_INDICATOR (255). The reader already accepts 255 in this position (get_is_atomic_null(is_collection, ...)).
Suggested fix:
if value is None:
if metadata.objtype is not None \
and not metadata.objtype.is_collection \
and not self.type.is_collection:
buf.write_uint8(TNS_OBJ_ATOMIC_NULL)
else:
buf.write_uint8(TNS_NULL_LENGTH_INDICATOR)
I have not built python-oracledb with this change. I found the bug while writing object binds for the Rust thin driver (oracle/rust-oracledb) in openrajska/php-oracle, with an encoder modelled on python-oracledb's pickling. With the same rule (255 inside a Collection, 253 only inline), [None] and [point, None, point] bind correctly against the same database, and PL/SQL sees the NULL elements: patch.
- Does your application call init_oracle_client()?
No, this is Thin mode. Thick mode was not tested.
- Include a runnable Python script that shows the problem.
import os
import oracledb
def connect():
return oracledb.connect(
user=os.environ["PYO_USER"],
password=os.environ["PYO_PASSWORD"],
dsn=os.environ["PYO_DSN"],
)
with connect() as conn:
cursor = conn.cursor()
cursor.execute("create or replace type udt_point as object (x number, y number)")
cursor.execute("create or replace type udt_point_list as table of udt_point")
# None marks a NULL element of the nested table
for layout in (["point"], [None], ["point", None, "point"]):
conn = connect()
point = conn.gettype("UDT_POINT").newobject()
point.X = 1
elements = [point if e else None for e in layout]
value = conn.gettype("UDT_POINT_LIST").newobject(elements)
out = conn.cursor().var(int)
try:
conn.cursor().execute(
"declare l udt_point_list := :l; begin :n := l.count; end;",
l=value,
n=out,
)
print(layout, "-> ok, count =", out.getvalue())
except oracledb.Error as e:
print(layout, "->", " / ".join(str(e).splitlines()[:3]))
Output:
['point'] -> ok, count = 1
[None] -> DPY-4011: the database or network closed the connection / ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], [] / ORA-00600: internal error code, arguments: [kopp2ucoll233], [], [], [], [], [], [], [], [], [], [], []
['point', None, 'point'] -> DPY-4011: the database or network closed the connection / ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], [] / ORA-00600: internal error code, arguments: [kopp2ucoll233], [], [], [], [], [], [], [], [], [], [], []
- Ngôn ngữ chính
- Python
- Star
- 458
- Fork
- 123
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của oracle/python-oracledb
-
Free-threading supportĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
oracle/python-oracledb#642 · 1 bình luận ·
-
connection.gettype with large type def throws error: dbms_pickler: raw variable length too longĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
oracle/python-oracledb#641 · 6 bình luận ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
oracle/python-oracledb#639 ·
-
Client Library or Database
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
oracle/python-oracledb#637 · 2 bình luận ·
-
Client Library or Database
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
oracle/python-oracledb#633 · 2 bình luận ·
Tất cả issue của oracle/python-oracledb
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug improve content
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
opensafely/documentation#2102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:1 documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MakazhanAlpamys/Soup#3533 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
onyx-dot-app/onyx#18730 ·
Maintainer thường phản hồi trong vòng 1 ngày