Skip to content
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

Fetching rows with a UROWID typed column segfaults if several rows have the same value #120

Closed
markfinn opened this issue Nov 28, 2017 · 5 comments
Labels

Comments

@markfinn
Copy link

cx_oracle 681c186
11xe database
12.2 client
64 bit linux.

with these tables:

CREATE TABLE change_log_target_test
(
num NUMBER NOT NULL PRIMARY KEY
)

CREATE TABLE change_log_test
(
changeid NUMBER NOT NULL PRIMARY KEY,
xrowid UROWID not null
)
this code segfaults:

import cx_Oracle
con = cx_Oracle.connect('user', 'pw', 'localhost')
c=con.cursor()
c.execute('delete from change_log_test')
c.execute('delete from change_log_target_test')
c.execute('insert into change_log_target_test(num) values(1)')
c.execute('insert into change_log_test(changeid, xrowid) values(1, (select rowid from change_log_target_test where num=1))')
c.execute('insert into change_log_test(changeid, xrowid) values(2, (select rowid from change_log_target_test where num=1))')
c.execute('insert into change_log_test(changeid, xrowid) values(3, (select rowid from change_log_target_test where num=1))')
con.commit()

c=con.cursor()
c.execute('select * from change_log_test')
c.fetchone()
c.fetchone()
c.fetchone()

You can do this all day if the rowids are different in each row, but the thrird row to have a duplicate value in the xrowid column segfaults in:

0 0x00007f54fe83ea90 in kgrdub2c () from /tmp/venvzz/oracle/instantclient_12_2/libclntsh.so.12.1
1 0x00007f54fd806f9f in kpuubrid2c () from /tmp/venvzz/oracle/instantclient_12_2/libclntsh.so.12.1
2 0x00007f5505ac2c24 in dpiOci__rowidToChar (rowid=0x32043f0, buffer=0x7ffd505ea037 "", bufferSize=0x3204418, error=0x7ffd505ea040)
at odpi/src/dpiOci.c:2242
3 0x00007f5505ad3a2d in dpiRowid_getStringValue (rowid=0x32043f0, value=value@entry=0x7ffd505ea0a0, valueLength=valueLength@entry=0x7ffd505ea09c)
at odpi/src/dpiRowid.c:90
4 0x00007f5505ad3b4a in RowidVar_GetValue (var=, data=) at src/StringVar.c:105
5 0x00007f5505abac1e in Variable_GetSingleValue (arrayPos=2, var=0x7f550e2ef500) at src/Variable.c:718
6 Cursor_CreateRow (self=self@entry=0x7f550d169df0, pos=2) at src/Cursor.c:925
7 0x00007f5505ae8a29 in Cursor_FetchOne (self=0x7f550d169df0, args=) at src/Cursor.c:1632
8 0x00000000004b9117 in call_function (oparg=, pp_stack=0x7ffd505ea200) at Python/ceval.c:4336
9 PyEval_EvalFrameEx (f=f@entry=0x7f550f125be8, throwflag=throwflag@entry=0) at Python/ceval.c:2989
10 0x00000000004bacb8 in PyEval_EvalCodeEx (co=co@entry=0x7f550d212030, globals=globals@entry=0x7f550ed365c8, locals=locals@entry=0x7f550ed365c8,
args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0, defcount=defcount@entry=0,
closure=closure@entry=0x0) at Python/ceval.c:3584
...

@anthony-tuininga
Copy link
Member

If you set the environment variable ORA_OCI_NO_OPTIMIZED_FETCH to the value 1 prior to running the program does the problem go away? If so, this is a known issue.

@markfinn
Copy link
Author

That does seem to make it go away. Is that an issue with the database, instantclient, or something else?

@anthony-tuininga
Copy link
Member

Its a bug in the OCI libraries: 26225722. Setting that environment variable is the only workaround for now that I am aware of. Sorry!

@markfinn
Copy link
Author

Thanks.

@hexaclock
Copy link

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants