SQLite

Check-in [a721a73818]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix harmless compiler warnings in changebatch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | changebatch
Files: files | file ages | folders
SHA1: a721a738184d914fcde3f5684099984a9373dff3
User & Date: drh 2016-08-23 18:09:37.916
Context
2016-08-23
19:02
Add further tests for changebatch. And a fix to prevent a changeset from conflicting with itself. (check-in: 506d6ff4b6 user: dan tags: changebatch)
18:09
Fix harmless compiler warnings in changebatch. (check-in: a721a73818 user: drh tags: changebatch)
17:02
Add a new method to sessions - sqlite3sessions_fullchangeset() - to return a changeset that always contains values for all old.* fields. Update changebatch to use these values to more reliably detect multi-column UNIQUE constraint violations. (check-in: efa761b2f5 user: dan tags: changebatch)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/session/sqlite3changebatch.c.
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
** Return the hash bucket that pEntry belongs in.
*/
static int cbHash(sqlite3_changebatch *p, BatchIndexEntry *pEntry){
  unsigned int iHash = (unsigned int)pEntry->iIdxId;
  unsigned char *pEnd = (unsigned char*)&pEntry->aRecord[pEntry->szRecord];
  unsigned char *pIter;

  for(pIter=pEntry->aRecord; pIter<pEnd; pIter++){
    iHash += (iHash << 7) + *pIter;
  }

  return (int)(iHash % p->nHash);
}

/*







|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
** Return the hash bucket that pEntry belongs in.
*/
static int cbHash(sqlite3_changebatch *p, BatchIndexEntry *pEntry){
  unsigned int iHash = (unsigned int)pEntry->iIdxId;
  unsigned char *pEnd = (unsigned char*)&pEntry->aRecord[pEntry->szRecord];
  unsigned char *pIter;

  for(pIter=(unsigned char*)pEntry->aRecord; pIter<pEnd; pIter++){
    iHash += (iHash << 7) + *pIter;
  }

  return (int)(iHash % p->nHash);
}

/*
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

  apNew = cbMalloc(&rc, sizeof(BatchIndexEntry*) * nNew);
  if( rc==SQLITE_OK ){
    int nHash = p->nHash;
    p->nHash = nNew;
    for(i=0; i<nHash; i++){
      BatchIndexEntry *pEntry;
      while( pEntry=p->apHash[i] ){
        int iHash = cbHash(p, pEntry);
        p->apHash[i] = pEntry->pNext;
        pEntry->pNext = apNew[iHash];
        apNew[iHash] = pEntry;
      }
    }








|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

  apNew = cbMalloc(&rc, sizeof(BatchIndexEntry*) * nNew);
  if( rc==SQLITE_OK ){
    int nHash = p->nHash;
    p->nHash = nNew;
    for(i=0; i<nHash; i++){
      BatchIndexEntry *pEntry;
      while( (pEntry=p->apHash[i])!=0 ){
        int iHash = cbHash(p, pEntry);
        p->apHash[i] = pEntry->pNext;
        pEntry->pNext = apNew[iHash];
        apNew[iHash] = pEntry;
      }
    }