From 936bd29f43e7a5e82bebb382b338e685b6b7680b Mon Sep 17 00:00:00 2001 From: Randeep Singh Date: Thu, 1 Oct 2015 18:59:57 +0900 Subject: [PATCH] Corrected DB query of PDM MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To check the existence of link between two devices, We should use query with ‘and’ not ‘or’. Previously link was checked with ‘or’ thats why if we try to create multiple links involving one same device and other different devices then it was showing link already exists. for example if we create link between A-B then if we try to create link between A-C then we are getting error that link already exists. Change-Id: I408658af4f423a641bab077439435711ecac876e Signed-off-by: Randeep Singh Reviewed-on: https://gerrit.iotivity.org/gerrit/3361 Reviewed-by: Woochul Shim Tested-by: jenkins-iotivity Reviewed-by: Sachin Agrawal (cherry picked from commit 370c560720ef374672d6a91d57cb7c72311c2182) Reviewed-on: https://gerrit.iotivity.org/gerrit/3425 --- .../csdk/security/provisioning/src/provisioningdatabasemanager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100755 => 100644 resource/csdk/security/provisioning/src/provisioningdatabasemanager.c diff --git a/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c b/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c old mode 100755 new mode 100644 index 0d3182e..e50b5f8 --- a/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c +++ b/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c @@ -73,6 +73,7 @@ #define PDM_SQLITE_LIST_ALL_UUID "SELECT UUID FROM T_DEVICE_LIST" #define PDM_SQLITE_GET_UUID "SELECT UUID FROM T_DEVICE_LIST WHERE ID = ?" #define PDM_SQLITE_GET_LINKED_DEVICES "SELECT ID,ID2 FROM T_DEVICE_LINK_STATE WHERE ID = ? or ID2 = ?" +#define PDM_SQLITE_GET_DEVICE_LINKS "SELECT ID,ID2 FROM T_DEVICE_LINK_STATE WHERE ID = ? and ID2 = ?" #define ASCENDING_ORDER(id1, id2) do{if( (id1) > (id2) )\ { int temp; temp = id1; id1 = id2; id2 = temp; }}while(0) @@ -704,8 +705,8 @@ OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* u sqlite3_stmt *stmt = 0; int res = 0; - res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_LINKED_DEVICES, - strlen(PDM_SQLITE_GET_LINKED_DEVICES) + 1, &stmt, NULL); + res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_DEVICE_LINKS, + strlen(PDM_SQLITE_GET_DEVICE_LINKS) + 1, &stmt, NULL); PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR); res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_FIRST, id1); -- 2.7.4