Skip to content

Commit

Permalink
Initialize cursor_magic field when creating cursor clientData structu…
Browse files Browse the repository at this point in the history
…res. In the yet-unused mongotcl_cmdNameObjToCursor, make sure the error message gets set if the command object lookup fails. Extend README.md with more examples.

BUGZID:
  • Loading branch information
lehenbauer committed Feb 13, 2014
1 parent 221a3f6 commit 128d6ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,18 @@ To build the same index in the bacground, append the '''background''' option to

```tcl
$mongo create_index daystream.controlstream $keyBson $bsonResult background
``
```

* search

This is a little gross and is going to be simplified, but...

```tcl
set cursor [$mongo cursor #auto daystream.controlstream]
$cursor next
$cursor to_list
4 changes: 3 additions & 1 deletion generic/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ mongotcl_cmdNameObjToCursor (Tcl_Interp *interp, Tcl_Obj *commandNameObj, mongo_
Tcl_CmdInfo cmdInfo;

if (!Tcl_GetCommandInfo (interp, Tcl_GetString(commandNameObj), &cmdInfo)) {
return TCL_ERROR;
goto lookup_error;
}

if (cmdInfo.objClientData == NULL || ((mongotcl_cursorClientData *)cmdInfo.objClientData)->cursor_magic != MONGOTCL_CURSOR_MAGIC) {
lookup_error:
Tcl_AppendResult (interp, "Error: '", Tcl_GetString (commandNameObj), "' is not a mongo cursor object", NULL);
return TCL_ERROR;
}
Expand Down Expand Up @@ -387,6 +388,7 @@ mongotcl_createCursorObjCmd(Tcl_Interp *interp, mongo *conn, char *commandName,
mc->interp = interp;
mc->conn = conn;
mc->cursor = (mongo_cursor *)ckalloc(sizeof(mongo_cursor));
mc->cursor_magic = MONGOTCL_CURSOR_MAGIC;

mongo_cursor_init (mc->cursor, conn, namespace);

Expand Down

0 comments on commit 128d6ec

Please sign in to comment.