MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Query

Method Query

lib/db_ido_pgsql/idopgsqlconnection.cpp:481–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479}
480
481IdoPgsqlResult IdoPgsqlConnection::Query(const String& query)
482{
483 AssertOnWorkQueue();
484
485 Defer decreaseQueries ([this]() { DecreasePendingQueries(1); });
486
487 Log(LogDebug, "IdoPgsqlConnection")
488 << "Query: " << query;
489
490 IncreaseQueryCount();
491
492 PGresult *result = m_Pgsql->exec(m_Connection, query.CStr());
493
494 if (!result) {
495 String message = m_Pgsql->errorMessage(m_Connection);
496 Log(LogCritical, "IdoPgsqlConnection")
497 << "Error \"" << message << "\" when executing query \"" << query << "\"";
498
499 BOOST_THROW_EXCEPTION(
500 database_error()
501 << errinfo_message(message)
502 << errinfo_database_query(query)
503 );
504 }
505
506 char *rowCount = m_Pgsql->cmdTuples(result);
507 m_AffectedRows = atoi(rowCount);
508
509 if (m_Pgsql->resultStatus(result) == PGRES_COMMAND_OK) {
510 m_Pgsql->clear(result);
511 return IdoPgsqlResult();
512 }
513
514 if (m_Pgsql->resultStatus(result) != PGRES_TUPLES_OK) {
515 String message = m_Pgsql->resultErrorMessage(result);
516 m_Pgsql->clear(result);
517
518 Log(LogCritical, "IdoPgsqlConnection")
519 << "Error \"" << message << "\" when executing query \"" << query << "\"";
520
521 BOOST_THROW_EXCEPTION(
522 database_error()
523 << errinfo_message(message)
524 << errinfo_database_query(query)
525 );
526 }
527
528 return IdoPgsqlResult(result, [this](PGresult* result) { m_Pgsql->clear(result); });
529}
530
531DbReference IdoPgsqlConnection::GetSequenceValue(const String& table, const String& column)
532{

Callers

nothing calls this directly

Calls 9

LogClass · 0.85
database_errorClass · 0.85
execMethod · 0.80
CStrMethod · 0.80
errorMessageMethod · 0.80
cmdTuplesMethod · 0.80
resultStatusMethod · 0.80
resultErrorMessageMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected