[CDRIVER-295] Allow access to getLastError document Created: 13/Mar/14 Updated: 03/May/17 Resolved: 13/Mar/14 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 0.90.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Maga Napanga | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Any |
||
| Description |
|
There is no way to access the getLastError document, since it's being received, evaluated and then discarded right after _mongoc_write_concern_has_gle(). So, clients can't access the rest of the fields to evaluate for example, how many documents were affected by the previous update/delete operation, or whether an upsert resulted in an update or an insert, besides other useful fields I've seen there. |
| Comments |
| Comment by Maga Napanga [ 13/Mar/14 ] |
|
Hello! I'm glad it was useful, although you had to fix my fixes... lol Thanks for taking care of this so quickly |
| Comment by Christian Hergert [ 13/Mar/14 ] |
|
This is now in mongo-c-driver master. See the following for a follow up commit that changes the semantics a bit from your original patch. https://github.com/mongodb/mongo-c-driver/commit/b04fd6722cec92aa30288344f7cf5bfff03bd0a5 Thanks again! – Christian |
| Comment by Christian Hergert [ 13/Mar/14 ] |
|
One thing I think we can do, however, is to keep the mongoc_client_* methods keep mongoc_client_t as the first parameter. We can add an out parameter for the GLE response, which can then be stored by the caller (in this case, mongoc_collection_t). Either way, I'll bring in this commit, and massage it a bit. |
| Comment by Christian Hergert [ 13/Mar/14 ] |
|
Hi Maga, Thanks for working on this! I think the important thing is that we document the necessity of the last command sending a write concern that would result in a GLE (which it looks likve you've done on the patch). We should probably also clear the GLE if a command such as OP_INSERT/etc has been dispatched since without a GLE. The patch you've put together on github looks quite comprehensive, thanks for catching up with the codebase so quick! – Christian |
| Comment by Maga Napanga [ 13/Mar/14 ] |
|
Would it be acceptable to add:
to _mongoc_collection_t() ? If so:
I could work on that if it sounds good to you. |