Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1054

Support negative cursor limit for single-batch OP_QUERY and find command results

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.2
    • Affects Version/s: 1.3.0
    • Component/s: libmongoc
    • Labels:
      None

      Currently, there is no way for an extending driver to request single-batch result sets in a universal manner suitable for OP_QUERY and the find command. In the case of OP_QUERY, _mongoc_n_return() has an assertion as of 1.3.0 that fails for negative limits. For the find command, there is no way to express singleBatch without using a 3.2+ find command document (I may be overlooking some hacky solution to abuse how query modifiers are merged into the command document).

      Changing the private cursor struct to have a signed limit would allow drivers extending libmongoc to pass a negative limit and request that the query return a single batch of results and leave no cursor open on the server. For legacy OP_QUERY operations, this negative limit would be passed as-is (the wire protocol already specifies a signed 32-bit integer for limit). For the find command, a negative limit would be made positive and the singleBatch command option set to true.

      Changes would entail revising the assertion in _mongoc_n_return() to operate on the absolute value of the limit, as well as changing the internal struct's field to a signed integer.

      Note: the related issue, CDRIVER-1053, refers to changing the public API of mongoc_collection_find() to receive a signed limit.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: