Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/burp/burp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "../burp/std_desc.h"
#include "../burp/split/spit.h"
#include "../jrd/license.h"

#include "../jrd/obj.h"
#include "../common/classes/timestamp.h"
#include "../burp/burp_proto.h"
#include "../burp/backu_proto.h"
Expand Down Expand Up @@ -1147,7 +1147,7 @@ int gbak(Firebird::UtilSvc* uSvc)
BURP_error(441, true, SafeArg() << in_sw_tab->in_sw_name);
// parameter for option -@1 is missing
}
tdgbl->loadMapping(argv[itr], tdgbl->tablespace_mapping, false);
tdgbl->loadMapping(argv[itr], tdgbl->tablespaceFileMap, false);
break;
case IN_SW_BURP_TS_ORIGINAL_PATHS:
if (tdgbl->gbl_sw_ts_orig_paths)
Expand All @@ -1162,11 +1162,11 @@ int gbak(Firebird::UtilSvc* uSvc)
}

{
Firebird::string ts_name = argv[++itr];
Firebird::string ts_path = argv[++itr];
const string ts_name(argv[++itr]);
const string ts_path(argv[++itr]);

if (ts_name.length() && ts_path.length())
tdgbl->tablespace_mapping.put(ts_name, ts_path);
tdgbl->tablespaceFileMap.put(ts_name, ts_path);
}

break;
Expand Down Expand Up @@ -2790,6 +2790,24 @@ void BurpGlobals::setupSkipIncludePattern(const string& regexp, USHORT alreadySe
}
}

burp_pkg* BurpGlobals::getPackage(const QualifiedMetaString& name) const
{
const auto result = metaDictionary.get({obj_package_header, name});
return result ? result->package : nullptr;
}

burp_rel* BurpGlobals::getRelation(const QualifiedMetaString& name) const
{
const auto result = metaDictionary.get({obj_relation, name});
return result ? result->relation : nullptr;
}

burp_prc* BurpGlobals::getProcedure(const QualifiedMetaString& name) const
{
const auto result = metaDictionary.get({obj_procedure, name});
return result ? result->procedure : nullptr;
}

Firebird::string BurpGlobals::toSystem(const Firebird::PathName& from)
{
Firebird::string to = from.ToString();
Expand Down
41 changes: 38 additions & 3 deletions src/burp/burp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool
firstMap(true),
firstDbc(true),
stdIoMode(false),
tablespace_mapping(*getDefaultMemoryPool())
tablespaceFileMap(*getDefaultMemoryPool()),
metaDictionary(*getDefaultMemoryPool())
{
// this is VERY dirty hack to keep current (pre-FB2) behaviour
memset (&gbl_database_file_name, 0,
Expand Down Expand Up @@ -1321,9 +1322,43 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool
Firebird::AutoPtr<Firebird::SimilarToRegex> skipDataMatcher;
Firebird::AutoPtr<Firebird::SimilarToRegex> includeSchemaDataMatcher;
Firebird::AutoPtr<Firebird::SimilarToRegex> includeDataMatcher;
StringMap tablespace_mapping; // Will be used to overwrite filename of tablespace with given name
StringMap tablespaceFileMap; // Will be used to overwrite filename of tablespace with given name

union MetaObjectValue
{
burp_pkg* package;
burp_rel* relation;
burp_prc* procedure;
burp_meta_obj* object;

MetaObjectValue(burp_pkg* value) : package(value) {}
MetaObjectValue(burp_rel* value) : relation(value) {}
MetaObjectValue(burp_prc* value) : procedure(value) {}
MetaObjectValue(burp_meta_obj* value) : object(value) {}
};

typedef Firebird::RightPooledPair<SSHORT, Firebird::QualifiedMetaString> MetaObjectKey;
typedef Firebird::LeftPooledMap<MetaObjectKey, MetaObjectValue> MetaDictionary;

MetaDictionary metaDictionary;

template <typename T>
void putToDictionary(SSHORT type, const Firebird::QualifiedMetaString& name, T* value)
{
fb_assert(name.hasData() && value != nullptr);
metaDictionary.put({type, name}, value);
}

burp_meta_obj* getMetaObject(SSHORT type, const Firebird::QualifiedMetaString& name) const
{
const auto result = metaDictionary.get({type, name});
return result ? result->object : nullptr;
}

burp_pkg* getPackage(const Firebird::QualifiedMetaString& name) const;
burp_rel* getRelation(const Firebird::QualifiedMetaString& name) const;
burp_prc* getProcedure(const Firebird::QualifiedMetaString& name) const;

public:
Firebird::string toSystem(const Firebird::PathName& from);

enum StatCounter { TIME_TOTAL = 0, TIME_DELTA, READS, WRITES, LAST_COUNTER};
Expand Down
Loading
Loading