diff --git a/doc/src/releasenotes.rst b/doc/src/releasenotes.rst index 15cb3bf9..87825321 100644 --- a/doc/src/releasenotes.rst +++ b/doc/src/releasenotes.rst @@ -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 + `__). #) Added method :func:`dpiConn_startupDatabaseWithPfile()` in order to support starting up the database with a parameter file (PFILE), as requested (`issue 41 `__). diff --git a/doc/src/structs/dpiErrorInfo.rst b/doc/src/structs/dpiErrorInfo.rst index ab0b1291..5214c64e 100644 --- a/doc/src/structs/dpiErrorInfo.rst +++ b/doc/src/structs/dpiErrorInfo.rst @@ -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 @@ -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. diff --git a/include/dpi.h b/include/dpi.h index 97de07d5..edbfa8f6 100644 --- a/include/dpi.h +++ b/include/dpi.h @@ -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; @@ -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 diff --git a/src/dpiError.c b/src/dpiError.c index bf126dfc..236f9259 100644 --- a/src/dpiError.c +++ b/src/dpiError.c @@ -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; diff --git a/src/dpiImpl.h b/src/dpiImpl.h index b9497b63..42fb7cf9 100644 --- a/src/dpiImpl.h +++ b/src/dpiImpl.h @@ -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 diff --git a/src/dpiQueue.c b/src/dpiQueue.c index 9c2f39a9..03a9117d 100644 --- a/src/dpiQueue.c +++ b/src/dpiQueue.c @@ -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 @@ -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; } } diff --git a/src/dpiSodaColl.c b/src/dpiSodaColl.c index b0a0ded7..6427424f 100644 --- a/src/dpiSodaColl.c +++ b/src/dpiSodaColl.c @@ -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); diff --git a/src/dpiStmt.c b/src/dpiStmt.c index 669b7891..0dcfde52 100644 --- a/src/dpiStmt.c +++ b/src/dpiStmt.c @@ -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; @@ -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) @@ -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; }