Skip to content

Commit 08cb3f9

Browse files
NoremosArtyom Abakumov
and
Artyom Abakumov
authored
Correct section name for services in fbtrace config (#8500)
* Correct section name for services in fbtrace config * Move section type paring to trace reader class --------- Co-authored-by: Artyom Abakumov <[email protected]>
1 parent 907edbb commit 08cb3f9

File tree

4 files changed

+45
-47
lines changed

4 files changed

+45
-47
lines changed

src/common/config/config_file.cpp

-33
Original file line numberDiff line numberDiff line change
@@ -960,36 +960,3 @@ bool ConfigFile::Parameter::asBoolean() const
960960
value.equalsNoCase("y");
961961
}
962962

963-
/******************************************************************************
964-
*
965-
* Parse name as a section key
966-
*/
967-
968-
ConfigFile::SectionType ConfigFile::Parameter::parseSectionKey() const
969-
{
970-
if (name == "database")
971-
{
972-
return SectionType::DATABASE;
973-
}
974-
else if (name == "databaseName")
975-
{
976-
return SectionType::DATABASE_NAME;
977-
}
978-
else if (name == "databaseRegex")
979-
{
980-
return SectionType::DATABASE_REGEX;
981-
}
982-
else if (name == "service")
983-
{
984-
return SectionType::SERVICE;
985-
}
986-
else
987-
{
988-
fatal_exception::raiseFmt("error while parsing trace configuration\n\t"
989-
"line %d: wrong section header, \"database\", \"databaseName\", \"databaseRegex\" or \"service\" is expected",
990-
line);
991-
992-
// Return something to calm down the compiler
993-
return SectionType::DATABASE;
994-
}
995-
}

src/common/config/config_file.h

-10
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted
7575
virtual const char* getFileName() const = 0;
7676
};
7777

78-
// Possible section types
79-
enum class SectionType
80-
{
81-
DATABASE,
82-
DATABASE_NAME,
83-
DATABASE_REGEX,
84-
SERVICE
85-
};
86-
8778
struct Parameter : public AutoStorage
8879
{
8980
Parameter(MemoryPool& p, const Parameter& par)
@@ -96,7 +87,6 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted
9687

9788
SINT64 asInteger() const;
9889
bool asBoolean() const;
99-
SectionType parseSectionKey() const;
10090

10191
KeyType name;
10292
String value;

src/utilities/ntrace/TraceConfiguration.cpp

+35-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void TraceCfgReader::readConfig()
8989
{
9090
const ConfigFile::Parameter* section = &params[n];
9191

92-
const ConfigFile::SectionType sectionType = section->parseSectionKey();
93-
const bool isDatabase = (sectionType != ConfigFile::SectionType::SERVICE);
92+
const SectionType sectionType = parseSectionKey(section);
93+
const bool isDatabase = (sectionType != SectionType::SERVICES);
9494

9595
const ConfigFile::String pattern = section->value;
9696
bool match = false;
@@ -127,14 +127,14 @@ void TraceCfgReader::readConfig()
127127
noQuotePattern.alltrim(" '\'");
128128
PathName expandedName;
129129

130-
if (sectionType != ConfigFile::SectionType::DATABASE_REGEX && (m_databaseName == noQuotePattern ||
130+
if (sectionType != SectionType::DATABASE_REGEX && (m_databaseName == noQuotePattern ||
131131
(expandDatabaseName(noQuotePattern, expandedName, nullptr),
132132
m_databaseName == expandedName) ))
133133
{
134134
// Compare by name
135135
match = exactMatch = true;
136136
}
137-
else if (sectionType != ConfigFile::SectionType::DATABASE_NAME)
137+
else if (sectionType != SectionType::DATABASE_NAME)
138138
{
139139
// Compare by regex
140140
bool regExpOk = false;
@@ -318,3 +318,34 @@ void TraceCfgReader::expandPattern(const ConfigFile::Parameter* el, PathName& va
318318
pos++;
319319
}
320320
}
321+
322+
TraceCfgReader::SectionType TraceCfgReader::parseSectionKey(const ConfigFile::Parameter* el) const
323+
{
324+
fb_assert(el);
325+
326+
if (el->name == "database")
327+
{
328+
return SectionType::DATABASE;
329+
}
330+
else if (el->name == "databaseName")
331+
{
332+
return SectionType::DATABASE_NAME;
333+
}
334+
else if (el->name == "databaseRegex")
335+
{
336+
return SectionType::DATABASE_REGEX;
337+
}
338+
else if (el->name == "services")
339+
{
340+
return SectionType::SERVICES;
341+
}
342+
else
343+
{
344+
fatal_exception::raiseFmt("error while parsing trace configuration\n\t"
345+
"line %d: wrong section header, \"database\", \"databaseName\", \"databaseRegex\" or \"services\" is expected",
346+
el->line);
347+
348+
// Return something to calm down the compiler
349+
return SectionType::DATABASE;
350+
}
351+
}

src/utilities/ntrace/TraceConfiguration.h

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ class TraceCfgReader
4949
int end;
5050
};
5151

52+
// Possible section types
53+
enum class SectionType
54+
{
55+
DATABASE,
56+
DATABASE_NAME,
57+
DATABASE_REGEX,
58+
SERVICES
59+
};
60+
5261
private:
5362
TraceCfgReader(const char* text, const Firebird::PathName& databaseName, TracePluginConfig& config) :
5463
m_text(text),
@@ -61,6 +70,7 @@ class TraceCfgReader
6170
void expandPattern(const ConfigFile::Parameter* el, Firebird::PathName& valueToExpand);
6271
bool parseBoolean(const ConfigFile::Parameter* el) const;
6372
ULONG parseUInteger(const ConfigFile::Parameter* el) const;
73+
SectionType parseSectionKey(const ConfigFile::Parameter* el) const;
6474

6575
const char* const m_text;
6676
const Firebird::PathName& m_databaseName;

0 commit comments

Comments
 (0)