-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
bugSomething isn't workingSomething isn't working
Description
- What versions are you using?
platform.platform: Linux-5.4.17-2136.342.5.3.el8uek.x86_64-x86_64-with-glibc2.28
sys.maxsize > 2**32: True
platform.python_version: 3.9.20
oracledb.version: 3.1.1
- Is it an error or a hang or a crash?
error
- What error(s) or behavior you are seeing?
File "test.py", line 34, in <module>
rows = cursor.fetchall()
File ".venv/lib64/python3.9/site-packages/oracledb/cursor.py", line 777, in fetchall
row = fetch_next_row(self)
File "src/oracledb/impl/base/cursor.pyx", line 575, in oracledb.base_impl.BaseCursorImpl.fetch_next_row
File "src/oracledb/impl/base/cursor.pyx", line 256, in oracledb.base_impl.BaseCursorImpl._create_row
File "src/oracledb/impl/thick/var.pyx", line 189, in oracledb.thick_impl.ThickVarImpl._get_scalar_value
File "src/oracledb/impl/thick/var.pyx", line 444, in oracledb.thick_impl.ThickVarImpl._transform_element_to_python
File "src/oracledb/impl/thick/var.pyx", line 167, in oracledb.thick_impl.ThickVarImpl._get_lob_value
AttributeError: 'list' object has no attribute '_impl'
- Does your application call init_oracle_client()?
yes
- Include a runnable Python script that shows the problem.
oracledb.init_oracle_client()
conn = oracledb.connect(user=..., password=..., dns=...)
sql = f"""
SELECT * FROM my_clob_table
"""
cursor.execute(sql)
rows = cursor.fetchall()
The quintessence seems to be that we have a CLOB field where config parameters are saved in a manner like this:
[ { "name": "test123", "host": [ "host1", "host4", "host7"], "command_name": "dosomething", "command_params": ["param1", "param2", "param3"] } ]
which causes the fetchall to fail.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
anthony-tuininga commentedon Jun 18, 2025
Can you supply a more complete scenario that demonstrates the problem? Simply fetching from CLOBs doesn't result in this issue at least! Is the issue present when a CLOB contains the supplied data? If a single row with that data in it is fetched does it result in the problem?
Lunnaris01 commentedon Jun 19, 2025
That's correct, I only encountered the issue for a single table where the clob field contained the specificly formatted data while running the script for many tables, many of them including clobs.
From the traceback I would guess the specific syntax of the content of the clob caused a weird interaction. I will try to reproduce the issue with a dummy database and if I can reproduce it I'll check single row fetching as well.
cjbj commentedon Jun 19, 2025
@Lunnaris01 what is a "poorly formatted clob". Does your CLOB have a check constraint IS JSON?
Lunnaris01 commentedon Jun 19, 2025
The "poorly formatted clob" really just refered to my idea of the syntax/format being the root cause of the issue. While the content seems to be a json or something similar from the text I personally doubt there is going to be a check constraint on it but I'll check it tomorrow and change the title to be less insulting to the json format
[-]Error with fetchall() for poorly formatted clobs[/-][+]Error with fetchall() for clobs with content of specific syntax/format?[/+]Lunnaris01 commentedon Jun 20, 2025
@cjbj good call, seems like there is a check constraint for is json, however it is disabled. When I created a test table with the same structure and turned the check on, attempting to insert the data present in the original table gave an ORA-02290 for not satisfying the check.
Most likely the check was added assuming the data would be formatted in json and then disabled when the check didn't work with the idea of maybe fixing the input data later on and reenableing it, but seems like that wasn't achieved yet.
I dropped the constraint and everything worked fine again.
[-]Error with fetchall() for clobs with content of specific syntax/format?[/-][+]Error with fetchall() for clobs with existing but disabled json check constraint and non json conform content[/+]cjbj commentedon Jun 20, 2025
I'm glad you are past the problem, but it is an interesting one that would be good to have fixed.
To help us try to reproduce it, can you share the values of the DB version:
connection.version
, and the client version:oracledb.clientversion()
?Lunnaris01 commentedon Jul 1, 2025
connection.version: 19.26.0.0.0
oracledb.clientversion(): (21, 11, 0, 0, 0)
Sadly when I asked a colleague about the table just to get some more information why it existed and if he knew why there was a disabled json check he later came back to me saying he deleted it because it was apparently obsolete, thus I can't fully replicate the situation.
I tried to replicate the error with a dummy table. I am still able to produce an error with the disabled is json check but it is a different one, I'm not sure why exactly:
I think the gist of it is that despite the is json check being disabled the clob is still interpreted as a json and the fetchall will however assume that it actually is a json
The problem is recreatable when dropping and readding the constraint.
ALTER TABLE "TEST"."python_bugtest" ADD CONSTRAINT json_check_constraint CHECK(test_clob_column IS JSON) DISABLE;
-> fetching will fail
ALTER TABLE "TEST"."python_bugtest" DROP CONSTRAINT json_check_constraint;
-> fetching will work fine.
Note that adding the constraint without the disable naturally produced an error since the data violates the check constraints.
*Cause: an alter table operation tried to validate a check constraint to
populated table that had nocomplying values.
*Action: Obvious
earlybard commentedon Jul 8, 2025
I'm getting the same error with the following conditions
ALTER TABLE X ADD CONSTRAINT Y CHECK (Z IS JSON)
Either removing the constraint or running in Thin mode fixes the issue - unfortunately I need both!
cjbj commentedon Jul 8, 2025
@earlybard what Oracle Database & Oracle Client versions are you using? And python-oracledb version?
earlybard commentedon Jul 8, 2025
Oracle Database - 19.0.0.0.ru-2025-04.rur-2025-04.r1 running on Amazon RDS. I've seen it on other non-cloud instances of 19 too.
Oracle Client - https://download.oracle.com/otn_software/linux/instantclient/2380000/instantclient-basic-linux.x64-23.8.0.25.04.zip
python-oracledb - 3.1.0
Python - 3.12.11
Django - 5.2.1
cjbj commentedon Jul 9, 2025
@earlybard this smells like an Oracle client / DB issue, but maybe python-oracledb can workaround it if we can reproduce it.
What does
print(connection.version)
give for the DB version?earlybard commentedon Jul 9, 2025
@cjbj - '19.27.0.0.0'
Thanks for looking into this!
cjbj commentedon Jul 10, 2025
We're tracking this as an Oracle bug 37445305 which is assigned to the database team.