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

Tailable cursors not supported correctly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.4
    • Affects Version/s: 0.3
    • Component/s: None
    • Labels:
    • Environment:
      Windows Server 2008 R2, Mongo v1.6.5 64 bit

      When the data currently in the cursor is exhausted, the mongo_cursor_next routine will call the 'private' mongo_cursor_get_more routine to see if there is any additional data. If not, mongo_cursor_next returns 0. At this point, the cursor never has a chance to get any more data (without a requery) because this code in mongo_cursor_next prevents another call to mongo_cursor_get_more.

      /* no data */
      if (!cursor->mm || cursor->mm->fields.num == 0)
      return 0;

      I found that if I make the mongo_cursor_get_more routine 'public', i.e., put it in mongo.h, and then add this code

      if ( mongo_cursor_get_more( m_pCursor ) )
      bson_init( &m_pCursor->current, &m_pCursor->mm->objs, 0 );

      prior to calling mongo_query_next, I get the desired results. This seems like a pretty vulgar hack to me...

      If there was a way to tell that a cursor was 'tailable' from the cursor structure, the above logic could be worked into the mongo_cursor_next routine.

        1. mongo.c
          30 kB
        2. mongo.c
          30 kB
        3. mongo.h
          8 kB

            Assignee:
            kbanker Kyle Banker
            Reporter:
            slg1013 Steve Green
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: