[CDRIVER-1234] Inconsistent error reporting when advancing completed OP_QUERY and command cursor Created: 17/May/16  Updated: 10/Aug/16  Resolved: 24/May/16

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.4.0
Fix Version/s: 1.4.0

Type: Bug Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to PHPC-673 Cursor::isDead() returns true despite... Closed
is related to CDRIVER-1221 mongoc_cursor_is_alive() returns fals... Closed

 Description   

While revising older PHPC tests to account for proper behavior noted in CDRIVER-1221, I realized another inconsistency between legacy and command cursor iteration.

_mongoc_cursor_next() and _mongoc_cursor_cursorid_next() are used for OP_QUERY and command cursor iteration, respectively. Both return true or false depending on whether a BSON document has been read (i.e. *bson is checked), although they differ in how cursor->done is calculated.

An superfluous call to _mongoc_cursor_next() results in a cursor error being set ("Cannot advance a completed or failed cursor."); however, a superfluous call to _mongoc_cursor_cursorid_next() raise no such error. In PHPC, this means that extra iteration on a complete cursor may or may not throw an exception, depending on the underlying protocol.

Is it feasible to make these two methods consistent, either by having _mongoc_cursor_cursorid_next() set an error or removing the exception error from _mongoc_cursor_next()?



 Comments   
Comment by Githook User [ 06/Jun/16 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: Test cursor iteration beyond last document for CDRIVER-1234
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/ee751dc027c485d79aefed5d6f37aaed96c6f9bb

Comment by Githook User [ 24/May/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1234 always an err to iterate done cursor
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c03fde8afdae869a982bd9f0120ebf3cee302fc5

Comment by Jeremy Mikola [ 17/May/16 ]

Current PHPC tests: https://github.com/mongodb/mongo-php-driver/pull/327

Generated at Wed Feb 07 21:11:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.