mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Fix time collation.
This commit is contained in:
Binary file not shown.
@@ -4,15 +4,18 @@
|
||||
|
||||
static int time_collation(void *pArg, int nKey1, const void *pKey1, int nKey2,
|
||||
const void *pKey2) {
|
||||
// If keys are of different length, and both terminated by a Z,
|
||||
// ignore the Z for collation purposes.
|
||||
if (nKey1 && nKey2 && nKey1 != nKey2) {
|
||||
const char *pK1 = (const char *)pKey1;
|
||||
const char *pK2 = (const char *)pKey2;
|
||||
if (pK1[nKey1 - 1] == 'Z' && pK2[nKey2 - 1] == 'Z') {
|
||||
nKey1--;
|
||||
nKey2--;
|
||||
}
|
||||
// Remove a Z suffix if one key is no longer than the other.
|
||||
// A Z suffix collates before any character but after the empty string.
|
||||
// This avoids making different keys equal.
|
||||
const int nK1 = nKey1;
|
||||
const int nK2 = nKey2;
|
||||
const char *pK1 = (const char *)pKey1;
|
||||
const char *pK2 = (const char *)pKey2;
|
||||
if (nK1 && nK1 <= nK2 && pK1[nK1 - 1] == 'Z') {
|
||||
nKey1--;
|
||||
}
|
||||
if (nK2 && nK2 <= nK1 && pK2[nK2 - 1] == 'Z') {
|
||||
nKey2--;
|
||||
}
|
||||
|
||||
int n = nKey1 < nKey2 ? nKey1 : nKey2;
|
||||
|
||||
Reference in New Issue
Block a user