Skip to content

Commit 82aa0a8

Browse files
committed
Fix problem of mixing MetaString and MetaName in comparations.
1 parent a6fbd1a commit 82aa0a8

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

src/common/classes/QualifiedMetaString.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131

3232
namespace Firebird {
3333

34+
template <typename T>
35+
concept IsQualifiedName = requires(T t)
36+
{
37+
{ t.schema };
38+
{ t.object };
39+
{ t.package };
40+
};
41+
3442
template <typename T>
3543
class BaseQualifiedName
3644
{
@@ -277,26 +285,30 @@ class BaseQualifiedName
277285
}
278286

279287
public:
280-
bool operator<(const BaseQualifiedName& m) const
288+
template <IsQualifiedName U>
289+
bool operator<(const U& m) const
281290
{
282291
return schema < m.schema ||
283292
(schema == m.schema && object < m.object) ||
284293
(schema == m.schema && object == m.object && package < m.package);
285294
}
286295

287-
bool operator>(const BaseQualifiedName& m) const
296+
template <IsQualifiedName U>
297+
bool operator>(const U& m) const
288298
{
289299
return schema > m.schema ||
290300
(schema == m.schema && object > m.object) ||
291301
(schema == m.schema && object == m.object && package > m.package);
292302
}
293303

294-
bool operator==(const BaseQualifiedName& m) const
304+
template <IsQualifiedName U>
305+
bool operator==(const U& m) const
295306
{
296307
return schema == m.schema && object == m.object && package == m.package;
297308
}
298309

299-
bool operator!=(const BaseQualifiedName& m) const
310+
template <IsQualifiedName U>
311+
bool operator!=(const U& m) const
300312
{
301313
return !(*this == m);
302314
}

src/jrd/MetaName.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ class MetaName
286286
return compare(s.c_str(), s.length());
287287
}
288288

289+
int compare(const Firebird::MetaString& s) const
290+
{
291+
return compare(s.c_str(), s.length());
292+
}
293+
289294
int compare(const MetaName& m) const
290295
{
291296
if (word == m.word)
@@ -319,6 +324,16 @@ class MetaName
319324
return compare(s) != 0;
320325
}
321326

327+
bool operator==(const Firebird::MetaString& s) const
328+
{
329+
return compare(s) == 0;
330+
}
331+
332+
bool operator!=(const Firebird::MetaString& s) const
333+
{
334+
return compare(s) != 0;
335+
}
336+
322337
bool operator<=(const MetaName& m) const
323338
{
324339
return compare(m) <= 0;

src/jrd/jrd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2963,7 +2963,7 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch
29632963
{
29642964
// Superuser can create databases for anyone other
29652965
fb_utils::dpbItemUpper(options.dpb_owner);
2966-
if (userId.getUserName() != options.dpb_owner)
2966+
if (userId.getUserName() != MetaString(options.dpb_owner))
29672967
{
29682968
(Arg::Gds(isc_no_priv) << "IMPERSONATE USER" << "DATABASE" << filename).raise();
29692969
}

src/jrd/replication/Replicator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ namespace Replication
9090
buffer->add(ptr, sizeof(SINT64));
9191
}
9292

93-
template <typename T>
94-
ULONG defineAtom(const T& name)
93+
ULONG defineAtom(const Firebird::string& name)
9594
{
9695
if (lastAtom < atoms.getCount() && atoms[lastAtom] == name)
9796
return lastAtom;

0 commit comments

Comments
 (0)