Execute hangs or throws unclear error on divide by zero situation · Issue #472 · oracle/python-oracledb (original) (raw)
- What versions are you using?
Oracle 19.0.0.0.ru-2024-07.rur-2024-07.r1 (hosted on Amazon RDS)
platform.platform: macOS-15.1.1-arm64-arm-64bit
sys.maxsize > 2**32: True
platform.python_version: 3.12.6
oracledb.__version__: 3.0.0 (I had the same issue in 2.5.1)
- Is it an error or a hang or a crash?
Both, depending on various parameters
- What error(s) or behavior you are seeing?
oracledb.defaults.prefetchrows = 10_000 oracledb.defaults.arraysize = 10_000
with get_database_connection().cursor() as cursor: # cursor.execute("drop table example_table") cursor.execute("create table example_table(id number generated by default on null as identity, data number)")
# Populate the table with data; data is `2` except for one row which is `0`
cursor.executemany("insert into example_table(data) values (2)", [tuple() for _ in range(20_000)])
cursor.execute("insert into example_table(data) values (0)")
cursor.connection.commit()
print("inserted")
successful_query = cursor.execute("SELECT id, data FROM EXAMPLE_TABLE").fetchall()
print("total records:", len(successful_query)) # Prints 20002
# Fails with error `DPY-5000: internal error: unknown protocol message type 1 at position 10`
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE").fetchall()
# Fails with the seemingly correct error `ORA-01476: divisor is equal to zero`
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE order by id").fetchall()
# Hangs for values from 1 to 19000
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE where id > 1").fetchall()
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE where id > 19000").fetchall()
# Fails with the seemingly correct error `ORA-01476: divisor is equal to zero`
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE where id > 19001").fetchall()
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE where id > 20000").fetchall()
# Succeeds (returns nothing) as expected
cursor.execute("SELECT id, 1 / data FROM EXAMPLE_TABLE where id > 20001").fetchall()
# I've also gotten errors like `ValueError: could not convert string to float: b'2.482419253800I50'`
# or `ValueError: invalid literal for int() with base 10: b'200I500'` when running a similar query,
# but I haven't managed to recreate that consistently here
- Does your application call init_oracle_client()?
No, I use thin mode