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

Method InternalExecuteQuery

lib/db_ido_pgsql/idopgsqlconnection.cpp:859–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857}
858
859void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOverride)
860{
861 AssertOnWorkQueue();
862
863 if (IsPaused() && GetPauseCalled()) {
864 DecreasePendingQueries(1);
865 return;
866 }
867
868 if (!GetConnected()) {
869 DecreasePendingQueries(1);
870 return;
871 }
872
873 if (query.Type == DbQueryNewTransaction) {
874 DecreasePendingQueries(1);
875 InternalNewTransaction();
876 return;
877 }
878
879 /* check whether we're allowed to execute the query first */
880 if (GetCategoryFilter() != DbCatEverything && (query.Category & GetCategoryFilter()) == 0) {
881 DecreasePendingQueries(1);
882 return;
883 }
884
885 if (query.Object && query.Object->GetObject()->GetExtension("agent_check").ToBool()) {
886 DecreasePendingQueries(1);
887 return;
888 }
889
890 /* check if there are missing object/insert ids and re-enqueue the query */
891 if (!CanExecuteQuery(query)) {
892 m_QueryQueue.Enqueue([this, query, typeOverride]() { InternalExecuteQuery(query, typeOverride); }, query.Priority);
893 return;
894 }
895
896 std::ostringstream qbuf, where;
897 int type;
898
899 if (query.WhereCriteria) {
900 where << " WHERE ";
901
902 ObjectLock olock(query.WhereCriteria);
903 Value value;
904 bool first = true;
905
906 for (const Dictionary::Pair& kv : query.WhereCriteria) {
907 if (!FieldToEscapedString(kv.first, kv.second, &value)) {
908 m_QueryQueue.Enqueue([this, query]() { InternalExecuteQuery(query, -1); }, query.Priority);
909 return;
910 }
911
912 if (!first)
913 where << " AND ";
914
915 where << kv.first << " = " << value;
916

Callers

nothing calls this directly

Calls 8

GetExtensionMethod · 0.80
SubStrMethod · 0.80
SetValueMethod · 0.80
ToBoolMethod · 0.45
GetObjectMethod · 0.45
EnqueueMethod · 0.45
GetLengthMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected