MB-6082: Handle python script on windows

Need to install python scripts to bin directory on windows platform,
which is different from that on linux.

Change-Id: Id6c259b82897cd5cdb4c4c819e7fe8fb94926d63
Reviewed-on: http://review.couchbase.org/19160
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
New API: couchstore_walk_{id/seq}_tree()

Lets caller examine tree nodes and reduce values. Used by dbdump.c
if the '--tree' flag is given. Probably not useful to many clients.

Change-Id: I72888e612a28e626c6121a239718ab809b84c7ac
Reviewed-on: http://review.couchbase.org/18696
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Jens Alfke <jens@couchbase.com>
MB-6091 Add cookie value to file_ops structure

This helps to enable external users to wrap the default file ops to do
things like collect timings for these operations.

Change-Id: Ide5e4a87e4a5ac6794686f1c02822101c76233c3
Reviewed-on: http://review.couchbase.org/19188
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-100 Fix build under -Wpedantic -Werror

Change-Id: I7f79fc86a3e54a84d38ce5537302491361a91b45
Reviewed-on: http://review.couchbase.org/19221
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Fix integer truncation warnings from Clang

ssize_t assignment to couchstore_error_t requires explicit cast
since it's throwing away the upper half of a 64-bit value.

Change-Id: If4456dcb1a8fd34234bde433d30d2441c6dcb90d
Reviewed-on: http://review.couchbase.org/19179
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
MB-100 Fix dbdump reading deleted docs

The corrupt node check was checking only the bp field of DocInfos in, as
a zeroed out docinfo is used to indicate b-tree corruption. However, it
is possible for a bp to be 0 in normal cases, being deleted docs.

Also changed the wording of errors reading the doc body, to make the
deleted doc without a body case less scary sounding, as it's not
necessarily an error if we do not expect a body. It is possible for a
deleted doc to have a body, so we do still check for one.

Change-Id: I5e44484eb1cea65496e2ad342157b42ded4ec89d
Reviewed-on: http://review.couchbase.org/19634
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-100 Remove reference to libei in README

Change-Id: I139a7cac313aa232350af2e644839bdd9459b3c2
Reviewed-on: http://review.couchbase.org/19684
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
Include b-tree size in space_used

Change-Id: Ic8bee4ea51817f9b065546f1c0bb3374aebe3a51
Reviewed-on: http://review.couchbase.org/19730
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-6358 Add missing files to the dist-file

Change-Id: Ib530da7579446c34842fa8b079a2486f8c485ab1
Reviewed-on: http://review.couchbase.org/19966
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-6199 ability to get OS error information

Change-Id: I697f1bf520880fc73ed746300a3cdccde60812fd
Reviewed-on: http://review.couchbase.org/20374
Tested-by: Jin Lim <jin@couchbase.com>
Reviewed-by: Jens Alfke <jens@couchbase.com>
Reviewed-by: Jin Lim <jin@couchbase.com>
MB-100 Fix compile warnings

Change-Id: I07cd4b433e724ca5e359d5eec0532d53bb64bf7a
Reviewed-on: http://review.couchbase.org/20549
Reviewed-by: Jens Alfke <jens@couchbase.com>
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
Reviewed-by: Farshid Ghods <farshid@couchbase.com>
Tested-by: Farshid Ghods <farshid@couchbase.com>
MB-6580 Fix large file regression

Change-Id: Ic0e3288c136ec98642bf27dc0ab2b1c41ad03fe1
Reviewed-on: http://review.couchbase.org/20679
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100 Tests should not assume deleted keys take 0 space

space_used represents the amount of data in a file that is not "junk",
or that will be retained after compaction. Because metadata about
deleted items is kept around, a file with all the items that had been
present before will not have a space_used of 0

Change-Id: Ib41f55135ba739a91c08ec6866c84e8b782bf9ef
Reviewed-on: http://review.couchbase.org/20597
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-100 Support compiling against Lua 5.2

Change-Id: If06a09d630d1b13565eeb30624395dcd0e9c4fe1
Reviewed-on: http://review.couchbase.org/20598
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-6199 WINAPI-only I/O layer

Change-Id: I7e12a9d04391165548e7b801b9939fad8fca864b
Reviewed-on: http://review.couchbase.org/20762
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Jin Lim <jin@couchbase.com>
MB-6544 Fix segfault in compaction error cleanup

couchstore_close_db should not segfault when passed NULL, as may happen
in the cleanup and error handling of the compactor when it cannot open
the destination file.

also, avoid deleting files during cleanup that we didn't create.

Change-Id: I39ca3cac19a3eff466e833d9bab6e0ddf0b4fde7
Reviewed-on: http://review.couchbase.org/20596
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-100 Fix incorrect sizeof() use in tests

Change-Id: I2aef80d12ffb043c75959aeaec12fb0b66ac5e31
Reviewed-on: http://review.couchbase.org/20714
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
MB-100 rand() cannot be trusted to be unique

Change-Id: I58e60408e4b102eec25a5b9bc0f38769602bfe22
Reviewed-on: http://review.couchbase.org/20715
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
MB-6921: Return NO_HEADERS when opening a non-existent file READ_ONLY

When doing a get on a file that doesn't have headers and we pass in
the READ_ONLY flag from ep-engine and this will cause us to return
the error CHECKSUM_FAILED which is converted into a TMP_FAIL in
ep-engine. It would be much more clear to return a NO_HEADER
error since ew can infer that the file doesn't have any data yet. Then
from the ep-engine side we can map this error to not found.

Change-Id: I058c49e26a2bc6186bff62959a232ab160d4cde4
Reviewed-on: http://review.couchbase.org/21647
Tested-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Reviewed-by: Jens Alfke <jens@couchbase.com>
MB-6928: import ctypes with fallback

Fallback steps:
1. Try to import ctypes from our library
2. If import fails - remove couchbase library from system path and
try again.
3. Exit if it still fails; otherwise return library to system path
and keep working.

Change-Id: I2b556597bb070b1426ca6824af6e9f58bf363953
Reviewed-on: http://review.couchbase.org/21750
Reviewed-by: Bin Cui <bin.cui@gmail.com>
Tested-by: Pavel Paulau <pavel.paulau@gmail.com>