Skip to content

Commit

Permalink
fix(oracle): disable statement cache
Browse files Browse the repository at this point in the history
Oracle really doesn't like to "re" prepare a statement, which means
attempting to execute two bound expressions in succession with the same
name will usual fail, or "work" in unexpected ways.

https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_b.html#statement-caching-in-thin-and-thick-modes
https://python-oracledb.readthedocs.io/en/latest/user_guide/tuning.html#setting-the-statement-cache

We set the cache to size 0 to disable it to avoid these shenanigans.
  • Loading branch information
gforsyth authored and cpcloud committed May 5, 2023
1 parent 25e2f21 commit 41d3857
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ibis/backends/oracle/__init__.py
Expand Up @@ -127,7 +127,12 @@ def do_connect(
engine = sa.create_engine(
url,
poolclass=sa.pool.StaticPool,
connect_args={"service_name": database},
# We set the statement cache size to 0 because Oracle will otherwise
# attempt to reuse prepared statements even if the type of the bound variable
# has changed.
# This is apparently accepted behavior.
# https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_b.html#statement-caching-in-thin-and-thick-modes
connect_args={"service_name": database, "stmtcachesize": 0},
)

super().do_connect(engine)
Expand Down

0 comments on commit 41d3857

Please sign in to comment.