Overview
Artifact ID: | a4e8662c091d4f8c1e03192c03f7cf3158aa7a0ed20072584bd36899fd6c127d |
---|---|
Ticket: | 8897054d959750c9cb3c9a1d4da762cb2a956f7c
lsm1 does not overwrite values for duplicate keys |
User & Date: | anonymous 2017-08-14 14:02:50 |
Changes
- foundin changed to: "3.20.0"
- icomment:
In the lsm1 extension, lsm_insert(): insert a new key/value pair into the database, overwriting any existing entry with the same key (https://sqlite.org/src4/doc/trunk/www/lsmusr.wiki#writing_to_a_database), When I tried to test this case (insert existing entry with the same key) the database size increasing without overwriting any existing entry with the same key. The below test c code illustrate the case: void test(void) { lsm_db *db; int rc = lsm_new(0, &db); if( rc != LSM_OK ) return; rc = lsm_open(db, "test.lsmdb"); if( rc != LSM_OK ) return; DWORD Key = 0x12345678; char Val_1[] = "12345678"; char Val_2[] = "ABCDEFGH"; lsm_begin(db, 1); lsm_insert(db, (void *)&Key, sizeof(Key), Val_1, strlen(Val_1)+1); // below insert should update the same key with a new value lsm_insert(db, (void *)&Key, sizeof(Key), Val_2, strlen(Val_2)+1); lsm_commit(db, 0); lsm_cursor *csr; if( lsm_csr_open(db, &csr) != LSM_OK ) return; int seekrc = lsm_csr_seek(csr, &Key, sizeof(Key), LSM_SEEK_EQ); int validrc = lsm_csr_valid(csr); if( seekrc == LSM_OK && validrc ) { char *pKeyPtr, *pValPtr; int nKey, nVal; lsm_csr_key(csr, (const void **)&pKeyPtr, &nKey); lsm_csr_value(csr, (const void **)&pValPtr, &nVal); // the below printf will display the old value rather than new updated value printf("key = %08X, val = %s\n", pKeyPtr, pValPtr); } lsm_csr_close(csr); lsm_close(db); }
- login: "anonymous"
- mimetype: "text/plain"
- private_contact changed to: "ccff8adb4b80590cdec7e0c8c2b35729c408fb35"
- severity changed to: "Severe"
- status changed to: "Open"
- title changed to: "lsm1 does not overwrite values for duplicate keys"
- type changed to: "Code_Defect"