diff --git a/xapian-core/common/pack.h b/xapian-core/common/pack.h
index 0f2887a..6794da9 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, | 
          
            | 149 |  |                   "Template type U too wide for database format"); | 
          
            |  | 148 | //static_assert(sizeof(U) <= SORTABLE_UINT_MAX_BYTES, | 
          
            |  | 149 | //"Template type U too wide for database format"); | 
        
        
          
            | 150 | 150 |  | 
          
            | 151 | 151 | char tmp[sizeof(U) + 1]; | 
          
            | 152 | 152 | char * p = tmp + sizeof(tmp); | 
        
      
    
    
      
      diff --git a/xapian-core/configure.ac b/xapian-core/configure.ac
index 7ff5288..bd99733 100644
      
        
          
        
        
          
            | a | b | if test x$USE_MAINTAINER_MODE = xyes; then | 
        
        
          
            | 456 | 456 | test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode]) | 
          
            | 457 | 457 | fi | 
          
            | 458 | 458 |  | 
        
        
          
            |  | 459 |  | 
          
            |  | 460 | AC_ARG_ENABLE([64bit_docid], | 
          
            |  | 461 | [AS_HELP_STRING([--enable-64bit-docid], [enable 64bit docids[default=no]])], | 
          
            |  | 462 | [case ${enableval} in | 
          
            |  | 463 | yes|no) ;; | 
          
            |  | 464 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-docid]) ;; | 
          
            |  | 465 | esac], | 
          
            |  | 466 | [enable_64bit_docid=no]) | 
          
            |  | 467 |  | 
          
            |  | 468 | AC_ARG_ENABLE([64bit_termcount], | 
          
            |  | 469 | [AS_HELP_STRING([--enable-64bit-termcount], [enable 64bit termcounts[default=no]])], | 
          
            |  | 470 | [case ${enableval} in | 
          
            |  | 471 | yes|no) ;; | 
          
            |  | 472 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termcount]) ;; | 
          
            |  | 473 | esac], | 
          
            |  | 474 | [enable_64bit_termcount=no]) | 
          
            |  | 475 |  | 
        
        
          
            | 459 | 476 | AC_ARG_ENABLE([documentation], | 
          
            | 460 | 477 | [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])], | 
          
            | 461 | 478 | [case ${enableval} in | 
        
        
          
            | … | … | for backend in CHERT GLASS INMEMORY REMOTE ; do | 
        
        
          
            | 1258 | 1275 | cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_${backend}_BACKEND" | 
          
            | 1259 | 1276 | fi | 
          
            | 1260 | 1277 | done | 
        
        
          
            |  | 1278 |  | 
          
            |  | 1279 | if test yes = "$enable_64bit_docid" ; then | 
          
            |  | 1280 | cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_64BIT_DOCID" | 
          
            |  | 1281 | fi | 
          
            |  | 1282 |  | 
          
            |  | 1283 | if test yes = "$enable_64bit_termcount" ; then | 
          
            |  | 1284 | cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_64BIT_TERMCOUNT" | 
          
            |  | 1285 | fi | 
          
            |  | 1286 |  | 
        
        
          
            | 1261 | 1287 | dnl For GCC (and compilers which pretend to be GCC) and MSVC, we create some | 
          
            | 1262 | 1288 | dnl ABI checks in the generated version.h, and $CXXFLAGS may contain options | 
          
            | 1263 | 1289 | dnl which affect the ABI (e.g. -fabi-version for GCC) so we want to use these | 
        
      
    
    
      
      diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
index 130411c..b47e2be 100644
      
        
          
        
        
          
            | a | b |  | 
        
        
          
            | 25 | 25 | # error "Never use <xapian/types.h> directly; include <xapian.h> instead." | 
          
            | 26 | 26 | #endif | 
          
            | 27 | 27 |  | 
        
        
          
            |  | 28 | #include <xapian/version.h> | 
        
        
          
            | 28 | 29 | #include <xapian/deprecated.h> | 
          
            | 29 | 30 |  | 
          
            | 30 | 31 | namespace Xapian { | 
        
        
          
            | … | … | namespace Xapian { | 
        
        
          
            | 34 | 35 | *  This is used to hold values such as the number of documents in a database | 
          
            | 35 | 36 | *  and the frequency of a term in the database. | 
          
            | 36 | 37 | */ | 
        
        
          
            |  | 38 | #ifdef XAPIAN_HAS_64BIT_DOCID | 
          
            |  | 39 | typedef unsigned long long doccount; | 
          
            |  | 40 | #else | 
        
        
          
            | 37 | 41 | typedef unsigned doccount; | 
        
        
          
            |  | 42 | #endif | 
        
        
          
            | 38 | 43 |  | 
          
            | 39 | 44 | /** A signed difference between two counts of documents. | 
          
            | 40 | 45 | * | 
          
            | 41 | 46 | *  This is used by the Xapian classes which are STL containers of documents | 
          
            | 42 | 47 | *  for "difference_type". | 
          
            | 43 | 48 | */ | 
        
        
          
            | 44 |  | typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */ | 
          
            |  | 49 | #ifdef XAPIAN_HAS_64BIT_DOCID | 
          
            |  | 50 | typedef long long doccount_diff; | 
          
            |  | 51 | #else | 
          
            |  | 52 | typedef int doccount_diff; | 
          
            |  | 53 | #endif | 
        
        
          
            | 45 | 54 |  | 
          
            | 46 | 55 | /** A unique identifier for a document. | 
          
            | 47 | 56 | * | 
          
            | 48 | 57 | *  Docid 0 is invalid, providing an "out of range" value which can be | 
          
            | 49 | 58 | *  used to mean "not a valid document". | 
          
            | 50 | 59 | */ | 
        
        
          
            |  | 60 | #ifdef XAPIAN_HAS_64BIT_DOCID | 
          
            |  | 61 | typedef unsigned long long docid; | 
          
            |  | 62 | #else | 
        
        
          
            | 51 | 63 | typedef unsigned docid; | 
        
        
          
            |  | 64 | #endif | 
        
        
          
            | 52 | 65 |  | 
          
            | 53 | 66 | /** A normalised document length. | 
          
            | 54 | 67 | * | 
        
        
          
            | … | … | XAPIAN_DEPRECATED(typedef int percent); | 
        
        
          
            | 68 | 81 | * | 
          
            | 69 | 82 | *  This is used to hold values such as the Within Document Frequency (wdf). | 
          
            | 70 | 83 | */ | 
        
        
          
            |  | 84 | #ifdef XAPIAN_HAS_64BIT_TERMCOUNT | 
          
            |  | 85 | typedef unsigned long long termcount; | 
          
            |  | 86 | #else | 
        
        
          
            | 71 | 87 | typedef unsigned termcount; | 
        
        
          
            |  | 88 | #endif | 
        
        
          
            | 72 | 89 |  | 
          
            | 73 | 90 | /** A signed difference between two counts of terms. | 
          
            | 74 | 91 | * | 
          
            | 75 | 92 | *  This is used by the Xapian classes which are STL containers of terms | 
          
            | 76 | 93 | *  for "difference_type". | 
          
            | 77 | 94 | */ | 
        
        
          
            | 78 |  | typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */ | 
          
            |  | 95 | #ifdef XAPIAN_HAS_64BIT_TERMCOUNT | 
          
            |  | 96 | typedef long long termcount_diff; | 
          
            |  | 97 | #else | 
          
            |  | 98 | typedef int termcount_diff; | 
          
            |  | 99 | #endif | 
        
        
          
            | 79 | 100 |  | 
          
            | 80 | 101 | /** A term position within a document or query. | 
          
            | 81 | 102 | */ | 
        
      
    
    
      
      diff --git a/xapian-core/include/xapian/version_h.cc b/xapian-core/include/xapian/version_h.cc
index 064761d..0a8c9c6 100644
      
        
          
        
        
          
            | a | b | const char * dummy[] = { | 
        
        
          
            | 157 | 157 | " */", | 
          
            | 158 | 158 | "#define XAPIAN_REVISION ",REVISION, | 
          
            | 159 | 159 | "", | 
        
        
          
            |  | 160 | "/// XAPIAN_HAS_64BIT_DOCID Defined if the 64bit docid is enabled.", | 
          
            |  | 161 | #ifdef XAPIAN_HAS_64BIT_DOCID | 
          
            |  | 162 | "#define XAPIAN_HAS_64BIT_DOCID 1", | 
          
            |  | 163 | #else | 
          
            |  | 164 | "/* #undef XAPIAN_HAS_64BIT_DOCID */", | 
          
            |  | 165 | #endif | 
          
            |  | 166 | "", | 
          
            |  | 167 | "/// XAPIAN_HAS_64BIT_TERMCOUNT Defined if the 64bit termcount is enabled.", | 
          
            |  | 168 | #ifdef XAPIAN_HAS_64BIT_TERMCOUNT | 
          
            |  | 169 | "#define XAPIAN_HAS_64BIT_TERMCOUNT 1", | 
          
            |  | 170 | #else | 
          
            |  | 171 | "/* #undef XAPIAN_HAS_64BIT_TERMCOUNT */", | 
          
            |  | 172 | #endif | 
          
            |  | 173 | "", | 
        
        
          
            | 160 | 174 | "/// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled.", | 
          
            | 161 | 175 | #ifdef XAPIAN_HAS_CHERT_BACKEND | 
          
            | 162 | 176 | "#define XAPIAN_HAS_CHERT_BACKEND 1", | 
        
      
    
    
      
      diff --git a/xapian-core/net/length.cc b/xapian-core/net/length.cc
index 6f4ec33..a4a59a8 100644
      
        
          
        
        
          
            | a | b | decode_length(const char ** p, const char *end, uint64_t & out) | 
        
        
          
            | 103 | 103 | } | 
          
            | 104 | 104 |  | 
          
            | 105 | 105 | void | 
        
        
          
            |  | 106 | decode_length(const char ** p, const char *end, unsigned long long & out) | 
          
            |  | 107 | { | 
          
            |  | 108 | decode_length_(p, end, out); | 
          
            |  | 109 | } | 
          
            |  | 110 |  | 
          
            |  | 111 | void | 
        
        
          
            | 106 | 112 | decode_length_and_check(const char ** p, const char *end, uint32_t & out) | 
          
            | 107 | 113 | { | 
          
            | 108 | 114 | decode_length_and_check_(p, end, out); | 
        
        
          
            | … | … | decode_length_and_check(const char ** p, const char *end, uint64_t & out) | 
        
        
          
            | 113 | 119 | { | 
          
            | 114 | 120 | decode_length_and_check_(p, end, out); | 
          
            | 115 | 121 | } | 
        
        
          
            |  | 122 |  | 
          
            |  | 123 | void | 
          
            |  | 124 | decode_length_and_check(const char ** p, const char *end, unsigned long long & out) | 
          
            |  | 125 | { | 
          
            |  | 126 | decode_length_and_check_(p, end, out); | 
          
            |  | 127 | } | 
        
      
    
    
      
      diff --git a/xapian-core/net/length.h b/xapian-core/net/length.h
index b286177..5461cd4 100644
      
        
          
        
        
          
            | a | b | void decode_length(const char ** p, const char *end, uint32_t & out); | 
        
        
          
            | 66 | 66 |  | 
          
            | 67 | 67 | void decode_length(const char ** p, const char *end, uint64_t & out); | 
          
            | 68 | 68 |  | 
        
        
          
            |  | 69 | void decode_length(const char ** p, const char *end, unsigned long long & out); | 
          
            |  | 70 |  | 
        
        
          
            | 69 | 71 | /** Decode a length encoded by encode_length. | 
          
            | 70 | 72 | * | 
          
            | 71 | 73 | *  Also checks the result against the amount of data remaining after the | 
        
        
          
            | … | … | void decode_length_and_check(const char ** p, const char *end, uint32_t & out); | 
        
        
          
            | 80 | 82 |  | 
          
            | 81 | 83 | void decode_length_and_check(const char ** p, const char *end, uint64_t & out); | 
          
            | 82 | 84 |  | 
        
        
          
            |  | 85 | void decode_length_and_check(const char ** p, const char *end, unsigned long long & out); | 
          
            |  | 86 |  | 
        
        
          
            | 83 | 87 | #endif //XAPIAN_INCLUDED_LENGTH_H | 
        
      
    
    
      
      diff --git a/xapian-core/tests/api_wrdb.cc b/xapian-core/tests/api_wrdb.cc
index 5bb8072..833bbef 100644
      
        
          
        
        
          
            | a | b | DEFINE_TESTCASE(nomoredocids1, writable) { | 
        
        
          
            | 1614 | 1614 | doc.set_data("prose"); | 
          
            | 1615 | 1615 | doc.add_term("word"); | 
          
            | 1616 | 1616 |  | 
        
        
          
            | 1617 |  | db.replace_document(Xapian::docid(-1), doc); | 
          
            |  | 1617 | // FIXME: This probably should use the _MAX_DOCID values | 
          
            |  | 1618 | Xapian::docid max_id = 0xffffffff; | 
          
            |  | 1619 |  | 
          
            |  | 1620 | db.replace_document(max_id, doc); | 
        
        
          
            | 1618 | 1621 |  | 
          
            | 1619 | 1622 | TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc)); | 
          
            | 1620 | 1623 |  |