BlockIO InterpreterSetQuery::execute()
{
	ASTSetQuery & ast = typeid_cast<ASTSetQuery &>(*query_ptr);
	Context & target = ast.global ? context.getGlobalContext() : context.getSessionContext();
	executeImpl(ast, target);
	return {};
}
Exemple #2
0
StoreQueryResult Query::store()
{
    executeImpl();
    MYSQL_RES * res = mysql_store_result(conn->getDriver());
    if (!res)
        checkError(conn->getDriver());

    return StoreQueryResult(res, conn, this);
}
Exemple #3
0
UseQueryResult Query::use()
{
    executeImpl();
    MYSQL_RES * res = mysql_use_result(conn->getDriver());
    if (!res)
        onError(conn->getDriver());

    return UseQueryResult(res, conn, this);
}
std::unique_ptr<ShellCommand> ShellCommand::execute(const std::string & command)
{
	/// Аргументы в неконстантных кусках памяти (как требуется для execv).
	/// Причём, их копирование должно быть совершено раньше вызова vfork, чтобы после vfork делать минимум вещей.
	std::vector<char> argv0("sh", "sh" + strlen("sh") + 1);
	std::vector<char> argv1("-c", "-c" + strlen("-c") + 1);
	std::vector<char> argv2(command.data(), command.data() + command.size() + 1);

	char * const argv[] = { argv0.data(), argv1.data(), argv2.data(), nullptr };

	return executeImpl("/bin/sh", argv);
}
int AsyncIOCommand::execute(AsyncIOChannel& channel)
{
	delete _pException;
	_pException = 0;

	_state = CMD_IN_PROGRESS;
	try
	{
		_result = executeImpl(channel);
		_state = CMD_COMPLETED;
		_completed.set();
		AsyncIOEvent completedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_COMPLETED);
		commandCompleted(this, completedEvent);
		channel.commandCompleted(this, completedEvent);
		return _result;
	}
	catch (Exception& exc)
	{
		_pException = exc.clone();
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
	catch (std::exception& exc)
	{
		_pException = new Exception(exc.what());
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
	catch (...)
	{
		_pException = new Exception("Unknown exception");
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
}
std::unique_ptr<ShellCommand> ShellCommand::executeDirect(const std::string & path, const std::vector<std::string> & arguments)
{
	size_t argv_sum_size = path.size() + 1;
	for (const auto & arg : arguments)
		argv_sum_size += arg.size() + 1;

	std::vector<char *> argv(arguments.size() + 2);
	std::vector<char> argv_data(argv_sum_size);
	WriteBuffer writer(argv_data.data(), argv_sum_size);

	argv[0] = writer.position();
	writer.write(path.data(), path.size() + 1);

	for (size_t i = 0, size = arguments.size(); i < size; ++i)
	{
		argv[i + 1] = writer.position();
		writer.write(arguments[i].data(), arguments[i].size() + 1);
	}

	argv[arguments.size() + 1] = nullptr;

	return executeImpl(path.data(), argv.data());
}
void InterpreterSetQuery::executeForCurrentContext()
{
	ASTSetQuery & ast = typeid_cast<ASTSetQuery &>(*query_ptr);
	executeImpl(ast, context);
}
Exemple #8
0
void Query::execute()
{
    executeImpl();
}
Exemple #9
0
DLL_EXPORT void execute(char *fileBuff) {
	struct RuntimeContext *ctx = createRuntimeContext(NULL);
	readMetadata(ctx, fileBuff);
	executeImpl(ctx);
}
Exemple #10
0
int main(int argc, char *argv[]) {
	struct RuntimeContext *ctx = initializeRuntimeFromFile(argv[1]);
	executeImpl(ctx);
	return 0;
}
BlockIO InterpreterExplainQuery::execute()
{
    BlockIO res;
    res.in = executeImpl();
    return res;
}