cursor.execute() fails when fetching from table with NCLOB column and IS JSON check. (original) (raw)

cursor.execute() crashes when fetching from table with NCLOB column and IS JSON check. The following SQL crashes in Django:

cursor.execute('SELECT * FROM "INSPECTDB_JSONFIELDCOLUMNTYPE" WHERE ROWNUM < 2 AND 2 > 0')

(it works with the 1.4.2 version).

Table definition:

CREATE TABLE "INSPECTDB_JSONFIELDCOLUMNTYPE" ( "ID" NUMBER(11) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL PRIMARY KEY, "JSON_FIELD" NCLOB NOT NULL CHECK ("JSON_FIELD" IS JSON), "NULL_JSON_FIELD" NCLOB NULL CHECK ("NULL_JSON_FIELD" IS JSON) )

  1. What versions are you using?

Oracle 23c (crashes the same way on Oracle 19c).

platform.platform: Linux-5.15.0-89-generic-x86_64-with-glibc2.35
sys.maxsize > 2**32: True
platform.python_version: 3.10.9
oracledb.__version__: 2.0.0
  1. Is it an error or a hang or a crash?

crash

  1. What error(s) or behavior you are seeing?
  File "python3.10/site-packages/oracledb/cursor.py", line 744, in execute
    impl.execute(self)
  File "src/oracledb/impl/thin/cursor.pyx", line 173, in oracledb.thin_impl.ThinCursorImpl.execute
  File "src/oracledb/impl/thin/protocol.pyx", line 425, in oracledb.thin_impl.Protocol._process_single_message
  File "src/oracledb/impl/thin/messages.pyx", line 1323, in oracledb.thin_impl.MessageWithData.postprocess
IndexError: list index out of range

  1. Does your application call init_oracle_client()?

No

  1. Include a runnable Python script that shows the problem.

I was not able to reproduce it with the bare oracledb cursor or Django cursor, but it crashes in our test suite. Maybe previous fetchall(), fetchone(), execute() calls affect it somehow 🤔 🤯