             return
 
         _query_opts = {}  # this will be the input to the @_query command.
-        result = undefined
+        locals =
+            result     : undefined
+            changes_cb : undefined
         async.series([
             (cb) =>
                 if client_query.get.check_hook?

                                 where, json_fields, account_id, client_query, cb) =>
        dbg = @_dbg("_user_get_query_changefeed(table='#{table}')")
        dbg()
        if not misc.is_object(changes)
            cb("changes must be an object with keys id and cb")
            return

                misc.merge(_query_opts, x)

                if opts.changes?
                    locals.changes_cb = opts.changes.cb
                    locals.changes_queue = []
                    # see note about why we do the following at the bottom of this file
                    opts.changes.cb = (err, obj) ->
                        locals.changes_queue.push({err:err, obj:obj})
                    @_user_get_query_changefeed(opts.changes, table, primary_keys,
                                                opts.query, _query_opts.where, json_fields,
                                                opts.account_id, client_query, cb)
                else
                    cb()
            (cb) =>
                @_user_get_query_do_query _query_opts, client_query, opts.query, opts.multi, json_fields, (err, result) =>
                    if err
                        cb(err)
                        return
                    locals.result = result
                    cb()
        ], (err) =>
            if err
                opts.cb(err)
                return
            opts.cb(undefined, locals.result)
            if opts.changes?
                opts.changes.cb = locals.changes_cb
                ##dbg("sending queued #{JSON.stringify(locals.changes_queue)}")
                for {err, obj} in locals.changes_queue
                    ##dbg("sending queued changes #{JSON.stringify([err, obj])}")
                    opts.changes.cb(err, obj)
        )

    ###
