Status ParsedUpdate::parseRequest() {
    // It is invalid to request that the UpdateStage return the prior or newly-updated version
    // of a document during a multi-update.
    invariant(!(_request->shouldReturnAnyDocs() && _request->isMulti()));

    // It is invalid to request that a ProjectionStage be applied to the UpdateStage if the
    // UpdateStage would not return any document.
    invariant(_request->getProj().isEmpty() || _request->shouldReturnAnyDocs());

    if (!_request->getCollation().isEmpty()) {
        auto collator = CollatorFactoryInterface::get(_opCtx->getServiceContext())
                            ->makeFromBSON(_request->getCollation());
        if (!collator.isOK()) {
            return collator.getStatus();
        }
        _collator = std::move(collator.getValue());
    }

    Status status = parseArrayFilters();
    if (!status.isOK()) {
        return status;
    }

    // We parse the update portion before the query portion because the dispostion of the update
    // may determine whether or not we need to produce a CanonicalQuery at all.  For example, if
    // the update involves the positional-dollar operator, we must have a CanonicalQuery even if
    // it isn't required for query execution.
    parseUpdate();
    status = parseQuery();
    if (!status.isOK())
        return status;
    return Status::OK();
}
示例#2
0
 Status UpdateExecutor::prepare() {
     // We parse the update portion before the query portion because the dispostion of the update
     // may determine whether or not we need to produce a CanonicalQuery at all.  For example, if
     // the update involves the positional-dollar operator, we must have a CanonicalQuery even if
     // it isn't required for query execution.
     Status status = parseUpdate();
     if (!status.isOK())
         return status;
     status = parseQuery();
     if (!status.isOK())
         return status;
     return Status::OK();
 }
示例#3
0
void UpdateScript::parse(const std::string& path)
{
	m_path.clear();

	TiXmlDocument document(path);
	if (document.LoadFile())
	{
		m_path = path;

		LOG(Info,"Loaded script from " + path);

		const TiXmlElement* updateNode = document.RootElement();
		parseUpdate(updateNode);
	}
	else
	{
		LOG(Error,"Unable to load script " + path);
	}
}
示例#4
0
Status ParsedUpdate::parseRequest() {
    // It is invalid to request that the UpdateStage return the prior or newly-updated version
    // of a document during a multi-update.
    invariant(!(_request->shouldReturnAnyDocs() && _request->isMulti()));

    // It is invalid to request that a ProjectionStage be applied to the UpdateStage if the
    // UpdateStage would not return any document.
    invariant(_request->getProj().isEmpty() || _request->shouldReturnAnyDocs());

    // We parse the update portion before the query portion because the dispostion of the update
    // may determine whether or not we need to produce a CanonicalQuery at all.  For example, if
    // the update involves the positional-dollar operator, we must have a CanonicalQuery even if
    // it isn't required for query execution.
    Status status = parseUpdate();
    if (!status.isOK())
        return status;
    status = parseQuery();
    if (!status.isOK())
        return status;
    return Status::OK();
}
示例#5
0
//static
Command* Command::parseTokens( Tokens& tokens, bool helpMode )
{
    if (tokens.empty()) THROW( CWDB_ERR_PARSER, "Bad syntax: no tokens to parse");
    Command* result = 0;
    try {
        switch(tokens.front().m_angen) {
            case ANGEN_CREATE:   parseCreate( tokens, helpMode, result ); break;
            case ANGEN_DESCR:    parseDescr( tokens, helpMode, result ); break;
            case ANGEN_DROP:     parseDrop( tokens, helpMode, result ); break;
            case ANGEN_DUMP:     parseDump( tokens, helpMode, result ); break;
            case ANGEN_GET:
            case ANGEN_SET:
            case ANGEN_PUT:      parseInput( tokens, helpMode, result ); break;
            case ANGEN_QUERY:    parseQuery( tokens, helpMode, result ); break;
            case ANGEN_USE:      parseUse( tokens, helpMode, result ); break;
            case ANGEN_GENERATE: parseGenerate( tokens, helpMode, result ); break;
            case ANGEN_VERSION:  parseVersion( tokens, helpMode, result ); break;
            case ANGEN_FORMAT:   parseFormat( tokens, helpMode, result ); break;
            case ANGEN_COMPACT:  parseCompact( tokens, helpMode, result ); break;
            case ANGEN_UPDATE:   parseUpdate( tokens, helpMode, result ); break;
            case ANGEN_START:
            case ANGEN_STOP:     parseStart( tokens, helpMode, result ); break;
            case ANGEN_EXPORT:   parseExport( tokens, helpMode, result ); break;
            case ANGEN_IMPORT:   parseImport( tokens, helpMode, result ); break;
            default: THROW( CWDB_ERR_PARSER, "Bad syntax: unknown command" );
        }
    }
    catch (CWDBException& e) {
        if (result != 0) {
            delete result;
            result = 0;
        }
        throw e;
    }

    return result;
}
AISUpdate::AISUpdate(const LLSD& update)
{
	parseUpdate(update);
}