di is not a mandatory DELETE query parameter. 79/22279/2
authorTodd Malsbary <todd.malsbary@intel.com>
Wed, 30 Aug 2017 21:03:42 +0000 (14:03 -0700)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 14 Sep 2017 06:15:20 +0000 (06:15 +0000)
Bug: https://jira.iotivity.org/browse/IOT-2659
Change-Id: If9e6c94f0e5896ef6ae129775166078da402d9b5
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
resource/csdk/resource-directory/src/internal/rd_database.c
resource/csdk/resource-directory/src/rd_server.c

index 562681d..e899b89 100644 (file)
@@ -598,7 +598,7 @@ static int deleteResources(const char *deviceId, const int64_t *instanceIds, uin
             "WHERE ins IN ("
             "SELECT RD_DEVICE_LINK_LIST.ins FROM RD_DEVICE_LINK_LIST "
             "INNER JOIN RD_DEVICE_LIST ON RD_DEVICE_LINK_LIST.DEVICE_ID=RD_DEVICE_LIST.ID "
-            "WHERE RD_DEVICE_LIST.di=@deviceId AND RD_DEVICE_LINK_LIST.ins IN (";
+            "WHERE RD_DEVICE_LINK_LIST.ins IN (";
         size_t inLen = nInstanceIds + (nInstanceIds - 1);
         static const char post[] = "))";
         size_t delResourceSize = sizeof(pre) + inLen + (sizeof(post) - 1);
@@ -617,12 +617,9 @@ static int deleteResources(const char *deviceId, const int64_t *instanceIds, uin
         OICStrcat(delResource, delResourceSize, post);
         VERIFY_SQLITE(sqlite3_prepare_v2(gRDDB, delResource, (int)delResourceSize,
                         &stmt, NULL));
-        VERIFY_SQLITE(sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(stmt, "@deviceId"),
-                        deviceId, (int)strlen(deviceId), SQLITE_STATIC));
-        assert(sqlite3_bind_parameter_index(stmt, "@deviceId") == 1);
         for (uint16_t i = 0; i < nInstanceIds; ++i)
         {
-            VERIFY_SQLITE(sqlite3_bind_int64(stmt, 2 + i, instanceIds[i]));
+            VERIFY_SQLITE(sqlite3_bind_int64(stmt, 1 + i, instanceIds[i]));
         }
     }
 
index c8ecf29..4aafa41 100644 (file)
@@ -287,9 +287,9 @@ static OCEntityHandlerResult handleDeleteRequest(const OCEntityHandlerRequest *e
 
         keyValuePair = strtok_r(NULL, OC_QUERY_SEPARATOR, &restOfQuery);
     }
-    if (!di)
+    if (!di && !nIns)
     {
-        OIC_LOG_V(ERROR, TAG, "Missing required di query parameter!");
+        OIC_LOG_V(ERROR, TAG, "Missing required query parameters!");
         goto exit;
     }