indexer: Allocate new db handle for every index scan

ForestDB db handle is not thread-safe and hence it cannot be shared
among db scan threads. ForestDB iterator alloc helper function
is refactored to create new db handle during iterator creation.

Change-Id: I8fcbde660eae064e81bcd984211e3ea677522c73
Reviewed-on: http://review.couchbase.org/43910
Reviewed-by: Deepkaran Salooja <deepkaran.couchbase@gmail.com>
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Tested-by: Sarath Lakshman <sarath@couchbase.com>
querycmd: Fix index create command with -primary flag

Change-Id: I2dc9015d381840b40a81dc2b5d036ee8364f1931
Reviewed-on: http://review.couchbase.org/44013
Reviewed-by: Pratap Chakravarthy <prataprc@couchbase.com>
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Tested-by: Sarath Lakshman <sarath@couchbase.com>
N1QL: Implement Indexer{} interface.

- Index{} interface is refactored between Indexer{} and Index{}
- Export Refresh() API that shall be defined in Indexer{}.
- uses RWMutex
  - Write-lock is acquired by
    CreatePrimaryIndex(), CreateIndex(), Refresh() and Drop() APIs,
    after necessary network operation is performed.
  - Read-lock is acquired by all APIs that need to access the local-cache.

Change-Id: I1148400aeadbe87a23f7d0bf9d0135c8d409ae78
Reviewed-on: http://review.couchbase.org/44024
Reviewed-by: Sriram Melkote <siri@couchbase.com>
Tested-by: Sriram Melkote <siri@couchbase.com>
Fix Multiple Bucket Recovery

If there are multiple buckets in catchup stream, the merge will happen
one by one. Once all merges are done, catchup stream is dropped.

Change-Id: I8b8b4f8d1caea1ee44a1e957c5e3bf843a7ecb66
Reviewed-on: http://review.couchbase.org/44023
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Reviewed-by: Sriram Melkote <siri@couchbase.com>
Tested-by: Sriram Melkote <siri@couchbase.com>
N1QL: API signature change.

- Rename Span.Equal to Span.Seek
- Index.EqualKey() to Index.SeekKey

2i still retains the local nomenclature, so the rest of the components remains
unaffected.

Change-Id: I75fdb14cb01c0c4315a2bf2018cb1d25740f1906
Reviewed-on: http://review.couchbase.org/44101
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Reviewed-by: Pratap Chakravarthy <prataprc@couchbase.com>
Tested-by: Pratap Chakravarthy <prataprc@couchbase.com>
Merge branch 'unstable'

Deliver N1QL changes

Change-Id: I24f8a8a8aa55c10c594ea01191cdc082f33cccd1