Пример #1
0
void Connection::rollback()
{
	doExecute(m_connection,_S("ROLLBACK"));
#ifdef OS_ENABLE_DATABASE_ANALYZE
	m_transactionId = 0;
#endif
}
Пример #2
0
void Connection::commit()
{
	doExecute(m_connection,_S("COMMIT"));
#ifdef OS_ENABLE_DATABASE_ANALYZE
	m_transactionId = 0;
#endif
}
Пример #3
0
void ImportCommand::redo()
{
    KBookmarkGroup bkGroup;

    if (!folder().isNull()) {
        doCreateHoldingFolder(bkGroup);

    } else {
        // import into the root, after cleaning it up
        bkGroup = GlobalBookmarkManager::self()->root();
        delete m_cleanUpCmd;
        m_cleanUpCmd = DeleteCommand::deleteAll(m_model, bkGroup);

        new DeleteCommand(m_model, bkGroup.address(),
                          true /* contentOnly */, m_cleanUpCmd);
        m_cleanUpCmd->redo();

        // import at the root
        m_group = "";
    }

    doExecute(bkGroup);

    // notify the model that the data has changed
    //
    // FIXME Resetting the model completely has the unwanted
    // side-effect of collapsing all items in tree views
    // (and possibly other side effects)
    m_model->resetModel();
}
Пример #4
0
Terminal::Terminal(QWidget *parent) : QWidget(parent)
{
    logMessage("Terminal::Terminal()");

    setWindowTitle(tr("Command dialog"));
    setWindowIcon(icon("run"));

    txtCommand = new TerminalLineEdit(this);
    txtCommand->setCompleter(Util::completer());
    txtCommand->setMinimumWidth(300);
    connect(txtCommand, SIGNAL(returnPressed()), this, SLOT(doExecute()));
    connect(txtCommand, SIGNAL(textChanged(QString)), this, SLOT(doCommandTextChanged(QString)));

    txtOutput = new QTextEdit(this);
    txtOutput->setLineWrapMode (QTextEdit::NoWrap);
#ifndef Q_WS_MAC
    txtOutput->setFont(QFont("Monospaced", 9));
#endif
    txtOutput->setReadOnly(true);    

    btnExecute = new QPushButton(this);
    btnExecute->setText(tr("Execute"));
    btnExecute->setEnabled(false);
    connect(btnExecute, SIGNAL(clicked()), this, SLOT(doExecute()));

    btnClear = new QPushButton(this);
    btnClear->setText(tr("Clear"));
    connect(btnClear, SIGNAL(clicked()), txtOutput, SLOT(clear()));

    // layout
    QHBoxLayout *layoutCommand = new QHBoxLayout();
    layoutCommand->addWidget(new QLabel(tr("Enter command:")));
    layoutCommand->addWidget(txtCommand, 1);
    layoutCommand->addWidget(btnExecute);
    layoutCommand->addWidget(btnClear);

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(txtOutput);
    layout->addLayout(layoutCommand);
    txtCommand->setFocus();

    setTabOrder(txtCommand, btnExecute);
    setTabOrder(btnExecute, btnClear);
    setTabOrder(btnClear, txtCommand);

    setLayout(layout);
}
Пример #5
0
void Connection::beginTransaction()
{
	doExecute(m_connection,_S("BEGIN"));
#ifdef OS_ENABLE_DATABASE_ANALYZE
	static uint32 transactionStaticID = 0;
	m_transactionId = transactionStaticID++;
#endif
}
Пример #6
0
int main( int argc, char *argv[] )
{
	const char *name;
	int ch;

	/* Scan options */
	while ((ch = getopt( argc, argv, "hvV" )) != -1)
	{
		switch ((char) ch)
		{
		case 'h':
			usage();
			exit( EXIT_SUCCESS );
			break;

		case 'v':
			option_verbose = TRUE;
			break;

		case 'V':
			version();
			exit( EXIT_SUCCESS );
			break;

		default:
			usage();
			exit( EXIT_FAILURE );
			break;
		}
	}

	if (optind >= argc)
	{
		usage();
		exit( EXIT_FAILURE );
	}

	/* skip options */
	argc -= optind;
	argv += optind;

	if (argc < 1)
	{
		usage();
		exit( EXIT_FAILURE );
	}

	/* skip package */
	argc--; name = *argv++;

	if (! EcInit())
		error( "can't initialize elastiC environment" );

	doExecute( name, argc, argv );

	EcCleanup();
	exit( EXIT_SUCCESS );
}
Пример #7
0
void Action::setData(const QVariantMap data)
{
    setValue(data[Identifiers::keyValue]);
    if(data.contains(Identifiers::keyStartDelay)) setStartDelay(data[Identifiers::keyStartDelay].toInt());
    setRestore(data[Identifiers::keyRestore].toBool());
    doSetData(data);
    emit dataChanged(data);

    if(mRunning) doExecute(mValue);
}
Пример #8
0
QueryResult Statement::execute()
{
    try{
        return doExecute();
    }catch(OciException &ex){
        if(acquiredMutex){
            unlockConnection();
        }
        throw ex;
    }
}
Пример #9
0
void Action::timerEvent(QTimerEvent* event)
{
    const int timerId(event->timerId());
    if(timerId == mStartTimerId)
    {
        killTimer(mStartTimerId);
        mStartTimerId = 0;
        doStart(false);
        doExecute(mValue);
        mRunning = true;
    }
}
Пример #10
0
bool CmdsExecutor::execute(CmdArray& cmds, bool bContinue /* = false */)
{
    for(unsigned i = 0; i < cmds.size(); i++)
    {
        // 执行失败,并且需要中断执行,则返回
        if(!doExecute(cmds[i]) && !bContinue)
        {
            return false;
        }
    }
    return true;
}
Пример #11
0
void Connection::connect(const String &filename)
{
	close();

	// _tsqlite3_open crea un nuovo database se il file non esiste: dovrebbe essere il driver a monte che non crea la connessione se il file non esiste
	OS_ASSERT(FileSystem::instance()->fileExists(filename));

	int32 res = _tsqlite3_open(filename.c_str(), &m_connection);
	OS_EXCEPT_IF(res != SQLITE_OK, sqlite_last_error(m_connection, res));
	m_filename = filename;

	uint32 cacheSize = OS_NAMESPACE_NAME::Options::instance()->getOption<uint32>(OS_SQLITE_OPTION_CACHE_SIZE);
	String synchronous = static_cast<String>(OS_NAMESPACE_NAME::Options::instance()->getOption<String>(OS_SQLITE_OPTION_SYNCHRONOUS)).to_upper();
	if((synchronous != _S("FULL")) && (synchronous != _S("NORMAL")) && (synchronous != _S("OFF")))
		synchronous = _S("FULL");
	uint32 tempStore = OS_NAMESPACE_NAME::Options::instance()->getOption<uint32>(OS_SQLITE_OPTION_TEMP_STORE);
	if(tempStore > 2)
		tempStore = 0;

	doExecute(m_connection, _S("PRAGMA legacy_file_format = OFF;"));
	doExecute(m_connection, String::format(_S("PRAGMA cache_size = %d;").c_str(), cacheSize)); // Default di sqlite:2000
	doExecute(m_connection, String::format(_S("PRAGMA synchronous = %S;").c_str(), synchronous.c_str())); // FULL/NORMAL/OFF, Default di sqlite: FULL
	doExecute(m_connection, String::format(_S("PRAGMA temp_store = %d").c_str(), tempStore)); // 0(Default)/1(File)/2(Memory), Default di sqlite: 0
}
Пример #12
0
void Action::start(bool running)
{
    doCancelRestore();

    if(!mRunning && running)
    {
        doStart(true);
        doExecute(mValue);
        mRunning = true;
    }

    if(!mRunning && !mStartTimerId)
    {
        mStartTimerId = startTimer(mStartDelay);
    }
}
Пример #13
0
uint32 Connection::_execute(const String &sql)
{
	OS_LOCK(m_cs);

	//RealtimeStatsScopeTimer RSS(_S("Debug"), _S("Sqlite - Connection::execute"));
	//OS_LOG_WARNING(sql);
#ifdef OS_ENABLE_DATABASE_ANALYZE
	RealtimeStatsScopeTimer RSS(_S("Debug"), _S("Sqlite - ") + preAnalyze(sql));
#endif

	uint32 result = doExecute(m_connection, sql);
#ifdef OS_ENABLE_DATABASE_ANALYZE
	postAnalyze(sql);
#endif
	return result;
}
Пример #14
0
//-----------------------------------------------------------------------------
// 描述: 执行SQL (返回数据集)
//-----------------------------------------------------------------------------
DbDataSet* DbQuery::query()
{
    ensureConnected();

    DbDataSet *dataSet = database_->createDbDataSet(this);
    try
    {
        // 执行查询
        doExecute(dataSet);
        // 初始化数据集
        dataSet->initDataSet();
        // 初始化数据集各字段的定义
        dataSet->initFieldDefs();
    }
    catch (Exception&)
    {
        delete dataSet;
        dataSet = NULL;
        throw;
    }

    return dataSet;
}
Пример #15
0
void Executor::scheduleByTime(const bool monitorReuse, scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
		void *param) {
//	if (delayUs < 0) {
//		firmwareError(OBD_PCM_Processor_Fault, "Negative delayUs %s: %d", prefix, delayUs);
//		return;
//	}
//	if (delayUs == 0) {
//		callback(param);
//		return;
//	}
	if (!reentrantFlag) {
		// this would guard the queue and disable interrupts
		lockAnyContext();
	}
	bool needToResetTimer = queue.insertTask(scheduling, US2NT(timeUs), callback, param);
	if (!reentrantFlag) {
		doExecute();
		if (needToResetTimer) {
			scheduleTimerCallback();
		}
		unlockAnyContext();
	}
}
Пример #16
0
    template <typename F> void GpuFFTPlanCl<F>::doExecute (const cl::CommandQueue& queue, const cl::Buffer& input, csize_t inputOffset, const cl::Buffer& output, csize_t outputOffset, bool doForward) const {
      if (supportNonZeroOffsets) {
        if (inputOffset != 0 || outputOffset != 0) {
          queue.enqueueCopyBuffer (input, tmp.getDataWritable (), (inputOffset * sizeof (std::complex<F>)) (), 0, (csize_t (sizeof (std::complex<F>)) * this->batchSize ()).value ());
          doExecute (queue, tmp.getDataWritable (), 0, tmp.getDataWritable (), 0, doForward);
          queue.enqueueCopyBuffer (tmp.getData (), output, 0, (outputOffset * sizeof (std::complex<F>)) (), (csize_t (sizeof (std::complex<F>)) * this->batchSize ()).value ());
          return;
        }
      } else {
        ASSERT_MSG (inputOffset == 0, "not implemented");
        ASSERT_MSG (outputOffset == 0, "not implemented");
      }

      if (this->size () == 0)
        return;
      if (this->size () == 1) {
        if (input () != output ())
          queue.enqueueCopyBuffer (input, output, 0, 0, (csize_t (sizeof (std::complex<F>)) * this->batchCount ()).value ());
        return;
      }

      cl::detail::errHandler (VAL(ExecuteInterleaved) (queue (), static_cast<TY(Plan)> (plan), Core::checked_cast<int> (this->batchCount ()), doForward ? VAL(Forward) : VAL(Inverse), input (), output (), 0, NULL, NULL), VAL(ExecuteInterleavedStr));
    }
