[CDRIVER-167] Clarification on mongo_connect example in tutorial Created: 15/Aug/12  Updated: 11/Sep/19  Resolved: 17/Aug/12

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 0.6
Fix Version/s: 0.7

Type: Task Priority: Major - P3
Reporter: Stennie Steneker (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The API docs @ http://api.mongodb.org/c/current/tutorial.html#connecting include an example which suggests that you can get a mongo_connect() return value which is != MONGO_OK but still be able to check for MONGO_CONN_SUCCESS:

 int status = mongo_connect( conn, "127.0.0.1", 27017 );
 
 if( status != MONGO_OK ) {
      switch ( conn->err ) {
        case MONGO_CONN_SUCCESS:    printf( "connection succeeded\n" ); break;
...

Although conn->err is 0 (MONGO_CONN_SUCCESS) when connected, it doesn't seem possible to get both an error and be successfully connected?



 Comments   
Comment by Gary Murakami [ 17/Aug/12 ]

MONGO_CONN_SUCCESS is defined as mongo_error_t value 0, but it is never used in the code base - tutorial fixed

Comment by auto [ 17/Aug/12 ]

Author:

{u'date': u'2012-08-16T19:16:25-07:00', u'email': u'gary.murakami@10gen.com', u'name': u'Gary Murakami'}

Message: CDRIVER-167 - Clarification on mongo_connect example in tutorial
MONGO_CONN_SUCCESS is never used for an error return and the tutorial was wrong, it is now fixed.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/8ae2c57e95a3939850a77fb9329c129b2bcfcd1a

Comment by Gary Murakami [ 17/Aug/12 ]

Stephen - you are correct. While MONGO_CONN_SUCCESS is defined as mongo_error_t value 0, it is never used in the code base. I'll fix the tutorial. Thanks for pointing it out.

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