Skip to content

Commit

Permalink
Correct parameter to dpiConn_newSubscription() as noted in issue #28.…
Browse files Browse the repository at this point in the history
… There is

no OCI documentation for the registration id attribute and it should not be
exposed.  The parameter is also deprecated and will be removed in version 2.1
of the ODPI-C API.
  • Loading branch information
anthony-tuininga committed Aug 17, 2017
1 parent 8dac85e commit d03de1d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
5 changes: 3 additions & 2 deletions doc/src/public_functions/dpiConn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ handles.

.. function:: int dpiConn_newSubscription(dpiConn \*conn, \
dpiSubscrCreateParams \*params, dpiSubscr \**subscr, \
uint32_t \*subscrId)
uint64_t \*subscrId)

Returns a reference to a subscription which is used for requesting
notifications of changes on tables or queries that are made in the
Expand All @@ -539,7 +539,8 @@ handles.
created by this function.

**subscrId** [OUT] -- a pointer to the id of the subscription that is
created by this function.
created by this function, or NULL. This parameter is deprecated and will be
removed in version 2.1.


.. function:: int dpiConn_newTempLob(dpiConn \*conn, \
Expand Down
2 changes: 1 addition & 1 deletion include/dpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ int dpiConn_newMsgProps(dpiConn *conn, dpiMsgProps **props);

// create a new subscription for events
int dpiConn_newSubscription(dpiConn *conn, dpiSubscrCreateParams *params,
dpiSubscr **subscr, uint32_t *subscrId);
dpiSubscr **subscr, uint64_t *subscrId);

// create a new temporary LOB
int dpiConn_newTempLob(dpiConn *conn, dpiOracleTypeNum lobType, dpiLob **lob);
Expand Down
4 changes: 2 additions & 2 deletions samples/TestCQN.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ void TestCallback(void *context, dpiSubscrMessage *message)
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
uint32_t subscrId, numQueryColumns, i;
dpiCommonCreateParams commonParams;
dpiSubscrCreateParams createParams;
uint32_t numQueryColumns, i;
dpiSampleParams *params;
dpiSubscr *subscr;
uint64_t queryId;
Expand All @@ -98,7 +98,7 @@ int main(int argc, char **argv)
return dpiSamples_showError();
createParams.qos = DPI_SUBSCR_QOS_QUERY | DPI_SUBSCR_QOS_ROWIDS;
createParams.callback = TestCallback;
if (dpiConn_newSubscription(conn, &createParams, &subscr, &subscrId) < 0)
if (dpiConn_newSubscription(conn, &createParams, &subscr, NULL) < 0)
return dpiSamples_showError();

// register query
Expand Down
3 changes: 1 addition & 2 deletions src/dpiConn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ int dpiConn_newMsgProps(dpiConn *conn, dpiMsgProps **props)
// Create a new subscription and return it.
//-----------------------------------------------------------------------------
int dpiConn_newSubscription(dpiConn *conn, dpiSubscrCreateParams *params,
dpiSubscr **subscr, uint32_t *subscrId)
dpiSubscr **subscr, uint64_t *subscrId)
{
dpiSubscr *tempSubscr;
dpiError error;
Expand All @@ -1406,7 +1406,6 @@ int dpiConn_newSubscription(dpiConn *conn, dpiSubscrCreateParams *params,
return DPI_FAILURE;
DPI_CHECK_PTR_NOT_NULL(params)
DPI_CHECK_PTR_NOT_NULL(subscr)
DPI_CHECK_PTR_NOT_NULL(subscrId)
if (dpiGen__allocate(DPI_HTYPE_SUBSCR, conn->env, (void**) &tempSubscr,
&error) < 0)
return DPI_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/dpiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ void dpiRowid__free(dpiRowid *rowid, dpiError *error);
//-----------------------------------------------------------------------------
void dpiSubscr__free(dpiSubscr *subscr, dpiError *error);
int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn,
dpiSubscrCreateParams *params, uint32_t *subscrId, dpiError *error);
dpiSubscrCreateParams *params, uint64_t *subscrId, dpiError *error);


//-----------------------------------------------------------------------------
Expand Down
11 changes: 7 additions & 4 deletions src/dpiSubscr.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void dpiSubscr__callback(dpiSubscr *subscr, void *handle, void *payload,
// is returned.
//-----------------------------------------------------------------------------
int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn,
dpiSubscrCreateParams *params, uint32_t *subscrId, dpiError *error)
dpiSubscrCreateParams *params, uint64_t *subscrId, dpiError *error)
{
uint32_t qosFlags;
int rowids;
Expand Down Expand Up @@ -166,10 +166,13 @@ int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn,
if (dpiOci__subscriptionRegister(conn, &subscr->handle, error) < 0)
return DPI_FAILURE;

// get the registration id
return dpiOci__attrGet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
// get the registration id, if applicable
if (subscrId && dpiOci__attrGet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
subscrId, NULL, DPI_OCI_ATTR_SUBSCR_CQ_REGID,
"get reigstration id", error);
"get registration id", error) < 0)
return DPI_FAILURE;

return DPI_SUCCESS;
}


Expand Down
3 changes: 1 addition & 2 deletions test/TestConn.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ int dpiTest__callFunctionsWithError(dpiTestCase *testCase,
dpiEncodingInfo info;
dpiMsgProps *props;
dpiSubscr *subscr;
uint32_t subscrId;
int commitNeeded;
dpiData *data;
dpiStmt *stmt;
Expand Down Expand Up @@ -122,7 +121,7 @@ int dpiTest__callFunctionsWithError(dpiTestCase *testCase,
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;

dpiConn_newSubscription(conn, &subscrParams, &subscr, &subscrId);
dpiConn_newSubscription(conn, &subscrParams, &subscr, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;

Expand Down
3 changes: 1 addition & 2 deletions test/TestSubscriptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ int dpiTest_2200_verifyNewSubscriptionWithCallBkNULL(dpiTestCase *testCase,
dpiSubscrCreateParams subParams;
dpiContext *context;
dpiSubscr *subscr;
uint32_t subscrId;
dpiConn *conn;

dpiTestSuite_getContext(&context);
Expand All @@ -46,7 +45,7 @@ int dpiTest_2200_verifyNewSubscriptionWithCallBkNULL(dpiTestCase *testCase,
return dpiTestCase_setFailedFromError(testCase);
subParams.callback = NULL;
subParams.protocol = DPI_SUBSCR_PROTO_CALLBACK;
dpiConn_newSubscription(conn, &subParams, &subscr, &subscrId);
dpiConn_newSubscription(conn, &subParams, &subscr, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiConn_release(conn);
Expand Down

0 comments on commit d03de1d

Please sign in to comment.