-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multibyte string in query results in ORA-03120/ORA-03146 DatabaseError #133
Comments
Thanks for the report. To help up diagnose the issue, can you provide a SQL script that creates the table and inserts some problematic data? What's the DB character set & national character set - see here for queries to run. What OS are you running Python on? What's your version of Python? |
Hi, thanks for the prompt response. As I don't have the necessary privileges to test table creation, I can't confirm if the following would reproduce the issue:
DB charset: JA16SJISTILDE |
That table and query work fine for me. I am, however, using database character set AL32UTF8 which is a universal character set. This may be relevant for your case. It would be useful to run this code: import oracledb
conn = oracledb.connect("user/password@host/service_name")
cursor = conn.cursor()
value = 'カタカナ'
sql = f"select '{value}' from dual"
cursor.execute(sql)
print("result:", cursor.fetchall()) That gives me the following result:
which shows that the encoding is working fine. Can you try the same with your database? |
One other thing: assuming that the above query works for you, can you also check the output of this query?
My results are as follows:
|
Thanks for your suggestion. |
Yes, I get a similar result (the string I gave was just a dummy one). |
When you say 'dummy one', do you mean this string doesn't reproduce the problem for you? We need to be using the same data as you. Out of interest, can you confirm there is no problem when you enable Thick mode? |
Sorry, I'm afraid I cannot share the specific strings we have in our DB as they are sensitive. However, this is a common issue with any Japanese multibyte string we have (as with the dummy). We have not been able to try |
OK I found one string you could try with: |
I tried that string. It works just as well as the other one. I modified my code as follows: import oracledb
conn = oracledb.connect("user/password@host/service_name")
cursor = conn.cursor()
value = 'ディテール'
sql = f"select '{value}' from dual"
cursor.execute(sql)
fetched_value, = cursor.fetchone()
print("Matches?", fetched_value == value) The output shows that it matches. If you use this code, do you get the bug? Or are you using some other code? |
I get a |
That suggests that you may have corrupted data in your database. I modified my script as follows: import oracledb
# oracledb.init_oracle_client()
conn = oracledb.connect("user/password@host/service_name")
cursor = conn.cursor()
value = 'ディテール'
sql = f"select '{value}', dump('{value}') from dual"
cursor.execute(sql)
fetched_value, dumped_value = cursor.fetchone()
print("Matches?", fetched_value == value)
print("Dumped value:", dumped_value) Can you run the same and confirm that you get this value:
Assuming you do, run |
Sorry, please ignore my previous post... I was using a connector to snowflake and not oracle!
Above is the error dump from the first task you asked me to do when using |
I am able to replicate your issue when using your character set on the database. I'll get back to you on the solution once I have it! |
Fantastic! |
I have pushed a patch that should correct this issue and added a relevant test case. If you are able to build from source you can verify that it corrects your issue as well. |
This has been included in version 1.3.0 which was just released. |
Hi,
DB: Oracle Database 12c EE Extreme Perf Release 12.1.0.2.0 - 64bit Production
Client: oracledb.version: 1.2.2
DatabaseError
We are currently facing an issue where certain query strings that use to work with
cx_Oracle
are throwing either ORA-03120 or ORA-03146 errors. The same query using DBeaver client works so the issue is likely withoracledb
.Our code goes like:
Which results in
DatabaseError: ORA-03146: Invalid buffer length for TTC field
If we added a limit on the results, a different
DatabaseError
is thrownThis will result in
ORA-03120: two-task conversion routine: integer overflow
After trial and error, we found that using bind variable helps to get us past this issue:
No, we use the thin client. But the same queries work with cx_Oracle and DBeaver client.
See above.
Thanks!
The text was updated successfully, but these errors were encountered: