From 469f4cba82f9728754e1e8dcfd3123eb5302d188 Mon Sep 17 00:00:00 2001 From: Elias Ohm Date: Thu, 4 Oct 2018 13:30:17 +0200 Subject: [PATCH 1/4] implement (LONG VAR)RAW/BINARY attributes for Objects - first try without changing signatures of existing functions --- src/dpiImpl.h | 2 ++ src/dpiObject.c | 27 +++++++++++++++++++++++++++ src/dpiOracleType.c | 1 + 3 files changed, 30 insertions(+) diff --git a/src/dpiImpl.h b/src/dpiImpl.h index 067e7e47..290b4a14 100644 --- a/src/dpiImpl.h +++ b/src/dpiImpl.h @@ -313,6 +313,7 @@ extern unsigned long dpiDebugLevel; #define DPI_SQLT_BIN 23 #define DPI_SQLT_LBI 24 #define DPI_SQLT_UIN 68 +#define DPI_SQLT_LVB 95 #define DPI_SQLT_AFC 96 #define DPI_SQLT_IBFLOAT 100 #define DPI_SQLT_IBDOUBLE 101 @@ -777,6 +778,7 @@ typedef union { void **asInterval; void **asLobLocator; void **asString; + void **asOciraw; void **asStmt; void **asRowid; int *asBoolean; diff --git a/src/dpiObject.c b/src/dpiObject.c index 2aabd9ec..d9c651c7 100644 --- a/src/dpiObject.c +++ b/src/dpiObject.c @@ -105,6 +105,11 @@ static void dpiObject__clearOracleValue(dpiObject *obj, dpiError *error, dpiOci__stringResize(obj->env->handle, &buffer->asString, 0, error); break; + case DPI_ORACLE_TYPE_RAW: + if (buffer->asRaw) + dpiOci__rawResize(obj->env->handle, &buffer->asRaw, 0, + error); + break; case DPI_ORACLE_TYPE_TIMESTAMP: if (buffer->asTimestamp) dpiOci__descriptorFree(buffer->asTimestamp, @@ -243,6 +248,17 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, return DPI_SUCCESS; } break; + case DPI_ORACLE_TYPE_RAW: + if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) { + asBytes = &data->value.asBytes; + dpiOci__rawPtr(obj->env->handle, *value->asOciraw, + &asBytes->ptr); + dpiOci__rawSize(obj->env->handle, *value->asOciraw, + &asBytes->length); + asBytes->encoding = NULL; + return DPI_SUCCESS; + } + break; case DPI_ORACLE_TYPE_NATIVE_INT: if (nativeTypeNum == DPI_NATIVE_TYPE_INT64) return dpiDataBuffer__fromOracleNumberAsInteger(&data->value, @@ -385,6 +401,17 @@ static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error, return DPI_SUCCESS; } break; + case DPI_ORACLE_TYPE_RAW: + buffer->asRaw = NULL; + if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) { + bytes = &data->value.asBytes; + if (dpiOci__rawAssignBytes(obj->env->handle, bytes->ptr, + bytes->length, &buffer->asRaw, error) < 0) + return DPI_FAILURE; + *ociValue = buffer->asRaw; + return DPI_SUCCESS; + } + break; case DPI_ORACLE_TYPE_NATIVE_INT: case DPI_ORACLE_TYPE_NUMBER: *ociValue = &buffer->asNumber; diff --git a/src/dpiOracleType.c b/src/dpiOracleType.c index e22d20fc..595e31cc 100644 --- a/src/dpiOracleType.c +++ b/src/dpiOracleType.c @@ -309,6 +309,7 @@ static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode, case DPI_SQLT_ODT: return DPI_ORACLE_TYPE_DATE; case DPI_SQLT_BIN: + case DPI_SQLT_LVB: return DPI_ORACLE_TYPE_RAW; case DPI_SQLT_AFC: if (charsetForm == DPI_SQLCS_NCHAR) From 47367fe4eca82f89acac2883dec0ef2d4fe9107a Mon Sep 17 00:00:00 2001 From: Elias Ohm Date: Thu, 4 Oct 2018 14:08:52 +0200 Subject: [PATCH 2/4] added cast to disable warnings... --- src/dpiObject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpiObject.c b/src/dpiObject.c index d9c651c7..ae193441 100644 --- a/src/dpiObject.c +++ b/src/dpiObject.c @@ -252,7 +252,7 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) { asBytes = &data->value.asBytes; dpiOci__rawPtr(obj->env->handle, *value->asOciraw, - &asBytes->ptr); + (void **)&asBytes->ptr); dpiOci__rawSize(obj->env->handle, *value->asOciraw, &asBytes->length); asBytes->encoding = NULL; From c182c82e561124d14726d86bd7b0c05cb82b95c0 Mon Sep 17 00:00:00 2001 From: Elias Ohm Date: Thu, 4 Oct 2018 14:50:37 +0200 Subject: [PATCH 3/4] changed void to char ptr (dpiOci__rawPtr) --- src/dpiDeqOptions.c | 2 +- src/dpiImpl.h | 2 +- src/dpiMsgProps.c | 4 ++-- src/dpiObject.c | 2 +- src/dpiOci.c | 2 +- src/dpiSubscr.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dpiDeqOptions.c b/src/dpiDeqOptions.c index 309eb05e..c1c68014 100644 --- a/src/dpiDeqOptions.c +++ b/src/dpiDeqOptions.c @@ -171,7 +171,7 @@ int dpiDeqOptions_getMsgId(dpiDeqOptions *options, const char **value, &rawValue, NULL, DPI_OCI_ATTR_DEQ_MSGID, "get attribute value", &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); - dpiOci__rawPtr(options->env->handle, rawValue, (void**) value); + dpiOci__rawPtr(options->env->handle, rawValue, value); dpiOci__rawSize(options->env->handle, rawValue, valueLength); return dpiGen__endPublicFn(options, DPI_SUCCESS, &error); } diff --git a/src/dpiImpl.h b/src/dpiImpl.h index 290b4a14..b1ba5c17 100644 --- a/src/dpiImpl.h +++ b/src/dpiImpl.h @@ -1518,7 +1518,7 @@ int dpiOci__passwordChange(dpiConn *conn, const char *userName, int dpiOci__ping(dpiConn *conn, dpiError *error); int dpiOci__rawAssignBytes(void *envHandle, const char *value, uint32_t valueLength, void **handle, dpiError *error); -int dpiOci__rawPtr(void *envHandle, void *handle, void **ptr); +int dpiOci__rawPtr(void *envHandle, void *handle, char **ptr); int dpiOci__rawResize(void *envHandle, void **handle, uint32_t newSize, dpiError *error); int dpiOci__rawSize(void *envHandle, void *handle, uint32_t *size); diff --git a/src/dpiMsgProps.c b/src/dpiMsgProps.c index 24260897..7cfff888 100644 --- a/src/dpiMsgProps.c +++ b/src/dpiMsgProps.c @@ -41,7 +41,7 @@ int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw, { const char *rawPtr; - dpiOci__rawPtr(props->env->handle, ociRaw, (void**) &rawPtr); + dpiOci__rawPtr(props->env->handle, ociRaw, &rawPtr); dpiOci__rawSize(props->env->handle, ociRaw, msgIdLength); if (*msgIdLength > props->bufferLength) { if (props->buffer) { @@ -259,7 +259,7 @@ int dpiMsgProps_getOriginalMsgId(dpiMsgProps *props, const char **value, &rawValue, NULL, DPI_OCI_ATTR_ORIGINAL_MSGID, "get attribute value", &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); - dpiOci__rawPtr(props->env->handle, rawValue, (void**) value); + dpiOci__rawPtr(props->env->handle, rawValue, value); dpiOci__rawSize(props->env->handle, rawValue, valueLength); return dpiGen__endPublicFn(props, DPI_SUCCESS, &error); } diff --git a/src/dpiObject.c b/src/dpiObject.c index ae193441..d9c651c7 100644 --- a/src/dpiObject.c +++ b/src/dpiObject.c @@ -252,7 +252,7 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) { asBytes = &data->value.asBytes; dpiOci__rawPtr(obj->env->handle, *value->asOciraw, - (void **)&asBytes->ptr); + &asBytes->ptr); dpiOci__rawSize(obj->env->handle, *value->asOciraw, &asBytes->length); asBytes->encoding = NULL; diff --git a/src/dpiOci.c b/src/dpiOci.c index 292e5be3..8432d91f 100644 --- a/src/dpiOci.c +++ b/src/dpiOci.c @@ -2445,7 +2445,7 @@ int dpiOci__rawAssignBytes(void *envHandle, const char *value, // dpiOci__rawPtr() [INTERNAL] // Wrapper for OCIRawPtr(). //----------------------------------------------------------------------------- -int dpiOci__rawPtr(void *envHandle, void *handle, void **ptr) +int dpiOci__rawPtr(void *envHandle, void *handle, char **ptr) { dpiError *error = NULL; diff --git a/src/dpiSubscr.c b/src/dpiSubscr.c index 644d3983..f7fc5107 100644 --- a/src/dpiSubscr.c +++ b/src/dpiSubscr.c @@ -401,7 +401,7 @@ static int dpiSubscr__populateMessage(dpiSubscr *subscr, if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES, &rawValue, NULL, DPI_OCI_ATTR_CHDES_XID, "get transaction id", error) < 0) return DPI_FAILURE; - dpiOci__rawPtr(subscr->env->handle, rawValue, (void**) &message->txId); + dpiOci__rawPtr(subscr->env->handle, rawValue, (char**) &message->txId); dpiOci__rawSize(subscr->env->handle, rawValue, &message->txIdLength); // populate event specific attributes From 82f2e5702692ab8a1171ab53b04ae2972a63ca87 Mon Sep 17 00:00:00 2001 From: Elias Ohm Date: Thu, 4 Oct 2018 14:55:43 +0200 Subject: [PATCH 4/4] add casts to avoid compiler warnings --- src/dpiDeqOptions.c | 2 +- src/dpiMsgProps.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dpiDeqOptions.c b/src/dpiDeqOptions.c index c1c68014..6cb542f5 100644 --- a/src/dpiDeqOptions.c +++ b/src/dpiDeqOptions.c @@ -171,7 +171,7 @@ int dpiDeqOptions_getMsgId(dpiDeqOptions *options, const char **value, &rawValue, NULL, DPI_OCI_ATTR_DEQ_MSGID, "get attribute value", &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); - dpiOci__rawPtr(options->env->handle, rawValue, value); + dpiOci__rawPtr(options->env->handle, rawValue, (char **)value); dpiOci__rawSize(options->env->handle, rawValue, valueLength); return dpiGen__endPublicFn(options, DPI_SUCCESS, &error); } diff --git a/src/dpiMsgProps.c b/src/dpiMsgProps.c index 7cfff888..561f0375 100644 --- a/src/dpiMsgProps.c +++ b/src/dpiMsgProps.c @@ -41,7 +41,7 @@ int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw, { const char *rawPtr; - dpiOci__rawPtr(props->env->handle, ociRaw, &rawPtr); + dpiOci__rawPtr(props->env->handle, ociRaw, (char **)&rawPtr); dpiOci__rawSize(props->env->handle, ociRaw, msgIdLength); if (*msgIdLength > props->bufferLength) { if (props->buffer) { @@ -259,7 +259,7 @@ int dpiMsgProps_getOriginalMsgId(dpiMsgProps *props, const char **value, &rawValue, NULL, DPI_OCI_ATTR_ORIGINAL_MSGID, "get attribute value", &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); - dpiOci__rawPtr(props->env->handle, rawValue, value); + dpiOci__rawPtr(props->env->handle, rawValue, (char **)value); dpiOci__rawSize(props->env->handle, rawValue, valueLength); return dpiGen__endPublicFn(props, DPI_SUCCESS, &error); }