diff --git a/xapian-core/backends/brass/brass_database.cc b/xapian-core/backends/brass/brass_database.cc
index 2626782..b73dedf 100644
a
|
b
|
BrassWritableDatabase::add_document(const Xapian::Document & document)
|
1106 | 1106 | { |
1107 | 1107 | LOGCALL(DB, Xapian::docid, "BrassWritableDatabase::add_document", document); |
1108 | 1108 | // Make sure the docid counter doesn't overflow. |
1109 | | if (stats.get_last_docid() == Xapian::docid(-1)) |
| 1109 | if (stats.get_last_docid() == 0xffffffff) |
1110 | 1110 | throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents"); |
1111 | 1111 | // Use the next unused document ID. |
1112 | 1112 | RETURN(add_document_(stats.get_next_docid(), document)); |
diff --git a/xapian-core/backends/chert/chert_database.cc b/xapian-core/backends/chert/chert_database.cc
index 0320d1d..83b9597 100644
a
|
b
|
ChertWritableDatabase::add_document(const Xapian::Document & document)
|
1152 | 1152 | { |
1153 | 1153 | LOGCALL(DB, Xapian::docid, "ChertWritableDatabase::add_document", document); |
1154 | 1154 | // Make sure the docid counter doesn't overflow. |
1155 | | if (stats.get_last_docid() == Xapian::docid(-1)) |
| 1155 | if (stats.get_last_docid() == 0xffffffff) |
1156 | 1156 | throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents"); |
1157 | 1157 | // Use the next unused document ID. |
1158 | 1158 | RETURN(add_document_(stats.get_next_docid(), document)); |
diff --git a/xapian-core/backends/flint/flint_database.cc b/xapian-core/backends/flint/flint_database.cc
index e98cee8..f43b5af 100644
a
|
b
|
FlintWritableDatabase::add_document(const Xapian::Document & document)
|
1127 | 1127 | { |
1128 | 1128 | LOGCALL(DB, Xapian::docid, "FlintWritableDatabase::add_document", document); |
1129 | 1129 | // Make sure the docid counter doesn't overflow. |
1130 | | if (lastdocid == Xapian::docid(-1)) |
| 1130 | if (lastdocid == 0xffffffff) |
1131 | 1131 | throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents"); |
1132 | 1132 | // Use the next unused document ID. |
1133 | 1133 | RETURN(add_document_(++lastdocid, document)); |
diff --git a/xapian-core/common/pack.h b/xapian-core/common/pack.h
index 01143eb..d37e104 100644
a
|
b
|
pack_uint_preserving_sort(std::string & s, U value)
|
145 | 145 | { |
146 | 146 | // Check U is an unsigned type. |
147 | 147 | STATIC_ASSERT_UNSIGNED_TYPE(U); |
148 | | STATIC_ASSERT(sizeof(U) <= SORTABLE_UINT_MAX_BYTES); |
| 148 | //STATIC_ASSERT(sizeof(U) <= SORTABLE_UINT_MAX_BYTES); |
149 | 149 | |
150 | 150 | char tmp[sizeof(U) + 1]; |
151 | 151 | char * p = tmp + sizeof(tmp); |
diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
index 30e6160..d11d20b 100644
a
|
b
|
|
21 | 21 | #ifndef XAPIAN_INCLUDED_TYPES_H |
22 | 22 | #define XAPIAN_INCLUDED_TYPES_H |
23 | 23 | |
| 24 | #define USE_64BIT_DOCID 1 |
| 25 | #define USE_64BIT_TERMCOUNT 1 |
| 26 | |
24 | 27 | namespace Xapian { |
25 | 28 | |
26 | 29 | /** A count of documents. |
… |
… |
namespace Xapian {
|
28 | 31 | * This is used to hold values such as the number of documents in a database |
29 | 32 | * and the frequency of a term in the database. |
30 | 33 | */ |
| 34 | #ifdef USE_64BIT_DOCID |
| 35 | typedef unsigned long long doccount; |
| 36 | #else |
31 | 37 | typedef unsigned doccount; |
| 38 | #endif |
32 | 39 | |
33 | 40 | /** A signed difference between two counts of documents. |
34 | 41 | * |
35 | 42 | * This is used by the Xapian classes which are STL containers of documents |
36 | 43 | * for "difference_type". |
37 | 44 | */ |
38 | | typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */ |
| 45 | /* FIXME: can overflow. */ |
| 46 | #ifdef USE_64BIT_DOCID |
| 47 | typedef long long doccount_diff; |
| 48 | #else |
| 49 | typedef int doccount_diff; |
| 50 | #endif |
39 | 51 | |
40 | 52 | /** A unique identifier for a document. |
41 | 53 | * |
42 | 54 | * Docid 0 is invalid, providing an "out of range" value which can be |
43 | 55 | * used to mean "not a valid document". |
44 | 56 | */ |
| 57 | #ifdef USE_64BIT_DOCID |
| 58 | typedef unsigned long long docid; |
| 59 | #else |
45 | 60 | typedef unsigned docid; |
| 61 | #endif |
46 | 62 | |
47 | 63 | /** A normalised document length. |
48 | 64 | * |
… |
… |
typedef int percent;
|
58 | 74 | * |
59 | 75 | * This is used to hold values such as the Within Document Frequency (wdf). |
60 | 76 | */ |
| 77 | #ifdef USE_64BIT_TERMCOUNT |
| 78 | typedef unsigned long long termcount; |
| 79 | #else |
61 | 80 | typedef unsigned termcount; |
| 81 | #endif |
62 | 82 | |
63 | 83 | /** A signed difference between two counts of terms. |
64 | 84 | * |
65 | 85 | * This is used by the Xapian classes which are STL containers of terms |
66 | 86 | * for "difference_type". |
67 | 87 | */ |
68 | | typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */ |
| 88 | /* FIXME: can overflow. */ |
| 89 | #ifdef USE_64BIT_DOCID |
| 90 | typedef long long termcount_diff; |
| 91 | #else |
| 92 | typedef int termcount_diff; |
| 93 | #endif |
69 | 94 | |
70 | 95 | /** A term position within a document or query. |
71 | 96 | */ |
diff --git a/xapian-core/net/remoteconnection.cc b/xapian-core/net/remoteconnection.cc
index c7515bb..a8de28c 100644
a
|
b
|
RemoteConnection::get_message(string &result, double end_time)
|
489 | 489 | unsigned char ch; |
490 | 490 | int shift = 0; |
491 | 491 | do { |
492 | | if (i == buffer.end() || shift > 28) { |
| 492 | if (i == buffer.end() || shift > 63) { |
493 | 493 | // Something is very wrong... |
494 | 494 | throw Xapian::NetworkError("Insane message length specified!"); |
495 | 495 | } |
diff --git a/xapian-core/net/serialise.cc b/xapian-core/net/serialise.cc
index af035b9..ef5b26d 100644
a
|
b
|
decode_length(const char ** p, const char *end, bool check_remaining)
|
51 | 51 | unsigned char ch; |
52 | 52 | int shift = 0; |
53 | 53 | do { |
54 | | if (*p == end || shift > 28) |
| 54 | if (*p == end || shift > 63) |
55 | 55 | throw Xapian::NetworkError("Bad encoded length: insufficient data"); |
56 | 56 | ch = *(*p)++; |
57 | 57 | len |= size_t(ch & 0x7f) << shift; |
diff --git a/xapian-core/tests/api_wrdb.cc b/xapian-core/tests/api_wrdb.cc
index 4f98d55..e602e7b 100644
a
|
b
|
DEFINE_TESTCASE(nomoredocids1, writable) {
|
1592 | 1592 | doc.set_data("prose"); |
1593 | 1593 | doc.add_term("word"); |
1594 | 1594 | |
1595 | | db.replace_document(Xapian::docid(-1), doc); |
| 1595 | db.replace_document(0xffffffff, doc); |
1596 | 1596 | |
1597 | 1597 | TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc)); |
1598 | 1598 | |
diff --git a/xapian-core/tests/harness/testutils.cc b/xapian-core/tests/harness/testutils.cc
index d2bcf21..e56d0d4 100644
a
|
b
|
|
30 | 30 | |
31 | 31 | using namespace std; |
32 | 32 | |
33 | | ostream & |
34 | | operator<<(ostream &os, const vector<unsigned int> &ints) |
| 33 | template<class T> ostream & |
| 34 | operator<<(ostream &os, const vector<T> &ints) |
35 | 35 | { |
36 | 36 | copy(ints.begin(), ints.end(), |
37 | | ostream_iterator<unsigned int>(os, ", ")); |
| 37 | ostream_iterator<T>(os, ", ")); |
38 | 38 | return os; |
39 | 39 | } |
40 | 40 | |
diff --git a/xapian-core/tests/harness/testutils.h b/xapian-core/tests/harness/testutils.h
index b0d4cd4..357a287 100644
a
|
b
|
|
28 | 28 | // ###################################################################### |
29 | 29 | // Useful display operators |
30 | 30 | |
| 31 | template<class T> |
31 | 32 | std::ostream &operator<<(std::ostream &os, |
32 | | const std::vector<unsigned int> &ints); |
| 33 | const std::vector<T> &ints); |
33 | 34 | |
34 | 35 | // ###################################################################### |
35 | 36 | // Useful comparison operators |