示例#1
0
    void pushStatistics(const Query& query)
    {
        try
        {
            work tr(*_connection);
            string sql = "insert into \"scidb_stat\"(query_id, ts, query_str, query_stat)"
                    " values ($1, now(), $2, $3)";
            _connection->prepare("append_stat", sql)
                    ("bigint", treat_direct)
                    ("varchar", treat_string)
                    ("varchar", treat_string);

            stringstream ss;
            query.writeStatistics(ss);

            tr.prepared("append_stat")
                    (query.getQueryID())
                    (query.queryString)
                    (ss.str()).exec();
            _connection->unprepare("append_stat");
            tr.commit();
        }
        catch (const sql_error &e)
        {
            throw SYSTEM_EXCEPTION(SCIDB_SE_SYSCAT, SCIDB_LE_PG_QUERY_EXECUTION_FAILED) << e.query()
                << e.what();
        }
        catch (const PGSTD::runtime_error &e)
        {
            throw SYSTEM_EXCEPTION(SCIDB_SE_SYSCAT, SCIDB_LE_CANT_CONNECT_PG) << e.what();
        }
        catch (const Exception &e)
        {
            throw;
        }
        catch (const std::exception &e)
        {
            throw SYSTEM_EXCEPTION(SCIDB_SE_SYSCAT, SCIDB_LE_UNKNOWN_ERROR) << e.what();
        }
        catch (...)
        {
            throw SYSTEM_EXCEPTION(SCIDB_SE_SYSCAT, SCIDB_LE_UNKNOWN_ERROR) <<
                "Unknown exception when connecting to system catalog";
        }
    }
示例#2
0
 void pushStatistics(const Query& query)
 {
     stringstream ss;
     query.writeStatistics(ss);
     LOG4CXX_INFO(_logger, "Statistics of query " << query.getQueryID() << ": " << ss.str())
 }