Skip to content

Commit

Permalink
Modified offset member of structure dpiErrorInfo to be 32-bit instead…
Browse files Browse the repository at this point in the history
… of 16-bit

in order to allow for row offsets that exceed 65536. The original member has
been renamed to offset16 in order to retain backwards compatibility
(oracle/node-oracledb#1157).
  • Loading branch information
anthony-tuininga committed Dec 24, 2019
1 parent 477cf38 commit 294d596
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
5 changes: 5 additions & 0 deletions doc/src/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Version 3.4 (TBD)
``ORA-24344: success with compilation error`` (after a successful call to
:func:`dpiStmt_execute()` to create a stored procedure with compilation
errors).
#) Modified member :member:`dpiErrorInfo.offset` to be 32-bit and added new
member :member:`dpiErrorInfo.offset16` for backwards compatibility; in this
way row offsets that exceed 65536 can be reported successfully
(`node-oracledb issue 1157
<https://github.com/oracle/node-oracledb/issues/1157>`__).
#) Added method :func:`dpiConn_startupDatabaseWithPfile()` in order to support
starting up the database with a parameter file (PFILE), as requested
(`issue 41 <https://github.com/oracle/odpi/issues/41>`__).
Expand Down
13 changes: 9 additions & 4 deletions doc/src/structs/dpiErrorInfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ made.
The OCI error code if an OCI error has taken place. If no OCI error has
taken place the value is 0.

.. member:: uint16_t dpiErrorInfo.offset
.. member:: uint16_t dpiErrorInfo.offset16

The parse error offset (in bytes) when executing a statement or the row
offset when performing bulk operations or fetching batch error information.
If neither of these cases are true, the value is 0.
The 16-bit value of :member:`~dpiErrorInfo.offset` retained for backwards
compatibility. This member will be removed at some point in the future.

.. member:: const char \*dpiErrorInfo.message

Expand Down Expand Up @@ -61,3 +60,9 @@ made.
proceeding. Examples include connecting to the database with a password
that is about to expire (within the grace period) and creating a stored
procedure with compilation errors.

.. member:: uint16_t dpiErrorInfo.offset

The parse error offset (in bytes) when executing a statement or the row
offset when performing bulk operations or fetching batch error information.
If neither of these cases are true, the value is 0.
3 changes: 2 additions & 1 deletion include/dpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ struct dpiEncodingInfo {
// structure used for transferring error information from ODPI-C
struct dpiErrorInfo {
int32_t code;
uint16_t offset;
uint16_t offset16;
const char *message;
uint32_t messageLength;
const char *encoding;
Expand All @@ -535,6 +535,7 @@ struct dpiErrorInfo {
const char *sqlState;
int isRecoverable;
int isWarning;
uint32_t offset;
};

// structure used for transferring object attribute information from ODPI-C
Expand Down
1 change: 1 addition & 0 deletions src/dpiError.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ int dpiError__getInfo(dpiError *error, dpiErrorInfo *info)
return DPI_FAILURE;
info->code = error->buffer->code;
info->offset = error->buffer->offset;
info->offset16 = (uint16_t) error->buffer->offset;
info->message = error->buffer->message;
info->messageLength = error->buffer->messageLength;
info->fnName = error->buffer->fnName;
Expand Down
2 changes: 1 addition & 1 deletion src/dpiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ typedef struct {
// with the function dpiStmt_getBatchErrors()
typedef struct {
int32_t code; // Oracle error code or 0
uint16_t offset; // parse error offset or row offset
uint32_t offset; // parse error offset or row offset
dpiErrorNum errorNum; // OCPI-C error number
const char *fnName; // ODPI-C function name
const char *action; // internal action
Expand Down
4 changes: 2 additions & 2 deletions src/dpiQueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static int dpiQueue__deq(dpiQueue *queue, uint32_t *numProps,
queue->buffer.msgIds, error) < 0) {
if (error->buffer->code != 25228)
return DPI_FAILURE;
error->buffer->offset = (uint16_t) *numProps;
error->buffer->offset = *numProps;
}

// transfer message properties to destination array
Expand Down Expand Up @@ -315,7 +315,7 @@ static int dpiQueue__enq(dpiQueue *queue, uint32_t numProps,
queue->enqOptions->handle, &numProps, queue->buffer.handles,
payloadTDO, queue->buffer.instances, queue->buffer.indicators,
queue->buffer.msgIds, error) < 0) {
error->buffer->offset = (uint16_t) numProps;
error->buffer->offset = numProps;
return DPI_FAILURE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dpiSodaColl.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static int dpiSodaColl__insertMany(dpiSodaColl *coll, uint32_t numDocs,
dpiOci__attrGet(optionsHandle, DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS,
(void*) &docCount, 0, DPI_OCI_ATTR_SODA_DOC_COUNT,
NULL, error);
error->buffer->offset = (uint16_t) docCount;
error->buffer->offset = (uint32_t) docCount;
}
dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS);

Expand Down
9 changes: 5 additions & 4 deletions src/dpiStmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static int dpiStmt__execute(dpiStmt *stmt, uint32_t numIters,
uint32_t mode, int reExecute, dpiError *error)
{
uint32_t prefetchSize, i, j;
uint16_t tempOffset;
dpiData *data;
dpiVar *var;

Expand Down Expand Up @@ -600,9 +601,9 @@ static int dpiStmt__execute(dpiStmt *stmt, uint32_t numIters,
// drop statement from cache for all errors (except those which are due to
// invalid data which may be fixed in subsequent execution)
if (dpiOci__stmtExecute(stmt, numIters, mode, error) < 0) {
dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT,
&error->buffer->offset, 0, DPI_OCI_ATTR_PARSE_ERROR_OFFSET,
"set parse offset", error);
dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, &tempOffset, 0,
DPI_OCI_ATTR_PARSE_ERROR_OFFSET, "set parse offset", error);
error->buffer->offset = tempOffset;
switch (error->buffer->code) {
case 1007:
if (reExecute)
Expand Down Expand Up @@ -779,7 +780,7 @@ static int dpiStmt__getBatchErrors(dpiStmt *stmt, dpiError *error)
break;
}
localError.buffer->fnName = error->buffer->fnName;
localError.buffer->offset = (uint16_t) rowOffset;
localError.buffer->offset = (uint32_t) rowOffset;

}

Expand Down

0 comments on commit 294d596

Please sign in to comment.