Skip to content

Commit

Permalink
Internal change: let the Oracle Client library know that bound REF
Browse files Browse the repository at this point in the history
CURSOR statement handles will not be re-used for any other purpose.
  • Loading branch information
anthony-tuininga committed Jul 23, 2024
1 parent 4ed44dc commit 1369573
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions doc/src/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Version 5.3 (TBD)
#) Eliminated memory leak when dequeing messages with JSON payloads
(`python-oracledb issue 346
<https://github.com/oracle/python-oracledb/issues/346>`__).
#) Internal change: let the Oracle Client library know that bound REF CURSOR
statement handles will not be re-used for any other purpose.


Version 5.2 (March 11, 2024)
Expand Down
1 change: 1 addition & 0 deletions src/dpiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ extern unsigned long dpiDebugLevel;
#define DPI_OCI_SODA_INDEX_DROP_FORCE 0x00010000
#define DPI_OCI_TRANS_TWOPHASE 0x01000000
#define DPI_OCI_SECURE_NOTIFICATION 0x20000000
#define DPI_OCI_BIND_DEDICATED_REF_CURSOR 0x00000400

//-----------------------------------------------------------------------------
// Macros
Expand Down
24 changes: 16 additions & 8 deletions src/dpiOci.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,11 @@ int dpiOci__attrSet(void *handle, uint32_t handleType, void *ptr,
int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name,
int32_t nameLength, int dynamicBind, dpiVar *var, dpiError *error)
{
uint32_t mode = DPI_OCI_BIND_DEDICATED_REF_CURSOR;
int status;

if (dynamicBind)
mode |= DPI_OCI_DATA_AT_EXEC;
DPI_OCI_LOAD_SYMBOL("OCIBindByName", dpiOciSymbols.fnBindByName)
DPI_OCI_ENSURE_ERROR_HANDLE(error)
status = (*dpiOciSymbols.fnBindByName)(stmt->handle, bindHandle,
Expand All @@ -871,8 +874,7 @@ int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name,
var->buffer.actualLength16,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
(var->isArray) ? &var->buffer.actualArraySize : NULL, mode);
DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by name");
}

Expand All @@ -884,8 +886,11 @@ int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name,
int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name,
int32_t nameLength, int dynamicBind, dpiVar *var, dpiError *error)
{
uint32_t mode = DPI_OCI_BIND_DEDICATED_REF_CURSOR;
int status;

if (dynamicBind)
mode |= DPI_OCI_DATA_AT_EXEC;
DPI_OCI_LOAD_SYMBOL("OCIBindByName2", dpiOciSymbols.fnBindByName2)
DPI_OCI_ENSURE_ERROR_HANDLE(error)
status = (*dpiOciSymbols.fnBindByName2)(stmt->handle, bindHandle,
Expand All @@ -898,8 +903,7 @@ int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name,
var->buffer.actualLength32,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
(var->isArray) ? &var->buffer.actualArraySize : NULL, mode);
DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by name");
}

Expand All @@ -911,8 +915,11 @@ int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name,
int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos,
int dynamicBind, dpiVar *var, dpiError *error)
{
uint32_t mode = DPI_OCI_BIND_DEDICATED_REF_CURSOR;
int status;

if (dynamicBind)
mode |= DPI_OCI_DATA_AT_EXEC;
DPI_OCI_LOAD_SYMBOL("OCIBindByPos", dpiOciSymbols.fnBindByPos)
DPI_OCI_ENSURE_ERROR_HANDLE(error)
status = (*dpiOciSymbols.fnBindByPos)(stmt->handle, bindHandle,
Expand All @@ -924,8 +931,7 @@ int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos,
var->buffer.actualLength16,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
(var->isArray) ? &var->buffer.actualArraySize : NULL, mode);
DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by position");
}

Expand All @@ -937,8 +943,11 @@ int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos,
int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos,
int dynamicBind, dpiVar *var, dpiError *error)
{
uint32_t mode = DPI_OCI_BIND_DEDICATED_REF_CURSOR;
int status;

if (dynamicBind)
mode |= DPI_OCI_DATA_AT_EXEC;
DPI_OCI_LOAD_SYMBOL("OCIBindByPos2", dpiOciSymbols.fnBindByPos2)
DPI_OCI_ENSURE_ERROR_HANDLE(error)
status = (*dpiOciSymbols.fnBindByPos2)(stmt->handle, bindHandle,
Expand All @@ -950,8 +959,7 @@ int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos,
var->buffer.actualLength32,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
(var->isArray) ? &var->buffer.actualArraySize : NULL, mode);
DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by position");
}

Expand Down

0 comments on commit 1369573

Please sign in to comment.