Пример #17
0
	bool Abstract::doGuardExecute()
	{
		bool r = doExecute();
		return r;
	}
Пример #18
0
void
ElemUse::execute(StylesheetExecutionContext&	executionContext) const
{
	doExecute(executionContext, true);
}
Пример #19
0
void Connection::vacuum()
{
	doExecute(m_connection, _S("vacuum"));
}
Пример #20
0
void Executor::onTimerCallback() {
	lockAnyContext();
	doExecute();
	scheduleTimerCallback();
	unlockAnyContext();
}
Пример #21
0
void Connection::reindex()
{
	doExecute(m_connection, _S("reindex"));
}
Пример #22
0
void Connection::analyze()
{
	doExecute(m_connection, _S("analyze"));
}
Пример #23
0
//-----------------------------------------------------------------------------
// 描述: 执行SQL (无返回结果)
//-----------------------------------------------------------------------------
void DbQuery::execute()
{
    ensureConnected();
    doExecute(NULL);
}
Пример #24
0
 Value Command::execute()
 {
   return doExecute();
 }
Пример #25
0
String Connection::preAnalyze(const String &sql)
{
	static boost::recursive_mutex cs;
	OS_LOCK(cs);

	// Per vedere le sql nel charts:
	// RealtimeStatsManager::signal(sql, 1, RealtimeStatsCounter::ctAbsolute, _S("status"));

	// Da notare che vengono archiviate nella os_monitor solo le query analizzate dalla "explain".
	// Una "insert", non usando indici, non viene catalogata, a meno che non abbia sotto-query.

	if(sql.find(_S("explain query plan ")) != String::npos)
		return _S("");

	if(sql.find(_S("os_monitor")) != String::npos)
		return _S("");

	static shared_ptr<Connection> connectionAnalyze = nullptr;
	if(connectionAnalyze == nullptr)
	{
		shared_ptr<Driver> driver = boost::dynamic_pointer_cast<Driver>(getDriver());
		String path = driver->getDatabasePath(_S("monitor.db"));
		if(FileSystem::instance()->exists(path) == false)
		{
			// Crea il database se non esiste
			File file;
			String msg = _S("Cannot create file '") + path + _S("'");
			OS_EXCEPT_IF(file.open(path, File::ofWrite) == false, msg.to_ascii());
		}

		connectionAnalyze.reset(OS_NEW Connection(path, getDriver()->createOptions(), getDriver()));

		int32 res = _tsqlite3_open(path.c_str(), &connectionAnalyze->m_connection);
		OS_EXCEPT_IF(res != SQLITE_OK, sqlite_last_error(connectionAnalyze->m_connection, res));

		// Creazione tabella
		String sqlCreate = _S("CREATE TABLE IF NOT EXISTS os_monitor (filename text,sql text,thread integer,conn integer,trans integer, qorder integer,qfrom integer,detail text,indexUsed text)");
		doExecute(connectionAnalyze->m_connection, sqlCreate);
	}

	// I valori dei campi li setto a ?, per poter fare delle distinct sui risultati
	String keySql = sql;
	keySql.trim();
	keySql = regex_replace(keySql, RegexManager::instance()->getRegex(_S("'(.*?)'")), _S("<s>")); // Valori dei campi
	keySql = regex_replace(keySql, RegexManager::instance()->getRegex(_S("[-+]?[0-9]*\\.?[0-9]+")), _S("<n>")); // Numeri
	keySql = keySql.replace_all(_S("\n"),_S(""));
	keySql = keySql.replace_all(_S("\r"),_S(""));
	keySql = keySql.replace_all(_S("\t"),_S(""));
	keySql = keySql.replace_all(_S("'"),_S("")); // Futile, per evitare errori nella insert nella os_monitor
	for(;;) // Comprimo gli spazi
	{
		String x = keySql;
		keySql = keySql.replace_all(_S("  "),_S(" "));
		if(x == keySql)
			break;
	}

	uint32 conn = uint32(reinterpret_cast<uint64>(this));
	boost::any threadID = PlatformManager::instance()->getCurrentThreadID();
	// Tenta un cast a uint32
	uint32 *thread = boost::any_cast<uint32>(&threadID);
	int32 trans = m_transactionId;

	DataTable result;
	doQuery(m_connection, _S("explain query plan ") + sql,result);

	for(uint32 r=0;r<result.rows();r++)
	{
		int32 order = *result.get(r,_S("order"));
		int32 from = *result.get(r,_S("from"));
		String detail = *result.get(r,_S("detail"));

		String indexUsed;
		String::size_type posWithIndex = detail.find(_S("WITH INDEX"));
		if(posWithIndex != String::npos)
		{
			indexUsed = detail.substr(posWithIndex+10);
			indexUsed = indexUsed.replace_all(_S("ORDER BY"),String::EMPTY);
			indexUsed.trim();
		}

		String sqlInsert = String::format(_S("insert into os_monitor values ('%S','%S',%u,%u,%u,%d,%d,'%S','%S')").c_str(), m_filename.c_str(), keySql.c_str(), conn, thread != nullptr ? *thread : 0, trans, order, from, detail.c_str(), indexUsed.c_str());
		doExecute(connectionAnalyze->m_connection, sqlInsert);
	}

	String trace = String::format(_S("Sqlite monitor: sql='%S',conn=%u,thread=%u,trans=%u\n").c_str(), sql.c_str(), conn, thread != nullptr ? *thread : 0, trans);
	//OS_TRACE(trace);

	//RealtimeStatsManager::signal(_S("Sqlite ") + keySql.mid(0,6), 1, RealtimeStatsCounter::ctRelative, _S("items"));
	return keySql;
}
Пример #26
0
bool KHelper::execute()
{
	return doExecute();
}
Пример #27
0
void ObjectSelector::run(){
	//ulong		crttout;
	int 		state;
	int 		pollwait = 0;
	const int	maxnbcnt = 256;
	int			nbcnt = -1;//non blocking opperations count
							//used to reduce the number of calls for the system time.
	do{
		state = 0;
		if(nbcnt < 0){
			d.ctimepos.currentRealTime();
			nbcnt = maxnbcnt;
		}
		
		if(d.ctimepos > d.ntimepos){
			state |= Data::FULL_SCAN;
		}
		if(state || d.objq.size()){
			pollwait = 0;
			--nbcnt;
		}else{ 
			if(d.ntimepos.seconds() != 0xffffffff) {
				pollwait = 1;
			}else pollwait = -1;
			nbcnt = -1;
        }
        
		state |= doWait(pollwait);
		
		if(state & Data::FULL_SCAN){
			idbgx(Debug::frame, "full_scan");
			ulong evs = 0;
			d.ntimepos.set(0xffffffff);
			for(Data::ObjectStubVectorT::iterator it(d.sv.begin()); it != d.sv.end(); it += 4){
				if(!it->objptr.empty()){
					Data::ObjectStub &ro = *it;
					evs = 0;
					if(d.ctimepos >= ro.timepos) evs |= EventTimeout;
					else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos;
					if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs
					if(evs){
						state |= doExecute(it - d.sv.begin(), evs, d.ctimepos);
					}
				}
				if(!(it + 1)->objptr.empty()){
					Data::ObjectStub &ro = *(it + 1);
					evs = 0;
					if(d.ctimepos >= ro.timepos) evs |= EventTimeout;
					else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos;
					if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs
					if(evs){
						state |= doExecute(it - d.sv.begin() + 1, evs, d.ctimepos);
					}
				}
				if(!(it + 2)->objptr.empty()){
					Data::ObjectStub &ro = *(it + 2);
					evs = 0;
					if(d.ctimepos >= ro.timepos) evs |= EventTimeout;
					else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos;
					if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs
					if(evs){
						state |= doExecute(it - d.sv.begin() + 2, evs, d.ctimepos);
					}
				}
				if(!(it + 3)->objptr.empty()){
					Data::ObjectStub &ro = *(it + 3);
					evs = 0;
					if(d.ctimepos >= ro.timepos) evs |= EventTimeout;
					else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos;
					if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs
					if(evs){
						state |= doExecute(it - d.sv.begin() + 3, evs, d.ctimepos);
					}
				}
			}
		}
		
		{	
			int qsz = d.objq.size();
			while(qsz){//we only do a single scan:
				vdbgx(Debug::frame, "qsz = "<<qsz<<" queuesz "<<d.objq.size());
				int pos = d.objq.front();d.objq.pop(); --qsz;
				Data::ObjectStub &ro = d.sv[pos];
				if(ro.state){
					ro.state = 0;
					state |= doExecute(pos, 0, d.ctimepos);
				}
			}
		}
		vdbgx(Debug::frame, "sz = "<<d.sz);
		if(empty()) state |= Data::EXIT_LOOP;
	}while(state != Data::EXIT_LOOP);
}