diff --git a/src/alice/alice.cpp b/src/alice/alice.cpp index 06b1ce4357a..ad544e084ef 100644 --- a/src/alice/alice.cpp +++ b/src/alice/alice.cpp @@ -60,6 +60,9 @@ #include #endif +namespace Firebird::Alice +{ + using MsgFormat::SafeArg; @@ -90,7 +93,7 @@ constexpr int ALICE_MSG_FAC = FB_IMPL_MSG_FACILITY_GFIX; [[noreturn]] void ALICE_exit(int code, AliceGlobals* tdgbl) { tdgbl->exit_code = code; - Firebird::LongJump::raise(); + LongJump::raise(); } static void alice_output(bool error, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3); @@ -102,16 +105,16 @@ static void alice_output(bool error, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3); // Entry point for GFIX in case of service manager. // -int ALICE_main(Firebird::UtilSvc* uSvc) +int ALICE_main(UtilSvc* uSvc) { int exit_code = FINI_OK; try { exit_code = alice(uSvc); } - catch (const Firebird::Exception& e) + catch (const Exception& e) { - Firebird::StaticStatusVector status; + StaticStatusVector status; e.stuffException(status); uSvc->getStatusAccessor().setServiceStatus(status.begin()); uSvc->started(); @@ -127,7 +130,7 @@ int ALICE_main(Firebird::UtilSvc* uSvc) // Parse switches and do work // -int alice(Firebird::UtilSvc* uSvc) +int alice(UtilSvc* uSvc) { AliceGlobals gblInstance(uSvc); AliceGlobals* tdgbl = &gblInstance; @@ -579,16 +582,16 @@ int alice(Firebird::UtilSvc* uSvc) } // try - catch (const Firebird::LongJump&) + catch (const LongJump&) { // All "calls" to ALICE_exit(), normal and error exits, wind up here exit_code = tdgbl->exit_code; } - catch (const Firebird::Exception& e) + catch (const Exception& e) { // Non-alice exception was caught - Firebird::StaticStatusVector status; + StaticStatusVector status; e.stuffException(status); fb_utils::copyStatus(tdgbl->status_vector, ISC_STATUS_LENGTH, status.begin(), status.getCount()); ALICE_print_status(true, tdgbl->status_vector); @@ -607,7 +610,7 @@ int alice(Firebird::UtilSvc* uSvc) if ((exit_code != FINI_OK) && uSvc->isService() && (tdgbl->status[0] == 1) && (tdgbl->status[1] != 0)) { - Firebird::UtilSvc::StatusAccessor sa = uSvc->getStatusAccessor(); + UtilSvc::StatusAccessor sa = uSvc->getStatusAccessor(); sa.init(); uSvc->getStatusAccessor().setServiceStatus(tdgbl->status); } @@ -720,7 +723,7 @@ static void alice_output(bool error, const SCHAR* format, ...) va_list arglist; va_start(arglist, format); - Firebird::string buf; + string buf; buf.vprintf(format, arglist); va_end(arglist); @@ -729,3 +732,6 @@ static void alice_output(bool error, const SCHAR* format, ...) else tdgbl->uSvc->outputVerbose(buf.c_str()); } + + +} // namespace Firebird::Alice diff --git a/src/alice/alice.h b/src/alice/alice.h index f2527d6d64d..071d0f70934 100644 --- a/src/alice/alice.h +++ b/src/alice/alice.h @@ -33,6 +33,8 @@ #include "../common/classes/array.h" #include "../common/UtilSvc.h" +namespace Firebird::Alice { + enum val_errors { VAL_INVALID_DB_VERSION = 0, @@ -105,16 +107,16 @@ struct tdr : public pool_alloc { tdr* tdr_next; // next sub-transaction TraNumber tdr_id; // database-specific transaction id - Firebird::string tdr_fullpath; // full (possibly) remote pathname - Firebird::string tdr_filename; // filename - Firebird::string tdr_host_site; // host for transaction - Firebird::string tdr_remote_site; // site for remote transaction + string tdr_fullpath; // full (possibly) remote pathname + string tdr_filename; // filename + string tdr_host_site; // host for transaction + string tdr_remote_site; // site for remote transaction FB_API_HANDLE tdr_handle; // reconnected transaction handle FB_API_HANDLE tdr_db_handle; // re-attached database handle USHORT tdr_db_caps; // capabilities of database USHORT tdr_state; // see flags below - tdr(Firebird::MemoryPool& p) + tdr(MemoryPool& p) : tdr_fullpath(p), tdr_filename(p), tdr_host_site(p), tdr_remote_site(p) { } }; @@ -149,11 +151,11 @@ enum tdr_state_vals { // Global data -class AliceGlobals : public Firebird::ThreadData +class AliceGlobals : public ThreadData { private: MemoryPool* ALICE_default_pool; - friend class Firebird::SubsystemContextPoolHolder ; + friend class SubsystemContextPoolHolder ; void setDefaultPool(MemoryPool* p) { @@ -161,7 +163,7 @@ class AliceGlobals : public Firebird::ThreadData } public: - AliceGlobals(Firebird::UtilSvc* us) + AliceGlobals(UtilSvc* us) : ThreadData(ThreadData::tddALICE), ALICE_default_pool(0), exit_code(FINI_ERROR), // prevent FINI_OK in case of unknown error thrown @@ -184,7 +186,7 @@ class AliceGlobals : public Firebird::ThreadData user_action ALICE_data; ISC_STATUS_ARRAY status_vector; int exit_code; - Firebird::UtilSvc* uSvc; + UtilSvc* uSvc; FILE* output_file; isc_db_handle db_handle; isc_tr_handle tr_handle; @@ -206,7 +208,8 @@ class AliceGlobals : public Firebird::ThreadData } }; -typedef Firebird::SubsystemContextPoolHolder AliceContextPoolHolder; +typedef SubsystemContextPoolHolder AliceContextPoolHolder; -#endif // ALICE_ALICE_H +} // namespace Firebird::Alice +#endif // ALICE_ALICE_H diff --git a/src/alice/alice_meta.epp b/src/alice/alice_meta.epp index 321507c5224..4070728bde3 100644 --- a/src/alice/alice_meta.epp +++ b/src/alice/alice_meta.epp @@ -53,9 +53,11 @@ DATABASE DB = STATIC FILENAME "yachts.lnk"; #define DB tdgbl->db_handle #define gds_trans tdgbl->tr_handle -typedef Firebird::HalfStaticArray TextBuffer; +namespace Firebird::Alice { -static void get_string(const TEXT**, Firebird::string&); +typedef HalfStaticArray TextBuffer; + +static void get_string(const TEXT**, string&); static USHORT get_capabilities(ISC_STATUS*); static tdr* get_description(ISC_QUAD*); static void parse_fullpath(tdr*); @@ -81,7 +83,7 @@ static const rfr_tab_t rfr_table[] = static inline void return_error(const ISC_STATUS* /*user_status*/) { ALICE_print_status(true, gds_status); - Firebird::LongJump::raise(); + LongJump::raise(); } /*____________________________________________________________ @@ -243,7 +245,7 @@ void MET_set_capabilities(ISC_STATUS* user_status, tdr* trans) * Eat a string with a byte-encoded length. */ -static void get_string(const TEXT** ptr, Firebird::string& str) +static void get_string(const TEXT** ptr, string& str) { AliceGlobals* tdgbl = AliceGlobals::getSpecific(); @@ -316,11 +318,11 @@ static tdr* get_description(ISC_QUAD* blob_id) return NULL; tdr* trans = NULL; - Firebird::string host_site; - Firebird::string database_path; + string host_site; + string database_path; const TEXT* p = buffer.begin(); - Firebird::MemoryPool& pool(*tdgbl->getDefaultPool()); + MemoryPool& pool(*tdgbl->getDefaultPool()); // skip version number ++p; @@ -380,8 +382,8 @@ static tdr* get_description(ISC_QUAD* blob_id) static void parse_fullpath(tdr* trans) { - Firebird::PathName filename = trans->tdr_fullpath.c_str(); - Firebird::PathName hostname; + PathName filename = trans->tdr_fullpath.c_str(); + PathName hostname; // Find the last remote node in the path @@ -442,3 +444,5 @@ static bool snarf_blob(ISC_QUAD* blob_id, TextBuffer& buffer) return true; } + +} // namespace Firebird::Alice diff --git a/src/alice/alice_meta.h b/src/alice/alice_meta.h index fbd84b04a34..560552116fc 100644 --- a/src/alice/alice_meta.h +++ b/src/alice/alice_meta.h @@ -24,10 +24,13 @@ #ifndef ALICE_ALICE_META_H #define ALICE_ALICE_META_H +namespace Firebird::Alice { + void MET_disable_wal(ISC_STATUS*, isc_db_handle); void MET_get_state(ISC_STATUS*, tdr*); tdr* MET_get_transaction(ISC_STATUS*, isc_db_handle, TraNumber); void MET_set_capabilities(ISC_STATUS*, tdr*); -#endif // ALICE_ALICE_META_H +} // namespace Firebird::Alice +#endif // ALICE_ALICE_META_H diff --git a/src/alice/alice_proto.h b/src/alice/alice_proto.h index 3907a466850..a6c55149f4e 100644 --- a/src/alice/alice_proto.h +++ b/src/alice/alice_proto.h @@ -28,8 +28,12 @@ #include "../common/classes/MsgPrint.h" #include "../common/UtilSvc.h" -int ALICE_main(Firebird::UtilSvc*); -int alice(Firebird::UtilSvc*); +namespace Firebird::Alice +{ + + +int ALICE_main(UtilSvc*); +int alice(UtilSvc*); class AliceGlobals; @@ -39,4 +43,7 @@ void ALICE_print(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); void ALICE_print_status(bool error, const ISC_STATUS*); [[noreturn]] void ALICE_exit(int, AliceGlobals*); + +} // namespace Firebird::Alice + #endif // ALICE_ALICE_PROTO_H diff --git a/src/alice/aliceswi.h b/src/alice/aliceswi.h index 92b8f373d31..ae6d968630d 100644 --- a/src/alice/aliceswi.h +++ b/src/alice/aliceswi.h @@ -23,7 +23,11 @@ #define ALICE_ALICESWI_H #include "ibase.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Alice +{ + // switch definitions @@ -331,4 +335,7 @@ static inline constexpr const char* alice_repl_mode_sw_table[] = ALICE_SW_MODE_NONE, ALICE_SW_MODE_RO, ALICE_SW_MODE_RW }; + +} // namespace Firebird::Alice + #endif // ALICE_ALICESWI_H diff --git a/src/alice/exe.cpp b/src/alice/exe.cpp index 6592c9c9545..57294f832ba 100644 --- a/src/alice/exe.cpp +++ b/src/alice/exe.cpp @@ -44,11 +44,14 @@ #include "../alice/alice_meta.h" #include "../alice/tdr_proto.h" #include "../yvalve/gds_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/ClumpletWriter.h" +namespace Firebird::Alice +{ + -static void buildDpb(Firebird::ClumpletWriter&, const SINT64); +static void buildDpb(ClumpletWriter&, const SINT64); static void extract_db_info(const UCHAR*, size_t); // Keep always in sync with function extract_db_info() @@ -73,7 +76,7 @@ int EXE_action(const TEXT* database, const SINT64 switches) bool error = false; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); { - Firebird::AutoMemoryPool newPool(MemoryPool::createPool()); + AutoMemoryPool newPool(MemoryPool::createPool()); AliceContextPoolHolder context(tdgbl, newPool); for (USHORT i = 0; i < MAX_VAL_ERRORS; i++) @@ -83,7 +86,7 @@ int EXE_action(const TEXT* database, const SINT64 switches) // generate the database parameter block for the attach, // based on the various switches - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::Tagged, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::Tagged, MAX_DPB_SIZE); buildDpb(dpb, switches); FB_API_HANDLE handle = 0; @@ -110,8 +113,8 @@ int EXE_action(const TEXT* database, const SINT64 switches) if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) { isc_database_info(tdgbl->status, &handle, sizeof(val_errors), - val_errors, sizeof(error_string), - reinterpret_cast(error_string)); + val_errors, sizeof(error_string), + reinterpret_cast(error_string)); extract_db_info(error_string, sizeof(error_string)); } @@ -145,7 +148,7 @@ int EXE_two_phase(const TEXT* database, const SINT64 switches) bool error = false; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); { - Firebird::AutoMemoryPool newPool(MemoryPool::createPool()); + AutoMemoryPool newPool(MemoryPool::createPool()); AliceContextPoolHolder context(tdgbl, newPool); for (USHORT i = 0; i < MAX_VAL_ERRORS; i++) @@ -155,7 +158,7 @@ int EXE_two_phase(const TEXT* database, const SINT64 switches) // generate the database parameter block for the attach, // based on the various switches - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::Tagged, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::Tagged, MAX_DPB_SIZE); buildDpb(dpb, switches); FB_API_HANDLE handle = 0; @@ -198,7 +201,7 @@ int EXE_two_phase(const TEXT* database, const SINT64 switches) // based on the various switches // -static void buildDpb(Firebird::ClumpletWriter& dpb, const SINT64 switches) +static void buildDpb(ClumpletWriter& dpb, const SINT64 switches) { AliceGlobals* tdgbl = AliceGlobals::getSpecific(); dpb.reset(isc_dpb_version1); @@ -483,3 +486,6 @@ static void extract_db_info(const UCHAR* db_info_buffer, size_t buf_size) p += length; } } + + +} // namespace Firebird::Alice diff --git a/src/alice/exe_proto.h b/src/alice/exe_proto.h index 6cbe6aa2306..17906bf4494 100644 --- a/src/alice/exe_proto.h +++ b/src/alice/exe_proto.h @@ -24,7 +24,11 @@ #ifndef ALICE_EXE_PROTO_H #define ALICE_EXE_PROTO_H +namespace Firebird::Alice { + int EXE_action(const TEXT*, const SINT64); int EXE_two_phase(const TEXT*, const SINT64); +} // namespace Firebird::Alice + #endif // ALICE_EXE_PROTO_H diff --git a/src/alice/main/aliceMain.cpp b/src/alice/main/aliceMain.cpp index 68268e31191..c6fa9166bd8 100644 --- a/src/alice/main/aliceMain.cpp +++ b/src/alice/main/aliceMain.cpp @@ -53,6 +53,8 @@ int CLIB_ROUTINE main(int argc, char* argv[]) * Invoke real gfix main function * **************************************/ + using namespace Firebird; + #ifdef HAVE_LOCALE_H // Pick up the system locale to allow SYSTEM<->UTF8 conversions setlocale(LC_CTYPE, ""); @@ -61,14 +63,14 @@ int CLIB_ROUTINE main(int argc, char* argv[]) try { - Firebird::AutoPtr uSvc(Firebird::UtilSvc::createStandalone(argc, argv)); - return alice(uSvc); - } - catch (const Firebird::Exception& ex) - { - Firebird::StaticStatusVector st; - ex.stuffException(st); - isc_print_status(st.begin()); - } - return 1; + AutoPtr uSvc(UtilSvc::createStandalone(argc, argv)); + return Alice::alice(uSvc); + } + catch (const Exception& ex) + { + StaticStatusVector st; + ex.stuffException(st); + isc_print_status(st.begin()); + } + return 1; } diff --git a/src/alice/tdr.cpp b/src/alice/tdr.cpp index c8dc9b4d31c..963577c4daf 100644 --- a/src/alice/tdr.cpp +++ b/src/alice/tdr.cpp @@ -44,9 +44,12 @@ #include "../alice/tdr_proto.h" #include "../yvalve/gds_proto.h" #include "../common/isc_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/ClumpletWriter.h" +namespace Firebird::Alice +{ + using MsgFormat::SafeArg; @@ -185,7 +188,7 @@ bool TDR_attach_database(ISC_STATUS* status_vector, tdr* trans, const TEXT* path if (tdgbl->ALICE_data.ua_debug) ALICE_print(68, SafeArg() << pathname); // msg 68: ATTACH_DATABASE: attempted attach of %s - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); dpb.insertTag(isc_dpb_no_garbage_collect); dpb.insertTag(isc_dpb_gfix_attach); tdgbl->uSvc->fillDpb(dpb); @@ -289,7 +292,7 @@ void TDR_list_limbo(FB_API_HANDLE handle, const TEXT* name, const SINT64 switche TraNumber id; tdr* trans; - for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); + for (ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) { const UCHAR item = p.getClumpTag(); @@ -687,7 +690,7 @@ static void reattach_database(tdr* trans) if (trans->tdr_fullpath.hasData()) { - Firebird::string hostname; + string hostname; ISC_get_host(hostname); // if this is being run from the same host, @@ -703,7 +706,7 @@ static void reattach_database(tdr* trans) // try going through the previous host with all available // protocols, using chaining to try the same method of // attachment originally used from that host - const Firebird::string pathname = trans->tdr_host_site + ':' + trans->tdr_fullpath; + const string pathname = trans->tdr_host_site + ':' + trans->tdr_fullpath; if (TDR_attach_database(status_vector, trans, pathname.c_str())) return; } @@ -713,7 +716,7 @@ static void reattach_database(tdr* trans) if (trans->tdr_remote_site.hasData()) { - const Firebird::string pathname = trans->tdr_remote_site + ':' + trans->tdr_filename; + const string pathname = trans->tdr_remote_site + ':' + trans->tdr_filename; if (TDR_attach_database(status_vector, trans, pathname.c_str())) return; } @@ -830,3 +833,6 @@ static bool reconnect(FB_API_HANDLE handle, TraNumber number, const TEXT* name, return false; } + + +} // namespace Firebird::Alice diff --git a/src/alice/tdr_proto.h b/src/alice/tdr_proto.h index bcedfa7513d..067b16b55fb 100644 --- a/src/alice/tdr_proto.h +++ b/src/alice/tdr_proto.h @@ -24,6 +24,8 @@ #ifndef ALICE_TDR_PROTO_H #define ALICE_TDR_PROTO_H +namespace Firebird::Alice { + void TDR_list_limbo(FB_API_HANDLE, const TEXT*, const SINT64); bool TDR_reconnect_multiple(FB_API_HANDLE, TraNumber, const TEXT*, SINT64); void TDR_shutdown_databases(tdr*); @@ -31,5 +33,6 @@ USHORT TDR_analyze(const tdr*); bool TDR_attach_database(ISC_STATUS*, tdr*, const TEXT*); void TDR_get_states(tdr*); -#endif // ALICE_TDR_PROTO_H +} // namespace Firebird::Alice +#endif // ALICE_TDR_PROTO_H diff --git a/src/auth/AuthDbg.cpp b/src/auth/AuthDbg.cpp index 386f9f5e231..e95d59a5875 100644 --- a/src/auth/AuthDbg.cpp +++ b/src/auth/AuthDbg.cpp @@ -32,38 +32,42 @@ #ifdef AUTH_DEBUG +namespace Firebird::Auth +{ + + //#define AUTH_VERBOSE // register plugin -static Firebird::SimpleFactory clientFactory; -static Firebird::SimpleFactory serverFactory; +static SimpleFactory clientFactory; +static SimpleFactory serverFactory; -extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { - Firebird::CachedMasterInterface::set(master); + using namespace Firebird; + + CachedMasterInterface::set(master); const char* name = "Auth_Debug"; - Firebird::PluginManagerInterfacePtr iPlugin; + PluginManagerInterfacePtr iPlugin; - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_CLIENT, name, &clientFactory); - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_SERVER, name, &serverFactory); + iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_CLIENT, name, &clientFactory); + iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_SERVER, name, &serverFactory); } -namespace Auth { - -DebugServer::DebugServer(Firebird::IPluginConfig* pConf) +DebugServer::DebugServer(IPluginConfig* pConf) : str(getPool()) { - Firebird::LocalStatus ls; - Firebird::CheckStatusWrapper s(&ls); + LocalStatus ls; + CheckStatusWrapper s(&ls); config.assignRefNoIncr(pConf->getDefaultConfig(&s)); check(&s); } -int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IServerBlock* sb, - Firebird::IWriter* writerInterface) +int DebugServer::authenticate(CheckStatusWrapper* status, IServerBlock* sb, + IWriter* writerInterface) { try { @@ -85,7 +89,7 @@ int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IS fprintf(stderr, "DebugServer::authenticate1: %s\n", str.c_str()); #endif sb->putData(status, str.length(), str.c_str()); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { return AUTH_FAILED; } @@ -97,13 +101,13 @@ int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IS #ifdef AUTH_VERBOSE fprintf(stderr, "DebugServer::authenticate2: %s\n", str.c_str()); #endif - Firebird::LocalStatus ls; - Firebird::CheckStatusWrapper s(&ls); + LocalStatus ls; + CheckStatusWrapper s(&ls); writerInterface->add(&s, str.c_str()); check(&s); str.erase(); - Firebird::RefPtr group(Firebird::REF_NO_INCR, config->find(&s, "GROUP")); + RefPtr group(REF_NO_INCR, config->find(&s, "GROUP")); check(&s); if (group) { @@ -113,7 +117,7 @@ int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IS check(&s); } - Firebird::RefPtr multi(Firebird::REF_NO_INCR, config->find(&s, "MULTIGROUPS")); + RefPtr multi(REF_NO_INCR, config->find(&s, "MULTIGROUPS")); check(&s); if (multi) { @@ -123,17 +127,17 @@ int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IS for (int n = 0; n < limit; ++n) { writerInterface->add(status, grName); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return AUTH_FAILED; writerInterface->setType(status, "Group"); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return AUTH_FAILED; } } return AUTH_SUCCESS; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -141,14 +145,14 @@ int DebugServer::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IS return AUTH_FAILED; } -void DebugServer::setDbCryptCallback(Firebird::CheckStatusWrapper*, Firebird::ICryptKeyCallback*) +void DebugServer::setDbCryptCallback(CheckStatusWrapper*, ICryptKeyCallback*) { /* ignore it */ } -DebugClient::DebugClient(Firebird::IPluginConfig*) +DebugClient::DebugClient(IPluginConfig*) : str(getPool()) { } -int DebugClient::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IClientBlock* cb) +int DebugClient::authenticate(CheckStatusWrapper* status, IClientBlock* cb) { try { @@ -183,7 +187,7 @@ int DebugClient::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IC fprintf(stderr, "DebugClient::authenticate: sending %s\n", str.c_str()); #endif cb->putData(status, str.length(), str.c_str()); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { return AUTH_FAILED; } @@ -193,7 +197,7 @@ int DebugClient::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IC #endif return AUTH_SUCCESS; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -201,6 +205,7 @@ int DebugClient::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IC return AUTH_FAILED; } -} // namespace Auth + +} // namespace Firebird::Auth #endif // AUTH_DEBUG diff --git a/src/auth/AuthDbg.h b/src/auth/AuthDbg.h index b556bd537fb..1c3a1cb4beb 100644 --- a/src/auth/AuthDbg.h +++ b/src/auth/AuthDbg.h @@ -41,39 +41,42 @@ #include "../common/classes/array.h" #include "../common/classes/fb_string.h" -namespace Auth { +namespace Firebird::Auth +{ + // The idea of debug plugin is to send some data from server to client, // modify them on client and return result (which becomes login name) to the server class DebugServer final : - public Firebird::StdPlugin > + public StdPlugin> { public: - explicit DebugServer(Firebird::IPluginConfig*); + explicit DebugServer(IPluginConfig*); - int authenticate(Firebird::CheckStatusWrapper* status, Firebird::IServerBlock* sBlock, - Firebird::IWriter* writerInterface); - void setDbCryptCallback(Firebird::CheckStatusWrapper*, Firebird::ICryptKeyCallback*); + int authenticate(CheckStatusWrapper* status, IServerBlock* sBlock, + IWriter* writerInterface); + void setDbCryptCallback(CheckStatusWrapper*, ICryptKeyCallback*); private: - Firebird::string str; - Firebird::RefPtr config; + string str; + RefPtr config; }; class DebugClient final : - public Firebird::StdPlugin > + public StdPlugin> { public: - DebugClient(Firebird::IPluginConfig*); + DebugClient(IPluginConfig*); - int authenticate(Firebird::CheckStatusWrapper* status, Firebird::IClientBlock* sBlock); + int authenticate(CheckStatusWrapper* status, IClientBlock* sBlock); private: - Firebird::string str; + string str; }; -} // namespace Auth + +} // namespace Firebird::Auth #endif // AUTH_DEBUG diff --git a/src/auth/SecDbCache.cpp b/src/auth/SecDbCache.cpp index 601790bdba9..6a21488a1e0 100644 --- a/src/auth/SecDbCache.cpp +++ b/src/auth/SecDbCache.cpp @@ -32,10 +32,9 @@ #include +namespace Firebird::Auth +{ -using namespace Firebird; - -namespace Auth { void CachedSecurityDatabase::close() { @@ -163,4 +162,5 @@ void PluginDatabases::handler(CachedSecurityDatabase* tgt) } } -} // namespace Auth + +} // namespace Firebird::Auth diff --git a/src/auth/SecDbCache.h b/src/auth/SecDbCache.h index 1937e4a7ca9..6920a1f54ab 100644 --- a/src/auth/SecDbCache.h +++ b/src/auth/SecDbCache.h @@ -35,7 +35,9 @@ #include "../common/classes/auto.h" -namespace Auth { +namespace Firebird::Auth +{ + class VSecDb { @@ -56,12 +58,12 @@ class VSecDb class PluginDatabases; class CachedSecurityDatabase final - : public Firebird::RefCntIface > + : public RefCntIface> { public: char secureDbName[MAXPATHLEN + 1]; - CachedSecurityDatabase(PluginDatabases* l, const Firebird::PathName& nm) + CachedSecurityDatabase(PluginDatabases* l, const PathName& nm) : secDb(nullptr), list(l) { nm.copyTo(secureDbName, sizeof secureDbName); @@ -71,13 +73,13 @@ class CachedSecurityDatabase final void handler(); void close(); - Firebird::Mutex mutex; - Firebird::AutoPtr secDb; + Mutex mutex; + AutoPtr secDb; PluginDatabases* list; public: // Related RAII holder - class Instance : public Firebird::RefPtr + class Instance : public RefPtr { public: Instance() @@ -121,15 +123,16 @@ class PluginDatabases { } private: - Firebird::HalfStaticArray dbArray; - Firebird::Mutex arrayMutex; + HalfStaticArray dbArray; + Mutex arrayMutex; public: - void getInstance(Firebird::IPluginConfig* pluginConfig, CachedSecurityDatabase::Instance& instance); + void getInstance(IPluginConfig* pluginConfig, CachedSecurityDatabase::Instance& instance); int shutdown(); void handler(CachedSecurityDatabase* tgt); }; -} // namespace Auth + +} // namespace Firebird::Auth #endif // FB_SECDBCACHE_H diff --git a/src/auth/SecureRemotePassword/Message.h b/src/auth/SecureRemotePassword/Message.h index 2d994473118..c703e1eb0ad 100644 --- a/src/auth/SecureRemotePassword/Message.h +++ b/src/auth/SecureRemotePassword/Message.h @@ -19,19 +19,25 @@ #endif // INTERNAL_FIREBIRD + +// FIXME: Move this file outside of Auth. It's not directly related to Auth. +namespace Firebird +{ + + #ifdef INTERNAL_FIREBIRD // This class helps to work with metadata iface -class Meta : public Firebird::RefPtr +class Meta : public RefPtr { public: - Meta(Firebird::IStatement* stmt, bool out) + Meta(IStatement* stmt, bool out) { - Firebird::LocalStatus ls; - Firebird::CheckStatusWrapper st(&ls); - Firebird::IMessageMetadata* m = out ? stmt->getOutputMetadata(&st) : stmt->getInputMetadata(&st); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + LocalStatus ls; + CheckStatusWrapper st(&ls); + IMessageMetadata* m = out ? stmt->getOutputMetadata(&st) : stmt->getInputMetadata(&st); + if (st.getState() & IStatus::STATE_ERRORS) { - Firebird::status_exception::raise(&st); + status_exception::raise(&st); } assignRefNoIncr(m); } @@ -55,7 +61,7 @@ class Message // : public AutoStorage { public: - Message(Firebird::IMessageMetadata* aMeta = NULL) + Message(IMessageMetadata* aMeta = NULL) #ifdef INTERNAL_FIREBIRD : s(&st), #else @@ -78,9 +84,9 @@ class Message } else { - Firebird::IMetadataBuilder* bld = + IMetadataBuilder* bld = #ifdef INTERNAL_FIREBIRD - Firebird::MasterInterfacePtr()-> + MasterInterfacePtr()-> #else fb_get_master_interface()-> #endif @@ -131,7 +137,7 @@ class Message if (fieldCount >= l) { #ifdef INTERNAL_FIREBIRD - (Firebird::Arg::Gds(isc_random) << + (Arg::Gds(isc_random) << "Attempt to add to the message more variables than possible").raise(); #else fatalErrorHandler("Attempt to add to the message more variables than possible"); @@ -145,7 +151,7 @@ class Message if (!checkType(t, sz)) { #ifdef INTERNAL_FIREBIRD - (Firebird::Arg::Gds(isc_random) << "Incompatible data type").raise(); + (Arg::Gds(isc_random) << "Incompatible data type").raise(); #else fatalErrorHandler("Incompatible data type"); #endif @@ -173,12 +179,12 @@ class Message return fieldCount++; } - static void check(Firebird::IStatus* status) + static void check(IStatus* status) { - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { #ifdef INTERNAL_FIREBIRD - Firebird::status_exception::raise(status); + status_exception::raise(status); #else char msg[100]; const ISC_STATUS* st = status->getErrors(); @@ -191,12 +197,12 @@ class Message // Attention! // No addRef/release interface here! // Lifetime is equal at least to Message lifetime - Firebird::IMessageMetadata* getMetadata() + IMessageMetadata* getMetadata() { if (!metadata) { fb_assert(builder); - Firebird::IMessageMetadata* aMeta = builder->getMetadata(&statusWrapper); + IMessageMetadata* aMeta = builder->getMetadata(&statusWrapper); check(&statusWrapper); metadata = aMeta; builder->release(); @@ -230,7 +236,7 @@ class Message } private: - void createBuffer(Firebird::IMessageMetadata* aMeta) + void createBuffer(IMessageMetadata* aMeta) { unsigned l = aMeta->getMessageLength(&statusWrapper); check(&statusWrapper); @@ -238,20 +244,20 @@ class Message } public: - Firebird::IStatus* s; + IStatus* s; private: - Firebird::IMessageMetadata* metadata; + IMessageMetadata* metadata; unsigned char* buffer; - Firebird::IMetadataBuilder* builder; + IMetadataBuilder* builder; unsigned fieldCount; FieldLink* fieldList; #ifdef INTERNAL_FIREBIRD - Firebird::LocalStatus st; + LocalStatus st; #endif public: - Firebird::CheckStatusWrapper statusWrapper; + CheckStatusWrapper statusWrapper; }; @@ -545,3 +551,6 @@ inline unsigned Message::getType(unsigned& sz) sz = sizeof(FB_BOOLEAN); return SQL_BOOLEAN; } + + +} // namespace Firebird diff --git a/src/auth/SecureRemotePassword/client/SrpClient.cpp b/src/auth/SecureRemotePassword/client/SrpClient.cpp index e019a636dac..81ce27a006a 100644 --- a/src/auth/SecureRemotePassword/client/SrpClient.cpp +++ b/src/auth/SecureRemotePassword/client/SrpClient.cpp @@ -30,11 +30,11 @@ #include "../auth/SecureRemotePassword/srp.h" #include "../common/classes/ImplementHelper.h" -using namespace Firebird; +namespace Firebird::Auth +{ -namespace Auth { -class SrpClient : public StdPlugin > +class SrpClient : public StdPlugin> { public: explicit SrpClient(IPluginConfig*) @@ -195,4 +195,5 @@ void registerSrpClient(IPluginManager* iPlugin) iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_CLIENT, RemotePassword::pluginName(512).c_str(), &factory_sha512); } -} // namespace Auth + +} // namespace Firebird::Auth diff --git a/src/auth/SecureRemotePassword/client/SrpClient.h b/src/auth/SecureRemotePassword/client/SrpClient.h index 767d602c823..b2f494b06ab 100644 --- a/src/auth/SecureRemotePassword/client/SrpClient.h +++ b/src/auth/SecureRemotePassword/client/SrpClient.h @@ -29,10 +29,9 @@ #include "firebird/Interface.h" -namespace Auth { - -void registerSrpClient(Firebird::IPluginManager* iPlugin); - -} // namespace Auth +namespace Firebird::Auth +{ + void registerSrpClient(IPluginManager* iPlugin); +} // namespace Firebird::Auth #endif // AUTH_SRP_CLIENT_H diff --git a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp index 54df74eb26e..5f60a9282ed 100644 --- a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp +++ b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp @@ -33,33 +33,34 @@ #include "../common/StatusHolder.h" #include "firebird/Interface.h" #include "../auth/SecureRemotePassword/srp.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "firebird/impl/inf_pub.h" #include "../utilities/gsec/gsec.h" #include "../auth/SecureRemotePassword/Message.h" #include "../common/classes/auto.h" #include "../common/classes/ParsedList.h" -namespace { +namespace Firebird::Auth +{ -typedef Field Varfield; -typedef Field Blob; -typedef Field Boolean; -Firebird::GlobalPtr keys; +namespace +{ + typedef Field Varfield; + typedef Field Blob; + typedef Field Boolean; + GlobalPtr keys; } // anonymous namespace -namespace Auth { - -class SrpManagement final : public Firebird::StdPlugin > +class SrpManagement final : public StdPlugin> { public: - explicit SrpManagement(Firebird::IPluginConfig* par) + explicit SrpManagement(IPluginConfig* par) : curAtt(nullptr), mainTra(nullptr), grAdminTra(nullptr) { - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); config.assignRefNoIncr(par->getFirebirdConf(&statusWrapper)); check(&statusWrapper); } @@ -98,9 +99,9 @@ class SrpManagement final : public Firebird::StdPluginstartTransaction(&statusWrapper, 0, NULL)); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); + ITransaction* ddlTran(curAtt->startTransaction(&statusWrapper, 0, NULL)); check(&statusWrapper); try @@ -124,7 +125,7 @@ class SrpManagement final : public Firebird::StdPlugincommit(&statusWrapper); check(&statusWrapper); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (ddlTran) { @@ -134,7 +135,7 @@ class SrpManagement final : public Firebird::StdPluginadmin()->entered()) { return; } - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); - Firebird::string userName(user->userName()->get()); + string userName(user->userName()->get()); prepareName(userName, '"'); - Firebird::string sql; + string sql; if (user->admin()->get() == 0) { - Firebird::string userName2(user->userName()->get()); + string userName2(user->userName()->get()); prepareName(userName2, '\''); - Firebird::string selGrantor; + string selGrantor; selGrantor.printf("SELECT RDB$GRANTOR FROM SYSTEM.RDB$USER_PRIVILEGES " "WHERE RDB$USER = '%s' AND RDB$RELATION_NAME = '%s' AND RDB$PRIVILEGE = 'M'", userName2.c_str(), ADMIN_ROLE); Message out; Field grantor(out, MAX_SQL_IDENTIFIER_SIZE); - Firebird::IResultSet* curs = curAtt->openCursor(&statusWrapper, grAdminTra, selGrantor.length(), + IResultSet* curs = curAtt->openCursor(&statusWrapper, grAdminTra, selGrantor.length(), selGrantor.c_str(), SQL_DIALECT_V6, NULL, NULL, out.getMetadata(), NULL, 0); check(&statusWrapper); - const bool hasGrant = curs->fetchNext(&statusWrapper, out.getBuffer()) == Firebird::IStatus::RESULT_OK; + const bool hasGrant = curs->fetchNext(&statusWrapper, out.getBuffer()) == IStatus::RESULT_OK; curs->close(&statusWrapper); check(&statusWrapper); @@ -204,7 +205,7 @@ class SrpManagement final : public Firebird::StdPlugininit(); @@ -241,19 +241,19 @@ class SrpManagement final : public Firebird::StdPlugingetKey(config, "SecurityDatabase"); const char* secDbName = config->asString(secDbKey); if (!(secDbName && secDbName[0])) { - Firebird::Arg::Gds(isc_secdb_name).raise(); + Arg::Gds(isc_secdb_name).raise(); } - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); dpb.insertByte(isc_dpb_sec_attach, TRUE); - dpb.insertString(isc_dpb_config, Firebird::ParsedList::getNonLoopbackProviders(secDbName)); + dpb.insertString(isc_dpb_config, ParsedList::getNonLoopbackProviders(secDbName)); unsigned int authBlockSize; const unsigned char* authBlock = logonInfo->authBlock(&authBlockSize); @@ -279,7 +279,7 @@ class SrpManagement final : public Firebird::StdPluginattachDatabase(status, secDbName, dpb.getBufferLength(), dpb.getBuffer()); check(status); ownAtt.reset(curAtt); @@ -287,13 +287,13 @@ class SrpManagement final : public Firebird::StdPluginattachment(status); + IAttachment* att = logonInfo->attachment(status); // ID of passed attachment - Firebird::UCharBuffer actualId; + UCharBuffer actualId; if (att && getUid(status, att, actualId)) { if (actualId == reqId) @@ -321,7 +321,7 @@ class SrpManagement final : public Firebird::StdPluginoperation()) { - case Firebird::IUser::OP_USER_DROP_MAP: - case Firebird::IUser::OP_USER_SET_MAP: + case IUser::OP_USER_DROP_MAP: + case IUser::OP_USER_SET_MAP: { - Firebird::string sql; + string sql; sql.printf("ALTER ROLE " ADMIN_ROLE " %s AUTO ADMIN MAPPING", - user->operation() == Firebird::IUser::OP_USER_SET_MAP ? "SET" : "DROP"); + user->operation() == IUser::OP_USER_SET_MAP ? "SET" : "DROP"); curAtt->execute(status, grAdminTra, sql.length(), sql.c_str(), SQL_DIALECT_V6, NULL, NULL, NULL, NULL); check(status); } break; - case Firebird::IUser::OP_USER_ADD: + case IUser::OP_USER_ADD: { const char* insert = "INSERT INTO plg$srp.plg$srp_view(PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST," "PLG$COMMENT, PLG$ATTRIBUTES, PLG$ACTIVE) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"; - Firebird::IStatement* stmt = NULL; + IStatement* stmt = NULL; try { for (unsigned repeat = 0; ; ++repeat) { - stmt = curAtt->prepare(status, mainTra, 0, insert, SQL_DIALECT_V6, Firebird::IStatement::PREPARE_PREFETCH_METADATA); - if (!(status->getState() & Firebird::IStatus::STATE_ERRORS)) + stmt = curAtt->prepare(status, mainTra, 0, insert, SQL_DIALECT_V6, IStatement::PREPARE_PREFETCH_METADATA); + if (!(status->getState() & IStatus::STATE_ERRORS)) { break; } else if (repeat > 0) { - Firebird::status_exception::raise(status); + status_exception::raise(status); } if (fb_utils::containsErrorCode(status->getErrors(), isc_dsql_relation_err)) @@ -419,12 +419,12 @@ class SrpManagement final : public Firebird::StdPluginactive()); #if SRP_DEBUG > 1 - Firebird::BigInteger salt("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); + BigInteger salt("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); #else - Firebird::BigInteger salt; + BigInteger salt; salt.random(RemotePassword::SRP_SALT_SIZE); #endif - Firebird::UCharBuffer s; + UCharBuffer s; salt.getBytes(s); slt.set(s.getCount(), s.begin()); @@ -432,7 +432,7 @@ class SrpManagement final : public Firebird::StdPlugin 0 fprintf(stderr, ">%s< >%s<\n", user->userName()->get(), user->password()->get()); #endif - Firebird::string s1; + string s1; salt.getText(s1); server.computeVerifier(user->userName()->get(), s1, user->password()->get()).getBytes(s); dumpIt("verifier", s); @@ -446,7 +446,7 @@ class SrpManagement final : public Firebird::StdPlugin verifier, slt; + AutoPtr verifier, slt; if (user->password()->entered()) { update += "PLG$VERIFIER=?,PLG$SALT=?,"; } - Firebird::AutoPtr first, middle, last; - Firebird::AutoPtr comment, attr; - Firebird::AutoPtr active; + AutoPtr first, middle, last; + AutoPtr comment, attr; + AutoPtr active; allocField(user->firstName(), update, "PLG$FIRST"); allocField(user->middleName(), update, "PLG$MIDDLE"); allocField(user->lastName(), update, "PLG$LAST"); @@ -485,10 +485,10 @@ class SrpManagement final : public Firebird::StdPluginprepare(status, mainTra, 0, update.c_str(), SQL_DIALECT_V6, Firebird::IStatement::PREPARE_PREFETCH_METADATA); + stmt = curAtt->prepare(status, mainTra, 0, update.c_str(), SQL_DIALECT_V6, IStatement::PREPARE_PREFETCH_METADATA); check(status); Meta im(stmt, false); @@ -499,12 +499,12 @@ class SrpManagement final : public Firebird::StdPlugin 1 - Firebird::BigInteger salt("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); + BigInteger salt("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); #else - Firebird::BigInteger salt; + BigInteger salt; salt.random(RemotePassword::SRP_SALT_SIZE); #endif - Firebird::UCharBuffer s; + UCharBuffer s; salt.getBytes(s); slt->set(s.getCount(), s.begin()); @@ -512,7 +512,7 @@ class SrpManagement final : public Firebird::StdPlugin 0 fprintf(stderr, ">%s< >%s<\n", user->userName()->get(), user->password()->get()); #endif - Firebird::string s1; + string s1; salt.getText(s1); server.computeVerifier(user->userName()->get(), s1, user->password()->get()).getBytes(s); dumpIt("verifier", s); @@ -541,7 +541,7 @@ class SrpManagement final : public Firebird::StdPluginrelease(); - return GsecMsg22; + return Gsec::GsecMsg22; } stmt->free(status); @@ -549,7 +549,7 @@ class SrpManagement final : public Firebird::StdPluginprepare(status, mainTra, 0, del, SQL_DIALECT_V6, Firebird::IStatement::PREPARE_PREFETCH_METADATA); + stmt = curAtt->prepare(status, mainTra, 0, del, SQL_DIALECT_V6, IStatement::PREPARE_PREFETCH_METADATA); check(status); Meta im(stmt, false); @@ -579,7 +579,7 @@ class SrpManagement final : public Firebird::StdPluginrelease(); - return GsecMsg22; + return Gsec::GsecMsg22; } stmt->free(status); @@ -591,7 +591,7 @@ class SrpManagement final : public Firebird::StdPluginprepare(status, mainTra, 0, disp.c_str(), SQL_DIALECT_V6, - Firebird::IStatement::PREPARE_PREFETCH_METADATA); + IStatement::PREPARE_PREFETCH_METADATA); check(status); Meta om(stmt, true); @@ -645,7 +645,7 @@ class SrpManagement final : public Firebird::StdPlugingetBuffer() : NULL), om, 0); check(status); - while (rs->fetchNext(status, di.getBuffer()) == Firebird::IStatus::RESULT_OK) + while (rs->fetchNext(status, di.getBuffer()) == IStatus::RESULT_OK) { listField(user->userName(), login); listField(user->firstName(), first); @@ -667,7 +667,7 @@ class SrpManagement final : public Firebird::StdPluginfree(status); check(status); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (stmt) { @@ -682,7 +682,7 @@ class SrpManagement final : public Firebird::StdPlugincommit(status); - if (!(status->getState() & Firebird::IStatus::STATE_ERRORS)) + if (!(status->getState() & IStatus::STATE_ERRORS)) { ownTra.release(); } } } - void rollback(Firebird::CheckStatusWrapper* status) + void rollback(CheckStatusWrapper* status) { if (ownTra) { ownTra->rollback(status); - if (!(status->getState() & Firebird::IStatus::STATE_ERRORS)) + if (!(status->getState() & IStatus::STATE_ERRORS)) { ownTra.release(); } @@ -716,20 +716,20 @@ class SrpManagement final : public Firebird::StdPlugin config; + RefPtr config; // attachment(s) - Firebird::AutoRelease ownAtt; - Firebird::IAttachment* curAtt; + AutoRelease ownAtt; + IAttachment* curAtt; // transactions - Firebird::AutoRelease ownTra; - Firebird::ITransaction* mainTra; - Firebird::ITransaction* grAdminTra; + AutoRelease ownTra; + ITransaction* mainTra; + ITransaction* grAdminTra; - RemotePasswordImpl server; + RemotePasswordImpl server; - int recordsCount(Firebird::CheckStatusWrapper* status, Firebird::IStatement* stmt, UCHAR item) + int recordsCount(CheckStatusWrapper* status, IStatement* stmt, UCHAR item) { UCHAR buffer[33]; const UCHAR count_info[] = { isc_info_sql_records }; @@ -753,16 +753,16 @@ class SrpManagement final : public Firebird::StdPlugingetState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { checkStatusVectorForMissingTable(status->getErrors()); - Firebird::status_exception::raise(status); + status_exception::raise(status); } } - static void setField(Varfield& to, Firebird::ICharUserField* from) + static void setField(Varfield& to, ICharUserField* from) { if (from->entered()) { @@ -774,7 +774,7 @@ class SrpManagement final : public Firebird::StdPluginentered()) { @@ -786,7 +786,7 @@ class SrpManagement final : public Firebird::StdPluginentered()) { @@ -798,7 +798,7 @@ class SrpManagement final : public Firebird::StdPluginentered() || value->specified()) { @@ -809,7 +809,7 @@ class SrpManagement final : public Firebird::StdPlugin - static void allocField(Firebird::AutoPtr& field, Message& up, Firebird::IUserField* value) + static void allocField(AutoPtr& field, Message& up, IUserField* value) { if (value->entered() || value->specified()) { @@ -817,7 +817,7 @@ class SrpManagement final : public Firebird::StdPlugin& field, Firebird::ICharUserField* name) + static void assignField(AutoPtr& field, ICharUserField* name) { if (field.hasData()) { @@ -833,7 +833,7 @@ class SrpManagement final : public Firebird::StdPlugin& field, Firebird::IIntUserField* name) + static void assignField(AutoPtr& field, IIntUserField* name) { if (field.hasData()) { @@ -849,7 +849,7 @@ class SrpManagement final : public Firebird::StdPlugin& field, Firebird::ICharUserField* name) + void assignField(CheckStatusWrapper* st, AutoPtr& field, ICharUserField* name) { if (field.hasData()) { @@ -866,10 +866,10 @@ class SrpManagement final : public Firebird::StdPluginsetEntered(&statusWrapper, from.null ? 0 : 1); check(&statusWrapper); if (!from.null) @@ -879,10 +879,10 @@ class SrpManagement final : public Firebird::StdPluginsetEntered(&statusWrapper, from.null ? 0 : 1); check(&statusWrapper); if (!from.null) @@ -892,16 +892,16 @@ class SrpManagement final : public Firebird::StdPluginsetEntered(&statusWrapper, from.null ? 0 : 1); check(&statusWrapper); if (!from.null) { - Firebird::string s; - Firebird::IBlob* blob = NULL; + string s; + IBlob* blob = NULL; try { blob = curAtt->openBlob(&statusWrapper, mainTra, &from, 0, NULL); @@ -913,7 +913,7 @@ class SrpManagement final : public Firebird::StdPlugingetSegment(&statusWrapper, sizeof(segbuf), segbuf, &len); check(&statusWrapper); - if (cc == Firebird::IStatus::RESULT_NO_DATA) + if (cc == IStatus::RESULT_NO_DATA) break; s.append(segbuf, len); } @@ -924,7 +924,7 @@ class SrpManagement final : public Firebird::StdPluginset(&statusWrapper, s.c_str()); check(&statusWrapper); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (blob) blob->release(); @@ -933,13 +933,13 @@ class SrpManagement final : public Firebird::StdPluginget(); unsigned len = static_cast(strlen(ptr)); - Firebird::IBlob* blob = NULL; + IBlob* blob = NULL; try { blob = curAtt->createBlob(st, mainTra, &to, 0, NULL); @@ -957,7 +957,7 @@ class SrpManagement final : public Firebird::StdPluginclose(st); check(st); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (blob) blob->release(); @@ -967,13 +967,17 @@ class SrpManagement final : public Firebird::StdPlugin factory; +static SimpleFactory factory; + + +} // namespace Firebird::Auth + -} // namespace Auth +using namespace Firebird; -extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { - Firebird::CachedMasterInterface::set(master); - Firebird::PluginManagerInterfacePtr()->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory); - Firebird::getUnloadDetector()->registerMe(); + CachedMasterInterface::set(master); + PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory); + getUnloadDetector()->registerMe(); } diff --git a/src/auth/SecureRemotePassword/misc/test_srp.cpp b/src/auth/SecureRemotePassword/misc/test_srp.cpp index 6247f508ff2..ce0596a7e06 100644 --- a/src/auth/SecureRemotePassword/misc/test_srp.cpp +++ b/src/auth/SecureRemotePassword/misc/test_srp.cpp @@ -1,14 +1,15 @@ #include "../auth/SecureRemotePassword/srp.h" -using namespace Auth; +using namespace Firebird; +using namespace Firebird::Auth; templatevoid runTest(int argc, char** argv) { - Firebird::string salt; + string salt; #if SRP_DEBUG > 1 - Firebird::BigInteger s("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); + BigInteger s("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); #else - Firebird::BigInteger s; + BigInteger s; s.random(128); #endif s.getText(salt); @@ -19,7 +20,7 @@ templatevoid runTest(int argc, char** argv) const char* account = "SYSDBA"; const char* password = "masterkey"; - Firebird::UCharBuffer verifier; + UCharBuffer verifier; dumpIt("salt", salt); #if SRP_DEBUG > 0 fprintf(stderr, "%s %s\n", account, password); @@ -27,18 +28,18 @@ templatevoid runTest(int argc, char** argv) server->computeVerifier(account, salt, password).getBytes(verifier); dumpIt("verifier", verifier); - Firebird::string clientPubKey, serverPubKey; + string clientPubKey, serverPubKey; client->genClientKey(clientPubKey); fprintf(stderr, "C Pub %d\n", clientPubKey.length()); server->genServerKey(serverPubKey, verifier); fprintf(stderr, "S Pub %d\n", serverPubKey.length()); - Firebird::UCharBuffer key1, key2; + UCharBuffer key1, key2; client->clientSessionKey(key1, account, salt.c_str(), argc > 1 ? argv[1] : password, serverPubKey.c_str()); server->serverSessionKey(key2, clientPubKey.c_str(), verifier); - Firebird::BigInteger cProof = client->clientProof(account, salt.c_str(), key1); - Firebird::BigInteger sProof = server->clientProof(account, salt.c_str(), key2); + BigInteger cProof = client->clientProof(account, salt.c_str(), key1); + BigInteger sProof = server->clientProof(account, salt.c_str(), key2); printf("Proof length = %d\n",cProof.length()); printf("%s\n", cProof == sProof ? "OK" : "differ"); @@ -47,10 +48,10 @@ templatevoid runTest(int argc, char** argv) int main(int argc, char** argv) { - runTest(argc,argv); - runTest(argc,argv); - runTest(argc,argv); - runTest(argc,argv); - runTest(argc,argv); + runTest(argc,argv); + runTest(argc,argv); + runTest(argc,argv); + runTest(argc,argv); + runTest(argc,argv); } diff --git a/src/auth/SecureRemotePassword/server/SrpServer.cpp b/src/auth/SecureRemotePassword/server/SrpServer.cpp index 7afde371d3b..cb6cd7539be 100644 --- a/src/auth/SecureRemotePassword/server/SrpServer.cpp +++ b/src/auth/SecureRemotePassword/server/SrpServer.cpp @@ -35,11 +35,12 @@ #include "../common/classes/ParsedList.h" #include "../common/isc_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../auth/SecDbCache.h" -using namespace Firebird; -using namespace Auth; +namespace Firebird::Auth +{ + namespace { @@ -70,7 +71,7 @@ struct Metadata InitInstance meta; -class SrpServer : public StdPlugin > +class SrpServer : public StdPlugin> { public: explicit SrpServer(IPluginConfig* par) @@ -141,7 +142,7 @@ class SecurityDatabase final : public VSecDb static void forceClean(IProvider* p, CachedSecurityDatabase::Instance& instance) { - Firebird::PathName secDbName(instance->secureDbName); + PathName secDbName(instance->secureDbName); instance.reset(); cleanup(); @@ -418,8 +419,6 @@ SimpleFactory > factory_sha512; } // anonymous namespace -namespace Auth { - void registerSrpServer(IPluginManager* iPlugin) { iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_SERVER, RemotePassword::plugName, &factory_sha1); @@ -429,4 +428,5 @@ void registerSrpServer(IPluginManager* iPlugin) iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_SERVER, RemotePassword::pluginName(512).c_str(), &factory_sha512); } -} // namespace Auth + +} // namespace Firebird::Auth diff --git a/src/auth/SecureRemotePassword/server/SrpServer.h b/src/auth/SecureRemotePassword/server/SrpServer.h index 596772643a2..041961033a2 100644 --- a/src/auth/SecureRemotePassword/server/SrpServer.h +++ b/src/auth/SecureRemotePassword/server/SrpServer.h @@ -29,10 +29,9 @@ #include "firebird/Interface.h" -namespace Auth { - -void registerSrpServer(Firebird::IPluginManager* iPlugin); - -} // namespace Auth +namespace Firebird::Auth +{ + void registerSrpServer(IPluginManager* iPlugin); +} // namespace Firebird::Auth #endif // AUTH_SRP_SERVER_H diff --git a/src/auth/SecureRemotePassword/srp.cpp b/src/auth/SecureRemotePassword/srp.cpp index c1a5df118f4..6cc61ca5ffc 100644 --- a/src/auth/SecureRemotePassword/srp.cpp +++ b/src/auth/SecureRemotePassword/srp.cpp @@ -8,28 +8,30 @@ #include "../common/classes/fb_string.h" #include "../common/sha.h" -using namespace Firebird; - -namespace { -const char* primeStr = "E67D2E994B2F900C3F41F08F5BB2627ED0D49EE1FE767A52EFCD565C" - "D6E768812C3E1E9CE8F0A8BEA6CB13CD29DDEBF7A96D4A93B55D488D" - "F099A15C89DCB0640738EB2CBDD9A8F7BAB561AB1B0DC1C6CDABF303" - "264A08D1BCA932D1F1EE428B619D970F342ABA9A65793B8B2F041AE5" - "364350C16F735F56ECBCA87BD57B29E7"; -const char* genStr = "02"; +namespace Firebird::Auth +{ + + +namespace +{ + const char* primeStr = "E67D2E994B2F900C3F41F08F5BB2627ED0D49EE1FE767A52EFCD565C" + "D6E768812C3E1E9CE8F0A8BEA6CB13CD29DDEBF7A96D4A93B55D488D" + "F099A15C89DCB0640738EB2CBDD9A8F7BAB561AB1B0DC1C6CDABF303" + "264A08D1BCA932D1F1EE428B619D970F342ABA9A65793B8B2F041AE5" + "364350C16F735F56ECBCA87BD57B29E7"; + const char* genStr = "02"; } // anonumous namespace -namespace Auth { class RemoteGroup { public: BigInteger prime, generator, k; - explicit RemoteGroup(Firebird::MemoryPool&) + explicit RemoteGroup(MemoryPool&) : prime(primeStr), generator(genStr), k() { - Auth::SecureHash hash; + Auth::SecureHash hash; hash.processInt(prime); if (prime.length() > generator.length()) @@ -109,7 +111,7 @@ void RemotePassword::genClientKey(string& pubkey) dumpIt("clientPublicKey", clientPublicKey); } -void RemotePassword::genServerKey(string& pubkey, const Firebird::UCharBuffer& verifier) +void RemotePassword::genServerKey(string& pubkey, const UCharBuffer& verifier) { dumpIt("privateKey(S)", privateKey); BigInteger gb(group->generator.modPow(privateKey, group->prime)); // g^b @@ -202,7 +204,7 @@ RemotePassword::~RemotePassword() { } #if SRP_DEBUG > 0 -void dumpIt(const char* name, const Firebird::UCharBuffer& data) +void dumpIt(const char* name, const UCharBuffer& data) { fprintf(stderr, "%s\n", name); for (size_t x = 0; x -namespace Auth { +namespace Firebird::Auth +{ + /* * Order of battle for SRP handshake: @@ -55,23 +57,23 @@ class RemoteGroup; template class SecureHash : public SHA { public: - void getInt(Firebird::BigInteger& hash) + void getInt(BigInteger& hash) { - Firebird::UCharBuffer tmp; + UCharBuffer tmp; SHA::getHash(tmp); hash.assign(tmp.getCount(), tmp.begin()); } - void processInt(const Firebird::BigInteger& data) + void processInt(const BigInteger& data) { - Firebird::UCharBuffer bytes; + UCharBuffer bytes; data.getBytes(bytes); SHA::process(bytes); } - void processStrippedInt(const Firebird::BigInteger& data) + void processStrippedInt(const BigInteger& data) { - Firebird::UCharBuffer bytes; + UCharBuffer bytes; data.getBytes(bytes); if (bytes.getCount()) { @@ -82,21 +84,21 @@ template class SecureHash : public SHA }; -class RemotePassword : public Firebird::GlobalStorage +class RemotePassword : public GlobalStorage { private: const RemoteGroup* group; - Auth::SecureHash hash; - Firebird::BigInteger privateKey; - Firebird::BigInteger scramble; + Auth::SecureHash hash; + BigInteger privateKey; + BigInteger scramble; protected: - virtual Firebird::BigInteger makeProof(const Firebird::BigInteger n1, const Firebird::BigInteger n2, - const char* salt, const Firebird::UCharBuffer& sessionKey) = 0; + virtual BigInteger makeProof(const BigInteger n1, const BigInteger n2, + const char* salt, const UCharBuffer& sessionKey) = 0; public: - Firebird::BigInteger clientPublicKey; - Firebird::BigInteger serverPublicKey; + BigInteger clientPublicKey; + BigInteger serverPublicKey; public: RemotePassword(); @@ -107,33 +109,33 @@ class RemotePassword : public Firebird::GlobalStorage static constexpr unsigned SRP_VERIFIER_SIZE = SRP_KEY_SIZE; static constexpr unsigned SRP_SALT_SIZE = 32; - static Firebird::string pluginName(unsigned bits); + static string pluginName(unsigned bits); - Firebird::BigInteger getUserHash(const char* account, + BigInteger getUserHash(const char* account, const char* salt, const char* password); - Firebird::BigInteger computeVerifier(const Firebird::string& account, - const Firebird::string& salt, - const Firebird::string& password); - void genClientKey(Firebird::string& clientPubKey); - void genServerKey(Firebird::string& serverPubKey, const Firebird::UCharBuffer& verifier); + BigInteger computeVerifier(const string& account, + const string& salt, + const string& password); + void genClientKey(string& clientPubKey); + void genServerKey(string& serverPubKey, const UCharBuffer& verifier); void computeScramble(); - void clientSessionKey(Firebird::UCharBuffer& sessionKey, const char* account, + void clientSessionKey(UCharBuffer& sessionKey, const char* account, const char* salt, const char* password, const char* serverPubKey); - void serverSessionKey(Firebird::UCharBuffer& sessionKey, + void serverSessionKey(UCharBuffer& sessionKey, const char* clientPubKey, - const Firebird::UCharBuffer& verifier); - Firebird::BigInteger clientProof(const char* account, + const UCharBuffer& verifier); + BigInteger clientProof(const char* account, const char* salt, - const Firebird::UCharBuffer& sessionKey); + const UCharBuffer& sessionKey); }; template class RemotePasswordImpl : public RemotePassword { protected: - Firebird::BigInteger makeProof(const Firebird::BigInteger n1, const Firebird::BigInteger n2, - const char* salt, const Firebird::UCharBuffer& sessionKey) + BigInteger makeProof(const BigInteger n1, const BigInteger n2, + const char* salt, const UCharBuffer& sessionKey) { Auth::SecureHash digest; digest.processInt(n1); // H(prime) ^ H(g) @@ -143,7 +145,7 @@ template class RemotePasswordImpl : public RemotePassword digest.processInt(serverPublicKey); // B digest.process(sessionKey); // K - Firebird::BigInteger rc; + BigInteger rc; digest.getInt(rc); return rc; } @@ -152,19 +154,20 @@ template class RemotePasswordImpl : public RemotePassword #if SRP_DEBUG > 0 -void dumpIt(const char* name, const Firebird::BigInteger& bi); -void dumpIt(const char* name, const Firebird::UCharBuffer& data); -void dumpIt(const char* name, const Firebird::string& str); -void dumpBin(const char* name, const Firebird::string& str); +void dumpIt(const char* name, const BigInteger& bi); +void dumpIt(const char* name, const UCharBuffer& data); +void dumpIt(const char* name, const string& str); +void dumpBin(const char* name, const string& str); #else -void static inline dumpIt(const char* /*name*/, const Firebird::BigInteger& /*bi*/) { } -void static inline dumpIt(const char* /*name*/, const Firebird::UCharBuffer& /*data*/) { } -void static inline dumpIt(const char* /*name*/, const Firebird::string& /*str*/) { } -void static inline dumpBin(const char* /*name*/, const Firebird::string& /*str*/) { } +void static inline dumpIt(const char* /*name*/, const BigInteger& /*bi*/) { } +void static inline dumpIt(const char* /*name*/, const UCharBuffer& /*data*/) { } +void static inline dumpIt(const char* /*name*/, const string& /*str*/) { } +void static inline dumpBin(const char* /*name*/, const string& /*str*/) { } #endif void checkStatusVectorForMissingTable(const ISC_STATUS* v, std::function cleanup = nullptr); -} // namespace Auth + +} // namespace Firebird::Auth #endif // AUTH_SRP_SRP_H diff --git a/src/auth/SecurityDatabase/LegacyClient.cpp b/src/auth/SecurityDatabase/LegacyClient.cpp index 517566a88bb..fa251380adc 100644 --- a/src/auth/SecurityDatabase/LegacyClient.cpp +++ b/src/auth/SecurityDatabase/LegacyClient.cpp @@ -33,9 +33,11 @@ #include "../common/classes/ImplementHelper.h" #include "../common/classes/init.h" -namespace Auth { +namespace Firebird::Auth +{ + -int SecurityDatabaseClient::authenticate(Firebird::CheckStatusWrapper* status, Firebird::IClientBlock* cb) +int SecurityDatabaseClient::authenticate(CheckStatusWrapper* status, IClientBlock* cb) { // fprintf(stderr, "Clnt: Legacy: lgn=%s pswd=%s\n", cb->getLogin(), cb->getPassword()); if (!(cb->getLogin() && cb->getPassword())) @@ -46,7 +48,7 @@ int SecurityDatabaseClient::authenticate(Firebird::CheckStatusWrapper* status, F TEXT pwt[MAX_LEGACY_PASSWORD_LENGTH + 2]; ENC_crypt(pwt, sizeof pwt, cb->getPassword(), LEGACY_PASSWORD_SALT); cb->putData(status, static_cast(strlen(&pwt[2])), &pwt[2]); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { return AUTH_FAILED; } @@ -55,12 +57,13 @@ int SecurityDatabaseClient::authenticate(Firebird::CheckStatusWrapper* status, F } namespace { - Firebird::SimpleFactory factory; + SimpleFactory factory; } -void registerLegacyClient(Firebird::IPluginManager* iPlugin) +void registerLegacyClient(IPluginManager* iPlugin) { - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_CLIENT, "Legacy_Auth", &factory); + iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_CLIENT, "Legacy_Auth", &factory); } -} // namespace Auth + +} // namespace Firebird::Auth diff --git a/src/auth/SecurityDatabase/LegacyClient.h b/src/auth/SecurityDatabase/LegacyClient.h index c271f945206..be1015f1220 100644 --- a/src/auth/SecurityDatabase/LegacyClient.h +++ b/src/auth/SecurityDatabase/LegacyClient.h @@ -30,25 +30,28 @@ #include "firebird/Interface.h" #include "../common/classes/ImplementHelper.h" -namespace Auth { +namespace Firebird::Auth +{ + // Required to stop analyzing rest of plugins before first roundtrip to server // if legacy login is present in DPB class SecurityDatabaseClient final : - public Firebird::StdPlugin > + public StdPlugin> { public: - explicit SecurityDatabaseClient(Firebird::IPluginConfig*) + explicit SecurityDatabaseClient(IPluginConfig*) { } // IClient implementation - int authenticate(Firebird::CheckStatusWrapper*, Firebird::IClientBlock* data); + int authenticate(CheckStatusWrapper*, IClientBlock* data); }; -void registerLegacyClient(Firebird::IPluginManager* iPlugin); +void registerLegacyClient(IPluginManager* iPlugin); + -} // namespace Auth +} // namespace Firebird::Auth #endif // AUTH_LEGACY_CLIENT_H diff --git a/src/auth/SecurityDatabase/LegacyHash.h b/src/auth/SecurityDatabase/LegacyHash.h index 3c80154a890..5a9c20a7e8c 100644 --- a/src/auth/SecurityDatabase/LegacyHash.h +++ b/src/auth/SecurityDatabase/LegacyHash.h @@ -32,7 +32,9 @@ #include "../common/os/guid.h" #include "../common/utils_proto.h" -namespace Auth { +namespace Firebird::Auth +{ + inline constexpr size_t MAX_LEGACY_PASSWORD_LENGTH = 64; // used to store passwords internally static inline constexpr const char* LEGACY_PASSWORD_SALT = "9z"; // for old ENC_crypt() @@ -41,28 +43,26 @@ inline constexpr size_t SALT_LENGTH = 12; // measured after base64 coding class LegacyHash { public: - static void hash(Firebird::string& h, const Firebird::string& userName, const TEXT* passwd) + static void hash(string& h, const string& userName, const TEXT* passwd) { - Firebird::string salt; + string salt; fb_utils::random64(salt, SALT_LENGTH); hash(h, userName, passwd, salt); } - static void hash(Firebird::string& h, - const Firebird::string& userName, - const Firebird::string& passwd, - const Firebird::string& oldHash) + static void hash(string& h, const string& userName, const string& passwd, const string& oldHash) { - Firebird::string salt(oldHash); + string salt(oldHash); salt.resize(SALT_LENGTH, '='); - Firebird::string allData(salt); + string allData(salt); allData += userName; allData += passwd; - Firebird::Sha1::hashBased64(h, allData); + Sha1::hashBased64(h, allData); h = salt + h; } }; -} // namespace Auth + +} // namespace Firebird::Auth #endif // AUTH_LEGACY_SERVER_H diff --git a/src/auth/SecurityDatabase/LegacyManagement.epp b/src/auth/SecurityDatabase/LegacyManagement.epp index 31fd920de9e..c297b948387 100644 --- a/src/auth/SecurityDatabase/LegacyManagement.epp +++ b/src/auth/SecurityDatabase/LegacyManagement.epp @@ -45,22 +45,23 @@ #include "../common/classes/ParsedList.h" #include "firebird/Interface.h" -using namespace Firebird; - // Here we use version-independent symbolic link (or copy) of actual database DATABASE database = STATIC FILENAME "security.fdb"; -static Firebird::GlobalPtr execLineMutex; // protects various gpre generated structures +namespace Firebird::Auth +{ + + +static GlobalPtr execLineMutex; // protects various gpre generated structures -static bool grantRevokeAdmin(ISC_STATUS* isc_status, FB_API_HANDLE database, FB_API_HANDLE trans, - Firebird::IUser* user) +static bool grantRevokeAdmin(ISC_STATUS* isc_status, FB_API_HANDLE database, FB_API_HANDLE trans, IUser* user) { if (!user->admin()->entered()) { return true; } - Firebird::string userName(user->userName()->get()); + string userName(user->userName()->get()); for (unsigned i = 0; i < userName.length(); ++i) { if (userName[i] == '"') @@ -69,7 +70,7 @@ static bool grantRevokeAdmin(ISC_STATUS* isc_status, FB_API_HANDLE database, FB_ } } - Firebird::string sql; + string sql; sql.printf((user->admin()->get() ? "GRANT %s TO \"%s\"" : "REVOKE %s FROM \"%s\""), ADMIN_ROLE, userName.c_str()); isc_dsql_execute_immediate(isc_status, &database, &trans, sql.length(), sql.c_str(), SQL_DIALECT_V6, NULL); @@ -102,20 +103,18 @@ static bool grantRevokeAdmin(ISC_STATUS* isc_status, FB_API_HANDLE database, FB_ } -static Firebird::GlobalPtr keys; +static GlobalPtr keys; -namespace Auth { - -SecurityDatabaseManagement::SecurityDatabaseManagement(Firebird::IPluginConfig* par) +SecurityDatabaseManagement::SecurityDatabaseManagement(IPluginConfig* par) : database(0), transaction(0) { - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); config.assignRefNoIncr(par->getFirebirdConf(&statusWrapper)); check(&s); } -void SecurityDatabaseManagement::start(Firebird::CheckStatusWrapper* st, Firebird::ILogonInfo* logonInfo) +void SecurityDatabaseManagement::start(CheckStatusWrapper* st, ILogonInfo* logonInfo) { try { @@ -125,12 +124,12 @@ void SecurityDatabaseManagement::start(Firebird::CheckStatusWrapper* st, Firebir const char* secDbName = config->asString(secDbKey); if (!(secDbName && secDbName[0])) { - Firebird::Arg::Gds(isc_secdb_name).raise(); + Arg::Gds(isc_secdb_name).raise(); } - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); dpb.insertByte(isc_dpb_sec_attach, TRUE); - dpb.insertString(isc_dpb_config, Firebird::ParsedList::getNonLoopbackProviders(secDbName)); + dpb.insertString(isc_dpb_config, ParsedList::getNonLoopbackProviders(secDbName)); string schemaSearchPath; schemaSearchPath.printf("%s, %s", PLG_LEGACY_SEC_SCHEMA, SYSTEM_SCHEMA); @@ -156,21 +155,21 @@ void SecurityDatabaseManagement::start(Firebird::CheckStatusWrapper* st, Firebir if (isc_attach_database(status, 0, secDbName, &database, dpb.getBufferLength(), reinterpret_cast(dpb.getBuffer()))) { - Firebird::status_exception::raise(status); + status_exception::raise(status); } if (isc_start_transaction(status, &transaction, 1, &database, 0, NULL)) { - Firebird::status_exception::raise(status); + status_exception::raise(status); } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } } -void SecurityDatabaseManagement::commit(Firebird::CheckStatusWrapper* st) +void SecurityDatabaseManagement::commit(CheckStatusWrapper* st) { try { @@ -181,17 +180,17 @@ void SecurityDatabaseManagement::commit(Firebird::CheckStatusWrapper* st) { if (isc_commit_transaction(status, &transaction)) { - Firebird::status_exception::raise(status); + status_exception::raise(status); } } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } } -void SecurityDatabaseManagement::rollback(Firebird::CheckStatusWrapper* st) +void SecurityDatabaseManagement::rollback(CheckStatusWrapper* st) { try { @@ -202,11 +201,11 @@ void SecurityDatabaseManagement::rollback(Firebird::CheckStatusWrapper* st) { if (isc_rollback_transaction(status, &transaction)) { - Firebird::status_exception::raise(status); + status_exception::raise(status); } } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } @@ -231,7 +230,7 @@ int SecurityDatabaseManagement::release() #define STR_STORE(to, from) fb_utils::copy_terminate(to, from, sizeof(to)) #define STR_VSTORE(to, from) string2vary(&to, from, sizeof(to)) -static void string2vary(void* to, const Firebird::string& from, size_t to_size) +static void string2vary(void* to, const string& from, size_t to_size) { const size_t len = MIN(to_size - sizeof(USHORT), from.size()); paramvary* v = reinterpret_cast(to); @@ -240,8 +239,7 @@ static void string2vary(void* to, const Firebird::string& from, size_t to_size) } -int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebird::IUser* user, - Firebird::IListUsers* callback) +int SecurityDatabaseManagement::execute(CheckStatusWrapper* st, IUser* user, IListUsers* callback) { /************************************* * @@ -311,10 +309,10 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi fb_utils::init_status(isc_status); st->init(); - Firebird::MutexLockGuard guard(execLineMutex, FB_FUNCTION); + MutexLockGuard guard(execLineMutex, FB_FUNCTION); SCHAR encrypted1[MAX_LEGACY_PASSWORD_LENGTH + 2]; - Firebird::string encrypted2; + string encrypted2; bool found; // check for non-printable characters in user name @@ -322,7 +320,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi { if (!isprint(*p)) { - return GsecMsg75; // Add special error message for this case ? + return Gsec::GsecMsg75; // Add special error message for this case ? } } @@ -331,21 +329,21 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi switch (user->operation()) { - case Firebird::IUser::OP_USER_DROP_MAP: - case Firebird::IUser::OP_USER_SET_MAP: + case IUser::OP_USER_DROP_MAP: + case IUser::OP_USER_SET_MAP: { - Firebird::string sql; + string sql; sql.printf("ALTER ROLE " ADMIN_ROLE " %s AUTO ADMIN MAPPING", - user->operation() == Firebird::IUser::OP_USER_SET_MAP ? "SET" : "DROP"); + user->operation() == IUser::OP_USER_SET_MAP ? "SET" : "DROP"); isc_dsql_execute_immediate(isc_status, &database, &transaction, sql.length(), sql.c_str(), 1, NULL); if (isc_status[1] != 0) { - ret = GsecMsg97; + ret = Gsec::GsecMsg97; } } break; - case Firebird::IUser::OP_USER_ADD: + case IUser::OP_USER_ADD: // this checks the "entered" flags for each parameter (except the name) // and makes all non-entered parameters null valued @@ -411,15 +409,15 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi U.PLG$LAST_NAME.NULL = ISC_TRUE; END_STORE ON_ERROR - ret = GsecMsg19; // gsec - add record error + ret = Gsec::GsecMsg19; // gsec - add record error END_ERROR; if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user)) { - ret = GsecMsg19; // gsec - add record error + ret = Gsec::GsecMsg19; // gsec - add record error } break; - case Firebird::IUser::OP_USER_MODIFY: + case IUser::OP_USER_MODIFY: // this updates an existing record, replacing all fields that are // entered, and for those that were specified but not entered, it // changes the current value to the null value @@ -499,30 +497,30 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi U.PLG$LAST_NAME.NULL = ISC_TRUE; END_MODIFY ON_ERROR - ret = GsecMsg20; + ret = Gsec::GsecMsg20; END_ERROR; } END_FOR ON_ERROR - ret = GsecMsg21; + ret = Gsec::GsecMsg21; END_ERROR; if (!ret && !found) - ret = GsecMsg22; + ret = Gsec::GsecMsg22; if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user)) { - ret = GsecMsg21; + ret = Gsec::GsecMsg21; } break; - case Firebird::IUser::OP_USER_DELETE: + case IUser::OP_USER_DELETE: // looks up the specified user record and deletes it found = false; // Do not allow SYSDBA user to be deleted if (!fb_utils::stricmp(user->userName()->get(), DBA_USER_NAME)) - ret = GsecMsg23; + ret = Gsec::GsecMsg23; else { FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS @@ -531,17 +529,17 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi found = true; ERASE U ON_ERROR - ret = GsecMsg23; // gsec - delete record error + ret = Gsec::GsecMsg23; // gsec - delete record error END_ERROR; } END_FOR ON_ERROR - ret = GsecMsg24; // gsec - find/delete record error + ret = Gsec::GsecMsg24; // gsec - find/delete record error END_ERROR; } if (!ret && !found) - ret = GsecMsg22; // gsec - record not found for user: + ret = Gsec::GsecMsg22; // gsec - record not found for user: user->admin()->set(st, 0); check(st); @@ -549,25 +547,25 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi check(st); if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user)) { - ret = GsecMsg24; + ret = Gsec::GsecMsg24; } break; - case Firebird::IUser::OP_USER_DISPLAY: + case IUser::OP_USER_DISPLAY: // gets either the desired record, or all records, and displays them found = false; if (!user->userName()->entered()) { - Firebird::LocalStatus s2; - Firebird::CheckStatusWrapper statusWrapper2(&s2); - Firebird::CheckStatusWrapper* s = st; + LocalStatus s2; + CheckStatusWrapper statusWrapper2(&s2); + CheckStatusWrapper* s = st; FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS try { { - Firebird::string attr, a1, a2, a3; + string attr, a1, a2, a3; if (!U.PLG$UID.NULL) a1.printf("Uid=%d\n", U.PLG$UID); @@ -627,14 +625,14 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi found = true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(s); s = &statusWrapper2; } END_FOR ON_ERROR - ret = GsecMsg28; // gsec - find/display record error + ret = Gsec::GsecMsg28; // gsec - find/display record error END_ERROR; // real error raise - out of gpre's FOR loop @@ -642,10 +640,10 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi } else { - Firebird::string attr, a1, a2, a3; - Firebird::LocalStatus s2; - Firebird::CheckStatusWrapper statusWrapper2(&s2); - Firebird::CheckStatusWrapper* s = st; + string attr, a1, a2, a3; + LocalStatus s2; + CheckStatusWrapper statusWrapper2(&s2); + CheckStatusWrapper* s = st; FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS WITH U.PLG$USER_NAME EQ user->userName()->get() @@ -709,14 +707,14 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi found = true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(s); s = &statusWrapper2; } END_FOR ON_ERROR - ret = GsecMsg28; // gsec - find/display record error + ret = Gsec::GsecMsg28; // gsec - find/display record error END_ERROR; // real error raise - out of gpre's FOR loop @@ -725,7 +723,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi break; default: - ret = GsecMsg16; // gsec - error in switch specifications + ret = Gsec::GsecMsg16; // gsec - error in switch specifications break; } @@ -736,7 +734,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi { if (! ret) { - ret = GsecMsg94; // error releasing request in security database + ret = Gsec::GsecMsg94; // error releasing request in security database } } } @@ -748,14 +746,14 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi { if (! ret) { - ret = GsecMsg94; // error releasing request in security database + ret = Gsec::GsecMsg94; // error releasing request in security database } } } fb_utils::setIStatus(st, isc_status); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } @@ -763,15 +761,19 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi return ret; } -} // namespace Auth + +} // namespace Firebird::Auth + + +using namespace Firebird; // register plugin -static Firebird::SimpleFactory factory; +static SimpleFactory factory; -extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { - Firebird::CachedMasterInterface::set(master); - Firebird::PluginManagerInterfacePtr()->registerPluginFactory( - Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, "Legacy_UserManager", &factory); - Firebird::getUnloadDetector()->registerMe(); + CachedMasterInterface::set(master); + PluginManagerInterfacePtr()->registerPluginFactory( + IPluginManager::TYPE_AUTH_USER_MANAGEMENT, "Legacy_UserManager", &factory); + getUnloadDetector()->registerMe(); } diff --git a/src/auth/SecurityDatabase/LegacyManagement.h b/src/auth/SecurityDatabase/LegacyManagement.h index 65136edb6ad..58358e6ebc0 100644 --- a/src/auth/SecurityDatabase/LegacyManagement.h +++ b/src/auth/SecurityDatabase/LegacyManagement.h @@ -31,27 +31,30 @@ #include "firebird/Interface.h" -namespace Auth { +namespace Firebird::Auth +{ + class SecurityDatabaseManagement final : - public Firebird::StdPlugin > + public StdPlugin> { public: - explicit SecurityDatabaseManagement(Firebird::IPluginConfig* par); + explicit SecurityDatabaseManagement(IPluginConfig* par); // IManagement implementation - void start(Firebird::CheckStatusWrapper* status, Firebird::ILogonInfo* logonInfo) override; - int execute(Firebird::CheckStatusWrapper* status, Firebird::IUser* user, Firebird::IListUsers* callback) override; - void commit(Firebird::CheckStatusWrapper* status) override; - void rollback(Firebird::CheckStatusWrapper* status) override; + void start(CheckStatusWrapper* status, ILogonInfo* logonInfo) override; + int execute(CheckStatusWrapper* status, IUser* user, IListUsers* callback) override; + void commit(CheckStatusWrapper* status) override; + void rollback(CheckStatusWrapper* status) override; int release() override; private: - Firebird::RefPtr config; + RefPtr config; FB_API_HANDLE database, transaction; }; -} // namespace Auth + +} // namespace Firebird::Auth #endif // AUTH_LEGACY_MANAGEMENT_H diff --git a/src/auth/SecurityDatabase/LegacyServer.cpp b/src/auth/SecurityDatabase/LegacyServer.cpp index 66f1340c7d9..8b28f159eb4 100644 --- a/src/auth/SecurityDatabase/LegacyServer.cpp +++ b/src/auth/SecurityDatabase/LegacyServer.cpp @@ -33,7 +33,7 @@ #include "../auth/SecurityDatabase/LegacyHash.h" #include "../auth/SecDbCache.h" #include "../remote/remot_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/enc_proto.h" #include "../common/status.h" #include "../common/classes/init.h" @@ -43,7 +43,8 @@ #define PLUG_MODULE 1 -using namespace Firebird; +namespace Firebird::Auth { + namespace { @@ -57,7 +58,7 @@ const UCHAR PWD_REQUEST[] = blr_long, 0, blr_long, 0, blr_short, 0, - blr_text, BLR_WORD(Auth::MAX_LEGACY_PASSWORD_LENGTH + 2), + blr_text, BLR_WORD(MAX_LEGACY_PASSWORD_LENGTH + 2), blr_message, 0, 1, 0, blr_cstring, 129, 0, blr_receive, 0, @@ -107,7 +108,7 @@ struct user_record SLONG gid; SLONG uid; SSHORT flag; - SCHAR password[Auth::MAX_LEGACY_PASSWORD_LENGTH + 2]; + SCHAR password[MAX_LEGACY_PASSWORD_LENGTH + 2]; }; typedef char user_name[129]; @@ -124,7 +125,6 @@ const UCHAR TPB[4] = } // anonymous namespace -namespace Auth { GlobalPtr instances; @@ -410,11 +410,14 @@ void registerLegacyServer(IPluginManager* iPlugin) "Legacy_Auth", &factory); } -} // namespace Auth + +} // namespace Firebird::Auth #ifdef PLUG_MODULE +using namespace Firebird; + extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { CachedMasterInterface::set(master); diff --git a/src/auth/SecurityDatabase/LegacyServer.h b/src/auth/SecurityDatabase/LegacyServer.h index 43f7f306dee..274b89e4bea 100644 --- a/src/auth/SecurityDatabase/LegacyServer.h +++ b/src/auth/SecurityDatabase/LegacyServer.h @@ -29,10 +29,9 @@ #include "firebird/Interface.h" -namespace Auth { - -void registerLegacyServer(Firebird::IPluginManager* iPlugin); - -} // namespace Auth +namespace Firebird::Auth +{ + void registerLegacyServer(IPluginManager* iPlugin); +} // namespace Firebird::Auth #endif // AUTH_LEGACY_SERVER_H diff --git a/src/auth/trusted/AuthSspi.cpp b/src/auth/trusted/AuthSspi.cpp index 04570e77c65..d1f0b736b96 100644 --- a/src/auth/trusted/AuthSspi.cpp +++ b/src/auth/trusted/AuthSspi.cpp @@ -34,12 +34,14 @@ #include "../common/classes/ImplementHelper.h" #include "../common/isc_f_proto.h" -using namespace Firebird; +namespace Firebird::Auth +{ + namespace { - Firebird::SimpleFactory clientFactory; - Firebird::SimpleFactory serverFactory; + SimpleFactory clientFactory; + SimpleFactory serverFactory; constexpr const char* plugName = "Win_Sspi"; @@ -65,8 +67,6 @@ namespace } } -namespace Auth { - static thread_local bool legacySSP = false; @@ -377,12 +377,12 @@ bool AuthSspi::getLogin(string& login, bool& wh, GroupsList& grNames) } -WinSspiServer::WinSspiServer(Firebird::IPluginConfig*) +WinSspiServer::WinSspiServer(IPluginConfig*) : sspiData(getPool()), done(false) { } -int WinSspiServer::authenticate(Firebird::CheckStatusWrapper* status, +int WinSspiServer::authenticate(CheckStatusWrapper* status, IServerBlock* sBlock, IWriter* writerInterface) { @@ -426,7 +426,7 @@ int WinSspiServer::authenticate(Firebird::CheckStatusWrapper* status, } // walk groups to which login belongs and list them using writerInterface - Firebird::string grName; + string grName; for (unsigned n = 0; n < grNames.getCount(); ++n) { @@ -465,7 +465,7 @@ int WinSspiServer::authenticate(Firebird::CheckStatusWrapper* status, sBlock->putData(status, sspiData.getCount(), sspiData.begin()); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); return AUTH_FAILED; @@ -475,11 +475,11 @@ int WinSspiServer::authenticate(Firebird::CheckStatusWrapper* status, } -WinSspiClient::WinSspiClient(Firebird::IPluginConfig*) +WinSspiClient::WinSspiClient(IPluginConfig*) : sspiData(getPool()), keySet(false) { } -int WinSspiClient::authenticate(Firebird::CheckStatusWrapper* status, +int WinSspiClient::authenticate(CheckStatusWrapper* status, IClientBlock* cBlock) { try @@ -520,7 +520,7 @@ int WinSspiClient::authenticate(Firebird::CheckStatusWrapper* status, keySet = true; } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); return AUTH_FAILED; @@ -530,16 +530,17 @@ int WinSspiClient::authenticate(Firebird::CheckStatusWrapper* status, } -void registerTrustedClient(Firebird::IPluginManager* iPlugin) +void registerTrustedClient(IPluginManager* iPlugin) { - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_CLIENT, plugName, &clientFactory); + iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_CLIENT, plugName, &clientFactory); } -void registerTrustedServer(Firebird::IPluginManager* iPlugin) +void registerTrustedServer(IPluginManager* iPlugin) { - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_SERVER, plugName, &serverFactory); + iPlugin->registerPluginFactory(IPluginManager::TYPE_AUTH_SERVER, plugName, &serverFactory); } -} // namespace Auth + +} // namespace Firebird::Auth #endif // TRUSTED_AUTH diff --git a/src/auth/trusted/AuthSspi.h b/src/auth/trusted/AuthSspi.h index 9f693ff0f22..507a94fc578 100644 --- a/src/auth/trusted/AuthSspi.h +++ b/src/auth/trusted/AuthSspi.h @@ -49,13 +49,15 @@ #include #include -namespace Auth { +namespace Firebird::Auth +{ + class AuthSspi { public: - typedef Firebird::ObjectsArray GroupsList; - typedef Firebird::UCharBuffer Key; + typedef ObjectsArray GroupsList; + typedef UCharBuffer Key; private: static constexpr size_t BUFSIZE = 4096; @@ -64,7 +66,7 @@ class AuthSspi bool hasCredentials; CtxtHandle ctxtHndl; bool hasContext; - Firebird::string ctName; + string ctName; bool wheel; GroupsList groupNames; Key sessionKey; @@ -85,7 +87,7 @@ class AuthSspi bool initEntries() noexcept; public: - typedef Firebird::Array DataHolder; + typedef Array DataHolder; AuthSspi(); ~AuthSspi(); @@ -104,22 +106,22 @@ class AuthSspi bool accept(DataHolder& data); // returns Windows user/group names, matching accepted security context - bool getLogin(Firebird::string& login, bool& wh, GroupsList& grNames); + bool getLogin(string& login, bool& wh, GroupsList& grNames); // returns session key for wire encryption const Key* getKey() const noexcept; }; class WinSspiServer : - public Firebird::StdPlugin > + public StdPlugin> { public: // IServer implementation - int authenticate(Firebird::CheckStatusWrapper* status, Firebird::IServerBlock* sBlock, - Firebird::IWriter* writerInterface); - void setDbCryptCallback(Firebird::CheckStatusWrapper* status, Firebird::ICryptKeyCallback* callback) noexcept {}; // do nothing + int authenticate(CheckStatusWrapper* status, IServerBlock* sBlock, + IWriter* writerInterface); + void setDbCryptCallback(CheckStatusWrapper* status, ICryptKeyCallback* callback) noexcept {}; // do nothing - WinSspiServer(Firebird::IPluginConfig*); + WinSspiServer(IPluginConfig*); private: AuthSspi::DataHolder sspiData; @@ -128,13 +130,13 @@ class WinSspiServer : }; class WinSspiClient : - public Firebird::StdPlugin > + public StdPlugin> { public: // IClient implementation - int authenticate(Firebird::CheckStatusWrapper* status, Firebird::IClientBlock* sBlock); + int authenticate(CheckStatusWrapper* status, IClientBlock* sBlock); - WinSspiClient(Firebird::IPluginConfig*); + WinSspiClient(IPluginConfig*); private: AuthSspi::DataHolder sspiData; @@ -142,14 +144,15 @@ class WinSspiClient : bool keySet; }; -void registerTrustedClient(Firebird::IPluginManager* iPlugin); -void registerTrustedServer(Firebird::IPluginManager* iPlugin); +void registerTrustedClient(IPluginManager* iPlugin); +void registerTrustedServer(IPluginManager* iPlugin); // Set per-thread flag that specify which security package should be used by // newly created plugin instances: true - use NTLM, false - use Negotiate. void setLegacySSP(bool value) noexcept; -} // namespace Auth + +} // namespace Firebird::Auth #endif // TRUSTED_AUTH #endif // AUTH_SSPI_H diff --git a/src/burp/BurpTasks.cpp b/src/burp/BurpTasks.cpp index 5b9feb7b51a..5e7ec0cb751 100644 --- a/src/burp/BurpTasks.cpp +++ b/src/burp/BurpTasks.cpp @@ -32,11 +32,11 @@ #include "../burp/burp_proto.h" #include "../burp/mvol_proto.h" +namespace Firebird::Burp +{ + using MsgFormat::SafeArg; -using namespace Firebird; -namespace Burp -{ // IO buffer should fit at least one blob segment, two is better. constexpr FB_SIZE_T MIN_IO_BUFFER_SIZE = 128 * 1024; @@ -1144,4 +1144,5 @@ const char* RestoreRelationTask::ExcReadDone::what() const noexcept throw ExcReadDone(); } -} // namespace Firebird + +} // namespace Firebird::Burp diff --git a/src/burp/BurpTasks.h b/src/burp/BurpTasks.h index acea882743b..cfd99618731 100644 --- a/src/burp/BurpTasks.h +++ b/src/burp/BurpTasks.h @@ -38,7 +38,9 @@ #include "../common/classes/condition.h" #include "../common/classes/fb_atomic.h" -namespace Burp { +namespace Firebird::Burp +{ + class ReadRelationMeta { @@ -62,7 +64,7 @@ class ReadRelationMeta SSHORT m_fldCount; SSHORT m_inMgsNum; SSHORT m_outMgsNum; - Firebird::HalfStaticArray m_blr; + HalfStaticArray m_blr; RCRD_LENGTH m_outMsgLen; RCRD_LENGTH m_outRecLen; RCRD_OFFSET m_outEofOffset; @@ -84,11 +86,11 @@ class ReadRelationReq void reset(const ReadRelationMeta* meta); void clear(); - void compile(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* db); + void compile(CheckStatusWrapper* status, IAttachment* db); void setParams(ULONG loPP, ULONG hiPP); - void start(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tran); - void receive(Firebird::CheckStatusWrapper* status); - void release(Firebird::CheckStatusWrapper* status); + void start(CheckStatusWrapper* status, ITransaction* tran); + void receive(CheckStatusWrapper* status); + void release(CheckStatusWrapper* status); const ReadRelationMeta* getMeta() const noexcept { @@ -115,9 +117,9 @@ class ReadRelationReq const burp_rel* m_relation = nullptr; const ReadRelationMeta* m_meta = nullptr; InMsg m_inMgs{}; - Firebird::Array m_outMsg; + Array m_outMsg; SSHORT* m_eof = nullptr; - Firebird::IRequest* m_request = nullptr; + IRequest* m_request = nullptr; }; @@ -133,28 +135,28 @@ class WriteRelationMeta void setRelation(BurpGlobals* tdgbl, const burp_rel* relation); void clear(); - Firebird::IBatch* createBatch(BurpGlobals* tdgbl, Firebird::IAttachment* att); + IBatch* createBatch(BurpGlobals* tdgbl, IAttachment* att); //private: bool prepareBatch(BurpGlobals* tdgbl); void prepareRequest(BurpGlobals* tdgbl); const burp_rel* m_relation; - Firebird::Mutex m_mutex; + Mutex m_mutex; bool m_batchMode; bool m_batchOk; ULONG m_inMsgLen; ULONG m_blobCount; // batch mode - Firebird::string m_sqlStatement; - Firebird::RefPtr m_batchMeta; + string m_sqlStatement; + RefPtr m_batchMeta; unsigned m_batchStep; unsigned m_batchInlineBlobLimit; // request mode SSHORT m_inMgsNum; - Firebird::HalfStaticArray m_blr; + HalfStaticArray m_blr; }; class WriteRelationReq @@ -174,8 +176,8 @@ class WriteRelationReq void reset(WriteRelationMeta* meta); void clear(); - void compile(BurpGlobals* tdgbl, Firebird::IAttachment* att); - void send(BurpGlobals* tdgbl, Firebird::ITransaction* tran, bool lastRec); + void compile(BurpGlobals* tdgbl, IAttachment* att); + void send(BurpGlobals* tdgbl, ITransaction* tran, bool lastRec); void execBatch(BurpGlobals * tdgbl); void release(); @@ -189,7 +191,7 @@ class WriteRelationReq return m_inMsg.begin(); } - Firebird::IBatch* getBatch() const noexcept + IBatch* getBatch() const noexcept { return m_batch; } @@ -212,10 +214,10 @@ class WriteRelationReq private: const burp_rel* m_relation = nullptr; WriteRelationMeta* m_meta = nullptr; - Firebird::Array m_inMsg; - Firebird::Array m_batchMsg; - Firebird::IBatch* m_batch = nullptr; - Firebird::IRequest* m_request = nullptr; + Array m_inMsg; + Array m_batchMsg; + IBatch* m_batch = nullptr; + IRequest* m_request = nullptr; int m_recs = 0; // total records sent int m_batchRecs = 0; // records in current batch bool m_resync = true; @@ -229,7 +231,7 @@ class BurpTask; // Common base class for backup and restore task items -class BurpTaskItem : public Firebird::Task::WorkItem +class BurpTaskItem : public Task::WorkItem { public: BurpTaskItem(BurpTask* task); @@ -238,10 +240,10 @@ class BurpTaskItem : public Firebird::Task::WorkItem }; // Common base class for backup and restore tasks -class BurpTask : public Firebird::Task +class BurpTask : public Task { public: - BurpTask(BurpGlobals* tdgbl) : Firebird::Task(), + BurpTask(BurpGlobals* tdgbl) : Task(), m_masterGbl(tdgbl) { } @@ -289,12 +291,12 @@ class BurpTask : public Firebird::Task private: friend class BurpMaster; - Firebird::Mutex burpOutMutex; + Mutex burpOutMutex; }; inline BurpTaskItem::BurpTaskItem(BurpTask* task) : - Firebird::Task::WorkItem(task) + Task::WorkItem(task) { } @@ -314,7 +316,7 @@ class BackupRelationTask : public BurpTask bool handler(WorkItem& _item) override; bool getWorkItem(WorkItem** pItem) override; - bool getResult(Firebird::IStatus* status) override; + bool getResult(IStatus* status) override; int getMaxWorkers() override; class Item : public BurpTaskItem @@ -345,16 +347,16 @@ class BackupRelationTask : public BurpTask bool m_writer; // file writer or table reader bool m_ownAttach; BurpGlobals* m_gbl = nullptr; - Firebird::IAttachment* m_att = nullptr; - Firebird::ITransaction* m_tra = nullptr; + IAttachment* m_att = nullptr; + ITransaction* m_tra = nullptr; burp_rel* m_relation = nullptr; ReadRelationReq m_request; ULONG m_ppSequence = 0; // PP to read - Firebird::Mutex m_mutex; - Firebird::HalfStaticArray m_cleanBuffers; + Mutex m_mutex; + HalfStaticArray m_cleanBuffers; IOBuffer* m_buffer = nullptr; - Firebird::Condition m_cleanCond; + Condition m_cleanCond; }; static BackupRelationTask* getBackupTask(BurpGlobals* tdgbl) noexcept @@ -393,14 +395,14 @@ class BackupRelationTask : public BurpTask bool m_readDone; // true when all readers are done ULONG m_nextPP; - Firebird::Mutex m_mutex; - Firebird::HalfStaticArray m_items; + Mutex m_mutex; + HalfStaticArray m_items; volatile bool m_stop; bool m_error; - Firebird::HalfStaticArray m_buffers; - Firebird::HalfStaticArray m_dirtyBuffers; - Firebird::Condition m_dirtyCond; + HalfStaticArray m_buffers; + HalfStaticArray m_dirtyBuffers; + Condition m_dirtyCond; }; @@ -414,7 +416,7 @@ class RestoreRelationTask : public BurpTask bool handler(WorkItem& _item) override; bool getWorkItem(WorkItem** pItem) override; - bool getResult(Firebird::IStatus* status) override; + bool getResult(IStatus* status) override; int getMaxWorkers() override; class Item : public BurpTaskItem @@ -444,20 +446,20 @@ class RestoreRelationTask : public BurpTask bool m_reader; // file reader or table writer bool m_ownAttach; BurpGlobals* m_gbl = nullptr; - Firebird::IAttachment* m_att = nullptr; - Firebird::ITransaction* m_tra = nullptr; + IAttachment* m_att = nullptr; + ITransaction* m_tra = nullptr; burp_rel* m_relation = nullptr; WriteRelationReq m_request; - Firebird::Mutex m_mutex; + Mutex m_mutex; IOBuffer* m_buffer = nullptr; }; - class ExcReadDone : public Firebird::Exception + class ExcReadDone : public Exception { public: - ExcReadDone() noexcept : Firebird::Exception() { } - virtual void stuffByException(Firebird::StaticStatusVector& status_vector) const noexcept; + ExcReadDone() noexcept : Exception() { } + virtual void stuffByException(StaticStatusVector& status_vector) const noexcept; virtual const char* what() const noexcept; [[noreturn]] static void raise(); }; @@ -513,18 +515,18 @@ class RestoreRelationTask : public BurpTask int m_writers; // number of active writers, could be less than items allocated bool m_readDone; // all records was read - Firebird::Mutex m_mutex; - Firebird::HalfStaticArray m_items; + Mutex m_mutex; + HalfStaticArray m_items; volatile bool m_stop; bool m_error; - Firebird::AtomicCounter m_records; // records restored for the current relation + AtomicCounter m_records; // records restored for the current relation FB_UINT64 m_verbRecs; // last records count reported - Firebird::HalfStaticArray m_buffers; - Firebird::HalfStaticArray m_cleanBuffers; - Firebird::HalfStaticArray m_dirtyBuffers; - Firebird::Condition m_cleanCond; - Firebird::Condition m_dirtyCond; + HalfStaticArray m_buffers; + HalfStaticArray m_cleanBuffers; + HalfStaticArray m_dirtyBuffers; + Condition m_cleanCond; + Condition m_dirtyCond; }; @@ -626,7 +628,7 @@ class IOBuffer private: BurpTaskItem* const m_item; - Firebird::Array m_memory; + Array m_memory; UCHAR* m_aligned; const FB_SIZE_T m_size; FB_SIZE_T m_used; @@ -634,7 +636,7 @@ class IOBuffer IOBuffer* m_next; bool m_linked; int m_locked; - Firebird::Mutex m_mutex; + Mutex m_mutex; }; @@ -670,6 +672,7 @@ class BurpMaster BurpGlobals* m_tdgbl; }; -} // namespace Burp + +} // namespace Firebird::Burp #endif // BURP_TASKS_H diff --git a/src/burp/OdsDetection.epp b/src/burp/OdsDetection.epp index 2ca60361336..ce5a08d1244 100644 --- a/src/burp/OdsDetection.epp +++ b/src/burp/OdsDetection.epp @@ -27,6 +27,9 @@ #include "../burp/burp_proto.h" #include "../burp/OdsDetection.h" +namespace Firebird::Burp +{ + namespace { @@ -100,7 +103,7 @@ void detectRuntimeODS() // and rdb$field_name = 'RDB$SYSTEM_FLAG'; int count = 0; - Firebird::IRequest* req_handle = nullptr; + IRequest* req_handle = nullptr; FOR (REQUEST_HANDLE req_handle) RFR IN RDB$RELATION_FIELDS WITH (RFR.RDB$RELATION_NAME = 'RDB$RELATIONS' OR RFR.RDB$RELATION_NAME = 'RDB$RELATION_FIELDS') AND @@ -118,7 +121,7 @@ void detectRuntimeODS() if (count != 2) return; - Firebird::IRequest* req_handle2 = nullptr; + IRequest* req_handle2 = nullptr; for (const rel_field_t* rel = relations; rel->relation; ++rel) { FOR (REQUEST_HANDLE req_handle2) @@ -140,7 +143,7 @@ void detectRuntimeODS() if (tdgbl->runtimeODS < DB_VERSION_DDL8) return; - Firebird::IRequest* req_handle3 = nullptr; + IRequest* req_handle3 = nullptr; for (const rel_field_t* rf = rel_fields; rf->relation; ++rf) { FOR (REQUEST_HANDLE req_handle3) @@ -181,3 +184,6 @@ namespace BURP_abort(isc_status); } } + + +} // namespace Firebird::Burp diff --git a/src/burp/OdsDetection.h b/src/burp/OdsDetection.h index 4609ab16e27..92df1d75a1f 100644 --- a/src/burp/OdsDetection.h +++ b/src/burp/OdsDetection.h @@ -60,6 +60,10 @@ ASF: Engine that works with ODS11.1 and newer supports access to non-existent sy Reads return NULL and writes do nothing. */ +namespace Firebird::Burp +{ + + inline constexpr int DB_VERSION_DDL8 = 80; // ods8 db, IB4 inline constexpr int DB_VERSION_DDL9 = 90; // ods9 db, IB5 inline constexpr int DB_VERSION_DDL10 = 100; // ods10 db, IB6, FB1, FB1.5 @@ -75,4 +79,7 @@ inline constexpr int DB_VERSION_OLDEST_SUPPORTED = DB_VERSION_DDL8; // IB4.0 is void detectRuntimeODS(); + +} // namespace Firebird::Burp + #endif // BURP_ODSDETECTION_H diff --git a/src/burp/backu_proto.h b/src/burp/backu_proto.h index 80a6c030356..3045e4b6ddf 100644 --- a/src/burp/backu_proto.h +++ b/src/burp/backu_proto.h @@ -24,7 +24,9 @@ #ifndef BURP_BACKU_PROTO_H #define BURP_BACKU_PROTO_H -int BACKUP_backup (const TEXT*, const TEXT*); +namespace Firebird::Burp +{ + int BACKUP_backup (const TEXT*, const TEXT*); +} // namespace Firebird::Burp #endif // BURP_BACKU_PROTO_H - diff --git a/src/burp/backup.epp b/src/burp/backup.epp index f3df7267962..36c0676aecd 100644 --- a/src/burp/backup.epp +++ b/src/burp/backup.epp @@ -46,7 +46,7 @@ #include "../jrd/ods.h" #include "../jrd/align.h" #include "../common/gdsassert.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/stuff.h" #include "../burp/backu_proto.h" #include "../burp/burp_proto.h" @@ -62,9 +62,10 @@ #include "../burp/OdsDetection.h" #include "../burp/BurpTasks.h" +namespace Firebird::Burp +{ + using MsgFormat::SafeArg; -using namespace Firebird; -using namespace Burp; // For service APIs the follow DB handle is a value stored @@ -235,7 +236,7 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name) if (tdgbl->gbl_sw_ignore_limbo) { gds_trans = DB->startTransaction(&status_vector, sizeof(limbo_nau_tpb), limbo_nau_tpb); - if (status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (status_vector->getState() & IStatus::STATE_ERRORS) { gds_trans = DB->startTransaction(&status_vector, sizeof(limbo_tpb), limbo_tpb); } @@ -243,14 +244,14 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name) else { EXEC SQL SET TRANSACTION NO_AUTO_UNDO; - if (isc_status->getState() & Firebird::IStatus::STATE_ERRORS) + if (isc_status->getState() & IStatus::STATE_ERRORS) EXEC SQL SET TRANSACTION; } if (!gds_trans) { EXEC SQL SET TRANSACTION NAME gds_trans NO_AUTO_UNDO; - if (isc_status->getState() & Firebird::IStatus::STATE_ERRORS) + if (isc_status->getState() & IStatus::STATE_ERRORS) EXEC SQL SET TRANSACTION NAME gds_trans; } @@ -657,7 +658,7 @@ burp_fld* get_fields( burp_rel* relation) USHORT count = 1; - Firebird::HalfStaticArray field_list; + HalfStaticArray field_list; // if we have all capabilities, use the first request to get the // most performance out of the latest engine; if we don't @@ -933,15 +934,15 @@ SINT64 get_gen_id(const QualifiedMetaString& name) { BurpGlobals* tdgbl = BurpGlobals::getSpecific(); - Firebird::string sql; + string sql; sql.printf( "select first(1) gen_id(%s, 0) from %srdb$database", name.toQuotedString().c_str(), (tdgbl->runtimeODS >= DB_VERSION_DDL14 ? "system." : "")); BurpSql getGenerator(tdgbl, sql.c_str()); - FB_MESSAGE(GetGen, Firebird::ThrowWrapper, (FB_BIGINT, id)); - GetGen getGen(&tdgbl->throwStatus, Firebird::MasterInterfacePtr()); + FB_MESSAGE(GetGen, ThrowWrapper, (FB_BIGINT, id)); + GetGen getGen(&tdgbl->throwStatus, MasterInterfacePtr()); getGenerator.singleSelect(tdgbl->tr_handle, &getGen); return getGen->id; @@ -2342,7 +2343,7 @@ void write_character_sets() * each user defined character set. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2449,7 +2450,7 @@ void write_check_constraints() * each check constraint. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2489,7 +2490,7 @@ void write_collations() * each user defined collation * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2599,8 +2600,8 @@ void write_database( const TEXT* dbb_file) **************************************/ FbLocalStatus status_vector; UCHAR buffer[256]; - Firebird::IRequest* req_handle1 = nullptr; - Firebird::IRequest* req_handle2 = nullptr; + IRequest* req_handle1 = nullptr; + IRequest* req_handle2 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2763,7 +2764,7 @@ void write_exceptions() * each exception. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2845,7 +2846,7 @@ void write_field_dimensions() * each array field dimension. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2885,7 +2886,7 @@ void write_filters() * each filter. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -2926,7 +2927,7 @@ void write_functions() * each function. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3209,7 +3210,7 @@ void write_generators() * Write any defined generators. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3344,7 +3345,7 @@ void write_global_fields() * each global field. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3596,7 +3597,7 @@ void write_packages() * each package. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3670,7 +3671,7 @@ void write_procedures() * each stored procedure. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3885,7 +3886,7 @@ void write_publications() * each publication. * **************************************/ - Firebird::IRequest* req_handle = nullptr; + IRequest* req_handle = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3934,7 +3935,7 @@ void write_pub_tables() * **************************************/ QualifiedMetaString tableName; - Firebird::IRequest* req_handle = nullptr; + IRequest* req_handle = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -3981,7 +3982,7 @@ void write_ref_constraints() * each referential constraint. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4027,7 +4028,7 @@ void write_rel_constraints() * each relation constraint. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4083,7 +4084,7 @@ void write_relations() * each relation. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4280,7 +4281,7 @@ void write_schemas() void write_secclasses() { - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4316,7 +4317,7 @@ void write_shadow_files() * Write out files to use as shadows. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4358,7 +4359,7 @@ void write_sql_roles() * each SQL roles. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4424,7 +4425,7 @@ void write_mapping() * each names mapping. * **************************************/ - Firebird::IRequest* req_handle = nullptr; + IRequest* req_handle = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); if (tdgbl->runtimeODS >= DB_VERSION_DDL12) @@ -4504,7 +4505,7 @@ void write_db_creators() * each grant to create database. * **************************************/ - Firebird::IRequest* req_handle = nullptr; + IRequest* req_handle = nullptr; bool first = true; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4563,7 +4564,7 @@ void write_triggers() * write the triggers in rdb$triggers * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4691,7 +4692,7 @@ void write_trigger_messages() * each trigger message. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4744,7 +4745,7 @@ void write_types() * each type. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4786,7 +4787,7 @@ void write_user_privileges() * **************************************/ QualifiedMetaString user; - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); @@ -4833,8 +4834,6 @@ void write_user_privileges() } // namespace -namespace Burp { - /// class ReadRelationMeta void ReadRelationMeta::setRelation(const burp_rel* relation, bool partition) @@ -5222,4 +5221,5 @@ bool BackupRelationTask::tableReader(Item& item) return true; } -} // namespace Burp + +} // namespace Firebird::Burp diff --git a/src/burp/burp.cpp b/src/burp/burp.cpp index a1b7f4d4598..da35a523348 100644 --- a/src/burp/burp.cpp +++ b/src/burp/burp.cpp @@ -41,7 +41,7 @@ #include "../jrd/ibsetjmp.h" #include "../common/msg_encode.h" #include "../jrd/ods.h" // to get MAX_PAGE_SIZE -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../burp/burp.h" #include "../burp/std_desc.h" #include "../burp/split/spit.h" @@ -84,9 +84,11 @@ #include #endif -using namespace Firebird; +namespace Firebird::Burp +{ + using MsgFormat::SafeArg; -using namespace Burp; + inline constexpr const char* fopen_write_type = "w"; inline constexpr const char* fopen_read_type = "r"; @@ -105,18 +107,18 @@ enum gbak_action //FDESC = 3 // CVC: Unused }; -static void close_out_transaction(gbak_action, Firebird::ITransaction**); +static void close_out_transaction(gbak_action, ITransaction**); //static void enable_signals(); //static void excp_handler(); static SLONG get_number(const SCHAR*) noexcept; static ULONG get_size(const SCHAR*, burp_fil*); static gbak_action open_files(const TEXT *, const TEXT**, USHORT, - const Firebird::ClumpletWriter&); -static int svc_api_gbak(Firebird::UtilSvc*, const Switches& switches); + const ClumpletWriter&); +static int svc_api_gbak(UtilSvc*, const Switches& switches); static void burp_output(bool err, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3); static void burp_usage(const Switches& switches); -static Switches::in_sw_tab_t* findSwitchOrThrow(Firebird::UtilSvc*, Switches& switches, Firebird::string& sw); -static void processFetchPass(const SCHAR*& password, int& itr, const int argc, Firebird::UtilSvc::ArgvType& argv); +static Switches::in_sw_tab_t* findSwitchOrThrow(UtilSvc*, Switches& switches, string& sw); +static void processFetchPass(const SCHAR*& password, int& itr, const int argc, UtilSvc::ArgvType& argv); // fil.fil_length is FB_UINT64 @@ -140,7 +142,7 @@ static inline constexpr StatFormat STAT_FORMATS[] = {"writes", "%6" UQUADFORMAT" ", 7} }; -int BURP_main(Firebird::UtilSvc* uSvc) +int BURP_main(UtilSvc* uSvc) { /************************************** * @@ -157,9 +159,9 @@ int BURP_main(Firebird::UtilSvc* uSvc) try { exit_code = gbak(uSvc); } - catch (const Firebird::Exception& e) + catch (const Exception& e) { - Firebird::StaticStatusVector status; + StaticStatusVector status; e.stuffException(status); UtilSvc::StatusAccessor sa = uSvc->getStatusAccessor(); sa.init(); @@ -203,13 +205,13 @@ static unsigned int binIn(void* data, int len) int n = read(bin, data, len); if (n < 0) - Firebird::system_call_failed::raise("read(stdin)"); + system_call_failed::raise("read(stdin)"); return n; } -static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) +static int svc_api_gbak(UtilSvc* uSvc, const Switches& switches) { /********************************************** * @@ -221,7 +223,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) * Run gbak using services APIs * **********************************************/ - Firebird::string usr, pswd, service; + string usr, pswd, service; const SCHAR* pswd2 = NULL; bool flag_restore = false; bool flag_verbose = false; @@ -231,9 +233,9 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) bool flag_verbint = false; SLONG verbint_val = 0; - Firebird::UtilSvc::ArgvType& argv = uSvc->argv; + UtilSvc::ArgvType& argv = uSvc->argv; const int argc = uSvc->argv.getCount(); - Firebird::string files[2]; + string files[2]; unsigned fileIndex = 0; for (int itr = 1; itr < argc; ++itr) @@ -321,14 +323,14 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) } } - const Firebird::string* dbName = flag_restore ? &files[1] : &files[0]; + const string* dbName = flag_restore ? &files[1] : &files[0]; FbLocalStatus status; - Firebird::IService* svc_handle = nullptr; + IService* svc_handle = nullptr; try { - Firebird::ClumpletWriter spb(Firebird::ClumpletWriter::spbList, MAX_DPB_SIZE); + ClumpletWriter spb(ClumpletWriter::spbList, MAX_DPB_SIZE); // isc_spb_user_name // isc_spb_password @@ -355,20 +357,20 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) #endif // Fill command line options - Firebird::string options; + string options; for (int itr = 1; itr < argc; ++itr) { if (!argv[itr]) { continue; } - Firebird::UtilSvc::addStringWithSvcTrmntr(argv[itr], options); + UtilSvc::addStringWithSvcTrmntr(argv[itr], options); } options.rtrim(); spb.insertString(isc_spb_command_line, options); - svc_handle = Firebird::DispatcherPtr()->attachServiceManager(&status, service.c_str(), + svc_handle = DispatcherPtr()->attachServiceManager(&status, service.c_str(), spb.getBufferLength(), spb.getBuffer()); if (!status.isSuccess()) { @@ -413,7 +415,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) } // What are we going to receive from service manager - Firebird::ClumpletWriter receive(Firebird::ClumpletWriter::SpbReceiveItems, 16); + ClumpletWriter receive(ClumpletWriter::SpbReceiveItems, 16); receive.insertTag(flag_verbose ? isc_info_svc_line : isc_info_svc_to_eof); if (flag_restore) receive.insertTag(isc_info_svc_stdin); @@ -421,7 +423,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) unsigned int stdinRequest = 0; for (bool running = true; running;) { // Were we requested to send some data - Firebird::ClumpletWriter send(Firebird::ClumpletWriter::SpbSendItems, MAX_DPB_SIZE); + ClumpletWriter send(ClumpletWriter::SpbSendItems, MAX_DPB_SIZE); UCHAR respbuf[16384]; if (stdinRequest) { @@ -443,10 +445,10 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) return FINI_ERROR; } - Firebird::ClumpletReader resp(Firebird::ClumpletReader::SpbResponse, respbuf, sizeof(respbuf)); + ClumpletReader resp(ClumpletReader::SpbResponse, respbuf, sizeof(respbuf)); stdinRequest = 0; int len = 0; - Firebird::string line; + string line; bool not_ready = false; for (resp.rewind(); running && !resp.isEof(); resp.moveNext()) { @@ -483,7 +485,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) svc_handle->release(); return FINI_OK; } - catch (const Firebird::Exception& e) + catch (const Exception& e) { FbLocalStatus s; e.stuffException(&s); @@ -496,7 +498,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) } -static Switches::in_sw_tab_t* findSwitchOrThrow(Firebird::UtilSvc* uSvc, Switches& switches, Firebird::string& sw) +static Switches::in_sw_tab_t* findSwitchOrThrow(UtilSvc* uSvc, Switches& switches, string& sw) { /************************************** * @@ -536,7 +538,7 @@ static Switches::in_sw_tab_t* findSwitchOrThrow(Firebird::UtilSvc* uSvc, Switche } -int gbak(Firebird::UtilSvc* uSvc) +int gbak(UtilSvc* uSvc) { /************************************** * @@ -558,7 +560,7 @@ int gbak(Firebird::UtilSvc* uSvc) tdgbl->burp_throw = true; tdgbl->file_desc = INVALID_HANDLE_VALUE; - Firebird::UtilSvc::ArgvType& argv = uSvc->argv; + UtilSvc::ArgvType& argv = uSvc->argv; const int argc = uSvc->argv.getCount(); try @@ -605,11 +607,11 @@ int gbak(Firebird::UtilSvc* uSvc) bool verbint = false; bool noGarbage = false, ignoreDamaged = false, noDbTrig = false; bool transportableMentioned = false; - Firebird::string replicaMode; + string replicaMode; for (int itr = 1; itr < argc; ++itr) { - Firebird::string str = argv[itr]; + string str = argv[itr]; if (str.isEmpty()) { continue; @@ -656,7 +658,7 @@ int gbak(Firebird::UtilSvc* uSvc) if ((itr < argc - 1) && (*argv[itr + 1] != switch_char)) { // find optional BURP_SW_OVERWRITE parameter - Firebird::string next(argv[itr + 1]); + string next(argv[itr + 1]); next.upper(); if (strstr(BURP_SW_OVERWRITE, next.c_str()) == BURP_SW_OVERWRITE) { @@ -922,7 +924,7 @@ int gbak(Firebird::UtilSvc* uSvc) // msg 4 redirect location for output is not specified } - Firebird::string up(redirect); + string up(redirect); up.upper(); tdgbl->sw_redirect = (up == output_suppress) ? NOOUTPUT : REDIRECT; @@ -1140,7 +1142,7 @@ int gbak(Firebird::UtilSvc* uSvc) else if (!file2) file2 = file->fil_name.c_str(); - Firebird::PathName expanded; + PathName expanded; expandDatabaseName(file->fil_name, expanded, NULL); for (file_list = file->fil_next; file_list; @@ -1152,7 +1154,7 @@ int gbak(Firebird::UtilSvc* uSvc) // msg 9 mutiple sources or destinations specified } - Firebird::PathName expanded2; + PathName expanded2; expandDatabaseName(file_list->fil_name, expanded2, NULL); if (file->fil_name == expanded2 || expanded == expanded2) { @@ -1164,7 +1166,7 @@ int gbak(Firebird::UtilSvc* uSvc) } // Initialize 'dpb' - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); dpb.insertString(isc_dpb_gbak_attach, FB_VERSION, fb_strlen(FB_VERSION)); uSvc->fillDpb(dpb); @@ -1451,7 +1453,7 @@ int gbak(Firebird::UtilSvc* uSvc) BURP_exit_local(result, tdgbl); } // try - catch (const Firebird::LongJump&) + catch (const LongJump&) { // All calls to exit_local(), normal and error exits, wind up here tdgbl->burp_throw = false; @@ -1462,7 +1464,7 @@ int gbak(Firebird::UtilSvc* uSvc) exit_code = tdgbl->exit_code; } - catch (const Firebird::Exception& e) + catch (const Exception& e) { // Non-burp exception was caught tdgbl->burp_throw = false; @@ -1501,7 +1503,7 @@ int gbak(Firebird::UtilSvc* uSvc) tdgbl->db_handle->detach(&tdgbl->status_vector); - if (tdgbl->status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (tdgbl->status_vector->getState() & IStatus::STATE_ERRORS) BURP_print_status(true, &tdgbl->status_vector); else tdgbl->db_handle = NULL; @@ -1520,8 +1522,7 @@ int gbak(Firebird::UtilSvc* uSvc) } - -void BURP_abort(const Firebird::IStatus* status) +void BURP_abort(const IStatus* status) { /************************************** * @@ -1606,7 +1607,7 @@ void BURP_error(USHORT errcode, bool abort, const char* str) } -void BURP_error_redirect(const Firebird::IStatus* status_vector, USHORT errcode, const SafeArg& arg) +void BURP_error_redirect(const IStatus* status_vector, USHORT errcode, const SafeArg& arg) { /************************************** * @@ -1637,7 +1638,7 @@ void BURP_exit_local(int code, BurpGlobals* tdgbl) { tdgbl->exit_code = code; if (tdgbl->burp_throw) - throw Firebird::LongJump(); + throw LongJump(); } @@ -1698,7 +1699,7 @@ void BURP_msg_get(USHORT number, TEXT* output_msg, const SafeArg& arg) strcpy(output_msg, buffer); } -void OutputVersion::callback(Firebird::CheckStatusWrapper* status, const char* text) +void OutputVersion::callback(CheckStatusWrapper* status, const char* text) { /************************************** * @@ -1759,7 +1760,7 @@ void BURP_print(bool err, USHORT number, const char* str) } -void BURP_print_status(bool err, const Firebird::IStatus* status_vector, USHORT secondNumber) +void BURP_print_status(bool err, const IStatus* status_vector, USHORT secondNumber) { /************************************** * @@ -1814,7 +1815,7 @@ void BURP_print_status(bool err, const Firebird::IStatus* status_vector, USHORT } -void BURP_print_warning(const Firebird::IStatus* status, bool printErrorAsWarning) +void BURP_print_warning(const IStatus* status, bool printErrorAsWarning) { /************************************** * @@ -1924,7 +1925,7 @@ void BURP_verbose(USHORT number, const string& str) } -static void close_out_transaction(gbak_action action, Firebird::ITransaction** tPtr) +static void close_out_transaction(gbak_action action, ITransaction** tPtr) { /************************************** * @@ -2005,7 +2006,7 @@ static SLONG get_number(const SCHAR* string) noexcept static gbak_action open_files(const TEXT* file1, const TEXT** file2, USHORT sw_replace, - const Firebird::ClumpletWriter& dpb) + const ClumpletWriter& dpb) { /************************************** * @@ -2028,7 +2029,7 @@ static gbak_action open_files(const TEXT* file1, if (sw_replace != IN_SW_BURP_C && sw_replace != IN_SW_BURP_R) { - Firebird::DispatcherPtr provider; + DispatcherPtr provider; // provide crypt key(s) for engine @@ -2047,7 +2048,7 @@ static gbak_action open_files(const TEXT* file1, tdgbl->db_handle = provider->attachDatabase(&status_vector, file1, dpb.getBufferLength(), dpb.getBuffer()); - if (!(status_vector->getState() & Firebird::IStatus::STATE_ERRORS)) + if (!(status_vector->getState() & IStatus::STATE_ERRORS)) { if (sw_replace != IN_SW_BURP_B) { @@ -2055,7 +2056,7 @@ static gbak_action open_files(const TEXT* file1, BURP_error(13, true, file1); tdgbl->db_handle->detach(&status_vector); - if (status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (status_vector->getState() & IStatus::STATE_ERRORS) BURP_print_status(true, &status_vector); else tdgbl->db_handle = NULL; @@ -2067,7 +2068,7 @@ static gbak_action open_files(const TEXT* file1, // msg 139 Version(s) for database "%s" BURP_print(false, 139, file1); OutputVersion outputVersion("\t%s\n"); - Firebird::UtilInterfacePtr()->getFbVersion(&status_vector, tdgbl->db_handle, &outputVersion); + UtilInterfacePtr()->getFbVersion(&status_vector, tdgbl->db_handle, &outputVersion); } BURP_verbose(166, file1); // msg 166: readied database %s for backup @@ -2195,7 +2196,7 @@ static gbak_action open_files(const TEXT* file1, } else { - Firebird::string nm = tdgbl->toSystem(fil->fil_name); + string nm = tdgbl->toSystem(fil->fil_name); #ifdef WIN_NT if ((fil->fil_fd = NT_tape_open(nm.c_str(), MODE_WRITE, CREATE_ALWAYS)) == INVALID_HANDLE_VALUE) #else @@ -2244,7 +2245,7 @@ static gbak_action open_files(const TEXT* file1, { tdgbl->db_handle->detach(&status_vector); - if (status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (status_vector->getState() & IStatus::STATE_ERRORS) BURP_print_status(true, &status_vector); else tdgbl->db_handle = NULL; @@ -2305,7 +2306,7 @@ static gbak_action open_files(const TEXT* file1, tdgbl->stdIoMode = false; // open first file - Firebird::string nm = tdgbl->toSystem(fil->fil_name); + string nm = tdgbl->toSystem(fil->fil_name); #ifdef WIN_NT if ((fil->fil_fd = NT_tape_open(nm.c_str(), MODE_READ, OPEN_EXISTING)) == INVALID_HANDLE_VALUE) #else @@ -2351,7 +2352,7 @@ static gbak_action open_files(const TEXT* file1, return QUIT; } tdgbl->action->act_file = fil; - Firebird::string nm = tdgbl->toSystem(fil->fil_name); + string nm = tdgbl->toSystem(fil->fil_name); #ifdef WIN_NT if ((fil->fil_fd = NT_tape_open(nm.c_str(), MODE_READ, OPEN_EXISTING)) == INVALID_HANDLE_VALUE) #else @@ -2420,7 +2421,7 @@ static gbak_action open_files(const TEXT* file1, if (sw_replace == IN_SW_BURP_C || sw_replace == IN_SW_BURP_R) { - Firebird::DispatcherPtr provider; + DispatcherPtr provider; // provide crypt key(s) for engine @@ -2438,13 +2439,13 @@ static gbak_action open_files(const TEXT* file1, tdgbl->db_handle = provider->attachDatabase(&status_vector, *file2, dpb.getBufferLength(), dpb.getBuffer()); - if (!(status_vector->getState() & Firebird::IStatus::STATE_ERRORS)) + if (!(status_vector->getState() & IStatus::STATE_ERRORS)) { if (sw_replace == IN_SW_BURP_C) { tdgbl->db_handle->detach(&status_vector); - if (status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (status_vector->getState() & IStatus::STATE_ERRORS) BURP_print_status(true, &status_vector); else tdgbl->db_handle = NULL; @@ -2456,12 +2457,12 @@ static gbak_action open_files(const TEXT* file1, { tdgbl->db_handle->dropDatabase(&status_vector); - if (status_vector->getState() & Firebird::IStatus::STATE_ERRORS) + if (status_vector->getState() & IStatus::STATE_ERRORS) { - Firebird::FbLocalStatus status2; + FbLocalStatus status2; tdgbl->db_handle->detach(&status2); - if (status2->getState() & Firebird::IStatus::STATE_ERRORS) + if (status2->getState() & IStatus::STATE_ERRORS) BURP_print_status(true, &status2); else tdgbl->db_handle = NULL; @@ -2525,7 +2526,7 @@ static void burp_output(bool err, const SCHAR* format, ...) } else { - Firebird::string buf; + string buf; buf.vprintf(format, arglist); if (err) tdgbl->uSvc->outputError(buf.c_str()); @@ -2719,16 +2720,16 @@ void BurpGlobals::setupSkipIncludePattern(const string& regexp, USHORT alreadySe "\\", 1)); } } - catch (const Firebird::Exception&) + catch (const Exception&) { - Firebird::fatal_exception::raiseFmt( + fatal_exception::raiseFmt( "error while compiling regular expression \"%s\"", regexp.c_str()); } } -Firebird::string BurpGlobals::toSystem(const Firebird::PathName& from) +string BurpGlobals::toSystem(const PathName& from) { - Firebird::string to = from.ToString(); + string to = from.ToString(); if (uSvc->utf8FileNames()) ISC_utf8ToSystem(to); return to; @@ -2738,8 +2739,7 @@ namespace // for local symbols { enum Pattern { NOT_SET = 0, MATCH = 1, NOT_MATCH = 2 }; - Pattern checkPattern(Firebird::AutoPtr& matcher, - const char* name) + Pattern checkPattern(AutoPtr& matcher, const char* name) { if (!matcher) return NOT_SET; @@ -2888,7 +2888,7 @@ void BurpGlobals::print_stats_header() burp_output(false, "\n"); } -static void processFetchPass(const SCHAR*& password, int& itr, const int argc, Firebird::UtilSvc::ArgvType& argv) +static void processFetchPass(const SCHAR*& password, int& itr, const int argc, UtilSvc::ArgvType& argv) { if (++itr >= argc) { @@ -2919,3 +2919,5 @@ static void processFetchPass(const SCHAR*& password, int& itr, const int argc, F break; } } + +} // namespace Firebird::Burp diff --git a/src/burp/burp.h b/src/burp/burp.h index 3fb58a76b9e..4824648086b 100644 --- a/src/burp/burp.h +++ b/src/burp/burp.h @@ -68,6 +68,10 @@ //#define COMPRESS_DEBUG 1 #endif // WIRE_COMPRESS_SUPPORT +namespace Firebird::Burp +{ + + inline constexpr int GDS_NAME_LEN = METADATA_IDENTIFIER_CHAR_LEN * 4 /* max bytes per char */ + 1; typedef TEXT GDS_NAME[GDS_NAME_LEN]; @@ -747,7 +751,7 @@ struct burp_fld SSHORT fld_system_flag; SSHORT fld_name_length; TEXT fld_name [GDS_NAME_LEN]; - Firebird::QualifiedMetaString fld_source; + QualifiedMetaString fld_source; TEXT fld_base [GDS_NAME_LEN]; TEXT fld_query_name [GDS_NAME_LEN]; TEXT fld_security_class [GDS_NAME_LEN]; @@ -792,7 +796,7 @@ struct burp_rel burp_fld* rel_fields; SSHORT rel_flags; SSHORT rel_id; - Firebird::QualifiedMetaString rel_name; + QualifiedMetaString rel_name; GDS_NAME rel_owner; // relation owner, if not us ULONG rel_max_pp; // max pointer page sequence number }; @@ -806,7 +810,7 @@ enum burp_rel_flags_vals { struct burp_pkg { burp_pkg* pkg_next; - Firebird::QualifiedMetaString pkg_name; + QualifiedMetaString pkg_name; GDS_NAME pkg_owner; }; @@ -815,14 +819,14 @@ struct burp_pkg struct burp_prc { burp_prc* prc_next; - Firebird::QualifiedMetaString prc_name; + QualifiedMetaString prc_name; GDS_NAME prc_owner; // relation owner, if not us }; struct gfld { - Firebird::QualifiedMetaString gfld_name; + QualifiedMetaString gfld_name; ISC_QUAD gfld_vb; ISC_QUAD gfld_vs; ISC_QUAD gfld_vs2; @@ -847,7 +851,7 @@ struct burp_meta_obj { burp_meta_obj* obj_next; USHORT obj_type; - Firebird::QualifiedMetaString obj_name; + QualifiedMetaString obj_name; bool obj_class; }; @@ -908,13 +912,13 @@ class burp_fil { public: burp_fil* fil_next; - Firebird::PathName fil_name; + PathName fil_name; FB_UINT64 fil_length; DESC fil_fd; USHORT fil_seq; SIZE_CODE fil_size_code; -burp_fil(Firebird::MemoryPool& p) +burp_fil(MemoryPool& p) : fil_next(0), fil_name(p), fil_length(0), fil_fd(INVALID_HANDLE_VALUE), fil_seq(0), fil_size_code(size_n) { } }; @@ -976,9 +980,9 @@ class GblPool { private: // Moved it to separate class in order to ensure 'first create/last destroy' order - Firebird::MemoryPool* gbl_pool; + MemoryPool* gbl_pool; public: - Firebird::MemoryPool& getPool() + MemoryPool& getPool() { fb_assert(gbl_pool); return *gbl_pool; @@ -991,20 +995,17 @@ class GblPool ~GblPool() { if (gbl_pool != getDefaultMemoryPool()) - Firebird::MemoryPool::deletePool(gbl_pool); + MemoryPool::deletePool(gbl_pool); } }; // forward declarations -namespace Burp -{ - class BurpTaskItem; -}; +class BurpTaskItem; -class BurpGlobals : public Firebird::ThreadData, public GblPool +class BurpGlobals : public ThreadData, public GblPool { public: - explicit BurpGlobals(Firebird::UtilSvc* us) + explicit BurpGlobals(UtilSvc* us) : ThreadData(ThreadData::tddGBL), GblPool(us->isService()), gbl_sw_par_workers(1), @@ -1144,10 +1145,10 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool const TEXT* mvol_keyname; TEXT mvol_crypt_buffer[MAX_FILE_NAME_SIZE]; const TEXT* mvol_crypt; - TEXT gbl_key_hash[(Firebird::Sha1::HASH_SIZE + 1) * 4 / 3 + 1]; // take into an account base64 - Firebird::IAttachment* db_handle; - Firebird::ITransaction* tr_handle; - Firebird::ITransaction* global_trans; + TEXT gbl_key_hash[(Sha1::HASH_SIZE + 1) * 4 / 3 + 1]; // take into an account base64 + IAttachment* db_handle; + ITransaction* tr_handle; + ITransaction* global_trans; TraNumber tr_snapshot; DESC file_desc; int exit_code; @@ -1159,67 +1160,67 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool // burp_fld* v3_cvt_fld_list; // The handles_get... are for restore. - Firebird::IRequest* handles_get_character_sets_req_handle1; - Firebird::IRequest* handles_get_chk_constraint_req_handle1; - Firebird::IRequest* handles_get_collation_req_handle1; - Firebird::IRequest* handles_get_db_creators_req_handle1; - Firebird::IRequest* handles_get_exception_req_handle1; - Firebird::IRequest* handles_get_field_dimensions_req_handle1; - Firebird::IRequest* handles_get_field_req_handle1; - Firebird::IRequest* handles_get_fields_req_handle1; - Firebird::IRequest* handles_get_fields_req_handle2; - Firebird::IRequest* handles_get_fields_req_handle3; - Firebird::IRequest* handles_get_fields_req_handle4; - Firebird::IRequest* handles_get_fields_req_handle5; - Firebird::IRequest* handles_get_fields_req_handle6; - Firebird::IRequest* handles_get_files_req_handle1; - Firebird::IRequest* handles_get_filter_req_handle1; - Firebird::IRequest* handles_get_function_arg_req_handle1; - Firebird::IRequest* handles_get_function_req_handle1; - Firebird::IRequest* handles_get_global_field_req_handle1; - Firebird::IRequest* handles_get_index_req_handle1; - Firebird::IRequest* handles_get_index_req_handle2; - Firebird::IRequest* handles_get_index_req_handle3; - Firebird::IRequest* handles_get_index_req_handle4; - Firebird::IRequest* handles_get_mapping_req_handle1; - Firebird::IRequest* handles_get_package_req_handle1; - Firebird::IRequest* handles_get_procedure_prm_req_handle1; - Firebird::IRequest* handles_get_procedure_req_handle1; - Firebird::IRequest* handles_get_pub_req_handle1; - Firebird::IRequest* handles_get_pub_tab_req_handle1; - Firebird::IRequest* handles_get_ranges_req_handle1; - Firebird::IRequest* handles_get_ref_constraint_req_handle1; - Firebird::IRequest* handles_get_rel_constraint_req_handle1; - Firebird::IRequest* handles_get_relation_req_handle1; - Firebird::IRequest* handles_get_schema_req_handle1; - Firebird::IRequest* handles_get_security_class_req_handle1; - Firebird::IRequest* handles_get_sql_roles_req_handle1; - Firebird::IRequest* handles_get_trigger_message_req_handle1; - Firebird::IRequest* handles_get_trigger_message_req_handle2; - Firebird::IRequest* handles_get_trigger_old_req_handle1; - Firebird::IRequest* handles_get_trigger_req_handle1; - Firebird::IRequest* handles_get_trigger_req_handle2; - Firebird::IRequest* handles_get_type_req_handle1; - Firebird::IRequest* handles_get_user_privilege_req_handle1; - Firebird::IRequest* handles_get_view_req_handle1; - Firebird::IRequest* handles_activateIndex_req_handle1; + IRequest* handles_get_character_sets_req_handle1; + IRequest* handles_get_chk_constraint_req_handle1; + IRequest* handles_get_collation_req_handle1; + IRequest* handles_get_db_creators_req_handle1; + IRequest* handles_get_exception_req_handle1; + IRequest* handles_get_field_dimensions_req_handle1; + IRequest* handles_get_field_req_handle1; + IRequest* handles_get_fields_req_handle1; + IRequest* handles_get_fields_req_handle2; + IRequest* handles_get_fields_req_handle3; + IRequest* handles_get_fields_req_handle4; + IRequest* handles_get_fields_req_handle5; + IRequest* handles_get_fields_req_handle6; + IRequest* handles_get_files_req_handle1; + IRequest* handles_get_filter_req_handle1; + IRequest* handles_get_function_arg_req_handle1; + IRequest* handles_get_function_req_handle1; + IRequest* handles_get_global_field_req_handle1; + IRequest* handles_get_index_req_handle1; + IRequest* handles_get_index_req_handle2; + IRequest* handles_get_index_req_handle3; + IRequest* handles_get_index_req_handle4; + IRequest* handles_get_mapping_req_handle1; + IRequest* handles_get_package_req_handle1; + IRequest* handles_get_procedure_prm_req_handle1; + IRequest* handles_get_procedure_req_handle1; + IRequest* handles_get_pub_req_handle1; + IRequest* handles_get_pub_tab_req_handle1; + IRequest* handles_get_ranges_req_handle1; + IRequest* handles_get_ref_constraint_req_handle1; + IRequest* handles_get_rel_constraint_req_handle1; + IRequest* handles_get_relation_req_handle1; + IRequest* handles_get_schema_req_handle1; + IRequest* handles_get_security_class_req_handle1; + IRequest* handles_get_sql_roles_req_handle1; + IRequest* handles_get_trigger_message_req_handle1; + IRequest* handles_get_trigger_message_req_handle2; + IRequest* handles_get_trigger_old_req_handle1; + IRequest* handles_get_trigger_req_handle1; + IRequest* handles_get_trigger_req_handle2; + IRequest* handles_get_type_req_handle1; + IRequest* handles_get_user_privilege_req_handle1; + IRequest* handles_get_view_req_handle1; + IRequest* handles_activateIndex_req_handle1; // The handles_put.. are for backup. - Firebird::IRequest* handles_put_index_req_handle1; - Firebird::IRequest* handles_put_index_req_handle2; - Firebird::IRequest* handles_put_index_req_handle3; - Firebird::IRequest* handles_put_index_req_handle4; - Firebird::IRequest* handles_put_index_req_handle5; - Firebird::IRequest* handles_put_index_req_handle6; - Firebird::IRequest* handles_put_index_req_handle7; - Firebird::IRequest* handles_put_relation_req_handle1; - Firebird::IRequest* handles_put_relation_req_handle2; - Firebird::IRequest* handles_put_relation_req_handle3; - Firebird::IRequest* handles_store_blr_gen_id_req_handle1; - Firebird::IRequest* handles_write_function_args_req_handle1; - Firebird::IRequest* handles_write_function_args_req_handle2; - Firebird::IRequest* handles_write_procedure_prms_req_handle1; - Firebird::IRequest* handles_fix_security_class_name_req_handle1; + IRequest* handles_put_index_req_handle1; + IRequest* handles_put_index_req_handle2; + IRequest* handles_put_index_req_handle3; + IRequest* handles_put_index_req_handle4; + IRequest* handles_put_index_req_handle5; + IRequest* handles_put_index_req_handle6; + IRequest* handles_put_index_req_handle7; + IRequest* handles_put_relation_req_handle1; + IRequest* handles_put_relation_req_handle2; + IRequest* handles_put_relation_req_handle3; + IRequest* handles_store_blr_gen_id_req_handle1; + IRequest* handles_write_function_args_req_handle1; + IRequest* handles_write_function_args_req_handle2; + IRequest* handles_write_procedure_prms_req_handle1; + IRequest* handles_fix_security_class_name_req_handle1; bool hdr_forced_writes; TEXT database_security_class[GDS_NAME_LEN]; // To save database security class for deferred update @@ -1237,34 +1238,34 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool { ThreadData::restoreSpecific(); } - void setupSkipIncludePattern(const Firebird::string& regexp, USHORT alreadySetErrorCode, - Firebird::AutoPtr& matcher); - bool skipRelation(const Firebird::QualifiedMetaString& name); + void setupSkipIncludePattern(const string& regexp, USHORT alreadySetErrorCode, + AutoPtr& matcher); + bool skipRelation(const QualifiedMetaString& name); char veryEnd; //starting after this members must be initialized in constructor explicitly - Firebird::FbLocalStatus status_vector; - Firebird::ThrowLocalStatus throwStatus; + FbLocalStatus status_vector; + ThrowLocalStatus throwStatus; - Firebird::NonPooledMap defaultCollations; - Firebird::SortedArray systemFields; - Firebird::Array gbl_dpb_data; - Firebird::UtilSvc* uSvc; + NonPooledMap defaultCollations; + SortedArray systemFields; + Array gbl_dpb_data; + UtilSvc* uSvc; bool master; // set for master thread only - Burp::BurpTaskItem* taskItem; // current task item, if any. + BurpTaskItem* taskItem; // current task item, if any. ULONG verboseInterval; // How many records should be backed up or restored before we show this message bool flag_on_line; // indicates whether we will bring the database on-line bool firstMap; // this is the first time we entered get_mapping() bool firstDbc; // this is the first time we entered get_db_creators() bool stdIoMode; // stdin or stdout is used as backup file - Firebird::AutoPtr skipSchemaDataMatcher; - Firebird::AutoPtr skipDataMatcher; - Firebird::AutoPtr includeSchemaDataMatcher; - Firebird::AutoPtr includeDataMatcher; + AutoPtr skipSchemaDataMatcher; + AutoPtr skipDataMatcher; + AutoPtr includeSchemaDataMatcher; + AutoPtr includeDataMatcher; public: - Firebird::string toSystem(const Firebird::PathName& from); + string toSystem(const PathName& from); enum StatCounter { TIME_TOTAL = 0, TIME_DELTA, READS, WRITES, LAST_COUNTER}; @@ -1327,13 +1328,13 @@ enum burp_messages_vals { }; // BLOB buffer -typedef Firebird::HalfStaticArray BlobBuffer; +typedef HalfStaticArray BlobBuffer; -class BurpSql : public Firebird::AutoStorage +class BurpSql : public AutoStorage { public: BurpSql(BurpGlobals* g, const char* sql) - : Firebird::AutoStorage(), + : AutoStorage(), tdgbl(g), stmt(nullptr) { stmt = tdgbl->db_handle->prepare(&tdgbl->throwStatus, tdgbl->tr_handle, 0, sql, 3, 0); @@ -1349,35 +1350,35 @@ class BurpSql : public Firebird::AutoStorage } template - void singleSelect(Firebird::ITransaction* trans, M* msg) + void singleSelect(ITransaction* trans, M* msg) { stmt->execute(&tdgbl->throwStatus, tdgbl->tr_handle, nullptr, nullptr, msg->getMetadata(), msg->getData()); } template - void execute(Firebird::ITransaction* trans, M* msg) + void execute(ITransaction* trans, M* msg) { stmt->execute(&tdgbl->throwStatus, tdgbl->tr_handle, msg->getMetadata(), msg->getData(), nullptr, nullptr); } - void execute(Firebird::ITransaction* trans) + void execute(ITransaction* trans) { stmt->execute(&tdgbl->throwStatus, tdgbl->tr_handle, nullptr, nullptr, nullptr, nullptr); } private: BurpGlobals* tdgbl; - Firebird::IStatement* stmt; + IStatement* stmt; }; -class OutputVersion : public Firebird::IVersionCallbackImpl +class OutputVersion : public IVersionCallbackImpl { public: OutputVersion(const char* printFormat) : format(printFormat) { } - void callback(Firebird::CheckStatusWrapper* status, const char* text); + void callback(CheckStatusWrapper* status, const char* text); private: const char* format; @@ -1400,4 +1401,7 @@ static inline void BURP_free(void* block) noexcept MemoryPool::globalFree(block); } + +} // namespace Firebird::Burp + #endif // BURP_BURP_H diff --git a/src/burp/burp_proto.h b/src/burp/burp_proto.h index ad9814ee029..a877711be7a 100644 --- a/src/burp/burp_proto.h +++ b/src/burp/burp_proto.h @@ -29,25 +29,26 @@ #include "../common/classes/fb_string.h" #include "../common/UtilSvc.h" -class BurpGlobals; +namespace Firebird::Burp +{ + int BURP_main(UtilSvc*); + int gbak(UtilSvc*); -int BURP_main(Firebird::UtilSvc*); -int gbak(Firebird::UtilSvc*); - -void BURP_abort(const Firebird::IStatus* status = nullptr); -void BURP_error(USHORT, bool, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_error(USHORT, bool, const char* str); -void BURP_error_redirect(const Firebird::IStatus*, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_msg_partial(bool, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_msg_put(bool, USHORT, const MsgFormat::SafeArg& arg); -inline constexpr int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function. -void BURP_msg_get(USHORT, TEXT*, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_print(bool err, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_print(bool err, USHORT, const char* str); -void BURP_print_status(bool err, const Firebird::IStatus* status, USHORT secondNumber = 0); -void BURP_print_warning(const Firebird::IStatus* status, bool printErrorAsWarning = false); -void BURP_verbose(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); -void BURP_verbose(USHORT, const Firebird::string& str); -void BURP_message(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg(), bool totals = false); + void BURP_abort(const IStatus* status = nullptr); + void BURP_error(USHORT, bool, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_error(USHORT, bool, const char* str); + void BURP_error_redirect(const IStatus*, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_msg_partial(bool, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_msg_put(bool, USHORT, const MsgFormat::SafeArg& arg); + inline constexpr int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function. + void BURP_msg_get(USHORT, TEXT*, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_print(bool err, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_print(bool err, USHORT, const char* str); + void BURP_print_status(bool err, const IStatus* status, USHORT secondNumber = 0); + void BURP_print_warning(const IStatus* status, bool printErrorAsWarning = false); + void BURP_verbose(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); + void BURP_verbose(USHORT, const string& str); + void BURP_message(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg(), bool totals = false); +} // namespace Firebird::Burp #endif // BURP_BURP_PROTO_H diff --git a/src/burp/burpswi.h b/src/burp/burpswi.h index b9955aa7485..a770462b571 100644 --- a/src/burp/burpswi.h +++ b/src/burp/burpswi.h @@ -27,9 +27,13 @@ #ifndef BURP_BURPSWI_H #define BURP_BURPSWI_H -#include "../jrd/constants.h" +#include "../common/constants.h" #include "ibase.h" +namespace Firebird::Burp +{ + + /* Local copies of global variables. They will be copied into a data structure. */ @@ -247,5 +251,6 @@ static inline constexpr const char* burp_repl_mode_sw_table[] = }; -#endif // BURP_BURP_H +} // namespace Firebird::Burp +#endif // BURP_BURP_H diff --git a/src/burp/canon_proto.h b/src/burp/canon_proto.h index f41e68ccbc8..73acd1b0a40 100644 --- a/src/burp/canon_proto.h +++ b/src/burp/canon_proto.h @@ -24,8 +24,10 @@ #ifndef BURP_CANON_PROTO_H #define BURP_CANON_PROTO_H -ULONG CAN_encode_decode (burp_rel* relation, lstring* buffer, UCHAR* data, bool direction, bool useMissingOffset = false); -ULONG CAN_slice (lstring* buffer, lstring* slice, bool direction, UCHAR* sdl); +namespace Firebird::Burp +{ + ULONG CAN_encode_decode (burp_rel* relation, lstring* buffer, UCHAR* data, bool direction, bool useMissingOffset = false); + ULONG CAN_slice (lstring* buffer, lstring* slice, bool direction, UCHAR* sdl); +} // namespace Firebird::Burp #endif // BURP_CANON_PROTO_H - diff --git a/src/burp/canonical.cpp b/src/burp/canonical.cpp index ebc50354ea4..9d1d3b9e9b7 100644 --- a/src/burp/canonical.cpp +++ b/src/burp/canonical.cpp @@ -45,8 +45,9 @@ #include "../common/status.h" #include "fb_types.h" +namespace Firebird::Burp +{ -using Firebird::FbLocalStatus; struct BurpXdr : public xdr_t { @@ -177,17 +178,17 @@ ULONG CAN_encode_decode(burp_rel* relation, lstring* buffer, UCHAR* data, bool d break; case dtype_dec64: - if (!xdr_dec64(xdrs, (Firebird::Decimal64*) p)) + if (!xdr_dec64(xdrs, (Decimal64*) p)) return FALSE; break; case dtype_dec128: - if (!xdr_dec128(xdrs, (Firebird::Decimal128*) p)) + if (!xdr_dec128(xdrs, (Decimal128*) p)) return FALSE; break; case dtype_int128: - if (!xdr_int128(xdrs, (Firebird::Int128*) p)) + if (!xdr_int128(xdrs, (Int128*) p)) return FALSE; break; @@ -483,3 +484,6 @@ static bool_t xdr_slice(BurpXdr* xdrs, lstring* slice, /*USHORT sdl_length,*/ co return TRUE; } + + +} // namespace Firebird::Burp diff --git a/src/burp/main/burpMain.cpp b/src/burp/main/burpMain.cpp index 8a013529d85..5b029201204 100644 --- a/src/burp/main/burpMain.cpp +++ b/src/burp/main/burpMain.cpp @@ -35,6 +35,8 @@ #include #endif +using namespace Firebird; + static void atexit_fb_shutdown() { fb_shutdown(0, fb_shutrsn_app_stopped); @@ -60,12 +62,12 @@ int CLIB_ROUTINE main(int argc, char* argv[]) try { - Firebird::AutoPtr uSvc(Firebird::UtilSvc::createStandalone(argc, argv)); - return gbak(uSvc); + AutoPtr uSvc(UtilSvc::createStandalone(argc, argv)); + return Burp::gbak(uSvc); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { - Firebird::StaticStatusVector st; + StaticStatusVector st; ex.stuffException(st); isc_print_status(st.begin()); } diff --git a/src/burp/misc.cpp b/src/burp/misc.cpp index 66e0053ea0f..ae657538768 100644 --- a/src/burp/misc.cpp +++ b/src/burp/misc.cpp @@ -31,12 +31,15 @@ #include "../burp/burp_proto.h" #include "../burp/misc_proto.h" +namespace Firebird::Burp +{ + // Since this code appears everywhere, it makes more sense to isolate it // in a function visible to all gbak components. // Given a request, if it's non-zero (compiled), deallocate it but // without caring about a possible error. -void MISC_release_request_silent(Firebird::IRequest*& req_handle) +void MISC_release_request_silent(IRequest*& req_handle) { if (req_handle) { @@ -112,3 +115,6 @@ void MISC_terminate(const TEXT* from, TEXT* to, ULONG length, ULONG max_length) *--to = '\0'; } } + + +} // namespace Firebird::Burp diff --git a/src/burp/misc_proto.h b/src/burp/misc_proto.h index 1bba3073fe9..1ca57a8094c 100644 --- a/src/burp/misc_proto.h +++ b/src/burp/misc_proto.h @@ -24,9 +24,11 @@ #ifndef BURP_MISC_PROTO_H #define BURP_MISC_PROTO_H -void MISC_release_request_silent(Firebird::IRequest*& req_handle); -int MISC_symbol_length(const TEXT*, ULONG); -void MISC_terminate(const TEXT*, TEXT*, ULONG, ULONG); +namespace Firebird::Burp +{ + void MISC_release_request_silent(IRequest*& req_handle); + int MISC_symbol_length(const TEXT*, ULONG); + void MISC_terminate(const TEXT*, TEXT*, ULONG, ULONG); +} // namespace Firebird::Burp #endif // BURP_MISC_PROTO_H - diff --git a/src/burp/mvol.cpp b/src/burp/mvol.cpp index 33b9f191839..b23113fbc84 100644 --- a/src/burp/mvol.cpp +++ b/src/burp/mvol.cpp @@ -68,9 +68,11 @@ #include "../common/status.h" #include "../common/classes/zip.h" +namespace Firebird::Burp +{ + using MsgFormat::SafeArg; -using Firebird::FbLocalStatus; -using namespace Burp; + inline constexpr int open_mask = 0666; @@ -112,7 +114,7 @@ static UCHAR debug_on = 0; // able to turn this on in debug mode #endif #ifdef HAVE_ZLIB_H -static Firebird::InitInstance zlib; +static InitInstance zlib; #endif // HAVE_ZLIB_H static void bad_attribute(int, USHORT); @@ -134,7 +136,7 @@ static ULONG unzip_read_block(BurpGlobals*, UCHAR*, FB_SIZE_T); // Portion of data passed to crypt plugin inline constexpr ULONG CRYPT_STEP = 256; -class DbInfo final : public Firebird::RefCntIface > +class DbInfo final : public RefCntIface> { public: DbInfo(BurpGlobals* bg) @@ -142,7 +144,7 @@ class DbInfo final : public Firebird::RefCntIfacegbl_database_file_name; } @@ -161,22 +163,22 @@ struct BurpCrypt ~BurpCrypt() { if (crypt_plugin) - Firebird::PluginManagerInterfacePtr()->releasePlugin(crypt_plugin); + PluginManagerInterfacePtr()->releasePlugin(crypt_plugin); if (holder_plugin) - Firebird::PluginManagerInterfacePtr()->releasePlugin(holder_plugin); + PluginManagerInterfacePtr()->releasePlugin(holder_plugin); } - Firebird::IDbCryptPlugin* crypt_plugin; - Firebird::RefPtr db_info; - Firebird::IKeyHolderPlugin* holder_plugin; - Firebird::ICryptKeyCallback* crypt_callback; + IDbCryptPlugin* crypt_plugin; + RefPtr db_info; + IKeyHolderPlugin* holder_plugin; + ICryptKeyCallback* crypt_callback; }; //____________________________________________________________ // // -static void calc_hash(Firebird::string& valid, Firebird::IDbCryptPlugin* plugin) +static void calc_hash(string& valid, IDbCryptPlugin* plugin) { // crypt verifier const char* sample = "0123456789ABCDEF"; @@ -187,30 +189,30 @@ static void calc_hash(Firebird::string& valid, Firebird::IDbCryptPlugin* plugin) check(&sv); // calculate its hash - const Firebird::string verifier(result, sizeof(result)); - Firebird::Sha1::hashBased64(valid, verifier); + const string verifier(result, sizeof(result)); + Sha1::hashBased64(valid, verifier); } //____________________________________________________________ // // -static Firebird::IKeyHolderPlugin* mvol_get_holder(BurpGlobals* tdgbl, Firebird::RefPtr& config) +static IKeyHolderPlugin* mvol_get_holder(BurpGlobals* tdgbl, RefPtr& config) { fb_assert(tdgbl->gbl_sw_keyholder); if (!tdgbl->gbl_crypt) { - Firebird::GetPlugins - keyControl(Firebird::IPluginManager::TYPE_KEY_HOLDER, config, tdgbl->gbl_sw_keyholder); + GetPlugins + keyControl(IPluginManager::TYPE_KEY_HOLDER, config, tdgbl->gbl_sw_keyholder); if (!keyControl.hasData()) - (Firebird::Arg::Gds(isc_no_keyholder_plugin) << tdgbl->gbl_sw_keyholder).raise(); + (Arg::Gds(isc_no_keyholder_plugin) << tdgbl->gbl_sw_keyholder).raise(); BurpCrypt* g = tdgbl->gbl_crypt = FB_NEW_POOL(tdgbl->getPool()) BurpCrypt; g->holder_plugin = keyControl.plugin(); g->holder_plugin->addRef(); // Also do not forget about keys from services manager - Firebird::ICryptKeyCallback* cb = tdgbl->uSvc->getCryptCallback(); + ICryptKeyCallback* cb = tdgbl->uSvc->getCryptCallback(); if (cb) g->holder_plugin->keyCallback(&tdgbl->throwStatus, cb); } @@ -221,15 +223,15 @@ static Firebird::IKeyHolderPlugin* mvol_get_holder(BurpGlobals* tdgbl, Firebird: //____________________________________________________________ // // -Firebird::ICryptKeyCallback* MVOL_get_crypt(BurpGlobals* tdgbl) +ICryptKeyCallback* MVOL_get_crypt(BurpGlobals* tdgbl) { fb_assert(tdgbl->gbl_sw_keyholder); if (!tdgbl->gbl_crypt) { // Get per-DB config - Firebird::PathName dummy; - Firebird::RefPtr config; + PathName dummy; + RefPtr config; expandDatabaseName(tdgbl->gbl_database_file_name, dummy, &config); mvol_get_holder(tdgbl, config); @@ -259,12 +261,12 @@ static void start_crypt(BurpGlobals* tdgbl) FbLocalStatus status; // Get per-DB config - Firebird::PathName dummy; - Firebird::RefPtr config; + PathName dummy; + RefPtr config; expandDatabaseName(tdgbl->gbl_database_file_name, dummy, &config); // Prepare key holders - Firebird::IKeyHolderPlugin* keyHolder = mvol_get_holder(tdgbl, config); + IKeyHolderPlugin* keyHolder = mvol_get_holder(tdgbl, config); // Load crypt plugin if (!tdgbl->mvol_crypt) @@ -272,19 +274,19 @@ static void start_crypt(BurpGlobals* tdgbl) if (!tdgbl->mvol_crypt) BURP_error(378, true); - Firebird::GetPlugins - cryptControl(Firebird::IPluginManager::TYPE_DB_CRYPT, config, tdgbl->mvol_crypt); + GetPlugins + cryptControl(IPluginManager::TYPE_DB_CRYPT, config, tdgbl->mvol_crypt); if (!cryptControl.hasData()) - (Firebird::Arg::Gds(isc_no_crypt_plugin) << tdgbl->mvol_crypt).raise(); + (Arg::Gds(isc_no_crypt_plugin) << tdgbl->mvol_crypt).raise(); - Firebird::RefPtr dbInfo(FB_NEW DbInfo(tdgbl)); - Firebird::IDbCryptPlugin* p = cryptControl.plugin(); + RefPtr dbInfo(FB_NEW DbInfo(tdgbl)); + IDbCryptPlugin* p = cryptControl.plugin(); p->setInfo(&status, dbInfo); if (!status.isSuccess()) { const ISC_STATUS* v = status->getErrors(); if (v[0] == isc_arg_gds && v[1] != isc_arg_end && v[1] != isc_interface_version_too_old) - Firebird::status_exception::raise(&status); + status_exception::raise(&status); } // Initialize key in crypt plugin @@ -294,10 +296,10 @@ static void start_crypt(BurpGlobals* tdgbl) // Validate hash if (tdgbl->gbl_key_hash[0]) { - Firebird::string hash; + string hash; calc_hash(hash, p); if (hash != tdgbl->gbl_key_hash) - (Firebird::Arg::Gds(isc_bad_crypt_key) << tdgbl->mvol_keyname).raise(); + (Arg::Gds(isc_bad_crypt_key) << tdgbl->mvol_keyname).raise(); } // crypt plugin is ready @@ -485,7 +487,7 @@ static ULONG unzip_read_block(BurpGlobals* tdgbl, UCHAR* buffer, FB_SIZE_T buffe return buffer_length - strm.avail_out; #else - (Firebird::Arg::Gds(isc_random) << "No inflate support").raise(); + (Arg::Gds(isc_random) << "No inflate support").raise(); #endif } @@ -550,7 +552,7 @@ static void zip_write_block(BurpGlobals* tdgbl, const UCHAR* buffer, FB_SIZE_T b } } #else - (Firebird::Arg::Gds(isc_random) << "No deflate support").raise(); + (Arg::Gds(isc_random) << "No deflate support").raise(); #endif } @@ -682,8 +684,8 @@ static void checkCompression() #ifdef HAVE_ZLIB_H if (!zlib()) { - (Firebird::Arg::Gds(isc_random) << "Compession support library not loaded" << - Firebird::Arg::StatusVector(zlib().status)).raise(); + (Arg::Gds(isc_random) << "Compession support library not loaded" << + Arg::StatusVector(zlib().status)).raise(); } #endif } @@ -707,8 +709,8 @@ void MVOL_init_read(const char* file_name, USHORT* format) #ifdef HAVE_ZLIB_H z_stream& strm = tdgbl->gbl_stream; - strm.zalloc = Firebird::ZLib::allocFunc; - strm.zfree = Firebird::ZLib::freeFunc; + strm.zalloc = ZLib::allocFunc; + strm.zfree = ZLib::freeFunc; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; @@ -779,8 +781,8 @@ void MVOL_init_write(const char* file_name) { z_stream& strm = tdgbl->gbl_stream; - strm.zalloc = Firebird::ZLib::allocFunc; - strm.zfree = Firebird::ZLib::freeFunc; + strm.zalloc = ZLib::allocFunc; + strm.zfree = ZLib::freeFunc; strm.opaque = Z_NULL; checkCompression(); int ret = zlib().deflateInit(&strm, Z_DEFAULT_COMPRESSION); @@ -2039,7 +2041,7 @@ static bool write_header(DESC handle, ULONG backup_buffer_size, bool full_buffer { start_crypt(tdgbl); fb_assert(tdgbl->gbl_crypt && tdgbl->gbl_crypt->crypt_plugin); - Firebird::string hash; + string hash; calc_hash(hash, tdgbl->gbl_crypt->crypt_plugin); put_asciz(att_backup_hash, hash.c_str()); } @@ -2118,7 +2120,7 @@ bool MVOL_split_hdr_write() time_t seconds = time(NULL); - Firebird::string nm = tdgbl->toSystem(tdgbl->action->act_file->fil_name); + string nm = tdgbl->toSystem(tdgbl->action->act_file->fil_name); snprintf(buffer, sizeof(buffer), "%s%.24s , file No. %4d of %4d, %-27.27s", HDR_SPLIT_TAG, ctime(&seconds), tdgbl->action->act_file->fil_seq, tdgbl->action->act_total, nm.c_str()); @@ -2179,3 +2181,6 @@ bool MVOL_split_hdr_read() return false; } + + +} // namespace Firebird::Burp diff --git a/src/burp/mvol_proto.h b/src/burp/mvol_proto.h index 2ea1c805a17..716b6a7490a 100644 --- a/src/burp/mvol_proto.h +++ b/src/burp/mvol_proto.h @@ -27,6 +27,10 @@ #include "firebird/Interface.h" #include "std_desc.h" +namespace Firebird::Burp +{ + + class BurpGlobals; FB_UINT64 MVOL_fini_read(); @@ -41,12 +45,13 @@ UCHAR* MVOL_read_block(BurpGlobals*, UCHAR*, ULONG); void MVOL_skip_block(BurpGlobals*, ULONG); void MVOL_write(BurpGlobals*); const UCHAR* MVOL_write_block(BurpGlobals*, const UCHAR*, ULONG); -Firebird::ICryptKeyCallback* MVOL_get_crypt(BurpGlobals*); +ICryptKeyCallback* MVOL_get_crypt(BurpGlobals*); #if defined WIN_NT DESC NT_tape_open(const char*, ULONG, ULONG); #endif -#endif // BURP_MVOL_PROTO_H +} // namespace Firebird::Burp +#endif // BURP_MVOL_PROTO_H diff --git a/src/burp/resto_proto.h b/src/burp/resto_proto.h index 97196554bb0..61b7bd2505d 100644 --- a/src/burp/resto_proto.h +++ b/src/burp/resto_proto.h @@ -24,7 +24,9 @@ #ifndef BURP_RESTO_PROTO_H #define BURP_RESTO_PROTO_H -int RESTORE_restore(const TEXT*, const TEXT*); +namespace Firebird::Burp +{ + int RESTORE_restore(const TEXT*, const TEXT*); +} // namespace Firebird::Burp #endif // BURP_RESTO_PROTO_H - diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 1108459d14d..a08326c2aec 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -39,7 +39,7 @@ #include "../jrd/align.h" #include "../jrd/flags.h" #include "../jrd/license.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/ods.h" #include "../common/stuff.h" #include "../burp/burp_proto.h" @@ -49,7 +49,7 @@ #include "../burp/resto_proto.h" #include "../burp/BurpTasks.h" #include "../common/gdsassert.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../remote/protocol.h" #ifdef DEBUG #include "../common/prett_proto.h" @@ -66,9 +66,10 @@ #include "../common/msg_encode.h" #include "../common/classes/BatchCompletionState.h" +namespace Firebird::Burp +{ + using MsgFormat::SafeArg; -using namespace Firebird; -using namespace Burp; // For service APIs the follow DB handle is a value stored @@ -109,10 +110,10 @@ enum scan_attr_t AFTER_SKIP = 2 // After skipping and after scanning next byte for valid attribute }; -void add_access_dpb(BurpGlobals* tdgbl, Firebird::ClumpletWriter& dpb); +void add_access_dpb(BurpGlobals* tdgbl, ClumpletWriter& dpb); void add_files(BurpGlobals* tdgbl, const char*); void bad_attribute(scan_attr_t, att_type, USHORT); -void create_database(BurpGlobals* tdgbl, Firebird::IProvider*, const TEXT*); +void create_database(BurpGlobals* tdgbl, IProvider*, const TEXT*); void decompress(BurpGlobals* tdgbl, UCHAR*, ULONG); void eat_blob(BurpGlobals* tdgbl); void eat_text(BurpGlobals* tdgbl); @@ -174,7 +175,7 @@ void realign(BurpGlobals* tdgbl, UCHAR*, const burp_rel*); #ifdef sparc USHORT recompute_length(BurpGlobals* tdgbl, burp_rel*); #endif -bool restore(BurpGlobals* tdgbl, Firebird::IProvider*, const TEXT*, const TEXT*); +bool restore(BurpGlobals* tdgbl, IProvider*, const TEXT*, const TEXT*); void restore_security_class(BurpGlobals* tdgbl, const TEXT*, const TEXT*); USHORT get_view_base_relation_count(BurpGlobals* tdgbl, const QualifiedMetaString&, USHORT, bool* error); void store_blr_gen_id(BurpGlobals* tdgbl, const QualifiedMetaString& gen_name, SINT64 value, SINT64 initial_value, @@ -346,11 +347,11 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name) * Recreate a database from a backup. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; - Firebird::IRequest* req_handle3 = nullptr; + IRequest* req_handle1 = nullptr; + IRequest* req_handle3 = nullptr; QualifiedMetaString indexName; - Firebird::DispatcherPtr provider; + DispatcherPtr provider; BurpGlobals* tdgbl = BurpGlobals::getSpecific(); tdgbl->gbl_sw_transportable = tdgbl->gbl_sw_compress = false; @@ -431,7 +432,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name) if (gds_status->hasData()) general_on_error (); // Check to see if there is a warning - if (gds_status->getState() & Firebird::IStatus::STATE_WARNINGS) + if (gds_status->getState() & IStatus::STATE_WARNINGS) { BURP_print_warning(gds_status); } @@ -599,7 +600,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name) END_ERROR; // Check to see if there is a warning - if (gds_status->getState() & Firebird::IStatus::STATE_WARNINGS) + if (gds_status->getState() & IStatus::STATE_WARNINGS) { BURP_print_warning(gds_status); } @@ -624,7 +625,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name) BURP_verbose(360); - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); add_access_dpb(tdgbl, dpb); if (tdgbl->flag_on_line) @@ -637,7 +638,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name) if (tdgbl->gbl_sw_replica.has_value()) dpb.insertByte(isc_dpb_set_db_replica, tdgbl->gbl_sw_replica.value()); - Firebird::IAttachment* db_handle = provider->attachDatabase(&tdgbl->status_vector, database_name, + IAttachment* db_handle = provider->attachDatabase(&tdgbl->status_vector, database_name, dpb.getBufferLength(), dpb.getBuffer()); if (tdgbl->status_vector->hasData()) general_on_error(); @@ -684,7 +685,7 @@ namespace // unnamed, private { // Add the common DPB params to the two attach calls in RESTORE_restore() -void add_access_dpb(BurpGlobals* tdgbl, Firebird::ClumpletWriter& dpb) +void add_access_dpb(BurpGlobals* tdgbl, ClumpletWriter& dpb) { tdgbl->uSvc->fillDpb(dpb); @@ -722,7 +723,7 @@ void add_files(BurpGlobals* tdgbl, const char* file_name) * addresses & commit this much. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; // store the RDB$FILES records @@ -839,7 +840,7 @@ namespace { // and not to stdout if IUtil::version gets called class ProtocolVersion : - public Firebird::AutoIface > + public AutoIface> { public: ProtocolVersion(unsigned* v) @@ -849,7 +850,7 @@ public: } // IVersionCallback implementation - void callback(Firebird::CheckStatusWrapper*, const char* text) + void callback(CheckStatusWrapper*, const char* text) { const char* pm = ")/P"; const char* pp = strstr(text, pm); @@ -865,7 +866,7 @@ private: }; class EngineVersion : - public Firebird::AutoIface > + public AutoIface> { public: EngineVersion(char* v) @@ -875,7 +876,7 @@ public: } // IVersionCallback implementation - void callback(Firebird::CheckStatusWrapper*, const char* text) + void callback(CheckStatusWrapper*, const char* text) { if (!version[0]) strcpy(version, text); @@ -889,7 +890,7 @@ private: -void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file_name) +void create_database(BurpGlobals* tdgbl, IProvider* provider, const TEXT* file_name) { /************************************** * @@ -1010,7 +1011,7 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE if (tdgbl->gbl_sw_page_buffers) page_buffers = tdgbl->gbl_sw_page_buffers; - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); tdgbl->uSvc->fillDpb(dpb); const UCHAR* authBlock; @@ -1114,14 +1115,14 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE // msg 33 failed to create database %s } - if (status_vector->getState() & Firebird::IStatus::STATE_WARNINGS) + if (status_vector->getState() & IStatus::STATE_WARNINGS) { BURP_print_warning(&status_vector); } // get remote protocol version ProtocolVersion pv(&tdgbl->gbl_network_protocol); - Firebird::UtilInterfacePtr()->getFbVersion(&status_vector, DB, &pv); + UtilInterfacePtr()->getFbVersion(&status_vector, DB, &pv); // treat errors as old provider missing new calls if (status_vector->hasData()) @@ -1135,7 +1136,7 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE BURP_print(false, 139, file_name); // msg 139 Version(s) for database "%s" OutputVersion outputVersion("\t%s\n"); - Firebird::UtilInterfacePtr()->getFbVersion(&status_vector, DB, &outputVersion); + UtilInterfacePtr()->getFbVersion(&status_vector, DB, &outputVersion); } tdgbl->gbl_database_file_name = file_name; @@ -1148,7 +1149,7 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE // check server version char buf[256]; EngineVersion ev(buf); - Firebird::UtilInterfacePtr()->getFbVersion(&status_vector, DB, &ev); + UtilInterfacePtr()->getFbVersion(&status_vector, DB, &ev); const char* ptr = strstr(buf, "version \""); int v = 0; @@ -1179,9 +1180,9 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE if (!(ptr && *ptr)) { - Firebird::string x; + string x; x.printf("Undefined or too small server version: %s, need at least 3.0.4", buf); - (Firebird::Arg::Gds(isc_random) << x).raise(); + (Arg::Gds(isc_random) << x).raise(); } EXEC SQL SET TRANSACTION; @@ -1194,7 +1195,7 @@ void create_database(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TE // Unknown crypt plugin name - use -CRYPT switch } - Firebird::string sql; + string sql; const char* dQuote = SQL_dialect >= SQL_DIALECT_V6 ? "\"" : ""; sql.printf("ALTER DATABASE ENCRYPT WITH %s%s%s", dQuote, tdgbl->gbl_sw_crypt, dQuote); if (tdgbl->gbl_sw_keyname && tdgbl->gbl_sw_keyname[0]) @@ -1446,7 +1447,7 @@ void fix_security_class_name(BurpGlobals* tdgbl, TEXT* sec_class, bool is_field) FbLocalStatus status_vector; - Firebird::IRequest*& handle = tdgbl->handles_fix_security_class_name_req_handle1; + IRequest*& handle = tdgbl->handles_fix_security_class_name_req_handle1; if (!handle) { @@ -1543,8 +1544,8 @@ void general_on_error() if (isc_status->getErrors()[1] == isc_malformed_string) { - Firebird::Arg::StatusVector oldVector(isc_status); - Firebird::Arg::Gds newVector(isc_gbak_invalid_metadata); + Arg::StatusVector oldVector(isc_status); + Arg::Gds newVector(isc_gbak_invalid_metadata); newVector.append(oldVector); newVector.copyTo(isc_status); } @@ -1766,7 +1767,7 @@ void get_array(BurpGlobals* tdgbl, burp_rel* relation, UCHAR* record_buffer) xdr_buffer.lstr_allocated = 0; xdr_buffer.lstr_address = NULL; - Firebird::Cleanup datClean( [&] { + Cleanup datClean( [&] { if (buffer && *buffer) BURP_free(*buffer); if (tdgbl->gbl_sw_transportable && xdr_buffer.lstr_allocated) @@ -2438,7 +2439,7 @@ void get_blr_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) // Create new blob - Firebird::ITransaction* local_trans = (glb_trans && tdgbl->global_trans) ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = (glb_trans && tdgbl->global_trans) ? tdgbl->global_trans : gds_trans; FbLocalStatus status_vector; BlobWrapper blob(&status_vector); @@ -3201,7 +3202,7 @@ static void commit_relation_data(BurpGlobals* tdgbl, burp_rel* relation) ISC_STATUS error_code; while ((error_code = tdgbl->status_vector[1]) != 0) { - Firebird::IRequest* req_handle = 0; + IRequest* req_handle = 0; QualifiedMetaString indexName; switch (error_code) @@ -3336,7 +3337,7 @@ void get_data(BurpGlobals* tdgbl, burp_rel* relation, WriteRelationReq* req) data.lstr_allocated = 0; data.lstr_address = NULL; - Firebird::Cleanup datClean( [&] { + Cleanup datClean( [&] { if (data.lstr_address) BURP_free(data.lstr_address); } ); @@ -3829,7 +3830,7 @@ burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation, USHORT id) // If it is a view and there is a global transaction then use it bool global_tr = false; - Firebird::ITransaction* local_trans; + ITransaction* local_trans; if ((relation->rel_flags & REL_view) && tdgbl->global_trans) { local_trans = tdgbl->global_trans; @@ -4520,7 +4521,7 @@ bool get_function(BurpGlobals* tdgbl) bool existFlag = false; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; if (tdgbl->runtimeODS >= DB_VERSION_DDL12) { @@ -4903,7 +4904,7 @@ void get_function_arg(BurpGlobals* tdgbl, bool skip_arguments) att_type attribute; scan_attr_t scan_next_attr; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; if (skip_arguments) { @@ -6942,7 +6943,7 @@ void get_misc_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) // Create new blob - Firebird::ITransaction* local_trans; + ITransaction* local_trans; if (glb_trans && tdgbl->global_trans) local_trans = tdgbl->global_trans; else @@ -7039,7 +7040,7 @@ bool get_package(BurpGlobals* tdgbl) if (tdgbl->RESTORE_format < 10) return false; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; burp_pkg* package = (burp_pkg*) BURP_alloc_zero(sizeof(burp_pkg)); if (tdgbl->runtimeODS >= DB_VERSION_DDL14) @@ -7152,7 +7153,7 @@ bool get_procedure(BurpGlobals* tdgbl) att_type attribute; scan_attr_t scan_next_attr; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; burp_prc* procedure = (burp_prc*) BURP_alloc_zero (sizeof(burp_prc)); if (tdgbl->runtimeODS >= DB_VERSION_DDL14) @@ -7490,7 +7491,7 @@ bool get_procedure_prm(BurpGlobals* tdgbl, const QualifiedMetaString& name) att_type attribute; scan_attr_t scan_next_attr; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; if (tdgbl->runtimeODS >= DB_VERSION_DDL11_1) { @@ -8175,7 +8176,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t } // If this is a view and there is a global transaction then use it - Firebird::ITransaction* local_trans; + ITransaction* local_trans; if (view_blr_null || !tdgbl->global_trans) local_trans = gds_trans; else @@ -8824,7 +8825,7 @@ bool get_mapping(BurpGlobals* tdgbl) scan_attr_t scan_next_attr; TEXT temp[GDS_NAME_LEN]; SSHORT l; - Firebird::string role; + string role; if (tdgbl->runtimeODS >= DB_VERSION_DDL12) { @@ -8952,7 +8953,7 @@ bool get_mapping(BurpGlobals* tdgbl) constexpr unsigned MATCH_TO_TYPE = 0x10; constexpr unsigned MATCH_TO = 0x20; constexpr unsigned MATCH_ALL = 0x3f; - Firebird::NoCaseString txt; + NoCaseString txt; skip_init(&scan_next_attr); while (skip_scan(&scan_next_attr), get_attribute(&attribute, tdgbl) != att_end) @@ -9044,7 +9045,7 @@ bool get_mapping(BurpGlobals* tdgbl) BURP_verbose(298, MetaString(ADMIN_ROLE).toQuotedString()); // msg 298, restoring map @1 - Firebird::string sql; + string sql; sql.printf("%s ('%s', %d) %s", "UPDATE OR INSERT INTO RDB$ROLES(RDB$ROLE_NAME, RDB$SYSTEM_FLAG) VALUES", ADMIN_ROLE, 6, // constant 6 turns on auto admin mapping in FB 2.5 @@ -9266,7 +9267,7 @@ void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) // Create new blob BlobWrapper blob(&status_vector); - Firebird::ITransaction* local_trans; + ITransaction* local_trans; if (glb_trans && tdgbl->global_trans) local_trans = tdgbl->global_trans; else @@ -9531,7 +9532,7 @@ bool get_trigger(BurpGlobals* tdgbl) scan_attr_t scan_next_attr; bool skipTrig = false; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; if (tdgbl->runtimeODS >= DB_VERSION_DDL11_1) { @@ -9964,7 +9965,7 @@ bool get_trigger_message(BurpGlobals* tdgbl) if (tdgbl->runtimeODS < DB_VERSION_DDL11) message[78] = 0; - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; STORE (TRANSACTION_HANDLE local_trans REQUEST_HANDLE tdgbl->handles_get_trigger_message_req_handle2) @@ -10186,7 +10187,7 @@ bool get_user_privilege(BurpGlobals* tdgbl) relation.schema = PUBLIC_SCHEMA; // Check if object exists - Firebird::ITransaction* local_trans = nullptr; + ITransaction* local_trans = nullptr; bool exists = false; // if grantor is not set than it's system privilege which should not be restored if (grantor[0]) @@ -10394,7 +10395,7 @@ bool get_view(BurpGlobals* tdgbl, burp_rel* relation) // If there is a global transaction then use it - Firebird::ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; + ITransaction* local_trans = tdgbl->global_trans ? tdgbl->global_trans : gds_trans; if (tdgbl->runtimeODS >= DB_VERSION_DDL12) { @@ -10866,7 +10867,7 @@ USHORT recompute_length(BurpGlobals* tdgbl, burp_rel* relation) } #endif -bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file_name, const TEXT* database_name) +bool restore(BurpGlobals* tdgbl, IProvider* provider, const TEXT* file_name, const TEXT* database_name) { /************************************** * @@ -10928,16 +10929,16 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file // msg 129 started transaction att_type attribute; - Firebird::IRequest* req_handle2 = nullptr; - Firebird::IRequest* req_handle3 = nullptr; - Firebird::IRequest* req_handle4 = nullptr; - Firebird::IRequest* req_handle5 = nullptr; - Firebird::IRequest* reqHandleDflCharSetSchema = nullptr; + IRequest* req_handle2 = nullptr; + IRequest* req_handle3 = nullptr; + IRequest* req_handle4 = nullptr; + IRequest* req_handle5 = nullptr; + IRequest* reqHandleDflCharSetSchema = nullptr; // Collect system fields { - Firebird::IRequest* req_handle = nullptr; - tdgbl->systemFields.setSortMode(Firebird::FB_ARRAY_SORT_MANUAL); + IRequest* req_handle = nullptr; + tdgbl->systemFields.setSortMode(FB_ARRAY_SORT_MANUAL); FOR(REQUEST_HANDLE req_handle) X IN RDB$FIELDS WITH @@ -11124,7 +11125,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file if (tdgbl->gbl_sw_fix_fss_data) { bool found = false; - Firebird::string name = tdgbl->gbl_sw_fix_fss_data; + string name = tdgbl->gbl_sw_fix_fss_data; name.upper(); req_handle3 = 0; @@ -11151,7 +11152,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file if (tdgbl->gbl_sw_fix_fss_metadata) { bool found = false; - Firebird::string name = tdgbl->gbl_sw_fix_fss_metadata; + string name = tdgbl->gbl_sw_fix_fss_metadata; name.upper(); req_handle3 = 0; @@ -11379,7 +11380,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file if (tdgbl->defaultCollations.hasData()) { - Firebird::IRequest* req_handle5 = nullptr; + IRequest* req_handle5 = nullptr; FOR (REQUEST_HANDLE req_handle5) CS IN RDB$CHARACTER_SETS @@ -11440,7 +11441,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file if (tdgbl->gbl_sw_kill) { - Firebird::IRequest* req_handle5 = nullptr; + IRequest* req_handle5 = nullptr; FOR (REQUEST_HANDLE req_handle5) FIL IN RDB$FILES WITH FIL.RDB$SHADOW_NUMBER NOT MISSING @@ -11458,7 +11459,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file } // update statistics for system indices - Firebird::IRequest* req_handle6 = nullptr; + IRequest* req_handle6 = nullptr; FOR (REQUEST_HANDLE req_handle6) IND IN RDB$INDICES WITH IND.RDB$SYSTEM_FLAG EQ 1 @@ -11493,7 +11494,7 @@ void restore_security_class(BurpGlobals* tdgbl, const TEXT* owner_nm, const TEXT * restore the ownership of the relation in the ACL list * **************************************/ - Firebird::IRequest* req_handle2 = nullptr; + IRequest* req_handle2 = nullptr; //isc_tr_handle local_trans = gds_trans; @@ -11550,7 +11551,7 @@ USHORT get_view_base_relation_count(BurpGlobals* tdgbl, return 0; } - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; USHORT result = 0; @@ -11762,7 +11763,7 @@ void store_blr_gen_id(BurpGlobals* tdgbl, const QualifiedMetaString& gen_name, S fb_assert(blr_length <= sizeof(blr_buffer)); FbLocalStatus status_vector; - Firebird::RefPtr gen_id_reqh(Firebird::REF_NO_INCR, + RefPtr gen_id_reqh(REF_NO_INCR, DB->compileRequest(&status_vector, blr_length, blr_buffer)); if (status_vector->hasData()) { @@ -11795,7 +11796,7 @@ void update_global_field(BurpGlobals* tdgbl) * The blobs have been created already. * **************************************/ - Firebird::IRequest* req_handle1 = nullptr; + IRequest* req_handle1 = nullptr; for (gfld* gfield = tdgbl->gbl_global_fields; gfield; ) { @@ -11864,9 +11865,9 @@ void update_global_field(BurpGlobals* tdgbl) void update_ownership(BurpGlobals* tdgbl) { - Firebird::IRequest* req_handle2 = nullptr; - Firebird::IRequest* req_handle4 = nullptr; - Firebird::IRequest* req_handle6 = nullptr; + IRequest* req_handle2 = nullptr; + IRequest* req_handle4 = nullptr; + IRequest* req_handle6 = nullptr; BURP_verbose(358); // Change ownership of any packages @@ -12011,7 +12012,7 @@ void update_view_dbkey_lengths(BurpGlobals* tdgbl) * numeric overflow, or string truncation" error. * **************************************/ - Firebird::IRequest* req_handle2 = nullptr; + IRequest* req_handle2 = nullptr; BURP_verbose(357); @@ -12057,8 +12058,8 @@ void fix_missing_privileges(BurpGlobals* tdgbl) BURP_verbose(359); GDS_NAME owner_name; - Firebird::IRequest* req_handle1 = nullptr; - Firebird::IRequest* req_handle2 = nullptr; + IRequest* req_handle1 = nullptr; + IRequest* req_handle2 = nullptr; FOR (REQUEST_HANDLE req_handle1) REL IN RDB$RELATIONS @@ -12151,7 +12152,7 @@ void fix_generator(BurpGlobals* tdgbl, const FixGenerator* g) int start = static_cast(strlen(g->prefix) + 1); - Firebird::string sql; + string sql; sql.printf("EXECUTE BLOCK AS " "DECLARE VARIABLE maxInTable INT; " "DECLARE VARIABLE currentGen INT; " @@ -13161,8 +13162,6 @@ void set_transaction(BurpGlobals* tdgbl) } // namespace -namespace Burp -{ /// class WriteRelationMeta @@ -14247,4 +14246,5 @@ bool RestoreRelationTask::tableWriter(BurpGlobals* tdgbl, Item& item) return true; } -} // namespace Burp + +} // namespace Firebird::Burp diff --git a/src/burp/split/spit.cpp b/src/burp/split/spit.cpp index 1e93db809bc..2c973d0f27d 100644 --- a/src/burp/split/spit.cpp +++ b/src/burp/split/spit.cpp @@ -63,6 +63,9 @@ #include #endif +using namespace Firebird; + + static constexpr int mode_read = O_RDONLY; static constexpr int mode_write = O_WRONLY | O_CREAT; static constexpr int mask = 0666; diff --git a/src/common/Auth.cpp b/src/common/Auth.cpp index 43224fe23fd..dd8d2566293 100644 --- a/src/common/Auth.cpp +++ b/src/common/Auth.cpp @@ -32,9 +32,9 @@ #include "../common/utils_proto.h" #include "../common/db_alias.h" -using namespace Firebird; +namespace Firebird::Auth +{ -namespace Auth { WriterImplementation::WriterImplementation() : current(*getDefaultMemoryPool(), ClumpletReader::WideUnTagged, MAX_DPB_SIZE), @@ -60,7 +60,7 @@ void WriterImplementation::reset() sequence = 0; } -void WriterImplementation::add(Firebird::CheckStatusWrapper* st, const char* name) +void WriterImplementation::add(CheckStatusWrapper* st, const char* name) { try { @@ -75,7 +75,7 @@ void WriterImplementation::add(Firebird::CheckStatusWrapper* st, const char* nam } type = "USER"; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } @@ -98,20 +98,20 @@ void WriterImplementation::putLevel() result.insertBytes(sequence++, current.getBuffer(), current.getBufferLength()); } -void WriterImplementation::setType(Firebird::CheckStatusWrapper* st, const char* value) +void WriterImplementation::setType(CheckStatusWrapper* st, const char* value) { try { if (value) type = value; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } } -void WriterImplementation::setDb(Firebird::CheckStatusWrapper* st, const char* value) +void WriterImplementation::setDb(CheckStatusWrapper* st, const char* value) { try { @@ -122,10 +122,11 @@ void WriterImplementation::setDb(Firebird::CheckStatusWrapper* st, const char* v current.insertString(AuthReader::AUTH_SECURE_DB, target); } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(st); } } -} // namespace Auth + +} // namespace Firebird::Auth diff --git a/src/common/Auth.h b/src/common/Auth.h index affe519bd95..12b04470c0e 100644 --- a/src/common/Auth.h +++ b/src/common/Auth.h @@ -37,32 +37,32 @@ #include "../common/classes/fb_string.h" #include "../common/classes/ImplementHelper.h" -namespace Auth { +namespace Firebird::Auth { class WriterImplementation : - public Firebird::AutoIface > + public AutoIface > { public: WriterImplementation(); - void store(Firebird::ClumpletWriter* to, unsigned char tag); + void store(ClumpletWriter* to, unsigned char tag); void setPlugin(const char* m); // IWriter implementation void reset(); - void add(Firebird::CheckStatusWrapper* st, const char* name); - void setType(Firebird::CheckStatusWrapper* st, const char* value); - void setDb(Firebird::CheckStatusWrapper* st, const char* value); + void add(CheckStatusWrapper* st, const char* name); + void setType(CheckStatusWrapper* st, const char* value); + void setDb(CheckStatusWrapper* st, const char* value); private: - Firebird::ClumpletWriter current, result; - Firebird::string plugin, type; + ClumpletWriter current, result; + string plugin, type; unsigned int sequence; void putLevel(); }; -} // namespace Auth +} // namespace Firebird::Auth #endif // FB_AUTH_H diff --git a/src/common/BigInteger.cpp b/src/common/BigInteger.cpp index 45e6c3a4739..6cac19955bf 100644 --- a/src/common/BigInteger.cpp +++ b/src/common/BigInteger.cpp @@ -71,7 +71,7 @@ namespace Firebird assign(count, bytes); } - BigInteger::BigInteger(const Firebird::UCharBuffer& val) + BigInteger::BigInteger(const UCharBuffer& val) { CHECK_MP(mp_init(&t)); assign(val.getCount(), val.begin()); @@ -95,8 +95,8 @@ namespace Firebird void BigInteger::random(int numBytes) { - Firebird::UCharBuffer b; - Firebird::GenerateRandomBytes(b.getBuffer(numBytes), numBytes); + UCharBuffer b; + GenerateRandomBytes(b.getBuffer(numBytes), numBytes); assign(numBytes, b.begin()); } @@ -175,7 +175,7 @@ namespace Firebird return mp_cmp(const_cast(&t), const_cast(&val.t)) == 0; } - void BigInteger::getBytes(Firebird::UCharBuffer& bytes) const + void BigInteger::getBytes(UCharBuffer& bytes) const { CHECK_MP(mp_to_unsigned_bin(const_cast(&t), bytes.getBuffer(length()))); } diff --git a/src/common/BigInteger.h b/src/common/BigInteger.h index eb9765d6e7b..fdfcccd8581 100644 --- a/src/common/BigInteger.h +++ b/src/common/BigInteger.h @@ -42,7 +42,7 @@ class BigInteger BigInteger(); explicit BigInteger(const char* text, unsigned int radix = 16u); BigInteger(unsigned int count, const unsigned char* bytes); - explicit BigInteger(const Firebird::UCharBuffer& val); + explicit BigInteger(const UCharBuffer& val); BigInteger(const BigInteger& val); // BigInteger(int numBits, Random& r); ~BigInteger(); @@ -65,9 +65,9 @@ class BigInteger bool operator== (const BigInteger& val) const; - void getBytes(Firebird::UCharBuffer& bytes) const; + void getBytes(UCharBuffer& bytes) const; unsigned int length() const; - void getText(Firebird::string& str, unsigned int radix = 16u) const; + void getText(string& str, unsigned int radix = 16u) const; BigInteger modPow(const BigInteger& pow, const BigInteger& mod) const; diff --git a/src/common/CharSet.cpp b/src/common/CharSet.cpp index 8bce947a2eb..1fdc5c0c8af 100644 --- a/src/common/CharSet.cpp +++ b/src/common/CharSet.cpp @@ -95,8 +95,8 @@ #include "../jrd/intl_classes.h" #include "../common/classes/Aligner.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird +{ namespace @@ -239,9 +239,6 @@ ULONG MultiByteCharSet::substring(const ULONG srcLen, const UCHAR* src, const UL //------------- -namespace Firebird { - - CharSet* CharSet::createInstance(MemoryPool& pool, USHORT id, charset* cs) { if (cs->charset_min_bytes_per_char != cs->charset_max_bytes_per_char) @@ -300,4 +297,4 @@ ULONG CharSet::removeTrailingSpaces(ULONG srcLen, const UCHAR* src) const } -} // namespace Firebird +} // namespace Firebird diff --git a/src/common/CharSet.h b/src/common/CharSet.h index 7606c41871c..c488120e6c4 100644 --- a/src/common/CharSet.h +++ b/src/common/CharSet.h @@ -41,7 +41,7 @@ inline void SimpleDelete::clear(charset* cs) { if (cs) { - Firebird::IntlUtil::finiCharset(cs); + IntlUtil::finiCharset(cs); delete cs; } } @@ -49,7 +49,7 @@ inline void SimpleDelete::clear(charset* cs) class CharSet { public: - static CharSet* createInstance(Firebird::MemoryPool& pool, USHORT id, charset* cs); + static CharSet* createInstance(MemoryPool& pool, USHORT id, charset* cs); protected: CharSet(USHORT _id, charset* _cs) @@ -61,7 +61,7 @@ class CharSet sqlMatchAnyLength = getConvFromUnicode().convert(sizeof(SQL_MATCH_ANY_CHARS), &SQL_MATCH_ANY_CHARS, sizeof(sqlMatchAny), sqlMatchAny); } - catch (const Firebird::Exception&) + catch (const Exception&) { memset(sqlMatchAny, 0, sizeof(sqlMatchAny)); sqlMatchAnyLength = 0; @@ -72,7 +72,7 @@ class CharSet sqlMatchOneLength = getConvFromUnicode().convert( sizeof(SQL_MATCH_1_CHAR), &SQL_MATCH_1_CHAR, sizeof(sqlMatchOne), sqlMatchOne); } - catch (const Firebird::Exception&) + catch (const Exception&) { memset(sqlMatchOne, 0, sizeof(sqlMatchOne)); sqlMatchOneLength = 0; @@ -117,7 +117,7 @@ class CharSet void destroy() { - Firebird::IntlUtil::finiCharset(cs); + IntlUtil::finiCharset(cs); } const UCHAR* getSqlMatchAny() const { return sqlMatchAny; } diff --git a/src/common/CsConvert.h b/src/common/CsConvert.h index 4a584e277f3..4043c74a306 100644 --- a/src/common/CsConvert.h +++ b/src/common/CsConvert.h @@ -66,7 +66,7 @@ class CsConvert void convert(ULONG srcLen, const UCHAR* src, - Firebird::UCharBuffer& dst, + UCharBuffer& dst, ULONG* badInputPos = NULL, bool ignoreTrailingSpaces = false) { @@ -124,7 +124,7 @@ class CsConvert fb_assert(len % sizeof(USHORT) == 0); - Firebird::HalfStaticArray temp; + HalfStaticArray temp; len = (*cnvt1->csconvert_fn_convert)(cnvt1, srcLen, src, len, reinterpret_cast(temp.getBuffer(len / 2)), &errCode, &errPos); @@ -182,7 +182,7 @@ class CsConvert { // ASF: We should report the bad pos in context of the source string. // Convert the "good" UTF-16 buffer to it to know the length. - Firebird::HalfStaticArray dummyBuffer; + HalfStaticArray dummyBuffer; USHORT dummyErr; ULONG dummyPos; *badInputPos = (*charSet1->charset_from_unicode.csconvert_fn_convert)( @@ -272,16 +272,16 @@ class CsConvert private: [[noreturn]] void raiseError(ISC_STATUS code) { - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_arith_except) << - Firebird::Arg::Gds(code)); + status_exception::raise(Arg::Gds(isc_arith_except) << + Arg::Gds(code)); } [[noreturn]] void raiseError(ULONG dstLen, ULONG srcLen) { - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_arith_except) << - Firebird::Arg::Gds(isc_string_truncation) << - Firebird::Arg::Gds(isc_trunc_limits) << - Firebird::Arg::Num(dstLen) << Firebird::Arg::Num(srcLen)); + status_exception::raise(Arg::Gds(isc_arith_except) << + Arg::Gds(isc_string_truncation) << + Arg::Gds(isc_trunc_limits) << + Arg::Num(dstLen) << Arg::Num(srcLen)); } }; diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index 6476f39da57..744481ae3d9 100644 --- a/src/common/CvtFormat.cpp +++ b/src/common/CvtFormat.cpp @@ -40,7 +40,9 @@ #include #include -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -150,8 +152,7 @@ namespace #define CVT_FORMAT(id, format) constexpr Patterns format = 1llu << (id - 1); #define CVT_FORMAT2(id, format1, format2) constexpr Patterns format2 = 1llu << (id - 1); #define CVT_FORMAT_FLAG(id, format) constexpr Patterns format = 1llu << (id - 1); - namespace Format - { + namespace Format { typedef FB_UINT64 Patterns; constexpr Patterns NONE = 0; @@ -164,8 +165,7 @@ namespace #define CVT_FORMAT(id, format) constexpr const char* format = #format; #define CVT_FORMAT2(id, format1, format2) constexpr const char* format2 = #format1; #define CVT_FORMAT_FLAG(id, format) - namespace FormatStr - { + namespace FormatStr { #include "CvtFormatImpl.h" } #undef CVT_FORMAT @@ -214,10 +214,8 @@ namespace Token token; std::string_view data; }; -} -namespace -{ + template constexpr int sign(T value) { @@ -504,7 +502,7 @@ namespace switch (desc->dsc_dtype) { case dtype_sql_time: - Firebird::TimeStamp::decode_time(*(GDS_TIME*) desc->dsc_address, + TimeStamp::decode_time(*(GDS_TIME*) desc->dsc_address, &outTimes.tm_hour, &outTimes.tm_min, &outTimes.tm_sec, &outFractions); break; @@ -515,11 +513,11 @@ namespace break; case dtype_sql_date: - Firebird::TimeStamp::decode_date(*(GDS_DATE*) desc->dsc_address, &outTimes); + TimeStamp::decode_date(*(GDS_DATE*) desc->dsc_address, &outTimes); break; case dtype_timestamp: - Firebird::TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) desc->dsc_address, &outTimes, &outFractions); + TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) desc->dsc_address, &outTimes, &outFractions); break; case dtype_timestamp_tz: @@ -1125,7 +1123,7 @@ namespace return result; } - constexpr int applyPeriod(std::string_view period, int twelveHours, Firebird::Callbacks* cb) + constexpr int applyPeriod(std::string_view period, int twelveHours, Callbacks* cb) { if (period == FormatStr::AM) { @@ -1255,7 +1253,7 @@ namespace } std::optional getDisplacementFromString(const char* str, FB_SIZE_T length, FB_SIZE_T& offset, - std::string_view patternStr, Firebird::Callbacks* cb) + std::string_view patternStr, Callbacks* cb) { int sign = getIntSignFromString(str, offset); @@ -1298,7 +1296,7 @@ namespace } void processStringToDateTimeDeferredTokens(const std::vector& deferredTokens, - StringToDateTimeData& outCvtData, Firebird::Callbacks* cb) + StringToDateTimeData& outCvtData, Callbacks* cb) { struct tm& outTimes = outCvtData.times; @@ -1323,7 +1321,7 @@ namespace } void processStringToDateTimeTokens(const std::vector& tokens, string inputStr, StringToDateTimeData& outCvtData, - Firebird::Callbacks* cb) + Callbacks* cb) { const char* str = inputStr.c_str(); const FB_SIZE_T strLength = inputStr.length(); @@ -1840,8 +1838,8 @@ string CVT_format_datetime_to_string(const dsc* desc, const string& format, Call return result; } -ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const Firebird::string& format, - const EXPECT_DATETIME expectedType, Firebird::Callbacks* cb) +ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const string& format, + const EXPECT_DATETIME expectedType, Callbacks* cb) { if (!DTYPE_IS_TEXT(desc->dsc_dtype)) cb->err(Arg::Gds(isc_invalid_data_type_for_date_format)); @@ -1879,3 +1877,6 @@ ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const Firebird:: return timestampTZ; } + + +} // namespace Firebird diff --git a/src/common/CvtFormat.h b/src/common/CvtFormat.h index 39e2ab1bfee..99f774b2038 100644 --- a/src/common/CvtFormat.h +++ b/src/common/CvtFormat.h @@ -4,8 +4,11 @@ #include "firebird.h" #include "../common/cvt.h" -Firebird::string CVT_format_datetime_to_string(const dsc* desc, const Firebird::string& format, Firebird::Callbacks* cb); -ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const Firebird::string& format, - const Firebird::EXPECT_DATETIME expectedType, Firebird::Callbacks* cb); +namespace Firebird +{ + string CVT_format_datetime_to_string(const dsc* desc, const string& format, Callbacks* cb); + ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const string& format, + const EXPECT_DATETIME expectedType, Callbacks* cb); +} // namespace Firebird #endif // COMMON_CVT_FORMAT_H diff --git a/src/common/DecFloat.cpp b/src/common/DecFloat.cpp index 1d4528e790d..6ae2884eeda 100644 --- a/src/common/DecFloat.cpp +++ b/src/common/DecFloat.cpp @@ -47,7 +47,9 @@ extern "C" #include #include -using namespace Firebird; +namespace Firebird +{ + const DecimalStatus DecimalStatus::DEFAULT(FB_DEC_Errors); const NumericBinding NumericBinding::DEFAULT; @@ -347,8 +349,6 @@ void setSpecial(decNumber* number, decClass cl, int sign) -namespace Firebird { - void Decimal64::setScale(DecimalStatus decSt, int scale) { if (scale) @@ -1226,4 +1226,6 @@ string DecimalStatus::getTxtTraps() return rc; return "None"; } -} // namespace Firebird + + +} // namespace Firebird diff --git a/src/common/Int128.cpp b/src/common/Int128.cpp index 9f22b595196..191e3920a3d 100644 --- a/src/common/Int128.cpp +++ b/src/common/Int128.cpp @@ -40,7 +40,9 @@ #include #include -using namespace Firebird; + +namespace Firebird +{ #ifdef FB_USE_ABSEIL_INT128 @@ -55,8 +57,6 @@ const CInt128 minus1(-1); } // anonymous namespace -namespace Firebird { - Int128 Int128::set(const char* value) { // This is simplified method - it does not perform all what's needed for full conversion @@ -281,8 +281,6 @@ CInt128::CInt128(minmax mm) CInt128 MIN_Int128(CInt128::MkMin); CInt128 MAX_Int128(CInt128::MkMax); -} // namespace Firebird - #else // FB_USE_ABSEIL_INT128 namespace { @@ -292,13 +290,9 @@ constexpr double p2_32 = 4294967296.0; const I128limit i128limit; const CInt128 minus1(-1); - } // anonymous namespace - -namespace Firebird { - Int128 Int128::set(SLONG value, int scale) { v = ttmath::sint(value); @@ -643,16 +637,11 @@ CInt128::CInt128(minmax mm) CInt128 MIN_Int128(CInt128::MkMin); CInt128 MAX_Int128(CInt128::MkMax); -} // namespace Firebird - #endif // FB_USE_ABSEIL_INT128 // implementation independent part -namespace Firebird -{ - ULONG Int128::makeIndexKey(vary* buf, int exp) { fb_assert(-128 <= exp && exp <= 127); @@ -675,5 +664,5 @@ ULONG Int128::makeIndexKey(vary* buf, int exp) return Decimal128::makeBcdKey(buf, coeff, sign() < 0, exp, BIAS, PMAX); } -} // namespace Firebird +} // namespace Firebird diff --git a/src/common/IntlParametersBlock.cpp b/src/common/IntlParametersBlock.cpp index 67027bde503..9d41b589e68 100644 --- a/src/common/IntlParametersBlock.cpp +++ b/src/common/IntlParametersBlock.cpp @@ -35,7 +35,9 @@ #include "../common/UtilSvc.h" #include "../common/StatusHolder.h" -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -93,10 +95,8 @@ void processCommandLine(IntlParametersBlock::ProcessString* processString, strin par = result; } -} +} // namespace -namespace Firebird -{ void IntlParametersBlock::toUtf8(ClumpletWriter& pb) { @@ -154,7 +154,7 @@ void IntlParametersBlock::processParametersBlock(ProcessString* processString, C } } } - catch (const Firebird::status_exception& st) + catch (const status_exception& st) { LocalStatus ls; CheckStatusWrapper l(&ls); @@ -372,4 +372,5 @@ UCHAR IntlSpbStart::getUtf8Tag() noexcept return 0; } -} + +} // namespace Firebird diff --git a/src/common/IntlUtil.cpp b/src/common/IntlUtil.cpp index 1e9cbd5f851..ebcda2c794c 100644 --- a/src/common/IntlUtil.cpp +++ b/src/common/IntlUtil.cpp @@ -35,7 +35,8 @@ #include -using Firebird::UnicodeUtil; +namespace Firebird +{ namespace @@ -50,7 +51,7 @@ namespace ~TextTypeImpl() { - Firebird::IntlUtil::finiCharset(cs); + IntlUtil::finiCharset(cs); delete cs; delete collation; @@ -62,9 +63,6 @@ namespace } -namespace Firebird { - - static void unicodeDestroy(texttype* tt) noexcept; static USHORT unicodeKeyLength(texttype* tt, USHORT len) noexcept; static USHORT unicodeStrToKey(texttype* tt, USHORT srcLen, const UCHAR* src, @@ -80,11 +78,11 @@ GlobalPtr IntlUtil::utf8CharSet; IntlUtil::Utf8CharSet::Utf8CharSet(MemoryPool& pool) { IntlUtil::initUtf8Charset(&obj); - charSet = Firebird::CharSet::createInstance(pool, CS_UTF8, &obj); + charSet = CharSet::createInstance(pool, CS_UTF8, &obj); } -string IntlUtil::generateSpecificAttributes(Firebird::CharSet* cs, SpecificAttributesMap& map) +string IntlUtil::generateSpecificAttributes(CharSet* cs, SpecificAttributesMap& map) { SpecificAttributesMap::Accessor accessor(&map); @@ -125,7 +123,7 @@ string IntlUtil::generateSpecificAttributes(Firebird::CharSet* cs, SpecificAttri } -bool IntlUtil::parseSpecificAttributes(Firebird::CharSet* cs, ULONG len, const UCHAR* s, +bool IntlUtil::parseSpecificAttributes(CharSet* cs, ULONG len, const UCHAR* s, SpecificAttributesMap* map) { // Note that the map isn't cleared. @@ -295,7 +293,7 @@ ULONG IntlUtil::cvtAsciiToUtf16(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, if (ppDest == NULL) /* length estimate needed? */ return (2 * nSrc); - Firebird::OutAligner d(ppDest, nDest); + OutAligner d(ppDest, nDest); USHORT* pDest = d; const USHORT* const pStart = pDest; @@ -343,7 +341,7 @@ ULONG IntlUtil::cvtUtf16ToAscii(csconvert* obj, ULONG nSrc, const UCHAR* ppSrc, if (pDest == NULL) /* length estimate needed? */ return (nSrc / 2); - Firebird::Aligner s(ppSrc, nSrc); + Aligner s(ppSrc, nSrc); const USHORT* pSrc = s; const UCHAR* const pStart = pDest; @@ -374,7 +372,7 @@ ULONG IntlUtil::cvtUtf8ToUtf16(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, fb_assert(obj != NULL); fb_assert(obj->csconvert_fn_convert == cvtUtf8ToUtf16); return UnicodeUtil::utf8ToUtf16(nSrc, pSrc, - nDest, Firebird::OutAligner(ppDest, nDest), err_code, err_position); + nDest, OutAligner(ppDest, nDest), err_code, err_position); } @@ -383,7 +381,7 @@ ULONG IntlUtil::cvtUtf16ToUtf8(csconvert* obj, ULONG nSrc, const UCHAR* ppSrc, { fb_assert(obj != NULL); fb_assert(obj->csconvert_fn_convert == cvtUtf16ToUtf8); - return UnicodeUtil::utf16ToUtf8(nSrc, Firebird::Aligner(ppSrc, nSrc), + return UnicodeUtil::utf16ToUtf8(nSrc, Aligner(ppSrc, nSrc), nDest, pDest, err_code, err_position); } @@ -523,11 +521,11 @@ bool IntlUtil::initUnicodeCollation(texttype* tt, charset* cs, const ASCII* name IntlUtil::SpecificAttributesMap map; - Firebird::CharSet* charSet = NULL; + CharSet* charSet = NULL; try { - charSet = Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); + charSet = CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); IntlUtil::parseSpecificAttributes(charSet, specificAttributes.getCount(), specificAttributes.begin(), &map); delete charSet; @@ -594,11 +592,11 @@ void IntlUtil::finiCharset(charset* cs) } -ULONG IntlUtil::toLower(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, +ULONG IntlUtil::toLower(CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions) { const ULONG utf16_length = cs->getConvToUnicode().convertLength(srcLen); - Firebird::HalfStaticArray utf16_str; + HalfStaticArray utf16_str; UCHAR* utf16_ptr; if (dst != src && dstLen >= utf16_length) // if dst buffer is sufficient large, use it as intermediate @@ -610,9 +608,9 @@ ULONG IntlUtil::toLower(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, U srcLen = cs->getConvToUnicode().convert(srcLen, src, utf16_length, utf16_ptr); // convert to lowercase - Firebird::HalfStaticArray lower_str; - srcLen = UnicodeUtil::utf16LowerCase(srcLen, Firebird::Aligner(utf16_ptr, srcLen), - utf16_length, Firebird::OutAligner(lower_str.getBuffer(utf16_length), utf16_length), + HalfStaticArray lower_str; + srcLen = UnicodeUtil::utf16LowerCase(srcLen, Aligner(utf16_ptr, srcLen), + utf16_length, OutAligner(lower_str.getBuffer(utf16_length), utf16_length), exceptions); // convert to original character set @@ -620,11 +618,11 @@ ULONG IntlUtil::toLower(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, U } -ULONG IntlUtil::toUpper(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, +ULONG IntlUtil::toUpper(CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions) { const ULONG utf16_length = cs->getConvToUnicode().convertLength(srcLen); - Firebird::HalfStaticArray utf16_str; + HalfStaticArray utf16_str; UCHAR* utf16_ptr; if (dst != src && dstLen >= utf16_length) // if dst buffer is sufficient large, use it as intermediate @@ -636,9 +634,9 @@ ULONG IntlUtil::toUpper(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, U srcLen = cs->getConvToUnicode().convert(srcLen, src, utf16_length, utf16_ptr); // convert to uppercase - Firebird::HalfStaticArray upper_str; - srcLen = UnicodeUtil::utf16UpperCase(srcLen, Firebird::Aligner(utf16_ptr, srcLen), - utf16_length, Firebird::OutAligner(upper_str.getBuffer(utf16_length), utf16_length), + HalfStaticArray upper_str; + srcLen = UnicodeUtil::utf16UpperCase(srcLen, Aligner(utf16_ptr, srcLen), + utf16_length, OutAligner(upper_str.getBuffer(utf16_length), utf16_length), exceptions); // convert to original character set @@ -646,7 +644,7 @@ ULONG IntlUtil::toUpper(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, U } -bool IntlUtil::readOneChar(Firebird::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size) +bool IntlUtil::readOneChar(CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size) { (*s) += *size; @@ -668,7 +666,7 @@ bool IntlUtil::readOneChar(Firebird::CharSet* cs, const UCHAR** s, const UCHAR* bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes, const string& configInfo, string& newSpecificAttributes) { - AutoPtr charSet(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); + AutoPtr charSet(CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); IntlUtil::SpecificAttributesMap map; if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(), @@ -704,7 +702,7 @@ bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes, } -string IntlUtil::escapeAttribute(Firebird::CharSet* cs, const string& s) +string IntlUtil::escapeAttribute(CharSet* cs, const string& s) { string ret; const UCHAR* p = (const UCHAR*)s.begin(); @@ -739,7 +737,7 @@ string IntlUtil::escapeAttribute(Firebird::CharSet* cs, const string& s) } -string IntlUtil::unescapeAttribute(Firebird::CharSet* cs, const string& s) +string IntlUtil::unescapeAttribute(CharSet* cs, const string& s) { string ret; const UCHAR* p = (const UCHAR*)s.begin(); @@ -753,7 +751,7 @@ string IntlUtil::unescapeAttribute(Firebird::CharSet* cs, const string& s) } -bool IntlUtil::isAttributeEscape(Firebird::CharSet* cs, const UCHAR* s, ULONG size) +bool IntlUtil::isAttributeEscape(CharSet* cs, const UCHAR* s, ULONG size) { UCHAR uc[sizeof(ULONG)]; const ULONG uSize = cs->getConvToUnicode().convert(size, s, sizeof(uc), uc); @@ -762,7 +760,7 @@ bool IntlUtil::isAttributeEscape(Firebird::CharSet* cs, const UCHAR* s, ULONG si } -bool IntlUtil::readAttributeChar(Firebird::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape) +bool IntlUtil::readAttributeChar(CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape) { if (readOneChar(cs, s, end, size)) { @@ -943,8 +941,8 @@ static ULONG unicodeCanonical(texttype* tt, ULONG srcLen, const UCHAR* src, ULON &offendingPos); return impl->collation->canonical( - utf16Len, Firebird::Aligner(utf16Str.begin(), utf16Len), - dstLen, Firebird::OutAligner(dst, dstLen), NULL); + utf16Len, Aligner(utf16Str.begin(), utf16Len), + dstLen, OutAligner(dst, dstLen), NULL); } catch (const BadAlloc&) { diff --git a/src/common/MsgUtil.cpp b/src/common/MsgUtil.cpp index 68fa78cf18e..bc50cf163b6 100644 --- a/src/common/MsgUtil.cpp +++ b/src/common/MsgUtil.cpp @@ -29,7 +29,9 @@ #include "../common/classes/init.h" #include "utils_proto.h" -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -84,3 +86,6 @@ ISC_STATUS MsgUtil::getCodeByName(const char* name) return code; } + + +} // namespace Firebird diff --git a/src/common/ScanDir.cpp b/src/common/ScanDir.cpp index bbf8a61a5b2..473aa555d52 100644 --- a/src/common/ScanDir.cpp +++ b/src/common/ScanDir.cpp @@ -48,6 +48,9 @@ #include #include +namespace Firebird +{ + ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -166,3 +169,6 @@ bool ScanDir::isDots() { return getFileName() [0] == '.'; } + + +} // namespace Firebird diff --git a/src/common/ScanDir.h b/src/common/ScanDir.h index 84538d02e8b..e0fc414b43a 100644 --- a/src/common/ScanDir.h +++ b/src/common/ScanDir.h @@ -48,7 +48,11 @@ #include "../common/classes/fb_string.h" #include "../common/os/os_utils.h" -class ScanDir : public Firebird::AutoStorage +namespace Firebird +{ + + +class ScanDir : public AutoStorage { public: ScanDir(const char *dir, const char *pattern); @@ -61,18 +65,21 @@ class ScanDir : public Firebird::AutoStorage const char* getFileName(); bool next(); - Firebird::PathName directory; - Firebird::PathName pattern; - Firebird::PathName fileName; - Firebird::PathName filePath; + PathName directory; + PathName pattern; + PathName fileName; + PathName filePath; private: #ifdef _WIN32 WIN32_FIND_DATA data; HANDLE handle; #else DIR *dir; - dirent *data; + dirent *data; #endif }; + +} // namespace Firebird + #endif // !defined(AFX_SCANDIR_H__D3AE9FF3_1295_11D6_B8F7_00E0180AC49E__INCLUDED_) diff --git a/src/common/SimilarToRegex.cpp b/src/common/SimilarToRegex.cpp index 7c2fa26af5e..9405f84958c 100644 --- a/src/common/SimilarToRegex.cpp +++ b/src/common/SimilarToRegex.cpp @@ -24,7 +24,9 @@ #include "../common/unicode_util.h" #include -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -771,9 +773,6 @@ namespace }; } // namespace -namespace Firebird { - - SimilarToRegex::SimilarToRegex(MemoryPool& pool, unsigned flags, const char* patternStr, unsigned patternLen, const char* escapeStr, unsigned escapeLen) : PermanentStorage(pool) @@ -888,4 +887,4 @@ bool SubstringSimilarRegex::matches(const char* buffer, unsigned bufferLen, } -} // namespace Firebird +} // namespace Firebird diff --git a/src/common/SimilarToRegex.h b/src/common/SimilarToRegex.h index 56d5c1e9fb0..1eda2bbb0a4 100644 --- a/src/common/SimilarToRegex.h +++ b/src/common/SimilarToRegex.h @@ -28,10 +28,7 @@ #include "../common/classes/fb_string.h" namespace Firebird { - - -namespace SimilarToFlag -{ +namespace SimilarToFlag { static inline constexpr unsigned CASE_INSENSITIVE = 0x1; static inline constexpr unsigned LATIN = 0x2; static inline constexpr unsigned WELLFORMED = 0x4; diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index a4fb738e530..a8690d25540 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -49,7 +49,6 @@ namespace { } namespace Firebird { - namespace Arg { Base::Base(ISC_STATUS k, ISC_STATUS c) : diff --git a/src/common/Task.cpp b/src/common/Task.cpp index dabd2a01fce..025c14a9414 100644 --- a/src/common/Task.cpp +++ b/src/common/Task.cpp @@ -28,7 +28,9 @@ #include "../common/Task.h" #include "../common/isc_proto.h" -namespace Firebird { +namespace Firebird +{ + /// class WorkerThread @@ -75,7 +77,7 @@ int WorkerThread::threadRoutine() } return 0; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { iscLogException("Unexpected exception at WorkerThread", ex); } @@ -342,4 +344,4 @@ void Coordinator::releaseThread(WorkerThread* thd) } -} // namespace Jrd +} // namespace Firebird diff --git a/src/common/Task.h b/src/common/Task.h index 2ab32f396f8..3efb9fe080d 100644 --- a/src/common/Task.h +++ b/src/common/Task.h @@ -194,6 +194,6 @@ class WorkerThread final Thread m_thread; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // COMMON_TASK_H diff --git a/src/common/TextType.cpp b/src/common/TextType.cpp index 9be44a758b7..6d90b99064a 100644 --- a/src/common/TextType.cpp +++ b/src/common/TextType.cpp @@ -165,7 +165,7 @@ TextType::TextType(TTypeId _type, texttype *_tt, USHORT _attributes, CharSet* _c canonical(length, temp, sizeof(ULONG), reinterpret_cast(&canonicalChars[conversions[i].ch])); } - catch (const Firebird::Exception&) + catch (const Exception&) { memset(&canonicalChars[conversions[i].ch], 0, sizeof(ULONG)); } @@ -194,7 +194,7 @@ USHORT TextType::string_to_key(USHORT srcLen, const UCHAR* src, const UCHAR* space = getCharSet()->getSpace(); BYTE spaceLength = getCharSet()->getSpaceLength(); - Firebird::HalfStaticArray utf16Str; + HalfStaticArray utf16Str; UCHAR utf16Space[sizeof(ULONG)]; if (getCharSet()->isMultiByte()) @@ -228,7 +228,7 @@ USHORT TextType::string_to_key(USHORT srcLen, const UCHAR* src, if (getCharSet()->isMultiByte()) { - dstLen = UnicodeUtil::utf16ToKey(srcLen, Firebird::Aligner(src, srcLen), dstLen, dst); + dstLen = UnicodeUtil::utf16ToKey(srcLen, Aligner(src, srcLen), dstLen, dst); } else { @@ -254,8 +254,8 @@ SSHORT TextType::compare(ULONG len1, const UCHAR* str1, ULONG len2, const UCHAR* const UCHAR* space = getCharSet()->getSpace(); BYTE spaceLength = getCharSet()->getSpaceLength(); - Firebird::HalfStaticArray utf16Str1; - Firebird::HalfStaticArray utf16Str2; + HalfStaticArray utf16Str1; + HalfStaticArray utf16Str2; UCHAR utf16Space[sizeof(ULONG)]; if (getCharSet()->isMultiByte()) @@ -305,8 +305,8 @@ SSHORT TextType::compare(ULONG len1, const UCHAR* str1, ULONG len2, const UCHAR* if (getCharSet()->isMultiByte()) { INTL_BOOL error_flag; - return UnicodeUtil::utf16Compare(len1, Firebird::Aligner(str1, len1), - len2, Firebird::Aligner(str2, len2), &error_flag); + return UnicodeUtil::utf16Compare(len1, Aligner(str1, len1), + len2, Aligner(str2, len2), &error_flag); } int cmp = memcmp(str1, str2, MIN(len1, len2)); @@ -324,12 +324,12 @@ ULONG TextType::str_to_upper(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR { const ULONG result = tt->texttype_fn_str_to_upper ? (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst) : - Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL); + IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL); if (result == INTL_BAD_STR_LENGTH) { - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_arith_except) << - Firebird::Arg::Gds(isc_transliteration_failed)); + status_exception::raise(Arg::Gds(isc_arith_except) << + Arg::Gds(isc_transliteration_failed)); } return result; @@ -340,12 +340,12 @@ ULONG TextType::str_to_lower(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR { const ULONG result = tt->texttype_fn_str_to_lower ? (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst) : - Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL); + IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL); if (result == INTL_BAD_STR_LENGTH) { - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_arith_except) << - Firebird::Arg::Gds(isc_transliteration_failed)); + status_exception::raise(Arg::Gds(isc_arith_except) << + Arg::Gds(isc_transliteration_failed)); } return result; @@ -361,7 +361,7 @@ ULONG TextType::canonical(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* d { fb_assert(tt->texttype_canonical_width == sizeof(ULONG)); - Firebird::HalfStaticArray utf16_str; + HalfStaticArray utf16_str; ULONG utf16_len = getCharSet()->getConvToUnicode().convertLength(srcLen); @@ -374,8 +374,8 @@ ULONG TextType::canonical(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* d USHORT errCode; // convert UTF-16 to UTF-32 - return UnicodeUtil::utf16ToUtf32(utf16_len, Firebird::Aligner(utf16_str.begin(), utf16_len), - dstLen, Firebird::OutAligner(dst, dstLen), &errCode, &errPos) / sizeof(ULONG); + return UnicodeUtil::utf16ToUtf32(utf16_len, Aligner(utf16_str.begin(), utf16_len), + dstLen, OutAligner(dst, dstLen), &errCode, &errPos) / sizeof(ULONG); } fb_assert( @@ -398,4 +398,4 @@ USHORT TextType::getFlags() const return tt->texttype_flags; } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/common/TextType.h b/src/common/TextType.h index f952c9624ac..f5f46bfbde9 100644 --- a/src/common/TextType.h +++ b/src/common/TextType.h @@ -97,7 +97,7 @@ class TextType USHORT getFlags() const; public: - Firebird::QualifiedMetaString name; + QualifiedMetaString name; protected: texttype* tt; diff --git a/src/common/ThreadData.cpp b/src/common/ThreadData.cpp index d0f30ec9467..7db7f44a117 100644 --- a/src/common/ThreadData.cpp +++ b/src/common/ThreadData.cpp @@ -57,7 +57,9 @@ #include "../common/classes/locks.h" #include "../common/classes/rwlock.h" -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -84,3 +86,6 @@ void ThreadData::restoreSpecific() ThreadData* current_context = getSpecific(); TLS_SET(tData, current_context->threadDataPriorContext); } + + +} // namespace Firebird diff --git a/src/common/ThreadStart.cpp b/src/common/ThreadStart.cpp index b5d6eb12e47..43bc0e0121e 100644 --- a/src/common/ThreadStart.cpp +++ b/src/common/ThreadStart.cpp @@ -53,6 +53,9 @@ #include "../common/classes/rwlock.h" #include "../common/classes/Synchronize.h" +namespace Firebird +{ + namespace { @@ -86,7 +89,7 @@ extern "C" THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) { fb_assert(arg); - Firebird::ThreadSync* thread = FB_NEW Firebird::ThreadSync("threadStart"); + ThreadSync* thread = FB_NEW ThreadSync("threadStart"); MemoryPool::setContextPool(getDefaultMemoryPool()); ThreadArgs localArgs(*static_cast(arg)); @@ -94,7 +97,7 @@ THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) localArgs.run(); // Check if ThreadSync still exists before deleting - thread = Firebird::ThreadSync::findThread(); + thread = ThreadSync::findThread(); delete thread; return 0; @@ -124,18 +127,18 @@ void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Threa #if defined (LINUX) || defined (FREEBSD) if ((state = pthread_create(&pThread->m_handle, NULL, THREAD_ENTRYPOINT, THREAD_ARG))) - Firebird::system_call_failed::raise("pthread_create", state); + system_call_failed::raise("pthread_create", state); if (pThread == &thread) { if ((state = pthread_detach(pThread->m_handle))) - Firebird::system_call_failed::raise("pthread_detach", state); + system_call_failed::raise("pthread_detach", state); } #else pthread_attr_t pattr; state = pthread_attr_init(&pattr); if (state) - Firebird::system_call_failed::raise("pthread_attr_init", state); + system_call_failed::raise("pthread_attr_init", state); #if defined(_AIX) || defined(DARWIN) || defined(HPUX) // adjust stack size @@ -149,32 +152,32 @@ void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Threa size_t stack_size; state = pthread_attr_getstacksize(&pattr, &stack_size); if (state) - Firebird::system_call_failed::raise("pthread_attr_getstacksize"); + system_call_failed::raise("pthread_attr_getstacksize"); if (stack_size < 0x400000L) { state = pthread_attr_setstacksize(&pattr, 0x400000L); if (state) - Firebird::system_call_failed::raise("pthread_attr_setstacksize", state); + system_call_failed::raise("pthread_attr_setstacksize", state); } #endif // _AIX state = pthread_attr_setscope(&pattr, PTHREAD_SCOPE_SYSTEM); if (state) - Firebird::system_call_failed::raise("pthread_attr_setscope", state); + system_call_failed::raise("pthread_attr_setscope", state); if (pThread == &thread) { state = pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); if (state) - Firebird::system_call_failed::raise("pthread_attr_setdetachstate", state); + system_call_failed::raise("pthread_attr_setdetachstate", state); } state = pthread_create(&pThread->m_handle, &pattr, THREAD_ENTRYPOINT, THREAD_ARG); int state2 = pthread_attr_destroy(&pattr); if (state) - Firebird::system_call_failed::raise("pthread_create", state); + system_call_failed::raise("pthread_create", state); if (state2) - Firebird::system_call_failed::raise("pthread_attr_destroy", state2); + system_call_failed::raise("pthread_attr_destroy", state2); #endif @@ -184,7 +187,7 @@ void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Threa int dummy; // We do not want to know old cancel type state = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &dummy); if (state) - Firebird::system_call_failed::raise("pthread_setcanceltype", state); + system_call_failed::raise("pthread_setcanceltype", state); } #endif } @@ -197,7 +200,7 @@ void Thread::waitForCompletion() int state = pthread_join(m_handle, NULL); if (state) - Firebird::system_call_failed::raise("pthread_join", state); + system_call_failed::raise("pthread_join", state); m_handle = INVALID_HANDLE; } } @@ -249,12 +252,12 @@ void Thread::sleep(unsigned milliseconds) { if (errno != EINTR) { - Firebird::system_call_failed::raise("nanosleep"); + system_call_failed::raise("nanosleep"); } timer = rem; } #else - Firebird::Semaphore timer; + Semaphore timer; timer.tryEnter(0, milliseconds); #endif } @@ -334,7 +337,7 @@ void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Threa // GetLastError() still works because RTL call no other system // functions after CreateThread() in the case of error. // Watch out if it is ever changed. - Firebird::system_call_failed::raise("_beginthreadex", GetLastError()); + system_call_failed::raise("_beginthreadex", GetLastError()); } SetThreadPriority(handle, priority); @@ -371,7 +374,7 @@ void Thread::waitForCompletion() // When current DLL is unloading, OS loader holds loader lock. When thread is // exiting, OS notifies every DLL about it, and acquires loader lock. In such // scenario waiting on thread handle will never succeed. - if (!Firebird::dDllUnloadTID) { + if (!dDllUnloadTID) { WaitForSingleObject(m_handle, 10000); // error handler ???????????? } detach(); @@ -409,3 +412,6 @@ void Thread::yield() } #endif // WIN_NT + + +} // namespace Firebird diff --git a/src/common/ThreadStart.h b/src/common/ThreadStart.h index 40412735e4f..0f24a128ed7 100644 --- a/src/common/ThreadStart.h +++ b/src/common/ThreadStart.h @@ -37,6 +37,9 @@ #include #endif +namespace Firebird +{ + // Thread priorities (may be ignored) @@ -225,7 +228,7 @@ class ThreadFinishSync public: typedef void ThreadRoutine(TA); - ThreadFinishSync(Firebird::MemoryPool& pool, ThreadRoutine* routine, int priority_arg = THREAD_medium) + ThreadFinishSync(MemoryPool& pool, ThreadRoutine* routine, int priority_arg = THREAD_medium) : threadRoutine(routine), threadPriority(priority_arg), closing(false) @@ -271,7 +274,7 @@ class ThreadFinishSync { threadRoutine(threadArg); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { threadArg->exceptionHandler(ex, threadRoutine); } @@ -282,4 +285,7 @@ class ThreadFinishSync } }; + +} // namespace Firebird + #endif // JRD_THREADSTART_H diff --git a/src/common/TimeZoneUtil.cpp b/src/common/TimeZoneUtil.cpp index 6533976f855..fbc5297890e 100644 --- a/src/common/TimeZoneUtil.cpp +++ b/src/common/TimeZoneUtil.cpp @@ -36,7 +36,9 @@ #include "../common/os/os_utils.h" #include "unicode/ucal.h" -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -433,7 +435,7 @@ USHORT TimeZoneUtil::getSystemTimeZone() return cachedTimeZoneId; } -void TimeZoneUtil::getDatabaseVersion(Firebird::string& str) +void TimeZoneUtil::getDatabaseVersion(string& str) { UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); UErrorCode icuErrorCode = U_ZERO_ERROR; @@ -1193,3 +1195,6 @@ static void skipSpaces(const char*& p, const char* end) noexcept while (p < end && (*p == ' ' || *p == '\t')) ++p; } + + +} // namespace Firebird diff --git a/src/common/TimeZoneUtil.h b/src/common/TimeZoneUtil.h index 6e054356329..aec35c3b85e 100644 --- a/src/common/TimeZoneUtil.h +++ b/src/common/TimeZoneUtil.h @@ -82,7 +82,7 @@ class TimeZoneUtil static USHORT getSystemTimeZone(); - static void getDatabaseVersion(Firebird::string& str); + static void getDatabaseVersion(string& str); static void iterateRegions(std::function func); diff --git a/src/common/Tokens.cpp b/src/common/Tokens.cpp index 98c387b4573..daa42683479 100644 --- a/src/common/Tokens.cpp +++ b/src/common/Tokens.cpp @@ -29,9 +29,13 @@ #include "../common/StatusArg.h" +namespace Firebird +{ + + namespace { -constexpr Firebird::Tokens::Comment sqlComments[3] = { +constexpr Tokens::Comment sqlComments[3] = { { "/*", "*/", false }, { "--", "\n", true }, { NULL, NULL, false } @@ -42,8 +46,6 @@ constexpr const char* sqlQuotes = "\"'"; } // anonymous namespace -namespace Firebird { - Tokens::Tokens() : tokens(getPool()), str(getPool()), diff --git a/src/common/UtilSvc.cpp b/src/common/UtilSvc.cpp index 0aeca03cdae..d6844be1ad1 100644 --- a/src/common/UtilSvc.cpp +++ b/src/common/UtilSvc.cpp @@ -48,7 +48,7 @@ namespace { // runtime returns the number of characters (instead of bytes) written and make // ferror(stdout) return true. So lets not check for errors here. #ifndef WIN_NT - Firebird::system_call_failed::raise("StandaloneUtilityInterface::output()/fwrite()"); + system_call_failed::raise("StandaloneUtilityInterface::output()/fwrite()"); #endif } } @@ -145,7 +145,7 @@ class StandaloneUtilityInterface : public UtilSvc void fillDpb(ClumpletWriter&) override { } bool finished() override { return false; } bool utf8FileNames() override { return false; } - Firebird::ICryptKeyCallback* getCryptCallback() override { return NULL; } + ICryptKeyCallback* getCryptCallback() override { return NULL; } int getParallelWorkers() override { return 0; }; }; diff --git a/src/common/UtilSvc.h b/src/common/UtilSvc.h index 746f8dca281..2a69059c534 100644 --- a/src/common/UtilSvc.h +++ b/src/common/UtilSvc.h @@ -36,7 +36,7 @@ #include "../common/classes/array.h" #include "../common/classes/fb_string.h" -namespace MsgFormat { +namespace Firebird::MsgFormat { class SafeArg; } @@ -46,17 +46,17 @@ inline constexpr TEXT SVC_TRMNTR = '\377'; // ASCII 255 class ClumpletWriter; -class UtilSvc : public Firebird::GlobalStorage +class UtilSvc : public GlobalStorage { public: - typedef Firebird::HalfStaticArray ArgvType; + typedef HalfStaticArray ArgvType; // Services is rare for our code case where status vector is accessed from 2 different threads // in async way. To ensure it's stability appropriate protection is needed. class StatusAccessor { public: - StatusAccessor(Mutex& mtx, Firebird::CheckStatusWrapper* st, UtilSvc* u) + StatusAccessor(Mutex& mtx, CheckStatusWrapper* st, UtilSvc* u) : mutex(&mtx), status(st), uSvc(u) { mutex->enter(FB_FUNCTION); @@ -74,12 +74,12 @@ class UtilSvc : public Firebird::GlobalStorage sa.status = nullptr; } - operator const Firebird::CheckStatusWrapper*() const noexcept + operator const CheckStatusWrapper*() const noexcept { return status; } - const Firebird::CheckStatusWrapper* operator->() const noexcept + const CheckStatusWrapper* operator->() const noexcept { return status; } @@ -113,7 +113,7 @@ class UtilSvc : public Firebird::GlobalStorage private: Mutex* mutex; - Firebird::CheckStatusWrapper* status; + CheckStatusWrapper* status; UtilSvc* uSvc; }; @@ -141,11 +141,11 @@ class UtilSvc : public Firebird::GlobalStorage virtual StatusAccessor getStatusAccessor() = 0; virtual void checkService() = 0; virtual void hidePasswd(ArgvType&, int) = 0; - virtual void fillDpb(Firebird::ClumpletWriter& dpb) = 0; + virtual void fillDpb(ClumpletWriter& dpb) = 0; virtual bool finished() = 0; virtual unsigned int getAuthBlock(const unsigned char** bytes) = 0; virtual bool utf8FileNames() = 0; - virtual Firebird::ICryptKeyCallback* getCryptCallback() = 0; + virtual ICryptKeyCallback* getCryptCallback() = 0; virtual int getParallelWorkers() = 0; void setDataMode(bool value) noexcept @@ -157,7 +157,7 @@ class UtilSvc : public Firebird::GlobalStorage static UtilSvc* createStandalone(int ac, char** argv); - static inline void addStringWithSvcTrmntr(const Firebird::string& str, Firebird::string& switches) + static inline void addStringWithSvcTrmntr(const string& str, string& switches) { // All string parameters are delimited by SVC_TRMNTR. // This is done to ensure that paths with spaces are handled correctly diff --git a/src/common/call_service.cpp b/src/common/call_service.cpp index 86b9f330989..5ef9798138b 100644 --- a/src/common/call_service.cpp +++ b/src/common/call_service.cpp @@ -28,9 +28,11 @@ #include #include #include "../common/utils_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird +{ -using namespace Firebird; constexpr FB_SIZE_T SERVICE_SIZE = 256; constexpr FB_SIZE_T SERVER_PART = 200; @@ -94,7 +96,7 @@ static bool serverSizeValidate(ISC_STATUS* status, const TEXT* server) } -static int typeBuffer(ISC_STATUS*, char*, int, Auth::UserData&, Firebird::IListUsers*, Firebird::string&); +static int typeBuffer(ISC_STATUS*, char*, int, Auth::UserData&, IListUsers*, string&); // all this spb-writing functions should be gone @@ -327,7 +329,7 @@ static void userInfoToSpb(char*& spb, Auth::UserData& userData) } -static void setAttr(string& a, const char* nm, Firebird::IIntUserField* f) +static void setAttr(string& a, const char* nm, IIntUserField* f) { if (f->entered()) { @@ -368,7 +370,7 @@ static void setAttr(CheckStatusWrapper* status, Auth::UserData* u) void callRemoteServiceManager(ISC_STATUS* status, isc_svc_handle handle, Auth::UserData& userData, - Firebird::IListUsers* callback) + IListUsers* callback) { char spb_buffer[1024]; char* spb = spb_buffer; @@ -454,7 +456,7 @@ void callRemoteServiceManager(ISC_STATUS* status, stuffSpbLong(spb, 10); char resultBuffer[RESULT_BUF_SIZE + 4]; - Firebird::string text; + string text; ISC_STATUS_ARRAY temp_status; ISC_STATUS* local_status = status[1] ? temp_status : status; @@ -618,8 +620,8 @@ static void parseLong(const char*& p, Auth::IntField& f, FB_SIZE_T& loop) **/ static int typeBuffer(ISC_STATUS* status, char* buf, int offset, - Auth::UserData& uData, Firebird::IListUsers* callback, - Firebird::string& text) + Auth::UserData& uData, IListUsers* callback, + string& text) { const char* p = &buf[offset]; @@ -778,3 +780,6 @@ static void checkServerUsersVersion(isc_svc_handle svc_handle, char& server_user } } } + + +} // namespace Firebird diff --git a/src/common/call_service.h b/src/common/call_service.h index aaccb014c05..1612c400d16 100644 --- a/src/common/call_service.h +++ b/src/common/call_service.h @@ -28,10 +28,13 @@ #include "../utilities/gsec/gsec.h" #include "../common/security.h" -isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, - bool, int, const TEXT*); -isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, bool, const TEXT*, bool); -void callRemoteServiceManager(ISC_STATUS*, isc_svc_handle, Auth::UserData&, Firebird::IListUsers*); -void detachRemoteServiceManager(ISC_STATUS*, isc_svc_handle); +namespace Firebird +{ + isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, + bool, int, const TEXT*); + isc_svc_handle attachRemoteServiceManager(ISC_STATUS*, const TEXT*, const TEXT*, bool, const TEXT*, bool); + void callRemoteServiceManager(ISC_STATUS*, isc_svc_handle, Auth::UserData&, IListUsers*); + void detachRemoteServiceManager(ISC_STATUS*, isc_svc_handle); +} // namespace Firebird #endif // UTILITIES_GSEC_CALL_SERVICE_H diff --git a/src/common/classes/Aligner.h b/src/common/classes/Aligner.h index d4ef80a44cb..0e42aeca2d4 100644 --- a/src/common/classes/Aligner.h +++ b/src/common/classes/Aligner.h @@ -40,7 +40,7 @@ class OutAligner private: UCHAR* const userBuffer; #ifdef RISC_ALIGNMENT - Firebird::HalfStaticArray localBuffer; + HalfStaticArray localBuffer; ULONG bSize; C* bPointer; #endif @@ -105,7 +105,7 @@ class Aligner { private: #ifdef RISC_ALIGNMENT - Firebird::HalfStaticArray localBuffer; + HalfStaticArray localBuffer; #endif const C* bPointer; diff --git a/src/common/classes/BaseStream.cpp b/src/common/classes/BaseStream.cpp index 0a8e5d49f95..08e38699507 100644 --- a/src/common/classes/BaseStream.cpp +++ b/src/common/classes/BaseStream.cpp @@ -32,8 +32,7 @@ #include #endif -namespace MsgFormat -{ +namespace Firebird::MsgFormat { int RawStream::write(const void* str, unsigned int n) { diff --git a/src/common/classes/BaseStream.h b/src/common/classes/BaseStream.h index d7815cc0b01..77e5c419723 100644 --- a/src/common/classes/BaseStream.h +++ b/src/common/classes/BaseStream.h @@ -34,8 +34,7 @@ #include "../common/classes/fb_string.h" #include -namespace MsgFormat -{ +namespace Firebird::MsgFormat { // This is the abstract base class that is used by the MsgPrint routines. // It doesn't own the stream, thus it doesn't open, check or close it. @@ -112,11 +111,11 @@ class StringStream : public BaseStream }; -// Wraps a reference to a Firebird::string. +// Wraps a reference to a string. class StringRefStream : public BaseStream { public: - StringRefStream(Firebird::string& aRef) + StringRefStream(string& aRef) : ref(aRef) { } @@ -128,7 +127,7 @@ class StringRefStream : public BaseStream } private: - Firebird::string& ref; + string& ref; }; } // namespace diff --git a/src/common/classes/BlobWrapper.cpp b/src/common/classes/BlobWrapper.cpp index c37751dcec1..9adc20a3e5e 100644 --- a/src/common/classes/BlobWrapper.cpp +++ b/src/common/classes/BlobWrapper.cpp @@ -27,9 +27,12 @@ #include "ibase.h" #include "firebird/Interface.h" +namespace Firebird +{ + + static constexpr USHORT SEGMENT_LIMIT = 65535; -using namespace Firebird; bool BlobWrapper::open(IAttachment* db, ITransaction* trans, ISC_QUAD& blobid, USHORT bpb_len, const UCHAR* bpb) @@ -94,7 +97,7 @@ bool BlobWrapper::getSegment(FB_SIZE_T len, void* buffer, FB_SIZE_T& real_len) const unsigned ilen = MIN(len, SEGMENT_LIMIT); unsigned olen = 0; - const bool eof = m_blob->getSegment(m_status, ilen, buffer, &olen) == Firebird::IStatus::RESULT_NO_DATA; + const bool eof = m_blob->getSegment(m_status, ilen, buffer, &olen) == IStatus::RESULT_NO_DATA; if (m_status->isEmpty() && !eof) { real_len = olen; @@ -121,7 +124,7 @@ bool BlobWrapper::getData(FB_SIZE_T len, void* buffer, FB_SIZE_T& real_len, { unsigned olen = 0; const unsigned ilen = MIN(len, SEGMENT_LIMIT); - const bool eof = m_blob->getSegment(m_status, ilen, buf2, &olen) == Firebird::IStatus::RESULT_NO_DATA; + const bool eof = m_blob->getSegment(m_status, ilen, buf2, &olen) == IStatus::RESULT_NO_DATA; if (m_status->isEmpty() && !eof) { len -= olen; @@ -278,3 +281,6 @@ bool BlobWrapper::getSize(FB_UINT64* size, ULONG* seg_count, USHORT* max_seg) co return true; } + + +} // namespace Firebird diff --git a/src/common/classes/BlobWrapper.h b/src/common/classes/BlobWrapper.h index 7f808be67b3..0504f309f56 100644 --- a/src/common/classes/BlobWrapper.h +++ b/src/common/classes/BlobWrapper.h @@ -29,10 +29,14 @@ #include #include "../common/status.h" +namespace Firebird +{ + + class BlobWrapper { public: - explicit BlobWrapper(Firebird::CheckStatusWrapper* status) + explicit BlobWrapper(CheckStatusWrapper* status) : m_status(status ? status : &m_default_status), m_blob(nullptr), m_direction(dir_none) { } @@ -41,9 +45,9 @@ class BlobWrapper close(true); } - bool open(Firebird::IAttachment* db, Firebird::ITransaction* trans, ISC_QUAD& blobid, + bool open(IAttachment* db, ITransaction* trans, ISC_QUAD& blobid, USHORT bpb_len = 0, const UCHAR* bpb = nullptr); - bool create(Firebird::IAttachment* db, Firebird::ITransaction* trans, ISC_QUAD& blobid, + bool create(IAttachment* db, ITransaction* trans, ISC_QUAD& blobid, USHORT bpb_len = 0, const UCHAR* bpb = nullptr); bool close(bool force_internal_SV = false); bool getSegment(FB_SIZE_T len, void* buffer, FB_SIZE_T& real_len); @@ -83,13 +87,13 @@ class BlobWrapper dir_write }; - Firebird::FbLocalStatus m_default_status; - Firebird::CheckStatusWrapper* const m_status; - Firebird::IBlob* m_blob; + FbLocalStatus m_default_status; + CheckStatusWrapper* const m_status; + IBlob* m_blob; b_direction m_direction; }; +} // namespace Firebird #endif // FB_USER_BLOB_H - diff --git a/src/common/classes/BlrReader.h b/src/common/classes/BlrReader.h index cc654220d28..fc03dbf1aef 100644 --- a/src/common/classes/BlrReader.h +++ b/src/common/classes/BlrReader.h @@ -26,7 +26,7 @@ #include "iberror.h" #include "../common/classes/fb_string.h" #include "../common/StatusArg.h" -#include "../jrd/constants.h" +#include "../common/constants.h" namespace Firebird { diff --git a/src/common/classes/BlrWriter.cpp b/src/common/classes/BlrWriter.cpp index 6fb04f382a9..ba784968246 100644 --- a/src/common/classes/BlrWriter.cpp +++ b/src/common/classes/BlrWriter.cpp @@ -117,4 +117,4 @@ void BlrWriter::raiseError(const Arg::StatusVector& vector) vector.raise(); } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/common/classes/BlrWriter.h b/src/common/classes/BlrWriter.h index f8875c0a96f..0644b8bd7a2 100644 --- a/src/common/classes/BlrWriter.h +++ b/src/common/classes/BlrWriter.h @@ -30,10 +30,10 @@ namespace Firebird { // BLR/DYN writer. -class BlrWriter : public Firebird::PermanentStorage +class BlrWriter : public PermanentStorage { public: - typedef Firebird::HalfStaticArray BlrData; + typedef HalfStaticArray BlrData; explicit BlrWriter(MemoryPool& p) : PermanentStorage(p), diff --git a/src/common/classes/ByteChunk.h b/src/common/classes/ByteChunk.h index dc913cd4ed6..560d88d9981 100644 --- a/src/common/classes/ByteChunk.h +++ b/src/common/classes/ByteChunk.h @@ -41,7 +41,7 @@ struct ByteChunk // Array buffer. // This constructor is intentionally not-explicit. template - ByteChunk(const Firebird::Array& array) + ByteChunk(const Array& array) : data(array.begin()), length(array.getCount()) { diff --git a/src/common/classes/ClumpletReader.cpp b/src/common/classes/ClumpletReader.cpp index 93d2a66ff18..0933fde3e67 100644 --- a/src/common/classes/ClumpletReader.cpp +++ b/src/common/classes/ClumpletReader.cpp @@ -1018,9 +1018,9 @@ void dumpAuthBlock(const char* text, ClumpletReader* pb, unsigned char param) fprintf(stderr, "AuthBlock in %s:", text); if (pb->find(param)) { - Firebird::AuthReader::AuthBlock tmp; + AuthReader::AuthBlock tmp; tmp.assign(pb->getBytes(), pb->getClumpLength()); - Firebird::AuthReader rdr(tmp); + AuthReader rdr(tmp); string name, plugin; PathName secureDb; bool x = false; diff --git a/src/common/classes/DbImplementation.cpp b/src/common/classes/DbImplementation.cpp index 9fb78c56da9..ab8117fe661 100644 --- a/src/common/classes/DbImplementation.cpp +++ b/src/common/classes/DbImplementation.cpp @@ -145,7 +145,7 @@ constexpr UCHAR backEndianess[FB_NELEM(hardware)] = namespace Firebird { -DbImplementation::DbImplementation(const Ods::header_page* h) noexcept +DbImplementation::DbImplementation(const Jrd::Ods::header_page* h) noexcept : di_cpu(h->hdr_db_impl.hdr_cpu), di_os(h->hdr_db_impl.hdr_os), di_cc(h->hdr_db_impl.hdr_cc), di_flags(h->hdr_db_impl.hdr_compat) { @@ -195,7 +195,7 @@ bool DbImplementation::compatible(const DbImplementation& v) const noexcept return di_flags == v.di_flags; } -void DbImplementation::store(Ods::header_page* h) const noexcept +void DbImplementation::store(Jrd::Ods::header_page* h) const noexcept { h->hdr_db_impl.hdr_cpu = di_cpu; h->hdr_db_impl.hdr_os = di_os; diff --git a/src/common/classes/DbImplementation.h b/src/common/classes/DbImplementation.h index 098d54f9b64..39119d18e40 100644 --- a/src/common/classes/DbImplementation.h +++ b/src/common/classes/DbImplementation.h @@ -26,7 +26,7 @@ #include "../common/classes/fb_string.h" -namespace Ods { +namespace Firebird::Jrd::Ods { struct header_page; @@ -37,7 +37,7 @@ namespace Firebird { class DbImplementation { public: - explicit DbImplementation(const Ods::header_page* h) noexcept; + explicit DbImplementation(const Jrd::Ods::header_page* h) noexcept; DbImplementation(UCHAR p_cpu, UCHAR p_os, UCHAR p_cc, UCHAR p_flags) noexcept : di_cpu(p_cpu), di_os(p_os), di_cc(p_cc), di_flags(p_flags) @@ -57,7 +57,7 @@ class DbImplementation string implementation() const; bool compatible(const DbImplementation& v) const noexcept; - void store(Ods::header_page* h) const noexcept; + void store(Jrd::Ods::header_page* h) const noexcept; void stuff(UCHAR** info) const noexcept; static DbImplementation pick(const UCHAR* info) noexcept; UCHAR backwardCompatibleImplementation() const noexcept; diff --git a/src/common/classes/File.h b/src/common/classes/File.h index 02fbfa200d4..353538d598b 100644 --- a/src/common/classes/File.h +++ b/src/common/classes/File.h @@ -63,7 +63,7 @@ class ZeroBuffer FB_SIZE_T getSize() const noexcept { return bufSize; } private: - Firebird::Array buffer; + Array buffer; char* bufAligned; FB_SIZE_T bufSize; }; diff --git a/src/common/classes/Hash.cpp b/src/common/classes/Hash.cpp index 4437c01c3db..a49674f93c4 100644 --- a/src/common/classes/Hash.cpp +++ b/src/common/classes/Hash.cpp @@ -32,10 +32,12 @@ #endif #endif -using namespace Firebird; - unsigned int CRC32C(unsigned int length, const unsigned char* value) noexcept; +namespace Firebird +{ + + namespace { typedef unsigned int (*hash_func_t)(unsigned int length, const UCHAR* value); @@ -95,7 +97,7 @@ namespace #endif } - hash_func_t internalHash = SSE4_2Supported() ? CRC32C : basicHash; + hash_func_t internalHash = SSE4_2Supported() ? ::CRC32C : basicHash; #else // architecture check @@ -131,3 +133,6 @@ void WeakHashContext::finish(dsc& result) { result.makeInt64(0, &hashNumber); } + + +} // namespace Firebird diff --git a/src/common/classes/ImplementHelper.cpp b/src/common/classes/ImplementHelper.cpp index 21b395f9aa0..52e3a7346e8 100644 --- a/src/common/classes/ImplementHelper.cpp +++ b/src/common/classes/ImplementHelper.cpp @@ -31,20 +31,22 @@ #include "../common/classes/ImplementHelper.h" #include "../common/status.h" +namespace Firebird +{ + + namespace { -Firebird::IMaster* cached = NULL; +IMaster* cached = NULL; #ifdef NEVERDEF -typedef Firebird::ReferenceCounterDebugger* ReferenceCounterDebuggerPtr; +typedef ReferenceCounterDebugger* ReferenceCounterDebuggerPtr; TLS_DECLARE(ReferenceCounterDebuggerPtr*, debugArray); #endif // DEV_BUILD -Firebird::UnloadDetector myModule; +UnloadDetector myModule; } -namespace Firebird -{ UnloadDetectorHelper* getUnloadDetector() noexcept { @@ -148,4 +150,5 @@ IDebug* getImpDebug() } #endif //DEV_BUILD -} + +} // namespace Firebird diff --git a/src/common/classes/ImplementHelper.h b/src/common/classes/ImplementHelper.h index 75b5a7b80eb..d33eca5867e 100644 --- a/src/common/classes/ImplementHelper.h +++ b/src/common/classes/ImplementHelper.h @@ -175,7 +175,7 @@ class SimpleFactoryBase : public AutoIfaceaddRef(); return p; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } diff --git a/src/common/classes/InternalMessageBuffer.h b/src/common/classes/InternalMessageBuffer.h index 8947e93c36c..32dde6350c7 100644 --- a/src/common/classes/InternalMessageBuffer.h +++ b/src/common/classes/InternalMessageBuffer.h @@ -41,7 +41,7 @@ class InternalMessageBuffer ~InternalMessageBuffer(); public: - Firebird::IMessageMetadata* metadata; + IMessageMetadata* metadata; UCHAR* buffer; }; diff --git a/src/common/classes/MetaString.h b/src/common/classes/MetaString.h index 7a8f568f1ab..4dfb58bf183 100644 --- a/src/common/classes/MetaString.h +++ b/src/common/classes/MetaString.h @@ -33,7 +33,7 @@ #include "../common/classes/fb_pair.h" #include "../common/classes/objects_array.h" #include "../common/StatusArg.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include #include diff --git a/src/common/classes/MsgPrint.cpp b/src/common/classes/MsgPrint.cpp index c07d68d920e..896a3e21f8c 100644 --- a/src/common/classes/MsgPrint.cpp +++ b/src/common/classes/MsgPrint.cpp @@ -32,10 +32,10 @@ #include "../common/utils_proto.h" #include "../common/file_params.h" - -namespace MsgFormat +namespace Firebird::MsgFormat { + // Enough to the current conversions. If SINT128 is decoded as a full number // instead of two parts, it may be updated to 63, because 2^128 ~ 3.4e38. static constexpr int DECODE_BUF_LEN = 31; @@ -352,8 +352,11 @@ int MsgPrintErr(const char* format, const SafeArg& arg, bool userFormatting) return MsgPrint(st, format, arg, userFormatting); } -} // namespace +} // namespace Firebird::MsgFormat + +namespace Firebird +{ // Lookup and format message. Return as much of formatted string as fits in caller's buffer. int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsize, TEXT* buffer, @@ -377,14 +380,14 @@ int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsi } else { - Firebird::string s; + string s; s.printf("can't format message %d:%d -- ", facility, number); if (n == -1) s += "message text not found"; else if (n == -2) { s += "message file "; - s += fb_utils::getPrefix(Firebird::IConfigManager::DIR_MSG, MSG_FILE).ToString(); + s += fb_utils::getPrefix(IConfigManager::DIR_MSG, MSG_FILE).ToString(); s += " not found"; } else @@ -397,3 +400,6 @@ int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsi return (n > 0 ? total_msg : -total_msg); } + + +} // namespace Firebird diff --git a/src/common/classes/MsgPrint.h b/src/common/classes/MsgPrint.h index fa9afc79e31..b56d074d2d0 100644 --- a/src/common/classes/MsgPrint.h +++ b/src/common/classes/MsgPrint.h @@ -30,8 +30,10 @@ #include "SafeArg.h" -namespace MsgFormat +namespace Firebird::MsgFormat { + + class BaseStream; // Here we have routines that print a message that contains placeholders for @@ -96,14 +98,18 @@ int MsgPrint(char* plainstring, unsigned int s_size, const char* format, const S // E. Prints a formatted string into stderr and flushed the buffer. int MsgPrintErr(const char* format, const SafeArg& arg, bool userFormatting = false); -} // namespace +} // namespace Firebird::MsgFormat -// Type safe replacement of the old gds__msg_format. -int fb_msg_format(void* handle, - USHORT facility, - USHORT number, - unsigned int bsize, - TEXT* buffer, - const MsgFormat::SafeArg& arg); + +namespace Firebird +{ + // Type safe replacement of the old gds__msg_format. + int fb_msg_format(void* handle, + USHORT facility, + USHORT number, + unsigned int bsize, + TEXT* buffer, + const MsgFormat::SafeArg& arg); +} // namespace Firebird #endif // FB_MSGPRINT_H diff --git a/src/common/classes/ParsedList.cpp b/src/common/classes/ParsedList.cpp index 49b7feb424b..4f04abff98e 100644 --- a/src/common/classes/ParsedList.cpp +++ b/src/common/classes/ParsedList.cpp @@ -28,8 +28,9 @@ #include "../common/classes/ParsedList.h" #include "../common/db_alias.h" +namespace Firebird +{ -using namespace Firebird; ParsedList::ParsedList(const PathName& list) { @@ -114,3 +115,6 @@ PathName ParsedList::getNonLoopbackProviders(const PathName& aliasDb) return providers; } + + +} // namespace Firebird diff --git a/src/common/classes/ParsedList.h b/src/common/classes/ParsedList.h index dce15feeff6..ee7258aeba0 100644 --- a/src/common/classes/ParsedList.h +++ b/src/common/classes/ParsedList.h @@ -34,32 +34,32 @@ namespace Firebird { // tools to operate lists of security-related plugins -class ParsedList : public Firebird::ObjectsArray +class ParsedList : public ObjectsArray { public: - explicit ParsedList(const Firebird::PathName& list); + explicit ParsedList(const PathName& list); ParsedList() { } explicit ParsedList(MemoryPool& p) - : Firebird::ObjectsArray(p) + : ObjectsArray(p) { } - ParsedList(const Firebird::PathName& list, const char* delimiters); + ParsedList(const PathName& list, const char* delimiters); // create plane list from this parsed - void makeList(Firebird::PathName& list) const; + void makeList(PathName& list) const; // merge lists keeping only commom for both plugins - static void mergeLists(Firebird::PathName& list, const Firebird::PathName& serverList, - const Firebird::PathName& clientList); + static void mergeLists(PathName& list, const PathName& serverList, + const PathName& clientList); // get providers list for particular database amd remove "Loopback" provider from it - static Firebird::PathName getNonLoopbackProviders(const Firebird::PathName& aliasDb); + static PathName getNonLoopbackProviders(const PathName& aliasDb); private: - void parse(Firebird::PathName list, const char* delimiters); + void parse(PathName list, const char* delimiters); }; } // namespace Firebird diff --git a/src/common/classes/QualifiedMetaString.h b/src/common/classes/QualifiedMetaString.h index 01ee26a5a2f..efeb85dee88 100644 --- a/src/common/classes/QualifiedMetaString.h +++ b/src/common/classes/QualifiedMetaString.h @@ -340,9 +340,9 @@ class BaseQualifiedName return object.isEmpty(); } - Firebird::string toQuotedString() const + string toQuotedString() const { - Firebird::string s; + string s; const auto appendName = [&s](const T& name) { if (name.hasData()) @@ -374,7 +374,7 @@ class BaseQualifiedName bool unambiguous = false; }; -using QualifiedMetaString = Firebird::BaseQualifiedName; +using QualifiedMetaString = BaseQualifiedName; } // namespace Firebird diff --git a/src/common/classes/SafeArg.cpp b/src/common/classes/SafeArg.cpp index ca3a3333c44..9a508264a2d 100644 --- a/src/common/classes/SafeArg.cpp +++ b/src/common/classes/SafeArg.cpp @@ -32,8 +32,7 @@ #include #include "SafeArg.h" -namespace MsgFormat -{ +namespace Firebird::MsgFormat { // This is just a silly convenience in case all arguments are of type int. SafeArg::SafeArg(const int val[], FB_SIZE_T v_size) noexcept diff --git a/src/common/classes/SafeArg.h b/src/common/classes/SafeArg.h index 02af0c32ce7..5cc9346bf63 100644 --- a/src/common/classes/SafeArg.h +++ b/src/common/classes/SafeArg.h @@ -61,8 +61,7 @@ struct DoubleQuad typedef DoubleQuad SINT128; -namespace MsgFormat -{ +namespace Firebird::MsgFormat { // For now we allow 9 parameters; @1..@9 in MsgPrint. inline constexpr FB_SIZE_T SAFEARG_MAX_ARG = 9; diff --git a/src/common/classes/Switches.cpp b/src/common/classes/Switches.cpp index fa1780a5d12..924d37847ae 100644 --- a/src/common/classes/Switches.cpp +++ b/src/common/classes/Switches.cpp @@ -25,6 +25,10 @@ #include "Switches.h" #include "fb_exception.h" +namespace Firebird +{ + + namespace { constexpr char switch_char = '-'; @@ -66,7 +70,7 @@ Switches::~Switches() delete[] m_opLengths; } -const Switches::in_sw_tab_t* Switches::findSwitch(Firebird::string sw, bool* invalidSwitchInd) const +const Switches::in_sw_tab_t* Switches::findSwitch(string sw, bool* invalidSwitchInd) const { /************************************** * @@ -110,7 +114,7 @@ const Switches::in_sw_tab_t* Switches::findSwitch(Firebird::string sw, bool* inv return 0; } -Switches::in_sw_tab_t* Switches::findSwitchMod(Firebird::string& sw, bool* invalidSwitchInd) +Switches::in_sw_tab_t* Switches::findSwitchMod(string& sw, bool* invalidSwitchInd) { /************************************** * @@ -212,7 +216,7 @@ bool Switches::exists(const int in_sw, const char* const* argv, const int start, for (int itr = start; itr < stop; ++itr) { - Firebird::string sw(argv[itr]); + string sw(argv[itr]); if (sw.length() < 2 || sw[0] != switch_char) continue; sw.erase(0, 1); @@ -238,7 +242,7 @@ const char* Switches::findNameByTag(const int in_sw) const // Begin private functions. // static function -bool Switches::matchSwitch(const Firebird::string& sw, const char* target, FB_SIZE_T n) +bool Switches::matchSwitch(const string& sw, const char* target, FB_SIZE_T n) { /************************************** * @@ -295,5 +299,8 @@ const Switches::in_sw_tab_t* Switches::findByTag(const int in_sw, FB_SIZE_T* pos // static function void Switches::complain(const char* msg) { - Firebird::system_call_failed::raise(msg); + system_call_failed::raise(msg); } + + +} // namespace Firebird diff --git a/src/common/classes/Switches.h b/src/common/classes/Switches.h index a02c750e773..cd6fed02e96 100644 --- a/src/common/classes/Switches.h +++ b/src/common/classes/Switches.h @@ -30,6 +30,10 @@ #include "firebird.h" #include "../common/classes/fb_string.h" +namespace Firebird +{ + + class Switches { public: @@ -67,11 +71,11 @@ class Switches // and strings that don't start by an hyphen are discarded silently (function returns NULL). // Strings prefixed by an hyphen that are not found cause invalidSwitchInd to be activated // if the pointer is provided. - const in_sw_tab_t* findSwitch(Firebird::string sw, bool* invalidSwitchInd = 0) const; + const in_sw_tab_t* findSwitch(string sw, bool* invalidSwitchInd = 0) const; // Same as the previous, but it returns a modifiable item. Beware it throws system_call_failed // if "copy" was false in the constructor (no modifiable table was created). - in_sw_tab_t* findSwitchMod(Firebird::string& sw, bool* invalidSwitchInd = 0); + in_sw_tab_t* findSwitchMod(string& sw, bool* invalidSwitchInd = 0); // Get the same unmodifiable table that was passed as parameter to the constructor. const in_sw_tab_t* getTable() const noexcept; @@ -98,7 +102,7 @@ class Switches private: // Auxiliar function for findSwitch, findSwitchMod and exists(). - static bool matchSwitch(const Firebird::string& sw, const char* target, FB_SIZE_T n); + static bool matchSwitch(const string& sw, const char* target, FB_SIZE_T n); // Auxiliar function for exists(). const in_sw_tab_t* findByTag(const int in_sw, FB_SIZE_T* pos = 0, bool rejectAmbiguity = true) const; // Shortcut to raise exceptions @@ -112,4 +116,7 @@ class Switches FB_SIZE_T* m_opLengths; // array of in_sw_name's lengths to avoid recalculation }; + +} // namespace Firebird + #endif // CLASSES_SWITCHES diff --git a/src/common/classes/TomCryptHash.cpp b/src/common/classes/TomCryptHash.cpp index 1816cc0d52b..06d4e9bc4d6 100644 --- a/src/common/classes/TomCryptHash.cpp +++ b/src/common/classes/TomCryptHash.cpp @@ -32,7 +32,8 @@ #endif #include -using namespace Firebird; +namespace Firebird +{ struct LibTomCryptHashContext::Descriptor @@ -163,3 +164,6 @@ void Crc32HashContext::finish(dsc& result) result.makeLong(0, &hash); } + + +} // namespace Firebird diff --git a/src/common/classes/alloc.cpp b/src/common/classes/alloc.cpp index c7132e9661f..c9a9f18f38e 100644 --- a/src/common/classes/alloc.cpp +++ b/src/common/classes/alloc.cpp @@ -74,6 +74,10 @@ //#define VALGRIND_FIX_IT // overrides suspicious valgrind behavior #endif // USE_VALGRIND +namespace Firebird +{ + + namespace { ///#define MEM_DEBUG_EXTERNAL @@ -136,7 +140,7 @@ size_t delayedExtentsPos = 0; // Could slowdown pool significantly ! //#define VALIDATE_POOL -typedef Firebird::AtomicCounter::counter_type StatInt; +typedef AtomicCounter::counter_type StatInt; // We cache this amount of extents to avoid memory mapping overhead constexpr int MAP_CACHE_SIZE = 16; // == 1 MB @@ -164,13 +168,13 @@ FailedBlock* failedList = NULL; void corrupt(const char* text) noexcept { - const bool bcAbort = Firebird::Config::getBugcheckAbort(); - Firebird::Syslog::Record(bcAbort ? Firebird::Syslog::Error : Firebird::Syslog::Warning, text); + const bool bcAbort = Config::getBugcheckAbort(); + Syslog::Record(bcAbort ? Syslog::Error : Syslog::Warning, text); if (bcAbort) abort(); } -Firebird::Mutex* cache_mutex = NULL; +Mutex* cache_mutex = NULL; #if defined(WIN_NT) size_t get_page_size() @@ -192,7 +196,7 @@ inline size_t get_map_page_size() static volatile size_t map_page_size = 0; if (!map_page_size) { - Firebird::MutexLockGuard guard(cache_mutex, "get_map_page_size"); + MutexLockGuard guard(cache_mutex, "get_map_page_size"); if (!map_page_size) map_page_size = get_page_size(); } @@ -201,10 +205,7 @@ inline size_t get_map_page_size() } // anonymous namespace -namespace Firebird { - -namespace SemiDoubleLink -{ +namespace SemiDoubleLink { // SemiDoubleLink makes it possible to walk list one direction, // push/pop/remove members with very efficient back-link to the head pointer somewhere @@ -293,7 +294,7 @@ class MemHeader public: #ifdef DEBUG_GDS_ALLOC - Firebird::CustomSourceLocation location; + CustomSourceLocation location; #elif (SIZEOF_VOID_P == 4) FB_UINT64 dummyAlign; #endif @@ -2415,7 +2416,7 @@ void MemPool::releaseBlock(MemBlock* block, int flags) noexcept void MemPool::memoryIsExhausted(void) { - Firebird::BadAlloc::raise(); + BadAlloc::raise(); } void* MemPool::allocRaw(size_t size) @@ -2921,7 +2922,7 @@ friend class MemoryPool; return; static bool alreadyPrinted = false; - Firebird::AutoPtr file; + AutoPtr file; { // scope char name[PATH_MAX]; @@ -2939,7 +2940,7 @@ friend class MemoryPool; fprintf(file, "********* Moment: %s\n", moment); MemoryPool::externalMemoryManager->print_contents(file, - Firebird::MemoryPool::PRINT_USED_ONLY | Firebird::MemoryPool::PRINT_RECURSIVE); + MemoryPool::PRINT_USED_ONLY | MemoryPool::PRINT_RECURSIVE); file = NULL; alreadyPrinted = true; } @@ -3024,6 +3025,7 @@ void AutoStorage::ProbeStack() const noexcept } #endif + } // namespace Firebird @@ -3032,6 +3034,8 @@ void AutoStorage::ProbeStack() const noexcept // in a case when we actually need "new" only with file/line information // this version should be also present as a pair for "delete". +using namespace Firebird; + void* operator new(size_t s) { return getExternalMemoryPool()->allocate(s); diff --git a/src/common/classes/alloc.h b/src/common/classes/alloc.h index 0d0853d1cd9..b26c32ab2e4 100644 --- a/src/common/classes/alloc.h +++ b/src/common/classes/alloc.h @@ -62,7 +62,7 @@ #include "../common/StdHelper.h" #endif -#define FB_NEW new(*getDefaultMemoryPool()) +#define FB_NEW new(*::Firebird::getDefaultMemoryPool()) #define FB_NEW_POOL(pool) new(pool) #define FB_NEW_RPT(pool, count) new(pool, count) @@ -182,10 +182,10 @@ friend class ExternalMemoryHandler; public: #ifdef DEBUG_GDS_ALLOC -#define ALLOC_PARAMS , const Firebird::CustomSourceLocation location = Firebird::CustomSourceLocation::current() -#define ALLOC_PARAMS_NO_COMMA const Firebird::CustomSourceLocation location = Firebird::CustomSourceLocation::current() -#define ALLOC_PARAMS_DEF , const Firebird::CustomSourceLocation location -#define ALLOC_PARAMS_NO_COMMA_DEF const Firebird::CustomSourceLocation location +#define ALLOC_PARAMS , const ::Firebird::CustomSourceLocation location = ::Firebird::CustomSourceLocation::current() +#define ALLOC_PARAMS_NO_COMMA const ::Firebird::CustomSourceLocation location = ::Firebird::CustomSourceLocation::current() +#define ALLOC_PARAMS_DEF , const ::Firebird::CustomSourceLocation location +#define ALLOC_PARAMS_NO_COMMA_DEF const ::Firebird::CustomSourceLocation location #define ALLOC_PASS_ARGS , location #define ALLOC_PASS_ARGS_NO_COMMA location #else @@ -303,26 +303,20 @@ friend class ExternalMemoryHandler; void initExternalMemoryPool(); -} // namespace Firebird - -static inline Firebird::MemoryPool* getDefaultMemoryPool() noexcept +static inline MemoryPool* getDefaultMemoryPool() noexcept { - fb_assert(Firebird::MemoryPool::defaultMemoryManager); - return Firebird::MemoryPool::defaultMemoryManager; + fb_assert(MemoryPool::defaultMemoryManager); + return MemoryPool::defaultMemoryManager; } -static inline Firebird::MemoryPool* getExternalMemoryPool() noexcept +static inline MemoryPool* getExternalMemoryPool() noexcept { - using namespace Firebird; - if (!MemoryPool::externalMemoryManager) initExternalMemoryPool(); return MemoryPool::externalMemoryManager; } -namespace Firebird { - // Class intended to manage execution context pool stack // Declare instance of this class when you need to set new context pool and it // will be restored automatically as soon holder variable gets out of scope @@ -372,8 +366,6 @@ class SubsystemContextPoolHolder : public ContextPoolHolder } // namespace Firebird -using Firebird::MemoryPool; - // operators new and delete inline void* operator new(size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) @@ -388,12 +380,12 @@ inline void* operator new[](size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) inline void operator delete(void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS_DEF) noexcept { - MemoryPool::globalFree(mem); + Firebird::MemoryPool::globalFree(mem); } inline void operator delete[](void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS_DEF) noexcept { - MemoryPool::globalFree(mem); + Firebird::MemoryPool::globalFree(mem); } #ifdef DEBUG_GDS_ALLOC diff --git a/src/common/classes/array.h b/src/common/classes/array.h index 92bc569799a..78be5f1ad29 100644 --- a/src/common/classes/array.h +++ b/src/common/classes/array.h @@ -187,7 +187,7 @@ class Array : public Storage // CVC: Warning, after this call, "data" is an invalid pointer, be sure to reassign it // or make it equal to this->getStorage() if (data != this->getStorage()) - Firebird::MemoryPool::globalFree(data); + MemoryPool::globalFree(data); } void copyFrom(const Array& source) diff --git a/src/common/classes/fb_string.cpp b/src/common/classes/fb_string.cpp index 616996553d7..5271d676274 100644 --- a/src/common/classes/fb_string.cpp +++ b/src/common/classes/fb_string.cpp @@ -33,6 +33,10 @@ #include #include +namespace Firebird +{ + + #ifdef HAVE_STRCASECMP #define STRNCASECMP strncasecmp #else @@ -63,12 +67,12 @@ namespace { private: char m[32]{}; public: - strBitMask(Firebird::AbstractString::const_pointer s, Firebird::AbstractString::size_type l) noexcept + strBitMask(AbstractString::const_pointer s, AbstractString::size_type l) noexcept { - if (l == Firebird::AbstractString::npos) { - l = static_cast(strlen(s)); + if (l == AbstractString::npos) { + l = static_cast(strlen(s)); } - Firebird::AbstractString::const_pointer end = s + l; + AbstractString::const_pointer end = s + l; while (s < end) { const unsigned char uc = static_cast(*s++); @@ -85,8 +89,6 @@ namespace { } // namespace -namespace Firebird -{ const AbstractString::size_type AbstractString::npos = (AbstractString::size_type)(~0); AbstractString::AbstractString(const size_type limit, const AbstractString& v) @@ -111,7 +113,7 @@ namespace Firebird // fb_assert(n2 < npos - n1 && n1 + n2 <= max_length()); if (n2 > npos - n1) { - Firebird::fatal_exception::raise("String length overflow"); + fatal_exception::raise("String length overflow"); } // checkLength(n1 + n2); redundant: initialize() will check. initialize(n1 + n2); diff --git a/src/common/classes/fb_string.h b/src/common/classes/fb_string.h index 657da3fe054..a9b4df267ca 100644 --- a/src/common/classes/fb_string.h +++ b/src/common/classes/fb_string.h @@ -77,14 +77,14 @@ namespace Firebird void checkPos(size_type pos) const { if (pos >= length()) { - fatal_exception::raise("Firebird::string - pos out of range"); + fatal_exception::raise("string - pos out of range"); } } void checkLength(size_type len) const { if (len > getMaxLength()) { - fatal_exception::raise("Firebird::string - length exceeds predefined limit"); + fatal_exception::raise("string - length exceeds predefined limit"); } } diff --git a/src/common/classes/fb_tls.h b/src/common/classes/fb_tls.h index f27e17fe63d..9c4b99a3857 100644 --- a/src/common/classes/fb_tls.h +++ b/src/common/classes/fb_tls.h @@ -162,7 +162,7 @@ class TlsValue : private InstanceControl } // namespace Firebird -# define TLS_DECLARE(TYPE, NAME) ::Firebird::TlsValue NAME +# define TLS_DECLARE(TYPE, NAME) ::TlsValue NAME # define TLS_GET(NAME) (NAME).get() # define TLS_SET(NAME, VALUE) (NAME).set(VALUE) diff --git a/src/common/classes/init.cpp b/src/common/classes/init.cpp index 75949ae6a9e..bd815e06f6f 100644 --- a/src/common/classes/init.cpp +++ b/src/common/classes/init.cpp @@ -48,17 +48,21 @@ // operator in destructor will cause AV. #undef DEBUG_INIT +namespace Firebird +{ + + static bool dontCleanup = false; namespace { #ifdef DEV_BUILD - [[noreturn]] void cleanError(const Firebird::Exception* e) + [[noreturn]] void cleanError(const Exception* e) { if (e) { // This is done to be able to look at status in debugger - Firebird::StaticStatusVector status; + StaticStatusVector status; e->stuffException(status); } @@ -66,7 +70,7 @@ namespace abort(); } #else - inline void cleanError(const Firebird::Exception*) noexcept { } + inline void cleanError(const Exception*) noexcept { } #endif // This helps initialize globals, needed before regular ctors run @@ -89,14 +93,14 @@ namespace initDone = 2; #ifdef WIN_NT - if (Firebird::bDllProcessExiting) + if (bDllProcessExiting) dontCleanup = true; #endif if (dontCleanup) return; #ifdef DEBUG_GDS_ALLOC - Firebird::AutoPtr file; + AutoPtr file; { // scope char name[PATH_MAX]; @@ -110,14 +114,14 @@ namespace } #endif // DEBUG_GDS_ALLOC - Firebird::InstanceControl::destructors(); + InstanceControl::destructors(); if (dontCleanup) return; try { - Firebird::StaticMutex::release(); + StaticMutex::release(); } catch (...) { @@ -131,11 +135,11 @@ namespace if (file) { getDefaultMemoryPool()->print_contents(file, - Firebird::MemoryPool::PRINT_USED_ONLY | Firebird::MemoryPool::PRINT_RECURSIVE); + MemoryPool::PRINT_USED_ONLY | MemoryPool::PRINT_RECURSIVE); file = NULL; } #endif - Firebird::MemoryPool::cleanupDefaultPool(); + MemoryPool::cleanupDefaultPool(); } catch (...) { @@ -146,7 +150,7 @@ namespace #ifndef DEBUG_INIT // This instance ensures dtors run when program exits - Firebird::CleanupFunction global(allClean); + CleanupFunction global(allClean); #endif //DEBUG_INIT @@ -166,9 +170,9 @@ namespace return; } - Firebird::Mutex::initMutexes(); - Firebird::MemoryPool::initDefaultPool(); - Firebird::StaticMutex::create(); + Mutex::initMutexes(); + MemoryPool::initDefaultPool(); + StaticMutex::create(); #ifdef DEBUG_INIT atexit(allClean); @@ -179,17 +183,15 @@ namespace std::ignore = pthread_atfork(NULL, NULL, child); #endif - Firebird::MemoryPool::contextPoolInit(); + MemoryPool::contextPoolInit(); } - Firebird::InstanceControl::InstanceList* instanceList = 0; + InstanceControl::InstanceList* instanceList = 0; FPTR_VOID gdsCleanup = 0; FPTR_VOID gdsShutdown = 0; } -namespace Firebird -{ InstanceControl::InstanceControl() { // Initialize required subsystems, including static mutex @@ -243,7 +245,7 @@ namespace Firebird { gdsShutdown(); } - catch (const Firebird::Exception& e) + catch (const Exception& e) { cleanError(&e); } @@ -256,7 +258,7 @@ namespace Firebird { gdsCleanup(); } - catch (const Firebird::Exception& e) + catch (const Exception& e) { cleanError(&e); } @@ -283,7 +285,7 @@ namespace Firebird { i->dtor(); } - catch (const Firebird::Exception& e) + catch (const Exception& e) { cleanError(&e); } @@ -324,14 +326,13 @@ namespace Firebird dontCleanup = true; } - namespace StaticMutex - { - Firebird::Mutex* mutex = NULL; + namespace StaticMutex { + Mutex* mutex = NULL; void create() noexcept { - static char place[sizeof(Firebird::Mutex) + FB_ALIGNMENT]; - mutex = new((void*) FB_ALIGN(place, FB_ALIGNMENT)) Firebird::Mutex; + static char place[sizeof(Mutex) + FB_ALIGNMENT]; + mutex = new((void*) FB_ALIGN(place, FB_ALIGNMENT)) Mutex; } void release() noexcept @@ -339,4 +340,6 @@ namespace Firebird mutex->~Mutex(); } } -} + + +} // namespace Firebird diff --git a/src/common/classes/init.h b/src/common/classes/init.h index f673e9bbbf8..6a4ce217057 100644 --- a/src/common/classes/init.h +++ b/src/common/classes/init.h @@ -31,10 +31,11 @@ #include "../common/classes/alloc.h" #include -namespace Firebird { - -namespace StaticMutex +namespace Firebird { + + +namespace StaticMutex { // Support for common mutex for various inits extern Mutex* mutex; void create() noexcept; @@ -357,6 +358,7 @@ class Static : private InitInstance > } }; -} //namespace Firebird + +} // namespace Firebird #endif // CLASSES_INIT_INSTANCE_H diff --git a/src/common/classes/misc/class_perf.cpp b/src/common/classes/misc/class_perf.cpp index 142bfde3262..1a1beca7afb 100644 --- a/src/common/classes/misc/class_perf.cpp +++ b/src/common/classes/misc/class_perf.cpp @@ -47,7 +47,9 @@ void report(int scaleNode, int scaleTree) TEST_ITEMS, scaleNode, scaleTree, (int)(d-t)*1000/CLOCKS_PER_SEC); } -using namespace Firebird; +namespace Firebird +{ + static void testTree() { @@ -202,9 +204,9 @@ static void testAllocatorOverhead() static void testAllocatorMemoryPool() { - printf("Test run for Firebird::MemoryPool...\n"); + printf("Test run for MemoryPool...\n"); start(); - Firebird::MemoryPool* pool = Firebird::MemoryPool::createPool(); + MemoryPool* pool = MemoryPool::createPool(); MallocAllocator allocator; BePlusTree, AllocItem> items(&allocator), bigItems(&allocator); @@ -235,7 +237,7 @@ static void testAllocatorMemoryPool() if (bigItems.getFirst()) do { pool->deallocate(bigItems.current().item); } while (bigItems.getNext()); - Firebird::MemoryPool::deletePool(pool); + MemoryPool::deletePool(pool); report(); } @@ -324,3 +326,6 @@ int main() testAllocatorMalloc(); // testAllocatorOldPool(); } + + +} // namespace Firebird diff --git a/src/common/classes/misc/class_test.cpp b/src/common/classes/misc/class_test.cpp index dc28d164471..f43639c1084 100644 --- a/src/common/classes/misc/class_test.cpp +++ b/src/common/classes/misc/class_test.cpp @@ -33,7 +33,9 @@ #include "sparse_bitmap.h" #include -using namespace Firebird; +namespace Firebird +{ + const int BITMAP_ITEMS = 1000000; @@ -41,7 +43,7 @@ void testBitmap() { MallocAllocator temp; - printf("Test Firebird::SparseBitmap\n"); + printf("Test SparseBitmap\n"); printf("Fill arrays with test data (%d items)...", BITMAP_ITEMS); Vector v1; @@ -61,7 +63,7 @@ void testBitmap() } printf(" DONE\n"); - Firebird::BePlusTree tree(&temp), tree2(&temp); + BePlusTree tree(&temp), tree2(&temp); SparseBitmap bitmap(*getDefaultMemoryPool()), bitmap2(*getDefaultMemoryPool()); printf("Verify SET, TEST operations"); @@ -173,7 +175,7 @@ struct Test void testBePlusTree() { MallocAllocator temp; - printf("Test Firebird::BePlusTree\n"); + printf("Test BePlusTree\n"); printf("Fill array with test data (%d items)...", (int)TEST_ITEMS); Vector v; @@ -494,7 +496,7 @@ struct AllocItem void testAllocator() { - printf("Test Firebird::MemoryPool\n"); + printf("Test MemoryPool\n"); MemoryPool* parent = getDefaultMemoryPool(); MemoryPool* pool = MemoryPool::createPool(parent); @@ -601,3 +603,5 @@ int main() testBitmap(); } + +} // namespace Firebird diff --git a/src/common/classes/misc/string_test.cmd b/src/common/classes/misc/string_test.cmd index b65269e742f..fa5783df6de 100755 --- a/src/common/classes/misc/string_test.cmd +++ b/src/common/classes/misc/string_test.cmd @@ -2,7 +2,7 @@ : PROGRAM: Class library integrity tests : MODULE: string_test.cmd -: DESCRIPTION: test class Firebird::string +: DESCRIPTION: test class string : : The contents of this file are subject to the Initial : Developer's Public License Version 1.0 (the "License"); @@ -28,7 +28,7 @@ : DEV_BUILD makes single iteration, validating all string results. : When not defined, makes 100000 iterations (a few seconds runtime at P-4), : and reports time of that test. -: FIRESTR - use Firebird::string, if not defined - STL basic_string is used. +: FIRESTR - use string, if not defined - STL basic_string is used. : In the latter case some checks are not performed, because not supported by STL : or give AV with it (at least MS VC6 implementation). : Without DEV_BUILD this checks are also not performed to give compareable results @@ -43,10 +43,10 @@ set cc=cl -GR -GX : This line tests our test using std::basic_string : set flags=-DDEV_BUILD -: This line tests correctness of Firebird::string +: This line tests correctness of string set flags=-DFIRESTR -DDEV_BUILD -: This line tests speed of Firebird::string +: This line tests speed of string : set flags=-Ox -DFIRESTR : This line tests speed of std::basic_string for comparison diff --git a/src/common/classes/rwlock.h b/src/common/classes/rwlock.h index fa95b3c5638..aa2469bc8cd 100644 --- a/src/common/classes/rwlock.h +++ b/src/common/classes/rwlock.h @@ -73,7 +73,7 @@ class RWLock : public Reasons public: RWLock() { init(); } - explicit RWLock(Firebird::MemoryPool&) { init(); } + explicit RWLock(MemoryPool&) { init(); } ~RWLock() { if (readers_semaphore && !CloseHandle(readers_semaphore)) diff --git a/src/common/classes/stack.h b/src/common/classes/stack.h index 4dcc0eb9621..c69ae0c3311 100644 --- a/src/common/classes/stack.h +++ b/src/common/classes/stack.h @@ -325,7 +325,7 @@ namespace Firebird { private: // friend definition here is required to implement // Merge/Split pair of functions - friend class ::Firebird::Stack; + friend class Stack; const Entry* stk; FB_SIZE_T elem; @@ -429,7 +429,7 @@ namespace Firebird { class const_iterator { private: - friend class ::Firebird::Stack; + friend class Stack; const Entry* stk; FB_SIZE_T elem; @@ -736,4 +736,3 @@ namespace Firebird { } // namespace Firebird #endif // CLASSES_STACK_H - diff --git a/src/common/classes/tree.h b/src/common/classes/tree.h index 223735827bd..334e4cddb17 100644 --- a/src/common/classes/tree.h +++ b/src/common/classes/tree.h @@ -101,11 +101,11 @@ class BePlusTree static constexpr FB_SIZE_T LEAF_COUNT = LEAF_PAGE_SIZE / sizeof(Value); static constexpr FB_SIZE_T NODE_COUNT = NODE_PAGE_SIZE / sizeof(void*); public: - explicit BePlusTree(Firebird::MemoryPool& _pool) + explicit BePlusTree(MemoryPool& _pool) : pool(&_pool), level(0), defaultAccessor(this) { } - BePlusTree(Firebird::MemoryPool& _pool, const BePlusTree& from) + BePlusTree(MemoryPool& _pool, const BePlusTree& from) : pool(&_pool), level(0), defaultAccessor(this) { append(from); @@ -632,7 +632,7 @@ class BePlusTree }; // class Accessor private: - Firebird::MemoryPool* const pool; + MemoryPool* const pool; int level; NodePtr root; Accessor defaultAccessor; @@ -848,7 +848,7 @@ bool BePlusTree::add(const Value& item, Accessor* a this->root = nodeList; this->level++; } - catch (const Firebird::Exception&) + catch (const Exception&) { // Recover tree to innocent state while (curLevel) diff --git a/src/common/classes/zip.cpp b/src/common/classes/zip.cpp index 3997da39231..e8c3dbbfb58 100644 --- a/src/common/classes/zip.cpp +++ b/src/common/classes/zip.cpp @@ -30,14 +30,16 @@ #ifdef HAVE_ZLIB_H -using namespace Firebird; +namespace Firebird +{ + -ZLib::ZLib(Firebird::MemoryPool&) +ZLib::ZLib(MemoryPool&) { #ifdef WIN_NT - Firebird::PathName name("zlib1.dll"); + PathName name("zlib1.dll"); #else - Firebird::PathName name("libz." SHRLIB_EXT ".1"); + PathName name("libz." SHRLIB_EXT ".1"); #endif z.reset(ModuleLoader::fixAndLoadModule(status, name)); if (z) @@ -73,4 +75,7 @@ void ZLib::freeFunc(void*, void* address) MemoryPool::globalFree(address); } + +} // namespace Firebird + #endif // HAVE_ZLIB_H diff --git a/src/common/classes/zip.h b/src/common/classes/zip.h index 656ebb12bbc..e8e0eefa78f 100644 --- a/src/common/classes/zip.h +++ b/src/common/classes/zip.h @@ -37,7 +37,7 @@ namespace Firebird { class ZLib { public: - explicit ZLib(Firebird::MemoryPool&); + explicit ZLib(MemoryPool&); int ZEXPORT (*deflateInit_)(z_stream* strm, int level, const char *version, int stream_size); int ZEXPORT (*inflateInit_)(z_stream* strm, const char *version, int stream_size); diff --git a/src/common/common.h b/src/common/common.h index 799dfb0f023..8d4e906b9ff 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -355,7 +355,7 @@ #define FB_CC CcMsvc #endif -#define SYS_ERR Arg::Windows +#define SYS_ERR Firebird::Arg::Windows //format for __LINE__ #define LINEFORMAT "d" @@ -415,11 +415,11 @@ * UNIX *****************************************************/ #ifdef UNIX -#define SYS_ERR Arg::Unix +#define SYS_ERR Firebird::Arg::Unix #endif /* UNIX */ #ifndef SYS_ERR -#define SYS_ERR Arg::Unix +#define SYS_ERR Firebird::Arg::Unix #endif #ifndef ERRNO diff --git a/src/common/config/ConfigCache.cpp b/src/common/config/ConfigCache.cpp index d47a05a0c3b..1054f3f26a5 100644 --- a/src/common/config/ConfigCache.cpp +++ b/src/common/config/ConfigCache.cpp @@ -40,7 +40,9 @@ #include #endif -using namespace Firebird; +namespace Firebird +{ + ConfigCache::ConfigCache(MemoryPool& p, const PathName& fName) : PermanentStorage(p), files(FB_NEW_POOL(getPool()) ConfigCache::File(getPool(), fName)) @@ -72,12 +74,12 @@ void ConfigCache::checkLoadConfig() loadConfig(); } -bool ConfigCache::addFile(const Firebird::PathName& fName) +bool ConfigCache::addFile(const PathName& fName) { return files->add(fName); } -Firebird::PathName ConfigCache::getFileName() +PathName ConfigCache::getFileName() { return files->fileName; } @@ -165,3 +167,6 @@ void ConfigCache::File::trim() delete next; next = NULL; } + + +} // namespace Firebird diff --git a/src/common/config/ConfigCache.h b/src/common/config/ConfigCache.h index 18d2fec50cd..0f4aeed7f31 100644 --- a/src/common/config/ConfigCache.h +++ b/src/common/config/ConfigCache.h @@ -32,21 +32,25 @@ #include "../common/classes/fb_string.h" #include "../common/classes/rwlock.h" -class ConfigCache : public Firebird::PermanentStorage +namespace Firebird +{ + + +class ConfigCache : public PermanentStorage { public: - ConfigCache(Firebird::MemoryPool& p, const Firebird::PathName& fName); + ConfigCache(MemoryPool& p, const PathName& fName); virtual ~ConfigCache(); void checkLoadConfig(); - bool addFile(const Firebird::PathName& fName); // Returns true if file was added. - Firebird::PathName getFileName(); + bool addFile(const PathName& fName); // Returns true if file was added. + PathName getFileName(); protected: virtual void loadConfig() = 0; private: - class File : public Firebird::PermanentStorage + class File : public PermanentStorage { class PreciseTime { @@ -82,15 +86,15 @@ class ConfigCache : public Firebird::PermanentStorage }; public: - File(Firebird::MemoryPool& p, const Firebird::PathName& fName); + File(MemoryPool& p, const PathName& fName); ~File(); bool checkLoadConfig(bool set); - bool add(const Firebird::PathName& fName); // Returns true if file was added. + bool add(const PathName& fName); // Returns true if file was added. void trim(); public: - Firebird::PathName fileName; + PathName fileName; private: PreciseTime fileTime; @@ -100,7 +104,10 @@ class ConfigCache : public Firebird::PermanentStorage File* files; public: - Firebird::RWLock rwLock; + RWLock rwLock; }; + +} // namespace Firebird + #endif // COMMON_CONFIG_CACHE_H diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index 0589fbd435d..09acbcc00e2 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -29,7 +29,7 @@ #include "../common/os/fbsyslog.h" #include "../common/os/path_utils.h" #include "../common/utils_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "firebird/Interface.h" #include "../common/db_alias.h" #include "../jrd/build_no.h" @@ -48,6 +48,10 @@ // Currently user can only guess which parameter values have been applied by the engine // and which were ignored. Or resort to reading source code and using debugger to find out. +namespace Firebird +{ + + namespace { /****************************************************************************** @@ -55,24 +59,24 @@ namespace { * firebird.conf implementation */ -class ConfigImpl : public Firebird::PermanentStorage +class ConfigImpl : public PermanentStorage { public: - explicit ConfigImpl(Firebird::MemoryPool& p) - : Firebird::PermanentStorage(p), missConf(false) + explicit ConfigImpl(MemoryPool& p) + : PermanentStorage(p), missConf(false) { - const auto fullName = fb_utils::getPrefix(Firebird::IConfigManager::DIR_CONF, Firebird::CONFIG_FILE); + const auto fullName = fb_utils::getPrefix(IConfigManager::DIR_CONF, CONFIG_FILE); missConf = !PathUtils::canAccess(fullName, 0); if (missConf) { ConfigFile file(ConfigFile::USE_TEXT, ""); - defaultConfig = FB_NEW Firebird::Config(file); + defaultConfig = FB_NEW Config(file); } else { ConfigFile file(fullName, ConfigFile::ERROR_WHEN_MISS); - defaultConfig = FB_NEW Firebird::Config(file); + defaultConfig = FB_NEW Config(file); } } @@ -82,13 +86,13 @@ class ConfigImpl : public Firebird::PermanentStorage /*** It was a kind of getting ready for changing config remotely... - void changeDefaultConfig(Firebird::Config* newConfig) + void changeDefaultConfig(Config* newConfig) { defaultConfig = newConfig; } ***/ - Firebird::RefPtr& getDefaultConfig() noexcept + RefPtr& getDefaultConfig() noexcept { return defaultConfig; } @@ -98,15 +102,15 @@ class ConfigImpl : public Firebird::PermanentStorage return missConf; } - Firebird::IFirebirdConf* getFirebirdConf() + IFirebirdConf* getFirebirdConf() { - Firebird::IFirebirdConf* rc = FB_NEW Firebird::FirebirdConf(defaultConfig); + IFirebirdConf* rc = FB_NEW FirebirdConf(defaultConfig); rc->addRef(); return rc; } private: - Firebird::RefPtr defaultConfig; + RefPtr defaultConfig; bool missConf; }; @@ -116,12 +120,10 @@ class ConfigImpl : public Firebird::PermanentStorage * Static instance of the system configuration file */ -Firebird::InitInstance firebirdConf; +InitInstance firebirdConf; } // anonymous namespace -namespace Firebird -{ IFirebirdConf* getFirebirdConfig() { diff --git a/src/common/config/config.h b/src/common/config/config.h index 68086f75264..eeff65c1078 100644 --- a/src/common/config/config.h +++ b/src/common/config/config.h @@ -28,7 +28,7 @@ #include "../common/classes/RefCounted.h" #include "../common/config/config_file.h" #include "../common/classes/ImplementHelper.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include diff --git a/src/common/config/config_file.cpp b/src/common/config/config_file.cpp index 24572dfc13c..b9ab8e4216f 100644 --- a/src/common/config/config_file.cpp +++ b/src/common/config/config_file.cpp @@ -37,7 +37,9 @@ #include #endif -using namespace Firebird; +namespace Firebird +{ + bool ConfigFile::getLine(Stream* stream, String& str, unsigned int& number) { @@ -110,7 +112,7 @@ class MainStream : public ConfigFile::Stream private: AutoPtr file; - Firebird::PathName fileName; + PathName fileName; unsigned int l; }; @@ -212,7 +214,7 @@ class SubStream : public ConfigFile::Stream } // anonymous namespace -ConfigFile::ConfigFile(const Firebird::PathName& file, USHORT fl, ConfigCache* cache) +ConfigFile::ConfigFile(const PathName& file, USHORT fl, ConfigCache* cache) : AutoStorage(), parameters(getPool()), flags(fl), @@ -245,7 +247,7 @@ ConfigFile::ConfigFile(UseText, const char* configText, USHORT fl) parse(&s); } -ConfigFile::ConfigFile(MemoryPool& p, const Firebird::PathName& file, USHORT fl, ConfigCache* cache) +ConfigFile::ConfigFile(MemoryPool& p, const PathName& file, USHORT fl, ConfigCache* cache) : AutoStorage(p), parameters(getPool()), flags(fl), @@ -571,7 +573,7 @@ bool ConfigFile::substituteStandardDir(const String& from, String& to) const unsigned code; const char* name; } dirs[] = { -#define NMDIR(a) {Firebird::IConfigManager::a, "FB_"#a}, +#define NMDIR(a) {IConfigManager::a, "FB_"#a}, NMDIR(DIR_CONF) NMDIR(DIR_SECDB) NMDIR(DIR_PLUGINS) @@ -581,7 +583,7 @@ bool ConfigFile::substituteStandardDir(const String& from, String& to) const NMDIR(DIR_INTL) NMDIR(DIR_MSG) #undef NMDIR - {Firebird::IConfigManager::DIR_COUNT, NULL} + {IConfigManager::DIR_COUNT, NULL} }; for (const Dir* d = dirs; d->name; ++d) @@ -885,7 +887,7 @@ SINT64 ConfigFile::Parameter::asInteger() const int sign = 1; int state = 1; // 1 - sign, 2 - numbers, 3 - multiplier - Firebird::string trimmed = value; + string trimmed = value; trimmed.trim(" \t"); if (trimmed.isEmpty()) @@ -960,3 +962,5 @@ bool ConfigFile::Parameter::asBoolean() const value.equalsNoCase("y"); } + +} // namespace Firebird diff --git a/src/common/config/config_file.h b/src/common/config/config_file.h index b10669419fc..08d5fb6dbe4 100644 --- a/src/common/config/config_file.h +++ b/src/common/config/config_file.h @@ -29,6 +29,9 @@ #include "../common/classes/fb_string.h" #include "../common/classes/auto.h" +namespace Firebird +{ + /** Since the original (isc.cpp) code wasn't able to provide powerful and easy-to-use abilities to work with complex configurations, a decision @@ -48,7 +51,7 @@ class ConfigCache; -class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted +class ConfigFile : public AutoStorage, public RefCounted { public: // flags for config file @@ -63,9 +66,9 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted enum UseText {USE_TEXT}; // config_file strings are mostly case sensitive - typedef Firebird::string String; + typedef string String; // keys are case-insensitive - typedef Firebird::NoCaseString KeyType; + typedef NoCaseString KeyType; class Stream { @@ -90,7 +93,7 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted KeyType name; String value; - Firebird::RefPtr sub; + RefPtr sub; unsigned int line; bool hasValue; @@ -100,15 +103,15 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted } }; - typedef Firebird::SortedObjectsArray, + typedef SortedObjectsArray, KeyType, Parameter> Parameters; - typedef Firebird::ObjectsArray FilesArray; + typedef ObjectsArray FilesArray; - ConfigFile(const Firebird::PathName& file, USHORT fl = 0, ConfigCache* cache = NULL); + ConfigFile(const PathName& file, USHORT fl = 0, ConfigCache* cache = NULL); ConfigFile(const char* file, USHORT fl = 0, ConfigCache* cache = NULL); ConfigFile(UseText, const char* configText, USHORT fl = 0); - ConfigFile(MemoryPool& p, const Firebird::PathName& file, USHORT fl = 0, ConfigCache* cache = NULL); + ConfigFile(MemoryPool& p, const PathName& file, USHORT fl = 0, ConfigCache* cache = NULL); private: ConfigFile(MemoryPool& p, ConfigFile::Stream* s, USHORT fl); @@ -142,11 +145,14 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted LineType parseLine(const char* fileName, const String& input, Parameter& par); bool translate(const char* fileName, const String& from, String& to) const; [[noreturn]] void badLine(const char* fileName, const String& line); - void include(const char* currentFileName, const Firebird::PathName& path); - bool wildCards(const char* currentFileName, const Firebird::PathName& pathPrefix, FilesArray& components); + void include(const char* currentFileName, const PathName& path); + bool wildCards(const char* currentFileName, const PathName& pathPrefix, FilesArray& components); bool substituteStandardDir(const String& from, String& to) const; void adjustMacroReplacePositions(const String& value, const String& macro, String::size_type& from, String::size_type& to) const; unsigned getDirSeparatorLength(const String& value, String::size_type subFrom) const; }; + +} // namespace Firebird + #endif // CONFIG_CONFIG_FILE_H diff --git a/src/common/constants.h b/src/common/constants.h new file mode 100644 index 00000000000..7543b377768 --- /dev/null +++ b/src/common/constants.h @@ -0,0 +1,529 @@ +/* + * PROGRAM: JRD Access Method + * MODULE: constants.h + * DESCRIPTION: Misc system constants + * + * The contents of this file are subject to the Interbase Public + * License Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy + * of the License at http://www.Inprise.com/IPL.html + * + * Software distributed under the License is distributed on an + * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express + * or implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code was created by Inprise Corporation + * and its predecessors. Portions created by Inprise Corporation are + * Copyright (C) Inprise Corporation. + * + * All Rights Reserved. + * Contributor(s): ______________________________________. + * + * 2001.10.08 Claudio Valderrama: fb_sysflag enum with numbering + * for automatically created triggers that aren't system triggers. + */ + +#ifndef COMMON_CONSTANTS_H +#define COMMON_CONSTANTS_H + +namespace Firebird +{ + +// BLOb Subtype definitions + +/* Subtypes < 0 are user defined + * Subtype 0 means "untyped" + * Subtypes > 0 are Firebird defined + */ + +// BRS 29-Apr-2004 +// replace those constants with public defined ones isc_blob_* +// +//const int BLOB_untyped = 0; +// +//const int BLOB_text = 1; +//const int BLOB_blr = 2; +//const int BLOB_acl = 3; +//const int BLOB_ranges = 4; +//const int BLOB_summary = 5; +//const int BLOB_format = 6; +//const int BLOB_tra = 7; +//const int BLOB_extfile = 8; +//const int BLOB_max_predefined_subtype = 9; +// + +// Column Limits (in bytes) + +inline constexpr ULONG MAX_COLUMN_SIZE = 32767; +inline constexpr ULONG MAX_VARY_COLUMN_SIZE = MAX_COLUMN_SIZE - sizeof(USHORT); + +inline constexpr ULONG MAX_STR_SIZE = 65535; + +inline constexpr int TEMP_STR_LENGTH = 128; + +// Metadata constants + +inline constexpr unsigned METADATA_IDENTIFIER_CHAR_LEN = 63; +inline constexpr unsigned METADATA_BYTES_PER_CHAR = 4; + +// Misc constant values + +inline constexpr unsigned int USERNAME_LENGTH = METADATA_IDENTIFIER_CHAR_LEN * METADATA_BYTES_PER_CHAR; + +inline constexpr FB_SIZE_T MAX_SQL_IDENTIFIER_LEN = METADATA_IDENTIFIER_CHAR_LEN * METADATA_BYTES_PER_CHAR; +inline constexpr FB_SIZE_T MAX_SQL_IDENTIFIER_SIZE = MAX_SQL_IDENTIFIER_LEN + 1; +inline constexpr FB_SIZE_T MAX_CONFIG_NAME_LEN = 63; + +// Every character of the name may be a double-quote needed to be escaped (with another double-quote). +// The name would also need to be enclosed in double-quotes. +// There is two names, separated by a dot. +inline constexpr FB_SIZE_T MAX_QUALIFIED_NAME_TO_STRING_LEN = + ((METADATA_IDENTIFIER_CHAR_LEN * 2 + 2) * 2 + 1) * METADATA_BYTES_PER_CHAR; + +inline constexpr ULONG MAX_SQL_LENGTH = 10 * 1024 * 1024; // 10 MB - just a safety check + +inline constexpr const char* DB_KEY_NAME = "DB_KEY"; +inline constexpr const char* RDB_DB_KEY_NAME = "RDB$DB_KEY"; +inline constexpr const char* RDB_RECORD_VERSION_NAME = "RDB$RECORD_VERSION"; + +inline constexpr const char* NULL_STRING_MARK = "*** null ***"; +inline constexpr const char* UNKNOWN_STRING_MARK = "*** unknown ***"; + +inline constexpr const char* ISC_USER = "ISC_USER"; +inline constexpr const char* ISC_PASSWORD = "ISC_PASSWORD"; + +inline constexpr const char* NULL_ROLE = "NONE"; +#define ADMIN_ROLE "RDB$ADMIN" // It's used in C-string concatenations + +// User name assigned to any user granted USR_locksmith rights. +// If this name is changed, modify also the trigger in +// jrd/grant.gdl (which turns into jrd/trig.h. +inline constexpr const char* DBA_USER_NAME = "SYSDBA"; + +inline constexpr const char* PRIMARY_KEY = "PRIMARY KEY"; +inline constexpr const char* FOREIGN_KEY = "FOREIGN KEY"; +inline constexpr const char* UNIQUE_CNSTRT = "UNIQUE"; +inline constexpr const char* CHECK_CNSTRT = "CHECK"; +inline constexpr const char* NOT_NULL_CNSTRT = "NOT NULL"; + +inline constexpr const char* REL_SCOPE_PERSISTENT = "persistent table %s"; +inline constexpr const char* REL_SCOPE_GTT_PRESERVE = "global temporary table %s of type ON COMMIT PRESERVE ROWS"; +inline constexpr const char* REL_SCOPE_GTT_DELETE = "global temporary table %s of type ON COMMIT DELETE ROWS"; +inline constexpr const char* REL_SCOPE_EXTERNAL = "external table %s"; +inline constexpr const char* REL_SCOPE_VIEW = "view %s"; +inline constexpr const char* REL_SCOPE_VIRTUAL = "virtual table %s"; + +// literal strings in rdb$ref_constraints to be used to identify +// the cascade actions for referential constraints. Used +// by isql/show and isql/extract for now. + +inline constexpr const char* RI_ACTION_CASCADE = "CASCADE"; +inline constexpr const char* RI_ACTION_NULL = "SET NULL"; +inline constexpr const char* RI_ACTION_DEFAULT = "SET DEFAULT"; +inline constexpr const char* RI_ACTION_NONE = "NO ACTION"; +inline constexpr const char* RI_RESTRICT = "RESTRICT"; + +// Automatically created domains for fields with direct data type. +// Also, automatically created indices that are unique or non-unique, but not PK. +inline constexpr const char* IMPLICIT_DOMAIN_PREFIX = "RDB$"; +inline constexpr int IMPLICIT_DOMAIN_PREFIX_LEN = 4; + +// Automatically created indices for PKs. +inline constexpr const char* IMPLICIT_PK_PREFIX = "RDB$PRIMARY"; +inline constexpr int IMPLICIT_PK_PREFIX_LEN = 11; + +// The invisible "id zero" generator. +inline constexpr const char* MASTER_GENERATOR = ""; //Was "RDB$GENERATORS"; + +inline constexpr const char* SYSTEM_SCHEMA = "SYSTEM"; +inline constexpr const char* PUBLIC_SCHEMA = "PUBLIC"; +inline constexpr const char* PLG_LEGACY_SEC_SCHEMA = "PLG$LEGACY_SEC"; + +// Automatically created security classes for SQL objects. +// Keep in sync with trig.h +inline constexpr const char* DEFAULT_CLASS = "SQL$DEFAULT"; +inline constexpr const char* SQL_SECCLASS_GENERATOR = "RDB$SECURITY_CLASS"; +inline constexpr const char* SQL_SECCLASS_PREFIX = "SQL$"; +inline constexpr int SQL_SECCLASS_PREFIX_LEN = 4; +inline constexpr const char* SQL_FLD_SECCLASS_PREFIX = "SQL$GRANT"; +inline constexpr int SQL_FLD_SECCLASS_PREFIX_LEN = 9; + +inline constexpr const char* SQL_DDL_SECCLASS_FORMAT = "SQL$D%02d%s"; +inline constexpr int SQL_DDL_SECCLASS_PREFIX_LEN = 7; + +inline constexpr const char* GEN_SECCLASS_PREFIX = "GEN$"; +inline constexpr int GEN_SECCLASS_PREFIX_LEN = 4; + +inline constexpr const char* PROCEDURES_GENERATOR = "RDB$PROCEDURES"; +inline constexpr const char* FUNCTIONS_GENERATOR = "RDB$FUNCTIONS"; + +// Automatically created check constraints for unnamed PRIMARY and UNIQUE declarations. +inline constexpr const char* IMPLICIT_INTEGRITY_PREFIX = "INTEG_"; +inline constexpr int IMPLICIT_INTEGRITY_PREFIX_LEN = 6; + +// Default publication name +inline constexpr const char* DEFAULT_PUBLICATION = "RDB$DEFAULT"; + +//***************************************** +// System flag meaning - mainly Firebird. +//***************************************** + +enum fb_sysflag { + fb_sysflag_user = 0, + fb_sysflag_system = 1, + fb_sysflag_qli = 2, + fb_sysflag_check_constraint = 3, + fb_sysflag_referential_constraint = 4, + fb_sysflag_view_check = 5, + fb_sysflag_identity_generator = 6 +}; + +enum ViewContextType { + VCT_TABLE, + VCT_VIEW, + VCT_PROCEDURE +}; + +enum IdentityType { + IDENT_TYPE_ALWAYS, + IDENT_TYPE_BY_DEFAULT +}; + +enum SubRoutineType +{ + SUB_ROUTINE_TYPE_PSQL +}; + +// UDF Arguments are numbered from 0 to MAX_UDF_ARGUMENTS -- +// argument 0 is reserved for the return-type of the UDF + +inline constexpr unsigned MAX_UDF_ARGUMENTS = 15; + +// Maximum length of single line returned from pretty printer +inline constexpr int PRETTY_BUFFER_SIZE = 1024; + +inline constexpr int MAX_INDEX_SEGMENTS = 16; + +// Maximum index key length (must be in sync with MAX_PAGE_SIZE in ods.h) +inline constexpr ULONG MAX_KEY = 8192; // Maximum page size possible divide by 4 (MAX_PAGE_SIZE / 4) + +inline constexpr USHORT SQL_MATCH_1_CHAR = '_'; +inline constexpr USHORT SQL_MATCH_ANY_CHARS = '%'; + +inline constexpr size_t MAX_CONTEXT_VARS = 1000; // Maximum number of context variables allowed for a single object + +// Time precision limits and defaults for TIME/TIMESTAMP values. +// Currently they're applied to CURRENT_TIME[STAMP] expressions only. + +// Should be more than 6 as per SQL spec, but we don't support more than 3 yet +inline constexpr size_t MAX_TIME_PRECISION = 3; +// Consistent with the SQL spec +inline constexpr size_t DEFAULT_TIME_PRECISION = 0; +// Should be 6 as per SQL spec +inline constexpr size_t DEFAULT_TIMESTAMP_PRECISION = 3; + +// SQL spec requires an implementation-specific default (6.1 , syntax rules 6 (VARBINARY) and 7 (VARCHAR)) +inline constexpr size_t DEFAULT_VARCHAR_LENGTH = 255; +inline constexpr size_t DEFAULT_VARBINARY_LENGTH = 255; + +// SQL spec requires a default length of 1 (6.1 , syntax rule 5) +inline constexpr size_t DEFAULT_CHAR_LENGTH = 1; +inline constexpr size_t DEFAULT_BINARY_LENGTH = 1; + +inline constexpr size_t MAX_ARRAY_DIMENSIONS = 16; + +inline constexpr size_t MAX_SORT_ITEMS = 255; // ORDER BY f1,...,f255 + +inline constexpr size_t MAX_DB_PER_TRANS = 256; // A multi-db txn can span up to 256 dbs + +// relation types + +enum rel_t { + rel_persistent = 0, + rel_view = 1, + rel_external = 2, + rel_virtual = 3, + rel_temp_preserve = 4, + rel_temp_delete = 5 +}; + +// procedure types + +enum prc_t { + prc_legacy = 0, + prc_selectable = 1, + prc_executable = 2 +}; + +// procedure parameter mechanism + +enum prm_mech_t { + prm_mech_normal = 0, + prm_mech_type_of = 1 +}; + +// states + +enum mon_state_t { + mon_state_idle = 0, + mon_state_active = 1, + mon_state_stalled = 2 +}; + +// shutdown modes (match hdr_nbak_* in ods.h) + +enum shut_mode_t { + shut_mode_online = 0, + shut_mode_multi = 1, + shut_mode_single = 2, + shut_mode_full = 3 +}; + +// backup states (match hdr_backup_* in ods.h) + +enum backup_state_t { + backup_state_unknown = -1, + backup_state_normal = 0, + backup_state_stalled = 1, + backup_state_merge = 2 +}; + +// transaction isolation levels + +enum tra_iso_mode_t { + iso_mode_consistency = 0, + iso_mode_concurrency = 1, + iso_mode_rc_version = 2, + iso_mode_rc_no_version = 3, + iso_mode_rc_read_consistency = 4 +}; + +// statistics groups + +enum stat_group_t { + stat_database = 0, + stat_attachment = 1, + stat_transaction = 2, + stat_statement = 3, + stat_call = 4, + stat_cmp_statement = 5 +}; + +enum InfoType +{ + INFO_TYPE_CONNECTION_ID = 1, + INFO_TYPE_TRANSACTION_ID = 2, + INFO_TYPE_GDSCODE = 3, + INFO_TYPE_SQLCODE = 4, + INFO_TYPE_ROWS_AFFECTED = 5, + INFO_TYPE_TRIGGER_ACTION = 6, + INFO_TYPE_SQLSTATE = 7, + INFO_TYPE_EXCEPTION = 8, + INFO_TYPE_ERROR_MSG = 9, + INFO_TYPE_SESSION_RESETTING = 10, + MAX_INFO_TYPE +}; + +// Replica modes (match hdr_replica_* in ods.h) + +enum ReplicaMode +{ + REPLICA_NONE = 0, + REPLICA_READ_ONLY = 1, + REPLICA_READ_WRITE = 2 +}; + +enum TriggerType +{ + PRE_STORE_TRIGGER = 1, + POST_STORE_TRIGGER = 2, + PRE_MODIFY_TRIGGER = 3, + POST_MODIFY_TRIGGER = 4, + PRE_ERASE_TRIGGER = 5, + POST_ERASE_TRIGGER = 6 +}; + +enum TriggerAction +{ + // Order should be maintained because the numbers are stored in BLR + // and should be in sync with IExternalTrigger::ACTION_* . + TRIGGER_INSERT = 1, + TRIGGER_UPDATE = 2, + TRIGGER_DELETE = 3, + TRIGGER_CONNECT = 4, + TRIGGER_DISCONNECT = 5, + TRIGGER_TRANS_START = 6, + TRIGGER_TRANS_COMMIT = 7, + TRIGGER_TRANS_ROLLBACK = 8, + TRIGGER_DDL = 9 +}; + +inline constexpr unsigned TRIGGER_TYPE_SHIFT = 13; +inline constexpr FB_UINT64 TRIGGER_TYPE_MASK = (QUADCONST(3) << TRIGGER_TYPE_SHIFT); + +inline constexpr FB_UINT64 TRIGGER_TYPE_DML = (QUADCONST(0) << TRIGGER_TYPE_SHIFT); +inline constexpr FB_UINT64 TRIGGER_TYPE_DB = (QUADCONST(1) << TRIGGER_TYPE_SHIFT); +inline constexpr FB_UINT64 TRIGGER_TYPE_DDL = (QUADCONST(2) << TRIGGER_TYPE_SHIFT); + +inline constexpr unsigned DB_TRIGGER_CONNECT = 0; +inline constexpr unsigned DB_TRIGGER_DISCONNECT = 1; +inline constexpr unsigned DB_TRIGGER_TRANS_START = 2; +inline constexpr unsigned DB_TRIGGER_TRANS_COMMIT = 3; +inline constexpr unsigned DB_TRIGGER_TRANS_ROLLBACK = 4; +inline constexpr unsigned DB_TRIGGER_DDL = 5; +inline constexpr unsigned DB_TRIGGERS_COUNT = 6; + +static inline constexpr const char* DDL_TRIGGER_ACTION_NAMES[][2] = +{ + {NULL, NULL}, + {"CREATE", "TABLE"}, + {"ALTER", "TABLE"}, + {"DROP", "TABLE"}, + {"CREATE", "PROCEDURE"}, + {"ALTER", "PROCEDURE"}, + {"DROP", "PROCEDURE"}, + {"CREATE", "FUNCTION"}, + {"ALTER", "FUNCTION"}, + {"DROP", "FUNCTION"}, + {"CREATE", "TRIGGER"}, + {"ALTER", "TRIGGER"}, + {"DROP", "TRIGGER"}, + {"", ""}, {"", ""}, {"", ""}, // gap for TRIGGER_TYPE_MASK - 3 bits + {"CREATE", "EXCEPTION"}, + {"ALTER", "EXCEPTION"}, + {"DROP", "EXCEPTION"}, + {"CREATE", "VIEW"}, + {"ALTER", "VIEW"}, + {"DROP", "VIEW"}, + {"CREATE", "DOMAIN"}, + {"ALTER", "DOMAIN"}, + {"DROP", "DOMAIN"}, + {"CREATE", "ROLE"}, + {"ALTER", "ROLE"}, + {"DROP", "ROLE"}, + {"CREATE", "INDEX"}, + {"ALTER", "INDEX"}, + {"DROP", "INDEX"}, + {"CREATE", "SEQUENCE"}, + {"ALTER", "SEQUENCE"}, + {"DROP", "SEQUENCE"}, + {"CREATE", "USER"}, + {"ALTER", "USER"}, + {"DROP", "USER"}, + {"CREATE", "COLLATION"}, + {"DROP", "COLLATION"}, + {"ALTER", "CHARACTER SET"}, + {"CREATE", "PACKAGE"}, + {"ALTER", "PACKAGE"}, + {"DROP", "PACKAGE"}, + {"CREATE", "PACKAGE BODY"}, + {"DROP", "PACKAGE BODY"}, + {"CREATE", "MAPPING"}, + {"ALTER", "MAPPING"}, + {"DROP", "MAPPING"}, + {"CREATE", "SCHEMA"}, + {"ALTER", "SCHEMA"}, + {"DROP", "SCHEMA"} +}; + +inline constexpr int DDL_TRIGGER_BEFORE = 0; +inline constexpr int DDL_TRIGGER_AFTER = 1; + +inline constexpr FB_UINT64 DDL_TRIGGER_ANY = 0x7FFFFFFFFFFFFFFFULL & ~(FB_UINT64) TRIGGER_TYPE_MASK & ~1ULL; + +inline constexpr int DDL_TRIGGER_CREATE_TABLE = 1; +inline constexpr int DDL_TRIGGER_ALTER_TABLE = 2; +inline constexpr int DDL_TRIGGER_DROP_TABLE = 3; +inline constexpr int DDL_TRIGGER_CREATE_PROCEDURE = 4; +inline constexpr int DDL_TRIGGER_ALTER_PROCEDURE = 5; +inline constexpr int DDL_TRIGGER_DROP_PROCEDURE = 6; +inline constexpr int DDL_TRIGGER_CREATE_FUNCTION = 7; +inline constexpr int DDL_TRIGGER_ALTER_FUNCTION = 8; +inline constexpr int DDL_TRIGGER_DROP_FUNCTION = 9; +inline constexpr int DDL_TRIGGER_CREATE_TRIGGER = 10; +inline constexpr int DDL_TRIGGER_ALTER_TRIGGER = 11; +inline constexpr int DDL_TRIGGER_DROP_TRIGGER = 12; +// gap for TRIGGER_TYPE_MASK - 3 bits +inline constexpr int DDL_TRIGGER_CREATE_EXCEPTION = 16; +inline constexpr int DDL_TRIGGER_ALTER_EXCEPTION = 17; +inline constexpr int DDL_TRIGGER_DROP_EXCEPTION = 18; +inline constexpr int DDL_TRIGGER_CREATE_VIEW = 19; +inline constexpr int DDL_TRIGGER_ALTER_VIEW = 20; +inline constexpr int DDL_TRIGGER_DROP_VIEW = 21; +inline constexpr int DDL_TRIGGER_CREATE_DOMAIN = 22; +inline constexpr int DDL_TRIGGER_ALTER_DOMAIN = 23; +inline constexpr int DDL_TRIGGER_DROP_DOMAIN = 24; +inline constexpr int DDL_TRIGGER_CREATE_ROLE = 25; +inline constexpr int DDL_TRIGGER_ALTER_ROLE = 26; +inline constexpr int DDL_TRIGGER_DROP_ROLE = 27; +inline constexpr int DDL_TRIGGER_CREATE_INDEX = 28; +inline constexpr int DDL_TRIGGER_ALTER_INDEX = 29; +inline constexpr int DDL_TRIGGER_DROP_INDEX = 30; +inline constexpr int DDL_TRIGGER_CREATE_SEQUENCE = 31; +inline constexpr int DDL_TRIGGER_ALTER_SEQUENCE = 32; +inline constexpr int DDL_TRIGGER_DROP_SEQUENCE = 33; +inline constexpr int DDL_TRIGGER_CREATE_USER = 34; +inline constexpr int DDL_TRIGGER_ALTER_USER = 35; +inline constexpr int DDL_TRIGGER_DROP_USER = 36; +inline constexpr int DDL_TRIGGER_CREATE_COLLATION = 37; +inline constexpr int DDL_TRIGGER_DROP_COLLATION = 38; +inline constexpr int DDL_TRIGGER_ALTER_CHARACTER_SET = 39; +inline constexpr int DDL_TRIGGER_CREATE_PACKAGE = 40; +inline constexpr int DDL_TRIGGER_ALTER_PACKAGE = 41; +inline constexpr int DDL_TRIGGER_DROP_PACKAGE = 42; +inline constexpr int DDL_TRIGGER_CREATE_PACKAGE_BODY = 43; +inline constexpr int DDL_TRIGGER_DROP_PACKAGE_BODY = 44; +inline constexpr int DDL_TRIGGER_CREATE_MAPPING = 45; +inline constexpr int DDL_TRIGGER_ALTER_MAPPING = 46; +inline constexpr int DDL_TRIGGER_DROP_MAPPING = 47; +inline constexpr int DDL_TRIGGER_CREATE_SCHEMA = 48; +inline constexpr int DDL_TRIGGER_ALTER_SCHEMA = 49; +inline constexpr int DDL_TRIGGER_DROP_SCHEMA = 50; + +// that's how database trigger action types are encoded +// (TRIGGER_TYPE_DB | type) + +// that's how DDL trigger action types are encoded +// (TRIGGER_TYPE_DDL | DDL_TRIGGER_{AFTER | BEFORE} [ | DDL_TRIGGER_??? ...]) + +// switches for username and password used when an username and/or password +// is specified by the client application +#define USERNAME_SWITCH "USER" +#define PASSWORD_SWITCH "PASSWORD" + +// The highest transaction number possible +inline constexpr TraNumber MAX_TRA_NUMBER = 0x0000FFFFFFFFFFFF; // ~2.8 * 10^14 + +// Number of streams, conjuncts, indices that will be statically allocated +// in various arrays. Larger numbers will have to be allocated dynamically +inline constexpr unsigned OPT_STATIC_ITEMS = 16; +inline constexpr unsigned OPT_STATIC_STREAMS = 64; + +#define CURRENT_ENGINE "Engine14" +#define EMBEDDED_PROVIDERS "Providers=" CURRENT_ENGINE + +// Features set for current version of engine provider +#define ENGINE_FEATURES {fb_feature_multi_statements, \ + fb_feature_multi_transactions, \ + fb_feature_session_reset, \ + fb_feature_read_consistency, \ + fb_feature_statement_timeout, \ + fb_feature_statement_long_life} + +inline constexpr int WITH_GRANT_OPTION = 1; +inline constexpr int WITH_ADMIN_OPTION = 2; + +// Max length of the string returned by ERROR_TEXT context variable +inline constexpr USHORT MAX_ERROR_MSG_LENGTH = 1024 * METADATA_BYTES_PER_CHAR; // 1024 UTF-8 characters + +// Prefix of index that's getting dropped +inline constexpr const char* TEMP_DEPEND = "RDB$TEMP_DEPEND"; + + +inline constexpr int EPB_version1 = 1; + + +} // namespace Firebird + +#endif // COMMON_CONSTANTS_H diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index da9b6c40d6a..69fae7ebdd6 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -44,7 +44,7 @@ #include #include "iberror.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/intlobj_new.h" #include "../common/gdsassert.h" #include "../common/CharSet.h" @@ -52,7 +52,7 @@ #include "../common/classes/timestamp.h" #include "../common/cvt.h" #include "../jrd/intl.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/VaryStr.h" #include "../common/classes/FpeControl.h" #include "../common/dsc_proto.h" @@ -73,7 +73,9 @@ #endif -using namespace Firebird; +namespace Firebird +{ + /* normally the following two definitions are part of limits.h but due to a compiler bug on Apollo casting LONG_MIN to be a @@ -142,9 +144,9 @@ static void float_to_text(const dsc*, dsc*, Callbacks*); static void decimal_float_to_text(const dsc*, dsc*, DecimalStatus, Callbacks*); static void integer_to_text(const dsc*, dsc*, Callbacks*); static void int128_to_text(const dsc*, dsc*, Callbacks* cb); -static void localError(const Firebird::Arg::StatusVector&); +static void localError(const Arg::StatusVector&); static SSHORT cvt_get_short(const dsc* desc, SSHORT scale, DecimalStatus decSt, ErrorFunction err); -static void make_null_string(const dsc*, TTypeId, const char**, vary*, USHORT, Firebird::DecimalStatus, ErrorFunction); +static void make_null_string(const dsc*, TTypeId, const char**, vary*, USHORT, DecimalStatus, ErrorFunction); namespace { class RetPtr; @@ -1078,7 +1080,7 @@ void CVT_string_to_datetime(const dsc* desc, // Fetch current date/time tm times2; - Firebird::TimeStamp::getCurrentTimeStamp().decode(×2); + TimeStamp::getCurrentTimeStamp().decode(×2); // Handle defaulting of year @@ -1128,7 +1130,7 @@ void CVT_string_to_datetime(const dsc* desc, // convert day/month/year to Julian and validate result // This catches things like 29-Feb-1995 (not a leap year) - Firebird::TimeStamp ts(times); + TimeStamp ts(times); validateTimeStamp(ts.value(), expect_type, desc, cb); if (expect_type != expect_sql_time && expect_type != expect_sql_time_tz) @@ -2388,7 +2390,7 @@ static void datetime_to_text(const dsc* from, dsc* to, Callbacks* cb) switch (from->dsc_dtype) { case dtype_sql_time: - Firebird::TimeStamp::decode_time(*(GDS_TIME*) from->dsc_address, + TimeStamp::decode_time(*(GDS_TIME*) from->dsc_address, ×.tm_hour, ×.tm_min, ×.tm_sec, &fractions); break; @@ -2400,12 +2402,12 @@ static void datetime_to_text(const dsc* from, dsc* to, Callbacks* cb) break; case dtype_sql_date: - Firebird::TimeStamp::decode_date(*(GDS_DATE *) from->dsc_address, ×); + TimeStamp::decode_date(*(GDS_DATE *) from->dsc_address, ×); break; case dtype_timestamp: cb->isVersion4(version4); // Used in the conversion to text some lines below. - Firebird::TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) from->dsc_address, ×, &fractions); + TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) from->dsc_address, ×, &fractions); break; case dtype_timestamp_tz: @@ -3707,7 +3709,7 @@ static void hex_to_value(const char*& string, const char* end, RetPtr* retValue) } -static void localError(const Firebird::Arg::StatusVector&) +static void localError(const Arg::StatusVector&) { throw DummyException(); } @@ -3855,3 +3857,6 @@ void CVT_move(const dsc* from, dsc* to, DecimalStatus decSt, ErrorFunction err, CommonCallbacks callbacks(err); CVT_move_common(from, to, decSt, &callbacks, trustedSource); } + + +} // namespace Firebird diff --git a/src/common/cvt.h b/src/common/cvt.h index 984e6f151d9..587b1802d20 100644 --- a/src/common/cvt.h +++ b/src/common/cvt.h @@ -32,15 +32,12 @@ #include "../common/DecFloat.h" #include "../jrd/intl.h" -namespace Firebird { - -class CharSet; - -} - struct dsc; -namespace Firebird { +namespace Firebird +{ + class CharSet; + class Callbacks { @@ -83,28 +80,29 @@ enum EXPECT_DATETIME class Int128; -} // namespace Firebird - -void CVT_conversion_error(const dsc*, ErrorFunction, const Firebird::Exception* = nullptr); +void CVT_conversion_error(const dsc*, ErrorFunction, const Exception* = nullptr); double CVT_power_of_ten(const int); -SLONG CVT_get_long(const dsc*, SSHORT, Firebird::DecimalStatus, ErrorFunction); +SLONG CVT_get_long(const dsc*, SSHORT, DecimalStatus, ErrorFunction); bool CVT_get_boolean(const dsc*, ErrorFunction); -double CVT_get_double(const dsc*, Firebird::DecimalStatus, ErrorFunction, bool* getNumericOverflow = nullptr); -Firebird::Decimal64 CVT_get_dec64(const dsc*, Firebird::DecimalStatus, ErrorFunction); -Firebird::Decimal128 CVT_get_dec128(const dsc*, Firebird::DecimalStatus, ErrorFunction); -Firebird::Int128 CVT_get_int128(const dsc*, SSHORT, Firebird::DecimalStatus, ErrorFunction); -Firebird::Int128 CVT_hex_to_int128(const char* str, USHORT len); -USHORT CVT_make_string(const dsc*, TTypeId, const char**, vary*, USHORT, Firebird::DecimalStatus, ErrorFunction); -void CVT_move_common(const dsc*, dsc*, Firebird::DecimalStatus, Firebird::Callbacks*, bool trustedSource = false); -void CVT_move(const dsc*, dsc*, Firebird::DecimalStatus, ErrorFunction, bool trustedSource = false); -SSHORT CVT_decompose(const char*, USHORT, Firebird::Int128*, ErrorFunction); -USHORT CVT_get_string_ptr(const dsc*, TTypeId*, UCHAR**, vary*, USHORT, Firebird::DecimalStatus, ErrorFunction); -USHORT CVT_get_string_ptr_common(const dsc*, TTypeId*, UCHAR**, vary*, USHORT, Firebird::DecimalStatus, Firebird::Callbacks*); -SINT64 CVT_get_int64(const dsc*, SSHORT, Firebird::DecimalStatus, ErrorFunction); -SQUAD CVT_get_quad(const dsc*, SSHORT, Firebird::DecimalStatus, ErrorFunction); -void CVT_string_to_datetime(const dsc*, ISC_TIMESTAMP_TZ*, bool*, const Firebird::EXPECT_DATETIME, - bool, Firebird::Callbacks*); +double CVT_get_double(const dsc*, DecimalStatus, ErrorFunction, bool* getNumericOverflow = nullptr); +Decimal64 CVT_get_dec64(const dsc*, DecimalStatus, ErrorFunction); +Decimal128 CVT_get_dec128(const dsc*, DecimalStatus, ErrorFunction); +Int128 CVT_get_int128(const dsc*, SSHORT, DecimalStatus, ErrorFunction); +Int128 CVT_hex_to_int128(const char* str, USHORT len); +USHORT CVT_make_string(const dsc*, TTypeId, const char**, vary*, USHORT, DecimalStatus, ErrorFunction); +void CVT_move_common(const dsc*, dsc*, DecimalStatus, Callbacks*, bool trustedSource = false); +void CVT_move(const dsc*, dsc*, DecimalStatus, ErrorFunction, bool trustedSource = false); +SSHORT CVT_decompose(const char*, USHORT, Int128*, ErrorFunction); +USHORT CVT_get_string_ptr(const dsc*, TTypeId*, UCHAR**, vary*, USHORT, DecimalStatus, ErrorFunction); +USHORT CVT_get_string_ptr_common(const dsc*, TTypeId*, UCHAR**, vary*, USHORT, DecimalStatus, Callbacks*); +SINT64 CVT_get_int64(const dsc*, SSHORT, DecimalStatus, ErrorFunction); +SQUAD CVT_get_quad(const dsc*, SSHORT, DecimalStatus, ErrorFunction); +void CVT_string_to_datetime(const dsc*, ISC_TIMESTAMP_TZ*, bool*, const EXPECT_DATETIME, + bool, Callbacks*); const UCHAR* CVT_get_bytes(const dsc*, unsigned&); + +} // namespace Firebird + #endif //COMMON_CVT_H diff --git a/src/common/db_alias.cpp b/src/common/db_alias.cpp index 3fea5f009c1..903171007aa 100644 --- a/src/common/db_alias.cpp +++ b/src/common/db_alias.cpp @@ -37,7 +37,9 @@ #include "../common/classes/array.h" #include -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -247,7 +249,7 @@ namespace { public: explicit AliasesConf(MemoryPool& p) - : ConfigCache(p, fb_utils::getPrefix(Firebird::IConfigManager::DIR_CONF, ALIAS_FILE)), + : ConfigCache(p, fb_utils::getPrefix(IConfigManager::DIR_CONF, ALIAS_FILE)), databases(getPool()), aliases(getPool()) #ifdef HAVE_ID_BY_NAME , ids(getPool()) @@ -396,9 +398,10 @@ namespace #endif }; - InitInstance aliasesConf; +InitInstance aliasesConf; } + // Checks that argument doesn't contain colon or directory separator static inline bool hasSeparator(const PathName& name) { @@ -485,9 +488,9 @@ static bool setPath(const PathName& filename, PathName& expandedName) // Full processing of database name // Returns true if alias was found in databases.conf -bool expandDatabaseName(Firebird::PathName alias, - Firebird::PathName& file, - Firebird::RefPtr* config) +bool expandDatabaseName(PathName alias, + PathName& file, + RefPtr* config) { try { @@ -560,7 +563,7 @@ bool expandDatabaseName(Firebird::PathName alias, } // Probably file arrived on the disk -bool notifyDatabaseName(const Firebird::PathName& file) +bool notifyDatabaseName(const PathName& file) { #ifdef HAVE_ID_BY_NAME // notifyDatabaseName typically causes changes in aliasesConf() @@ -585,3 +588,6 @@ bool notifyDatabaseName(const Firebird::PathName& file) return false; } + + +} // namespace Firebird diff --git a/src/common/db_alias.h b/src/common/db_alias.h index 0718935b280..2ddf40d2fcb 100644 --- a/src/common/db_alias.h +++ b/src/common/db_alias.h @@ -27,14 +27,21 @@ #include "../common/classes/RefCounted.h" #include "../common/config/config.h" -bool resolveAlias(const Firebird::PathName& alias, - Firebird::PathName& file, - Firebird::RefPtr* config); +namespace Firebird +{ -bool expandDatabaseName(Firebird::PathName alias, - Firebird::PathName& file, - Firebird::RefPtr* config); -bool notifyDatabaseName(const Firebird::PathName& file); +bool resolveAlias(const PathName& alias, + PathName& file, + RefPtr* config); + +bool expandDatabaseName(PathName alias, + PathName& file, + RefPtr* config); + +bool notifyDatabaseName(const PathName& file); + + +} // namespace Firebird #endif // JRD_DB_ALIAS_H diff --git a/src/common/dsc.h b/src/common/dsc.h index 27727ca24d7..bf15b0e313a 100644 --- a/src/common/dsc.h +++ b/src/common/dsc.h @@ -87,9 +87,9 @@ typedef struct dsc { dsc() = default; - // These Ods::Descriptor constructor and operator were added to have - // interoperability between Ods::Descriptor and struct dsc - dsc(const Ods::Descriptor& od) noexcept + // These Firebird::Jrd::Ods::Descriptor constructor and operator were added to have + // interoperability between Firebird::Jrd::Ods::Descriptor and struct dsc + dsc(const Firebird::Jrd::Ods::Descriptor& od) noexcept : dsc_dtype(od.dsc_dtype), dsc_scale(od.dsc_scale), dsc_length(od.dsc_length), @@ -528,12 +528,12 @@ typedef struct dsc USHORT getStringLength() const noexcept; - operator Ods::Descriptor() const + operator Firebird::Jrd::Ods::Descriptor() const { #ifdef DEV_BUILD address32bit(); #endif - Ods::Descriptor d; + Firebird::Jrd::Ods::Descriptor d; d.dsc_dtype = dsc_dtype; d.dsc_scale = dsc_scale; d.dsc_length = dsc_length; diff --git a/src/common/enc.cpp b/src/common/enc.cpp index 81c643dc7d3..70a1b315fac 100644 --- a/src/common/enc.cpp +++ b/src/common/enc.cpp @@ -12,6 +12,10 @@ #include "../common/classes/alloc.h" #include "../common/classes/init.h" +namespace Firebird +{ + + /* #ifdef HAVE_UNISTD_H #ifdef LINUX @@ -447,7 +451,7 @@ static C_block CF6464[64 / CHUNKBITS][1 << CHUNKBITS]; // ==================================== -static Firebird::GlobalPtr cryptMutex; +static GlobalPtr cryptMutex; static C_block constdatablock; // encryption constant const static size_t RESULT_SIZE = (1 + 4 + 4 + 11 + 1); @@ -462,7 +466,7 @@ const static size_t RESULT_SIZE = (1 + 4 + 4 + 11 + 1); void ENC_crypt(TEXT* buf, size_t bufSize, const TEXT* key, const TEXT* setting) { fb_assert(bufSize >= RESULT_SIZE); - Firebird::MutexLockGuard guard(cryptMutex, "ENC_crypt"); + MutexLockGuard guard(cryptMutex, "ENC_crypt"); int t; int num_iter, salt_size; @@ -931,3 +935,6 @@ init_perm(C_block perm[64 / CHUNKBITS][1 << CHUNKBITS], } } } + + +} // namespace Firebird diff --git a/src/common/enc_proto.h b/src/common/enc_proto.h index 3fb272016fe..6cc33e78e8b 100644 --- a/src/common/enc_proto.h +++ b/src/common/enc_proto.h @@ -24,15 +24,10 @@ #ifndef JRD_ENC_PROTO_H #define JRD_ENC_PROTO_H -#ifdef __cplusplus -extern "C" { -#endif - -void ENC_crypt(TEXT*, size_t, const TEXT*, const TEXT*); - -#ifdef __cplusplus -} /* extern "C" */ -#endif +namespace Firebird +{ + void ENC_crypt(TEXT*, size_t, const TEXT*, const TEXT*); +} // namespace Firebird #endif // JRD_ENC_PROTO_H diff --git a/src/common/fb_exception.cpp b/src/common/fb_exception.cpp index db288c5ac3d..c61a5919499 100644 --- a/src/common/fb_exception.cpp +++ b/src/common/fb_exception.cpp @@ -123,7 +123,7 @@ status_exception::~status_exception() noexcept const char* status_exception::what() const noexcept { - return "Firebird::status_exception"; + return "status_exception"; } [[noreturn]] void status_exception::raise(const ISC_STATUS *status_vector) @@ -169,7 +169,7 @@ void BadAlloc::stuffByException(StaticStatusVector& status) const noexcept const char* BadAlloc::what() const noexcept { - return "Firebird::BadAlloc"; + return "BadAlloc"; } // ********************************* LongJump *************************** @@ -182,7 +182,7 @@ const char* BadAlloc::what() const noexcept void LongJump::stuffByException(StaticStatusVector& status) const noexcept { const ISC_STATUS sv[] = {isc_arg_gds, isc_random, isc_arg_string, - (ISC_STATUS)(IPTR) "Unexpected call to Firebird::LongJump::stuffException()", isc_arg_end}; + (ISC_STATUS)(IPTR) "Unexpected call to LongJump::stuffException()", isc_arg_end}; try { @@ -196,7 +196,7 @@ void LongJump::stuffByException(StaticStatusVector& status) const noexcept const char* LongJump::what() const noexcept { - return "Firebird::LongJump"; + return "LongJump"; } diff --git a/src/common/gdsassert.h b/src/common/gdsassert.h index 2ad552f51eb..879ccb9cc8b 100644 --- a/src/common/gdsassert.h +++ b/src/common/gdsassert.h @@ -68,7 +68,7 @@ inline void fb_assert_impl(const char* msg, const char* file, int line, bool do_ #endif // DEV_BUILD -namespace DtorException { +namespace Firebird::DtorException { inline void devHalt() noexcept { // If any guard's dtor is executed during exception processing, diff --git a/src/common/isc.cpp b/src/common/isc.cpp index 9183d8bfbeb..f15dd0098dc 100644 --- a/src/common/isc.cpp +++ b/src/common/isc.cpp @@ -61,6 +61,10 @@ #include #include +namespace Firebird +{ + + class SecurityAttributes { public: @@ -74,7 +78,7 @@ class SecurityAttributes // Pseudo-handles do not work on WinNT. Need real process handle. HANDLE hCurrentProcess = OpenProcess(READ_CONTROL | WRITE_DAC, FALSE, GetCurrentProcessId()); if (hCurrentProcess == NULL) { - Firebird::system_call_failed::raise("OpenProcess"); + system_call_failed::raise("OpenProcess"); } DWORD result = GetSecurityInfo(hCurrentProcess, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, @@ -90,7 +94,7 @@ class SecurityAttributes if (result != ERROR_SUCCESS) { CloseHandle(hCurrentProcess); - Firebird::system_call_failed::raise("GetSecurityInfo", result); + system_call_failed::raise("GetSecurityInfo", result); } // NULL pOldACL means all privileges. If we assign pNewACL in this case @@ -168,7 +172,10 @@ class SecurityAttributes MemoryPool& m_pool; }; -static Firebird::InitInstance security_attributes; +static InitInstance security_attributes; + + +} // namespace Firebird #endif // WIN_NT @@ -199,6 +206,9 @@ static Firebird::InitInstance security_attributes; #include #endif +namespace Firebird +{ + bool ISC_check_process_existence(SLONG pid) { @@ -307,7 +317,7 @@ TEXT* ISC_get_host(TEXT* string, USHORT length) } #endif -const TEXT* ISC_get_host(Firebird::string& host) +const TEXT* ISC_get_host(string& host) { /************************************** * @@ -326,7 +336,7 @@ const TEXT* ISC_get_host(Firebird::string& host) } #ifdef UNIX -bool ISC_get_user(Firebird::string* name, int* id, int* group) +bool ISC_get_user(string* name, int* id, int* group) { /************************************** * @@ -368,7 +378,7 @@ bool ISC_get_user(Firebird::string* name, int* id, int* group) #ifdef WIN_NT -bool ISC_get_user(Firebird::string* name, int* id, int* group) +bool ISC_get_user(string* name, int* id, int* group) { /************************************** * @@ -408,7 +418,7 @@ bool ISC_get_user(Firebird::string* name, int* id, int* group) } #endif //WIN_NT -inline void setPrefixIfNotEmpty(const Firebird::PathName& prefix, SSHORT arg_type) +inline void setPrefixIfNotEmpty(const PathName& prefix, SSHORT arg_type) { /************************************** * @@ -451,7 +461,7 @@ SLONG ISC_set_prefix(const TEXT* sw, const TEXT* path) */ static struct ESwitches { - Firebird::PathName prefix, lockPrefix, msgPrefix; + PathName prefix, lockPrefix, msgPrefix; explicit ESwitches(MemoryPool& p) : prefix(p), lockPrefix(p), msgPrefix(p) @@ -462,9 +472,9 @@ SLONG ISC_set_prefix(const TEXT* sw, const TEXT* path) { if (eSw) { - setPrefixIfNotEmpty(eSw->prefix, IB_PREFIX_TYPE); - setPrefixIfNotEmpty(eSw->lockPrefix, IB_PREFIX_LOCK_TYPE); - setPrefixIfNotEmpty(eSw->msgPrefix, IB_PREFIX_MSG_TYPE); + setPrefixIfNotEmpty(eSw->prefix, Why::IB_PREFIX_TYPE); + setPrefixIfNotEmpty(eSw->lockPrefix, Why::IB_PREFIX_LOCK_TYPE); + setPrefixIfNotEmpty(eSw->msgPrefix, Why::IB_PREFIX_MSG_TYPE); delete eSw; eSw = 0; @@ -526,7 +536,7 @@ void iscLogStatus(const TEXT* text, const ISC_STATUS* status_vector) try { - Firebird::string buffer(text ? text : ""); + string buffer(text ? text : ""); TEXT temp[BUFFER_LARGE]; while (fb_interpret(temp, sizeof(temp), &status_vector)) @@ -540,23 +550,23 @@ void iscLogStatus(const TEXT* text, const ISC_STATUS* status_vector) gds__log("%s", buffer.c_str()); } - catch (const Firebird::Exception&) + catch (const Exception&) {} // no-op } -void iscLogStatus(const TEXT* text, const Firebird::IStatus* status) +void iscLogStatus(const TEXT* text, const IStatus* status) { - Firebird::StaticStatusVector tmp; + StaticStatusVector tmp; tmp.mergeStatus(status); iscLogStatus(text, tmp.begin()); } -void iscDbLogStatus(const TEXT* text, Firebird::IStatus* status) +void iscDbLogStatus(const TEXT* text, IStatus* status) { const TEXT* hdr = NULL; - Firebird::string buf; + string buf; if (text) { buf = "Database: "; @@ -567,7 +577,7 @@ void iscDbLogStatus(const TEXT* text, Firebird::IStatus* status) } -void iscLogException(const char* text, const Firebird::Exception& e) +void iscLogException(const char* text, const Exception& e) { /************************************** * @@ -579,7 +589,7 @@ void iscLogException(const char* text, const Firebird::Exception& e) * Add record about an exception to firebird.log * **************************************/ - Firebird::StaticStatusVector s; + StaticStatusVector s; e.stuffException(s); iscLogStatus(text, s.begin()); } @@ -642,3 +652,6 @@ void iscSafeConcatPath(TEXT *resultString, const TEXT *appendString) memcpy(&resultString[len], appendString, alen); resultString[len + alen] = 0; } + + +} // namespace Firebird diff --git a/src/common/isc_f_proto.h b/src/common/isc_f_proto.h index 718f8f82088..70390fb8057 100644 --- a/src/common/isc_f_proto.h +++ b/src/common/isc_f_proto.h @@ -30,37 +30,44 @@ #include "../common/classes/fb_string.h" #include "../common/common.h" +namespace Firebird +{ + + enum iscProtocol {ISC_PROTOCOL_LOCAL, ISC_PROTOCOL_TCPIP}; #ifndef NO_NFS -bool ISC_analyze_nfs(Firebird::PathName&, Firebird::PathName&); +bool ISC_analyze_nfs(PathName&, PathName&); #endif #ifdef WIN_NT -bool ISC_analyze_pclan(Firebird::PathName&, Firebird::PathName&); +bool ISC_analyze_pclan(PathName&, PathName&); #endif -bool ISC_analyze_protocol(const char*, Firebird::PathName&, Firebird::PathName&, const char*, bool needFile); -bool ISC_analyze_tcp(Firebird::PathName&, Firebird::PathName&, bool = true); -bool ISC_check_if_remote(const Firebird::PathName&, bool); -iscProtocol ISC_extract_host(Firebird::PathName&, Firebird::PathName&, bool); -bool ISC_expand_filename(Firebird::PathName&, bool); -void ISC_systemToUtf8(Firebird::AbstractString& str); -void ISC_utf8ToSystem(Firebird::AbstractString& str); -void ISC_escape(Firebird::AbstractString& str); -void ISC_unescape(Firebird::AbstractString& str); +bool ISC_analyze_protocol(const char*, PathName&, PathName&, const char*, bool needFile); +bool ISC_analyze_tcp(PathName&, PathName&, bool = true); +bool ISC_check_if_remote(const PathName&, bool); +iscProtocol ISC_extract_host(PathName&, PathName&, bool); +bool ISC_expand_filename(PathName&, bool); +void ISC_systemToUtf8(AbstractString& str); +void ISC_utf8ToSystem(AbstractString& str); +void ISC_escape(AbstractString& str); +void ISC_unescape(AbstractString& str); // This form of ISC_expand_filename makes epp files happy inline bool ISC_expand_filename(const TEXT* unexpanded, USHORT len_unexpanded, TEXT* expanded, FB_SIZE_T len_expanded, bool expand_share) { - Firebird::PathName pn(unexpanded, len_unexpanded ? len_unexpanded : fb_strlen(unexpanded)); + PathName pn(unexpanded, len_unexpanded ? len_unexpanded : fb_strlen(unexpanded)); ISC_expand_filename(pn, expand_share); // What do I return here if the previous call returns false? return (pn.copyTo(expanded, len_expanded) != 0); } -void ISC_expand_share(Firebird::PathName&); +void ISC_expand_share(PathName&); int ISC_file_lock(SSHORT); int ISC_file_unlock(SSHORT); + +} // namespace Firebird + #endif // JRD_ISC_FILE_PROTO_H diff --git a/src/common/isc_file.cpp b/src/common/isc_file.cpp index 53ff5c9ab74..9ff6ca500e5 100644 --- a/src/common/isc_file.cpp +++ b/src/common/isc_file.cpp @@ -91,8 +91,6 @@ #include "../common/config/config.h" -constexpr char INET_FLAG = ':'; - // Unix/NFS specific stuff #ifndef NO_NFS @@ -135,20 +133,24 @@ constexpr const char* MTAB = "/etc/mtab"; #define MAXHOSTLEN 64 #endif -using namespace Firebird; +namespace Firebird +{ + namespace { - typedef Firebird::PathName tstring; + typedef PathName tstring; typedef tstring::size_type size; typedef tstring::iterator iter; const size npos = tstring::npos; + constexpr char INET_FLAG = ':'; + #ifndef NO_NFS const char* NFS_TYPE = "nfs"; - Firebird::GlobalPtr mntinfoMutex; + GlobalPtr mntinfoMutex; - class Mnt : public Firebird::MutexLockGuard // Protect static values returned by getmntinfo()/getmntent() + class Mnt : public MutexLockGuard // Protect static values returned by getmntinfo()/getmntent() { #ifdef DARWIN private: @@ -158,7 +160,7 @@ namespace { public: Mnt() - : Firebird::MutexLockGuard(mntinfoMutex, FB_FUNCTION), + : MutexLockGuard(mntinfoMutex, FB_FUNCTION), mnt_info(NULL), mnt_cnt(getmntinfo(&mnt_info, MNT_NOWAIT)), mnt_i(0) { } @@ -169,7 +171,7 @@ namespace { public: Mnt() - : Firebird::MutexLockGuard(mntinfoMutex, FB_FUNCTION), + : MutexLockGuard(mntinfoMutex, FB_FUNCTION), mtab(MTAB_OPEN(MTAB, "r")) { } @@ -533,8 +535,8 @@ bool ISC_check_if_remote(const tstring& file_name, bool implicit_flag) } -iscProtocol ISC_extract_host(Firebird::PathName& file_name, - Firebird::PathName& host_name, +iscProtocol ISC_extract_host(PathName& file_name, + PathName& host_name, bool implicit_flag) { /************************************** @@ -1774,7 +1776,7 @@ class WideCharBuffer // Converts a string from the system charset to UTF-8. -void ISC_systemToUtf8(Firebird::AbstractString& str) +void ISC_systemToUtf8(AbstractString& str) { if (str.isEmpty()) return; @@ -1797,7 +1799,7 @@ void ISC_systemToUtf8(Firebird::AbstractString& str) // Converts a string from UTF-8 to the system charset. -void ISC_utf8ToSystem(Firebird::AbstractString& str) +void ISC_utf8ToSystem(AbstractString& str) { if (str.isEmpty()) return; @@ -1897,3 +1899,6 @@ void ISC_unescape(AbstractString& /*str*/) } #endif } + + +} // namespace Firebird diff --git a/src/common/isc_proto.h b/src/common/isc_proto.h index f3f52cb19f1..059e40cef0c 100644 --- a/src/common/isc_proto.h +++ b/src/common/isc_proto.h @@ -27,17 +27,21 @@ #include "../common/classes/fb_string.h" #include "firebird/Interface.h" +namespace Firebird +{ + + bool ISC_check_process_existence(SLONG); TEXT* ISC_get_host(TEXT *, USHORT); -const TEXT* ISC_get_host(Firebird::string&); -bool ISC_get_user(Firebird::string*, int*, int*); +const TEXT* ISC_get_host(string&); +bool ISC_get_user(string*, int*, int*); SLONG ISC_set_prefix(const TEXT*, const TEXT*); -void iscDbLogStatus(const TEXT* text, Firebird::IStatus* status); +void iscDbLogStatus(const TEXT* text, IStatus* status); // Do not add word "Database" in the beginning like gds__log_status / iscDbLogStatus void iscLogStatus(const TEXT* text, const ISC_STATUS* status_vector); -void iscLogStatus(const TEXT* text, const Firebird::IStatus* status); -void iscLogException(const TEXT* text, const Firebird::Exception& e); +void iscLogStatus(const TEXT* text, const IStatus* status); +void iscLogException(const TEXT* text, const Exception& e); #ifdef WIN_NT struct _SECURITY_ATTRIBUTES* ISC_get_security_desc(); @@ -46,4 +50,7 @@ struct _SECURITY_ATTRIBUTES* ISC_get_security_desc(); void iscPrefixLock(TEXT* string, const TEXT* root, bool createLockDir); void iscSafeConcatPath(TEXT* resultString, const TEXT* appendString); + +} // namespace Firebird + #endif // JRD_ISC_PROTO_H diff --git a/src/common/isc_s_proto.h b/src/common/isc_s_proto.h index 72cb066de3a..9f27a560b56 100644 --- a/src/common/isc_s_proto.h +++ b/src/common/isc_s_proto.h @@ -200,7 +200,7 @@ class FileLock int setlock(const LockMode mode); // Alternative locker is using status vector to report errors - bool setlock(Firebird::CheckStatusWrapper* status, const LockMode mode); + bool setlock(CheckStatusWrapper* status, const LockMode mode); // Unlocking can only put error into log file - we can't throw in dtors void unlock(); @@ -211,7 +211,7 @@ class FileLock enum LockLevel {LCK_NONE, LCK_SHARED, LCK_EXCL}; private: - Firebird::RefPtr file; + RefPtr file; InitFunction* initFunction; LockLevel level; }; @@ -261,13 +261,13 @@ class SharedMemoryBase ~SharedMemoryBase(); #ifdef HAVE_OBJECT_MAP - UCHAR* mapObject(Firebird::CheckStatusWrapper* status, ULONG offset, ULONG size); - void unmapObject(Firebird::CheckStatusWrapper* status, UCHAR** object, ULONG size); + UCHAR* mapObject(CheckStatusWrapper* status, ULONG offset, ULONG size); + void unmapObject(CheckStatusWrapper* status, UCHAR** object, ULONG size); #endif - bool remapFile(Firebird::CheckStatusWrapper* status, ULONG newSize, bool truncateFlag); + bool remapFile(CheckStatusWrapper* status, ULONG newSize, bool truncateFlag); void removeMapFile(); static void unlinkFile(const TEXT* expanded_filename) noexcept; - Firebird::PathName getMapFileName(); + PathName getMapFileName(); bool mutexLock(std::optional timeout = std::nullopt); bool mutexTryLock(); @@ -280,11 +280,11 @@ class SharedMemoryBase int eventPost(event_t* event); // Used as memory allocation unit and mapping alignment - static ULONG getSystemPageSize(Firebird::CheckStatusWrapper* status); + static ULONG getSystemPageSize(CheckStatusWrapper* status); public: #ifdef UNIX - Firebird::AutoPtr mainLock; + AutoPtr mainLock; #endif #ifdef WIN_NT struct mtx sh_mem_winMutex; @@ -295,7 +295,7 @@ class SharedMemoryBase #endif #ifdef UNIX - Firebird::AutoPtr initFile; + AutoPtr initFile; #endif ULONG sh_mem_length_mapped; @@ -340,7 +340,7 @@ class SharedMemoryBase }; protected: - void logError(const char* text, const Firebird::CheckStatusWrapper* status); + void logError(const char* text, const CheckStatusWrapper* status); }; template // Header must be "public MemoryHeader" @@ -352,12 +352,12 @@ class SharedMemory : public SharedMemoryBase { } #ifdef HAVE_OBJECT_MAP - template Object* mapObject(Firebird::CheckStatusWrapper* status, ULONG offset) + template Object* mapObject(CheckStatusWrapper* status, ULONG offset) { return (Object*) SharedMemoryBase::mapObject(status, offset, sizeof(Object)); } - template void unmapObject(Firebird::CheckStatusWrapper* status, Object** object) + template void unmapObject(CheckStatusWrapper* status, Object** object) { SharedMemoryBase::unmapObject(status, (UCHAR**) object, sizeof(Object)); } @@ -427,15 +427,16 @@ class SharedMutexGuard }; -} // namespace Firebird - #ifdef WIN_NT -int ISC_mutex_init(struct Firebird::mtx*, const TEXT*); -void ISC_mutex_fini(struct Firebird::mtx*); -int ISC_mutex_lock(struct Firebird::mtx*); -int ISC_mutex_unlock(struct Firebird::mtx*); +int ISC_mutex_init(struct mtx*, const TEXT*); +void ISC_mutex_fini(struct mtx*); +int ISC_mutex_lock(struct mtx*); +int ISC_mutex_unlock(struct mtx*); #endif ULONG ISC_exception_post(ULONG, const TEXT*, ISC_STATUS&); + +} // namespace Firebird + #endif // JRD_ISC_S_PROTO_H diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index 9998406e93f..7f777fa33e0 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -132,7 +132,9 @@ static size_t getpagesize() #endif -using namespace Firebird; +namespace Firebird +{ + static void error(CheckStatusWrapper*, const TEXT*, ISC_STATUS); static bool event_blocked(const event_t* event, const SLONG value); @@ -259,8 +261,6 @@ namespace { } // anonymous namespace -namespace Firebird { - class SharedFileInfo : public RefCounted { SharedFileInfo(int f, const DevNode& id) @@ -464,8 +464,6 @@ class SharedFileInfo : public RefCounted GlobalPtr SharedFileInfo::sharedFiles; GlobalPtr SharedFileInfo::sharedFilesMutex; -} // namespace Firebird - FileLock::FileLock(const char* fileName, InitFunction* init) : file(REF_NO_INCR, SharedFileInfo::get(fileName)), initFunction(init), level(LCK_NONE) @@ -2910,3 +2908,6 @@ static void error(CheckStatusWrapper* statusVector, const TEXT* string, ISC_STAT (Arg::StatusVector(statusVector) << Arg::Gds(isc_sys_request) << string << SYS_ERR(status)).copyTo(statusVector); } + + +} // namespace Firebird diff --git a/src/common/obj.h b/src/common/obj.h new file mode 100644 index 00000000000..1bab24e7a8a --- /dev/null +++ b/src/common/obj.h @@ -0,0 +1,286 @@ +/* + * PROGRAM: JRD Access Method + * MODULE: obj.h + * DESCRIPTION: Object types in meta-data + * + * The contents of this file are subject to the Interbase Public + * License Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy + * of the License at http://www.Inprise.com/IPL.html + * + * Software distributed under the License is distributed on an + * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express + * or implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code was created by Inprise Corporation + * and its predecessors. Portions created by Inprise Corporation are + * Copyright (C) Inprise Corporation. + * + * All Rights Reserved. + * Contributor(s): ______________________________________. + */ + +#ifndef COMMON_OBJ_H +#define COMMON_OBJ_H + +#include "../common/gdsassert.h" + +namespace Firebird +{ + + +// Object types used in RDB$DEPENDENCIES and RDB$USER_PRIVILEGES and stored in backup. +// Note: some values are hard coded in grant.gdl +// Keep existing constants unchanged. + +typedef SSHORT ObjectType; + +inline constexpr ObjectType obj_relation = 0; +inline constexpr ObjectType obj_view = 1; +inline constexpr ObjectType obj_trigger = 2; +inline constexpr ObjectType obj_computed = 3; +inline constexpr ObjectType obj_validation = 4; +inline constexpr ObjectType obj_procedure = 5; +inline constexpr ObjectType obj_index_expression = 6; +inline constexpr ObjectType obj_exception = 7; +inline constexpr ObjectType obj_user = 8; +inline constexpr ObjectType obj_field = 9; +inline constexpr ObjectType obj_index = 10; +inline constexpr ObjectType obj_charset = 11; +inline constexpr ObjectType obj_user_group = 12; +inline constexpr ObjectType obj_sql_role = 13; +inline constexpr ObjectType obj_generator = 14; +inline constexpr ObjectType obj_udf = 15; +inline constexpr ObjectType obj_blob_filter = 16; +inline constexpr ObjectType obj_collation = 17; +inline constexpr ObjectType obj_package_header = 18; +inline constexpr ObjectType obj_package_body = 19; +inline constexpr ObjectType obj_privilege = 20; + +// objects types for ddl operations +inline constexpr ObjectType obj_database = 21; +inline constexpr ObjectType obj_relations = 22; +inline constexpr ObjectType obj_views = 23; +inline constexpr ObjectType obj_procedures = 24; +inline constexpr ObjectType obj_functions = 25; +inline constexpr ObjectType obj_packages = 26; +inline constexpr ObjectType obj_generators = 27; +inline constexpr ObjectType obj_domains = 28; +inline constexpr ObjectType obj_exceptions = 29; +inline constexpr ObjectType obj_roles = 30; +inline constexpr ObjectType obj_charsets = 31; +inline constexpr ObjectType obj_collations = 32; +inline constexpr ObjectType obj_filters = 33; + +// Add new codes here if they are used in RDB$DEPENDENCIES or RDB$USER_PRIVILEGES or stored in backup +// Codes for DDL operations add in isDdlObject function as well (find it below). +inline constexpr ObjectType obj_jobs = 34; +inline constexpr ObjectType obj_tablespace = 35; +inline constexpr ObjectType obj_tablespaces = 36; +inline constexpr ObjectType obj_index_condition = 37; + +inline constexpr ObjectType obj_schema = 38; +inline constexpr ObjectType obj_schemas = 39; + +inline constexpr ObjectType obj_type_MAX = 40; + +// used in the parser only / no relation with obj_type_MAX (should be greater) +inline constexpr ObjectType obj_user_or_role = 100; +inline constexpr ObjectType obj_parameter = 101; +inline constexpr ObjectType obj_column = 102; +inline constexpr ObjectType obj_publication = 103; + +inline constexpr ObjectType obj_any = 255; + + +inline bool isSchemaBoundObject(ObjectType objectType) noexcept +{ + switch (objectType) + { + case obj_relation: + case obj_view: + case obj_trigger: + case obj_procedure: + case obj_exception: + case obj_field: + case obj_index: + case obj_charset: + case obj_generator: + case obj_udf: + case obj_collation: + case obj_package_header: + return true; + + default: + return false; + } +} + + +inline bool isDdlObject(ObjectType objectType, bool* useSchema = nullptr) noexcept +{ + if (useSchema) + *useSchema = false; + + switch (objectType) + { + case obj_relations: + case obj_views: + case obj_procedures: + case obj_functions: + case obj_packages: + case obj_generators: + case obj_domains: + case obj_exceptions: + case obj_charsets: + case obj_collations: + if (useSchema) + *useSchema = true; + [[fallthrough]]; + + case obj_database: + case obj_filters: + case obj_roles: + case obj_jobs: + case obj_tablespaces: + case obj_schemas: + return true; + + default: + return false; + } +} + + +inline constexpr const char* getDdlSecurityName(ObjectType object_type) noexcept +{ + switch (object_type) + { + case obj_database: + return "SQL$DATABASE"; + case obj_relations: + return "SQL$TABLES"; + case obj_views: + return "SQL$VIEWS"; + case obj_procedures: + return "SQL$PROCEDURES"; + case obj_functions: + return "SQL$FUNCTIONS"; + case obj_packages: + return "SQL$PACKAGES"; + case obj_generators: + return "SQL$GENERATORS"; + case obj_filters: + return "SQL$FILTERS"; + case obj_domains: + return "SQL$DOMAINS"; + case obj_exceptions: + return "SQL$EXCEPTIONS"; + case obj_roles: + return "SQL$ROLES"; + case obj_charsets: + return "SQL$CHARSETS"; + case obj_collations: + return "SQL$COLLATIONS"; + case obj_jobs: + return "SQL$JOBS"; + case obj_tablespaces: + return "SQL$TABLESPACES"; + case obj_schemas: + return "SQL$SCHEMAS"; + default: + return ""; + } +} + + +inline const char* getDdlObjectName(ObjectType object_type) +{ + switch (object_type) + { + case obj_database: + return "DATABASE"; + case obj_relations: + return "TABLE"; + case obj_packages: + return "PACKAGE"; + case obj_procedures: + return "PROCEDURE"; + case obj_functions: + return "FUNCTION"; + case obj_column: + return "COLUMN"; + case obj_charsets: + return "CHARACTER SET"; + case obj_collations: + return "COLLATION"; + case obj_domains: + return "DOMAIN"; + case obj_exceptions: + return "EXCEPTION"; + case obj_generators: + return "GENERATOR"; + case obj_views: + return "VIEW"; + case obj_roles: + return "ROLE"; + case obj_filters: + return "FILTER"; + case obj_jobs: + return "JOB"; + case obj_tablespaces: + return "TABLESPACE"; + case obj_schemas: + return "SCHEMA"; + default: + fb_assert(false); + return ""; + } +} + + +inline const char* getObjectName(ObjectType objType) +{ + switch (objType) + { + case obj_relation: + return "TABLE"; + case obj_trigger: + return "TRIGGER"; + case obj_package_header: + return "PACKAGE"; + case obj_procedure: + return "PROCEDURE"; + case obj_udf: + return "FUNCTION"; + case obj_column: + return "COLUMN"; + case obj_charset: + return "CHARACTER SET"; + case obj_collation: + return "COLLATION"; + case obj_field: + return "DOMAIN"; + case obj_exception: + return "EXCEPTION"; + case obj_generator: + return "GENERATOR"; + case obj_view: + return "VIEW"; + case obj_sql_role: + return "ROLE"; + case obj_blob_filter: + return "FILTER"; + case obj_schema: + return "SCHEMA"; + default: + fb_assert(false); + return ""; + } +} + + +} // namespace Firebird + +#endif // COMMON_OBJ_H diff --git a/src/common/os/darwin/mod_loader.cpp b/src/common/os/darwin/mod_loader.cpp index 463209174b9..f6c87e3557f 100644 --- a/src/common/os/darwin/mod_loader.cpp +++ b/src/common/os/darwin/mod_loader.cpp @@ -36,6 +36,10 @@ #include #include +namespace Firebird +{ + + /// This is the Darwin implementation of the mod_loader abstraction. //#define DEBUG_LOADER @@ -43,20 +47,20 @@ class DlfcnModule : public ModuleLoader::Module { public: - DlfcnModule(MemoryPool& pool, const Firebird::PathName& aFileName, void* m) + DlfcnModule(MemoryPool& pool, const PathName& aFileName, void* m) : ModuleLoader::Module(pool, aFileName), module(m) {} ~DlfcnModule(); - void* findSymbol(ISC_STATUS*, const Firebird::string&) override; - bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) override; + void* findSymbol(ISC_STATUS*, const string&) override; + bool getRealPath(const string& anySymbol, PathName& path) override; private: void* module; }; -bool ModuleLoader::isLoadableModule(const Firebird::PathName& module) +bool ModuleLoader::isLoadableModule(const PathName& module) { struct stat sb; @@ -72,7 +76,7 @@ bool ModuleLoader::isLoadableModule(const Firebird::PathName& module) return true; } -bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) +bool ModuleLoader::doctorModuleExtension(PathName& name, int& step) { if (name.isEmpty()) return false; @@ -81,7 +85,7 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) { case 0: // Step 0: append missing extension { - Firebird::PathName::size_type pos = name.rfind(".dylib"); + PathName::size_type pos = name.rfind(".dylib"); if (pos != name.length() - 6) { name += ".dylib"; @@ -91,8 +95,8 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) } case 1: // Step 1: insert missing prefix { - Firebird::PathName::size_type pos = name.rfind('/'); - pos = (pos == Firebird::PathName::npos) ? 0 : pos + 1; + PathName::size_type pos = name.rfind('/'); + pos = (pos == PathName::npos) ? 0 : pos + 1; if (name.find("lib", pos) != pos) { name.insert(pos, "lib"); @@ -109,7 +113,7 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) #define FB_RTLD_MODE RTLD_LAZY #endif -ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebird::PathName& modPath) +ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const PathName& modPath) { void* module = dlopen(modPath.c_str(), FB_RTLD_MODE); if (module == NULL) @@ -135,12 +139,12 @@ DlfcnModule::~DlfcnModule() dlclose(module); } -void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symName) +void* DlfcnModule::findSymbol(ISC_STATUS* status, const string& symName) { void* result = dlsym(module, symName.c_str()); if (result == NULL) { - Firebird::string newSym ='_' + symName; + string newSym ='_' + symName; result = dlsym(module, newSym.c_str()); } @@ -156,7 +160,7 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam return result; } -bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) +bool DlfcnModule::getRealPath(const string& anySymbol, PathName& path) { #ifdef HAVE_DLADDR void* symbolPtr = dlsym(module, anySymbol.c_str()); @@ -183,3 +187,6 @@ bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathN path.clear(); return false; } + + +} // namespace Firebird diff --git a/src/common/os/divorce.h b/src/common/os/divorce.h index 84b5c5be8a4..e1e61a8d981 100644 --- a/src/common/os/divorce.h +++ b/src/common/os/divorce.h @@ -24,6 +24,9 @@ #ifndef JRD_DIVOR_PROTO_H #define JRD_DIVOR_PROTO_H -extern void divorce_terminal(int); +namespace Firebird +{ + void divorce_terminal(int); +} // namespace Firebird #endif /* JRD_DIVOR_PROTO_H */ diff --git a/src/common/os/guid.h b/src/common/os/guid.h index 1fcdf686ab6..2494c561a35 100644 --- a/src/common/os/guid.h +++ b/src/common/os/guid.h @@ -128,16 +128,16 @@ class Guid m_data.Data4[4], m_data.Data4[5], m_data.Data4[6], m_data.Data4[7]); } - Firebird::string toString(bool withBrackets = true) const + string toString(bool withBrackets = true) const { - Firebird::string result; + string result; toString(result, withBrackets); return result; } - Firebird::PathName toPathName(bool withBrackets = true) const + PathName toPathName(bool withBrackets = true) const { - Firebird::PathName result; + PathName result; toString(result, withBrackets); return result; } @@ -155,7 +155,7 @@ class Guid return (result == GUID_FORMAT_ARGS) ? std::optional(uuid) : std::nullopt; } - static std::optional fromString(const Firebird::string& str) + static std::optional fromString(const string& str) { return fromString(str.nullStr()); } diff --git a/src/common/os/isc_i_proto.h b/src/common/os/isc_i_proto.h index 12a9224124a..e1388cbb4fd 100644 --- a/src/common/os/isc_i_proto.h +++ b/src/common/os/isc_i_proto.h @@ -24,6 +24,10 @@ #ifndef JRD_ISC_I_PROTO_H #define JRD_ISC_I_PROTO_H +namespace Firebird +{ + + #ifdef WIN_NT // This will poke event int ISC_kill(SLONG, SLONG, HANDLE); @@ -39,4 +43,7 @@ HANDLE ISC_make_signal(bool, bool, int, int); void ISC_signal_init(); + +} // namespace Firebird + #endif // JRD_ISC_I_PROTO_H diff --git a/src/common/os/mod_loader.h b/src/common/os/mod_loader.h index aacd256b089..ace12c5d6ed 100644 --- a/src/common/os/mod_loader.h +++ b/src/common/os/mod_loader.h @@ -30,6 +30,10 @@ #include "../common/classes/fb_string.h" +namespace Firebird +{ + + /*** The ModuleLoader class is an abstraction of the dynamic code loading facilities provided by the host operating system. The class provides @@ -60,11 +64,11 @@ class ModuleLoader If the symbol can't be found or doesn't exist the function returns NULL. **/ - virtual void* findSymbol(ISC_STATUS*, const Firebird::string&) = 0; + virtual void* findSymbol(ISC_STATUS*, const string&) = 0; - virtual bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) = 0; + virtual bool getRealPath(const string& anySymbol, PathName& path) = 0; - template T& findSymbol(ISC_STATUS* status, const Firebird::string& symbol, T& ptr) + template T& findSymbol(ISC_STATUS* status, const string& symbol, T& ptr) { return (ptr = (T)(findSymbol(status, symbol))); } @@ -77,12 +81,12 @@ class ModuleLoader /// assignment of Modules isn't supported const Module& operator=(const Module&) = delete; - const Firebird::PathName fileName; + const PathName fileName; protected: /// The constructor is protected so normal code can't allocate instances /// of the class, but the class itself is still able to be subclassed. - Module(MemoryPool& pool, const Firebird::PathName& aFileName) + Module(MemoryPool& pool, const PathName& aFileName) : fileName(pool, aFileName) { } @@ -96,7 +100,7 @@ class ModuleLoader the returned module object when it is no longer needed. If unsuccessful it returns NULL. OS-specific error is returned in status parameter. **/ - static Module* loadModule(ISC_STATUS* status, const Firebird::PathName&); + static Module* loadModule(ISC_STATUS* status, const PathName&); /** doctorModuleExtension modifies the given path name to add the platform specific module extension. This allows the user to provide the root name @@ -108,13 +112,13 @@ class ModuleLoader Initialize step to zero before use. Return false if no name modification can be done anymore. **/ - static bool doctorModuleExtension(Firebird::PathName& name, int& step); + static bool doctorModuleExtension(PathName& name, int& step); /** Almost like loadModule(), but in case of failure invokes doctorModuleExtension() and retries. On success modName is set to really found module name. **/ - static Module* fixAndLoadModule(ISC_STATUS* status, Firebird::PathName& modName) + static Module* fixAndLoadModule(ISC_STATUS* status, PathName& modName) { Module* mod = nullptr; int step = 0; @@ -131,8 +135,10 @@ class ModuleLoader module. This function is required because different operating systems require different checks. **/ - static bool isLoadableModule(const Firebird::PathName&); + static bool isLoadableModule(const PathName&); }; -#endif // JRD_OS_MOD_LOADER_H +} // namespace Firebird + +#endif // JRD_OS_MOD_LOADER_H diff --git a/src/common/os/os_utils.h b/src/common/os/os_utils.h index bbdc2f1c459..ce7d1027d5f 100644 --- a/src/common/os/os_utils.h +++ b/src/common/os/os_utils.h @@ -68,12 +68,11 @@ #define FLOCK flock #endif -namespace os_utils -{ +namespace Firebird::os_utils { SLONG get_user_group_id(const TEXT* user_group_name); SLONG get_user_id(const TEXT* user_name); - bool get_user_home(int user_id, Firebird::PathName& homeDir); + bool get_user_home(int user_id, PathName& homeDir); void createLockDirectory(const char* pathname); int openCreateSharedFile(const char* pathname, int flags); @@ -90,11 +89,11 @@ namespace os_utils // return a binary string that uniquely identifies the file #ifdef WIN_NT - void getUniqueFileId(HANDLE fd, Firebird::UCharBuffer& id); + void getUniqueFileId(HANDLE fd, UCharBuffer& id); #else - void getUniqueFileId(int fd, Firebird::UCharBuffer& id); + void getUniqueFileId(int fd, UCharBuffer& id); #define HAVE_ID_BY_NAME - void getUniqueFileId(const char* name, Firebird::UCharBuffer& id); + void getUniqueFileId(const char* name, UCharBuffer& id); #endif inline SINT64 lseek(int fd, SINT64 offset, int origin) diff --git a/src/common/os/path_utils.h b/src/common/os/path_utils.h index fc37d0f4f3d..c9b27d0d408 100644 --- a/src/common/os/path_utils.h +++ b/src/common/os/path_utils.h @@ -31,6 +31,9 @@ #include "../common/classes/fb_string.h" #include "../../common/classes/alloc.h" +namespace Firebird +{ + /** This is a utility class that provides a platform independent way to do some file path operations. The operations include determining if a path is @@ -62,16 +65,16 @@ class PathUtils subclass DirIterator to create DirIterator objects that function correctly on the platform. **/ - class DirIterator : protected Firebird::AutoStorage + class DirIterator : protected AutoStorage { public: // The constructor requires a string that is the path of the directory being iterated. // DirIterator may be located on stack, therefore use AutoStorage. - DirIterator(MemoryPool& p, const Firebird::PathName& dir) + DirIterator(MemoryPool& p, const PathName& dir) : AutoStorage(p), dirPrefix(getPool(), dir) {} - DirIterator(const Firebird::PathName& dir) + DirIterator(const PathName& dir) : AutoStorage(), dirPrefix(getPool(), dir) {} @@ -93,7 +96,7 @@ class PathUtils // item in the iteration. This path is prefixed with the path of // the directory. If the last element of the path is wanted use // PathUtils::splitLastComponent on the result of this function. - virtual const Firebird::PathName& operator*() noexcept = 0; + virtual const PathName& operator*() noexcept = 0; // Tests if the iterator has reached the end of the iteration. // It is implemented in such a way to make the following loop work correctly: @@ -102,7 +105,7 @@ class PathUtils protected: // Stores the path to the directory as given in the constructor - const Firebird::PathName dirPrefix; + const PathName dirPrefix; }; /** isRelative returns true if the given path is relative, and false if not. @@ -110,19 +113,19 @@ class PathUtils For example, the path 'firebird/bin' is a relative path in unix while the path '/opt/firebird/bin' is not. **/ - static bool isRelative(const Firebird::PathName& path); + static bool isRelative(const PathName& path); /** isSymLink returns true if the given path is symbolic link, and false if not. Use of this links may provide way to override system security. Example: ln -s /usr/firebird/ExternalTables/mytable /etc/xinet.d/remoteshell and insert desired rows into mytable. **/ - static bool isSymLink(const Firebird::PathName& path); + static bool isSymLink(const PathName& path); /** canAccess returns true if the given path can be accessed by this process. mode - like in ACCESS(2). **/ - static bool canAccess(const Firebird::PathName& path, int mode); + static bool canAccess(const PathName& path, int mode); /** Concatenates the two paths given in the second and third parameters, and writes the resulting path into the first parameter. The @@ -132,17 +135,17 @@ class PathUtils a simple string concatenation of the arguments with the directory separator character. **/ - static void concatPath(Firebird::PathName&, const Firebird::PathName&, - const Firebird::PathName&); + static void concatPath(PathName&, const PathName&, + const PathName&); // Tries to ensure our path finishes with a platform-specific directory separator. // We don't work correctly with MBCS. - static void ensureSeparator(Firebird::PathName& in_out); + static void ensureSeparator(PathName& in_out); // Ensure the path separators are correct for the current platform static void fixupSeparators(char* path) noexcept; - static void fixupSeparators(Firebird::PathName& path) noexcept + static void fixupSeparators(PathName& path) noexcept { fixupSeparators(path.begin()); } @@ -154,15 +157,15 @@ class PathUtils If the input path has only one component that component is returned in the second parameter and the first parameter is set to the empty string. **/ - static void splitLastComponent(Firebird::PathName&, Firebird::PathName&, - const Firebird::PathName&); + static void splitLastComponent(PathName&, PathName&, + const PathName&); /** splitPrefix takes a path as the first argument, splits OS-dependent prefix from it (something like C:\, D: or \ in windows or / in posix), and returns stripped path inplace, i.e. as first argument. Prefix is returned as the second argument. **/ - static void splitPrefix(Firebird::PathName& path, Firebird::PathName& prefix); + static void splitPrefix(PathName& path, PathName& prefix); /** This is the factory method for allocating DirIterator objects. It takes a reference to a memory pool to use for all heap allocations, @@ -171,13 +174,15 @@ class PathUtils All errors result in either exceptions being thrown, or a valid empty DirIterator being returned. **/ - static DirIterator* newDirIterator(MemoryPool&, const Firebird::PathName&); + static DirIterator* newDirIterator(MemoryPool&, const PathName&); /** makeDir creates directory passed as parameter. return value is 0 on success or error code on error. **/ - static int makeDir(const Firebird::PathName& path); + static int makeDir(const PathName& path); }; -#endif // JRD_OS_PATH_UTILS_H +} // namespace Firebird + +#endif // JRD_OS_PATH_UTILS_H diff --git a/src/common/os/posix/SyncSignals.cpp b/src/common/os/posix/SyncSignals.cpp index 54beabd45d9..ee0452ea9a0 100644 --- a/src/common/os/posix/SyncSignals.cpp +++ b/src/common/os/posix/SyncSignals.cpp @@ -54,11 +54,15 @@ #include #include -namespace { +namespace Firebird +{ + +namespace +{ // Here we can't use atomic counter instead mutex/counter pair - or some thread may leave SyncSignalsSet() // before signals are actually set in the other thread, which incremented counter first - Firebird::GlobalPtr syncEnterMutex; + GlobalPtr syncEnterMutex; int syncEnterCounter = 0; TLS_DECLARE(sigjmp_buf*, sigjmpPtr); @@ -79,10 +83,8 @@ namespace { act.sa_handler = handler; sigaction(signum, &act, NULL); } - } // anonymous namespace -namespace Firebird { void syncSignalsSet(sigjmp_buf* sigenv) { @@ -98,7 +100,7 @@ void syncSignalsSet(sigjmp_buf* sigenv) **************************************/ TLS_SET(sigjmpPtr, sigenv); - Firebird::MutexLockGuard g(syncEnterMutex, "syncSignalsSet"); + MutexLockGuard g(syncEnterMutex, "syncSignalsSet"); if (syncEnterCounter++ == 0) { @@ -124,7 +126,7 @@ void syncSignalsReset() * **************************************/ - Firebird::MutexLockGuard g(syncEnterMutex, "syncSignalsReset"); + MutexLockGuard g(syncEnterMutex, "syncSignalsReset"); fb_assert(syncEnterCounter > 0); @@ -137,4 +139,5 @@ void syncSignalsReset() } } + } // namespace Firebird diff --git a/src/common/os/posix/divorce.cpp b/src/common/os/posix/divorce.cpp index ce2089fbe95..7a7173cc289 100644 --- a/src/common/os/posix/divorce.cpp +++ b/src/common/os/posix/divorce.cpp @@ -78,6 +78,8 @@ #include #endif +namespace Firebird +{ void divorce_terminal(int mask) @@ -147,3 +149,6 @@ void divorce_terminal(int mask) #endif // HAVE_SETPGID #endif // HAVE_SETPGRP } + + +} // namespace Firebird diff --git a/src/common/os/posix/guid.cpp b/src/common/os/posix/guid.cpp index b431026afbc..c93bb73d84b 100644 --- a/src/common/os/posix/guid.cpp +++ b/src/common/os/posix/guid.cpp @@ -46,7 +46,7 @@ void GenerateRandomBytes(void* buffer, FB_SIZE_T size) // do not use /dev/random because it may return lesser data than we need. int fd = os_utils::open("/dev/urandom", O_RDONLY); if (fd < 0) - Firebird::system_call_failed::raise("open"); + system_call_failed::raise("open"); for (FB_SIZE_T offset = 0; offset < size; ) { @@ -54,17 +54,17 @@ void GenerateRandomBytes(void* buffer, FB_SIZE_T size) if (rc < 0) { if (errno != EINTR) - Firebird::system_call_failed::raise("read"); + system_call_failed::raise("read"); continue; } if (rc == 0) - Firebird::system_call_failed::raise("read", EIO); + system_call_failed::raise("read", EIO); offset += static_cast(rc); } if (close(fd) < 0) { if (errno != EINTR) - Firebird::system_call_failed::raise("close"); + system_call_failed::raise("close"); // In case when close() is interrupted by a signal, // the state of fd is unspecified - give up and return success. } diff --git a/src/common/os/posix/isc_ipc.cpp b/src/common/os/posix/isc_ipc.cpp index 053efb49113..ed82421575a 100644 --- a/src/common/os/posix/isc_ipc.cpp +++ b/src/common/os/posix/isc_ipc.cpp @@ -81,6 +81,10 @@ //#define LOCAL_SEMAPHORES 4 +namespace Firebird +{ + + struct sig { struct sig* sig_next; @@ -114,15 +118,15 @@ namespace { class SignalMutex { public: - Firebird::Mutex mutex; + Mutex mutex; - explicit SignalMutex(Firebird::MemoryPool&) + explicit SignalMutex(MemoryPool&) { sigActive = true; } ~SignalMutex() { - Firebird::MutexLockGuard guard(mutex, "~SignalMutex()"); + MutexLockGuard guard(mutex, "~SignalMutex()"); sigActive = false; for (SIG sig = signals; sig;) @@ -135,12 +139,13 @@ namespace { } }; - Firebird::GlobalPtr sigMutex; + GlobalPtr sigMutex; } static bool isc_signal2(int signal, FPTR_VOID handler, void* arg, ULONG); static SIG que_signal(int signal, FPTR_VOID handler, void* arg, int flags, bool w_siginfo); + #ifdef __cplusplus extern "C" { #endif @@ -196,7 +201,7 @@ static bool isc_signal2(int signal_number, FPTR_VOID handler, void* arg, ULONG f SIG sig; - Firebird::MutexLockGuard guard(sigMutex->mutex, "isc_signal2"); + MutexLockGuard guard(sigMutex->mutex, "isc_signal2"); // See if this signal has ever been cared about before @@ -277,7 +282,7 @@ void ISC_signal_cancel(int signal_number, FPTR_VOID_PTR handler, void* arg) SIG sig; volatile SIG* ptr; - Firebird::MutexLockGuard guard(sigMutex->mutex, "ISC_signal_cancel"); + MutexLockGuard guard(sigMutex->mutex, "ISC_signal_cancel"); for (ptr = &signals; (sig = *ptr);) { if (sig->sig_signal == signal_number && @@ -393,3 +398,6 @@ static void CLIB_ROUTINE signal_action(int number) } } } + + +} // namespace Firebird diff --git a/src/common/os/posix/mod_loader.cpp b/src/common/os/posix/mod_loader.cpp index 5bf928e7ada..9fb60411043 100644 --- a/src/common/os/posix/mod_loader.cpp +++ b/src/common/os/posix/mod_loader.cpp @@ -41,21 +41,25 @@ #include #include +namespace Firebird +{ + + /// This is the POSIX (dlopen) implementation of the mod_loader abstraction. class DlfcnModule : public ModuleLoader::Module { public: - DlfcnModule(MemoryPool& pool, const Firebird::PathName& aFileName, void* m); + DlfcnModule(MemoryPool& pool, const PathName& aFileName, void* m); ~DlfcnModule(); - void* findSymbol(ISC_STATUS*, const Firebird::string&) override; + void* findSymbol(ISC_STATUS*, const string&) override; - bool getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) override; + bool getRealPath(const string& anySymbol, PathName& path) override; private: void* module; - Firebird::PathName realPath; + PathName realPath; }; static void makeErrorStatus(ISC_STATUS* status, const char* text) @@ -70,7 +74,7 @@ static void makeErrorStatus(ISC_STATUS* status, const char* text) } } -bool ModuleLoader::isLoadableModule(const Firebird::PathName& module) +bool ModuleLoader::isLoadableModule(const PathName& module) { struct STAT sb; @@ -86,7 +90,7 @@ bool ModuleLoader::isLoadableModule(const Firebird::PathName& module) return true; } -bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) +bool ModuleLoader::doctorModuleExtension(PathName& name, int& step) { if (name.isEmpty()) return false; @@ -95,11 +99,11 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) { case 0: // Step 0: append missing extension { - Firebird::PathName::size_type pos = name.rfind("." SHRLIB_EXT); + PathName::size_type pos = name.rfind("." SHRLIB_EXT); if (pos != name.length() - 3) { pos = name.rfind("." SHRLIB_EXT "."); - if (pos == Firebird::PathName::npos) + if (pos == PathName::npos) { name += "." SHRLIB_EXT; return true; @@ -109,8 +113,8 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) } case 1: // Step 1: insert missing prefix { - Firebird::PathName::size_type pos = name.rfind('/'); - pos = (pos == Firebird::PathName::npos) ? 0 : pos + 1; + PathName::size_type pos = name.rfind('/'); + pos = (pos == PathName::npos) ? 0 : pos + 1; if (name.find("lib", pos) != pos) { name.insert(pos, "lib"); @@ -127,7 +131,7 @@ bool ModuleLoader::doctorModuleExtension(Firebird::PathName& name, int& step) #define FB_RTLD_MODE RTLD_LAZY // save time when loading library #endif -ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebird::PathName& modPath) +ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const PathName& modPath) { void* module = dlopen(modPath.nullStr(), FB_RTLD_MODE); if (module == NULL) @@ -137,13 +141,13 @@ ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebir } #ifdef DEBUG_THREAD_IN_UNLOADED_LIBRARY - Firebird::string command; + string command; command.printf("echo +++ %s +++ >>/tmp/fbmaps;date >> /tmp/fbmaps;cat /proc/%d/maps >>/tmp/fbmaps", modPath.c_str(), getpid()); system(command.c_str()); #endif - Firebird::PathName linkPath = modPath; + PathName linkPath = modPath; char b[PATH_MAX]; const char* newPath = realpath(modPath.c_str(), b); if (newPath) @@ -152,7 +156,7 @@ ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const Firebir return FB_NEW_POOL(*getDefaultMemoryPool()) DlfcnModule(*getDefaultMemoryPool(), linkPath, module); } -DlfcnModule::DlfcnModule(MemoryPool& pool, const Firebird::PathName& aFileName, void* m) +DlfcnModule::DlfcnModule(MemoryPool& pool, const PathName& aFileName, void* m) : ModuleLoader::Module(pool, aFileName), module(m), realPath(pool) @@ -166,13 +170,13 @@ DlfcnModule::~DlfcnModule() dlclose(module); } -void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symName) +void* DlfcnModule::findSymbol(ISC_STATUS* status, const string& symName) { void* result = dlsym(module, symName.c_str()); if (!result) { - Firebird::string newSym = '_' + symName; + string newSym = '_' + symName; result = dlsym(module, newSym.c_str()); } @@ -202,7 +206,7 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam if (PathUtils::isRelative(libraryPath) || PathUtils::isRelative(symbolPath)) { // check only name (not path) of the library - Firebird::PathName dummyDir, nm1, nm2; + PathName dummyDir, nm1, nm2; PathUtils::splitLastComponent(dummyDir, nm1, libraryPath); PathUtils::splitLastComponent(dummyDir, nm2, symbolPath); if (nm1 != nm2) @@ -221,7 +225,7 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam return result; } -bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathName& path) +bool DlfcnModule::getRealPath(const string& anySymbol, PathName& path) { if (realPath.hasData()) { @@ -287,3 +291,6 @@ bool DlfcnModule::getRealPath(const Firebird::string& anySymbol, Firebird::PathN path.clear(); return false; } + + +} // namespace Firebird diff --git a/src/common/os/posix/os_utils.cpp b/src/common/os/posix/os_utils.cpp index e2d39b73d27..e1bdeb69cc1 100644 --- a/src/common/os/posix/os_utils.cpp +++ b/src/common/os/posix/os_utils.cpp @@ -32,7 +32,7 @@ #include "../common/gdsassert.h" #include "../common/os/os_utils.h" #include "../common/os/isc_i_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #ifdef HAVE_UNISTD_H #include @@ -86,11 +86,10 @@ #include -using namespace Firebird; - -namespace os_utils +namespace Firebird::os_utils { + static GlobalPtr grMutex; // Return user group id if user group name found, otherwise return 0. @@ -186,7 +185,7 @@ void createLockDirectory(const char* pathname) system_call_failed::raise("access", pathname); } - Firebird::PathName newname(pathname); + PathName newname(pathname); newname.rtrim("/"); newname += ".tmp.XXXXXX"; char* pathname2 = newname.begin(); @@ -199,7 +198,7 @@ void createLockDirectory(const char* pathname) } changeFileRights(pathname2, 0770); - Firebird::PathName renameGuard(pathname2); + PathName renameGuard(pathname2); renameGuard += "/fb_rename_guard"; for(;;) { @@ -451,4 +450,5 @@ void CtrlCHandler::handler(void*) terminated = true; } -} // namespace os_utils + +} // namespace Firebird::os_utils diff --git a/src/common/os/posix/path_utils.cpp b/src/common/os/posix/path_utils.cpp index 26f6476a8e5..d6b14ca831d 100644 --- a/src/common/os/posix/path_utils.cpp +++ b/src/common/os/posix/path_utils.cpp @@ -34,7 +34,9 @@ #include #include -using namespace Firebird; +namespace Firebird +{ + /// The POSIX implementation of the path_utils abstraction. @@ -266,3 +268,6 @@ int PathUtils::makeDir(const PathName& path) return rc; } + + +} // namespace Firebird diff --git a/src/common/os/win32/fbsyslog.cpp b/src/common/os/win32/fbsyslog.cpp index 1255bd7d2bd..de338b11d35 100644 --- a/src/common/os/win32/fbsyslog.cpp +++ b/src/common/os/win32/fbsyslog.cpp @@ -25,6 +25,10 @@ #include +namespace Firebird +{ + + namespace { typedef HANDLE WINAPI tRegisterEventSource(LPCTSTR lpUNCServerName, LPCTSTR lpSourceName); @@ -48,7 +52,7 @@ class SyslogAccess tReportEvent *fReportEvent; bool InitFlag; public: - explicit SyslogAccess(Firebird::MemoryPool&) + explicit SyslogAccess(MemoryPool&) { InitializeCriticalSection(&cs); InitFlag = false; @@ -88,12 +92,10 @@ void SyslogAccess::Record(WORD wType, const char* msg) LeaveCriticalSection(&cs); } -Firebird::InitInstance iSyslogAccess; +InitInstance iSyslogAccess; } // namespace -namespace Firebird { - void Syslog::Record(Severity level, const char* msg) { WORD wType = EVENTLOG_ERROR_TYPE; diff --git a/src/common/os/win32/guid.cpp b/src/common/os/win32/guid.cpp index 0878decea11..15f4d9658b0 100644 --- a/src/common/os/win32/guid.cpp +++ b/src/common/os/win32/guid.cpp @@ -41,14 +41,14 @@ namespace Firebird { void GenerateRandomBytes(void* buffer, FB_SIZE_T size) { if (BCryptGenRandom(nullptr, static_cast(buffer), size, BCRYPT_USE_SYSTEM_PREFERRED_RNG) != S_OK) - Firebird::system_call_failed::raise("BCryptGenRandom"); + system_call_failed::raise("BCryptGenRandom"); } void GenerateGuid(UUID* guid) { const HRESULT error = CoCreateGuid(guid); if (!SUCCEEDED(error)) - Firebird::system_call_failed::raise("CoCreateGuid", error); + system_call_failed::raise("CoCreateGuid", error); } diff --git a/src/common/os/win32/isc_ipc.cpp b/src/common/os/win32/isc_ipc.cpp index d3e8b8b7e1b..05fb6480f75 100644 --- a/src/common/os/win32/isc_ipc.cpp +++ b/src/common/os/win32/isc_ipc.cpp @@ -64,6 +64,9 @@ #define SIG_ACK (void (__cdecl *)(int))4 // acknowledge #endif +namespace Firebird +{ + namespace { @@ -73,7 +76,7 @@ constexpr int MAX_OPN_EVENTS = 40; class OpenEvents { public: - explicit OpenEvents(Firebird::MemoryPool&) noexcept + explicit OpenEvents(MemoryPool&) noexcept { m_count = 0; m_clock = 0; @@ -91,7 +94,7 @@ class OpenEvents HANDLE getEvent(SLONG pid, SLONG signal_number) { - Firebird::MutexLockGuard guard(&m_mutex, FB_FUNCTION); + MutexLockGuard guard(&m_mutex, FB_FUNCTION); Item* oldestEvent = NULL; FB_UINT64 oldestAge = ~(0ULL); @@ -145,12 +148,12 @@ class OpenEvents Item m_events[MAX_OPN_EVENTS]{}; int m_count; FB_UINT64 m_clock; - Firebird::Mutex m_mutex; + Mutex m_mutex; }; } // namespace -Firebird::GlobalPtr openEvents; +GlobalPtr openEvents; int ISC_kill(SLONG pid, SLONG signal_number, HANDLE object_hndl) { @@ -228,7 +231,7 @@ namespace } }; - Firebird::InitMutex signalInit("SignalInit"); + InitMutex signalInit("SignalInit"); } // anonymous namespace void ISC_signal_init() @@ -246,3 +249,6 @@ void ISC_signal_init() signalInit.init(); } + + +} // namespace Firebird diff --git a/src/common/os/win32/mod_loader.cpp b/src/common/os/win32/mod_loader.cpp index 99db521c756..72e0a07e2ee 100644 --- a/src/common/os/win32/mod_loader.cpp +++ b/src/common/os/win32/mod_loader.cpp @@ -11,7 +11,9 @@ #include "../common/config/config.h" #include "../common/classes/ImplementHelper.h" -using namespace Firebird; +namespace Firebird +{ + /// This is the Win32 implementation of the mod_loader abstraction. @@ -120,7 +122,7 @@ class ContextActivator actCtx.cbSize = sizeof(actCtx); actCtx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID; actCtx.lpResourceName = ISOLATIONAWARE_MANIFEST_RESOURCE_ID; - actCtx.hModule = Firebird::hDllInst; + actCtx.hModule = hDllInst; if (actCtx.hModule) { @@ -282,3 +284,6 @@ bool Win32Module::getRealPath(const string& /*anySymbol*/, PathName& path) return false; } + + +} // namespace Firebird diff --git a/src/common/os/win32/os_utils.cpp b/src/common/os/win32/os_utils.cpp index 25369ae7b29..7d43caa2681 100644 --- a/src/common/os/win32/os_utils.cpp +++ b/src/common/os/win32/os_utils.cpp @@ -33,7 +33,7 @@ #include "../common/gdsassert.h" #include "../common/os/guid.h" #include "../common/os/os_utils.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/os/path_utils.h" #include "../common/isc_proto.h" #include "iberror.h" @@ -127,8 +127,7 @@ namespace InitMutex entryLoader("EntryPointLoader"); } // anonymous namespace -namespace os_utils -{ +namespace Firebird::os_utils { // waits for implementation SLONG get_user_group_id(const TEXT* /*user_group_name*/) diff --git a/src/common/os/win32/path_utils.cpp b/src/common/os/win32/path_utils.cpp index ecd2e37907c..66fb6887815 100644 --- a/src/common/os/win32/path_utils.cpp +++ b/src/common/os/win32/path_utils.cpp @@ -5,7 +5,9 @@ #include // _mkdir #include -using namespace Firebird; +namespace Firebird +{ + /// The Win32 implementation of the path_utils abstraction. @@ -261,3 +263,6 @@ int PathUtils::makeDir(const PathName& path) { return _mkdir(path.c_str()) ? errno : 0; } + + +} // namespace Firebird diff --git a/src/common/prett_proto.h b/src/common/prett_proto.h index fbf9967254e..a19d97399b1 100644 --- a/src/common/prett_proto.h +++ b/src/common/prett_proto.h @@ -24,8 +24,11 @@ #ifndef GPRE_PRETT_PROTO_H #define GPRE_PRETT_PROTO_H -int PRETTY_print_cdb(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); -int PRETTY_print_dyn(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); -int PRETTY_print_sdl(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); +namespace Firebird +{ + int PRETTY_print_cdb(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); + int PRETTY_print_dyn(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); + int PRETTY_print_sdl(const UCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT); +} // namespace Firebird #endif // GPRE_PRETT_PROTO_H diff --git a/src/common/pretty.cpp b/src/common/pretty.cpp index 44b883b7755..ee4fcd6adfa 100644 --- a/src/common/pretty.cpp +++ b/src/common/pretty.cpp @@ -32,10 +32,14 @@ #include #include #include "ibase.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/prett_proto.h" #include "../yvalve/gds_proto.h" +namespace Firebird +{ + + static inline void ADVANCE_PTR(TEXT*& ptr) noexcept { while (*ptr) @@ -899,3 +903,5 @@ static int print_word( ctl* control) return (v2 << 8) | v1; } + +} // namespace Firebird diff --git a/src/common/sdl.cpp b/src/common/sdl.cpp index 46eeedb908f..db6386c993e 100644 --- a/src/common/sdl.cpp +++ b/src/common/sdl.cpp @@ -32,12 +32,13 @@ constexpr int COMPILE_SIZE = 256; -using namespace Jrd; -using namespace Firebird; +namespace Firebird +{ + struct sdl_arg { - Ods::InternalArrayDesc* sdl_arg_desc; + Jrd::Ods::InternalArrayDesc* sdl_arg_desc; const UCHAR* sdl_arg_sdl; UCHAR* sdl_arg_array; SLONG* sdl_arg_variables; @@ -114,7 +115,7 @@ constexpr int op_scalar = 12; SLONG SDL_compute_subscript(CheckStatusWrapper* status_vector, - const Ods::InternalArrayDesc* desc, + const Jrd::Ods::InternalArrayDesc* desc, USHORT dimensions, const SLONG* subscripts) { @@ -138,8 +139,8 @@ SLONG SDL_compute_subscript(CheckStatusWrapper* status_vector, SLONG subscript = 0; - const Ods::InternalArrayDesc::iad_repeat* range = desc->iad_rpt; - for (const Ods::InternalArrayDesc::iad_repeat* const end = range + desc->iad_dimensions; + const Jrd::Ods::InternalArrayDesc::iad_repeat* range = desc->iad_rpt; + for (const Jrd::Ods::InternalArrayDesc::iad_repeat* const end = range + desc->iad_dimensions; range < end; ++range) { const SLONG n = *subscripts++; @@ -241,7 +242,7 @@ ISC_STATUS SDL_info(CheckStatusWrapper* status_vector, int SDL_walk(CheckStatusWrapper* status_vector, const UCHAR* sdl, UCHAR* array, - Ods::InternalArrayDesc* array_desc, + Jrd::Ods::InternalArrayDesc* array_desc, SLONG* variables, SDL_walk_callback callback, array_slice* argument) @@ -515,8 +516,8 @@ static bool execute(sdl_arg* arg) SLONG value, count; dsc element_desc; - Ods::InternalArrayDesc* array_desc = arg->sdl_arg_desc; - const Ods::InternalArrayDesc::iad_repeat* const range_end = + Jrd::Ods::InternalArrayDesc* array_desc = arg->sdl_arg_desc; + const Jrd::Ods::InternalArrayDesc::iad_repeat* const range_end = array_desc->iad_rpt + array_desc->iad_dimensions; SLONG* variables = arg->sdl_arg_variables; const IPTR* next = arg->sdl_arg_compiled; @@ -588,7 +589,7 @@ static bool execute(sdl_arg* arg) value = *next++; next++; // Skip count, unsupported. SLONG subscript = 0; - for (const Ods::InternalArrayDesc::iad_repeat* range = array_desc->iad_rpt; + for (const Jrd::Ods::InternalArrayDesc::iad_repeat* range = array_desc->iad_rpt; range < range_end; ++range) { const SLONG n = *stack_ptr++; @@ -963,3 +964,6 @@ static IPTR* stuff(IPTR value, sdl_arg* arg) return arg->sdl_arg_next - 1; } + + +} // namespace Firebird diff --git a/src/common/sdl.h b/src/common/sdl.h index f3914f04a3a..9b46cc810e9 100644 --- a/src/common/sdl.h +++ b/src/common/sdl.h @@ -26,14 +26,19 @@ #include "../common/classes/MetaString.h" #include "../common/classes/QualifiedMetaString.h" +#include "../common/constants.h" #include "../common/dsc.h" +namespace Firebird +{ + + struct sdl_info { USHORT sdl_info_fid; USHORT sdl_info_rid; - Firebird::MetaString sdl_info_field; - Firebird::QualifiedMetaString sdl_info_relation; + MetaString sdl_info_field; + QualifiedMetaString sdl_info_relation; dsc sdl_info_element; USHORT sdl_info_dimensions; SLONG sdl_info_lower[MAX_ARRAY_DIMENSIONS]; @@ -54,5 +59,8 @@ struct array_slice }; typedef void (*SDL_walk_callback)(array_slice*, ULONG, dsc*); -#endif /* JRD_SDL_H */ + +} // namespace Firebird + +#endif /* JRD_SDL_H */ diff --git a/src/common/sdl_proto.h b/src/common/sdl_proto.h index 7ef8b303c92..55895834b97 100644 --- a/src/common/sdl_proto.h +++ b/src/common/sdl_proto.h @@ -24,17 +24,20 @@ #ifndef JRD_SDL_PROTO_H #define JRD_SDL_PROTO_H -namespace Ods { - struct InternalArrayDesc; -} +namespace Firebird +{ + namespace Jrd::Ods + { + struct InternalArrayDesc; + } -struct sdl_info; -struct array_alice; + struct sdl_info; + struct array_alice; -SLONG SDL_compute_subscript(Firebird::CheckStatusWrapper*, const Ods::InternalArrayDesc*, USHORT, const SLONG*); -ISC_STATUS SDL_info(Firebird::CheckStatusWrapper*, const UCHAR*, sdl_info*, const SLONG*); -int SDL_walk(Firebird::CheckStatusWrapper*, const UCHAR*, UCHAR*, Ods::InternalArrayDesc*, SLONG*, - SDL_walk_callback, array_slice*); + SLONG SDL_compute_subscript(CheckStatusWrapper*, const Jrd::Ods::InternalArrayDesc*, USHORT, const SLONG*); + ISC_STATUS SDL_info(CheckStatusWrapper*, const UCHAR*, sdl_info*, const SLONG*); + int SDL_walk(CheckStatusWrapper*, const UCHAR*, UCHAR*, Jrd::Ods::InternalArrayDesc*, SLONG*, + SDL_walk_callback, array_slice*); +} // namespace Firebird #endif // JRD_SDL_PROTO_H - diff --git a/src/common/security.cpp b/src/common/security.cpp index e309557c942..673b806e690 100644 --- a/src/common/security.cpp +++ b/src/common/security.cpp @@ -41,10 +41,10 @@ void raise() } // anonymous namespace -namespace Auth { +namespace Firebird::Auth { Get::Get(const Config* firebirdConf) - : GetPlugins(IPluginManager::TYPE_AUTH_USER_MANAGEMENT, firebirdConf) + : GetPlugins(IPluginManager::TYPE_AUTH_USER_MANAGEMENT, firebirdConf) { if (!hasData()) { @@ -53,7 +53,7 @@ Get::Get(const Config* firebirdConf) } Get::Get(const Config* firebirdConf, const char* plugName) - : GetPlugins(IPluginManager::TYPE_AUTH_USER_MANAGEMENT, firebirdConf, plugName) + : GetPlugins(IPluginManager::TYPE_AUTH_USER_MANAGEMENT, firebirdConf, plugName) { if (!hasData()) { @@ -61,7 +61,7 @@ Get::Get(const Config* firebirdConf, const char* plugName) } } -void UserData::clear(Firebird::CheckStatusWrapper*) +void UserData::clear(CheckStatusWrapper*) { op = 0; @@ -101,24 +101,24 @@ int setGsecCode(int code, unsigned int operation) switch(operation) { case ADD_OPER: - return GsecMsg19; + return Gsec::GsecMsg19; case MOD_OPER: - return GsecMsg20; + return Gsec::GsecMsg20; case DEL_OPER: - return GsecMsg23; + return Gsec::GsecMsg23; case OLD_DIS_OPER: case DIS_OPER: - return GsecMsg28; + return Gsec::GsecMsg28; case MAP_DROP_OPER: case MAP_SET_OPER: - return GsecMsg97; + return Gsec::GsecMsg97; } - return GsecMsg17; + return Gsec::GsecMsg17; } -} // namespace Auth +} // namespace Firebird::Auth diff --git a/src/common/security.h b/src/common/security.h index 2851816d2ea..59940549f10 100644 --- a/src/common/security.h +++ b/src/common/security.h @@ -31,10 +31,10 @@ #include "../common/classes/MetaString.h" #include "../common/classes/objects_array.h" -namespace Auth { +namespace Firebird::Auth { class CharField : - public Firebird::AutoIface > + public AutoIface > { public: CharField() @@ -52,7 +52,7 @@ class CharField : return s; } - void setEntered(Firebird::CheckStatusWrapper*, int newValue) + void setEntered(CheckStatusWrapper*, int newValue) { e = newValue; } @@ -71,13 +71,13 @@ class CharField : return value.c_str(); } - void set(Firebird::CheckStatusWrapper* status, const char* newValue) + void set(CheckStatusWrapper* status, const char* newValue) { try { value = newValue ? newValue : ""; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -96,11 +96,11 @@ class CharField : private: int e, s; - Firebird::string value; + string value; }; class IntField : - public Firebird::AutoIface > + public AutoIface > { public: IntField() @@ -118,7 +118,7 @@ class IntField : return s; } - void setEntered(Firebird::CheckStatusWrapper*, int newValue) + void setEntered(CheckStatusWrapper*, int newValue) { e = newValue; } @@ -137,7 +137,7 @@ class IntField : return value; } - void set(Firebird::CheckStatusWrapper*, int newValue) + void set(CheckStatusWrapper*, int newValue) { value = newValue; } @@ -153,10 +153,10 @@ class IntField : int value; }; -typedef Firebird::Array AuthenticationBlock; +typedef Array AuthenticationBlock; class UserData final : - public Firebird::VersionedIface > + public VersionedIface > { public: UserData() @@ -169,52 +169,52 @@ class UserData final : return op; } - Firebird::ICharUserField* userName() + ICharUserField* userName() { return &user; } - Firebird::ICharUserField* password() + ICharUserField* password() { return &pass; } - Firebird::ICharUserField* firstName() + ICharUserField* firstName() { return &first; } - Firebird::ICharUserField* lastName() + ICharUserField* lastName() { return &last; } - Firebird::ICharUserField* middleName() + ICharUserField* middleName() { return &middle; } - Firebird::ICharUserField* comment() + ICharUserField* comment() { return &com; } - Firebird::ICharUserField* attributes() + ICharUserField* attributes() { return &attr; } - Firebird::IIntUserField* admin() + IIntUserField* admin() { return &adm; } - Firebird::IIntUserField* active() + IIntUserField* active() { return &act; } - void clear(Firebird::CheckStatusWrapper* status); + void clear(CheckStatusWrapper* status); unsigned int op; @@ -226,22 +226,22 @@ class UserData final : CharField database, dba, dbaPassword, role; AuthenticationBlock authenticationBlock; - Firebird::MetaString plugin; + MetaString plugin; // deprecated CharField group; IntField u, g; }; -class Get : public Firebird::GetPlugins +class Get : public GetPlugins { public: - explicit Get(const Firebird::Config* firebirdConf); - Get(const Firebird::Config* firebirdConf, const char* plugName); + explicit Get(const Config* firebirdConf); + Get(const Config* firebirdConf, const char* plugName); }; int setGsecCode(int code, unsigned int operation); -} // namespace Auth +} // namespace Firebird::Auth #endif // UTILITIES_SECUR_PROTO_H diff --git a/src/common/sha.cpp b/src/common/sha.cpp index db7a151dbd1..6f6d24f6801 100644 --- a/src/common/sha.cpp +++ b/src/common/sha.cpp @@ -17,7 +17,9 @@ #include "../common/os/guid.h" #include "../common/utils_proto.h" -using namespace Firebird; +namespace Firebird +{ + namespace { @@ -342,7 +344,6 @@ void sha_final(unsigned char digest[SHA_DIGESTSIZE], SHA_INFO *sha_info) noexcep } // anonymous namespace -namespace Firebird { void Sha1::hashBased64(string& hash, const string& data) { @@ -393,4 +394,5 @@ namespace Firebird { } } -} // namespace Firebird + +} // namespace Firebird diff --git a/src/common/sha.h b/src/common/sha.h index 71b7315d25c..05097661965 100644 --- a/src/common/sha.h +++ b/src/common/sha.h @@ -69,7 +69,7 @@ class Sha1 : public GlobalStorage ~Sha1(); // return base64-coded values - static void hashBased64(Firebird::string& hashBase64, const Firebird::string& data); + static void hashBased64(string& hashBase64, const string& data); private: void clear() noexcept; diff --git a/src/common/sha2/sha2.h b/src/common/sha2/sha2.h index 93f0cb61e24..18e03ba2182 100644 --- a/src/common/sha2/sha2.h +++ b/src/common/sha2/sha2.h @@ -92,7 +92,7 @@ templatevoid get_digest(const unsigned char* message, size_t len, uns /* This template class provides a simple one line means of computing a SHA-2 * digest from an arbitrary length message, and encoding the result in BASE64. */ -template void hashBased64(Firebird::string& hash, const Firebird::string& data) +template void hashBased64(string& hash, const string& data) { SHA digest; digest.process(data.length(), data.c_str()); diff --git a/src/common/status.h b/src/common/status.h index 44e1ff5cad9..7c033e1467e 100644 --- a/src/common/status.h +++ b/src/common/status.h @@ -50,7 +50,7 @@ namespace Firebird { } template - explicit LocalStatusWrapper(Firebird::MemoryPool& p, Args&&... args) + explicit LocalStatusWrapper(MemoryPool& p, Args&&... args) : localStatus(p), localStatusVector(&localStatus, std::forward(args)...) { } @@ -84,7 +84,7 @@ namespace Firebird { if (localStatusVector.isDirty()) { - if (localStatus.getState() & Firebird::IStatus::STATE_ERRORS) + if (localStatus.getState() & IStatus::STATE_ERRORS) raise(); } } @@ -101,7 +101,7 @@ namespace Firebird [[noreturn]] void raise() const { - Firebird::status_exception::raise(&localStatus); + status_exception::raise(&localStatus); } bool isEmpty() const @@ -115,7 +115,7 @@ namespace Firebird } private: - Firebird::LocalStatus localStatus; + LocalStatus localStatus; SW localStatusVector; }; diff --git a/src/common/tests/CvtTest.cpp b/src/common/tests/CvtTest.cpp index e0f0a380985..232c7eb8494 100644 --- a/src/common/tests/CvtTest.cpp +++ b/src/common/tests/CvtTest.cpp @@ -8,15 +8,14 @@ #include "../jrd/intl.h" using namespace Firebird; -using namespace Jrd; -using namespace CvtTestUtils; +using namespace Firebird::CvtTestUtils; BOOST_AUTO_TEST_SUITE(CVTSuite) BOOST_AUTO_TEST_SUITE(CVTDatetimeFormat) // Currently we cannot print our error messages because we need master interface for that -static void errFunc(const Firebird::Arg::StatusVector& v) +static void errFunc(const Arg::StatusVector& v) { v.raise(); } @@ -315,7 +314,7 @@ BOOST_AUTO_TEST_SUITE_END() // CVTDatetimeToFormatString BOOST_AUTO_TEST_SUITE(CVTStringToFormatDateTime) static void testCVTStringToFormatDateTime(const string& date, const string& format, - const ISC_TIMESTAMP_TZ& expected, Firebird::EXPECT_DATETIME expectedType, Callbacks& cb) + const ISC_TIMESTAMP_TZ& expected, EXPECT_DATETIME expectedType, Callbacks& cb) { try { diff --git a/src/common/tests/CvtTestUtils.h b/src/common/tests/CvtTestUtils.h index b7917242419..40f0ea056ac 100644 --- a/src/common/tests/CvtTestUtils.h +++ b/src/common/tests/CvtTestUtils.h @@ -6,10 +6,9 @@ #include "../common/TimeZoneUtil.h" #include "../common/TimeZones.h" -using Firebird::NoThrowTimeStamp; -using Firebird::TimeZoneUtil; +namespace Firebird::CvtTestUtils +{ -namespace CvtTestUtils { #define DECOMPOSE_TM_STRUCT(times, fractions, timezone) "Year:" << times.tm_year + 1900 << \ " Month:" << times.tm_mon << \ @@ -102,7 +101,7 @@ static ISC_TIME_TZ createTimeTZ(int hours, int minutes, int seconds, int offsetI } -class MockCallback : public Firebird::Callbacks +class MockCallback : public Callbacks { public: explicit MockCallback(ErrorFunction aErr, std::function mockGetLocalDateFunc) @@ -112,9 +111,9 @@ class MockCallback : public Firebird::Callbacks public: bool transliterate(const dsc* from, dsc* to, CSetId&) override { return true; } CSetId getChid(const dsc* d) override { return CSetId(0); } - Firebird::CharSet* getToCharset(CSetId charset2) override { return nullptr; } - void validateData(Firebird::CharSet* toCharset, SLONG length, const UCHAR* q) override { } - ULONG validateLength(Firebird::CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, + CharSet* getToCharset(CSetId charset2) override { return nullptr; } + void validateData(CharSet* toCharset, SLONG length, const UCHAR* q) override { } + ULONG validateLength(CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, const USHORT size) override { return 0; } SLONG getLocalDate() override @@ -149,6 +148,7 @@ UCHAR getDSCTypeFromDateType() { return dtype_sql_time_tz; } template<> UCHAR getDSCTypeFromDateType() { return dtype_timestamp_tz; } -} // namespace CvtTestUtils + +} // namespace Firebird::CvtTestUtils #endif // CVT_TEST_UTILS_H diff --git a/src/common/tests/StringTest.cpp b/src/common/tests/StringTest.cpp index aa168b1d5f9..63f5bbee144 100644 --- a/src/common/tests/StringTest.cpp +++ b/src/common/tests/StringTest.cpp @@ -98,10 +98,10 @@ BOOST_AUTO_TEST_CASE(FatalRangeTest) BOOST_TEST_FAIL("Range exception is missing"); } - catch(Firebird::fatal_exception& ex) + catch(fatal_exception& ex) { std::string_view what = ex.what(); - BOOST_TEST(what == "Firebird::string - pos out of range"); + BOOST_TEST(what == "string - pos out of range"); } catch(...) { @@ -598,7 +598,7 @@ BOOST_AUTO_TEST_CASE(LowerTest) static constexpr std::string_view EmptyString = ""; static constexpr std::string_view SmallStringValue = "123"; static constexpr std::string_view BigStringValue = "BiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiigString"; -static_assert(BigStringValue.length() > Firebird::string::INLINE_BUFFER_SIZE); +static_assert(BigStringValue.length() > string::INLINE_BUFFER_SIZE); // Utils void checkMovedString(const string& moved) diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 05ffe216b40..e9cefd92e4d 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -26,7 +26,7 @@ #include "firebird.h" #include "../common/classes/alloc.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/unicode_util.h" #include "../common/isc_proto.h" #include "../common/CharSet.h" @@ -52,8 +52,9 @@ # include #endif +namespace Firebird +{ -using namespace Firebird; namespace { #if defined(WIN_NT) @@ -281,9 +282,8 @@ void BaseICU::initialize(ModuleLoader::Module* module) } } -} +} // namespace -namespace Firebird { // encapsulate ICU collations libraries struct UnicodeUtil::ICU : public BaseICU @@ -517,7 +517,7 @@ static void getVersions(const string& configInfo, ObjectsArray& versions charset cs; IntlUtil::initAsciiCharset(&cs); - AutoPtr ascii(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs)); + AutoPtr ascii(CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs)); IntlUtil::SpecificAttributesMap config; IntlUtil::parseSpecificAttributes(ascii, configInfo.length(), @@ -1365,7 +1365,7 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU() Arg::Gds err(isc_icu_library); - if (lastError.getState() & Firebird::IStatus::STATE_ERRORS) + if (lastError.getState() & IStatus::STATE_ERRORS) { err << Arg::StatusVector(lastError.getErrors()) << Arg::Gds(isc_random) << Arg::Str(version); @@ -1392,8 +1392,8 @@ string UnicodeUtil::getDefaultIcuVersion() } -UnicodeUtil::ICU* UnicodeUtil::getCollVersion(const Firebird::string& icuVersion, - const Firebird::string& configInfo, Firebird::string& collVersion) +UnicodeUtil::ICU* UnicodeUtil::getCollVersion(const string& icuVersion, + const string& configInfo, string& collVersion) { ICU* icu = loadICU(icuVersion, configInfo); @@ -1413,7 +1413,7 @@ UnicodeUtil::ICU* UnicodeUtil::getCollVersion(const Firebird::string& icuVersion UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create( texttype* tt, USHORT attributes, - Firebird::IntlUtil::SpecificAttributesMap& specificAttributes, const Firebird::string& configInfo) + IntlUtil::SpecificAttributesMap& specificAttributes, const string& configInfo) { int attributeCount = 0; bool error; @@ -2110,4 +2110,4 @@ void UnicodeUtil::Utf16Collation::normalize(ULONG* strLen, const USHORT** str, b } -} // namespace Firebird +} // namespace Firebird diff --git a/src/common/unicode_util.h b/src/common/unicode_util.h index 99661e8e6b9..0a0462725f9 100644 --- a/src/common/unicode_util.h +++ b/src/common/unicode_util.h @@ -137,7 +137,7 @@ class UnicodeUtil int vMajor, vMinor; }; - static Firebird::string getDefaultIcuVersion(); + static string getDefaultIcuVersion(); class ICUModules; // routines semantically equivalent with intlobj_new.h @@ -166,20 +166,20 @@ class UnicodeUtil static INTL_BOOL utf16WellFormed(ULONG len, const USHORT* str, ULONG* offending_position) noexcept; static INTL_BOOL utf32WellFormed(ULONG len, const ULONG* str, ULONG* offending_position) noexcept; - static void utf8Normalize(Firebird::UCharBuffer& data); + static void utf8Normalize(UCharBuffer& data); static ConversionICU& getConversionICU(); - static ICU* loadICU(const Firebird::string& icuVersion, const Firebird::string& configInfo); + static ICU* loadICU(const string& icuVersion, const string& configInfo); static void getICUVersion(ICU* icu, int& majorVersion, int& minorVersion) noexcept; - static ICU* getCollVersion(const Firebird::string& icuVersion, - const Firebird::string& configInfo, Firebird::string& collVersion); + static ICU* getCollVersion(const string& icuVersion, + const string& configInfo, string& collVersion); class Utf16Collation { public: static Utf16Collation* create(texttype* tt, USHORT attributes, - Firebird::IntlUtil::SpecificAttributesMap& specificAttributes, - const Firebird::string& configInfo); + IntlUtil::SpecificAttributesMap& specificAttributes, + const string& configInfo); Utf16Collation() : contractionsPrefix(*getDefaultMemoryPool()) @@ -200,7 +200,7 @@ class UnicodeUtil class ArrayComparator { public: - static bool greaterThan(const Firebird::Array& i1, const Firebird::Array& i2) + static bool greaterThan(const Array& i1, const Array& i2) { const FB_SIZE_T minCount = std::min(i1.getCount(), i2.getCount()); const int cmp = memcmp(i1.begin(), i2.begin(), minCount * sizeof(T)); @@ -211,35 +211,35 @@ class UnicodeUtil return i1.getCount() > i2.getCount(); } - static bool greaterThan(const Firebird::Array* i1, const Firebird::Array* i2) + static bool greaterThan(const Array* i1, const Array* i2) { return greaterThan(*i1, *i2); } }; - typedef Firebird::SortedObjectsArray< - Firebird::Array, - Firebird::InlineStorage*, 3>, - Firebird::Array, - Firebird::DefaultKeyValue*>, + typedef SortedObjectsArray< + Array, + InlineStorage*, 3>, + Array, + DefaultKeyValue*>, ArrayComparator > SortKeyArray; - typedef Firebird::GenericMap< - Firebird::Pair< - Firebird::Full< - Firebird::Array, // UTF-16 string + typedef GenericMap< + Pair< + Full< + Array, // UTF-16 string SortKeyArray // sort keys > >, ArrayComparator > ContractionsPrefixMap; - static ICU* loadICU(const Firebird::string& icuVersion, const Firebird::string& collVersion, - const Firebird::string& locale, const Firebird::string& configInfo); + static ICU* loadICU(const string& icuVersion, const string& collVersion, + const string& locale, const string& configInfo); void normalize(ULONG* strLen, const USHORT** str, bool forNumericSort, - Firebird::HalfStaticArray& buffer) const; + HalfStaticArray& buffer) const; ICU* icu; texttype* tt; diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 749be6c197e..21e26f27f3f 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -47,7 +47,7 @@ #include "../common/classes/locks.h" #include "../common/classes/init.h" #include "../common/isc_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "firebird/impl/inf_pub.h" #include "../jrd/align.h" #include "../common/os/path_utils.h" @@ -85,8 +85,7 @@ #endif -namespace fb_utils -{ +namespace Firebird::fb_utils { bool implicit_name(const char* name, const char* prefix, int prefix_len) noexcept; @@ -278,7 +277,7 @@ int name_length_limit(const TEXT* const name, size_t bufsize) noexcept //*************** // Goes to read directly the environment variables from the operating system on Windows // and provides a stub for UNIX. -bool readenv(const char* env_name, Firebird::string& env_value) +bool readenv(const char* env_name, string& env_value) { #ifdef WIN_NT const DWORD rc = GetEnvironmentVariable(env_name, NULL, 0); @@ -304,9 +303,9 @@ bool readenv(const char* env_name, Firebird::string& env_value) } -bool readenv(const char* env_name, Firebird::PathName& env_value) +bool readenv(const char* env_name, PathName& env_value) { - Firebird::string result; + string result; bool rc = readenv(env_name, result); env_value.assign(result.c_str(), result.length()); return rc; @@ -477,7 +476,7 @@ class PrivateNamespace { init(); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { iscLogException("Error creating private namespace", ex); } @@ -522,7 +521,7 @@ class PrivateNamespace [[noreturn]] void raiseError(const char* apiRoutine) { - (Firebird::Arg::Gds(isc_sys_request) << apiRoutine << Firebird::Arg::OsError()).raise(); + (Arg::Gds(isc_sys_request) << apiRoutine << Arg::OsError()).raise(); } void init() @@ -558,7 +557,7 @@ class PrivateNamespace raiseError("ConvertStringSecurityDescriptorToSecurityDescriptor"); } - Firebird::Cleanup cleanSecDesc( [&sa] { + Cleanup cleanSecDesc( [&sa] { LocalFree(sa.lpSecurityDescriptor); }); @@ -566,7 +565,7 @@ class PrivateNamespace if (hBoundaryDesc == NULL) raiseError("CreateBoundaryDescriptor"); - Firebird::Cleanup cleanBndDesc( [&hBoundaryDesc] { + Cleanup cleanBndDesc( [&hBoundaryDesc] { DeleteBoundaryDescriptor(hBoundaryDesc); }); @@ -598,7 +597,7 @@ class PrivateNamespace if (err != ERROR_DUP_NAME) raiseError("OpenPrivateNamespace"); - Firebird::string name(sPrivateNameSpace); + string name(sPrivateNameSpace); name.append("\\test"); m_hTestEvent = CreateEvent(ISC_get_security_desc(), TRUE, TRUE, name.c_str()); @@ -615,7 +614,7 @@ class PrivateNamespace HANDLE m_hTestEvent; }; -static Firebird::InitInstance privateNamespace; +static InitInstance privateNamespace; bool private_kernel_object_name(char* name, size_t bufsize) @@ -638,7 +637,7 @@ bool privateNameSpaceReady() // ******************************* // Return the name of the current process -Firebird::PathName get_process_name() +PathName get_process_name() { char buffer[MAXPATHLEN]; @@ -662,11 +661,11 @@ Firebird::PathName get_process_name() SLONG genUniqueId() noexcept { - static Firebird::AtomicCounter cnt; + static AtomicCounter cnt; return ++cnt; } -void getCwd(Firebird::PathName& pn) +void getCwd(PathName& pn) { char* buffer = pn.getBuffer(MAXPATHLEN); #if defined(WIN_NT) @@ -683,7 +682,7 @@ namespace { class InputFile { public: - explicit InputFile(const Firebird::PathName& name) + explicit InputFile(const PathName& name) : flagEcho(false) { if (name == "stdin") { @@ -750,7 +749,7 @@ namespace { } // namespace // fetch password from file -FetchPassResult fetchPassword(const Firebird::PathName& name, const char*& password) +FetchPassResult fetchPassword(const PathName& name, const char*& password) { InputFile file(name); if (!file) @@ -758,7 +757,7 @@ FetchPassResult fetchPassword(const Firebird::PathName& name, const char*& passw return FETCH_PASS_FILE_OPEN_ERROR; } - Firebird::string pwd; + string pwd; if (! pwd.LoadFromFile(file.getStdioFile())) { return ferror(file.getStdioFile()) ? FETCH_PASS_FILE_READ_ERROR : FETCH_PASS_FILE_EMPTY; @@ -866,7 +865,7 @@ void get_process_times(SINT64 &userTime, SINT64 &sysTime) } -void exactNumericToStr(SINT64 value, int scale, Firebird::string& target, bool append) +void exactNumericToStr(SINT64 value, int scale, string& target, bool append) { if (value == 0) { @@ -951,7 +950,7 @@ bool bootBuild() if (state == FB_BOOT_UNKNOWN) { // not care much about protecting state with mutex - each thread will assign it same value - Firebird::string dummy; + string dummy; state = readenv("FIREBIRD_BOOT_BUILD", dummy) ? FB_BOOT_SET : FB_BOOT_NORMAL; } @@ -959,22 +958,22 @@ bool bootBuild() } // Build full file name in specified directory -Firebird::PathName getPrefix(unsigned int prefType, const char* name) +PathName getPrefix(unsigned int prefType, const char* name) { - Firebird::PathName s; + PathName s; #ifdef ANDROID const bool useInstallDir = - prefType == Firebird::IConfigManager::DIR_BIN || - prefType == Firebird::IConfigManager::DIR_SBIN || - prefType == Firebird::IConfigManager::DIR_LIB || - prefType == Firebird::IConfigManager::DIR_GUARD || - prefType == Firebird::IConfigManager::DIR_PLUGINS; + prefType == IConfigManager::DIR_BIN || + prefType == IConfigManager::DIR_SBIN || + prefType == IConfigManager::DIR_LIB || + prefType == IConfigManager::DIR_GUARD || + prefType == IConfigManager::DIR_PLUGINS; if (useInstallDir) s = name; else - PathUtils::concatPath(s, Firebird::Config::getRootDirectory(), name); + PathUtils::concatPath(s, Config::getRootDirectory(), name); return s; #else @@ -986,14 +985,14 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) FB_GUARDDIR, FB_PLUGDIR, FB_TZDATADIR }; - fb_assert(FB_NELEM(configDir) == Firebird::IConfigManager::DIR_COUNT); - fb_assert(prefType < Firebird::IConfigManager::DIR_COUNT); + fb_assert(FB_NELEM(configDir) == IConfigManager::DIR_COUNT); + fb_assert(prefType < IConfigManager::DIR_COUNT); if (! bootBuild()) { - if (prefType != Firebird::IConfigManager::DIR_CONF && - prefType != Firebird::IConfigManager::DIR_MSG && - prefType != Firebird::IConfigManager::DIR_TZDATA && + if (prefType != IConfigManager::DIR_CONF && + prefType != IConfigManager::DIR_MSG && + prefType != IConfigManager::DIR_TZDATA && configDir[prefType][0]) { // Value is set explicitly and is not environment overridable @@ -1011,8 +1010,8 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) switch (prefType) { - case Firebird::IConfigManager::DIR_BIN: - case Firebird::IConfigManager::DIR_SBIN: + case IConfigManager::DIR_BIN: + case IConfigManager::DIR_SBIN: #ifdef WIN_NT s = ""; #else @@ -1020,14 +1019,14 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) #endif break; - case Firebird::IConfigManager::DIR_CONF: - case Firebird::IConfigManager::DIR_LOG: - case Firebird::IConfigManager::DIR_GUARD: - case Firebird::IConfigManager::DIR_SECDB: + case IConfigManager::DIR_CONF: + case IConfigManager::DIR_LOG: + case IConfigManager::DIR_GUARD: + case IConfigManager::DIR_SECDB: s = ""; break; - case Firebird::IConfigManager::DIR_LIB: + case IConfigManager::DIR_LIB: #ifdef WIN_NT s = ""; #else @@ -1035,47 +1034,47 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) #endif break; - case Firebird::IConfigManager::DIR_PLUGINS: + case IConfigManager::DIR_PLUGINS: s = "plugins"; break; - case Firebird::IConfigManager::DIR_TZDATA: - PathUtils::concatPath(s, Firebird::TimeZoneUtil::getTzDataPath(), name); + case IConfigManager::DIR_TZDATA: + PathUtils::concatPath(s, TimeZoneUtil::getTzDataPath(), name); return s; - case Firebird::IConfigManager::DIR_INC: + case IConfigManager::DIR_INC: s = "include"; break; - case Firebird::IConfigManager::DIR_DOC: + case IConfigManager::DIR_DOC: s = "doc"; break; - case Firebird::IConfigManager::DIR_UDF: + case IConfigManager::DIR_UDF: s = "UDF"; break; - case Firebird::IConfigManager::DIR_SAMPLE: + case IConfigManager::DIR_SAMPLE: s = "examples"; break; - case Firebird::IConfigManager::DIR_SAMPLEDB: + case IConfigManager::DIR_SAMPLEDB: s = "examples/empbuild"; break; - case Firebird::IConfigManager::DIR_HELP: + case IConfigManager::DIR_HELP: s = "help"; break; - case Firebird::IConfigManager::DIR_INTL: + case IConfigManager::DIR_INTL: s = "intl"; break; - case Firebird::IConfigManager::DIR_MISC: + case IConfigManager::DIR_MISC: s = "misc"; break; - case Firebird::IConfigManager::DIR_MSG: + case IConfigManager::DIR_MSG: gds__prefix_msg(tmp, name); return tmp; @@ -1120,14 +1119,14 @@ unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space, } unsigned int mergeStatus(ISC_STATUS* const dest, unsigned int space, - const Firebird::IStatus* from) noexcept + const IStatus* from) noexcept { const ISC_STATUS* s; unsigned int copied = 0; const int state = from->getState(); ISC_STATUS* to = dest; - if (state & Firebird::IStatus::STATE_ERRORS) + if (state & IStatus::STATE_ERRORS) { s = from->getErrors(); copied = copyStatus(to, space, s, statusLength(s)); @@ -1136,7 +1135,7 @@ unsigned int mergeStatus(ISC_STATUS* const dest, unsigned int space, space -= copied; } - if (state & Firebird::IStatus::STATE_WARNINGS) + if (state & IStatus::STATE_WARNINGS) { if (!copied) { @@ -1155,18 +1154,18 @@ unsigned int mergeStatus(ISC_STATUS* const dest, unsigned int space, return copied; } -void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::IStatus* from) noexcept +void copyStatus(CheckStatusWrapper* to, const IStatus* from) noexcept { to->init(); const unsigned flags = from->getState(); - if (flags & Firebird::IStatus::STATE_ERRORS) + if (flags & IStatus::STATE_ERRORS) to->setErrors(from->getErrors()); - if (flags & Firebird::IStatus::STATE_WARNINGS) + if (flags & IStatus::STATE_WARNINGS) to->setWarnings(from->getWarnings()); } -void setIStatus(Firebird::IStatus* to, const ISC_STATUS* from) noexcept +void setIStatus(IStatus* to, const ISC_STATUS* from) noexcept { try { @@ -1182,7 +1181,7 @@ void setIStatus(Firebird::IStatus* to, const ISC_STATUS* from) noexcept } to->setErrors2(w - from, from); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(to); } @@ -1304,7 +1303,7 @@ miss: pos += nextArg(in[pos]); // moves DB path information (from limbo transaction) to another buffer void getDbPathInfo(unsigned int& itemsLength, const unsigned char*& items, unsigned int& bufferLength, unsigned char*& buffer, - Firebird::Array& newItemsBuffer, const Firebird::PathName& dbpath) + Array& newItemsBuffer, const PathName& dbpath) { if (itemsLength && items) { @@ -1341,7 +1340,7 @@ bool isRunningCheck(const UCHAR* items, unsigned int length) { if (!items) { - Firebird::Arg::Gds(isc_null_block).raise(); + Arg::Gds(isc_null_block).raise(); } switch (*items++) @@ -1363,7 +1362,7 @@ bool isRunningCheck(const UCHAR* items, unsigned int length) case isc_info_svc_stdin: if (state == S_INF) { - Firebird::Arg::Gds(isc_mixed_info).raise(); + Arg::Gds(isc_mixed_info).raise(); } state = S_RUN; break; @@ -1383,13 +1382,13 @@ bool isRunningCheck(const UCHAR* items, unsigned int length) case isc_info_svc_get_licensed_users: if (state == S_RUN) { - Firebird::Arg::Gds(isc_mixed_info).raise(); + Arg::Gds(isc_mixed_info).raise(); } state = S_INF; break; default: - (Firebird::Arg::Gds(isc_unknown_info) << Firebird::Arg::Num(ULONG(items[-1]))).raise(); + (Arg::Gds(isc_unknown_info) << Arg::Num(ULONG(items[-1]))).raise(); break; } } @@ -1403,7 +1402,7 @@ static inline char conv_bin2ascii(ULONG l) noexcept } // converts bytes to BASE64 representation -void base64(Firebird::string& b64, const Firebird::UCharBuffer& bin) +void base64(string& b64, const UCharBuffer& bin) { b64.erase(); const unsigned char* f = bin.begin(); @@ -1430,10 +1429,10 @@ void base64(Firebird::string& b64, const Firebird::UCharBuffer& bin) } } -void random64(Firebird::string& randomValue, FB_SIZE_T length) +void random64(string& randomValue, FB_SIZE_T length) { - Firebird::UCharBuffer binRand; - Firebird::GenerateRandomBytes(binRand.getBuffer(length), length); + UCharBuffer binRand; + GenerateRandomBytes(binRand.getBuffer(length), length); base64(randomValue, binRand); randomValue.resize(length, '$'); } @@ -1441,7 +1440,7 @@ void random64(Firebird::string& randomValue, FB_SIZE_T length) [[noreturn]] void logAndDie(const char* text) { gds__log(text); - Firebird::Syslog::Record(Firebird::Syslog::Error, text); + Syslog::Record(Syslog::Error, text); abort(); } @@ -1509,7 +1508,7 @@ unsigned sqlTypeToDsc(unsigned runOffset, unsigned sqlType, unsigned sqlLength, if (dscType == dtype_unknown) { fb_assert(false); - Firebird::Arg::Gds(isc_dsql_datatype_err).raise(); + Arg::Gds(isc_dsql_datatype_err).raise(); } if (dtype) @@ -1564,7 +1563,7 @@ inline bool sqlSymbolChar(char c, bool first) return (isdigit(c) && !first) || isalpha(c) || c == '_' || c == '$'; } -const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf) +const char* dpbItemUpper(const char* s, FB_SIZE_T l, string& buf) { if (l && (s[0] == '"' || s[0] == '\'')) { @@ -1587,7 +1586,7 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf) if (s[i] != end_quote) { buf.assign(&s[i], l - i); - (Firebird::Arg::Gds(isc_quoted_str_bad) << buf).raise(); + (Arg::Gds(isc_quoted_str_bad) << buf).raise(); } // skipped the escape quote, continue processing @@ -1599,7 +1598,7 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf) } buf.assign(1, s[0]); - (Firebird::Arg::Gds(isc_quoted_str_miss) << buf).raise(); + (Arg::Gds(isc_quoted_str_miss) << buf).raise(); } // non-quoted string - try to uppercase @@ -1616,13 +1615,13 @@ const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf) bool isBpbSegmented(unsigned parLength, const unsigned char* par) { if (parLength && !par) - Firebird::Arg::Gds(isc_null_block).raise(); + Arg::Gds(isc_null_block).raise(); - Firebird::ClumpletReader bpb(Firebird::ClumpletReader::Tagged, par, parLength); + ClumpletReader bpb(ClumpletReader::Tagged, par, parLength); if (bpb.getBufferTag() != isc_bpb_version1) { - (Firebird::Arg::Gds(isc_bpb_version) << Firebird::Arg::Num(bpb.getBufferTag()) << - Firebird::Arg::Num(isc_bpb_version1)).raise(); + (Arg::Gds(isc_bpb_version) << Arg::Num(bpb.getBufferTag()) << + Arg::Num(isc_bpb_version1)).raise(); } if (!bpb.find(isc_bpb_type)) diff --git a/src/common/utils_proto.h b/src/common/utils_proto.h index 06fbffc15a5..31fc93cbd44 100644 --- a/src/common/utils_proto.h +++ b/src/common/utils_proto.h @@ -39,11 +39,10 @@ #include "firebird/Interface.h" #include "memory_routines.h" -namespace fb_utils -{ +namespace Firebird::fb_utils { char* copy_terminate(char* dest, const char* src, size_t bufsize) noexcept; char* exact_name(char* const name) noexcept; - inline void exact_name(Firebird::string& str) + inline void exact_name(string& str) { str.rtrim(); } @@ -53,8 +52,8 @@ namespace fb_utils bool implicit_pk(const char* pk_name) noexcept; int name_length(const TEXT* const name) noexcept; int name_length_limit(const TEXT* const name, size_t bufsize) noexcept; - bool readenv(const char* env_name, Firebird::string& env_value); - bool readenv(const char* env_name, Firebird::PathName& env_value); + bool readenv(const char* env_name, string& env_value); + bool readenv(const char* env_name, PathName& env_value); bool setenv(const char* name, const char* value, bool overwrite); int snprintf(char* buffer, size_t count, const char* format...) noexcept; char* cleanup_passwd(char* arg); @@ -135,9 +134,9 @@ namespace fb_utils return n1 == n2 ? 0 : n1 < n2 ? 1 : -1; } - Firebird::PathName get_process_name(); + PathName get_process_name(); SLONG genUniqueId() noexcept; - void getCwd(Firebird::PathName& pn); + void getCwd(PathName& pn); void inline initStatusTo(ISC_STATUS* status, ISC_STATUS to) noexcept { @@ -161,16 +160,16 @@ namespace fb_utils initStatusTo(status, isc_exception_sigill); // Any better ideas? New error code? } - void inline init_status(Firebird::CheckStatusWrapper* status) + void inline init_status(CheckStatusWrapper* status) { status->init(); } unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space, const ISC_STATUS* const from, const unsigned int count) noexcept; - void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::IStatus* from) noexcept; - unsigned int mergeStatus(ISC_STATUS* const to, unsigned int space, const Firebird::IStatus* from) noexcept; - void setIStatus(Firebird::IStatus* to, const ISC_STATUS* from) noexcept; + void copyStatus(CheckStatusWrapper* to, const IStatus* from) noexcept; + unsigned int mergeStatus(ISC_STATUS* const to, unsigned int space, const IStatus* from) noexcept; + void setIStatus(IStatus* to, const ISC_STATUS* from) noexcept; unsigned int statusLength(const ISC_STATUS* const status) noexcept; unsigned int subStatus(const ISC_STATUS* in, unsigned int cin, const ISC_STATUS* sub, unsigned int csub) noexcept; @@ -205,7 +204,7 @@ namespace fb_utils FETCH_PASS_FILE_READ_ERROR, FETCH_PASS_FILE_EMPTY }; - FetchPassResult fetchPassword(const Firebird::PathName& name, const char*& password); + FetchPassResult fetchPassword(const PathName& name, const char*& password); // Returns current value of performance counter SINT64 query_performance_counter(); @@ -215,27 +214,27 @@ namespace fb_utils void get_process_times(SINT64 &userTime, SINT64 &sysTime); - void exactNumericToStr(SINT64 value, int scale, Firebird::string& target, bool append = false); + void exactNumericToStr(SINT64 value, int scale, string& target, bool append = false); // Returns true if called from firebird build process (appr. environment is set) bool bootBuild(); // Add appropriate file prefix. - Firebird::PathName getPrefix(unsigned int prefType, const char* name); + PathName getPrefix(unsigned int prefType, const char* name); // moves DB path information (from limbo transaction) to another buffer void getDbPathInfo(unsigned int& itemsLength, const unsigned char*& items, unsigned int& bufferLength, unsigned char*& buffer, - Firebird::Array& newItemsBuffer, const Firebird::PathName& dbpath); + Array& newItemsBuffer, const PathName& dbpath); // returns true if passed info items work with running svc thread bool isRunningCheck(const UCHAR* items, unsigned int length); // converts bytes to BASE64 representation - void base64(Firebird::string& b64, const Firebird::UCharBuffer& bin); + void base64(string& b64, const UCharBuffer& bin); // generate random string in BASE64 representation - void random64(Firebird::string& randomValue, FB_SIZE_T length); + void random64(string& randomValue, FB_SIZE_T length); [[noreturn]] void logAndDie(const char* text); @@ -260,13 +259,13 @@ namespace fb_utils } // Uppercase/strip string according to login rules - const char* dpbItemUpper(const char* s, FB_SIZE_T l, Firebird::string& buf); + const char* dpbItemUpper(const char* s, FB_SIZE_T l, string& buf); // Uppercase/strip string according to login rules template void dpbItemUpper(STR& name) { - Firebird::string buf; + string buf; const char* up = dpbItemUpper(name.c_str(), name.length(), buf); if (up) name = up; diff --git a/src/common/xdr.cpp b/src/common/xdr.cpp index 73eb6a7eba0..227c174ae30 100644 --- a/src/common/xdr.cpp +++ b/src/common/xdr.cpp @@ -33,6 +33,10 @@ #include "../common/DecFloat.h" #include "../common/Int128.h" +namespace Firebird +{ + + typedef struct xdr_t xdr_t; inline UCHAR* XDR_ALLOC(ULONG size) @@ -263,20 +267,20 @@ bool_t xdr_datum( xdr_t* xdrs, const dsc* desc, UCHAR* buffer) break; case dtype_dec64: - fb_assert(desc->dsc_length >= sizeof(Firebird::Decimal64)); - if (!xdr_dec64(xdrs, reinterpret_cast(p))) + fb_assert(desc->dsc_length >= sizeof(Decimal64)); + if (!xdr_dec64(xdrs, reinterpret_cast(p))) return FALSE; break; case dtype_dec128: - fb_assert(desc->dsc_length >= sizeof(Firebird::Decimal128)); - if (!xdr_dec128(xdrs, reinterpret_cast(p))) + fb_assert(desc->dsc_length >= sizeof(Decimal128)); + if (!xdr_dec128(xdrs, reinterpret_cast(p))) return FALSE; break; case dtype_int128: - fb_assert(desc->dsc_length >= sizeof(Firebird::Int128)); - if (!xdr_int128(xdrs, reinterpret_cast(p))) + fb_assert(desc->dsc_length >= sizeof(Int128)); + if (!xdr_int128(xdrs, reinterpret_cast(p))) return FALSE; break; @@ -419,20 +423,20 @@ static bool_t xdr_decfloat_hyper(xdr_t* xdrs, void* dec) } -bool_t xdr_dec64(xdr_t* xdrs, Firebird::Decimal64* ip) +bool_t xdr_dec64(xdr_t* xdrs, Decimal64* ip) { return xdr_decfloat_hyper(xdrs, ip->getBytes()); } -bool_t xdr_dec128(xdr_t* xdrs, Firebird::Decimal128* ip) +bool_t xdr_dec128(xdr_t* xdrs, Decimal128* ip) { UCHAR* bytes = ip->getBytes(); return xdr_decfloat_hyper(xdrs, &bytes[8]) && xdr_decfloat_hyper(xdrs, &bytes[0]); } -bool_t xdr_int128(xdr_t* xdrs, Firebird::Int128* ip) +bool_t xdr_int128(xdr_t* xdrs, Int128* ip) { UCHAR* bytes = ip->getBytes(); @@ -962,3 +966,5 @@ bool_t xdr_t::x_putbytes(const SCHAR* buff, unsigned bytecount) xdr_t::~xdr_t() { } + +} // namespace Firebird diff --git a/src/common/xdr.h b/src/common/xdr.h index 670a0ad973a..f8a7e4850bc 100644 --- a/src/common/xdr.h +++ b/src/common/xdr.h @@ -44,6 +44,10 @@ typedef char* caddr_t; #include #endif +namespace Firebird +{ + + typedef int XDR_INT; typedef int bool_t; @@ -68,4 +72,7 @@ struct xdr_t int create(SCHAR* addr, unsigned len, xdr_op op) noexcept; }; + +} // namespace Firebird + #endif // COMMON_XDR_H diff --git a/src/common/xdr_proto.h b/src/common/xdr_proto.h index 9a31846042e..c92c62c66ef 100644 --- a/src/common/xdr_proto.h +++ b/src/common/xdr_proto.h @@ -27,11 +27,15 @@ #include "../common/dsc.h" #include "../common/xdr.h" +namespace Firebird +{ + + bool_t xdr_datum(xdr_t*, const dsc*, UCHAR*); bool_t xdr_double(xdr_t*, double*); -bool_t xdr_dec64(xdr_t*, Firebird::Decimal64*); -bool_t xdr_dec128(xdr_t*, Firebird::Decimal128*); -bool_t xdr_int128(xdr_t*, Firebird::Int128*); +bool_t xdr_dec64(xdr_t*, Decimal64*); +bool_t xdr_dec128(xdr_t*, Decimal128*); +bool_t xdr_int128(xdr_t*, Int128*); bool_t xdr_enum(xdr_t*, xdr_op*); bool_t xdr_float(xdr_t*, float*); bool_t xdr_int(xdr_t*, int*); @@ -47,4 +51,7 @@ bool_t xdr_wrapstring(xdr_t*, SCHAR**); bool_t xdr_hyper(xdr_t*, void*); SLONG xdr_peek_long(const xdr_t*, const void* data, size_t size); + +} // namespace Firebird + #endif // REMOTE_XDR_PROTO_H diff --git a/src/dsql/AggNodes.cpp b/src/dsql/AggNodes.cpp index 403cf592ebb..f61b5d258b0 100644 --- a/src/dsql/AggNodes.cpp +++ b/src/dsql/AggNodes.cpp @@ -42,10 +42,8 @@ #include "../jrd/DataTypeUtil.h" #include -using namespace Firebird; -using namespace Jrd; - -namespace Jrd { +namespace Firebird::Jrd +{ static RegisterNode regAggNode({blr_agg_function}); @@ -1646,7 +1644,7 @@ void BinAggNode::aggInit(thread_db* tdbb, Request* request) const impure_value_ex* impure = request->getImpure(impureOffset); if (nodFlags & FLAG_INT128) { - Firebird::Int128 i128; + Int128 i128; i128.set(initValue, 0); impure->make_decimal_fixed(i128, 0); } @@ -2597,4 +2595,4 @@ AggNode* RegrCountAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/ } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/AggNodes.h b/src/dsql/AggNodes.h index b9a186b698e..6cdfdf108a9 100644 --- a/src/dsql/AggNodes.h +++ b/src/dsql/AggNodes.h @@ -27,7 +27,7 @@ #include "../dsql/Nodes.h" #include "../dsql/NodePrinter.h" -namespace Jrd { +namespace Firebird::Jrd { class AnyValueAggNode final : public AggNode @@ -44,7 +44,7 @@ class AnyValueAggNode final : public AggNode void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -74,7 +74,7 @@ class AvgAggNode final : public AggNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_AGG_CALLS; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -113,7 +113,7 @@ class ListAggNode final : public AggNode bool dsqlMatch(DsqlCompilerScratch* dsqlScratch, const ExprNode* other, bool ignoreMapCast) const override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; @@ -146,7 +146,7 @@ class CountAggNode final : public AggNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_AGG_CALLS; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; @@ -177,7 +177,7 @@ class SumAggNode final : public AggNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_AGG_CALLS; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -208,7 +208,7 @@ class MaxMinAggNode final : public AggNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_AGG_CALLS; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -244,7 +244,7 @@ class BinAggNode final : public AggNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_AGG_CALLS; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -279,7 +279,7 @@ class StdDevAggNode final : public AggNode } dbl; struct { - Firebird::Decimal128 x, x2; + Decimal128 x, x2; } dec; }; @@ -292,7 +292,7 @@ class StdDevAggNode final : public AggNode void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -330,7 +330,7 @@ class CorrAggNode final : public AggNode } dbl; struct { - Firebird::Decimal128 x, x2, y, y2, xy; + Decimal128 x, x2, y, y2, xy; } dec; }; @@ -350,7 +350,7 @@ class CorrAggNode final : public AggNode holder.add(arg2); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -395,7 +395,7 @@ class RegrAggNode final : public AggNode } dbl; struct { - Firebird::Decimal128 x, x2, y, y2, xy; + Decimal128 x, x2, y, y2, xy; } dec; }; @@ -415,7 +415,7 @@ class RegrAggNode final : public AggNode holder.add(arg2); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -456,7 +456,7 @@ class RegrCountAggNode final : public AggNode holder.add(arg2); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; diff --git a/src/dsql/BlrDebugWriter.cpp b/src/dsql/BlrDebugWriter.cpp index a6b43aeaf0e..24b81cd8d80 100644 --- a/src/dsql/BlrDebugWriter.cpp +++ b/src/dsql/BlrDebugWriter.cpp @@ -32,9 +32,9 @@ #include "../jrd/DebugInterface.h" #include "../dsql/errd_proto.h" -using namespace Firebird; +namespace Firebird::Jrd +{ -namespace Jrd { void BlrDebugWriter::raiseError(const Arg::StatusVector& vector) { @@ -188,4 +188,5 @@ void BlrDebugWriter::putBlrOffset() putValue(offset); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/dsql/BlrDebugWriter.h b/src/dsql/BlrDebugWriter.h index 6569a65b928..924cbac5348 100644 --- a/src/dsql/BlrDebugWriter.h +++ b/src/dsql/BlrDebugWriter.h @@ -24,20 +24,20 @@ #include "../common/classes/BlrWriter.h" -namespace Jrd { +namespace Firebird::Jrd { class DeclareSubFuncNode; class DeclareSubProcNode; // BLR writer with debug info support. -class BlrDebugWriter : public Firebird::BlrWriter +class BlrDebugWriter : public BlrWriter { public: - typedef Firebird::HalfStaticArray DebugData; + typedef HalfStaticArray DebugData; explicit BlrDebugWriter(MemoryPool& p) - : Firebird::BlrWriter(p), + : BlrWriter(p), debugData(p) { } @@ -54,7 +54,7 @@ class BlrDebugWriter : public Firebird::BlrWriter DebugData& getDebugData() { return debugData; } - virtual void raiseError(const Firebird::Arg::StatusVector& vector); + virtual void raiseError(const Arg::StatusVector& vector); private: void putValue(ULONG val); @@ -64,6 +64,6 @@ class BlrDebugWriter : public Firebird::BlrWriter }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_BLR_DEBUG_WRITER_H diff --git a/src/dsql/BoolNodes.cpp b/src/dsql/BoolNodes.cpp index 29f8a8eb78d..56bfc74b18f 100644 --- a/src/dsql/BoolNodes.cpp +++ b/src/dsql/BoolNodes.cpp @@ -44,8 +44,9 @@ #include "../dsql/pass1_proto.h" #include "../dsql/DSqlDataTypeUtil.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { @@ -2213,3 +2214,6 @@ BoolExprNode* RseBoolNode::convertNeqAllToNotAny(thread_db* tdbb, CompilerScratc SubExprNodeCopier copier(csb->csb_pool, csb); return copier.copy(tdbb, static_cast(newNode)); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/BoolNodes.h b/src/dsql/BoolNodes.h index bdf0301f654..9f6bf279b5f 100644 --- a/src/dsql/BoolNodes.h +++ b/src/dsql/BoolNodes.h @@ -26,7 +26,7 @@ #include "firebird/impl/blr.h" #include "../dsql/Nodes.h" -namespace Jrd { +namespace Firebird::Jrd { class SubQuery; @@ -47,7 +47,7 @@ class BinaryBoolNode final : public TypedNode process) override; - Firebird::TriState execute(thread_db* tdbb, Request* request) const override; + TriState execute(thread_db* tdbb, Request* request) const override; private: - Firebird::TriState stringBoolean(thread_db* tdbb, Request* request, dsc* desc1, dsc* desc2, + TriState stringBoolean(thread_db* tdbb, Request* request, dsc* desc1, dsc* desc2, bool computedInvariant) const; bool sleuth(thread_db* tdbb, Request* request, const dsc* desc1, const dsc* desc2) const; @@ -159,7 +159,7 @@ class InListBoolNode final : public TypedNode process) override; - Firebird::TriState execute(thread_db* tdbb, Request* request) const override; + TriState execute(thread_db* tdbb, Request* request) const override; private: BoolExprNode* decompose(CompilerScratch* csb); @@ -211,7 +211,7 @@ class MissingBoolNode final : public TypedNode process) override; - Firebird::TriState execute(thread_db* tdbb, Request* request) const override; + TriState execute(thread_db* tdbb, Request* request) const override; public: bool dsqlUnknown; @@ -249,13 +249,13 @@ class NotBoolNode final : public TypedNode process) override; - Firebird::TriState execute(thread_db* tdbb, Request* request) const override; + TriState execute(thread_db* tdbb, Request* request) const override; private: BoolExprNode* convertNeqAllToNotAny(thread_db* tdbb, CompilerScratch* csb); diff --git a/src/dsql/DSqlDataTypeUtil.cpp b/src/dsql/DSqlDataTypeUtil.cpp index 8d87a1dde5a..394af6d62aa 100644 --- a/src/dsql/DSqlDataTypeUtil.cpp +++ b/src/dsql/DSqlDataTypeUtil.cpp @@ -27,12 +27,18 @@ #include "../dsql/DsqlCompilerScratch.h" #include "../dsql/metd_proto.h" -UCHAR Jrd::DSqlDataTypeUtil::maxBytesPerChar(CSetId charSet) +namespace Firebird::Jrd { + + +UCHAR DSqlDataTypeUtil::maxBytesPerChar(CSetId charSet) { return METD_get_charset_bpc(dsqlScratch->getTransaction(), charSet); } -USHORT Jrd::DSqlDataTypeUtil::getDialect() const +USHORT DSqlDataTypeUtil::getDialect() const { return dsqlScratch->clientDialect; } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DSqlDataTypeUtil.h b/src/dsql/DSqlDataTypeUtil.h index cd8a4abdaf5..58d030eac81 100644 --- a/src/dsql/DSqlDataTypeUtil.h +++ b/src/dsql/DSqlDataTypeUtil.h @@ -27,7 +27,7 @@ #include "../jrd/DataTypeUtil.h" -namespace Jrd { +namespace Firebird::Jrd { class DsqlCompilerScratch; diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 02e4550a85c..c67f9461ee8 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -31,7 +31,7 @@ #include "../jrd/intl.h" #include "../jrd/jrd.h" #include "../common/msg_encode.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/ods.h" #include "../jrd/tra.h" #include "../jrd/met.h" @@ -81,15 +81,17 @@ #include "../jrd/GarbageCollector.h" #include "../jrd/ProtectRelations.h" -namespace Jrd { + +DATABASE DB = STATIC "ODS.RDB"; + + +namespace Firebird::Jrd { // Define range of user relation ids inline constexpr MetaId MIN_RELATION_ID = USER_DEF_REL_INIT_ID; inline constexpr MetaId MAX_RELATION_ID = 32767; -using namespace Firebird; - static const UCHAR nonnull_validation_blr[] = { blr_version5, @@ -144,8 +146,6 @@ static ISC_STATUS getErrorCodeByObjectType(int obj_type); static constexpr const char* CHECK_CONSTRAINT_EXCEPTION = "check_constraint"; -DATABASE DB = STATIC "ODS.RDB"; - //---------------------- @@ -6106,7 +6106,7 @@ void CreateAlterSequenceNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsql } -void CreateAlterSequenceNode::putErrorPrefix(Firebird::Arg::StatusVector& statusVector) +void CreateAlterSequenceNode::putErrorPrefix(Arg::StatusVector& statusVector) { // Possibilities I see in parse.y //CREATE SEQ -> !legacy, create, !alter @@ -6128,7 +6128,7 @@ void CreateAlterSequenceNode::putErrorPrefix(Firebird::Arg::StatusVector& status else rc = isc_dsql_create_sequence_failed; } - statusVector << Firebird::Arg::Gds(rc) << name.toQuotedString(); + statusVector << Arg::Gds(rc) << name.toQuotedString(); } void CreateAlterSequenceNode::executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, @@ -8492,7 +8492,7 @@ void RelationNode::makeVersion(thread_db* tdbb, jrd_tra* transaction, const Qual if (notNull && !defaultValue->isEmpty()) { - Jrd::ContextPoolHolder context(tdbb, dbb->createPool()); + JrdContextPoolHolder context(tdbb, dbb->createPool()); Statement* defaultStatement = NULL; try { @@ -8510,7 +8510,7 @@ void RelationNode::makeVersion(thread_db* tdbb, jrd_tra* transaction, const Qual dsc* result = nullptr; { // scope - Firebird::Cleanup detach([&defaultRequest] {TRA_detach_request(defaultRequest);}); + Cleanup detach([&defaultRequest] {TRA_detach_request(defaultRequest);}); TRA_attach_request(transaction, defaultRequest); result = EVL_expr(tdbb, defaultRequest, defaultNode); } @@ -9124,7 +9124,7 @@ Format* RelationNode::makeFormat(thread_db* tdbb, jrd_tra* transaction, Cached:: // Use generic representation of formats with 32-bit offsets - Firebird::Array odsDescs; + Array odsDescs; Ods::Descriptor* odsDesc = odsDescs.getBuffer(format->fmt_count); for (Format::fmt_desc_const_iterator desc = format->fmt_desc.begin(); @@ -12189,7 +12189,7 @@ bool ModifyIndexNode::modify(thread_db* tdbb, Cached::Relation* relation, jrd_tr return rc; } -string ModifyIndexNode::print(Jrd::NodePrinter& printer) const +string ModifyIndexNode::print(NodePrinter& printer) const { NODE_PRINT(printer, indexName); NODE_PRINT(printer, create); @@ -12383,7 +12383,7 @@ MetaId StoreIndexNode::create(thread_db* tdbb, Cached::Relation* rel, jrd_tra* t try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, relation, nullptr, 0, nullptr, &IDX.RDB$CONDITION_BLR, nullptr, &csb, indexName, obj_index_condition, 0, @@ -12661,7 +12661,7 @@ MetaId StoreIndexNode::createExpression(thread_db* tdbb, Cached::Relation* rel, try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, relation, nullptr, 0, nullptr, &IDX.RDB$EXPRESSION_BLR, nullptr, &csb, indexName, obj_index_expression, 0, @@ -12694,7 +12694,7 @@ MetaId StoreIndexNode::createExpression(thread_db* tdbb, Cached::Relation* rel, try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, relation, nullptr, 0, nullptr, &IDX.RDB$CONDITION_BLR, nullptr, &csb, indexName, obj_index_condition, 0, @@ -14543,7 +14543,7 @@ void MappingNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) void MappingNode::runInSecurityDb(SecDbContext* secDbContext) { - Firebird::LocalStatus st; + LocalStatus st; CheckStatusWrapper statusWrapper(&st); // first of all try to use regenerated DDL statement @@ -15116,7 +15116,7 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra userData->createIfNotExistsOnly = createIfNotExistsOnly; - Firebird::LocalStatus s; + LocalStatus s; CheckStatusWrapper statusWrapper(&s); userData->op = mode == USER_ADD ? Auth::ADD_OPER : mode == USER_MOD ? @@ -15223,7 +15223,7 @@ void DropUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jr string text = name.c_str(); - Firebird::LocalStatus s; + LocalStatus s; CheckStatusWrapper statusWrapper(&s); userData->op = Auth::DEL_OPER; @@ -17521,4 +17521,4 @@ bool DropSchemaNode::collectObjects(thread_db* tdbb, jrd_tra* transaction, return objects && objects->hasData(); } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/DdlNodes.h b/src/dsql/DdlNodes.h index b72ac145e9a..132cbbeb2bc 100644 --- a/src/dsql/DdlNodes.h +++ b/src/dsql/DdlNodes.h @@ -40,7 +40,7 @@ #include "../jrd/Savepoint.h" #include "../dsql/errd_proto.h" -namespace Jrd { +namespace Firebird::Jrd { enum SqlSecurity { @@ -65,7 +65,7 @@ class BoolSourceClause : public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { NODE_PRINT(printer, value); NODE_PRINT(printer, source); @@ -75,7 +75,7 @@ class BoolSourceClause : public Printable public: NestConst value; - Firebird::string source; + string source; }; @@ -89,7 +89,7 @@ class ValueSourceClause final : public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { NODE_PRINT(printer, value); NODE_PRINT(printer, source); @@ -99,7 +99,7 @@ class ValueSourceClause final : public Printable public: NestConst value; - Firebird::string source; + string source; }; @@ -121,7 +121,7 @@ class ExternalClause final : public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { NODE_PRINT(printer, name); NODE_PRINT(printer, engine); @@ -131,9 +131,9 @@ class ExternalClause final : public Printable } public: - Firebird::string name; + string name; MetaName engine; - Firebird::string udfModule; + string udfModule; }; @@ -144,7 +144,7 @@ class ParameterClause final : public Printable ValueSourceClause* aDefaultClause = NULL, ValueExprNode* aParameterExpr = NULL); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; public: MetaName name; @@ -169,7 +169,7 @@ struct CollectedParameter bid defaultValue; }; -typedef Firebird::LeftPooledMap CollectedParameterMap; +typedef LeftPooledMap CollectedParameterMap; class ExecInSecurityDb @@ -198,7 +198,7 @@ class RecreateNode : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { Node::internalPrint(printer); @@ -238,9 +238,9 @@ class RecreateNode : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(ERROR_CODE) << createNode->name.toQuotedString(); + statusVector << Arg::Gds(ERROR_CODE) << createNode->name.toQuotedString(); } protected: @@ -260,7 +260,7 @@ class AlterCharSetNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -275,9 +275,9 @@ class AlterCharSetNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_charset_failed) << charSet.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_charset_failed) << charSet.toQuotedString(); } private: @@ -300,7 +300,7 @@ class AlterEDSPoolSetNode final : public DdlNode public: void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; bool mustBeReplicated() const override @@ -309,9 +309,9 @@ class AlterEDSPoolSetNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - // TODO: statusVector << Firebird::Arg::Gds(??); + // TODO: statusVector << Arg::Gds(??); } private: @@ -325,7 +325,7 @@ class AlterEDSPoolClearNode final : public DdlNode public: enum PARAM { POOL_ALL, POOL_OLDEST, POOL_DB }; - AlterEDSPoolClearNode(MemoryPool& pool, PARAM prm, const Firebird::string& val = "") + AlterEDSPoolClearNode(MemoryPool& pool, PARAM prm, const string& val = "") : DdlNode(pool), m_param(prm), m_value(pool) @@ -335,7 +335,7 @@ class AlterEDSPoolClearNode final : public DdlNode public: void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; bool mustBeReplicated() const override @@ -344,14 +344,14 @@ class AlterEDSPoolClearNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - // TODO: statusVector << Firebird::Arg::Gds(??); + // TODO: statusVector << Arg::Gds(??); } private: PARAM m_param; - Firebird::string m_value; + string m_value; }; @@ -360,7 +360,7 @@ class CommentOnNode final : public DdlNode public: CommentOnNode(MemoryPool& pool, ObjectType aObjType, const QualifiedName& aName, const MetaName& aSubName, - const Firebird::string aText) + const string aText) : DdlNode(pool), objType(aObjType), name(pool, aName), @@ -371,27 +371,27 @@ class CommentOnNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { str = name.toQuotedString(); if (subName.hasData()) str.append(".").append(subName.c_str()); - statusVector << Firebird::Arg::Gds(isc_dsql_comment_on_failed) << str; + statusVector << Arg::Gds(isc_dsql_comment_on_failed) << str; } private: ObjectType objType; QualifiedName name; MetaName subName; - Firebird::string text, str; + string text, str; }; @@ -419,16 +419,16 @@ class CreateAlterFunctionNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_func_failed, isc_dsql_alter_func_failed, isc_dsql_create_alter_func_failed)) << name.toQuotedString(); @@ -458,11 +458,11 @@ class CreateAlterFunctionNode final : public DdlNode bool alter; bool createIfNotExistsOnly = false; NestConst external; - Firebird::TriState deterministic; - Firebird::Array> parameters; + TriState deterministic; + Array> parameters; NestConst returnType; NestConst localDeclList; - Firebird::string source; + string source; NestConst body; bool compiled; bool invalid; @@ -488,7 +488,7 @@ class AlterExternalFunctionNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -502,9 +502,9 @@ class AlterExternalFunctionNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_func_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_func_failed) << name.toQuotedString(); } public: @@ -527,15 +527,15 @@ class DropFunctionNode final : public DdlNode static void dropArguments(thread_db* tdbb, jrd_tra* transaction, const QualifiedName& functionName); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_func_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_func_failed) << name.toQuotedString(); } public: @@ -572,16 +572,16 @@ class CreateAlterProcedureNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_proc_failed, isc_dsql_alter_proc_failed, isc_dsql_create_alter_proc_failed)) << name.toQuotedString(); @@ -606,9 +606,9 @@ class CreateAlterProcedureNode final : public DdlNode bool alter; bool createIfNotExistsOnly = false; NestConst external; - Firebird::Array > parameters; - Firebird::Array > returns; - Firebird::string source; + Array > parameters; + Array > returns; + string source; NestConst localDeclList; NestConst body; bool compiled; @@ -637,15 +637,15 @@ class DropProcedureNode final : public DdlNode static void dropParameters(thread_db* tdbb, jrd_tra* transaction, const QualifiedName& procedureName); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_proc_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_proc_failed) << name.toQuotedString(); } public: @@ -694,12 +694,12 @@ class TriggerDefinition QualifiedName name; QualifiedName relationName; std::optional type; - Firebird::TriState active; + TriState active; std::optional position; NestConst external; - Firebird::string source; - Firebird::ByteChunk blrData; - Firebird::ByteChunk debugData; + string source; + ByteChunk blrData; + ByteChunk debugData; USHORT systemFlag; bool fkTrigger; std::optional ssDefiner; @@ -723,16 +723,16 @@ class CreateAlterTriggerNode final : public DdlNode, public TriggerDefinition } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_trigger_failed, isc_dsql_alter_trigger_failed, isc_dsql_create_alter_trigger_failed)) << name.toQuotedString(); @@ -798,15 +798,15 @@ class DropTriggerNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_trigger_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_trigger_failed) << name.toQuotedString(); } public: @@ -855,7 +855,7 @@ class CreateCollationNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -865,7 +865,6 @@ class CreateCollationNode final : public DdlNode if ((attributesOn | attributesOff) & attribute) { // msg: 222: "Invalid collation attributes" - using namespace Firebird; ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::PrivateDyn(222)); } @@ -877,7 +876,6 @@ class CreateCollationNode final : public DdlNode if ((attributesOn | attributesOff) & attribute) { // msg: 222: "Invalid collation attributes" - using namespace Firebird; ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::PrivateDyn(222)); } @@ -885,17 +883,17 @@ class CreateCollationNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_collation_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_create_collation_failed) << name.toQuotedString(); } public: QualifiedName name; QualifiedName forCharSet; QualifiedName fromName; - Firebird::string fromExternal; - Firebird::UCharBuffer specificAttributes; + string fromExternal; + UCharBuffer specificAttributes; bool createIfNotExistsOnly = false; private: @@ -916,7 +914,7 @@ class DropCollationNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -930,9 +928,9 @@ class DropCollationNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_collation_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_collation_failed) << name.toQuotedString(); } public: @@ -953,7 +951,7 @@ class CreateDomainNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -969,9 +967,9 @@ class CreateDomainNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_domain_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_create_domain_failed) << name.toQuotedString(); } public: @@ -1002,7 +1000,7 @@ class AlterDomainNode final : public DdlNode const QualifiedName& relationName, const MetaName& fieldName, const MetaName& newFieldName); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1019,9 +1017,9 @@ class AlterDomainNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_domain_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_domain_failed) << name.toQuotedString(); } private: @@ -1032,8 +1030,8 @@ class AlterDomainNode final : public DdlNode NestConst setConstraint; NestConst setDefault; MetaName renameTo; - Firebird::AutoPtr type; - Firebird::TriState notNullFlag; // true = NOT NULL / false = NULL + AutoPtr type; + TriState notNullFlag; // true = NOT NULL / false = NULL bool dropConstraint = false; bool dropDefault = false; }; @@ -1052,7 +1050,7 @@ class DropDomainNode final : public DdlNode const QualifiedName& name); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1066,9 +1064,9 @@ class DropDomainNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_domain_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_domain_failed) << name.toQuotedString(); } private: @@ -1084,7 +1082,7 @@ class CreateAlterExceptionNode final : public DdlNode { public: CreateAlterExceptionNode(MemoryPool& p, const QualifiedName& aName, - const Firebird::string& aMessage) + const string& aMessage) : DdlNode(p), name(p, aName), message(p, aMessage), @@ -1094,7 +1092,7 @@ class CreateAlterExceptionNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1112,10 +1110,10 @@ class CreateAlterExceptionNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_except_failed, isc_dsql_alter_except_failed, isc_dsql_create_alter_except_failed)) << name.toQuotedString(); @@ -1127,7 +1125,7 @@ class CreateAlterExceptionNode final : public DdlNode public: QualifiedName name; - Firebird::string message; + string message; bool create; bool alter; bool createIfNotExistsOnly = false; @@ -1145,7 +1143,7 @@ class DropExceptionNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1163,9 +1161,9 @@ class DropExceptionNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_except_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_except_failed) << name.toQuotedString(); } public: @@ -1195,7 +1193,6 @@ class CreateAlterSequenceNode final : public DdlNode /* if (!aValue.specified && !aStep.specified) { - using namespace Firebird; ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << // Unexpected end of command Arg::Gds(isc_command_end_err2) << Arg::Num(this->line) << @@ -1208,7 +1205,7 @@ class CreateAlterSequenceNode final : public DdlNode fb_sysflag sysFlag, SINT64 value, SLONG step); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1230,7 +1227,7 @@ class CreateAlterSequenceNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override; + void putErrorPrefix(Arg::StatusVector& statusVector) override; private: void executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1261,7 +1258,7 @@ class DropSequenceNode final : public DdlNode static void deleteIdentity(thread_db* tdbb, jrd_tra* transaction, const QualifiedName& name); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1279,9 +1276,9 @@ class DropSequenceNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_sequence_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_sequence_failed) << name.toQuotedString(); } public: @@ -1326,7 +1323,7 @@ class ModifyIndexList } private: - Firebird::HalfStaticArray nodes; + HalfStaticArray nodes; }; @@ -1356,10 +1353,10 @@ class RelationNode : public DdlNode QualifiedName identitySequence; std::optional identityType; std::optional collationId; - Firebird::TriState notNullFlag; // true = NOT NULL / false = NULL + TriState notNullFlag; // true = NOT NULL / false = NULL std::optional position; - Firebird::string defaultSource; - Firebird::ByteChunk defaultValue; + string defaultSource; + ByteChunk defaultValue; std::optional viewContext; MetaName baseField; }; @@ -1381,11 +1378,11 @@ class RelationNode : public DdlNode enum Type { TYPE_CHECK, TYPE_NOT_NULL, TYPE_PK, TYPE_UNIQUE, TYPE_FK }; // Specialized BlrWriter for constraints. - class BlrWriter final : public Jrd::BlrDebugWriter + class BlrWriter final : public BlrDebugWriter { public: explicit BlrWriter(MemoryPool& p) - : Jrd::BlrDebugWriter(p), + : BlrDebugWriter(p), dsqlScratch(NULL) { } @@ -1421,14 +1418,14 @@ class RelationNode : public DdlNode } Constraint::Type type; - Firebird::ObjectsArray columns; + ObjectsArray columns; NestConst index; QualifiedName refRelation; - Firebird::ObjectsArray refColumns; + ObjectsArray refColumns; const char* refUpdateAction; const char* refDeleteAction; - Firebird::ObjectsArray triggers; - Firebird::ObjectsArray blrWritersHolder; + ObjectsArray triggers; + ObjectsArray blrWritersHolder; }; struct CreateDropConstraint @@ -1439,7 +1436,7 @@ class RelationNode : public DdlNode } MetaName name; - Firebird::AutoPtr create; + AutoPtr create; bool silent = false; }; @@ -1510,10 +1507,10 @@ class RelationNode : public DdlNode MetaName name; ConstraintType constraintType; - Firebird::ObjectsArray columns; + ObjectsArray columns; NestConst index; QualifiedName refRelation; - Firebird::ObjectsArray refColumns; + ObjectsArray refColumns; NestConst refAction; NestConst check; bool createIfNotExistsOnly = false; @@ -1554,7 +1551,7 @@ class RelationNode : public DdlNode dsql_fld* field; NestConst defaultValue; - Firebird::ObjectsArray constraints; + ObjectsArray constraints; QualifiedName collate; NestConst computed; NestConst identityOptions; @@ -1670,7 +1667,7 @@ class RelationNode : public DdlNode protected: static void validateLttColumnClause(const AddColumnClause* addColumnClause); - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { DdlNode::internalPrint(printer); @@ -1683,11 +1680,11 @@ class RelationNode : public DdlNode void defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction, AddColumnClause* clause, SSHORT position, - const Firebird::ObjectsArray* pkcols); + const ObjectsArray* pkcols); bool defineDefault(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, dsql_fld* field, - ValueSourceClause* clause, Firebird::string& source, BlrDebugWriter::BlrData& value); + ValueSourceClause* clause, string& source, BlrDebugWriter::BlrData& value); void makeConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction, - AddConstraintClause* clause, Firebird::ObjectsArray& constraints, + AddConstraintClause* clause, ObjectsArray& constraints, bool* notNull = NULL); void defineConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction, MetaName& constraintName, Constraint& constraint); @@ -1703,7 +1700,7 @@ class RelationNode : public DdlNode void defineUpdateCascadeTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint); void generateUnnamedTriggerBeginning(Constraint& constraint, bool onUpdate, BlrDebugWriter& blrWriter); - void stuffDefaultBlr(const Firebird::ByteChunk& defaultBlr, BlrDebugWriter& blrWriter); + void stuffDefaultBlr(const ByteChunk& defaultBlr, BlrDebugWriter& blrWriter); void stuffMatchingBlr(Constraint& constraint, BlrDebugWriter& blrWriter); void stuffTriggerFiringCondition(const Constraint& constraint, BlrDebugWriter& blrWriter); @@ -1727,11 +1724,11 @@ class RelationNode : public DdlNode public: NestConst dsqlNode; QualifiedName name; - Firebird::Array > clauses; + Array > clauses; std::optional tempFlag; // REL_temp_gtt, REL_temp_ltt std::optional tempRowsFlag; // REL_temp_tran, REL_temp_conn - Firebird::TriState ssDefiner; - Firebird::TriState replicationState; + TriState ssDefiner; + TriState replicationState; ModifyIndexList indexList; }; @@ -1740,14 +1737,14 @@ class CreateRelationNode final : public RelationNode { public: CreateRelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode, - const Firebird::string* aExternalFile = NULL) + const string* aExternalFile = NULL) : RelationNode(p, aDsqlNode), externalFile(aExternalFile) { } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1766,17 +1763,17 @@ class CreateRelationNode final : public RelationNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_table_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_create_table_failed) << name.toQuotedString(); } private: - const Firebird::ObjectsArray* findPkColumns(); + const ObjectsArray* findPkColumns(); void defineLocalTempTable(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); public: - const Firebird::string* externalFile; + const string* externalFile; bool createIfNotExistsOnly = false; }; @@ -1804,14 +1801,14 @@ class AlterRelationNode final : public RelationNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_table_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_table_failed) << name.toQuotedString(); } private: @@ -1835,7 +1832,7 @@ class DropRelationNode final : public DdlNode static void deleteGlobalField(thread_db* tdbb, jrd_tra* transaction, const QualifiedName& globalName); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -1858,9 +1855,9 @@ class DropRelationNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(view ? isc_dsql_drop_view_failed : isc_dsql_drop_table_failed) << + statusVector << Arg::Gds(view ? isc_dsql_drop_view_failed : isc_dsql_drop_table_failed) << name.toQuotedString(); } @@ -1892,16 +1889,16 @@ class CreateAlterViewNode final : public RelationNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_view_failed, isc_dsql_alter_view_failed, isc_dsql_create_alter_view_failed)) << name.toQuotedString(); @@ -1917,7 +1914,7 @@ class CreateAlterViewNode final : public RelationNode bool createIfNotExistsOnly = false; NestConst viewFields; NestConst selectExpr; - Firebird::string source; + string source; bool withCheckOption; }; @@ -1960,7 +1957,7 @@ class ModifyIndexNode virtual bool exec(thread_db* tdbb, Cached::Relation* rel, jrd_tra* transaction) = 0; protected: - Firebird::string print(NodePrinter& printer) const; + string print(NodePrinter& printer) const; static Cached::Relation* getRelByIndex(thread_db* tdbb, const QualifiedName& index, jrd_tra* transaction); public: @@ -1985,17 +1982,17 @@ class CreateIndexNode final : public DdlNode QualifiedName index; QualifiedName relation; - Firebird::ObjectsArray columns; - Firebird::TriState unique; - Firebird::TriState descending; - Firebird::TriState inactive; + ObjectsArray columns; + TriState unique; + TriState descending; + TriState inactive; SSHORT type; bid expressionBlr; bid expressionSource; bid conditionBlr; bid conditionSource; QualifiedName refRelation; - Firebird::ObjectsArray refColumns; + ObjectsArray refColumns; }; public: @@ -2010,7 +2007,7 @@ class CreateIndexNode final : public DdlNode Definition& definition, QualifiedName* referredIndexName = nullptr); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; @@ -2025,9 +2022,9 @@ class CreateIndexNode final : public DdlNode jrd_tra* transaction, LocalTemporaryTable* ltt); protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_index_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_create_index_failed) << name.toQuotedString(); } public: @@ -2073,7 +2070,7 @@ class AlterIndexNode final : public ModifyIndexNode, public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2096,9 +2093,9 @@ class AlterIndexNode final : public ModifyIndexNode, public DdlNode bool exec(thread_db* tdbb, Cached::Relation* rel, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_index_failed) << indexName.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_index_failed) << indexName.toQuotedString(); } public: @@ -2116,7 +2113,7 @@ class SetStatisticsNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2133,10 +2130,10 @@ class SetStatisticsNode final : public DdlNode jrd_tra* transaction, LocalTemporaryTable* ltt, LocalTemporaryTable::Index* lttIndex); protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { // ASF: using ALTER INDEX's code. - statusVector << Firebird::Arg::Gds(isc_dsql_alter_index_failed) << indexName.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_alter_index_failed) << indexName.toQuotedString(); } public: @@ -2154,7 +2151,7 @@ class DropIndexNode final : public ModifyIndexNode, public DdlNode static void clearId(thread_db* tdbb, MetaId relId, MetaId indexId); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; Cached::Relation* drop(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction, @@ -2179,9 +2176,9 @@ class DropIndexNode final : public ModifyIndexNode, public DdlNode bool exec(thread_db* tdbb, Cached::Relation* rel, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_index_failed) << indexName.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_index_failed) << indexName.toQuotedString(); } public: @@ -2211,7 +2208,7 @@ class CreateFilterNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { NODE_PRINT(printer, name); NODE_PRINT(printer, number); @@ -2234,22 +2231,22 @@ class CreateFilterNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_filter_failed) << name; + statusVector << Arg::Gds(isc_dsql_create_filter_failed) << name; } public: MetaName name; NestConst inputFilter; NestConst outputFilter; - Firebird::string entryPoint; - Firebird::string moduleName; + string entryPoint; + string moduleName; bool createIfNotExistsOnly = false; }; @@ -2264,14 +2261,14 @@ class DropFilterNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_filter_failed) << name; + statusVector << Arg::Gds(isc_dsql_drop_filter_failed) << name; } public: @@ -2284,7 +2281,7 @@ class CreateShadowNode final : public DdlNode { public: CreateShadowNode(MemoryPool& p, SSHORT aNumber, bool aManual, bool aConditional, - const Firebird::string& aFileName) + const string& aFileName) : DdlNode(p), number(aNumber), manual(aManual), @@ -2294,7 +2291,7 @@ class CreateShadowNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2304,16 +2301,16 @@ class CreateShadowNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_shadow_failed) << Firebird::Arg::Num(number); + statusVector << Arg::Gds(isc_dsql_create_shadow_failed) << Arg::Num(number); } public: SSHORT number; bool manual; bool conditional; - Firebird::string fileName; + string fileName; bool createIfNotExistsOnly = false; }; @@ -2329,7 +2326,7 @@ class DropShadowNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2339,9 +2336,9 @@ class DropShadowNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_shadow_failed) << Firebird::Arg::Num(number); + statusVector << Arg::Gds(isc_dsql_drop_shadow_failed) << Arg::Num(number); } public: @@ -2376,14 +2373,14 @@ class CreateAlterRoleNode final : public PrivilegesNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(createFlag ? isc_dsql_create_role_failed : + statusVector << Arg::Gds(createFlag ? isc_dsql_create_role_failed : isc_dsql_alter_role_failed) << name; } @@ -2403,7 +2400,7 @@ class CreateAlterRoleNode final : public PrivilegesNode } private: - Firebird::HalfStaticArray privileges; + HalfStaticArray privileges; }; @@ -2431,14 +2428,14 @@ class MappingNode final : public DdlNode, private ExecInSecurityDb return DdlNode::dsqlPass(dsqlScratch); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_mapping_failed) << name << + statusVector << Arg::Gds(isc_dsql_mapping_failed) << name << (op == MAP_ADD ? "CREATE" : op == MAP_MOD ? "ALTER" : op == MAP_RPL ? "CREATE OR ALTER" : op == MAP_DROP ? "DROP" : "COMMENT ON"); @@ -2446,17 +2443,17 @@ class MappingNode final : public DdlNode, private ExecInSecurityDb void runInSecurityDb(SecDbContext* secDbContext) override; private: - void addItem(Firebird::string& ddl, const char* text, char quote = '"'); + void addItem(string& ddl, const char* text, char quote = '"'); public: MetaName name; - Firebird::string fromUtf8; + string fromUtf8; MetaName* plugin = nullptr; MetaName* db = nullptr; MetaName* fromType = nullptr; IntlString* from = nullptr; MetaName* to = nullptr; - Firebird::string* comment = nullptr; + string* comment = nullptr; OP op; char mode = '#'; // * - any source, P - plugin, M - mapping, S - any serverwide plugin bool global = false; @@ -2476,14 +2473,14 @@ class DropRoleNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_role_failed) << name; + statusVector << Arg::Gds(isc_dsql_drop_role_failed) << name; } public: @@ -2523,7 +2520,7 @@ class CreateAlterUserNode final : public UserNode { } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2533,9 +2530,9 @@ class CreateAlterUserNode final : public UserNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(mode == USER_ADD ? + statusVector << Arg::Gds(mode == USER_ADD ? isc_dsql_create_user_failed : isc_dsql_alter_user_failed) << name; } @@ -2548,23 +2545,23 @@ class CreateAlterUserNode final : public UserNode { } MetaName property; - Firebird::string value; + string value; }; - Firebird::ObjectsArray properties; + ObjectsArray properties; const MetaName name; - Firebird::string* password; - Firebird::string* firstName; - Firebird::string* middleName; - Firebird::string* lastName; + string* password; + string* firstName; + string* middleName; + string* lastName; MetaName* plugin; - Firebird::string* comment; - Firebird::TriState adminRole; - Firebird::TriState active; + string* comment; + TriState adminRole; + TriState active; Mode mode; bool createIfNotExistsOnly = false; - void addProperty(MetaName* pr, Firebird::string* val = NULL) + void addProperty(MetaName* pr, string* val = NULL) { fb_assert(pr); @@ -2592,7 +2589,7 @@ class DropUserNode final : public UserNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2602,9 +2599,9 @@ class DropUserNode final : public UserNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_user_failed) << name; + statusVector << Arg::Gds(isc_dsql_drop_user_failed) << name; } public: @@ -2629,8 +2626,8 @@ typedef RecreateNode*> PrivilegeClause; -typedef Firebird::NonPooledPair GranteeClause; +typedef NonPooledPair*> PrivilegeClause; +typedef NonPooledPair GranteeClause; class GrantRevokeNode final : public PrivilegesNode, private ExecInSecurityDb { @@ -2651,13 +2648,13 @@ class GrantRevokeNode final : public PrivilegesNode, private ExecInSecurityDb } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override { - Firebird::Array grantees; + Array grantees; if (object) grantees.add(object); @@ -2730,10 +2727,10 @@ class GrantRevokeNode final : public PrivilegesNode, private ExecInSecurityDb } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(isGrant ? isc_dsql_grant_failed : isc_dsql_revoke_failed); + Arg::Gds(isGrant ? isc_dsql_grant_failed : isc_dsql_revoke_failed); } void runInSecurityDb(SecDbContext* secDbContext) override; @@ -2791,15 +2788,15 @@ class GrantRevokeNode final : public PrivilegesNode, private ExecInSecurityDb SSHORT userType; MetaName user, revoker; }; - Firebird::Array createDbJobs; + Array createDbJobs; public: bool isGrant; - Firebird::Array privileges; - Firebird::Array roles; - Firebird::Array defaultRoles; + Array privileges; + Array roles; + Array defaultRoles; NestConst object; - Firebird::Array users; + Array users; bool grantAdminOption; NestConst grantor; // ddl rights @@ -2848,7 +2845,7 @@ class AlterDatabaseNode final : public DdlNode return this; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -2858,27 +2855,27 @@ class AlterDatabaseNode final : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_alter_database_failed); + statusVector << Arg::Gds(isc_dsql_alter_database_failed); } private: static void changeBackupMode(thread_db* tdbb, jrd_tra* transaction, unsigned clause); - static void defineDifference(thread_db* tdbb, jrd_tra* transaction, const Firebird::PathName& file); + static void defineDifference(thread_db* tdbb, jrd_tra* transaction, const PathName& file); void checkClauses(thread_db* tdbb); public: bool create = false; // Is the node created with a CREATE DATABASE command? SLONG linger = -1; unsigned clauses = 0; - Firebird::string differenceFile; + string differenceFile; QualifiedName setDefaultCharSet; QualifiedName setDefaultCollation; MetaName cryptPlugin; MetaName keyName; - Firebird::TriState ssDefiner; - Firebird::Array pubTables; + TriState ssDefiner; + Array pubTables; }; @@ -2893,15 +2890,15 @@ class CreateAlterSchemaNode final : public DdlNode public: DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_schema_failed, isc_dsql_alter_schema_failed, isc_dsql_create_alter_schema_failed)) << name.toQuotedString(); @@ -2931,19 +2928,19 @@ class DropSchemaNode final : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_schema_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_schema_failed) << name.toQuotedString(); } private: bool collectObjects(thread_db* tdbb, jrd_tra* transaction, - Firebird::Array>* objects = nullptr); + Array>* objects = nullptr); public: MetaName name; diff --git a/src/dsql/DsqlBatch.cpp b/src/dsql/DsqlBatch.cpp index d15da6ff51b..ab0b29e8301 100644 --- a/src/dsql/DsqlBatch.cpp +++ b/src/dsql/DsqlBatch.cpp @@ -36,14 +36,15 @@ #include "../common/utils_proto.h" #include "../common/classes/BatchCompletionState.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { const char* const TEMP_NAME = "fb_batch"; const UCHAR initBlobParameters[] = {isc_bpb_version1, isc_bpb_type, 1, isc_bpb_type_stream}; - class JTransliterate : public Firebird::Transliterate + class JTransliterate : public Transliterate { public: JTransliterate(thread_db* tdbb) @@ -182,7 +183,7 @@ DsqlBatch* DsqlBatch::open(thread_db* tdbb, DsqlDmlRequest* req, IMessageMetadat unsigned parLength, const UCHAR* par) { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &req->getPool()); + JrdContextPoolHolder context(tdbb, &req->getPool()); // Validate cursor or batch being not already open @@ -438,7 +439,7 @@ void DsqlBatch::registerBlob(const ISC_QUAD* engineBlob, const ISC_QUAD* batchBl *idPtr = *engineBlob; } -Firebird::IBatchCompletionState* DsqlBatch::execute(thread_db* tdbb) +IBatchCompletionState* DsqlBatch::execute(thread_db* tdbb) { // todo - add new trace event here // TraceDSQLExecute trace(req_dbb->dbb_attachment, this); @@ -1101,3 +1102,5 @@ void DsqlBatch::info(thread_db* tdbb, unsigned int itemsLength, const unsigned c memcpy(buffer, out.getBuffer(), out.getBufferLength()); } + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlBatch.h b/src/dsql/DsqlBatch.h index 1a9aefcdf6e..96a742fa119 100644 --- a/src/dsql/DsqlBatch.h +++ b/src/dsql/DsqlBatch.h @@ -30,14 +30,14 @@ #include "../common/classes/GenericMap.h" -namespace Firebird { - -class ClumpletReader; - +namespace Firebird +{ + class ClumpletReader; } +namespace Firebird::Jrd +{ -namespace Jrd { class DsqlDmlRequest; class dsql_msg; @@ -48,8 +48,8 @@ class Attachment; class DsqlBatch { public: - DsqlBatch(DsqlDmlRequest* req, const dsql_msg* message, Firebird::IMessageMetadata* inMetadata, - Firebird::ClumpletReader& pb); + DsqlBatch(DsqlDmlRequest* req, const dsql_msg* message, IMessageMetadata* inMetadata, + ClumpletReader& pb); ~DsqlBatch(); static const ULONG RAM_BATCH = 128 * 1024; @@ -59,7 +59,7 @@ class DsqlBatch static const ULONG SIZEOF_BLOB_HEAD = sizeof(ISC_QUAD) + 2 * sizeof(ULONG); static const unsigned BLOB_STREAM_ALIGN = 4; - static DsqlBatch* open(thread_db* tdbb, DsqlDmlRequest* req, Firebird::IMessageMetadata* inMetadata, + static DsqlBatch* open(thread_db* tdbb, DsqlDmlRequest* req, IMessageMetadata* inMetadata, unsigned parLength, const UCHAR* par); Attachment* getAttachment() const; @@ -70,8 +70,8 @@ class DsqlBatch void appendBlobData(thread_db* tdbb, ULONG length, const void* inBuffer); void addBlobStream(thread_db* tdbb, unsigned length, const void* inBuffer); void registerBlob(thread_db* tdbb, const ISC_QUAD* existingBlob, ISC_QUAD* blobId); - Firebird::IBatchCompletionState* execute(thread_db* tdbb); - Firebird::IMessageMetadata* getMetadata(thread_db* tdbb); + IBatchCompletionState* execute(thread_db* tdbb); + IMessageMetadata* getMetadata(thread_db* tdbb); void cancel(thread_db* tdbb); void setDefaultBpb(thread_db* tdbb, unsigned parLength, const unsigned char* par); void info(thread_db* tdbb, unsigned int itemsLength, const unsigned char* items, @@ -101,9 +101,9 @@ class DsqlBatch DsqlDmlRequest* const m_dsqlRequest; JBatch* m_batch = nullptr; - Firebird::IMessageMetadata* const m_meta; + IMessageMetadata* const m_meta; - class DataCache : public Firebird::PermanentStorage + class DataCache : public PermanentStorage { public: DataCache(MemoryPool& p) @@ -126,9 +126,9 @@ class DsqlBatch void flush(); private: - typedef Firebird::Array Cache; + typedef Array Cache; Cache m_cache; - Firebird::AutoPtr m_space; + AutoPtr m_space; ULONG m_used = 0; ULONG m_got = 0; ULONG m_limit = 0; @@ -152,9 +152,9 @@ class DsqlBatch DataCache m_messages; DataCache m_blobs; - Firebird::GenericMap>, QuadComparator> m_blobMap; - Firebird::HalfStaticArray m_blobMeta; - typedef Firebird::HalfStaticArray Bpb; + GenericMap>, QuadComparator> m_blobMap; + HalfStaticArray m_blobMeta; + typedef HalfStaticArray Bpb; Bpb m_defaultBpb; ISC_QUAD m_genId; ULONG m_messageSize = 0; @@ -165,9 +165,10 @@ class DsqlBatch ULONG m_bufferSize = BUFFER_LIMIT; ULONG m_lastBlob = MAX_ULONG; bool m_setBlobSize = false; - UCHAR m_blobPolicy = Firebird::IBatch::BLOB_NONE; + UCHAR m_blobPolicy = IBatch::BLOB_NONE; }; -} // namespace + +} // namespace Firebird::Jrd #endif // DSQL_BATCH_H diff --git a/src/dsql/DsqlCompilerScratch.cpp b/src/dsql/DsqlCompilerScratch.cpp index e1dc329de0e..b59f71e4468 100644 --- a/src/dsql/DsqlCompilerScratch.cpp +++ b/src/dsql/DsqlCompilerScratch.cpp @@ -34,8 +34,8 @@ #include "../dsql/pass1_proto.h" #include -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ #ifdef DSQL_DEBUG @@ -1185,3 +1185,6 @@ void DsqlCompilerScratch::addCTEAlias(const string& alias) fb_assert(currCteAlias == NULL); cteAliases.add(FB_NEW_POOL(*tdbb->getDefaultPool()) string(*tdbb->getDefaultPool(), alias)); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlCompilerScratch.h b/src/dsql/DsqlCompilerScratch.h index ccebe02ba02..057fec3b542 100644 --- a/src/dsql/DsqlCompilerScratch.h +++ b/src/dsql/DsqlCompilerScratch.h @@ -34,8 +34,7 @@ #include #include -namespace Jrd -{ +namespace Firebird::Jrd { class BinaryBoolNode; class LocalDeclarationsNode; @@ -49,8 +48,8 @@ class TypeClause; class VariableNode; class WithClause; -typedef Firebird::Pair< - Firebird::NonPooled, NestConst>> ReturningClause; +typedef Pair< + NonPooled, NestConst>> ReturningClause; // DSQL Compiler scratch block. @@ -198,8 +197,8 @@ class DsqlCompilerScratch : public BlrDebugWriter dsql_var* resolveVariable(const MetaName& varName); void genReturn(bool eosFlag = false); - void genParameters(Firebird::Array >& parameters, - Firebird::Array >& returns); + void genParameters(Array >& parameters, + Array >& returns); // Get rid of any predefined contexts created for a view or trigger definition. // Also reset hidden variables. @@ -222,23 +221,23 @@ class DsqlCompilerScratch : public BlrDebugWriter SelectExprNode* findCTE(const MetaName& name); void clearCTEs(); void checkUnusedCTEs(); - void addCTEAlias(const Firebird::string& alias); + void addCTEAlias(const string& alias); - const Firebird::string* getNextCTEAlias() + const string* getNextCTEAlias() { return *(--currCteAlias); } - void resetCTEAlias(const Firebird::string& alias) + void resetCTEAlias(const string& alias) { #ifdef DEV_BUILD - const Firebird::string* const* begin = cteAliases.begin(); + const string* const* begin = cteAliases.begin(); #endif currCteAlias = cteAliases.end() - 1; fb_assert(currCteAlias >= begin); - const Firebird::string* curr = *(currCteAlias); + const string* curr = *(currCteAlias); while (strcmp(curr->c_str(), alias.c_str())) { @@ -310,11 +309,11 @@ class DsqlCompilerScratch : public BlrDebugWriter USHORT derivedContextNumber = 0; // Next available context number for derived tables USHORT scopeLevel = 0; // Scope level for parsing aliases in subqueries USHORT loopLevel = 0; // Loop level - Firebird::Stack labels; // Loop labels + Stack labels; // Loop labels USHORT cursorNumber = 0; // Cursor number - Firebird::Array cursors; // Cursors + Array cursors; // Cursors USHORT localTableNumber = 0; // Local table number - Firebird::Array localTables; // Local tables + Array localTables; // Local tables USHORT inSelectList = 0; // now processing "select list" USHORT inWhereClause = 0; // processing "where clause" USHORT inGroupByClause = 0; // processing "group by clause" @@ -323,37 +322,37 @@ class DsqlCompilerScratch : public BlrDebugWriter USHORT errorHandlers = 0; // count of active error handlers USHORT clientDialect = 0; // dialect passed into the API call USHORT inOuterJoin = 0; // processing inside outer-join part - Firebird::ObjectsArray aliasRelationPrefix; // prefix for every relation-alias. + ObjectsArray aliasRelationPrefix; // prefix for every relation-alias. QualifiedName package; // package being defined - Firebird::Stack currCtes; // current processing CTE's + Stack currCtes; // current processing CTE's dsql_ctx* recursiveCtx = nullptr; // context of recursive CTE USHORT recursiveCtxId = 0; // id of recursive union stream context bool processingWindow = false; // processing window functions bool checkConstraintTrigger = false; // compiling a check constraint trigger dsc domainValue; // VALUE in the context of domain's check constraint - Firebird::Array hiddenVariables; // hidden variables - Firebird::Array variables; - Firebird::Array outputVariables; + Array hiddenVariables; // hidden variables + Array variables; + Array outputVariables; ReturningClause* returningClause = nullptr; - const Firebird::string* const* currCteAlias = nullptr; + const string* const* currCteAlias = nullptr; DsqlCompilerScratch* mainScratch = nullptr; - Firebird::NonPooledMap outerMessagesMap; // - Firebird::NonPooledMap outerVarsMap; // + NonPooledMap outerMessagesMap; // + NonPooledMap outerVarsMap; // MetaName ddlSchema; - Firebird::AutoPtr> cachedDdlSchemaSearchPath; + AutoPtr> cachedDdlSchemaSearchPath; dsql_msg* recordKeyMessage = nullptr; // Side message for positioned DML private: - Firebird::HalfStaticArray ctes; // common table expressions - Firebird::HalfStaticArray cteAliases; // CTE aliases in recursive members + HalfStaticArray ctes; // common table expressions + HalfStaticArray cteAliases; // CTE aliases in recursive members USHORT nextVarNumber = 0; // Next available variable number bool psql = false; - Firebird::LeftPooledMap subFunctions; - Firebird::LeftPooledMap subProcedures; + LeftPooledMap subFunctions; + LeftPooledMap subProcedures; public: - Firebird::LeftPooledMap procedures; // known procedures - Firebird::LeftPooledMap functions; // known functions + LeftPooledMap procedures; // known procedures + LeftPooledMap functions; // known functions bool regularCacheValid = false; // flag for relations cache }; @@ -381,6 +380,6 @@ class PsqlChanger const bool oldValue; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_COMPILER_SCRATCH_H diff --git a/src/dsql/DsqlCursor.cpp b/src/dsql/DsqlCursor.cpp index 5c83259bf0b..1892a4b0680 100644 --- a/src/dsql/DsqlCursor.cpp +++ b/src/dsql/DsqlCursor.cpp @@ -30,8 +30,9 @@ #include "../dsql/DsqlCursor.h" #include "../dsql/StmtNodes.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + static const char* const SCRATCH = "fb_cursor_"; static const ULONG PREFETCH_SIZE = 65536; // 64 KB @@ -122,7 +123,7 @@ void DsqlCursor::close(thread_db* tdbb, DsqlCursor* cursor) JRD_unwind_request(tdbb, dsqlRequest->getRequest()); } - catch (Firebird::Exception&) + catch (Exception&) {} // no-op } @@ -424,3 +425,6 @@ bool DsqlCursor::cacheInput(thread_db* tdbb, UCHAR* buffer, FB_UINT64 position) return (position < m_cachedCount); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlCursor.h b/src/dsql/DsqlCursor.h index f98d8985349..239e07bf8ab 100644 --- a/src/dsql/DsqlCursor.h +++ b/src/dsql/DsqlCursor.h @@ -25,7 +25,7 @@ #include "../jrd/TempSpace.h" -namespace Jrd { +namespace Firebird::Jrd { class DsqlDmlRequest; class JResultSet; diff --git a/src/dsql/DsqlRequests.cpp b/src/dsql/DsqlRequests.cpp index 00522d975ad..de728441edb 100644 --- a/src/dsql/DsqlRequests.cpp +++ b/src/dsql/DsqlRequests.cpp @@ -36,8 +36,8 @@ #include "../dsql/movd_proto.h" #include "../jrd/exe_proto.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ static void checkD(IStatus* st); @@ -81,7 +81,7 @@ void DsqlRequest::releaseRequest(thread_db* tdbb) // It seems to me we should destroy owner request here, not a child // statement - as it always was before - //Jrd::ContextPoolHolder context(tdbb, &childStatement->getPool()); + //JrdContextPoolHolder context(tdbb, &childStatement->getPool()); //releaseStatement(childStatement); } @@ -96,7 +96,7 @@ void DsqlRequest::releaseRequest(thread_db* tdbb) req_batch = nullptr; } - Jrd::Attachment* att = req_dbb->dbb_attachment; + Attachment* att = req_dbb->dbb_attachment; const bool need_trace_free = req_traced && TraceManager::need_dsql_free(att); if (need_trace_free) { @@ -346,7 +346,7 @@ bool DsqlDmlRequest::fetch(thread_db* tdbb, UCHAR* msgBuffer) { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &getPool()); + JrdContextPoolHolder context(tdbb, &getPool()); // if the cursor isn't open, we've got a problem if (dsqlStatement->isCursorBased()) @@ -373,7 +373,7 @@ bool DsqlDmlRequest::fetch(thread_db* tdbb, UCHAR* msgBuffer) } // Set up things for tracing this call - Jrd::Attachment* att = req_dbb->dbb_attachment; + Attachment* att = req_dbb->dbb_attachment; TraceDSQLFetch trace(att, this); thread_db::TimerGuard timerGuard(tdbb, req_timer, false); @@ -427,7 +427,7 @@ void DsqlDmlRequest::setCursor(thread_db* tdbb, const TEXT* name) { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &getPool()); + JrdContextPoolHolder context(tdbb, &getPool()); constexpr size_t MAX_CURSOR_LENGTH = 132 - 1; string cursor = name; @@ -503,7 +503,7 @@ DsqlCursor* DsqlDmlRequest::openCursor(thread_db* tdbb, jrd_tra** traHandle, { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &getPool()); + JrdContextPoolHolder context(tdbb, &getPool()); // Validate transaction handle @@ -644,7 +644,7 @@ void DsqlDmlRequest::doExecute(thread_db* tdbb, jrd_tra** traHandle, } } -DsqlBatch* DsqlDmlRequest::openBatch(thread_db* tdbb, Firebird::IMessageMetadata* inMetadata, +DsqlBatch* DsqlDmlRequest::openBatch(thread_db* tdbb, IMessageMetadata* inMetadata, unsigned parLength, const UCHAR* par) { return DsqlBatch::open(tdbb, this, inMetadata, parLength, par); @@ -788,7 +788,7 @@ void DsqlDmlRequest::executeReceiveWithRestarts(thread_db* tdbb, jrd_tra** traHa } } -void DsqlDmlRequest::metadataToFormat(Firebird::IMessageMetadata* meta, const dsql_msg* message) +void DsqlDmlRequest::metadataToFormat(IMessageMetadata* meta, const dsql_msg* message) { if (!message) { @@ -983,7 +983,7 @@ void DsqlDdlRequest::execute(thread_db* tdbb, jrd_tra** traHandle, if (!isInternalRequest && node->mustBeReplicated()) { - REPL_exec_sql(tdbb, req_transaction, getDsqlStatement()->getOrgText(), + Replication::REPL_exec_sql(tdbb, req_transaction, getDsqlStatement()->getOrgText(), *getDsqlStatement()->getSchemaSearchPath()); } } @@ -1061,3 +1061,6 @@ static void checkD(IStatus* st) if (st->getState() & IStatus::STATE_ERRORS) ERRD_post(Arg::StatusVector(st)); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlRequests.h b/src/dsql/DsqlRequests.h index 3dd0a955ab1..02131c98505 100644 --- a/src/dsql/DsqlRequests.h +++ b/src/dsql/DsqlRequests.h @@ -31,7 +31,7 @@ #include "../common/classes/RefCounted.h" #include "../jrd/jrd.h" -namespace Jrd { +namespace Firebird::Jrd { class DdlNode; @@ -50,7 +50,7 @@ class TransactionNode; struct RecordKey; -class DsqlRequest : public Firebird::PermanentStorage +class DsqlRequest : public PermanentStorage { public: DsqlRequest(MemoryPool& pool, dsql_dbb* dbb, DsqlStatement* aStatement); @@ -63,7 +63,7 @@ class DsqlRequest : public Firebird::PermanentStorage return req_transaction; } - Firebird::RefPtr getDsqlStatement() + RefPtr getDsqlStatement() { return dsqlStatement; } @@ -79,31 +79,31 @@ class DsqlRequest : public Firebird::PermanentStorage } virtual DsqlCursor* openCursor(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMeta, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMeta, ULONG flags) + IMessageMetadata* inMeta, const UCHAR* inMsg, + IMessageMetadata* outMeta, ULONG flags) { - Firebird::Arg::Gds(isc_no_cursor).raise(); + Arg::Gds(isc_no_cursor).raise(); } - virtual DsqlBatch* openBatch(thread_db* tdbb, Firebird::IMessageMetadata* inMetadata, + virtual DsqlBatch* openBatch(thread_db* tdbb, IMessageMetadata* inMetadata, unsigned parLength, const UCHAR* par) { - (Firebird::Arg::Gds(isc_sqlerr) << - Firebird::Arg::Num(-504) << - Firebird::Arg::Gds(isc_unprepared_stmt) + (Arg::Gds(isc_sqlerr) << + Arg::Num(-504) << + Arg::Gds(isc_unprepared_stmt) ).raise(); } virtual void execute(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMetadata, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* inMetadata, const UCHAR* inMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton) = 0; virtual void setCursor(thread_db* tdbb, const TEXT* name); virtual bool fetch(thread_db* tdbb, UCHAR* buffer); - virtual void setDelayedFormat(thread_db* tdbb, Firebird::IMessageMetadata* metadata); + virtual void setDelayedFormat(thread_db* tdbb, IMessageMetadata* metadata); // Get session-level timeout, milliseconds unsigned int getTimeout(); @@ -122,23 +122,23 @@ class DsqlRequest : public Firebird::PermanentStorage public: dsql_dbb* req_dbb; // DSQL attachment - Firebird::RefPtr dsqlStatement; - Firebird::Array cursors{getPool()}; // Cursor update statements + RefPtr dsqlStatement; + Array cursors{getPool()}; // Cursor update statements jrd_tra* req_transaction = nullptr; // JRD transaction - Firebird::string req_cursor_name{getPool()}; // Cursor name, if any + string req_cursor_name{getPool()}; // Cursor name, if any DsqlCursor* req_cursor = nullptr; // Open cursor, if any DsqlBatch* req_batch = nullptr; // Active batch, if any - Firebird::AutoPtr req_fetch_baseline; // State of request performance counters when we reported it last time + AutoPtr req_fetch_baseline; // State of request performance counters when we reported it last time SINT64 req_fetch_elapsed = 0; // Number of clock ticks spent while fetching rows for this request since we reported it last time SINT64 req_fetch_rowcount = 0; // Total number of rows returned by this request bool req_traced = false; // request is traced via TraceAPI protected: unsigned int req_timeout = 0; // query timeout in milliseconds, set by the user - Firebird::RefPtr req_timer; // timeout timer + RefPtr req_timer; // timeout timer }; @@ -151,7 +151,7 @@ class DsqlDmlRequest final : public DsqlRequest // Reintroduce method to fake covariant return type with RefPtr. auto getDsqlStatement() { - return Firebird::RefPtr((DsqlDmlStatement*) dsqlStatement.getPtr()); + return RefPtr((DsqlDmlStatement*) dsqlStatement.getPtr()); } Statement* getStatement() const override; @@ -167,26 +167,26 @@ class DsqlDmlRequest final : public DsqlRequest } DsqlCursor* openCursor(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMeta, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMeta, ULONG flags) override; + IMessageMetadata* inMeta, const UCHAR* inMsg, + IMessageMetadata* outMeta, ULONG flags) override; - DsqlBatch* openBatch(thread_db* tdbb, Firebird::IMessageMetadata* inMetadata, + DsqlBatch* openBatch(thread_db* tdbb, IMessageMetadata* inMetadata, unsigned parLength, const UCHAR* par) override; void execute(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMetadata, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* inMetadata, const UCHAR* inMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton) override; void setCursor(thread_db* tdbb, const TEXT* name) override; bool fetch(thread_db* tdbb, UCHAR* buffer) override; - void setDelayedFormat(thread_db* tdbb, Firebird::IMessageMetadata* metadata) override; + void setDelayedFormat(thread_db* tdbb, IMessageMetadata* metadata) override; // Convert IMessageMetadata to Format and force it to corresponding MessageNode for current request. // After that this MessageNode and their ParameterNodes can work with client message buffer directly - void metadataToFormat(Firebird::IMessageMetadata* metadata, const dsql_msg* message); + void metadataToFormat(IMessageMetadata* metadata, const dsql_msg* message); void mapCursorKey(thread_db* tdbb); void gatherRecordKey(RecordKey* buffer) const; @@ -196,13 +196,13 @@ class DsqlDmlRequest final : public DsqlRequest void doExecute(thread_db* tdbb, jrd_tra** traHandle, const UCHAR* inMsg, // Only data buffer, metadata must be synchronized before call - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton); // [Re]start part of "request restarts" algorithm void executeReceiveWithRestarts(thread_db* tdbb, jrd_tra** traHandle, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton, bool exec, bool fetch); private: @@ -220,8 +220,8 @@ class DsqlDdlRequest final : public DsqlRequest DsqlDdlRequest(MemoryPool& pool, dsql_dbb* dbb, DsqlCompilerScratch* aInternalScratch, DdlNode* aNode); void execute(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMetadata, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* inMetadata, const UCHAR* inMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton) override; private: @@ -236,8 +236,8 @@ class DsqlTransactionRequest final : public DsqlRequest DsqlTransactionRequest(MemoryPool& pool, dsql_dbb* dbb, DsqlStatement* aStatement, TransactionNode* aNode); void execute(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMetadata, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* inMetadata, const UCHAR* inMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton) override; private: @@ -256,8 +256,8 @@ class DsqlSessionManagementRequest final : public DsqlRequest } void execute(thread_db* tdbb, jrd_tra** traHandle, - Firebird::IMessageMetadata* inMetadata, const UCHAR* inMsg, - Firebird::IMessageMetadata* outMetadata, UCHAR* outMsg, + IMessageMetadata* inMetadata, const UCHAR* inMsg, + IMessageMetadata* outMetadata, UCHAR* outMsg, bool singleton) override; private: @@ -265,6 +265,6 @@ class DsqlSessionManagementRequest final : public DsqlRequest }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_REQUESTS_H diff --git a/src/dsql/DsqlStatementCache.cpp b/src/dsql/DsqlStatementCache.cpp index 8e769132b2d..50b56581054 100644 --- a/src/dsql/DsqlStatementCache.cpp +++ b/src/dsql/DsqlStatementCache.cpp @@ -27,8 +27,8 @@ #include "../jrd/Statement.h" #include "../jrd/lck.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ // Class DsqlStatementCache @@ -181,7 +181,7 @@ void DsqlStatementCache::removeStatement(thread_db* tdbb, DsqlStatement* stateme } } -void DsqlStatementCache::statementGoingInactive(Firebird::RefStrPtr& key) +void DsqlStatementCache::statementGoingInactive(RefStrPtr& key) { const auto entryPtr = map.get(key); @@ -358,3 +358,6 @@ void DsqlStatementCache::dump() printf("\n"); } #endif + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlStatementCache.h b/src/dsql/DsqlStatementCache.h index 8f31a6411ab..1fb6b83cee3 100644 --- a/src/dsql/DsqlStatementCache.h +++ b/src/dsql/DsqlStatementCache.h @@ -32,7 +32,7 @@ #include "../common/classes/objects_array.h" #include "../common/classes/RefCounted.h" -namespace Jrd { +namespace Firebird::Jrd { class Attachment; @@ -41,7 +41,7 @@ class Lock; class thread_db; -class DsqlStatementCache final : public Firebird::PermanentStorage +class DsqlStatementCache final : public PermanentStorage { private: struct StatementEntry @@ -63,9 +63,9 @@ class DsqlStatementCache final : public Firebird::PermanentStorage StatementEntry(const StatementEntry&) = delete; StatementEntry& operator=(const StatementEntry&) = delete; - Firebird::RefStrPtr key; - Firebird::RefPtr dsqlStatement; - Firebird::SortedObjectsArray verifyCache; + RefStrPtr key; + RefPtr dsqlStatement; + SortedObjectsArray verifyCache; unsigned size = 0; bool active = true; }; @@ -73,7 +73,7 @@ class DsqlStatementCache final : public Firebird::PermanentStorage class RefStrPtrComparator { public: - static bool greaterThan(const Firebird::RefStrPtr& i1, const Firebird::RefStrPtr& i2) + static bool greaterThan(const RefStrPtr& i1, const RefStrPtr& i2) { return *i1 > *i2; } @@ -100,14 +100,14 @@ class DsqlStatementCache final : public Firebird::PermanentStorage return activeStatementList.isEmpty() && inactiveStatementList.isEmpty(); } - Firebird::RefPtr getStatement(thread_db* tdbb, const Firebird::string& text, + RefPtr getStatement(thread_db* tdbb, const string& text, USHORT clientDialect, bool isInternalRequest); - void putStatement(thread_db* tdbb, const Firebird::string& text, USHORT clientDialect, bool isInternalRequest, - Firebird::RefPtr dsqlStatement); + void putStatement(thread_db* tdbb, const string& text, USHORT clientDialect, bool isInternalRequest, + RefPtr dsqlStatement); void removeStatement(thread_db* tdbb, DsqlStatement* statement); - void statementGoingInactive(Firebird::RefStrPtr& key); + void statementGoingInactive(RefStrPtr& key); void purge(thread_db* tdbb, bool releaseLock); void purgeAllAttachments(thread_db* tdbb); @@ -118,10 +118,10 @@ class DsqlStatementCache final : public Firebird::PermanentStorage } private: - void buildStatementKey(thread_db* tdbb, Firebird::RefStrPtr& key, const Firebird::string& text, + void buildStatementKey(thread_db* tdbb, RefStrPtr& key, const string& text, USHORT clientDialect, bool isInternalRequest); - void buildVerifyKey(thread_db* tdbb, Firebird::string& key, bool isInternalRequest); + void buildVerifyKey(thread_db* tdbb, string& key, bool isInternalRequest); void shrink(); void ensureLockIsCreated(thread_db* tdbb); @@ -130,19 +130,19 @@ class DsqlStatementCache final : public Firebird::PermanentStorage #endif private: - Firebird::NonPooledMap< - Firebird::RefStrPtr, - Firebird::DoublyLinkedList::Iterator, + NonPooledMap< + RefStrPtr, + DoublyLinkedList::Iterator, RefStrPtrComparator > map; - Firebird::DoublyLinkedList activeStatementList; - Firebird::DoublyLinkedList inactiveStatementList; - Firebird::AutoPtr lock; + DoublyLinkedList activeStatementList; + DoublyLinkedList inactiveStatementList; + AutoPtr lock; unsigned maxCacheSize = 0; unsigned cacheSize = 0; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_STATEMENT_CACHE_H diff --git a/src/dsql/DsqlStatements.cpp b/src/dsql/DsqlStatements.cpp index 34aec832e7b..698ebe1ca27 100644 --- a/src/dsql/DsqlStatements.cpp +++ b/src/dsql/DsqlStatements.cpp @@ -30,8 +30,8 @@ #include "../dsql/gen_proto.h" #include "../jrd/cmp_proto.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ // Class DsqlStatement @@ -138,7 +138,7 @@ unsigned DsqlDmlStatement::getSize() const void DsqlDmlStatement::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scratch, ntrace_result_t* traceResult) { { // scope - ContextPoolHolder scratchContext(tdbb, &scratch->getPool()); + JrdContextPoolHolder scratchContext(tdbb, &scratch->getPool()); node = Node::doDsqlPass(scratch, node); } @@ -308,3 +308,6 @@ DsqlTransactionRequest* DsqlTransactionStatement::createRequest(thread_db* tdbb, { return FB_NEW_POOL(getPool()) DsqlTransactionRequest(getPool(), dbb, this, node); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/DsqlStatements.h b/src/dsql/DsqlStatements.h index a8a7ba01910..0edb9c89735 100644 --- a/src/dsql/DsqlStatements.h +++ b/src/dsql/DsqlStatements.h @@ -31,7 +31,7 @@ #include "../jrd/ntrace.h" #include "../dsql/DsqlRequests.h" -namespace Jrd { +namespace Firebird::Jrd { class DdlNode; @@ -46,7 +46,7 @@ class TransactionNode; // Compiled statement - shared by multiple requests. -class DsqlStatement : public Firebird::PermanentStorage +class DsqlStatement : public PermanentStorage { public: enum Type // statement type @@ -62,7 +62,7 @@ class DsqlStatement : public Firebird::PermanentStorage static inline constexpr unsigned FLAG_NO_BATCH = 0x01; static inline constexpr unsigned FLAG_SELECTABLE = 0x02; - static void rethrowDdlException(Firebird::status_exception& ex, bool metadataUpdate, DdlNode* node); + static void rethrowDdlException(status_exception& ex, bool metadataUpdate, DdlNode* node); public: DsqlStatement(MemoryPool& pool, dsql_dbb* aDsqlAttachment); @@ -102,12 +102,12 @@ class DsqlStatement : public Firebird::PermanentStorage unsigned getBlrVersion() const { return blrVersion; } void setBlrVersion(unsigned value) { blrVersion = value; } - Firebird::RefStrPtr& getSqlText() { return sqlText; } - const Firebird::RefStrPtr& getSqlText() const { return sqlText; } - void setSqlText(Firebird::RefString* value) { sqlText = value; } + RefStrPtr& getSqlText() { return sqlText; } + const RefStrPtr& getSqlText() const { return sqlText; } + void setSqlText(RefString* value) { sqlText = value; } void setOrgText(const char* ptr, ULONG len); - const Firebird::string& getOrgText() const { return *orgText; } + const string& getOrgText() const { return *orgText; } dsql_msg* getSendMsg() { return sendMsg; } const dsql_msg* getSendMsg() const { return sendMsg; } @@ -117,8 +117,8 @@ class DsqlStatement : public Firebird::PermanentStorage const dsql_msg* getReceiveMsg() const { return receiveMsg; } void setReceiveMsg(dsql_msg* value) { receiveMsg = value; } - Firebird::RefStrPtr getCacheKey() { return cacheKey; } - void setCacheKey(Firebird::RefStrPtr& value) { cacheKey = value; } + RefStrPtr getCacheKey() { return cacheKey; } + void setCacheKey(RefStrPtr& value) { cacheKey = value; } void resetCacheKey() { cacheKey = nullptr; } const auto getSchemaSearchPath() const { return schemaSearchPath; } @@ -157,20 +157,20 @@ class DsqlStatement : public Firebird::PermanentStorage protected: dsql_dbb* dsqlAttachment; - Firebird::MemoryStats memoryStats; + MemoryStats memoryStats; Type type = TYPE_SELECT; // Type of statement ULONG flags = 0; // generic flag unsigned blrVersion = blr_version5; - Firebird::RefStrPtr sqlText; - Firebird::RefStrPtr orgText; - Firebird::RefStrPtr cacheKey; + RefStrPtr sqlText; + RefStrPtr orgText; + RefStrPtr cacheKey; dsql_msg* sendMsg = nullptr; // Message to be sent to start request dsql_msg* receiveMsg = nullptr; // Per record message to be received DsqlCompilerScratch* scratch = nullptr; - Firebird::RefPtr>> schemaSearchPath; + RefPtr>> schemaSearchPath; private: - Firebird::AtomicCounter refCounter; + AtomicCounter refCounter; }; @@ -277,6 +277,6 @@ class DsqlSessionManagementStatement final : public DsqlStatement }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_STATEMENTS_H diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index bb495acfb52..f09e723287f 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -67,8 +67,9 @@ #include "../jrd/trace/TraceObjects.h" #include "../jrd/trace/TraceJrdHelpers.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { @@ -200,8 +201,6 @@ namespace } } -namespace Jrd { - static const long LONG_POS_MAX = 2147483647; static const SINT64 MAX_INT64_LIMIT = MAX_SINT64 / 10; @@ -306,7 +305,7 @@ TriState LookupValueList::find(thread_db* tdbb, Request* request, const ValueExp void Printable::print(NodePrinter& printer) const { NodePrinter subPrinter(printer.getIndent() + 1); - Firebird::string tag(internalPrint(subPrinter)); + string tag(internalPrint(subPrinter)); printer.begin(tag); printer.append(subPrinter); printer.end(); @@ -562,7 +561,7 @@ string ValueExprNode::internalPrint(NodePrinter& printer) const //-------------------- -Firebird::string ValueListNode::internalPrint(NodePrinter& printer) const +string ValueListNode::internalPrint(NodePrinter& printer) const { ListExprNode::internalPrint(printer); @@ -597,7 +596,7 @@ void ValueListNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) //-------------------- -Firebird::string RecSourceListNode::internalPrint(NodePrinter& printer) const +string RecSourceListNode::internalPrint(NodePrinter& printer) const { ListExprNode::internalPrint(printer); @@ -3711,7 +3710,7 @@ dsc* CastNode::execute(thread_db* tdbb, Request* request) const // Cast from one datatype to another. dsc* CastNode::perform(thread_db* tdbb, impure_value* impure, dsc* value, - const dsc* castDesc, const ItemInfo* itemInfo, const Firebird::string& format) + const dsc* castDesc, const ItemInfo* itemInfo, const string& format) { // If validation is not required and the source value is either NULL // or already in the desired data type, simply return it "as is" @@ -8689,7 +8688,7 @@ bool DsqlMapNode::dsqlMatch(DsqlCompilerScratch* dsqlScratch, const ExprNode* ot //-------------------- -void DerivedFieldNode::getContextNumbers(Firebird::SortedArray& contextNumbers, const DsqlContextStack& contextStack) +void DerivedFieldNode::getContextNumbers(SortedArray& contextNumbers, const DsqlContextStack& contextStack) { for (DsqlContextStack::const_iterator stack(contextStack); stack.hasData(); ++stack) { @@ -10067,7 +10066,7 @@ dsc* ParameterNode::execute(thread_db* tdbb, Request* request) const if (charSet->isMultiByte() && maxCharLength * charSet->maxBytesPerChar() == retDesc->dsc_length) { - Firebird::HalfStaticArray buffer; + HalfStaticArray buffer; retDesc->dsc_length = charSet->substring(retDesc->dsc_length, retDesc->dsc_address, retDesc->dsc_length, buffer.getBuffer(retDesc->dsc_length), 0, @@ -13225,7 +13224,7 @@ DmlNode* UdfCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* for (auto& parameter : node->function(tdbb)->getInputFields()) { - NestConst* argValue; + NestConst* argValue; bool argExists = false; if (parameter->prm_name.hasData()) @@ -13660,7 +13659,7 @@ dsc* UdfCallNode::execute(thread_db* tdbb, Request* request) const try { - Jrd::ContextPoolHolder context(tdbb, funcRequest->req_pool); // Save the old pool. + JrdContextPoolHolder context(tdbb, funcRequest->req_pool); // Save the old pool. funcRequest->setGmtTimeStamp(request->getGmtTimeStamp()); @@ -14363,7 +14362,7 @@ dsc* VariableNode::execute(thread_db* tdbb, Request* request) const //-------------------- -Firebird::string RowsClause::internalPrint(NodePrinter& printer) const +string RowsClause::internalPrint(NodePrinter& printer) const { NODE_PRINT(printer, length); NODE_PRINT(printer, skip); @@ -14375,7 +14374,7 @@ Firebird::string RowsClause::internalPrint(NodePrinter& printer) const //-------------------- -Firebird::string GeneratorItem::internalPrint(NodePrinter& printer) const +string GeneratorItem::internalPrint(NodePrinter& printer) const { NODE_PRINT(printer, id); NODE_PRINT(printer, name); @@ -14490,4 +14489,4 @@ static void setParameterInfo(dsql_par* parameter, const dsql_ctx* context) } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/ExprNodes.h b/src/dsql/ExprNodes.h index 108daf7d984..2fcdcd8ca76 100644 --- a/src/dsql/ExprNodes.h +++ b/src/dsql/ExprNodes.h @@ -31,14 +31,13 @@ #include "../common/classes/TriState.h" #include "../dsql/pass1_proto.h" -class SysFunction; - -namespace Jrd { +namespace Firebird::Jrd { class ItemInfo; class DeclareVariableNode; class SubQuery; class RelationSourceNode; +class SysFunction; class ValueListNode; @@ -80,7 +79,7 @@ class ArithmeticNode final : public TypedNode arg1; NestConst arg2; const UCHAR blrOp; @@ -137,7 +136,7 @@ class ArrayNode final : public TypedNode public: ArrayNode(MemoryPool& pool, FieldNode* aField); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; // This class is used only in the parser. It turns in a FieldNode in dsqlPass. @@ -193,7 +192,7 @@ class AtNode final : public TypedNode holder.add(zoneArg); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -225,7 +224,7 @@ class BoolAsValueNode final : public TypedNode { public: explicit CastNode(MemoryPool& pool, ValueExprNode* aSource = NULL, dsql_fld* aDsqlField = NULL, - const Firebird::string& aFormat = NULL); + const string& aFormat = NULL); static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); @@ -260,7 +259,7 @@ class CastNode final : public TypedNode holder.add(source); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -281,14 +280,14 @@ class CastNode final : public TypedNode ValueExprNode* pass2(thread_db* tdbb, CompilerScratch* csb) override; dsc* execute(thread_db* tdbb, Request* request) const override; static dsc* perform(thread_db* tdbb, impure_value* impure, dsc* value, - const dsc* castDesc, const ItemInfo* itemInfo, const Firebird::string& format = nullptr); + const dsc* castDesc, const ItemInfo* itemInfo, const string& format = nullptr); public: MetaName dsqlAlias; dsql_fld* dsqlField; NestConst source; NestConst itemInfo; - Firebird::string format; + string format; dsc castDesc; bool artificial; }; @@ -312,7 +311,7 @@ class CoalesceNode final : public TypedNode holder.add(values); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -631,7 +630,7 @@ class DecodeNode final : public TypedNode dsc* execute(thread_db* tdbb, Request* request) const override; public: - Firebird::string label; + string label; NestConst test; NestConst conditions; NestConst values; @@ -647,7 +646,7 @@ class DefaultNode final : public DsqlNode static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); static ValueExprNode* createFromField(thread_db* tdbb, CompilerScratch* csb, StreamType* map, jrd_fld* fld); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -688,7 +687,7 @@ class DerivedExprNode final : public TypedNode arg; - Firebird::Array internalStreamList; + Array internalStreamList; std::optional cursorNumber; }; @@ -743,7 +742,7 @@ class DomainValidationNode final : public TypedNode static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; ValueExprNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, RecordSourceNode** list); @@ -901,7 +900,7 @@ class GenIdNode final : public TypedNode holder.add(arg); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -956,7 +955,7 @@ class InternalInfoNode final : public TypedNode public: DsqlMapNode(MemoryPool& pool, dsql_ctx* aContext, dsql_map* aMap); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; bool dsqlAggregateFinder(AggregateFinder& visitor) override; @@ -1147,7 +1146,7 @@ class DerivedFieldNode final : public TypedNode& contextNumbers, const DsqlContextStack& contextStack); + static void getContextNumbers(SortedArray& contextNumbers, const DsqlContextStack& contextStack); void getChildren(NodeRefsHolder& holder, bool dsql) const override { @@ -1157,7 +1156,7 @@ class DerivedFieldNode final : public TypedNode holder.add(arg); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1289,7 +1288,7 @@ class NegateNode final : public TypedNode class NullNode final : public TypedNode { private: - friend class Firebird::GlobalPtr; + friend class GlobalPtr; explicit NullNode(MemoryPool& pool) : TypedNode(pool) @@ -1310,7 +1309,7 @@ class NullNode final : public TypedNode return true; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void setParameterName(dsql_par* parameter) const override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; @@ -1320,7 +1319,7 @@ class NullNode final : public TypedNode dsc* execute(thread_db* tdbb, Request* request) const override; private: - static Firebird::GlobalPtr INSTANCE; + static GlobalPtr INSTANCE; }; @@ -1342,7 +1341,7 @@ class OrderNode final : public DsqlNode holder.add(value); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; OrderNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; bool dsqlMatch(DsqlCompilerScratch* dsqlScratch, const ExprNode* other, bool ignoreMapCast) const override; @@ -1384,7 +1383,7 @@ class WindowClause final : public DsqlNode } } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; bool dsqlAggregateFinder(AggregateFinder& visitor) override; @@ -1652,7 +1651,7 @@ class ParameterNode final : public TypedNode holder.add(subscripts); } - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { ValueExprNode::internalPrint(printer); @@ -1867,7 +1866,7 @@ class StmtExprNode final : public TypedNode holder.add(arg); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1983,7 +1982,7 @@ class SubQueryNode final : public TypedNode holder.add(trimChars); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void setParameterName(dsql_par* parameter) const override; bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -2196,12 +2195,12 @@ class UdfCallNode final : public TypedNode* temp; + Array* temp; }; public: UdfCallNode(MemoryPool& pool, const QualifiedName& aName = {}, - ValueListNode* aArgs = nullptr, Firebird::ObjectsArray* aDsqlArgNames = nullptr); + ValueListNode* aArgs = nullptr, ObjectsArray* aDsqlArgNames = nullptr); static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); @@ -2212,7 +2211,7 @@ class UdfCallNode final : public TypedNode args; - NestConst> dsqlArgNames; + NestConst> dsqlArgNames; SubRoutine function; private: @@ -2267,7 +2266,7 @@ class ValueIfNode final : public TypedNodetok_ident, str, token->nonReserved}); } } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/Keywords.h b/src/dsql/Keywords.h index 43dff129318..1896857756d 100644 --- a/src/dsql/Keywords.h +++ b/src/dsql/Keywords.h @@ -29,8 +29,7 @@ #include "../jrd/MetaName.h" -namespace Jrd -{ +namespace Firebird::Jrd { class Keywords final { public: @@ -77,8 +76,8 @@ namespace Jrd } private: - Firebird::LeftPooledMap map; + LeftPooledMap map; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_KEYWORDS_H diff --git a/src/dsql/NodePrinter.h b/src/dsql/NodePrinter.h index 156e246658f..5a7a3a67ebd 100644 --- a/src/dsql/NodePrinter.h +++ b/src/dsql/NodePrinter.h @@ -32,7 +32,7 @@ //#define TRIVIAL_NODE_PRINTER -namespace Jrd { +namespace Firebird::Jrd { #ifndef TRIVIAL_NODE_PRINTER @@ -46,7 +46,7 @@ class NodePrinter } public: - void begin(const Firebird::string& s) + void begin(const string& s) { printIndent(); text += "<"; @@ -59,7 +59,7 @@ class NodePrinter void end() { - Firebird::string s = stack.pop(); + string s = stack.pop(); --indent; @@ -69,7 +69,7 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string& s, const MetaName& value) + void print(const string& s, const MetaName& value) { printIndent(); @@ -82,7 +82,7 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string& s, const QualifiedName& value) + void print(const string& s, const QualifiedName& value) { printIndent(); @@ -95,12 +95,12 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string&, const IntlString&) + void print(const string&, const IntlString&) { //// FIXME-PRINT: } - void print(const Firebird::string& s, const Firebird::string& value) + void print(const string& s, const string& value) { printIndent(); @@ -113,7 +113,7 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string& s, bool value) + void print(const string& s, bool value) { printIndent(); @@ -126,118 +126,118 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string& s, SINT64 value) + void print(const string& s, SINT64 value) { printIndent(); - Firebird::string temp; + string temp; temp.printf("<%s>%" QUADFORMAT"d\n", s.c_str(), value, s.c_str()); text += temp; } - void print(const Firebird::string& s, long value) + void print(const string& s, long value) { print(s, (SINT64) value); } - void print(const Firebird::string& s, unsigned long value) + void print(const string& s, unsigned long value) { print(s, (SINT64) value); } - void print(const Firebird::string& s, int value) + void print(const string& s, int value) { print(s, (SINT64) value); } - void print(const Firebird::string& s, unsigned int value) + void print(const string& s, unsigned int value) { print(s, (SINT64) value); } - void print(const Firebird::string& s, USHORT value) + void print(const string& s, USHORT value) { print(s, (SINT64) value); } - void print(const Firebird::string& s, SSHORT value) + void print(const string& s, SSHORT value) { print(s, (SINT64) value); } - void print(const Firebird::string&, const Firebird::UCharBuffer&) + void print(const string&, const UCharBuffer&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsql_ctx&) + void print(const string&, const dsql_ctx&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsql_var&) + void print(const string&, const dsql_var&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsql_fld&) + void print(const string&, const dsql_fld&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsql_map&) + void print(const string&, const dsql_map&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsql_par&) + void print(const string&, const dsql_par&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const ImplicitJoin&) + void print(const string&, const ImplicitJoin&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const dsc&) + void print(const string&, const dsc&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const Format&) + void print(const string&, const Format&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const GeneratorItem&) + void print(const string&, const GeneratorItem&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const RecordSource& recordSource) + void print(const string&, const RecordSource& recordSource) { //// FIXME-PRINT: } - void print(const Firebird::string&, const SubQuery&) + void print(const string&, const SubQuery&) { //// FIXME-PRINT: } - void print(const Firebird::string&, const Cursor&) + void print(const string&, const Cursor&) { //// FIXME-PRINT: } template - void print(const Firebird::string& s, const Firebird::Array& array) + void print(const string& s, const Array& array) { begin(s); for (const T* i = array.begin(); i != array.end(); ++i) { - Firebird::string s2; + string s2; s2.printf("%d", i - array.begin()); print(s2, *i); } @@ -246,17 +246,17 @@ class NodePrinter } template - void print(const Firebird::string& s, const Firebird::ObjectsArray& array) + void print(const string& s, const ObjectsArray& array) { begin(s); unsigned n = 0; - for (typename Firebird::ObjectsArray::const_iterator i = array.begin(); + for (typename ObjectsArray::const_iterator i = array.begin(); i != array.end(); ++i, ++n) { - Firebird::string s2; + string s2; s2.printf("%d", n); print(s2, *i); } @@ -265,38 +265,38 @@ class NodePrinter } template - void print(const Firebird::string& s, const T* array) + void print(const string& s, const T* array) { if (array) print(s, *array); } - void print(const Firebird::string& s, const Firebird::TriState& triState) + void print(const string& s, const TriState& triState) { if (triState.isAssigned()) print(s, triState.asBool()); } template - void print(const Firebird::string& s, const std::optional& optional) + void print(const string& s, const std::optional& optional) { if (optional.has_value()) print(s, optional.value()); } template - void print(const Firebird::string&, const Firebird::Pair&) + void print(const string&, const Pair&) { //// FIXME-PRINT: } template - void print(const Firebird::string& s, const NestConst& ptr) + void print(const string& s, const NestConst& ptr) { print(s, ptr.getObject()); } - void print(const Firebird::string& s, const Printable* printable) + void print(const string& s, const Printable* printable) { printIndent(); text += "<"; @@ -320,7 +320,7 @@ class NodePrinter text += ">\n"; } - void print(const Firebird::string& s, const Printable& printable) + void print(const string& s, const Printable& printable) { print(s, &printable); } @@ -335,7 +335,7 @@ class NodePrinter return indent; } - const Firebird::string& getText() const + const string& getText() const { return text; } @@ -351,8 +351,8 @@ class NodePrinter unsigned indent; private: - Firebird::ObjectsArray stack; - Firebird::string text; + ObjectsArray stack; + string text; }; #else // TRIVIAL_NODE_PRINTER @@ -366,7 +366,7 @@ class NodePrinter } public: - void begin(const Firebird::string& s) + void begin(const string& s) { } @@ -375,7 +375,7 @@ class NodePrinter } template - void print(const Firebird::string& s, const T& value) + void print(const string& s, const T& value) { } @@ -388,7 +388,7 @@ class NodePrinter return 0; } - const Firebird::string getText() const + const string getText() const { return ""; } @@ -397,6 +397,6 @@ class NodePrinter #endif // TRIVIAL_NODE_PRINTER -} // namespace Jrd +} // namespace Firebird::Jrd #endif // DSQL_NODE_PRINTER_H diff --git a/src/dsql/Nodes.h b/src/dsql/Nodes.h index 673d358abe6..25484604e1c 100644 --- a/src/dsql/Nodes.h +++ b/src/dsql/Nodes.h @@ -33,7 +33,7 @@ #include #include -namespace Jrd { +namespace Firebird::Jrd { class AggregateSort; class CompilerScratch; @@ -66,10 +66,10 @@ inline constexpr StreamType STREAM_MAP_LENGTH = MAX_STREAMS + 2; // New formula is simply MAX_STREAMS / BITS_PER_LONG inline constexpr int OPT_STREAM_BITS = MAX_STREAMS / BITS_PER_LONG; // 128 with 4096 streams -typedef Firebird::HalfStaticArray StreamList; -typedef Firebird::SortedArray SortedStreamList; +typedef HalfStaticArray StreamList; +typedef SortedArray SortedStreamList; -typedef Firebird::Array > NestValueArray; +typedef Array > NestValueArray; class Printable @@ -82,7 +82,7 @@ class Printable public: void print(NodePrinter& printer) const; - virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; + virtual string internalPrint(NodePrinter& printer) const = 0; }; @@ -158,7 +158,7 @@ class Node : public Printable doDsqlPass(dsqlScratch, target, node); } - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; virtual void getChildren(NodeRefsHolder& holder, bool dsql) const { @@ -187,8 +187,8 @@ class DdlNode : public Node { if (name == SYSTEM_SCHEMA) { - Firebird::status_exception::raise( - Firebird::Arg::Gds(isc_dyn_cannot_mod_obj_sys_schema) << + status_exception::raise( + Arg::Gds(isc_dyn_cannot_mod_obj_sys_schema) << getObjectName(objType)); } } @@ -232,11 +232,11 @@ class DdlNode : public Node static void executeDdlTrigger(thread_db* tdbb, jrd_tra* transaction, DdlTriggerWhen when, int action, const QualifiedName& objectName, - const QualifiedName& oldNewObjectName, const Firebird::string& sqlText); + const QualifiedName& oldNewObjectName, const string& sqlText); protected: - typedef Firebird::Pair > MetaNameBidPair; - typedef Firebird::GenericMap MetaNameBidMap; + typedef Pair > MetaNameBidPair; + typedef GenericMap MetaNameBidMap; // Return exception code based on combination of create and alter clauses. static ISC_STATUS createAlterCode(bool create, bool alter, ISC_STATUS createCode, @@ -260,14 +260,14 @@ class DdlNode : public Node const QualifiedName& oldNewObjectName); void storeGlobalField(thread_db* tdbb, jrd_tra* transaction, QualifiedName& name, const TypeClause* field, - const Firebird::string& computedSource = "", + const string& computedSource = "", const BlrDebugWriter::BlrData& computedValue = BlrDebugWriter::BlrData()); public: // Prefix DDL exceptions. To be implemented in each command. // Attention: do not store temp strings in Arg::StatusVector, // when needed keep them permanently in command's node. - virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) = 0; + virtual void putErrorPrefix(Arg::StatusVector& statusVector) = 0; virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) = 0; @@ -411,7 +411,7 @@ template static bool nodeIs(const NestConst& } -class NodeRefsHolder : public Firebird::AutoStorage +class NodeRefsHolder : public AutoStorage { public: NodeRefsHolder() @@ -459,7 +459,7 @@ class NodeRefsHolder : public Firebird::AutoStorage } public: - Firebird::HalfStaticArray refs; + HalfStaticArray refs; }; @@ -582,7 +582,7 @@ class ExprNode : public DmlNode virtual Type getType() const = 0; - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; virtual bool dsqlAggregateFinder(AggregateFinder& visitor) { @@ -792,7 +792,7 @@ class BoolExprNode : public ExprNode } BoolExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override = 0; - virtual Firebird::TriState execute(thread_db* tdbb, Request* request) const = 0; + virtual TriState execute(thread_db* tdbb, Request* request) const = 0; }; class ValueExprNode : public ExprNode @@ -804,7 +804,7 @@ class ValueExprNode : public ExprNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; Kind getKind() override { @@ -1050,7 +1050,7 @@ class AggNode : public TypedNode holder.add(arg); } - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; bool dsqlAggregateFinder(AggregateFinder& visitor) override; bool dsqlAggregate2Finder(Aggregate2Finder& visitor) override; @@ -1185,7 +1185,7 @@ class RecordSourceNode : public ExprNode stream = value; } - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; RecordSourceNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override { @@ -1336,7 +1336,7 @@ class ValueListNode : public TypedNode items.clear(); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); @@ -1412,7 +1412,7 @@ class RecSourceListNode : public TypedNode > items; + Array > items; }; @@ -1577,7 +1577,7 @@ class StmtNode : public DmlNode return KIND_STATEMENT; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override { @@ -1591,9 +1591,9 @@ class StmtNode : public DmlNode StmtNode* copy(thread_db* /*tdbb*/, NodeCopier& /*copier*/) const override { fb_assert(false); - Firebird::status_exception::raise( - Firebird::Arg::Gds(isc_cannot_copy_stmt) << - Firebird::Arg::Num(int(getType()))); + status_exception::raise( + Arg::Gds(isc_cannot_copy_stmt) << + Arg::Num(int(getType()))); return NULL; } @@ -1667,7 +1667,7 @@ class RowsClause : public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; public: NestConst length; @@ -1678,7 +1678,7 @@ class RowsClause : public Printable class GeneratorItem : public Printable { public: - GeneratorItem(Firebird::MemoryPool& pool, const QualifiedName& name) + GeneratorItem(MemoryPool& pool, const QualifiedName& name) : id(0), name(pool, name), secName(pool) {} @@ -1691,7 +1691,7 @@ class GeneratorItem : public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; public: SLONG id; @@ -1699,13 +1699,13 @@ class GeneratorItem : public Printable QualifiedName secName; }; -typedef Firebird::Array StreamMap; +typedef Array StreamMap; // Copy sub expressions (including subqueries). class SubExprNodeCopier : private StreamMap, public NodeCopier { public: - SubExprNodeCopier(Firebird::MemoryPool& pool, CompilerScratch* aCsb) + SubExprNodeCopier(MemoryPool& pool, CompilerScratch* aCsb) : NodeCopier(pool, aCsb, getBuffer(STREAM_MAP_LENGTH)) { // Initialize the map so all streams initially resolve to the original number. diff --git a/src/dsql/PackageNodes.epp b/src/dsql/PackageNodes.epp index 42f888c9cb0..92d3b63d34d 100644 --- a/src/dsql/PackageNodes.epp +++ b/src/dsql/PackageNodes.epp @@ -39,16 +39,10 @@ #include "../jrd/scl_proto.h" -using namespace Firebird; - -namespace Jrd { - -using namespace Firebird; - DATABASE DB = STATIC "ODS.RDB"; -//---------------------- +namespace Firebird::Jrd { namespace @@ -1081,4 +1075,4 @@ void DropPackageBodyNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/PackageNodes.h b/src/dsql/PackageNodes.h index 839e3c8d0f6..6ae5af9aca1 100644 --- a/src/dsql/PackageNodes.h +++ b/src/dsql/PackageNodes.h @@ -26,7 +26,7 @@ #include "../dsql/DdlNodes.h" #include "../common/classes/array.h" -namespace Jrd { +namespace Firebird::Jrd { class CreateAlterPackageNode : public DdlNode @@ -83,15 +83,15 @@ class CreateAlterPackageNode : public DdlNode public: DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { statusVector << - Firebird::Arg::Gds(createAlterCode(create, alter, + Arg::Gds(createAlterCode(create, alter, isc_dsql_create_pack_failed, isc_dsql_alter_pack_failed, isc_dsql_create_alter_pack_failed)) << name.toQuotedString(); @@ -108,10 +108,10 @@ class CreateAlterPackageNode : public DdlNode bool create; bool alter; bool createIfNotExistsOnly = false; - Firebird::string source; - Firebird::Array* items; - Firebird::SortedArray functionNames; - Firebird::SortedArray procedureNames; + string source; + Array* items; + SortedArray functionNames; + SortedArray procedureNames; std::optional ssDefiner; private: @@ -129,7 +129,7 @@ class DropPackageNode : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -147,9 +147,9 @@ class DropPackageNode : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_pack_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_pack_failed) << name.toQuotedString(); } public: @@ -178,25 +178,25 @@ class CreatePackageBodyNode : public DdlNode public: DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_create_pack_body_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_create_pack_body_failed) << name.toQuotedString(); } public: QualifiedName name; - Firebird::string source; - Firebird::Array* declaredItems; - Firebird::Array* items; + string source; + Array* declaredItems; + Array* items; bool createIfNotExistsOnly = false; private: - Firebird::string owner; + string owner; }; @@ -210,7 +210,7 @@ class DropPackageBodyNode : public DdlNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void checkPermission(thread_db* tdbb, jrd_tra* transaction) override; void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) override; @@ -224,9 +224,9 @@ class DropPackageBodyNode : public DdlNode } protected: - void putErrorPrefix(Firebird::Arg::StatusVector& statusVector) override + void putErrorPrefix(Arg::StatusVector& statusVector) override { - statusVector << Firebird::Arg::Gds(isc_dsql_drop_pack_body_failed) << name.toQuotedString(); + statusVector << Arg::Gds(isc_dsql_drop_pack_body_failed) << name.toQuotedString(); } public: diff --git a/src/dsql/Parser.cpp b/src/dsql/Parser.cpp index 6a2c9db5fa4..120bfe5cd7b 100644 --- a/src/dsql/Parser.cpp +++ b/src/dsql/Parser.cpp @@ -36,8 +36,8 @@ #define DBL_MAX_10_EXP 308 #endif -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ Parser::Parser(thread_db* tdbb, MemoryPool& pool, MemoryPool* aStatementPool, DsqlCompilerScratch* aScratch, @@ -400,7 +400,7 @@ int Parser::yylexAux() SSHORT c = lex.ptr[-1]; const UCHAR tok_class = classes(c); - char string[MAX_TOKEN_LEN]; + char str[MAX_TOKEN_LEN]; // Depending on tok_class of token, parse token @@ -424,8 +424,8 @@ int Parser::yylexAux() StrMark mark; mark.pos = lex.last_token - lex.start; - char* buffer = string; - SLONG buffer_len = sizeof(string); + char* buffer = str; + SLONG buffer_len = sizeof(str); const char* buffer_end = buffer + buffer_len - 1; char* p = buffer; @@ -435,7 +435,7 @@ int Parser::yylexAux() { if (lex.ptr >= lex.end) { - if (buffer != string) + if (buffer != str) gds__free (buffer); yyerror("unterminated string"); return -1; @@ -455,12 +455,12 @@ int Parser::yylexAux() // FREE: at outer block if (!new_buffer) // NOMEM: { - if (buffer != string) + if (buffer != str) gds__free (buffer); return -1; } memcpy (new_buffer, buffer, buffer_len); - if (buffer != string) + if (buffer != str) gds__free (buffer); buffer = new_buffer; p = buffer + buffer_len; @@ -484,7 +484,7 @@ int Parser::yylexAux() if (p - buffer > MAX_STR_SIZE) { - if (buffer != string) + if (buffer != str) gds__free (buffer); ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << @@ -502,7 +502,7 @@ int Parser::yylexAux() if (client_dialect == SQL_DIALECT_V6_TRANSITION) { - if (buffer != string) + if (buffer != str) gds__free (buffer); yyabandon(yyposn, -104, isc_invalid_string_constant); } @@ -510,19 +510,19 @@ int Parser::yylexAux() { if (p - buffer >= MAX_TOKEN_LEN) { - if (buffer != string) + if (buffer != str) gds__free (buffer); yyabandon(yyposn, -104, isc_token_too_long); } else if (p > &buffer[MAX_SQL_IDENTIFIER_LEN]) { - if (buffer != string) + if (buffer != str) gds__free (buffer); yyabandon(yyposn, -104, isc_dyn_name_longer); } else if (p - buffer == 0) { - if (buffer != string) + if (buffer != str) gds__free (buffer); yyabandon(yyposn, -104, isc_dyn_zero_len_id); } @@ -540,14 +540,14 @@ int Parser::yylexAux() yylval.metaNamePtr = FB_NEW_POOL(pool) MetaName(pool, name); - if (buffer != string) + if (buffer != str) gds__free (buffer); return TOK_SYMBOL; } } - yylval.intlStringPtr = newIntlString(Firebird::string(buffer, p - buffer)); - if (buffer != string) + yylval.intlStringPtr = newIntlString(string(buffer, p - buffer)); + if (buffer != str) gds__free (buffer); mark.length = lex.ptr - lex.last_token; @@ -601,7 +601,7 @@ int Parser::yylexAux() ++lex.ptr; bool hexerror = false; - Firebird::string temp; + string temp; // Scan over the hex string converting adjacent bytes into nibble values. // Every other nibble, write the saved byte to the temp space. @@ -762,7 +762,7 @@ int Parser::yylexAux() Arg::Num(MAX_STR_SIZE)); } - yylval.intlStringPtr = newIntlString(Firebird::string(start, len)); + yylval.intlStringPtr = newIntlString(string(start, len)); lex.ptr += endCharSize + 1; @@ -831,7 +831,7 @@ int Parser::yylexAux() // we deal with int128 fb_assert(charlen <= 32); // charlen is always <= 32, see 10-15 lines upper - Firebird::string sbuff(hexstring, charlen); + string sbuff(hexstring, charlen); sbuff.insert(0, "0X"); yylval.lim64ptr = newLim64String(sbuff, 0); @@ -1104,7 +1104,7 @@ int Parser::yylexAux() if (positive_overflow) { yylval.lim64ptr = newLim64String( - Firebird::string(lex.last_token, lex.ptr - lex.last_token), scale); + string(lex.last_token, lex.ptr - lex.last_token), scale); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -1116,7 +1116,7 @@ int Parser::yylexAux() if (have_exp_digit || have_128_over) { yylval.stringPtr = newString( - Firebird::string(lex.last_token, lex.ptr - lex.last_token)); + string(lex.last_token, lex.ptr - lex.last_token)); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -1128,7 +1128,7 @@ int Parser::yylexAux() if (have_overflow) { yylval.lim64ptr = newLim64String( - Firebird::string(lex.last_token, lex.ptr - lex.last_token), scale); + string(lex.last_token, lex.ptr - lex.last_token), scale); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -1163,7 +1163,7 @@ int Parser::yylexAux() * of our message database. */ ERRD_post_warning(Arg::Warning(isc_dsql_warning_number_ambiguous) << - Arg::Str(Firebird::string(lex.last_token, lex.ptr - lex.last_token))); + Arg::Str(string(lex.last_token, lex.ptr - lex.last_token))); ERRD_post_warning(Arg::Warning(isc_dsql_warning_number_ambiguous1)); } @@ -1174,7 +1174,7 @@ int Parser::yylexAux() if (client_dialect < SQL_DIALECT_V6_TRANSITION) { yylval.stringPtr = newString( - Firebird::string(lex.last_token, lex.ptr - lex.last_token)); + string(lex.last_token, lex.ptr - lex.last_token)); return TOK_FLOAT_NUMBER; } @@ -1204,24 +1204,24 @@ int Parser::yylexAux() if (tok_class & CHR_LETTER) { - char* p = string; - check_copy_incr(p, UPPER (c), string); + char* p = str; + check_copy_incr(p, UPPER (c), str); for (; lex.ptr < lex.end && (classes(*lex.ptr) & CHR_IDENT); lex.ptr++) { if (lex.ptr >= lex.end) return -1; - check_copy_incr(p, UPPER (*lex.ptr), string); + check_copy_incr(p, UPPER (*lex.ptr), str); } - check_bound(p, string); + check_bound(p, str); *p = 0; - if (p > &string[MAX_SQL_IDENTIFIER_LEN] || p > &string[METADATA_IDENTIFIER_CHAR_LEN]) + if (p > &str[MAX_SQL_IDENTIFIER_LEN] || p > &str[METADATA_IDENTIFIER_CHAR_LEN]) yyabandon(yyposn, -104, isc_dyn_name_longer); - const MetaName str(string, p - string); + const MetaName metaName(str, p - str); - if (const auto keyVer = dbb->dbb_keywords().get(str); + if (const auto keyVer = dbb->dbb_keywords().get(metaName); keyVer && (keyVer->keyword != TOK_COMMENT || lex.prev_keyword == -1)) { yylval.metaNamePtr = keyVer->str; @@ -1231,7 +1231,7 @@ int Parser::yylexAux() return keyVer->keyword; } - yylval.metaNamePtr = FB_NEW_POOL(pool) MetaName(pool, str); + yylval.metaNamePtr = FB_NEW_POOL(pool) MetaName(pool, metaName); lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; @@ -1242,9 +1242,9 @@ int Parser::yylexAux() if (lex.last_token + 1 < lex.end && !fb_utils::isspace(lex.last_token[1])) { - const MetaName str(lex.last_token, 2); + const MetaName metaName(lex.last_token, 2); - if (const auto keyVer = dbb->dbb_keywords().get(str)) + if (const auto keyVer = dbb->dbb_keywords().get(metaName)) { ++lex.ptr; return keyVer->keyword; @@ -1370,3 +1370,6 @@ void Parser::checkTimeDialect() Arg::Str("TIME")); } } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/Parser.h b/src/dsql/Parser.h index 265a125cc9a..1d16ed79bea 100644 --- a/src/dsql/Parser.h +++ b/src/dsql/Parser.h @@ -38,7 +38,6 @@ #include "../common/classes/stack.h" #include "../jrd/intl.h" -#include "parse.h" namespace Firebird { class CharSet; @@ -48,9 +47,13 @@ namespace Arg { } // namespace } // namespace -namespace Jrd { +namespace Firebird::Jrd +{ + +#include "parse.h" -class Parser : public Firebird::PermanentStorage + +class Parser : public PermanentStorage { private: // User-defined text position type. @@ -141,7 +144,7 @@ class Parser : public Firebird::PermanentStorage public: DsqlStatement* parse(); - const Firebird::string& getTransformedString() const + const string& getTransformedString() const { return transformedString; } @@ -151,17 +154,17 @@ class Parser : public Firebird::PermanentStorage return stmt_ambiguous; } - Firebird::string* newString(const Firebird::string& s) + string* newString(const string& s) { - return FB_NEW_POOL(getPool()) Firebird::string(getPool(), s); + return FB_NEW_POOL(getPool()) string(getPool(), s); } - Lim64String* newLim64String(const Firebird::string& s, int scale) + Lim64String* newLim64String(const string& s, int scale) { return FB_NEW_POOL(getPool()) Lim64String(getPool(), s, scale); } - IntlString* newIntlString(const Firebird::string& s, const char* charSet = NULL) + IntlString* newIntlString(const string& s, const char* charSet = NULL) { return FB_NEW_POOL(getPool()) IntlString(getPool(), s, charSet); } @@ -220,7 +223,7 @@ class Parser : public Firebird::PermanentStorage void check_copy_incr(char*& to, const char ch, const char* const string); void yyabandon(const Position& position, SLONG, ISC_STATUS); - void yyabandon(const Position& position, SLONG, const Firebird::Arg::StatusVector& status); + void yyabandon(const Position& position, SLONG, const Arg::StatusVector& status); MetaName optName(MetaName* name) { @@ -232,8 +235,8 @@ class Parser : public Firebird::PermanentStorage return (name ? *name : QualifiedName()); } - void transformString(const char* start, unsigned length, Firebird::string& dest); - Firebird::string makeParseStr(const Position& p1, const Position& p2); + void transformString(const char* start, unsigned length, string& dest); + string makeParseStr(const Position& p1, const Position& p2); ParameterNode* make_parameter(); // Set the value of a clause, checking if it was already specified. @@ -246,7 +249,7 @@ class Parser : public Firebird::PermanentStorage } template class Delete> - void setClause(Firebird::AutoPtr& clause, const char* duplicateMsg, T* value) + void setClause(AutoPtr& clause, const char* duplicateMsg, T* value) { checkDuplicateClause(clause, duplicateMsg); clause = value; @@ -269,13 +272,13 @@ class Parser : public Firebird::PermanentStorage } } - void setClause(Firebird::TriState& clause, const char* duplicateMsg, bool value) + void setClause(TriState& clause, const char* duplicateMsg, bool value) { checkDuplicateClause(clause, duplicateMsg); clause = value; } - void setClause(Firebird::TriState& clause, const char* duplicateMsg, const Firebird::TriState& value) + void setClause(TriState& clause, const char* duplicateMsg, const TriState& value) { if (value.isAssigned()) { @@ -297,7 +300,6 @@ class Parser : public Firebird::PermanentStorage void setClauseFlag(unsigned& clause, const unsigned flag, const char* duplicateMsg) { - using namespace Firebird; if (clause & flag) { status_exception::raise( @@ -310,7 +312,6 @@ class Parser : public Firebird::PermanentStorage template void checkDuplicateClause(const T& clause, const char* duplicateMsg) { - using namespace Firebird; if (isDuplicateClause(clause)) { status_exception::raise( @@ -335,7 +336,7 @@ class Parser : public Firebird::PermanentStorage return clause.object.hasData(); } - bool isDuplicateClause(const Firebird::TriState& clause) + bool isDuplicateClause(const TriState& clause) { return clause.isAssigned(); } @@ -347,7 +348,7 @@ class Parser : public Firebird::PermanentStorage } template - bool isDuplicateClause(const Firebird::Array& clause) + bool isDuplicateClause(const Array& clause) { return clause.hasData(); } @@ -383,11 +384,11 @@ class Parser : public Firebird::PermanentStorage USHORT db_dialect; const bool requireSemicolon; USHORT parser_version = 0; - Firebird::CharSet* charSet; + CharSet* charSet; - Firebird::CharSet* metadataCharSet; - Firebird::string transformedString; - Firebird::GenericMap > strMarks; + CharSet* metadataCharSet; + string transformedString; + GenericMap > strMarks; bool stmt_ambiguous; DsqlStatement* parsedStatement = nullptr; @@ -433,6 +434,7 @@ class Parser : public Firebird::PermanentStorage LexerState lex; }; -} // namespace + +} // namespace Firebird::Jrd #endif // DSQL_PARSER_H diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 3126fd74ded..928c248ae49 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -66,12 +66,9 @@ #include "../dsql/pass1_proto.h" #include "../dsql/DsqlStatementCache.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd { -namespace Jrd { - template static void dsqlExplodeFields(dsql_rel* relation, Array >& fields, bool includeComputed); static void dsqlGenReturning(DsqlCompilerScratch* dsqlScratch, ReturningClause* returning, @@ -114,8 +111,6 @@ static void restartRequest(const Request* request, jrd_tra* transaction); static void revertParametersOrder(Array& parameters); static void validateExpressions(thread_db* tdbb, const Array& validations); -} // namespace Jrd - namespace { @@ -185,15 +180,12 @@ namespace AutoSavePoint m_savepoint; Savepoint::ChangeMarker m_marker; }; -} // namespace +} // unnamed namespace //-------------------- -namespace Jrd { - - string StmtNode::internalPrint(NodePrinter& printer) const { DmlNode::internalPrint(printer); @@ -579,14 +571,14 @@ const StmtNode* BlockNode::execute(thread_db* tdbb, Request* request, ExeState* // The savepoint of this block will be dealt with below. // Do this only if error handlers exist. Otherwise, leave undo up to callers. - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); while (transaction->tra_save_point && transaction->tra_save_point->getNumber() > savNumber && transaction->tra_save_point->getNext() && transaction->tra_save_point->getNext()->getNumber() > savNumber) { - REPL_save_cleanup(tdbb, transaction, transaction->tra_save_point, true); + Replication::REPL_save_cleanup(tdbb, transaction, transaction->tra_save_point, true); transaction->tra_save_point = transaction->tra_save_point->rollforward(tdbb); } @@ -618,7 +610,7 @@ const StmtNode* BlockNode::execute(thread_db* tdbb, Request* request, ExeState* // request for that invocation of looper. Avoid this. { - Jrd::ContextPoolHolder contextLooper(tdbb, exeState->oldPool); + JrdContextPoolHolder contextLooper(tdbb, exeState->oldPool); tdbb->setRequest(exeState->oldRequest); fb_assert(request->req_caller == exeState->oldRequest); request->req_caller = NULL; @@ -715,7 +707,7 @@ bool BlockNode::testAndFixupError(thread_db* tdbb, Request* request, const Excep if (tdbb->tdbb_flags & TDBB_sys_error) return false; - Jrd::FbStatusVector* statusVector = tdbb->tdbb_status_vector; + FbStatusVector* statusVector = tdbb->tdbb_status_vector; bool found = false; @@ -1541,7 +1533,7 @@ DmlNode* DeclareSubFuncNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerSc subCsb->csb_blr_reader = csb->csb_blr_reader; BlrReader& reader = subCsb->csb_blr_reader; - ContextPoolHolder context(tdbb, &subCsb->csb_pool); + JrdContextPoolHolder context(tdbb, &subCsb->csb_pool); UCHAR type = reader.getByte(); if (type != SUB_ROUTINE_TYPE_PSQL) @@ -1608,7 +1600,7 @@ bool DeclareSubFuncNode::isForwardDecl() const } void DeclareSubFuncNode::parseParameters(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, - Firebird::Array >& paramArray, USHORT* defaultCount) + Array >& paramArray, USHORT* defaultCount) { BlrReader& reader = csb->csb_blr_reader; USHORT count = reader.getWord(); @@ -1864,7 +1856,7 @@ DmlNode* DeclareSubProcNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerSc subCsb->csb_blr_reader = csb->csb_blr_reader; BlrReader& reader = subCsb->csb_blr_reader; - ContextPoolHolder context(tdbb, &subCsb->csb_pool); + JrdContextPoolHolder context(tdbb, &subCsb->csb_pool); UCHAR type = reader.getByte(); if (type != SUB_ROUTINE_TYPE_PSQL) @@ -2790,7 +2782,7 @@ const StmtNode* EraseNode::erase(thread_db* tdbb, Request* request, WhichTrigger return forNode; } - REPL_erase(tdbb, rpb, transaction); + Replication::REPL_erase(tdbb, rpb, transaction); } spPreTriggers.release(); @@ -4048,7 +4040,7 @@ void ExecProcedureNode::executeProcedure(thread_db* tdbb, Request* request) cons ex.stuffException(tdbb->tdbb_status_vector); const bool noPriv = (tdbb->tdbb_status_vector->getErrors()[1] == isc_no_priv); trace.finish(false, - noPriv ? Firebird::ITracePlugin::RESULT_UNAUTHORIZED : ITracePlugin::RESULT_FAILED); + noPriv ? ITracePlugin::RESULT_UNAUTHORIZED : ITracePlugin::RESULT_FAILED); EXE_unwind(tdbb, procRequest); procRequest->req_attachment = NULL; @@ -4591,7 +4583,7 @@ void ExecStatementNode::getString(thread_db* tdbb, Request* request, const Value if (dsc) { - const Jrd::Attachment* att = tdbb->getAttachment(); + const Attachment* att = tdbb->getAttachment(); len = MOV_make_string2(tdbb, dsc, (useAttCS ? TTypeId(att->att_charset) : dsc->getTextType()), &p, buffer, false); } @@ -4758,7 +4750,7 @@ InAutonomousTransactionNode* InAutonomousTransactionNode::pass2(thread_db* tdbb, const StmtNode* InAutonomousTransactionNode::execute(thread_db* tdbb, Request* request, ExeState* /*exeState*/) const { Database* const dbb = tdbb->getDatabase(); - Jrd::Attachment* const attachment = tdbb->getAttachment(); + Attachment* const attachment = tdbb->getAttachment(); Impure* const impure = request->getImpure(impureOffset); @@ -8330,7 +8322,7 @@ const StmtNode* ModifyNode::modify(thread_db* tdbb, Request* request, WhichTrigg } IDX_modify(tdbb, orgRpb, newRpb, transaction); - REPL_modify(tdbb, orgRpb, newRpb, transaction); + Replication::REPL_modify(tdbb, orgRpb, newRpb, transaction); } spPreTriggers.release(); @@ -9399,7 +9391,7 @@ const StmtNode* StoreNode::store(thread_db* tdbb, Request* request, WhichTrigger { VIO_store(tdbb, rpb, transaction); IDX_store(tdbb, rpb, transaction); - REPL_store(tdbb, rpb, transaction); + Replication::REPL_store(tdbb, rpb, transaction); } rpb->rpb_number.setValid(true); @@ -10784,7 +10776,7 @@ void UpdateOrInsertNode::genBlr(DsqlCompilerScratch* dsqlScratch) //-------------------- -Firebird::string CommitRollbackNode::internalPrint(NodePrinter& printer) const +string CommitRollbackNode::internalPrint(NodePrinter& printer) const { TransactionNode::internalPrint(printer); @@ -10848,7 +10840,7 @@ void CommitRollbackNode::execute(thread_db* tdbb, DsqlRequest* request, jrd_tra* //-------------------- -Firebird::string UserSavepointNode::internalPrint(NodePrinter& printer) const +string UserSavepointNode::internalPrint(NodePrinter& printer) const { TransactionNode::internalPrint(printer); @@ -12480,4 +12472,4 @@ static void validateExpressions(thread_db* tdbb, const Array& vali } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/StmtNodes.h b/src/dsql/StmtNodes.h index 901224784ff..0bd91ffe7a2 100644 --- a/src/dsql/StmtNodes.h +++ b/src/dsql/StmtNodes.h @@ -34,7 +34,7 @@ #include "../common/DecFloat.h" #include "../common/classes/TriState.h" -namespace Jrd { +namespace Firebird::Jrd { class CompoundStmtNode; class ExecBlockNode; @@ -46,7 +46,7 @@ class SelectNode; class GeneratorItem; -class ExceptionItem final : public Firebird::PermanentStorage, public Printable +class ExceptionItem final : public PermanentStorage, public Printable { public: enum Type : UCHAR @@ -84,7 +84,7 @@ class ExceptionItem final : public Firebird::PermanentStorage, public Printable } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { NODE_PRINT(printer, type); NODE_PRINT(printer, code); @@ -101,7 +101,7 @@ class ExceptionItem final : public Firebird::PermanentStorage, public Printable QualifiedName secName; }; -typedef Firebird::ObjectsArray ExceptionArray; +typedef ObjectsArray ExceptionArray; struct ValidateInfo @@ -136,7 +136,7 @@ class AssignmentNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; BlockNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -199,7 +199,7 @@ class CompoundStmtNode : public TypedNode > statements; + Array > statements; bool onlyAssignments; }; @@ -228,7 +228,7 @@ class ContinueLeaveNode final : public TypedNode >& paramArray, USHORT* defaultCount = NULL); + Array >& paramArray, USHORT* defaultCount = NULL); void genParameters(DsqlCompilerScratch* dsqlScratch, - Firebird::Array >& paramArray); + Array >& paramArray); public: MetaName name; @@ -447,7 +447,7 @@ class DeclareSubProcNode final : public TypedNode >& paramArray, USHORT* defaultCount = NULL); + Array >& paramArray, USHORT* defaultCount = NULL); void genParameters(DsqlCompilerScratch* dsqlScratch, - Firebird::Array >& paramArray); + Array >& paramArray); public: MetaName name; @@ -497,7 +497,7 @@ class DeclareVariableNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; EraseNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -570,7 +570,7 @@ class ErrorHandlerNode final : public TypedNode* aDsqlInputArgNames = nullptr) + ObjectsArray* aDsqlInputArgNames = nullptr) : TypedNode(pool), dsqlName(pool, aDsqlName), inputSources(aInputs), @@ -602,7 +602,7 @@ class ExecProcedureNode final : public TypedNode outputTargets; NestConst outputMessage; SubRoutine procedure; - NestConst> dsqlInputArgNames; - NestConst> dsqlOutputArgNames; + NestConst> dsqlInputArgNames; + NestConst> dsqlOutputArgNames; bool dsqlCallSyntax = false; }; @@ -654,7 +654,7 @@ class ExecStatementNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; IfNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; IfNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -731,7 +731,7 @@ class InAutonomousTransactionNode final : public TypedNode> parameters; - Firebird::Array> returns; + Array> parameters; + Array> returns; NestConst localDeclList; NestConst body; }; @@ -819,7 +819,7 @@ class ExceptionNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; ExceptionNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -845,7 +845,7 @@ class ExitNode final : public TypedNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; }; @@ -874,7 +874,7 @@ class ForNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ForNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; StmtNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -940,7 +940,7 @@ class ForRangeNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; ForRangeNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -973,7 +973,7 @@ class HandlerNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; HandlerNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; HandlerNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -998,7 +998,7 @@ class LabelNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; LabelNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; LabelNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -1023,7 +1023,7 @@ class LineColumnNode final : public TypedNode>* inputParameters, - const Firebird::Array>* outputParameters); + const Array>* inputParameters, + const Array>* outputParameters); public: LocalDeclarationsNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; public: - Firebird::Array> statements; + Array> statements; }; @@ -1070,7 +1070,7 @@ class LoopNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; LoopNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; LoopNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -1099,7 +1099,7 @@ class MergeNode final : public TypedNode NestConst assignments; NestConst condition; - NestConst modifyRelation; + NestConst modifyRelation; NestValueArray processedFields; NestValueArray processedValues; NestConst processedReturning; @@ -1113,12 +1113,12 @@ class MergeNode final : public TypedNode { } - Firebird::Array> fields; + Array> fields; NestConst values; NestConst condition; std::optional overrideClause; - NestConst storeRelation; + NestConst storeRelation; NestValueArray processedFields; NestConst processedReturning; }; @@ -1132,7 +1132,7 @@ class MergeNode final : public TypedNode { } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; @@ -1140,16 +1140,16 @@ class MergeNode final : public TypedNode NestConst relation; NestConst usingClause; NestConst condition; - Firebird::ObjectsArray whenMatched; - Firebird::ObjectsArray whenNotMatchedByTarget; - Firebird::ObjectsArray whenNotMatchedBySource; + ObjectsArray whenMatched; + ObjectsArray whenNotMatchedByTarget; + ObjectsArray whenNotMatchedBySource; NestConst plan; NestConst order; NestConst returning; NestConst rse; dsql_ctx* oldContext = nullptr; - Firebird::SortedArray usingContexts; + SortedArray usingContexts; }; @@ -1183,7 +1183,7 @@ class MessageNode : public TypedNode virtual USHORT setupDesc(thread_db* tdbb, CompilerScratch* csb, USHORT index, dsc* desc, ItemInfo* itemInfo); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; MessageNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; MessageNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -1218,7 +1218,7 @@ class ModifyNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool updateOrInsert); StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; @@ -1244,7 +1244,7 @@ class ModifyNode final : public TypedNode NestConst statement; NestConst statement2; NestConst subMod; - Firebird::Array validations; + Array validations; NestConst mapView; NestConst forNode; // parent implicit cursor, if present StreamType orgStream = 0; @@ -1266,7 +1266,7 @@ class OuterMapNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& /*printer*/) const override + string internalPrint(NodePrinter& /*printer*/) const override { return "OuterMapNode"; } @@ -1299,7 +1299,7 @@ class PostEventNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; ReceiveNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; ReceiveNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -1354,7 +1354,7 @@ class StoreNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool updateOrInsert, bool& needSavePoint); StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; @@ -1369,14 +1369,14 @@ class StoreNode final : public TypedNode public: NestConst target; - Firebird::Array> dsqlFields; + Array> dsqlFields; NestConst dsqlValues; NestConst dsqlReturning; NestConst dsqlRse; NestConst statement; NestConst statement2; NestConst subStore; - Firebird::Array validations; + Array validations; unsigned marks; std::optional dsqlReturningLocalTableNumber; std::optional overrideClause; @@ -1394,14 +1394,14 @@ class SelectNode final : public TypedNode selectExpr; NestConst rse; - Firebird::TriState optimizeForFirstRows; + TriState optimizeForFirstRows; bool forUpdate = false; bool withLock = false; bool skipLocked = false; @@ -1420,7 +1420,7 @@ class SelectMessageNode final : public TypedNode> statements; + Array> statements; }; @@ -1455,7 +1455,7 @@ class SetGeneratorNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StallNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; StallNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -1506,7 +1506,7 @@ class SuspendNode final : public TypedNode public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; SuspendNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; SuspendNode* pass1(thread_db* tdbb, CompilerScratch* csb) override; @@ -1528,7 +1528,7 @@ class ReturnNode final : public TypedNode(pool), wrapped(aWrapped), text(pool, aText) @@ -1590,7 +1590,7 @@ class SessionManagementWrapperNode final : public TypedNode* aTables, + RestrictionOption(MemoryPool& p, ObjectsArray* aTables, unsigned aLockMode) : PermanentStorage(p), tables(aTables), @@ -1629,7 +1629,7 @@ class SetTransactionNode final : public TransactionNode { } - Firebird::ObjectsArray* tables; + ObjectsArray* tables; unsigned lockMode; }; @@ -1656,7 +1656,7 @@ class SetTransactionNode final : public TransactionNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { TransactionNode::internalPrint(printer); @@ -1683,18 +1683,18 @@ class SetTransactionNode final : public TransactionNode USHORT lockLevel); public: - Firebird::Array reserveList; - Firebird::UCharBuffer tpb; + Array reserveList; + UCharBuffer tpb; std::optional atSnapshotNumber; std::optional isoLevel; std::optional lockTimeout; - Firebird::TriState readOnly; - Firebird::TriState wait; - Firebird::TriState noAutoUndo; - Firebird::TriState ignoreLimbo; - Firebird::TriState restartRequests; - Firebird::TriState autoCommit; - Firebird::TriState autoReleaseTempBlobID; + TriState readOnly; + TriState wait; + TriState noAutoUndo; + TriState ignoreLimbo; + TriState restartRequests; + TriState autoCommit; + TriState autoReleaseTempBlobID; }; @@ -1716,7 +1716,7 @@ class CommitRollbackNode final : public TransactionNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; CommitRollbackNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** transaction) const override; @@ -1746,7 +1746,7 @@ class UserSavepointNode final : public TransactionNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; UserSavepointNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** transaction) const override; @@ -1765,7 +1765,7 @@ class SessionResetNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1794,7 +1794,7 @@ class SetRoleNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1824,7 +1824,7 @@ class SetSessionNode final : public SessionManagementNode SetSessionNode(MemoryPool& pool, Type aType, ULONG aVal, UCHAR blr_timepart); public: - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** traHandle) const override; private: @@ -1839,7 +1839,7 @@ class SetDebugOptionNode final : public SessionManagementNode SetDebugOptionNode(MemoryPool& pool, MetaName* aName, ExprNode* aValue); public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1863,7 +1863,7 @@ class SetDecFloatRoundNode final : public SessionManagementNode SetDecFloatRoundNode(MemoryPool& pool, MetaName* name); public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1889,7 +1889,7 @@ class SetDecFloatTrapsNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1918,7 +1918,7 @@ class SetBindNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1952,7 +1952,7 @@ class SetOptimizeNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1964,21 +1964,21 @@ class SetOptimizeNode final : public SessionManagementNode void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** traHandle) const override; public: - Firebird::TriState optimizeMode; + TriState optimizeMode; }; class SetSearchPathNode final : public SessionManagementNode { public: - SetSearchPathNode(MemoryPool& pool, Firebird::ObjectsArray* aSchemas) + SetSearchPathNode(MemoryPool& pool, ObjectsArray* aSchemas) : SessionManagementNode(pool), schemas(aSchemas) { } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -1990,14 +1990,14 @@ class SetSearchPathNode final : public SessionManagementNode void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** traHandle) const override; public: - NestConst> schemas; + NestConst> schemas; }; class SetTimeZoneNode final : public SessionManagementNode { public: - explicit SetTimeZoneNode(MemoryPool& pool, const Firebird::string& aStr) + explicit SetTimeZoneNode(MemoryPool& pool, const string& aStr) : SessionManagementNode(pool), str(pool, aStr), local(false) @@ -2012,7 +2012,7 @@ class SetTimeZoneNode final : public SessionManagementNode } public: - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { SessionManagementNode::internalPrint(printer); @@ -2025,7 +2025,7 @@ class SetTimeZoneNode final : public SessionManagementNode void execute(thread_db* tdbb, DsqlRequest* request, jrd_tra** traHandle) const override; public: - Firebird::string str; + string str; bool local; }; @@ -2041,7 +2041,7 @@ class TruncateLocalTableNode final : public TypedNode relation; - Firebird::Array> fields; + Array> fields; NestConst values; - Firebird::Array> matching; + Array> matching; NestConst plan; NestConst order; NestConst rows; @@ -2095,7 +2095,7 @@ class UpdateOrInsertNode final : public TypedNode overrideClause; NestConst storeNode; NestConst modifyNode; - Firebird::Array> varAssignments; + Array> varAssignments; }; @@ -2108,12 +2108,12 @@ class UsingNode final : public TypedNode { } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; void genBlr(DsqlCompilerScratch* dsqlScratch) override; public: - Firebird::Array> parameters; + Array> parameters; NestConst localDeclList; NestConst body; }; diff --git a/src/dsql/Visitors.h b/src/dsql/Visitors.h index 4bb7eb0f188..bea68319d7a 100644 --- a/src/dsql/Visitors.h +++ b/src/dsql/Visitors.h @@ -26,7 +26,7 @@ #include "../common/classes/auto.h" #include "../common/classes/NestConst.h" -namespace Jrd { +namespace Firebird::Jrd { class CompilerScratch; class ExprNode; @@ -51,12 +51,12 @@ enum FieldMatchType // Check for an aggregate expression in an expression. It could be buried in an expression // tree and therefore call itselfs again. The level parameters (currentLevel & deepestLevel) // are used to see how deep we are with passing sub-queries (= scope_level). -class AggregateFinder : public Firebird::PermanentStorage +class AggregateFinder : public PermanentStorage { public: - AggregateFinder(Firebird::MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch, bool aWindow); + AggregateFinder(MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch, bool aWindow); - static bool find(Firebird::MemoryPool& pool, DsqlCompilerScratch* dsqlScratch, bool window, ExprNode* node); + static bool find(MemoryPool& pool, DsqlCompilerScratch* dsqlScratch, bool window, ExprNode* node); bool visit(ExprNode* node); @@ -83,13 +83,13 @@ class AggregateFinder : public Firebird::PermanentStorage // NOTE 160 - outer reference is defined in Subclause 6.7, "". // 2) The shall not contain a without an intervening // . -class Aggregate2Finder : public Firebird::PermanentStorage +class Aggregate2Finder : public PermanentStorage { public: - Aggregate2Finder(Firebird::MemoryPool& pool, USHORT aCheckScopeLevel, + Aggregate2Finder(MemoryPool& pool, USHORT aCheckScopeLevel, FieldMatchType aMatchType, bool aWindowOnly); - static bool find(Firebird::MemoryPool& pool, USHORT checkScopeLevel, FieldMatchType matchType, bool windowOnly, + static bool find(MemoryPool& pool, USHORT checkScopeLevel, FieldMatchType matchType, bool windowOnly, ExprNode* node); bool visit(ExprNode* node); @@ -103,12 +103,12 @@ class Aggregate2Finder : public Firebird::PermanentStorage // Check the fields inside an aggregate and check if the field scope_level meets the specified // conditions. -class FieldFinder : public Firebird::PermanentStorage +class FieldFinder : public PermanentStorage { public: - FieldFinder(Firebird::MemoryPool& pool, USHORT aCheckScopeLevel, FieldMatchType aMatchType); + FieldFinder(MemoryPool& pool, USHORT aCheckScopeLevel, FieldMatchType aMatchType); - static bool find(Firebird::MemoryPool& pool, USHORT checkScopeLevel, FieldMatchType matchType, ExprNode* node); + static bool find(MemoryPool& pool, USHORT checkScopeLevel, FieldMatchType matchType, ExprNode* node); bool visit(ExprNode* node); @@ -150,13 +150,13 @@ class InvalidReferenceFinder // Called to map fields used in an aggregate-context after all pass1 calls // (SELECT-, ORDER BY-lists). Walk completly through the given node 'field' and map the fields // with same scope_level as the given context to the given context with the post_map function. -class FieldRemapper : public Firebird::PermanentStorage +class FieldRemapper : public PermanentStorage { public: - FieldRemapper(Firebird::MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch, dsql_ctx* aContext, bool aWindow, + FieldRemapper(MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch, dsql_ctx* aContext, bool aWindow, WindowClause* aWindowNode = NULL); - static ExprNode* remap(Firebird::MemoryPool& pool, DsqlCompilerScratch* dsqlScratch, dsql_ctx* context, bool window, + static ExprNode* remap(MemoryPool& pool, DsqlCompilerScratch* dsqlScratch, dsql_ctx* context, bool window, ExprNode* field, WindowClause* windowNode = NULL) { // The bool value returned by the visitor is completely discarded in this class. @@ -174,7 +174,7 @@ class FieldRemapper : public Firebird::PermanentStorage }; // Search if a sub select is buried inside a select list from a query expression. -class SubSelectFinder : public Firebird::PermanentStorage +class SubSelectFinder : public PermanentStorage { public: SubSelectFinder(MemoryPool& pool) @@ -192,10 +192,10 @@ class SubSelectFinder : public Firebird::PermanentStorage // Generic node copier. -class NodeCopier : public Firebird::PermanentStorage +class NodeCopier : public PermanentStorage { public: - NodeCopier(Firebird::MemoryPool& pool, CompilerScratch* aCsb, StreamType* aRemap) + NodeCopier(MemoryPool& pool, CompilerScratch* aCsb, StreamType* aRemap) : PermanentStorage(pool), csb(aCsb), remap(aRemap), diff --git a/src/dsql/WinNodes.cpp b/src/dsql/WinNodes.cpp index 4f03eceea4c..ca743e9bb69 100644 --- a/src/dsql/WinNodes.cpp +++ b/src/dsql/WinNodes.cpp @@ -30,10 +30,8 @@ #include "../jrd/par_proto.h" #include "../jrd/recsrc/RecordSource.h" -using namespace Firebird; -using namespace Jrd; - -namespace Jrd { +namespace Firebird::Jrd +{ WinFuncNode::WinFuncNode(MemoryPool& pool, const AggInfo& aAggInfo, ValueExprNode* aArg) @@ -890,4 +888,4 @@ AggNode* NTileWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/ } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/dsql/WinNodes.h b/src/dsql/WinNodes.h index bc4cfa8e3e5..ade30314ac1 100644 --- a/src/dsql/WinNodes.h +++ b/src/dsql/WinNodes.h @@ -27,7 +27,7 @@ #include "../dsql/Nodes.h" #include "../dsql/NodePrinter.h" -namespace Jrd { +namespace Firebird::Jrd { // DENSE_RANK function. @@ -46,7 +46,7 @@ class DenseRankWinNode final : public WinFuncNode // nothing } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -75,7 +75,7 @@ class RankWinNode final : public WinFuncNode // nothing } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -108,7 +108,7 @@ class PercentRankWinNode final : public WinFuncNode // nothing } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -143,7 +143,7 @@ class CumeDistWinNode final : public WinFuncNode // nothing } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -173,7 +173,7 @@ class RowNumberWinNode final : public WinFuncNode // nothing } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -197,7 +197,7 @@ class FirstValueWinNode final : public WinFuncNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_WIN_PASS_CALL; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -223,7 +223,7 @@ class LastValueWinNode final : public WinFuncNode return CAP_RESPECTS_WINDOW_FRAME | CAP_WANTS_WIN_PASS_CALL; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -264,7 +264,7 @@ class NthValueWinNode final : public WinFuncNode holder.add(from); } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; @@ -302,7 +302,7 @@ class LagLeadWinNode : public WinFuncNode holder.add(outExpr); } - Firebird::string internalPrint(NodePrinter& printer) const override = 0; + string internalPrint(NodePrinter& printer) const override = 0; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; @@ -325,7 +325,7 @@ class LagWinNode final : public LagLeadWinNode explicit LagWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL, ValueExprNode* aRows = NULL, ValueExprNode* aOutExpr = NULL); - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { LagLeadWinNode::internalPrint(printer); return "LagWinNode"; @@ -344,7 +344,7 @@ class LeadWinNode final : public LagLeadWinNode explicit LeadWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL, ValueExprNode* aRows = NULL, ValueExprNode* aOutExpr = NULL); - Firebird::string internalPrint(NodePrinter& printer) const override + string internalPrint(NodePrinter& printer) const override { LagLeadWinNode::internalPrint(printer); return "LeadWinNode"; @@ -367,7 +367,7 @@ class NTileWinNode final : public WinFuncNode return CAP_SUPPORTS_WINDOW_FRAME | CAP_WANTS_WIN_PASS_CALL; } - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; void make(DsqlCompilerScratch* dsqlScratch, dsc* desc) override; void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) override; ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const override; diff --git a/src/dsql/btyacc_fb.ske b/src/dsql/btyacc_fb.ske index 8bbf430148d..718ef09e7ee 100644 --- a/src/dsql/btyacc_fb.ske +++ b/src/dsql/btyacc_fb.ske @@ -29,9 +29,13 @@ #include "../jrd/RecordSourceNodes.h" #include "../common/classes/PodOptional.h" #include "../common/classes/TriState.h" -#include "parse.h" #include "../dsql/Parser.h" +namespace Firebird::Jrd +{ +#include "parse.h" +} + %% tables #define _C_ "C" diff --git a/src/dsql/ddl.cpp b/src/dsql/ddl.cpp index c45291b3bfc..457fa342a68 100644 --- a/src/dsql/ddl.cpp +++ b/src/dsql/ddl.cpp @@ -83,7 +83,7 @@ #include "../jrd/intl_classes.h" #include "../jrd/jrd.h" #include "../jrd/flags.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../dsql/errd_proto.h" #include "../dsql/ddl_proto.h" #include "../dsql/gen_proto.h" @@ -106,8 +106,8 @@ #include "../common/prett_proto.h" #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ static void assign_field_length(dsql_fld*, USHORT); @@ -124,8 +124,8 @@ bool DDL_ids(const DsqlCompilerScratch* scratch) } -void DDL_resolve_intl_type(DsqlCompilerScratch* dsqlScratch, dsql_fld* field, - QualifiedName& collation_name, bool modifying) +void DDL_resolve_intl_type(DsqlCompilerScratch* dsqlScratch, + dsql_fld* field, QualifiedName& collation_name, bool modifying) { /************************************** * @@ -473,3 +473,6 @@ static void post_607(const Arg::StatusVector& v) err.append(v); ERRD_post(err); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/ddl_proto.h b/src/dsql/ddl_proto.h index f67187cdfaf..f2bff30cd6c 100644 --- a/src/dsql/ddl_proto.h +++ b/src/dsql/ddl_proto.h @@ -30,10 +30,12 @@ // This is a DSQL internal file. Not to be used by anything but // the DSQL module itself. -namespace Jrd { +namespace Firebird::Jrd { class DsqlCompilerScratch; class dsql_fld; -}; +} + +namespace Firebird::Jrd { const USHORT blr_dtypes[] = { 0, @@ -67,8 +69,10 @@ const USHORT blr_dtypes[] = { blr_ex_timestamp_tz // dtype_ex_timestamp_tz }; -bool DDL_ids(const Jrd::DsqlCompilerScratch*); -void DDL_resolve_intl_type(Jrd::DsqlCompilerScratch*, Jrd::dsql_fld*, Jrd::QualifiedName&, - bool = false); +bool DDL_ids(const DsqlCompilerScratch*); +void DDL_resolve_intl_type(DsqlCompilerScratch*, dsql_fld*, QualifiedName&, bool = false); + +} // namespace Firebird::Jrd + #endif // DSQL_DDL_PROTO_H diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 2beb3594acb..e204213cf72 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -81,12 +81,12 @@ #include #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ static ULONG get_request_info(thread_db*, DsqlRequest*, ULONG, UCHAR*); -static dsql_dbb* init(Jrd::thread_db*, Jrd::Attachment*); +static dsql_dbb* init(thread_db*, Attachment*); static DsqlRequest* prepareRequest(thread_db*, dsql_dbb*, jrd_tra*, ULONG, const TEXT*, USHORT, unsigned, bool); static DsqlRequest* safePrepareRequest(thread_db*, dsql_dbb*, jrd_tra*, ULONG, const TEXT*, USHORT, unsigned, bool); static RefPtr prepareStatement(thread_db*, dsql_dbb*, jrd_tra*, ULONG, const TEXT*, USHORT, @@ -158,7 +158,7 @@ void DSQL_execute(thread_db* tdbb, { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); const auto statement = dsqlRequest->getDsqlStatement(); @@ -207,11 +207,12 @@ void DSQL_execute(thread_db* tdbb, @param option **/ -void DSQL_free_statement(thread_db* tdbb, DsqlRequest* dsqlRequest, USHORT option) +void DSQL_free_statement(thread_db* tdbb, + DsqlRequest* dsqlRequest, USHORT option) { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); const auto dsqlStatement = dsqlRequest->getDsqlStatement(); @@ -287,7 +288,7 @@ DsqlRequest* DSQL_prepare(thread_db* tdbb, if (items && buffer) { - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); sql_info(tdbb, dsqlRequest, items->getCount(), items->begin(), buffer->getCount(), buffer->begin()); } @@ -298,7 +299,7 @@ DsqlRequest* DSQL_prepare(thread_db* tdbb, { if (dsqlRequest) { - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); DsqlRequest::destroy(tdbb, dsqlRequest); } throw; @@ -328,14 +329,15 @@ void DSQL_sql_info(thread_db* tdbb, { SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); sql_info(tdbb, dsqlRequest, item_length, items, info_length, info); } // Common part of prepare and execute a statement. -void DSQL_execute_immediate(thread_db* tdbb, Jrd::Attachment* attachment, jrd_tra** tra_handle, +void DSQL_execute_immediate(thread_db* tdbb, + Attachment* attachment, jrd_tra** tra_handle, ULONG length, const TEXT* string, USHORT dialect, IMessageMetadata* in_meta, const UCHAR* in_msg, IMessageMetadata* out_meta, UCHAR* out_msg, @@ -363,7 +365,7 @@ void DSQL_execute_immediate(thread_db* tdbb, Jrd::Attachment* attachment, jrd_tr Arg::Gds(isc_bad_trans_handle)); } - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); // A select having cursor is a singleton select when executed immediate const bool singleton = dsqlStatement->isCursorBased(); @@ -383,7 +385,7 @@ void DSQL_execute_immediate(thread_db* tdbb, Jrd::Attachment* attachment, jrd_tr { if (dsqlRequest) { - Jrd::ContextPoolHolder context(tdbb, &dsqlRequest->getPool()); + JrdContextPoolHolder context(tdbb, &dsqlRequest->getPool()); DsqlRequest::destroy(tdbb, dsqlRequest); } throw; @@ -432,7 +434,7 @@ static ULONG get_request_info(thread_db* tdbb, DsqlRequest* dsqlRequest, ULONG b @param db_handle **/ -static dsql_dbb* init(thread_db* tdbb, Jrd::Attachment* attachment) +static dsql_dbb* init(thread_db* tdbb, Attachment* attachment) { SET_TDBB(tdbb); @@ -581,7 +583,7 @@ static RefPtr prepareStatement(thread_db* tdbb, dsql_dbb* databas DsqlCompilerScratch* scratch = nullptr; MemoryPool* statementPool = database->createPool(); - Jrd::ContextPoolHolder statementContext(tdbb, statementPool); + JrdContextPoolHolder statementContext(tdbb, statementPool); try { scratchPool = database->createPool(); @@ -597,7 +599,7 @@ static RefPtr prepareStatement(thread_db* tdbb, dsql_dbb* databas string transformedText; { // scope to delete parser before the scratch pool is gone - Jrd::ContextPoolHolder scratchContext(tdbb, scratchPool); + JrdContextPoolHolder scratchContext(tdbb, scratchPool); scratch = FB_NEW_POOL(*scratchPool) DsqlCompilerScratch(*scratchPool, database, transaction); scratch->clientDialect = clientDialect; @@ -1167,7 +1169,7 @@ static UCHAR* var_info(const dsql_msg* message, return info; thread_db* tdbb = JRD_get_thread_data(); - Jrd::Attachment* attachment = tdbb->getAttachment(); + Attachment* attachment = tdbb->getAttachment(); HalfStaticArray parameters; @@ -1511,3 +1513,6 @@ dsql_udf::dsql_udf(MemoryPool& p, const class Function* jfun) udf_arguments.add(arg); } } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/dsql.h b/src/dsql/dsql.h index c81cf09dff2..ce7668031fa 100644 --- a/src/dsql/dsql.h +++ b/src/dsql/dsql.h @@ -57,24 +57,13 @@ #define DSQL_DEBUG #endif -#ifdef DSQL_DEBUG -DEFINE_TRACE_ROUTINE(dsql_trace); -#endif - // generic block used as header to all allocated structures #include "../include/fb_blk.h" #include "../dsql/sym.h" +#include "../common/dsc.h" -// Context aliases used in triggers -inline constexpr const char* OLD_CONTEXT_NAME = "OLD"; -inline constexpr const char* NEW_CONTEXT_NAME = "NEW"; - -inline constexpr int OLD_CONTEXT_VALUE = 0; -inline constexpr int NEW_CONTEXT_VALUE = 1; - -namespace Jrd -{ +namespace Firebird::Jrd { class Attachment; class Database; class DsqlCompilerScratch; @@ -97,20 +86,20 @@ namespace Jrd class TimeoutTimer; class MetaName; - typedef Firebird::Stack DsqlContextStack; - typedef Firebird::Pair>> NamedWindowClause; - typedef Firebird::ObjectsArray NamedWindowsClause; -} - -//====================================================================== -// remaining node definitions for local processing -// + typedef Stack DsqlContextStack; + typedef Pair>> NamedWindowClause; + typedef ObjectsArray NamedWindowsClause; -/// Include definition of descriptor +// Context aliases used in triggers +inline constexpr const char* OLD_CONTEXT_NAME = "OLD"; +inline constexpr const char* NEW_CONTEXT_NAME = "NEW"; -#include "../common/dsc.h" +inline constexpr int OLD_CONTEXT_VALUE = 0; +inline constexpr int NEW_CONTEXT_VALUE = 1; -namespace Jrd { +#ifdef DSQL_DEBUG +DEFINE_TRACE_ROUTINE(dsql_trace); +#endif // blocks used to cache metadata @@ -118,15 +107,15 @@ namespace Jrd { class dsql_dbb : public pool_alloc { public: - Firebird::LeftPooledMap dbb_charsets; // known charsets in database - Firebird::LeftPooledMap dbb_collations; // known collations in database - Firebird::NonPooledMap dbb_charsets_by_id; // charsets sorted by charset_id - Firebird::LeftPooledMap dbb_cursors; // known cursors in database - Firebird::AutoPtr dbb_statement_cache; + LeftPooledMap dbb_charsets; // known charsets in database + LeftPooledMap dbb_collations; // known collations in database + NonPooledMap dbb_charsets_by_id; // charsets sorted by charset_id + LeftPooledMap dbb_cursors; // known cursors in database + AutoPtr dbb_statement_cache; MemoryPool& dbb_pool; // The current pool for the dbb Attachment* dbb_attachment; - Firebird::FullPooledMap dbb_schemas_dfl_charset; + FullPooledMap dbb_schemas_dfl_charset; QualifiedName dbb_dfl_charset; bool dbb_no_charset = false; @@ -312,7 +301,7 @@ class dsql_prc : public pool_alloc bool prc_private = false; // Packaged private procedure private: - dsql_fld* cpFields(MemoryPool& p, const Firebird::Array>& fields); + dsql_fld* cpFields(MemoryPool& p, const Array>& fields); }; // prc_flags bits @@ -356,7 +345,7 @@ class dsql_udf : public pool_alloc CSetId udf_character_set_id = CSetId(); USHORT udf_flags = 0; QualifiedName udf_name; - Firebird::Array udf_arguments; + Array udf_arguments; bool udf_private = false; // Packaged private function SSHORT udf_def_count = 0; // number of inputs with default values }; @@ -370,7 +359,7 @@ enum udf_flags_vals { // Variables - input, output & local //! Variable block -class dsql_var : public Firebird::PermanentStorage +class dsql_var : public PermanentStorage { public: enum Type @@ -487,13 +476,13 @@ class dsql_ctx : public pool_alloc USHORT ctx_scope_level = 0; // Subquery level within this request USHORT ctx_flags = 0; // Various flag values USHORT ctx_in_outer_join = 0; // inOuterJoin when context was created - Firebird::ObjectsArray ctx_alias; // Context alias (can include concatenated derived table alias) + ObjectsArray ctx_alias; // Context alias (can include concatenated derived table alias) QualifiedName ctx_internal_alias; // Alias as specified in query DsqlContextStack ctx_main_derived_contexts; // contexts used for blr_derived_expr DsqlContextStack ctx_childs_derived_table; // Childs derived table context - Firebird::LeftPooledMap ctx_imp_join; // Map of USING fieldname to ImplicitJoin - Firebird::Array ctx_win_maps; // Maps for window functions - Firebird::GenericMap ctx_named_windows; + LeftPooledMap ctx_imp_join; // Map of USING fieldname to ImplicitJoin + Array ctx_win_maps; // Maps for window functions + GenericMap ctx_named_windows; dsql_ctx& operator=(dsql_ctx& v) { @@ -519,7 +508,7 @@ class dsql_ctx : public pool_alloc return *this; } - Firebird::string getObjectName() const + string getObjectName() const { if (ctx_relation) return ctx_relation->rel_name.toQuotedString(); @@ -528,7 +517,7 @@ class dsql_ctx : public pool_alloc return ""; } - Firebird::string getConcatenatedAlias() const + string getConcatenatedAlias() const { if (ctx_alias.hasData()) { @@ -574,7 +563,7 @@ class dsql_map : public pool_alloc }; // Message block used in communicating with a running request -class dsql_msg : public Firebird::PermanentStorage +class dsql_msg : public PermanentStorage { public: explicit dsql_msg(MemoryPool& p) @@ -583,7 +572,7 @@ class dsql_msg : public Firebird::PermanentStorage { } - Firebird::Array msg_parameters; // Parameter list + Array msg_parameters; // Parameter list USHORT msg_number = 0; // Message number ULONG msg_length = 0; // Message length USHORT msg_parameter = 0; // Next parameter number @@ -591,7 +580,7 @@ class dsql_msg : public Firebird::PermanentStorage }; // Parameter block used to describe a parameter of a message -class dsql_par : public Firebird::PermanentStorage +class dsql_par : public PermanentStorage { public: explicit dsql_par(MemoryPool& p) @@ -627,39 +616,39 @@ class CStrCmp } }; -typedef Firebird::SortedArray, const char*, - Firebird::DefaultKeyValue, +typedef SortedArray, const char*, + DefaultKeyValue, CStrCmp> StrArray; class IntlString { public: - IntlString(Firebird::MemoryPool& p, const Firebird::string& str, + IntlString(MemoryPool& p, const string& str, const MetaName& cs = NULL) : charset(p, cs), s(p, str) { } - explicit IntlString(const Firebird::string& str, const QualifiedName& cs = {}) + explicit IntlString(const string& str, const QualifiedName& cs = {}) : charset(cs), s(str) { } - IntlString(Firebird::MemoryPool& p, const IntlString& o) + IntlString(MemoryPool& p, const IntlString& o) : charset(p, o.charset), s(p, o.s) { } - explicit IntlString(Firebird::MemoryPool& p) + explicit IntlString(MemoryPool& p) : charset(p), s(p) { } void dsqlPass(DsqlCompilerScratch* dsqlScratch); - Firebird::string toUtf8(jrd_tra* transaction) const; + string toUtf8(jrd_tra* transaction) const; const QualifiedName& getCharSet() const noexcept { @@ -671,7 +660,7 @@ class IntlString charset = value; } - const Firebird::string& getString() const noexcept + const string& getString() const noexcept { return s; } @@ -688,14 +677,14 @@ class IntlString private: QualifiedName charset; - Firebird::string s; + string s; }; -class Lim64String : public Firebird::string +class Lim64String : public string { public: - Lim64String(Firebird::MemoryPool& p, const Firebird::string& str, int sc) - : Firebird::string(p, str), + Lim64String(MemoryPool& p, const string& str, int sc) + : string(p, str), scale(sc) { } @@ -859,7 +848,7 @@ struct Signature flags(o.flags), defined(o.defined) { - for (Firebird::SortedObjectsArray::const_iterator i = o.parameters.begin(); + for (SortedObjectsArray::const_iterator i = o.parameters.begin(); i != o.parameters.end(); ++i) { @@ -877,7 +866,7 @@ struct Signature if (name != o.name || flags != o.flags || parameters.getCount() != o.parameters.getCount()) return false; - for (Firebird::SortedObjectsArray::const_iterator i = parameters.begin(), + for (SortedObjectsArray::const_iterator i = parameters.begin(), j = o.parameters.begin(); i != parameters.end(); ++i, ++j) @@ -895,14 +884,11 @@ struct Signature } MetaName name; - Firebird::SortedObjectsArray parameters; + SortedObjectsArray parameters; unsigned flags = 0; bool defined = false; }; - -} // namespace - /*! \var unsigned DSQL_debug \brief Debug level @@ -921,4 +907,7 @@ struct Signature extern unsigned DSQL_debug; #endif + +} // namespace Firebird::Jrd + #endif // DSQL_DSQL_H diff --git a/src/dsql/dsql_proto.h b/src/dsql/dsql_proto.h index 89a6e2b4c35..2e10626a6b8 100644 --- a/src/dsql/dsql_proto.h +++ b/src/dsql/dsql_proto.h @@ -28,22 +28,24 @@ #include "../common/classes/array.h" #include "firebird/Interface.h" -namespace Jrd { +namespace Firebird::Jrd { class Attachment; + class thread_db; class jrd_tra; class DsqlDmlRequest; class DsqlRequest; } -void DSQL_execute(Jrd::thread_db*, Jrd::jrd_tra**, Jrd::DsqlRequest*, - Firebird::IMessageMetadata*, const UCHAR*, Firebird::IMessageMetadata*, UCHAR*); -void DSQL_execute_immediate(Jrd::thread_db*, Jrd::Attachment*, Jrd::jrd_tra**, - ULONG, const TEXT*, USHORT, Firebird::IMessageMetadata*, const UCHAR*, - Firebird::IMessageMetadata*, UCHAR*, bool); -void DSQL_free_statement(Jrd::thread_db*, Jrd::DsqlRequest*, USHORT); -Jrd::DsqlRequest* DSQL_prepare(Jrd::thread_db*, Jrd::Attachment*, Jrd::jrd_tra*, ULONG, const TEXT*, - USHORT, unsigned, Firebird::Array*, Firebird::Array*, bool); -void DSQL_sql_info(Jrd::thread_db*, Jrd::DsqlRequest*, - ULONG, const UCHAR*, ULONG, UCHAR*); +namespace Firebird::Jrd { + +void DSQL_execute(thread_db*, jrd_tra**, DsqlRequest*, IMessageMetadata*, const UCHAR*, IMessageMetadata*, UCHAR*); +void DSQL_execute_immediate(thread_db*, Attachment*, jrd_tra**, ULONG, const TEXT*, USHORT, + IMessageMetadata*, const UCHAR*, IMessageMetadata*, UCHAR*, bool); +void DSQL_free_statement(thread_db*, DsqlRequest*, USHORT); +DsqlRequest* DSQL_prepare(thread_db*, Attachment*, jrd_tra*, ULONG, const TEXT*, USHORT, unsigned, + Array*, Array*, bool); +void DSQL_sql_info(thread_db*, DsqlRequest*, ULONG, const UCHAR*, ULONG, UCHAR*); + +} // namespace Firebird::Jrd #endif // DSQL_DSQL_PROTO_H diff --git a/src/dsql/errd.cpp b/src/dsql/errd.cpp index 593e42886a2..6d9075b3199 100644 --- a/src/dsql/errd.cpp +++ b/src/dsql/errd.cpp @@ -54,8 +54,8 @@ #include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ [[noreturn]] static void internal_post(const Arg::StatusVector& v); @@ -140,11 +140,11 @@ using namespace Firebird; @param **/ -void ERRD_post_warning(const Firebird::Arg::StatusVector& v) +void ERRD_post_warning(const Arg::StatusVector& v) { fb_assert(v.value()[0] == isc_arg_warning); - Jrd::FbStatusVector* status_vector = JRD_get_thread_data()->tdbb_status_vector; + FbStatusVector* status_vector = JRD_get_thread_data()->tdbb_status_vector; Arg::StatusVector cur(status_vector->getWarnings()); cur << v; @@ -187,7 +187,7 @@ void ERRD_post_warning(const Firebird::Arg::StatusVector& v) [[noreturn]] static void internal_post(const Arg::StatusVector& v) { // start building resulting vector - Jrd::FbStatusVector* status_vector = JRD_get_thread_data()->tdbb_status_vector; + FbStatusVector* status_vector = JRD_get_thread_data()->tdbb_status_vector; Arg::StatusVector final(status_vector->getErrors()); if (final.length() == 0) { @@ -218,7 +218,7 @@ void ERRD_post_warning(const Firebird::Arg::StatusVector& v) **/ -[[noreturn]] void ERRD_punt(const Jrd::FbStatusVector* local) +[[noreturn]] void ERRD_punt(const FbStatusVector* local) { thread_db* tdbb = JRD_get_thread_data(); @@ -230,3 +230,5 @@ void ERRD_post_warning(const Firebird::Arg::StatusVector& v) // Give up whatever we were doing and return to the user. status_exception::raise(tdbb->tdbb_status_vector); } + +} // namespace Firebird::Jrd diff --git a/src/dsql/errd_proto.h b/src/dsql/errd_proto.h index 2b32ca8cd06..a0cde5fb91d 100644 --- a/src/dsql/errd_proto.h +++ b/src/dsql/errd_proto.h @@ -26,15 +26,18 @@ #include "../jrd/status.h" +namespace Firebird::Jrd { + #ifdef DEV_BUILD [[noreturn]] void ERRD_assert_msg(const char*, const char*, ULONG); #endif [[noreturn]] void ERRD_bugcheck(const char*); [[noreturn]] void ERRD_error(const char*); -[[noreturn]] void ERRD_post(const Firebird::Arg::StatusVector& v); -void ERRD_post_warning(const Firebird::Arg::StatusVector& v); -[[noreturn]] void ERRD_punt(const Jrd::FbStatusVector* = 0); +[[noreturn]] void ERRD_post(const Arg::StatusVector& v); +void ERRD_post_warning(const Arg::StatusVector& v); +[[noreturn]] void ERRD_punt(const FbStatusVector* = 0); -#endif // DSQL_ERRD_PROTO_H +} // namespace Firebird::Jrd +#endif // DSQL_ERRD_PROTO_H diff --git a/src/dsql/gen.cpp b/src/dsql/gen.cpp index cefff20795d..95a94129ee8 100644 --- a/src/dsql/gen.cpp +++ b/src/dsql/gen.cpp @@ -44,7 +44,7 @@ #include "../jrd/RecordSourceNodes.h" #include "ibase.h" #include "../jrd/align.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/intl.h" #include "../jrd/jrd.h" #include "../jrd/val.h" @@ -59,8 +59,9 @@ #include "iberror.h" #include "../common/StatusArg.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + static void gen_plan(DsqlCompilerScratch*, const PlanNode*); @@ -173,7 +174,7 @@ void GEN_port(DsqlCompilerScratch* dsqlScratch, dsql_msg* message) class ParamCmp { public: - static int greaterThan(const Jrd::dsql_par* p1, const Jrd::dsql_par* p2) noexcept + static int greaterThan(const dsql_par* p1, const dsql_par* p2) noexcept { return p1->par_index > p2->par_index; } @@ -326,7 +327,7 @@ void GEN_statement(DsqlCompilerScratch* scratch, DmlNode* node) @param texttype **/ -void GEN_descriptor( DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool texttype) +void GEN_descriptor(DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool texttype) { switch (desc->dsc_dtype) { @@ -444,7 +445,7 @@ void GEN_descriptor( DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool tex // Generate a parameter reference. -void GEN_parameter( DsqlCompilerScratch* dsqlScratch, const dsql_par* parameter) +void GEN_parameter(DsqlCompilerScratch* dsqlScratch, const dsql_par* parameter) { const dsql_msg* message = parameter->par_message; @@ -716,10 +717,14 @@ void GEN_stuff_context(DsqlCompilerScratch* dsqlScratch, const dsql_ctx* context // Write a context number into the BLR buffer. Check for possible overflow. -void GEN_stuff_context_number(DsqlCompilerScratch* dsqlScratch, USHORT contextNumber) +void GEN_stuff_context_number(DsqlCompilerScratch* dsqlScratch, + USHORT contextNumber) { if (contextNumber > MAX_UCHAR) ERRD_post(Arg::Gds(isc_too_many_contexts)); dsqlScratch->appendUChar(contextNumber); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/gen_proto.h b/src/dsql/gen_proto.h index 6edf97052be..ebde3fb9c79 100644 --- a/src/dsql/gen_proto.h +++ b/src/dsql/gen_proto.h @@ -24,22 +24,31 @@ #ifndef DSQL_GEN_PROTO_H #define DSQL_GEN_PROTO_H -namespace Jrd -{ +namespace Firebird::Jrd { + class DmlNode; + class DsqlCompilerScratch; class ExprNode; + class RseNode; + class dsql_ctx; + class dsql_msg; + class dsql_par; class ValueListNode; } -void GEN_arg(Jrd::DsqlCompilerScratch*, Jrd::ExprNode*); -void GEN_descriptor(Jrd::DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool texttype); -void GEN_expr(Jrd::DsqlCompilerScratch*, Jrd::ExprNode*); -void GEN_hidden_variables(Jrd::DsqlCompilerScratch* dsqlScratch); -void GEN_parameter(Jrd::DsqlCompilerScratch*, const Jrd::dsql_par*); -void GEN_port(Jrd::DsqlCompilerScratch*, Jrd::dsql_msg*); -void GEN_statement(Jrd::DsqlCompilerScratch*, Jrd::DmlNode*); -void GEN_rse(Jrd::DsqlCompilerScratch*, Jrd::RseNode*); -void GEN_sort(Jrd::DsqlCompilerScratch*, UCHAR, Jrd::ValueListNode*); -void GEN_stuff_context(Jrd::DsqlCompilerScratch*, const Jrd::dsql_ctx*); -void GEN_stuff_context_number(Jrd::DsqlCompilerScratch*, USHORT); +namespace Firebird::Jrd { + +void GEN_arg(DsqlCompilerScratch*, ExprNode*); +void GEN_descriptor(DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool texttype); +void GEN_expr(DsqlCompilerScratch*, ExprNode*); +void GEN_hidden_variables(DsqlCompilerScratch* dsqlScratch); +void GEN_parameter(DsqlCompilerScratch*, const dsql_par*); +void GEN_port(DsqlCompilerScratch*, dsql_msg*); +void GEN_statement(DsqlCompilerScratch*, DmlNode*); +void GEN_rse(DsqlCompilerScratch*, RseNode*); +void GEN_sort(DsqlCompilerScratch*, UCHAR, ValueListNode*); +void GEN_stuff_context(DsqlCompilerScratch*, const dsql_ctx*); +void GEN_stuff_context_number(DsqlCompilerScratch*, USHORT); + +} // namespace Firebird::Jrd #endif // DSQL_GEN_PROTO_H diff --git a/src/dsql/make.cpp b/src/dsql/make.cpp index e30e24359ba..7b50e996f73 100644 --- a/src/dsql/make.cpp +++ b/src/dsql/make.cpp @@ -41,7 +41,7 @@ #include "../dsql/ExprNodes.h" #include "ibase.h" #include "../jrd/intl.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/align.h" #include "../dsql/errd_proto.h" #include "../dsql/make_proto.h" @@ -60,8 +60,9 @@ #include "../common/config/config.h" #include "../common/StatusArg.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + // DsqlDescMaker methods @@ -605,3 +606,6 @@ LiteralNode* MAKE_system_privilege(const char* privilege) return literal; } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/make_proto.h b/src/dsql/make_proto.h index 270161fca9c..8ec50abfdd3 100644 --- a/src/dsql/make_proto.h +++ b/src/dsql/make_proto.h @@ -29,7 +29,7 @@ #include "../dsql/sym.h" #include "../jrd/intl.h" -namespace Jrd { +namespace Firebird::Jrd { class dsql_ctx; class dsql_fld; class TypeClause; @@ -79,16 +79,20 @@ namespace Jrd { }; } +namespace Firebird::Jrd { + +LiteralNode* MAKE_const_slong(SLONG); +LiteralNode* MAKE_const_sint64(SINT64 value, SCHAR scale); +ValueExprNode* MAKE_constant(const char*, dsql_constant_type, SSHORT = 0); +LiteralNode* MAKE_str_constant(IntlString*, CSetId); +FieldNode* MAKE_field(dsql_ctx*, dsql_fld*, ValueListNode*); +void MAKE_field(dsql_fld*, const dsc*); +FieldNode* MAKE_field_name(const char*); +dsql_par* MAKE_parameter(dsql_msg*, bool, bool, USHORT, const ValueExprNode*); +void MAKE_parameter_names(dsql_par*, const ValueExprNode*); +LiteralNode* MAKE_system_privilege(const char*); + +} // namespace Firebird::Jrd -Jrd::LiteralNode* MAKE_const_slong(SLONG); -Jrd::LiteralNode* MAKE_const_sint64(SINT64 value, SCHAR scale); -Jrd::ValueExprNode* MAKE_constant(const char*, Jrd::dsql_constant_type, SSHORT = 0); -Jrd::LiteralNode* MAKE_str_constant(Jrd::IntlString*, CSetId); -Jrd::FieldNode* MAKE_field(Jrd::dsql_ctx*, Jrd::dsql_fld*, Jrd::ValueListNode*); -void MAKE_field(Jrd::dsql_fld*, const dsc*); -Jrd::FieldNode* MAKE_field_name(const char*); -Jrd::dsql_par* MAKE_parameter(Jrd::dsql_msg*, bool, bool, USHORT, const Jrd::ValueExprNode*); -void MAKE_parameter_names(Jrd::dsql_par*, const Jrd::ValueExprNode*); -Jrd::LiteralNode* MAKE_system_privilege(const char*); #endif // DSQL_MAKE_PROTO_H diff --git a/src/dsql/metd.epp b/src/dsql/metd.epp index 60827137d0e..fa2c120236a 100644 --- a/src/dsql/metd.epp +++ b/src/dsql/metd.epp @@ -56,15 +56,15 @@ #include "../common/classes/init.h" #include "../jrd/LocalTemporaryTable.h" -using namespace Jrd; -using namespace Firebird; // NOTE: The static definition of DB and gds_trans by gpre will not // be used by the meta data routines. Each of those routines has // its own local definition of these variables. - DATABASE DB = STATIC "yachts.lnk"; + +namespace Firebird::Jrd { + static void convert_dtype(TypeClause*, SSHORT); namespace @@ -955,7 +955,7 @@ dsql_rel* METD_get_view_base(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra bool METD_get_view_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScratch, - const Jrd::QualifiedName& view_name, const Jrd::QualifiedName& relation_or_alias, + const QualifiedName& view_name, const QualifiedName& relation_or_alias, dsql_rel*& relation, dsql_prc*& procedure) { /************************************** @@ -1055,3 +1055,5 @@ static void convert_dtype(TypeClause* field, SSHORT field_type) } } + +} // namespace Firebird::Jrd diff --git a/src/dsql/metd_proto.h b/src/dsql/metd_proto.h index 883a1853739..2c39a85a428 100644 --- a/src/dsql/metd_proto.h +++ b/src/dsql/metd_proto.h @@ -31,8 +31,8 @@ #include "../common/classes/fb_pair.h" // forward declarations -namespace Jrd { - typedef Firebird::GenericMap MetaNamePairMap; +namespace Firebird::Jrd { + typedef GenericMap MetaNamePairMap; class DsqlRequest; class DsqlCompilerScratch; @@ -43,30 +43,29 @@ namespace Jrd { class dsql_prc; class dsql_rel; class FieldNode; -}; + class TypeClause; -void METD_drop_charset(Jrd::jrd_tra*, const Jrd::QualifiedName&); -void METD_drop_collation(Jrd::jrd_tra*, const Jrd::QualifiedName&); -void METD_drop_relation(Jrd::jrd_tra*, const Jrd::QualifiedName&); +void METD_drop_charset(jrd_tra*, const QualifiedName&); +void METD_drop_collation(jrd_tra*, const QualifiedName&); +void METD_drop_relation(jrd_tra*, const QualifiedName&); + +dsql_intlsym* METD_get_charset(jrd_tra*, const QualifiedName& name); +USHORT METD_get_charset_bpc(jrd_tra*, CSetId); +QualifiedName METD_get_charset_name(jrd_tra*, CSetId); +dsql_intlsym* METD_get_collation(jrd_tra*, const QualifiedName&, CSetId charset_id); +QualifiedName METD_get_database_charset(jrd_tra*); +QualifiedName METD_get_schema_charset(jrd_tra*, const MetaName&); +bool METD_get_domain(jrd_tra*, TypeClause*, const QualifiedName& name); +dsql_udf* METD_get_function(jrd_tra*, DsqlCompilerScratch*, const QualifiedName&); +void METD_get_primary_key(jrd_tra*, const QualifiedName&, Array>&); +dsql_prc* METD_get_procedure(jrd_tra*, DsqlCompilerScratch*, const QualifiedName&); +dsql_rel* METD_get_relation(jrd_tra*, DsqlCompilerScratch*, const QualifiedName&); +bool METD_get_type(jrd_tra*, const MetaName&, const char*, SSHORT*); +dsql_rel* METD_get_view_base(jrd_tra*, DsqlCompilerScratch*, const QualifiedName& viewName, MetaNamePairMap& fields); +bool METD_get_view_relation(jrd_tra*, DsqlCompilerScratch*, const QualifiedName& view_name, + const QualifiedName& relation_or_alias, dsql_rel*& relation, dsql_prc*& procedure); + +} // namespace Firebird::Jrd -Jrd::dsql_intlsym* METD_get_charset(Jrd::jrd_tra*, const Jrd::QualifiedName& name); -USHORT METD_get_charset_bpc(Jrd::jrd_tra*, CSetId); -Jrd::QualifiedName METD_get_charset_name(Jrd::jrd_tra*, CSetId); -Jrd::dsql_intlsym* METD_get_collation(Jrd::jrd_tra*, const Jrd::QualifiedName&, CSetId charset_id); -Jrd::QualifiedName METD_get_database_charset(Jrd::jrd_tra*); -Jrd::QualifiedName METD_get_schema_charset(Jrd::jrd_tra*, const Jrd::MetaName&); -bool METD_get_domain(Jrd::jrd_tra*, class Jrd::TypeClause*, const Jrd::QualifiedName& name); -Jrd::dsql_udf* METD_get_function(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, - const Jrd::QualifiedName&); -void METD_get_primary_key(Jrd::jrd_tra*, const Jrd::QualifiedName&, - Firebird::Array>&); -Jrd::dsql_prc* METD_get_procedure(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, - const Jrd::QualifiedName&); -Jrd::dsql_rel* METD_get_relation(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, const Jrd::QualifiedName&); -bool METD_get_type(Jrd::jrd_tra*, const Jrd::MetaName&, const char*, SSHORT*); -Jrd::dsql_rel* METD_get_view_base(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, const Jrd::QualifiedName& viewName, - Jrd::MetaNamePairMap& fields); -bool METD_get_view_relation(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, const Jrd::QualifiedName& view_name, - const Jrd::QualifiedName& relation_or_alias, Jrd::dsql_rel*& relation, Jrd::dsql_prc*& procedure); #endif // DSQL_METD_PROTO_H diff --git a/src/dsql/movd.cpp b/src/dsql/movd.cpp index af6f8357f35..6fb01e0d77b 100644 --- a/src/dsql/movd.cpp +++ b/src/dsql/movd.cpp @@ -28,8 +28,8 @@ #include "../jrd/mov_proto.h" #include "../dsql/movd_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ // Move (and possible convert) something to something else. @@ -47,3 +47,6 @@ void MOVD_move(thread_db* tdbb, dsc* from, dsc* to) status_exception::raise(newVector); } } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/movd_proto.h b/src/dsql/movd_proto.h index 60f1c18288d..dc9bc510290 100644 --- a/src/dsql/movd_proto.h +++ b/src/dsql/movd_proto.h @@ -24,6 +24,12 @@ #ifndef DSQL_MOVD_PROTO_H #define DSQL_MOVD_PROTO_H -void MOVD_move(Jrd::thread_db* tdbb, dsc*, dsc*); +struct dsc; + +namespace Firebird::Jrd { +class thread_db; +void MOVD_move(thread_db* tdbb, ::dsc*, ::dsc*); +} + #endif // DSQL_MOVD_PROTO_H diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 056d36642de..84e16abd188 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -134,8 +134,8 @@ inline unsigned trigger_type_suffix(const unsigned slot1, const unsigned slot2, #include "../dsql/chars.h" -using namespace Jrd; using namespace Firebird; +using namespace Firebird::Jrd; %} @@ -756,10 +756,10 @@ using namespace Firebird; YYSTYPE() {} - Firebird::PodOptional nullableIntVal; - Firebird::TriState triState; - Firebird::PodOptional nullableSqlSecurityVal; - Firebird::PodOptional nullableOverrideClause; + PodOptional nullableIntVal; + TriState triState; + PodOptional nullableSqlSecurityVal; + PodOptional nullableOverrideClause; struct { bool first; bool second; } boolPair; bool boolVal; int intVal; @@ -767,122 +767,122 @@ using namespace Firebird; SLONG int32Val; SINT64 int64Val; FB_UINT64 uint64Val; - Firebird::PodOptional nullableInt64Val; - Firebird::PodOptional nullableUint64Val; - Jrd::ScaledNumber scaledNumber; + PodOptional nullableInt64Val; + PodOptional nullableUint64Val; + ScaledNumber scaledNumber; UCHAR blrOp; - Jrd::OrderNode::NullsPlacement nullsPlacement; - Jrd::ComparativeBoolNode::DsqlFlag cmpBoolFlag; - Jrd::dsql_fld* legacyField; - Jrd::ReturningClause* returningClause; - Jrd::MetaName* metaNamePtr; - Firebird::ObjectsArray* metaNameArray; - Firebird::ObjectsArray* qualifiedNameArray; - Firebird::PathName* pathNamePtr; - Jrd::QualifiedName* qualifiedNamePtr; - Firebird::string* stringPtr; - Jrd::IntlString* intlStringPtr; - Jrd::Lim64String* lim64ptr; - Jrd::ExternalClause* externalClause; - Firebird::NonPooledPair* namedArgument; - Firebird::NonPooledPair*, Jrd::ValueListNode*>* namedArguments; - Firebird::Array >* parametersClause; - Jrd::WindowClause* windowClause; - Jrd::WindowClause::FrameExtent* windowClauseFrameExtent; - Jrd::WindowClause::Frame* windowClauseFrame; - Jrd::WindowClause::Exclusion windowClauseExclusion; - Jrd::Node* node; - Jrd::ExprNode* exprNode; - Jrd::ValueExprNode* valueExprNode; - Jrd::BoolExprNode* boolExprNode; - Jrd::RecordSourceNode* recSourceNode; - Jrd::RelationSourceNode* relSourceNode; - Jrd::ValueListNode* valueListNode; - Jrd::RecSourceListNode* recSourceListNode; - Jrd::RseNode* rseNode; - Jrd::PlanNode* planNode; - Jrd::PlanNode::AccessType* accessType; - Jrd::StmtNode* stmtNode; - Jrd::DdlNode* ddlNode; - Jrd::SelectExprNode* selectExprNode; - Jrd::WithClause* withClause; - Jrd::RowsClause* rowsClause; - Jrd::FieldNode* fieldNode; - Jrd::DecodeNode* decodeNode; - Firebird::Array* fieldArray; - Firebird::Array >* nestFieldArray; - Jrd::NamedWindowClause* namedWindowClause; - Jrd::NamedWindowsClause* namedWindowsClause; - Jrd::TransactionNode* traNode; - Jrd::SessionManagementNode* mngNode; - Firebird::Array* privilegeArray; - Jrd::GranteeClause* granteeClause; - Firebird::Array* granteeArray; - Jrd::GrantRevokeNode* grantRevokeNode; - Jrd::CreateCollationNode* createCollationNode; - Jrd::CreateDomainNode* createDomainNode; - Jrd::AlterDomainNode* alterDomainNode; - Jrd::CreateAlterFunctionNode* createAlterFunctionNode; - Jrd::CreateAlterProcedureNode* createAlterProcedureNode; - Jrd::CreateAlterTriggerNode* createAlterTriggerNode; - Jrd::CreateAlterPackageNode* createAlterPackageNode; - Jrd::CreateFilterNode::NameNumber* filterNameNumber; - Jrd::CreateAlterExceptionNode* createAlterExceptionNode; - Jrd::CreateAlterSequenceNode* createAlterSequenceNode; - Jrd::CreateAlterSchemaNode* createAlterSchemaNode; - Jrd::CreateFilterNode* createFilterNode; - Jrd::CreateShadowNode* createShadowNode; - Firebird::Array* packageItems; - Jrd::ExceptionArray* exceptionArray; - Jrd::CreateAlterPackageNode::Item packageItem; - Jrd::CreatePackageBodyNode* createPackageBodyNode; - Jrd::BoolSourceClause* boolSourceClause; - Jrd::ValueSourceClause* valueSourceClause; - Jrd::RelationNode* relationNode; - Jrd::RelationNode::AddColumnClause* addColumnClause; - Jrd::RelationNode::AddConstraintClause* addConstraintClause; - Jrd::RelationNode::RefActionClause* refActionClause; - Jrd::RelationNode::IndexConstraintClause* indexConstraintClause; - Jrd::RelationNode::IdentityOptions* identityOptions; + OrderNode::NullsPlacement nullsPlacement; + ComparativeBoolNode::DsqlFlag cmpBoolFlag; + dsql_fld* legacyField; + ReturningClause* returningClause; + MetaName* metaNamePtr; + ObjectsArray* metaNameArray; + ObjectsArray* qualifiedNameArray; + PathName* pathNamePtr; + QualifiedName* qualifiedNamePtr; + string* stringPtr; + IntlString* intlStringPtr; + Lim64String* lim64ptr; + ExternalClause* externalClause; + NonPooledPair* namedArgument; + NonPooledPair*, ValueListNode*>* namedArguments; + Array >* parametersClause; + WindowClause* windowClause; + WindowClause::FrameExtent* windowClauseFrameExtent; + WindowClause::Frame* windowClauseFrame; + WindowClause::Exclusion windowClauseExclusion; + Node* node; + ExprNode* exprNode; + ValueExprNode* valueExprNode; + BoolExprNode* boolExprNode; + RecordSourceNode* recSourceNode; + RelationSourceNode* relSourceNode; + ValueListNode* valueListNode; + RecSourceListNode* recSourceListNode; + RseNode* rseNode; + PlanNode* planNode; + PlanNode::AccessType* accessType; + StmtNode* stmtNode; + DdlNode* ddlNode; + SelectExprNode* selectExprNode; + WithClause* withClause; + RowsClause* rowsClause; + FieldNode* fieldNode; + DecodeNode* decodeNode; + Array* fieldArray; + Array >* nestFieldArray; + NamedWindowClause* namedWindowClause; + NamedWindowsClause* namedWindowsClause; + TransactionNode* traNode; + SessionManagementNode* mngNode; + Array* privilegeArray; + GranteeClause* granteeClause; + Array* granteeArray; + GrantRevokeNode* grantRevokeNode; + CreateCollationNode* createCollationNode; + CreateDomainNode* createDomainNode; + AlterDomainNode* alterDomainNode; + CreateAlterFunctionNode* createAlterFunctionNode; + CreateAlterProcedureNode* createAlterProcedureNode; + CreateAlterTriggerNode* createAlterTriggerNode; + CreateAlterPackageNode* createAlterPackageNode; + CreateFilterNode::NameNumber* filterNameNumber; + CreateAlterExceptionNode* createAlterExceptionNode; + CreateAlterSequenceNode* createAlterSequenceNode; + CreateAlterSchemaNode* createAlterSchemaNode; + CreateFilterNode* createFilterNode; + CreateShadowNode* createShadowNode; + Array* packageItems; + ExceptionArray* exceptionArray; + CreateAlterPackageNode::Item packageItem; + CreatePackageBodyNode* createPackageBodyNode; + BoolSourceClause* boolSourceClause; + ValueSourceClause* valueSourceClause; + RelationNode* relationNode; + RelationNode::AddColumnClause* addColumnClause; + RelationNode::AddConstraintClause* addConstraintClause; + RelationNode::RefActionClause* refActionClause; + RelationNode::IndexConstraintClause* indexConstraintClause; + RelationNode::IdentityOptions* identityOptions; IdentityType identityType; - Jrd::CreateRelationNode* createRelationNode; - Jrd::CreateAlterViewNode* createAlterViewNode; - Jrd::CreateIndexNode* createIndexNode; - Jrd::AlterDatabaseNode* alterDatabaseNode; - Jrd::ExecBlockNode* execBlockNode; - Jrd::StoreNode* storeNode; - Jrd::UpdateOrInsertNode* updInsNode; - Jrd::UsingNode* usingNode; - Jrd::AggNode* aggNode; - Jrd::SysFuncCallNode* sysFuncCallNode; - Jrd::ValueIfNode* valueIfNode; - Jrd::CompoundStmtNode* compoundStmtNode; - Jrd::CursorStmtNode* cursorStmtNode; - Jrd::DeclareCursorNode* declCursorNode; - Jrd::ErrorHandlerNode* errorHandlerNode; - Jrd::ExecStatementNode* execStatementNode; - Jrd::LocalDeclarationsNode* localDeclarationsNode; - Jrd::MergeNode* mergeNode; - Jrd::MergeNode::NotMatched* mergeNotMatchedClause; - Jrd::MergeNode::Matched* mergeMatchedClause; - Jrd::SelectNode* selectNode; - Jrd::ForNode* forNode; - Jrd::SetTransactionNode* setTransactionNode; - Jrd::SetTransactionNode::RestrictionOption* setTransactionRestrictionClause; - Jrd::DeclareSubProcNode* declareSubProcNode; - Jrd::DeclareSubFuncNode* declareSubFuncNode; - Jrd::DsqlStatement* dsqlStatement; - Jrd::CreateAlterUserNode* createAlterUserNode; - Jrd::MappingNode* mappingNode; - Jrd::MappingNode::OP mappingOp; - Jrd::SetRoleNode* setRoleNode; - Jrd::SetSessionNode* setSessionNode; - Jrd::CreateAlterRoleNode* createAlterRoleNode; - Jrd::SetDecFloatRoundNode* setDecFloatRoundNode; - Jrd::SetDecFloatTrapsNode* setDecFloatTrapsNode; - Jrd::SetBindNode* setBindNode; - Jrd::SessionResetNode* sessionResetNode; - Jrd::ForRangeNode::Direction forRangeDirection; + CreateRelationNode* createRelationNode; + CreateAlterViewNode* createAlterViewNode; + CreateIndexNode* createIndexNode; + AlterDatabaseNode* alterDatabaseNode; + ExecBlockNode* execBlockNode; + StoreNode* storeNode; + UpdateOrInsertNode* updInsNode; + UsingNode* usingNode; + AggNode* aggNode; + SysFuncCallNode* sysFuncCallNode; + ValueIfNode* valueIfNode; + CompoundStmtNode* compoundStmtNode; + CursorStmtNode* cursorStmtNode; + DeclareCursorNode* declCursorNode; + ErrorHandlerNode* errorHandlerNode; + ExecStatementNode* execStatementNode; + LocalDeclarationsNode* localDeclarationsNode; + MergeNode* mergeNode; + MergeNode::NotMatched* mergeNotMatchedClause; + MergeNode::Matched* mergeMatchedClause; + SelectNode* selectNode; + ForNode* forNode; + SetTransactionNode* setTransactionNode; + SetTransactionNode::RestrictionOption* setTransactionRestrictionClause; + DeclareSubProcNode* declareSubProcNode; + DeclareSubFuncNode* declareSubFuncNode; + DsqlStatement* dsqlStatement; + CreateAlterUserNode* createAlterUserNode; + MappingNode* mappingNode; + MappingNode::OP mappingOp; + SetRoleNode* setRoleNode; + SetSessionNode* setSessionNode; + CreateAlterRoleNode* createAlterRoleNode; + SetDecFloatRoundNode* setDecFloatRoundNode; + SetDecFloatTrapsNode* setDecFloatTrapsNode; + SetBindNode* setBindNode; + SessionResetNode* sessionResetNode; + ForRangeNode::Direction forRangeDirection; } %include types.y diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index cad9b6cc039..5553bd34a17 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -150,7 +150,7 @@ #include "../jrd/intl.h" #include "firebird/impl/blr.h" #include "../jrd/jrd.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/intl_classes.h" #include "../jrd/RecordSourceNodes.h" #include "../dsql/DdlNodes.h" @@ -175,8 +175,8 @@ #include "../common/config/config.h" #include "../common/StatusArg.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch*, ValueListNode*, ValueListNode*); @@ -3101,3 +3101,6 @@ WindowMap* dsql_ctx::getWindowMap(DsqlCompilerScratch* dsqlScratch, WindowClause return windowMap; } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/pass1_proto.h b/src/dsql/pass1_proto.h index 4eb7e99fe5c..6cb9e8da69a 100644 --- a/src/dsql/pass1_proto.h +++ b/src/dsql/pass1_proto.h @@ -24,7 +24,7 @@ #ifndef DSQL_PASS1_PROTO_H #define DSQL_PASS1_PROTO_H -namespace Jrd +namespace Firebird::Jrd { class CompoundStmtNode; class DeclareCursorNode; @@ -36,32 +36,33 @@ namespace Jrd class SelectNode; class ValueExprNode; class ValueListNode; -} -void PASS1_ambiguity_check(Jrd::DsqlCompilerScratch*, const Jrd::MetaName&, const Jrd::DsqlContextStack&); -bool PASS1_compare_alias(const Jrd::QualifiedName& contextAlias, const Jrd::QualifiedName& lookupAlias); -bool PASS1_compare_alias(const Firebird::ObjectsArray& contextAlias, - const Firebird::ObjectsArray& lookupAlias); -Jrd::BoolExprNode* PASS1_compose(Jrd::BoolExprNode*, Jrd::BoolExprNode*, UCHAR); -Jrd::DeclareCursorNode* PASS1_cursor_name(Jrd::DsqlCompilerScratch*, const Jrd::MetaName&, USHORT, bool); -Jrd::RseNode* PASS1_derived_table(Jrd::DsqlCompilerScratch*, Jrd::SelectExprNode*, const char*, - const Jrd::SelectNode* = nullptr); -void PASS1_expand_contexts(Jrd::DsqlContextStack& contexts, Jrd::dsql_ctx* context); -Jrd::ValueListNode* PASS1_expand_select_list(Jrd::DsqlCompilerScratch*, Jrd::ValueListNode*, Jrd::RecSourceListNode*); -void PASS1_expand_select_node(Jrd::DsqlCompilerScratch*, Jrd::ExprNode*, Jrd::ValueListNode*, bool); -void PASS1_field_unknown(const TEXT*, const TEXT*, const Jrd::ExprNode*); -void PASS1_limit(Jrd::DsqlCompilerScratch*, NestConst, - NestConst, Jrd::RseNode*); -Jrd::ValueExprNode* PASS1_lookup_alias(Jrd::DsqlCompilerScratch*, const Jrd::MetaName&, - Jrd::ValueListNode*, bool); -Jrd::dsql_ctx* PASS1_make_context(Jrd::DsqlCompilerScratch* statement, Jrd::RecordSourceNode* relationNode); -bool PASS1_node_match(Jrd::DsqlCompilerScratch*, const Jrd::ExprNode*, const Jrd::ExprNode*, bool); -Jrd::DsqlMapNode* PASS1_post_map(Jrd::DsqlCompilerScratch*, Jrd::ValueExprNode*, Jrd::dsql_ctx*, - Jrd::WindowClause*); -Jrd::RecordSourceNode* PASS1_relation(Jrd::DsqlCompilerScratch*, Jrd::RecordSourceNode*); -Jrd::RseNode* PASS1_rse(Jrd::DsqlCompilerScratch*, Jrd::SelectExprNode*, const Jrd::SelectNode* = nullptr); -bool PASS1_set_parameter_type(Jrd::DsqlCompilerScratch*, Jrd::ValueExprNode*, std::function, bool); -bool PASS1_set_parameter_type(Jrd::DsqlCompilerScratch*, Jrd::ValueExprNode*, NestConst, bool); -Jrd::ValueListNode* PASS1_sort(Jrd::DsqlCompilerScratch*, Jrd::ValueListNode*, Jrd::ValueListNode*); + void PASS1_ambiguity_check(DsqlCompilerScratch*, const MetaName&, const DsqlContextStack&); + bool PASS1_compare_alias(const QualifiedName& contextAlias, const QualifiedName& lookupAlias); + bool PASS1_compare_alias(const ObjectsArray& contextAlias, + const ObjectsArray& lookupAlias); + BoolExprNode* PASS1_compose(BoolExprNode*, BoolExprNode*, UCHAR); + DeclareCursorNode* PASS1_cursor_name(DsqlCompilerScratch*, const MetaName&, USHORT, bool); + RseNode* PASS1_derived_table(DsqlCompilerScratch*, SelectExprNode*, const char*, + const SelectNode* = nullptr); + void PASS1_expand_contexts(DsqlContextStack& contexts, dsql_ctx* context); + ValueListNode* PASS1_expand_select_list(DsqlCompilerScratch*, ValueListNode*, RecSourceListNode*); + void PASS1_expand_select_node(DsqlCompilerScratch*, ExprNode*, ValueListNode*, bool); + void PASS1_field_unknown(const TEXT*, const TEXT*, const ExprNode*); + void PASS1_limit(DsqlCompilerScratch*, NestConst, + NestConst, RseNode*); + ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch*, const MetaName&, + ValueListNode*, bool); + dsql_ctx* PASS1_make_context(DsqlCompilerScratch* statement, RecordSourceNode* relationNode); + bool PASS1_node_match(DsqlCompilerScratch*, const ExprNode*, const ExprNode*, bool); + DsqlMapNode* PASS1_post_map(DsqlCompilerScratch*, ValueExprNode*, dsql_ctx*, + WindowClause*); + RecordSourceNode* PASS1_relation(DsqlCompilerScratch*, RecordSourceNode*); + RseNode* PASS1_rse(DsqlCompilerScratch*, SelectExprNode*, const SelectNode* = nullptr); + bool PASS1_set_parameter_type(DsqlCompilerScratch*, ValueExprNode*, std::function, bool); + bool PASS1_set_parameter_type(DsqlCompilerScratch*, ValueExprNode*, NestConst, bool); + ValueListNode* PASS1_sort(DsqlCompilerScratch*, ValueListNode*, ValueListNode*); +} // namespace Firebird::Jrd + #endif // DSQL_PASS1_PROTO_H diff --git a/src/dsql/sym.h b/src/dsql/sym.h index e294cbbbd6f..5069ff1cc42 100644 --- a/src/dsql/sym.h +++ b/src/dsql/sym.h @@ -24,7 +24,7 @@ #ifndef DSQL_SYM_H #define DSQL_SYM_H -namespace Jrd { +namespace Firebird::Jrd { // possible symbol types diff --git a/src/dsql/utld.cpp b/src/dsql/utld.cpp index 5d142f77e4f..f46c4ffc19f 100644 --- a/src/dsql/utld.cpp +++ b/src/dsql/utld.cpp @@ -37,12 +37,14 @@ #include "firebird/impl/sqlda_pub.h" #include "ibase.h" #include "../jrd/align.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../dsql/utld_proto.h" #include "../yvalve/gds_proto.h" #include "../common/classes/init.h" -using namespace Jrd; +namespace Firebird::Jrd +{ + /** @@ -59,3 +61,6 @@ USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPerC return MIN(((MAX_COLUMN_SIZE - overhead) / maxBytesPerChar) * maxBytesPerChar, (ULONG) lengthInChars * maxBytesPerChar); } + + +} // namespace Firebird::Jrd diff --git a/src/dsql/utld_proto.h b/src/dsql/utld_proto.h index 4e6039b3495..791ed1dc77d 100644 --- a/src/dsql/utld_proto.h +++ b/src/dsql/utld_proto.h @@ -27,6 +27,9 @@ #ifndef DSQL_UTLD_PROTO_H #define DSQL_UTLD_PROTO_H -USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPerChar, USHORT overhead); +namespace Firebird::Jrd { +USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPerChar, USHORT overhead); +} + #endif // DSQL_UTLD_PROTO_H diff --git a/src/gpre/boot/gpre_meta_boot.cpp b/src/gpre/boot/gpre_meta_boot.cpp index 67f13f4011d..7ff76bfb78f 100644 --- a/src/gpre/boot/gpre_meta_boot.cpp +++ b/src/gpre/boot/gpre_meta_boot.cpp @@ -41,6 +41,10 @@ #include "../gpre/par_proto.h" #include "../yvalve/gds_proto.h" +namespace Firebird::Gpre +{ + + /*____________________________________________________________ * * Lookup a field by name in a context. @@ -677,6 +681,10 @@ bool MET_trigger_exists(gpre_dbb* /*db*/, const TEXT* /*trigger_name*/) return false; } + +} // namespace Firebird::Gpre + + #include "firebird/Interface.h" using namespace Firebird; diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index e5a5025dddc..97a9643db23 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -46,6 +46,10 @@ #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + + static void align(int); static void asgn_from(const act*, ref*, int); static void asgn_to(const act*, ref*, int); @@ -4029,3 +4033,6 @@ static void t_start_auto(const act* action, endp(column); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/cmd.cpp b/src/gpre/cmd.cpp index fd3157ab3c7..7fcba7b4eb1 100644 --- a/src/gpre/cmd.cpp +++ b/src/gpre/cmd.cpp @@ -39,6 +39,10 @@ #include "../gpre/msc_proto.h" #include "../gpre/gpre_meta.h" +namespace Firebird::Gpre +{ + + typedef void (*pfn_local_trigger_cb) (gpre_nod*, gpre_req*); static void alter_database(gpre_req*, act*); @@ -2829,3 +2833,5 @@ static void set_statistics( gpre_req* request, const act* action) request->add_end(); } + +} // namespace Firebird::Gpre diff --git a/src/gpre/cmd_proto.h b/src/gpre/cmd_proto.h index 0db2b49f636..07b0306ce86 100644 --- a/src/gpre/cmd_proto.h +++ b/src/gpre/cmd_proto.h @@ -24,7 +24,9 @@ #ifndef GPRE_CMD_PROTO_H #define GPRE_CMD_PROTO_H -int CMD_compile_ddl(gpre_req*); +namespace Firebird::Gpre +{ + int CMD_compile_ddl(gpre_req*); +} // namespace Firebird::Gpre #endif // GPRE_CMD_PROTO_H - diff --git a/src/gpre/cme.cpp b/src/gpre/cme.cpp index b0da7c359d3..58d8185d524 100644 --- a/src/gpre/cme.cpp +++ b/src/gpre/cme.cpp @@ -44,6 +44,10 @@ #include "../gpre/msc_proto.h" #include "../jrd/align.h" +namespace Firebird::Gpre +{ + + static void cmp_array(gpre_nod*, gpre_req*); static void cmp_array_element(gpre_nod*, gpre_req*); static void cmp_cast(gpre_nod*, gpre_req*); @@ -2451,3 +2455,6 @@ static void get_dtype_of_list(const gpre_nod* node, gpre_fld* f) CPR_error("Incompatible data types"); return; } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/cme_proto.h b/src/gpre/cme_proto.h index cfdca2f4d88..aa5aa1841e8 100644 --- a/src/gpre/cme_proto.h +++ b/src/gpre/cme_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_CME_PROTO_H #define GPRE_CME_PROTO_H +namespace Firebird::Gpre +{ + + void CME_expr(gpre_nod*, gpre_req*); void CME_get_dtype(const gpre_nod*, gpre_fld*); void CME_relation(gpre_ctx*, gpre_req*); @@ -34,4 +38,7 @@ inline void CME_rse(gpre_nod* node, gpre_req* request) CME_rse((gpre_rse*) node, request); } + +} // namespace Firebird::Gpre + #endif // GPRE_CME_PROTO_H diff --git a/src/gpre/cmp.cpp b/src/gpre/cmp.cpp index 936bb8a0b41..666eb57488c 100644 --- a/src/gpre/cmp.cpp +++ b/src/gpre/cmp.cpp @@ -41,6 +41,8 @@ #include "../gpre/msc_proto.h" #include "../gpre/par_proto.h" +namespace Firebird::Gpre +{ static void cmp_any(gpre_req*); @@ -1838,3 +1840,5 @@ static void update_references( ref* references) } } + +} // namespace Firebird::Gpre diff --git a/src/gpre/cmp_proto.h b/src/gpre/cmp_proto.h index f72ec7aaa41..b9b8f8cf2fd 100644 --- a/src/gpre/cmp_proto.h +++ b/src/gpre/cmp_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_CMP_PROTO_H #define GPRE_CMP_PROTO_H +namespace Firebird::Gpre +{ + + void CMP_check(gpre_req*, SSHORT); void CMP_compile_request(gpre_req*); void CMP_external_field(gpre_req*, const gpre_fld*); @@ -32,5 +36,7 @@ ULONG CMP_next_ident(); void CMP_stuff_symbol(gpre_req*, const gpre_sym*); void CMP_t_start(gpre_tra*); -#endif // GPRE_CMP_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_CMP_PROTO_H diff --git a/src/gpre/exp.cpp b/src/gpre/exp.cpp index e60ce7ba727..7c19771aa3f 100644 --- a/src/gpre/exp.cpp +++ b/src/gpre/exp.cpp @@ -43,6 +43,10 @@ #include "../gpre/sqe_proto.h" #include "../gpre/sql_proto.h" +namespace Firebird::Gpre +{ + + constexpr int ZERO_BASED = 0; constexpr int ONE_BASED = 1; @@ -1645,3 +1649,5 @@ static gpre_nod* par_value( gpre_req* request, gpre_fld* field) } } + +} // namespace Firebird::Gpre diff --git a/src/gpre/exp_proto.h b/src/gpre/exp_proto.h index a38df0099c8..0c559afb1a8 100644 --- a/src/gpre/exp_proto.h +++ b/src/gpre/exp_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_EXP_PROTO_H #define GPRE_EXP_PROTO_H +namespace Firebird::Gpre +{ + + gpre_nod* EXP_array(gpre_req*, gpre_fld*, bool, bool); gpre_fld* EXP_cast(gpre_fld*); gpre_ctx* EXP_context(gpre_req*, gpre_sym*); @@ -44,5 +48,7 @@ ULONG EXP_ULONG_ordinal(bool); USHORT EXP_USHORT_ordinal(bool); USHORT EXP_pos_USHORT_ordinal(bool); -#endif // GPRE_EXP_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_EXP_PROTO_H diff --git a/src/gpre/gpre.cpp b/src/gpre/gpre.cpp index 24e04b6829e..d2644cd3d4a 100644 --- a/src/gpre/gpre.cpp +++ b/src/gpre/gpre.cpp @@ -73,6 +73,10 @@ #include #endif +namespace Firebird::Gpre +{ + + // Globals GpreGlobals gpreGlob; @@ -842,7 +846,7 @@ int main(int argc, char* argv[]) while ((end_position = compile_module(end_position, filename_array[3]))) ; // empty loop body } // try - catch (const Firebird::Exception&) {} // fall through to the cleanup code + catch (const Exception&) {} // fall through to the cleanup code #ifdef FTN_BLK_DATA if (gpreGlob.sw_language == lang_fortran) @@ -889,7 +893,7 @@ int main(int argc, char* argv[]) [[noreturn]] void CPR_abort() { ++fatals_global; - //throw Firebird::Exception(); + //throw Exception(); throw gpre_exception("Program terminated."); } @@ -1307,7 +1311,7 @@ static SLONG compile_module( SLONG start_position, const TEXT* base_directory) fseek(input_file, start_position, 0); input_char = input_buffer; - const Firebird::PathName filename = Firebird::TempFile::create(SCRATCH); + const PathName filename = TempFile::create(SCRATCH); strcpy(trace_file_name, filename.c_str()); trace_file = os_utils::fopen(trace_file_name, "w+b"); #ifdef UNIX @@ -2912,3 +2916,12 @@ static SSHORT skip_white() return c; } + + +} // namespace Firebird::Gpre + + +int main(int argc, char* argv[]) +{ + return Firebird::Gpre::main(argc, argv); +} diff --git a/src/gpre/gpre.h b/src/gpre/gpre.h index b00f701bf92..1c5928b3e46 100644 --- a/src/gpre/gpre.h +++ b/src/gpre/gpre.h @@ -65,15 +65,19 @@ #include #include "dyn_consts.h" #include "ibase.h" -#include "../jrd/constants.h" +#include "../common/dsc.h" +#include "../common/constants.h" #include "../jrd/intl.h" +#include "parse.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + static inline constexpr const char* CONST_STR = "const "; -inline constexpr int MAX_SYM_SIZE = 512; // max length of symbol + terminator inline constexpr int NAME_SIZE = 32; inline constexpr int MAX_CURSOR_SIZE = 64; inline constexpr int MAX_REF_SIZE = 32; // references are generated by gpre @@ -1508,9 +1512,6 @@ struct upd { inline constexpr size_t UPD_LEN = sizeof(upd); -#include "../common/dsc.h" -#include "parse.h" - // GPRE wide globals struct GpreGlobals @@ -1608,7 +1609,7 @@ extern GpreGlobals gpreGlob; //#define assert_IS_ACT(x) fb_assert(!(x) || ((x)->act_type >= 0 && (x)->act_type < ACT_LASTACT)) -class gpre_exception: public Firebird::LongJump +class gpre_exception: public LongJump { char msg[MAXPATHLEN << 1]; public: @@ -1626,5 +1627,7 @@ class gpre_exception: public Firebird::LongJump } }; -#endif // GPRE_GPRE_H +} // namespace Firebird::Gpre + +#endif // GPRE_GPRE_H diff --git a/src/gpre/gpre_meta.h b/src/gpre/gpre_meta.h index 8be741316e5..56ab673491f 100644 --- a/src/gpre/gpre_meta.h +++ b/src/gpre/gpre_meta.h @@ -24,6 +24,10 @@ #ifndef GPRE_GPRE_META_H #define GPRE_GPRE_META_H +namespace Firebird::Gpre +{ + + gpre_fld* MET_context_field(gpre_ctx*, const char*); bool MET_database(gpre_dbb*, bool); bool MET_domain_lookup(gpre_req*, gpre_fld*, const char*); @@ -48,5 +52,7 @@ gpre_rel* MET_make_relation(const SCHAR*); bool MET_type(gpre_fld*, const TEXT*, SSHORT*); bool MET_trigger_exists(gpre_dbb*, const TEXT*); -#endif // GPRE_GPRE_META_H +} // namespace Firebird::Gpre + +#endif // GPRE_GPRE_META_H diff --git a/src/gpre/gpre_proto.h b/src/gpre/gpre_proto.h index 62f28c2b5e4..9a6356c5b96 100644 --- a/src/gpre/gpre_proto.h +++ b/src/gpre/gpre_proto.h @@ -26,6 +26,10 @@ #include "../gpre/parse.h" +namespace Firebird::Gpre +{ + + [[noreturn]] void CPR_abort(); #ifdef DEV_BUILD [[noreturn]] void CPR_assert(const TEXT*, int); @@ -41,5 +45,7 @@ void CPR_get_text(TEXT*, const gpre_txt*); gpre_txt* CPR_start_text(); tok* CPR_token(); -#endif // GPRE_GPRE_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_GPRE_PROTO_H diff --git a/src/gpre/gpreswi.h b/src/gpre/gpreswi.h index ebdf228e263..e457353ea8d 100644 --- a/src/gpre/gpreswi.h +++ b/src/gpre/gpreswi.h @@ -48,6 +48,10 @@ // Switch handling constants. Note that IN_SW_COUNT must always be // one larger than the largest switch value +namespace Firebird::Gpre +{ + + enum gpre_cmd_switch { IN_SW_GPRE_0, // not a known switch @@ -198,3 +202,6 @@ const static Switches::in_sw_tab_t gpre_in_sw_table[] = {IN_SW_NO_QLI , 0, "NOQLI" , 0, 0, 0, false, false, 0, 0, "\t\tsuppress QLI syntax"}, {IN_SW_GPRE_0 , 0, NULL , 0, 0, 0, false, false, 0, 0, NULL} }; + + +} // namespace Firebird::Gpre diff --git a/src/gpre/hsh.cpp b/src/gpre/hsh.cpp index 9436902f991..db013d96cd2 100644 --- a/src/gpre/hsh.cpp +++ b/src/gpre/hsh.cpp @@ -33,6 +33,9 @@ #include "../gpre/gpre_proto.h" #include "../gpre/msc_proto.h" +namespace Firebird::Gpre +{ + static int hash(const SCHAR*); static bool scompare(const SCHAR*, const SCHAR*); @@ -273,3 +276,5 @@ static bool scompare2(const SCHAR* string1, const SCHAR* string2) return true; } + +} // namespace Firebird::Gpre diff --git a/src/gpre/hsh_proto.h b/src/gpre/hsh_proto.h index b43fecf1b98..721d01e0e55 100644 --- a/src/gpre/hsh_proto.h +++ b/src/gpre/hsh_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_HSH_PROTO_H #define GPRE_HSH_PROTO_H +namespace Firebird::Gpre +{ + + void HSH_fini(); void HSH_init(); void HSH_insert(gpre_sym*); @@ -31,5 +35,7 @@ gpre_sym* HSH_lookup(const SCHAR*); gpre_sym* HSH_lookup2(const SCHAR*); void HSH_remove(gpre_sym*); -#endif // GPRE_HSH_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_HSH_PROTO_H diff --git a/src/gpre/int_cxx.cpp b/src/gpre/int_cxx.cpp index ae04e0a998f..8bd69563e9d 100644 --- a/src/gpre/int_cxx.cpp +++ b/src/gpre/int_cxx.cpp @@ -36,6 +36,10 @@ #include "../gpre/lang_proto.h" #include "../yvalve/gds_proto.h" +namespace Firebird::Gpre +{ + + static void align(const int); static void asgn_from(ref*, int); #ifdef NOT_USED_OR_REPLACED @@ -738,3 +742,5 @@ static void printa(const int column, const TEXT* string, ...) va_end(ptr); } + +} // namespace Firebird::Gpre diff --git a/src/gpre/jrdme_proto.h b/src/gpre/jrdme_proto.h index 80a08368e37..2b94604ec1b 100644 --- a/src/gpre/jrdme_proto.h +++ b/src/gpre/jrdme_proto.h @@ -24,7 +24,9 @@ #ifndef GPRE_JRDME_PROTO_H #define GPRE_JRDME_PROTO_H -void JRDMET_init(gpre_dbb*); +namespace Firebird::Gpre +{ + void JRDMET_init(gpre_dbb*); +} // namespace Firebird::Gpre #endif // GPRE_JRDME_PROTO_H - diff --git a/src/gpre/jrdmet.cpp b/src/gpre/jrdmet.cpp index d11b6df001f..adfef99e0f4 100644 --- a/src/gpre/jrdmet.cpp +++ b/src/gpre/jrdmet.cpp @@ -28,7 +28,7 @@ #include "firebird.h" #include "ibase.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ods.h" #include "../gpre/gpre.h" @@ -39,6 +39,9 @@ #include "../gpre/jrdme_proto.h" #include "../gpre/msc_proto.h" +namespace Firebird::Gpre +{ + //____________________________________________________________ // @@ -47,6 +50,8 @@ void JRDMET_init( gpre_dbb* db) { + using namespace Jrd; + const int* relfld = relfields; while (relfld[RFLD_R_NAME]) @@ -142,3 +147,5 @@ void JRDMET_init( gpre_dbb* db) } } + +} // namespace Firebird::Gpre diff --git a/src/gpre/lang_proto.h b/src/gpre/lang_proto.h index 2978e5b92a6..604abb43287 100644 --- a/src/gpre/lang_proto.h +++ b/src/gpre/lang_proto.h @@ -26,6 +26,10 @@ #ifndef GPRE_LANG_PROTO_H #define GPRE_LANG_PROTO_H +namespace Firebird::Gpre +{ + + void ADA_action(const act*, int); void ADA_print_buffer(TEXT*, const int); void C_CXX_action(const act*, int); @@ -42,5 +46,7 @@ void PAS_action(const act*, int); void RMC_action(const act*, int); void RMC_print_buffer(TEXT*, bool); -#endif // GPRE_LANG_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_LANG_PROTO_H diff --git a/src/gpre/languages/ada.cpp b/src/gpre/languages/ada.cpp index 63a0b907da3..536b443a99b 100644 --- a/src/gpre/languages/ada.cpp +++ b/src/gpre/languages/ada.cpp @@ -45,6 +45,10 @@ #include #endif +namespace Firebird::Gpre +{ + + static void align (int); static void asgn_from (const act*, ref*, int); static void asgn_to (const act*, ref*, int); @@ -3635,3 +3639,5 @@ static void t_start_auto(const act* action, endp(column); } + +} // namespace Firebird::Gpre diff --git a/src/gpre/languages/cob.cpp b/src/gpre/languages/cob.cpp index 6da2ffcb500..ca3c8315ba5 100644 --- a/src/gpre/languages/cob.cpp +++ b/src/gpre/languages/cob.cpp @@ -57,6 +57,10 @@ #include #endif +namespace Firebird::Gpre +{ + + static const char* const COMMIT = "commit"; static const char* const ROLLBACK = "rollback"; @@ -4287,3 +4291,6 @@ static void t_start_auto(const gpre_req* request, set_sqlcode(action); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/languages/ftn.cpp b/src/gpre/languages/ftn.cpp index 4ec51ebfe1b..d4e855777ff 100644 --- a/src/gpre/languages/ftn.cpp +++ b/src/gpre/languages/ftn.cpp @@ -49,6 +49,10 @@ #include #endif +namespace Firebird::Gpre +{ + + #ifdef NOT_USED_OR_REPLACED static void align (int column); #endif @@ -1315,9 +1319,9 @@ static void gen_database() static void gen_database_data() //(const act* action) { - Firebird::PathName include_buffer; + PathName include_buffer; - include_buffer = fb_utils::getPrefix(Firebird::IConfigManager::DIR_INC, INCLUDE_FTN_FILE); + include_buffer = fb_utils::getPrefix(IConfigManager::DIR_INC, INCLUDE_FTN_FILE); snprintf(output_buffer, sizeof(output_buffer), INCLUDE_ISC_FTN, include_buffer.c_str()); FTN_print_buffer(output_buffer); @@ -4241,3 +4245,5 @@ static void printb(const TEXT* string, ...) } #endif + +} // namespace Firebird::Gpre diff --git a/src/gpre/languages/pas.cpp b/src/gpre/languages/pas.cpp index bce283a9d15..042ec3db04f 100644 --- a/src/gpre/languages/pas.cpp +++ b/src/gpre/languages/pas.cpp @@ -41,6 +41,9 @@ #include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + static void align(const int); static void asgn_from(const act*, const ref*, int); @@ -3489,3 +3492,6 @@ static void t_start_auto( const act* action, const gpre_req* request, set_sqlcode(action, column); ends(column); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/languages/rmc.cpp b/src/gpre/languages/rmc.cpp index f7aa8a168df..658d9c303dd 100644 --- a/src/gpre/languages/rmc.cpp +++ b/src/gpre/languages/rmc.cpp @@ -43,6 +43,10 @@ #include #endif +namespace Firebird::Gpre +{ + + static const char* const COMMIT = "commit"; static const char* const ROLLBACK = "rollback"; @@ -4483,3 +4487,6 @@ static void t_start_auto(const gpre_req* request, set_sqlcode(action); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/movg.cpp b/src/gpre/movg.cpp index 1abe62e9e5c..a7e032fed5d 100644 --- a/src/gpre/movg.cpp +++ b/src/gpre/movg.cpp @@ -39,7 +39,11 @@ #include "../gpre/gpre_proto.h" #include "../common/cvt.h" -static void post_error(const Firebird::Arg::StatusVector&); +namespace Firebird::Gpre +{ + + +static void post_error(const Arg::StatusVector&); //____________________________________________________________ @@ -58,8 +62,11 @@ void MOVG_move(const dsc* from, dsc* to) // A conversion error occurred. Complain. // -static void post_error(const Firebird::Arg::StatusVector&) +static void post_error(const Arg::StatusVector&) { CPR_error("conversion error: illegal string literal"); CPR_abort(); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/movg_proto.h b/src/gpre/movg_proto.h index 1120188da9f..685857da73f 100644 --- a/src/gpre/movg_proto.h +++ b/src/gpre/movg_proto.h @@ -24,7 +24,9 @@ #ifndef GPRE_MOVG_PROTO_H #define GPRE_MOVG_PROTO_H -void MOVG_move(const dsc*, dsc*); +namespace Firebird::Gpre +{ + void MOVG_move(const dsc*, dsc*); +} // namespace Firebird::Gpre #endif // GPRE_MOVG_PROTO_H - diff --git a/src/gpre/msc.cpp b/src/gpre/msc.cpp index b5e78ea5121..589a11b0e3a 100644 --- a/src/gpre/msc.cpp +++ b/src/gpre/msc.cpp @@ -49,6 +49,9 @@ #include "../gpre/msc_proto.h" #include "../yvalve/gds_proto.h" +namespace Firebird::Gpre +{ + struct gpre_space { @@ -520,3 +523,5 @@ gpre_usn* MSC_username(const SCHAR* name, USHORT name_dyn) return username; } + +} // namespace Firebird::Gpre diff --git a/src/gpre/msc_proto.h b/src/gpre/msc_proto.h index 977be195103..ff3011870ae 100644 --- a/src/gpre/msc_proto.h +++ b/src/gpre/msc_proto.h @@ -26,6 +26,10 @@ #include "../gpre/parse.h" +namespace Firebird::Gpre +{ + + act* MSC_action(gpre_req*, act_t); UCHAR* MSC_alloc(int); UCHAR* MSC_alloc_permanent(int); @@ -50,5 +54,7 @@ gpre_nod* MSC_ternary(nod_t, gpre_nod*, gpre_nod*, gpre_nod*); gpre_nod* MSC_unary(nod_t, gpre_nod*); gpre_usn* MSC_username(const SCHAR*, USHORT); -#endif // GPRE_MSC_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_MSC_PROTO_H diff --git a/src/gpre/obj_cxx.cpp b/src/gpre/obj_cxx.cpp index dcc2735d45b..e2441088ccb 100644 --- a/src/gpre/obj_cxx.cpp +++ b/src/gpre/obj_cxx.cpp @@ -45,6 +45,9 @@ #include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + static void align(int); static void asgn_from(const act*, ref*, int); @@ -167,7 +170,7 @@ static inline void set_sqlcode(const act* action, const int column) static inline void ObjectNotImplemented() { CPR_error("Feature is not implemented for object API"); - throw Firebird::LongJump(); + throw LongJump(); } //____________________________________________________________ @@ -4037,3 +4040,6 @@ static void t_start_auto(const act* action, endp(column); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/par.cpp b/src/gpre/par.cpp index bec7cf22e8e..87d40e06e1c 100644 --- a/src/gpre/par.cpp +++ b/src/gpre/par.cpp @@ -57,6 +57,10 @@ #include "../gpre/sql_proto.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + + #ifdef FTN_BLK_DATA static void block_data_list(const gpre_dbb*); #endif @@ -292,7 +296,7 @@ act* PAR_action(const TEXT* base_dir) if (gpreGlob.sw_language == lang_internal || gpreGlob.sw_language == lang_cxx || gpreGlob.sw_language == lang_cplusplus) { - if (CPR_token()) + while (true) { if (gpreGlob.token_global.tok_keyword == KW_L_BRACE) { @@ -301,6 +305,12 @@ act* PAR_action(const TEXT* base_dir) ++brace_count; return NULL; } + + if (gpreGlob.token_global.tok_keyword == KW_SEMI_COLON) + break; + + if (!CPR_token()) + break; } } break; @@ -356,13 +366,13 @@ act* PAR_action(const TEXT* base_dir) catch (const gpre_exception&) { throw; } - catch (const Firebird::fatal_exception&) + catch (const fatal_exception&) { // CVC: a fatal exception should be propagated. // For example, a failure in our runtime. throw; } - catch (const Firebird::Exception&) + catch (const Exception&) { gpreGlob.sw_sql = false; // This is to force GPRE to get the next symbol. Fix for bug #274. DROOT @@ -388,12 +398,12 @@ act* PAR_action(const TEXT* base_dir) catch (const gpre_exception&) { throw; } - catch (const Firebird::fatal_exception&) + catch (const fatal_exception&) { // CVC: a fatal exception should be propagated. throw; } - catch (const Firebird::Exception&) { + catch (const Exception&) { return 0; } case SYM_blob: @@ -404,12 +414,12 @@ act* PAR_action(const TEXT* base_dir) catch (const gpre_exception&) { throw; } - catch (const Firebird::fatal_exception&) + catch (const fatal_exception&) { // CVC: a fatal exception should be propagated. throw; } - catch (const Firebird::Exception&) { + catch (const Exception&) { return 0; } case SYM_relation: @@ -420,12 +430,12 @@ act* PAR_action(const TEXT* base_dir) catch (const gpre_exception&) { throw; } - catch (const Firebird::fatal_exception&) + catch (const fatal_exception&) { // CVC: a fatal exception should be propagated. throw; } - catch (const Firebird::Exception&) { + catch (const Exception&) { return 0; } default: @@ -639,7 +649,7 @@ act* PAR_database(bool sql, const TEXT* base_directory) found_error = true; } // CVC: It avoids countless errors if the db can't be loaded. - catch (const Firebird::Exception& exc) + catch (const Exception& exc) { found_error = true; // CVC: Print the low level error. The lack of this caused me a lot of problems. @@ -1184,7 +1194,7 @@ gpre_sym* PAR_symbol(sym_t type) [[noreturn]] void PAR_unwind() { - throw Firebird::LongJump(); + throw LongJump(); } @@ -2782,11 +2792,8 @@ static act* par_right_brace() if (--brace_count < 0) brace_count = 0; - if (brace_count <= 0) - { - if (--namespace_count < 0) - namespace_count = 0; - } + if (namespace_count > brace_count) + namespace_count = brace_count; return NULL; } @@ -3335,3 +3342,5 @@ static bool terminator() return false; } + +} // namespace Firebird::Gpre diff --git a/src/gpre/par_proto.h b/src/gpre/par_proto.h index 08dae5b447d..75089d2d517 100644 --- a/src/gpre/par_proto.h +++ b/src/gpre/par_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_PAR_PROTO_H #define GPRE_PAR_PROTO_H +namespace Firebird::Gpre +{ + + act* PAR_action(const TEXT*); SSHORT PAR_blob_subtype(gpre_dbb*); act* PAR_database(bool, const TEXT*); @@ -42,5 +46,7 @@ gpre_sym* PAR_symbol(sym_t); [[noreturn]] void PAR_unwind(); void PAR_using_db(); -#endif // GPRE_PAR_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_PAR_PROTO_H diff --git a/src/gpre/parse.h b/src/gpre/parse.h index 4e1b6267501..aa10fa49bd1 100644 --- a/src/gpre/parse.h +++ b/src/gpre/parse.h @@ -27,6 +27,14 @@ #include "../gpre/words.h" #include "../gpre/gpre.h" +namespace Firebird::Gpre +{ + +struct gpre_sym; + +inline constexpr int MAX_SYM_SIZE = 512; // max length of symbol + terminator + + // Token block, used to hold a lexical token. enum tok_t { @@ -69,5 +77,7 @@ inline bool isQuoted(const int typ) noexcept return (typ == tok_sglquoted || typ == tok_dblquoted); } -#endif // GPRE_PARSE_H +} // namespace Firebird + +#endif // GPRE_PARSE_H diff --git a/src/gpre/pat.cpp b/src/gpre/pat.cpp index e0ac289d753..af0c1117015 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -35,6 +35,9 @@ #include "../gpre/pat_proto.h" #include "../gpre/lang_proto.h" +namespace Firebird::Gpre +{ + enum pat_t { NL, @@ -490,3 +493,5 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) } + +} // namespace Firebird::Gpre diff --git a/src/gpre/pat.h b/src/gpre/pat.h index d73f2cee166..27357d702c6 100644 --- a/src/gpre/pat.h +++ b/src/gpre/pat.h @@ -24,6 +24,10 @@ #ifndef GPRE_PAT_H #define GPRE_PAT_H +namespace Firebird::Gpre +{ + + /* Substitution codes: @@ -98,5 +102,7 @@ struct pat typedef pat PAT; -#endif // GPRE_PAT_H +} // namespace Firebird::Gpre + +#endif // GPRE_PAT_H diff --git a/src/gpre/pat_proto.h b/src/gpre/pat_proto.h index a5d01c4bfa0..84df3e188f5 100644 --- a/src/gpre/pat_proto.h +++ b/src/gpre/pat_proto.h @@ -24,7 +24,9 @@ #ifndef GPRE_PAT_PROTO_H #define GPRE_PAT_PROTO_H -void PATTERN_expand(USHORT, const TEXT*, PAT*); +namespace Firebird::Gpre +{ + void PATTERN_expand(USHORT, const TEXT*, PAT*); +} // namespace Firebird::Gpre #endif // GPRE_PAT_PROTO_H - diff --git a/src/gpre/sqe.cpp b/src/gpre/sqe.cpp index 21c598117fe..b1b223e4fa7 100644 --- a/src/gpre/sqe.cpp +++ b/src/gpre/sqe.cpp @@ -55,6 +55,9 @@ #include "../gpre/sql_proto.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + struct scope { @@ -4049,3 +4052,5 @@ static bool validate_references(const gpre_nod* fields, const gpre_nod* group_by return invalid; } + +} // namespace Firebird::Gpre diff --git a/src/gpre/sqe_proto.h b/src/gpre/sqe_proto.h index 27ad18f8b5a..d0f2bf152ec 100644 --- a/src/gpre/sqe_proto.h +++ b/src/gpre/sqe_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_SQE_PROTO_H #define GPRE_SQE_PROTO_H +namespace Firebird::Gpre +{ + + typedef gpre_nod* (*pfn_SQE_list_cb) (gpre_req*, bool, USHORT*, bool*); gpre_nod* SQE_boolean(gpre_req*, USHORT*); @@ -39,5 +43,7 @@ gpre_nod* SQE_value(gpre_req*, bool, USHORT*, bool*); gpre_nod* SQE_value_or_null(gpre_req*, bool, USHORT*, bool*); gpre_nod* SQE_variable(gpre_req*, bool, USHORT*, bool*); -#endif // GPRE_SQE_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_SQE_PROTO_H diff --git a/src/gpre/sql.cpp b/src/gpre/sql.cpp index 4087822cb5a..ad8d0dd7739 100644 --- a/src/gpre/sql.cpp +++ b/src/gpre/sql.cpp @@ -33,7 +33,7 @@ #include "../gpre/gpre.h" #include "ibase.h" #include "../jrd/intl.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../gpre/cme_proto.h" #include "../gpre/cmp_proto.h" #include "../gpre/exp_proto.h" @@ -46,6 +46,9 @@ #include "../gpre/sql_proto.h" #include "../common/utils_proto.h" +namespace Firebird::Gpre +{ + constexpr int DEFAULT_BLOB_SEGMENT_LENGTH = 80; // bytes @@ -6867,3 +6870,6 @@ void SQL_dialect1_bad_type(USHORT field_dtype) "Client SQL dialect 1 does not support reference to the %s datatype", s); PAR_error(buffer); } + + +} // namespace Firebird::Gpre diff --git a/src/gpre/sql_proto.h b/src/gpre/sql_proto.h index 2402bebb247..d2629a8730d 100644 --- a/src/gpre/sql_proto.h +++ b/src/gpre/sql_proto.h @@ -24,6 +24,10 @@ #ifndef GPRE_SQL_PROTO_H #define GPRE_SQL_PROTO_H +namespace Firebird::Gpre +{ + + act* SQL_action(const TEXT*); void SQL_adjust_field_dtype(gpre_fld*); void SQL_dialect1_bad_type(USHORT); @@ -36,5 +40,7 @@ void SQL_relation_name(TEXT*, TEXT*, TEXT*); void SQL_resolve_identifier(const TEXT*, TEXT*, int in_size); TEXT* SQL_var_or_string(bool); -#endif // GPRE_SQL_PROTO_H +} // namespace Firebird::Gpre + +#endif // GPRE_SQL_PROTO_H diff --git a/src/gpre/std/gpre_meta.epp b/src/gpre/std/gpre_meta.epp index 11e1c64812a..a002de97d08 100644 --- a/src/gpre/std/gpre_meta.epp +++ b/src/gpre/std/gpre_meta.epp @@ -42,6 +42,9 @@ #include "../common/utils_proto.h" #include "../common/classes/ClumpletWriter.h" +namespace Firebird::Gpre +{ + constexpr char NEED_IB4_AT_LEAST[] = "Databases before IB4 are not supported"; @@ -158,7 +161,7 @@ bool MET_database(gpre_dbb* database, bool print_version) // generate a dpb for the attach from the specified // compiletime user name and password - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); const TEXT* p; if ((p = database->dbb_c_user)) { @@ -2068,3 +2071,5 @@ static int upcase(const TEXT* from, TEXT* const to) } #endif + +} // namespace Firebird::Gpre diff --git a/src/include/fb_blk.h b/src/include/fb_blk.h index 5f9ed765626..02da161b846 100644 --- a/src/include/fb_blk.h +++ b/src/include/fb_blk.h @@ -6,6 +6,10 @@ #include #endif +namespace Firebird +{ + + enum BlockType { type_unknown = 0, @@ -185,4 +189,7 @@ class pool_alloc_rpt : public TypedHandle void* operator new[](size_t); }; + +} // namespace Firebird + #endif // INCLUDE_FB_BLK diff --git a/src/include/fb_exception.h b/src/include/fb_exception.h index 326b1ecea6b..2931ae9ed44 100644 --- a/src/include/fb_exception.h +++ b/src/include/fb_exception.h @@ -105,7 +105,7 @@ class status_exception : public Exception const ISC_STATUS* value() const noexcept { return m_status_vector; } [[noreturn]] static void raise (const ISC_STATUS* status_vector); - [[noreturn]] static void raise (const Arg::StatusVector& statusVector); + [[noreturn]] static void raise (const Firebird::Arg::StatusVector& statusVector); [[noreturn]] static void raise (const IStatus* status); protected: diff --git a/src/intl/cs_icu.cpp b/src/intl/cs_icu.cpp index 45436e863c6..71c341b3d5e 100644 --- a/src/intl/cs_icu.cpp +++ b/src/intl/cs_icu.cpp @@ -31,6 +31,8 @@ #include #include "../common/unicode_util.h" +using namespace Firebird; + static void charset_destroy(charset* cs) { diff --git a/src/intl/cv_icu.cpp b/src/intl/cv_icu.cpp index 9d967eb9892..9117c7445d8 100644 --- a/src/intl/cv_icu.cpp +++ b/src/intl/cv_icu.cpp @@ -31,6 +31,8 @@ #include #include "../common/unicode_util.h" +using namespace Firebird; + namespace { static void U_EXPORT2 FB_UCNV_FROM_U_CALLBACK_STOP( diff --git a/src/intl/cv_narrow.cpp b/src/intl/cv_narrow.cpp index 359a582c79a..16b0814471a 100644 --- a/src/intl/cv_narrow.cpp +++ b/src/intl/cv_narrow.cpp @@ -26,6 +26,9 @@ #include "ld_proto.h" #include "cv_narrow.h" +using namespace Firebird; + + static void CV_convert_destroy(csconvert* csptr); diff --git a/src/intl/lc_ascii.cpp b/src/intl/lc_ascii.cpp index 35d541c866f..70ef4831312 100644 --- a/src/intl/lc_ascii.cpp +++ b/src/intl/lc_ascii.cpp @@ -29,6 +29,8 @@ #include "ld_proto.h" #include "lc_ascii.h" +using namespace Firebird; + static const ULONG UPPER_EXCEPTIONS_B5[] = { 0x00B5, // #MICRO SIGN diff --git a/src/intl/lc_dos.cpp b/src/intl/lc_dos.cpp index b2e41b35647..af2fd61c0de 100644 --- a/src/intl/lc_dos.cpp +++ b/src/intl/lc_dos.cpp @@ -27,6 +27,8 @@ #include "lc_narrow.h" #include "ld_proto.h" +using namespace Firebird; + static inline bool FAMILY1(texttype* cache, SSHORT country, USHORT flags, diff --git a/src/intl/lc_ksc.cpp b/src/intl/lc_ksc.cpp index 1c23d1c55f7..2b1de40dadc 100644 --- a/src/intl/lc_ksc.cpp +++ b/src/intl/lc_ksc.cpp @@ -27,6 +27,9 @@ #include "cv_ksc.h" #include "ld_proto.h" +using namespace Firebird; + + static USHORT LCKSC_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar, USHORT iOutLen, BYTE *pOutChar, USHORT); static USHORT LCKSC_key_length(texttype* obj, USHORT inLen); diff --git a/src/intl/ldcommon.h b/src/intl/ldcommon.h index 27089c41543..01fb56e9027 100644 --- a/src/intl/ldcommon.h +++ b/src/intl/ldcommon.h @@ -26,7 +26,7 @@ #include "../common/classes/alloc.h" #include "../common/intlobj_new.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/gdsassert.h" #include "../intl/charsets.h" #include "../intl/country_codes.h" diff --git a/src/iscguard/cntl_guard.cpp b/src/iscguard/cntl_guard.cpp index 06c487908d2..42dde0c532c 100644 --- a/src/iscguard/cntl_guard.cpp +++ b/src/iscguard/cntl_guard.cpp @@ -34,6 +34,8 @@ #include #endif +using namespace Firebird; + struct thread { thread* thread_next; diff --git a/src/iscguard/cntlg_proto.h b/src/iscguard/cntlg_proto.h index 3a0b3d8ffca..47d5abda0a2 100644 --- a/src/iscguard/cntlg_proto.h +++ b/src/iscguard/cntlg_proto.h @@ -26,7 +26,7 @@ #include "../common/ThreadStart.h" -void CNTL_init(ThreadEntryPoint*, const TEXT*); +void CNTL_init(Firebird::ThreadEntryPoint*, const TEXT*); void* CNTL_insert_thread(); void WINAPI CNTL_main_thread(DWORD, char* []); void CNTL_remove_thread(void*); @@ -34,4 +34,3 @@ void CNTL_shutdown_service(const TEXT*); void CNTL_stop_service(); //(const TEXT*); #endif // REMOTE_CNTL_PROTO_H - diff --git a/src/iscguard/iscguard.cpp b/src/iscguard/iscguard.cpp index 796de0f229d..5fb9de8b9b0 100644 --- a/src/iscguard/iscguard.cpp +++ b/src/iscguard/iscguard.cpp @@ -48,6 +48,8 @@ #include // _beginthread #endif +using namespace Firebird; + // Startup Configuration Entry point for regcfg.exe. //#define SVC_CONFIG 4 //#define REGCFG_ENTRYPOINT "LaunchInstReg" diff --git a/src/isql/ColList.cpp b/src/isql/ColList.cpp index 342b1409284..b6e2882231d 100644 --- a/src/isql/ColList.cpp +++ b/src/isql/ColList.cpp @@ -26,6 +26,9 @@ #include "ColList.h" #include "../common/utils_proto.h" +namespace Firebird::Isql +{ + ColList::item::item(const char* name, unsigned len) : col_len(len), next(0) @@ -132,3 +135,5 @@ bool ColList::find(const char* name, unsigned* out_len) const return false; } + +} // namespace Firebird::Isql diff --git a/src/isql/ColList.h b/src/isql/ColList.h index 158405dbb3d..fc54460fc67 100644 --- a/src/isql/ColList.h +++ b/src/isql/ColList.h @@ -25,7 +25,11 @@ #ifndef FB_COLLIST_H #define FB_COLLIST_H -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Isql +{ + // This is a linked list implementing a seldom used feature: the ability to // asssign a maximum width to each column, by name. The name should match the @@ -78,5 +82,7 @@ inline size_t ColList::count() const return m_count; } -#endif // FB_COLLIST_H +} // namespace Firebird::Isql + +#endif // FB_COLLIST_H diff --git a/src/isql/Extender.cpp b/src/isql/Extender.cpp index 7d536e11059..d9c10548e5f 100644 --- a/src/isql/Extender.cpp +++ b/src/isql/Extender.cpp @@ -25,6 +25,10 @@ #include "Extender.h" #include "../common/classes/alloc.h" +namespace Firebird::Isql +{ + + // Dynamic allocation. This is a destructive operation if the requested size // is bigger than the existing one. Otherwise, no reallocation happens. // The insertion point is always reset. This means getUsed() returns zero after @@ -108,3 +112,5 @@ void Extender::grow(size_t n) } } + +} // namespace Firebird::Isql diff --git a/src/isql/Extender.h b/src/isql/Extender.h index d98f119ef04..498bc77540a 100644 --- a/src/isql/Extender.h +++ b/src/isql/Extender.h @@ -38,6 +38,10 @@ #include +namespace Firebird::Isql +{ + + class Extender { public: @@ -87,5 +91,7 @@ inline size_t Extender::getUsed() const return m_pos - m_buf; } -#endif // FB_EXTENDER_H +} // namespace Firebird::Isql + +#endif // FB_EXTENDER_H diff --git a/src/isql/FrontendLexer.cpp b/src/isql/FrontendLexer.cpp index 5dd68b6057d..b4b34d0357c 100644 --- a/src/isql/FrontendLexer.cpp +++ b/src/isql/FrontendLexer.cpp @@ -27,6 +27,9 @@ #include #include +namespace Firebird::Isql +{ + std::string FrontendLexer::trim(std::string_view str) { @@ -464,3 +467,6 @@ void FrontendLexer::skipSpacesAndComments() } } } + + +} // namespace Firebird::Isql diff --git a/src/isql/FrontendLexer.h b/src/isql/FrontendLexer.h index d0e5df13821..fb7ba301d07 100644 --- a/src/isql/FrontendLexer.h +++ b/src/isql/FrontendLexer.h @@ -29,6 +29,10 @@ #include #include +namespace Firebird::Isql +{ + + class FrontendLexer { public: @@ -121,4 +125,7 @@ class FrontendLexer std::string::const_iterator deletePos; }; + +} // namespace Firebird::Isql + #endif // FB_ISQL_FRONTEND_LEXER_H diff --git a/src/isql/FrontendParser.cpp b/src/isql/FrontendParser.cpp index 64218057132..accc5a0e37c 100644 --- a/src/isql/FrontendParser.cpp +++ b/src/isql/FrontendParser.cpp @@ -25,6 +25,9 @@ #include "../isql/FrontendParser.h" #include +namespace Firebird::Isql +{ + FrontendParser::AnyNode FrontendParser::internalParse() { @@ -730,3 +733,6 @@ std::optional FrontendParser::parseUtilEof() return std::nullopt; } + + +} // namespace Firebird::Isql diff --git a/src/isql/FrontendParser.h b/src/isql/FrontendParser.h index 28a1b9cc3ba..d37e2dfb10b 100644 --- a/src/isql/FrontendParser.h +++ b/src/isql/FrontendParser.h @@ -25,7 +25,7 @@ #define FB_ISQL_FRONTEND_PARSER_H #include "../isql/FrontendLexer.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../common/classes/MetaString.h" #include "../common/classes/QualifiedMetaString.h" #include @@ -34,6 +34,10 @@ #include #include +namespace Firebird::Isql +{ + + class FrontendParser { private: @@ -47,10 +51,10 @@ class FrontendParser struct InvalidNode {}; - struct AddNode { Firebird::QualifiedMetaString tableName; }; + struct AddNode { QualifiedMetaString tableName; }; struct BlobDumpViewNode { ISC_QUAD blobId; std::optional file; }; struct ConnectNode { std::vector args; }; - struct CopyNode { Firebird::QualifiedMetaString source; Firebird::QualifiedMetaString destination; std::string database; }; + struct CopyNode { QualifiedMetaString source; QualifiedMetaString destination; std::string database; }; struct CreateDatabaseNode { std::vector args; }; struct DropDatabaseNode {}; struct EditNode { std::optional file; }; @@ -77,7 +81,7 @@ class FrontendParser struct SetListNode { std::string arg; }; struct SetLocalTimeoutNode { std::string arg; }; struct SetMaxRowsNode { std::string arg; }; - struct SetNamesNode { std::optional name; }; + struct SetNamesNode { std::optional name; }; struct SetPerTableStatsNode { std::string arg; }; struct SetPlanNode { std::string arg; }; struct SetPlanOnlyNode { std::string arg; }; @@ -92,32 +96,32 @@ class FrontendParser struct SetWireStatsNode { std::string arg; }; struct ShowNode {}; - struct ShowChecksNode { std::optional name; }; - struct ShowCollationsNode { std::optional name; }; + struct ShowChecksNode { std::optional name; }; + struct ShowCollationsNode { std::optional name; }; struct ShowCommentsNode {}; struct ShowDatabaseNode {}; - struct ShowDomainsNode { std::optional name; }; - struct ShowDependenciesNode { std::optional name; }; - struct ShowExceptionsNode { std::optional name; }; - struct ShowFiltersNode { std::optional name; }; - struct ShowFunctionsNode { std::optional name; }; - struct ShowGeneratorsNode { std::optional name; }; - struct ShowGrantsNode { std::optional name; }; - struct ShowIndexesNode { std::optional name; }; - struct ShowMappingsNode { std::optional name; }; - struct ShowPackagesNode { std::optional name; }; - struct ShowProceduresNode { std::optional name; }; - struct ShowPublicationsNode { std::optional name; }; - struct ShowRolesNode { std::optional name; }; - struct ShowSchemasNode { std::optional name; }; - struct ShowSecClassesNode { std::optional name; bool detail = false; }; + struct ShowDomainsNode { std::optional name; }; + struct ShowDependenciesNode { std::optional name; }; + struct ShowExceptionsNode { std::optional name; }; + struct ShowFiltersNode { std::optional name; }; + struct ShowFunctionsNode { std::optional name; }; + struct ShowGeneratorsNode { std::optional name; }; + struct ShowGrantsNode { std::optional name; }; + struct ShowIndexesNode { std::optional name; }; + struct ShowMappingsNode { std::optional name; }; + struct ShowPackagesNode { std::optional name; }; + struct ShowProceduresNode { std::optional name; }; + struct ShowPublicationsNode { std::optional name; }; + struct ShowRolesNode { std::optional name; }; + struct ShowSchemasNode { std::optional name; }; + struct ShowSecClassesNode { std::optional name; bool detail = false; }; struct ShowSqlDialectNode {}; struct ShowSystemNode { std::optional objType; }; - struct ShowTablesNode { std::optional name; }; - struct ShowTriggersNode { std::optional name; }; + struct ShowTablesNode { std::optional name; }; + struct ShowTriggersNode { std::optional name; }; struct ShowUsersNode {}; struct ShowVersionNode {}; - struct ShowViewsNode { std::optional name; }; + struct ShowViewsNode { std::optional name; }; struct ShowWireStatsNode {}; using AnySetNode = std::variant< @@ -261,21 +265,21 @@ class FrontendParser return lexer.getToken().type == Token::TYPE_EOF; } - std::optional parseName() + std::optional parseName() { const auto token = lexer.getNameToken(); if (token.type != Token::TYPE_EOF) - return Firebird::MetaString(token.processedText.c_str()); + return MetaString(token.processedText.c_str()); return std::nullopt; } - std::optional parseQualifiedName(bool allowPackage = false) + std::optional parseQualifiedName(bool allowPackage = false) { if (const auto optName1 = parseName()) { - Firebird::QualifiedMetaString name(optName1.value()); + QualifiedMetaString name(optName1.value()); auto lexerPos = lexer.getPos(); auto token = lexer.getToken(); @@ -334,4 +338,7 @@ class FrontendParser const Options options; }; + +} // namespace Firebird::Isql + #endif // FB_ISQL_FRONTEND_PARSER_H diff --git a/src/isql/InputDevices.cpp b/src/isql/InputDevices.cpp index 9fb6c05550a..b9a6b59e11f 100644 --- a/src/isql/InputDevices.cpp +++ b/src/isql/InputDevices.cpp @@ -40,7 +40,7 @@ #include "../common/os/os_utils.h" #include "InputDevices.h" -using Firebird::PathName; +namespace Firebird::Isql { InputDevices::indev::indev() @@ -298,3 +298,5 @@ void InputDevices::commandsToFile(FILE* f) commands.clear(); } + +} // namespace Firebird::Isql diff --git a/src/isql/InputDevices.h b/src/isql/InputDevices.h index 1b4566a8494..5a45b673859 100644 --- a/src/isql/InputDevices.h +++ b/src/isql/InputDevices.h @@ -31,6 +31,9 @@ #include +namespace Firebird::Isql +{ + // This is basically a stack of input files caused by the INPUT command, // because it can be invoked interactively and from a file. In turn, each file // (SQL script) can contain another INPUT command and so on. @@ -51,7 +54,7 @@ class InputDevices void init(const indev& src); //~indev(); void copy_from(const indev* src); - Firebird::PathName fileName(bool display) const; + PathName fileName(bool display) const; void close(); void drop(); void getPos(fpos_t* out) const; @@ -64,13 +67,13 @@ class InputDevices private: void makeFullFileName(); - Firebird::PathName indev_fn, indev_fn_display; + PathName indev_fn, indev_fn_display; void operator=(const void*); // prevent surprises. }; InputDevices(); - explicit InputDevices(Firebird::MemoryPool&); + explicit InputDevices(MemoryPool&); ~InputDevices(); void clear(FILE* fpointer = 0); //const indev* getHead(); @@ -93,20 +96,20 @@ class InputDevices indev m_ifp; indev m_ofp; - class Command : public Firebird::GlobalStorage + class Command : public GlobalStorage { public: Command(const char* statement, const char* term); void toFile(FILE* fpointer); private: - Firebird::string m_statement; + string m_statement; }; - Firebird::HalfStaticArray commands; + HalfStaticArray commands; }; -inline Firebird::PathName InputDevices::indev::fileName(bool display) const +inline PathName InputDevices::indev::fileName(bool display) const { return display ? indev_fn_display : indev_fn; } @@ -123,7 +126,7 @@ inline InputDevices::InputDevices() { } -inline InputDevices::InputDevices(Firebird::MemoryPool& p) +inline InputDevices::InputDevices(MemoryPool& p) : m_count(0), m_head(0), m_ifp(0, "", ""), m_ofp(0, "", ""), commands(p) { } @@ -153,5 +156,7 @@ inline size_t InputDevices::count() const return m_count; } -#endif // FB_INPUT_DEVICES_H +} // namespace Firebird::Isql + +#endif // FB_INPUT_DEVICES_H diff --git a/src/isql/OptionsBase.cpp b/src/isql/OptionsBase.cpp index 0974fa3bd7f..872ac56dd5a 100644 --- a/src/isql/OptionsBase.cpp +++ b/src/isql/OptionsBase.cpp @@ -26,6 +26,9 @@ #include "OptionsBase.h" #include "../common/gdsassert.h" +namespace Firebird::Isql +{ + int OptionsBase::getCommand(const char* cmd) const { @@ -102,3 +105,5 @@ void OptionsBase::showCommands(FILE* out) const fputc('\n', out); } + +} // namespace Firebird::Isql diff --git a/src/isql/OptionsBase.h b/src/isql/OptionsBase.h index 0ae7b3aabcb..5c2b959515b 100644 --- a/src/isql/OptionsBase.h +++ b/src/isql/OptionsBase.h @@ -27,6 +27,10 @@ #include +namespace Firebird::Isql +{ + + class OptionsBase { public: @@ -52,5 +56,7 @@ inline OptionsBase::OptionsBase(const optionsMap* inmap, size_t insize, int wron { } -#endif // FB_OPTIONSBASE_H +} // namespace Firebird::Isql + +#endif // FB_OPTIONSBASE_H diff --git a/src/isql/PtrSentry.h b/src/isql/PtrSentry.h index 18f65913653..7f2d1dded6c 100644 --- a/src/isql/PtrSentry.h +++ b/src/isql/PtrSentry.h @@ -24,6 +24,10 @@ #ifndef FB_PTRSENTRY_H #define FB_PTRSENTRY_H +namespace Firebird::Isql +{ + + // Helper class to track allocation of single entities and arrays. // Hopefully scarcely used as we move to more objects. // It simply deletes the given pointer when the container (an object of this clas) @@ -105,5 +109,6 @@ void PtrSentry::forget() } -#endif // FB_PTRSENTRY_H +} // namespace Firebird::Isql +#endif // FB_PTRSENTRY_H diff --git a/src/isql/extra_proto.h b/src/isql/extra_proto.h index 8dea6ff7bc2..b3d88bc82a2 100644 --- a/src/isql/extra_proto.h +++ b/src/isql/extra_proto.h @@ -28,12 +28,14 @@ #include "../common/classes/MetaString.h" #include "../common/classes/QualifiedMetaString.h" -using GetDefaultCharSetForSchemaFunc = std::function; +namespace Firebird::Isql +{ + using GetDefaultCharSetForSchemaFunc = std::function; -int EXTRACT_ddl(LegacyTables, const Firebird::QualifiedMetaString&); -int EXTRACT_list_table(const Firebird::QualifiedMetaString&, const Firebird::QualifiedMetaString&, bool, - GetDefaultCharSetForSchemaFunc getDefaultCharSetForSchemaFunc); -processing_state EXTRACT_list_grants (const SCHAR*); + int EXTRACT_ddl(LegacyTables, const QualifiedMetaString&); + int EXTRACT_list_table(const QualifiedMetaString&, const QualifiedMetaString&, bool, + GetDefaultCharSetForSchemaFunc getDefaultCharSetForSchemaFunc); + processing_state EXTRACT_list_grants (const SCHAR*); +} // namespace Firebird::Isql #endif // ISQL_EXTRA_PROTO_H - diff --git a/src/isql/extract.epp b/src/isql/extract.epp index 1e651a52c98..d167f834c12 100644 --- a/src/isql/extract.epp +++ b/src/isql/extract.epp @@ -46,7 +46,7 @@ #include #include "../common/classes/MetaString.h" #include "../common/classes/QualifiedMetaString.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "ibase.h" #include "../yvalve/gds_proto.h" #include "../common/intlobj_new.h" @@ -56,12 +56,14 @@ #include "../isql/show_proto.h" #include "../isql/iutils_proto.h" #include "../jrd/ini.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/ods.h" #include "../common/utils_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Isql +{ -using namespace Firebird; using MsgFormat::SafeArg; @@ -3414,3 +3416,6 @@ static void list_views() return; END_ERROR } + + +} // namespace Firebird::Isql diff --git a/src/isql/isql.epp b/src/isql/isql.epp index c46536dc65d..918b1a57892 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -109,7 +109,7 @@ enum literal_string_type #include "../isql/isql.h" #include "../yvalve/perf.h" #include "../jrd/license.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ods.h" #include "../common/file_params.h" #include "../common/classes/ImplementHelper.h" @@ -128,9 +128,6 @@ enum literal_string_type #include "../common/classes/MsgPrint.h" #include "../remote/protocol.h" -using namespace Firebird; -using MsgFormat::SafeArg; - #include "../isql/ColList.h" #include "../isql/InputDevices.h" #include "../isql/OptionsBase.h" @@ -141,6 +138,11 @@ using MsgFormat::SafeArg; #include "../intl/charsets.h" #include +namespace Firebird::Isql +{ + +using MsgFormat::SafeArg; + //DATABASE DB = COMPILETIME "yachts.lnk"; DATABASE DB = COMPILETIME "yachts.lnk" RUNTIME isqlGlob.global_Db_name; @@ -275,13 +277,13 @@ namespace IcuUtil } -static inline bool commit_trans(Firebird::ITransaction** x) +static inline bool commit_trans(ITransaction** x) { (*x)->commit(fbStatus); if (ISQL_errmsg (fbStatus)) { (*x)->rollback(fbStatus); - if (!(fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if (!(fbStatus->getState() & IStatus::STATE_ERRORS)) { *x = NULL; } @@ -371,13 +373,13 @@ static int win32ReadConsole(FILE* file, CharBuffer& mbBuffer) IsqlGlobals::IsqlGlobals() { - Firebird::AutoPtr + AutoPtr status_vector(fbMaster->getStatus()); - Firebird::CheckStatusWrapper statusWrapper(status_vector); + CheckStatusWrapper statusWrapper(status_vector); - df16 = Firebird::UtilInterfacePtr()->getDecFloat16(&statusWrapper); - df34 = Firebird::UtilInterfacePtr()->getDecFloat34(&statusWrapper); - i128 = Firebird::UtilInterfacePtr()->getInt128(&statusWrapper); + df16 = UtilInterfacePtr()->getDecFloat16(&statusWrapper); + df34 = UtilInterfacePtr()->getDecFloat34(&statusWrapper); + i128 = UtilInterfacePtr()->getInt128(&statusWrapper); } // I s q l G l o b a l s : : p r i n t f @@ -444,14 +446,14 @@ static processing_state newtrans(const TEXT*); static processing_state parse_arg(int, SCHAR**, QualifiedMetaString&); //, FILE**); static unsigned print_item(TEXT**, const IsqlVar*, const unsigned); static void print_item_numeric(SINT64, int, int, TEXT*); -static processing_state print_line(Firebird::IMessageMetadata*, UCHAR*, const unsigned pad[], TEXT line[]); +static processing_state print_line(IMessageMetadata*, UCHAR*, const unsigned pad[], TEXT line[]); static processing_state print_performance(const SINT64* perf_before); -static void print_message(Firebird::IMessageMetadata* msg, const char* dir); -static void process_header(Firebird::IMessageMetadata*, const unsigned pad[], TEXT header[], TEXT header2[]); +static void print_message(IMessageMetadata* msg, const char* dir); +static void process_header(IMessageMetadata*, const unsigned pad[], TEXT header[], TEXT header2[]); static void process_plan(); static void process_exec_path(); static SINT64 process_record_count(const unsigned statement_type); -static unsigned process_message_display(Firebird::IMessageMetadata* msg, unsigned pad[]); +static unsigned process_message_display(IMessageMetadata* msg, unsigned pad[]); static processing_state process_statement(const std::string&); #ifdef WIN_NT static BOOL CALLBACK query_abort(DWORD); @@ -474,17 +476,17 @@ bool Trusted_auth = false; bool Version_info = false; // Utility transaction handle -static Firebird::ITransaction* D__trans = NULL; -static Firebird::ITransaction* M__trans = NULL; +static ITransaction* D__trans = NULL; +static ITransaction* M__trans = NULL; static int global_numbufs; // # of cache buffers on connect -static Firebird::IStatement* global_Stmt = NULL; +static IStatement* global_Stmt = NULL; static SCHAR Password[PASSWORD_LENGTH]; static bool Merge_stderr; -static Firebird::GlobalPtr global_Buffer; +static GlobalPtr global_Buffer; static bool Abort_flag = false; static bool Interrupt_flag = false; -static Firebird::GlobalPtr Filelist; +static GlobalPtr Filelist; static int Pagelength = 20; static bool Nodbtriggers = false; // No database triggers static int Exit_value = 0; @@ -492,7 +494,7 @@ static bool Interactive = true; static bool Input_file = false; static const char* DEFAULT_DML_TRANS_SQL = "SET TRANSACTION"; -static Firebird::GlobalPtr TranParams; +static GlobalPtr TranParams; // Values used in the SET command. // Initial options set exclusively from the command line are not included here. @@ -596,18 +598,18 @@ static const SCHAR* alpha_months[] = class PerTableStats { public: - PerTableStats(Firebird::MemoryPool& pool) : + PerTableStats(MemoryPool& pool) : m_initialized(false), m_stat(pool), m_relNames(pool) {} - void getStats(Firebird::IAttachment* att, bool initial); + void getStats(IAttachment* att, bool initial); void reset(); private: - void printStats(Firebird::IAttachment* att); - unsigned loadRelNames(Firebird::IAttachment* att); + void printStats(IAttachment* att); + unsigned loadRelNames(IAttachment* att); struct StatItem { @@ -642,11 +644,11 @@ private: } }; - using StatArray = Firebird::SortedArray< + using StatArray = SortedArray< StatItem, - Firebird::EmptyStorage, + EmptyStorage, StatItem, - Firebird::DefaultKeyValue, + DefaultKeyValue, StatItem>; bool m_initialized; // initial (before) stats loaded OK @@ -658,7 +660,7 @@ private: static const char* m_itemNames[ITEM_COUNT]; }; -static Firebird::GlobalPtr perTableStats; +static GlobalPtr perTableStats; class StatementGetter @@ -731,7 +733,7 @@ static const ri_actions ri_actions_all[] = }; -static bool startTransaction(Firebird::ITransaction** t, unsigned len = 0, const UCHAR* tpb = NULL) +static bool startTransaction(ITransaction** t, unsigned len = 0, const UCHAR* tpb = NULL) { if (DB && !*t) { @@ -1139,7 +1141,7 @@ int getNextInputChar() } -bool ISQL_errmsg(Firebird::IStatus* st) +bool ISQL_errmsg(IStatus* st) { /************************************** * @@ -1155,7 +1157,7 @@ bool ISQL_errmsg(Firebird::IStatus* st) const ISC_STATUS* const status = st->getErrors(); const unsigned state = st->getState(); - if (Quiet && (state & Firebird::IStatus::STATE_ERRORS)) + if (Quiet && (state & IStatus::STATE_ERRORS)) Exit_value = FINI_ERROR; //else { @@ -1163,13 +1165,13 @@ bool ISQL_errmsg(Firebird::IStatus* st) if (vec[0] != isc_arg_gds) return false; - if (!(state & Firebird::IStatus::STATE_ERRORS) && - (!(state & Firebird::IStatus::STATE_WARNINGS) || !setValues.Warnings)) + if (!(state & IStatus::STATE_ERRORS) && + (!(state & IStatus::STATE_WARNINGS) || !setValues.Warnings)) { return false; } - if (state & Firebird::IStatus::STATE_ERRORS) + if (state & IStatus::STATE_ERRORS) { FB_SQLSTATE_STRING sqlstate; fb_sqlstate(sqlstate, status); @@ -1253,11 +1255,11 @@ bool ISQL_errmsg(Firebird::IStatus* st) ISQL_warning(st); } - return (state & Firebird::IStatus::STATE_ERRORS); + return (state & IStatus::STATE_ERRORS); } -void ISQL_warning(Firebird::IStatus* st) +void ISQL_warning(IStatus* st) { /************************************** * @@ -1270,7 +1272,7 @@ void ISQL_warning(Firebird::IStatus* st) * Simulate isc_print_status exactly, to control stderr **************************************/ - if ((st->getState() & Firebird::IStatus::STATE_WARNINGS) && setValues.Warnings) + if ((st->getState() & IStatus::STATE_WARNINGS) && setValues.Warnings) { const ISC_STATUS* vec = st->getWarnings(); TEXT buf[MSG_LENGTH]; @@ -1509,7 +1511,7 @@ bool ISQL_get_character_sets(SSHORT char_set_id, SSHORT collation, inline static bool failed() { - return (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS); + return (fbStatus->getState() & IStatus::STATE_ERRORS); } @@ -1520,7 +1522,7 @@ inline static bool succeeded() processing_state ISQL_fill_var(IsqlVar* var, - Firebird::IMessageMetadata* msg, + IMessageMetadata* msg, unsigned index, UCHAR* buf) { @@ -2128,7 +2130,7 @@ bool ISQL_printNumericType(const QualifiedMetaString& fieldName, const int field void ISQL_print_validation(FILE* fp, ISC_QUAD* blobid, bool isComputedField, - Firebird::ITransaction* trans) + ITransaction* trans) { /************************************** * @@ -2150,7 +2152,7 @@ void ISQL_print_validation(FILE* fp, if (blobid->gds_quad_high == 0 || !DB) return; - Firebird::IBlob* blob = DB->openBlob(fbStatus, trans, blobid, 0, NULL); + IBlob* blob = DB->openBlob(fbStatus, trans, blobid, 0, NULL); if (ISQL_errmsg(fbStatus)) return; @@ -2163,7 +2165,7 @@ void ISQL_print_validation(FILE* fp, { unsigned int length; int cc = blob->getSegment(fbStatus, sizeof(buffer) - 1, buffer, &length); - if (cc == Firebird::IStatus::RESULT_NO_DATA || cc == Firebird::IStatus::RESULT_ERROR) + if (cc == IStatus::RESULT_NO_DATA || cc == IStatus::RESULT_ERROR) break; buffer[length] = 0; @@ -2308,11 +2310,11 @@ static processing_state add_row(const QualifiedMetaString& tabname) } global_Stmt = DB->prepare(fbStatus, D__trans, 0, str2.c_str(), isqlGlob.SQL_dialect, - Firebird::IStatement::PREPARE_PREFETCH_METADATA); + IStatement::PREPARE_PREFETCH_METADATA); if (ISQL_errmsg(fbStatus)) return (SKIP); - Firebird::RefPtr msg(Firebird::REF_NO_INCR, global_Stmt->getOutputMetadata(fbStatus)); + RefPtr msg(REF_NO_INCR, global_Stmt->getOutputMetadata(fbStatus)); if (ISQL_errmsg(fbStatus)) return (SKIP); @@ -2326,7 +2328,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) global_Stmt = NULL; // Array for storing select/insert column mapping, colcheck sets it up - Firebird::Array coln; + Array coln; unsigned* colnumber = coln.getBuffer(n_cols); auto fixedTabName = tabname; @@ -2374,7 +2376,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) // Build metadata for insert message if (i_cols != n_cols) { - Firebird::RefPtr bldr(Firebird::REF_NO_INCR, msg->getBuilder(fbStatus)); + RefPtr bldr(REF_NO_INCR, msg->getBuilder(fbStatus)); if (ISQL_errmsg(fbStatus)) return (SKIP); @@ -2523,7 +2525,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) else { gds__edit(ftmp.c_str(), 0); - Firebird::UtilInterfacePtr()->loadBlob(fbStatus, blobid, DB, M__trans, + UtilInterfacePtr()->loadBlob(fbStatus, blobid, DB, M__trans, ftmp.c_str(), FB_TRUE); unlink(ftmp.c_str()); res = succeeded(); @@ -2535,7 +2537,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) // being loaded. As we aren't sure, we'll // do binary operation - this is NEW data in // the database, not updating existing info - Firebird::UtilInterfacePtr()->loadBlob(fbStatus, blobid, DB, M__trans, + UtilInterfacePtr()->loadBlob(fbStatus, blobid, DB, M__trans, lastInputLine, FB_FALSE); res = succeeded(); } @@ -2569,7 +2571,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) d64value = (FB_DEC16*) datap; if (isqlGlob.df16) isqlGlob.df16->fromString(fbStatus, lastInputLine, d64value); - if ((!isqlGlob.df16) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.df16) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -2585,7 +2587,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) i128value = (FB_I128*) datap; if (isqlGlob.i128) isqlGlob.i128->fromString(fbStatus, scale, lastInputLine, i128value); - if ((!isqlGlob.i128) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.i128) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -2597,7 +2599,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) d128value = (FB_DEC34*) datap; if (isqlGlob.df34) isqlGlob.df34->fromString(fbStatus, lastInputLine, d128value); - if ((!isqlGlob.df34) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.df34) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -2653,7 +2655,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) done = true; } - Firebird::UtilInterfacePtr()->encodeTimeTz(fbStatus, + UtilInterfacePtr()->encodeTimeTz(fbStatus, (ISC_TIME_TZ*) datap, hours, minutes, seconds, 0, timeZone); if (ISQL_errmsg(fbStatus)) done = true; @@ -2716,7 +2718,7 @@ static processing_state add_row(const QualifiedMetaString& tabname) done = true; } - Firebird::UtilInterfacePtr()->encodeTimeStampTz(fbStatus, + UtilInterfacePtr()->encodeTimeStampTz(fbStatus, (ISC_TIMESTAMP_TZ*) datap, year, month, day, hours, minutes, seconds, fractions, timeZone); if (ISQL_errmsg(fbStatus)) done = true; @@ -2879,7 +2881,7 @@ static processing_state blobedit(ISC_QUAD blobId, const char* path) processing_state rc = SKIP; if (!path) { - Firebird::UtilInterfacePtr utl; + UtilInterfacePtr utl; PathName tmpf = TempFile::create(fbStatus, "blob"); if (ISQL_errmsg(fbStatus)) return ps_ERR; @@ -2898,7 +2900,7 @@ static processing_state blobedit(ISC_QUAD blobId, const char* path) // If this is a blobdump, make sure there is a file name // We can't be sure if the BLOB is TEXT or BINARY data, // as we're not sure, we'll dump it in BINARY mode. - Firebird::UtilInterfacePtr()->dumpBlob(fbStatus, &blobId, DB, M__trans, path, FB_FALSE); + UtilInterfacePtr()->dumpBlob(fbStatus, &blobId, DB, M__trans, path, FB_FALSE); } else rc = ps_ERR; @@ -2965,7 +2967,7 @@ static processing_state bulk_insert_hack(const char* command) SINT64 perf_before[ISQL_COUNTERS]; if (setValues.Stats) { - Firebird::UtilInterfacePtr()->getPerfCounters(fbStatus, + UtilInterfacePtr()->getPerfCounters(fbStatus, DB, ISQL_COUNTERS_SET, perf_before); if (ISQL_errmsg(fbStatus)) { @@ -2984,8 +2986,8 @@ static processing_state bulk_insert_hack(const char* command) return (SKIP); } - unsigned prepFlags = Firebird::IStatement::PREPARE_PREFETCH_METADATA | - (setValues.Plan ? Firebird::IStatement::PREPARE_PREFETCH_DETAILED_PLAN : 0); + unsigned prepFlags = IStatement::PREPARE_PREFETCH_METADATA | + (setValues.Plan ? IStatement::PREPARE_PREFETCH_DETAILED_PLAN : 0); global_Stmt = DB->prepare(fbStatus, setValues.Autocommit ? D__trans : M__trans, 0, command, isqlGlob.SQL_dialect, prepFlags); @@ -3022,7 +3024,7 @@ static processing_state bulk_insert_hack(const char* command) } ***/ - Firebird::RefPtr message(global_Stmt->getInputMetadata(fbStatus)); + RefPtr message(global_Stmt->getInputMetadata(fbStatus)); if (ISQL_errmsg(fbStatus)) { return ps_ERR; @@ -3338,7 +3340,7 @@ static processing_state bulk_insert_hack(const char* command) blobid = (ISC_QUAD*) datap; { // scope - Firebird::IBlob* bs = DB->createBlob(fbStatus, M__trans, blobid, 0, NULL); + IBlob* bs = DB->createBlob(fbStatus, M__trans, blobid, 0, NULL); if (failed()) { STDERROUT("Unable to create blob"); @@ -3387,7 +3389,7 @@ static processing_state bulk_insert_hack(const char* command) d64value = (FB_DEC16*) datap; if (isqlGlob.df16) isqlGlob.df16->fromString(fbStatus, get_numeric_value(lastPos).c_str(), d64value); - if ((!isqlGlob.df16) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.df16) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -3399,7 +3401,7 @@ static processing_state bulk_insert_hack(const char* command) d128value = (FB_DEC34*) datap; if (isqlGlob.df34) isqlGlob.df34->fromString(fbStatus, get_numeric_value(lastPos).c_str(), d128value); - if ((!isqlGlob.df34) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.df34) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -3418,7 +3420,7 @@ static processing_state bulk_insert_hack(const char* command) isqlGlob.i128->fromString(fbStatus, scale, get_numeric_value(lastPos).c_str(), i128value); } - if ((!isqlGlob.i128) || (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if ((!isqlGlob.i128) || (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("Input parsing problem"); ISQL_errmsg(fbStatus); @@ -3474,7 +3476,7 @@ static processing_state bulk_insert_hack(const char* command) done = true; } - Firebird::UtilInterfacePtr()->encodeTimeTz(fbStatus, + UtilInterfacePtr()->encodeTimeTz(fbStatus, (ISC_TIME_TZ*) datap, hours, minutes, seconds, 0, timeZone); if (ISQL_errmsg(fbStatus)) done = true; @@ -3538,7 +3540,7 @@ static processing_state bulk_insert_hack(const char* command) done = true; } - Firebird::UtilInterfacePtr()->encodeTimeStampTz(fbStatus, + UtilInterfacePtr()->encodeTimeStampTz(fbStatus, (ISC_TIMESTAMP_TZ*) datap, year, month, day, hours, minutes, seconds, fractions, timeZone); if (ISQL_errmsg(fbStatus)) done = true; @@ -3872,7 +3874,8 @@ static void check_autoterm() } } - if (!(protocolVersion == 0 || protocolVersion >= (PROTOCOL_PREPARE_FLAG & FB_PROTOCOL_MASK)) && + if (!(protocolVersion == 0 || protocolVersion >= + (Remote::PROTOCOL_PREPARE_FLAG & Remote::FB_PROTOCOL_MASK)) && isqlGlob.major_ods >= ODS_VERSION14) { setValues.AutoTerm = false; @@ -4752,7 +4755,7 @@ static processing_state execSetDebugCommand() DB->execute(fbStatus, nullptr, 0, stmt, isqlGlob.SQL_dialect, nullptr, nullptr, nullptr, nullptr); - if (setValues.ExecPathDisplay[0] && (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS)) + if (setValues.ExecPathDisplay[0] && (fbStatus->getState() & IStatus::STATE_ERRORS)) { STDERROUT("SET EXEC_PATH_DISPLAY is not supported in this connection."); return FAIL; @@ -5515,7 +5518,7 @@ void ISQL_get_version(bool call_by_create_db) return; } - for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) + for (ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) { UCHAR item = p.getClumpTag(); if (item == isc_info_end) @@ -5874,11 +5877,11 @@ static processing_state print_sets() static processing_state explain(const TEXT* command) { - Firebird::AutoSetRestore autoExplainCommand(&setValues.ExplainCommand, true); - Firebird::AutoSetRestore autoPlanonly(&setValues.Planonly, true); - Firebird::AutoSetRestore autoPlan(&setValues.Plan, true); - Firebird::AutoSetRestore autoExplainPlan(&setValues.ExplainPlan, true); - Firebird::AutoSetRestore autoSqldaDisplay(&setValues.Sqlda_display, false); + AutoSetRestore autoExplainCommand(&setValues.ExplainCommand, true); + AutoSetRestore autoPlanonly(&setValues.Planonly, true); + AutoSetRestore autoPlan(&setValues.Plan, true); + AutoSetRestore autoExplainPlan(&setValues.ExplainPlan, true); + AutoSetRestore autoSqldaDisplay(&setValues.Sqlda_display, false); process_statement(command); @@ -6094,18 +6097,18 @@ static bool printUser(const char* dbName) "SELECT CURRENT_USER, CURRENT_ROLE FROM %sRDB$DATABASE", (isqlGlob.major_ods >= ODS_VERSION14 ? "SYSTEM." : "")); - Firebird::RefPtr st(Firebird::REF_NO_INCR, - DB->prepare(fbStatus, fbTrans, 0, sql.c_str(), 3, Firebird::IStatement::PREPARE_PREFETCH_METADATA)); + RefPtr st(REF_NO_INCR, + DB->prepare(fbStatus, fbTrans, 0, sql.c_str(), 3, IStatement::PREPARE_PREFETCH_METADATA)); if (failed()) return false; - Firebird::RefPtr m(Firebird::REF_NO_INCR, + RefPtr m(REF_NO_INCR, st->getOutputMetadata(fbStatus)); if (failed()) return false; unsigned bs = m->getMessageLength(fbStatus); if (failed()) return false; - Firebird::UCharBuffer outBuf; + UCharBuffer outBuf; UCHAR* buf = outBuf.getBuffer(bs); st->execute(fbStatus, fbTrans, NULL, NULL, m, buf); if (failed()) @@ -6242,7 +6245,7 @@ static processing_state newdb(const TEXT* dbname, local_numbufs = global_numbufs; // Build up a dpb - Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE); + ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); if (setValues.ISQL_charset) { @@ -7047,7 +7050,7 @@ static bool checkSpecial(TEXT* const p, const int length, const double value) if (std::isnan(value)) t = "NaN"; else if (std::isinf(value)) - t = Firebird::isNegativeInf(value) ? "-Infinity" : "Infinity"; + t = isNegativeInf(value) ? "-Infinity" : "Infinity"; else return false; @@ -7312,7 +7315,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) case SQL_DEC16: { - char decStr[Firebird::IDecFloat16::STRING_SIZE]; + char decStr[IDecFloat16::STRING_SIZE]; if (isqlGlob.df16) { isqlGlob.df16->toString(fbStatus, var->value.asDec16, sizeof(decStr), decStr); @@ -7331,7 +7334,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) case SQL_DEC34: { - char decStr[Firebird::IDecFloat34::STRING_SIZE]; + char decStr[IDecFloat34::STRING_SIZE]; if (isqlGlob.df34) { isqlGlob.df34->toString(fbStatus, var->value.asDec34, sizeof(decStr), decStr); @@ -7354,7 +7357,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) case SQL_INT128: { - char intStr[Firebird::IInt128::STRING_SIZE]; + char intStr[IInt128::STRING_SIZE]; if (isqlGlob.i128) { isqlGlob.i128->toString(fbStatus, var->value.asInt128, dscale, sizeof(intStr), intStr); @@ -7482,12 +7485,12 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) if (dtype == SQL_TIMESTAMP_TZ) { - Firebird::UtilInterfacePtr()->decodeTimeStampTz(fbStatus, var->value.asDateTimeTz, + UtilInterfacePtr()->decodeTimeStampTz(fbStatus, var->value.asDateTimeTz, &year, &month, &day, &hours, &minutes, &seconds, &fractions, sizeof(timeZone), timeZone); } else { - Firebird::UtilInterfacePtr()->decodeTimeStampTzEx(fbStatus, var->value.asDateTimeTzEx, + UtilInterfacePtr()->decodeTimeStampTzEx(fbStatus, var->value.asDateTimeTzEx, &year, &month, &day, &hours, &minutes, &seconds, &fractions, sizeof(timeZone), timeZone); } @@ -7529,12 +7532,12 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) if (dtype == SQL_TIME_TZ) { - Firebird::UtilInterfacePtr()->decodeTimeTz(fbStatus, var->value.asTimeTz, &hours, &minutes, &seconds, + UtilInterfacePtr()->decodeTimeTz(fbStatus, var->value.asTimeTz, &hours, &minutes, &seconds, &fractions, sizeof(timeZone), timeZone); } else { - Firebird::UtilInterfacePtr()->decodeTimeTzEx(fbStatus, var->value.asTimeTzEx, &hours, &minutes, &seconds, + UtilInterfacePtr()->decodeTimeTzEx(fbStatus, var->value.asTimeTzEx, &hours, &minutes, &seconds, &fractions, sizeof(timeZone), timeZone); } @@ -7589,7 +7592,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } -processing_state ISQL_print_item_blob(FILE* fp, const IsqlVar* var, Firebird::ITransaction* trans, int subtype) +processing_state ISQL_print_item_blob(FILE* fp, const IsqlVar* var, ITransaction* trans, int subtype) { /****************************************** * @@ -7659,7 +7662,7 @@ processing_state ISQL_print_item_blob(FILE* fp, const IsqlVar* var, Firebird::IT set_bpb_for_translation(blob_subtype); } - Firebird::IBlob* blob = DB->openBlob(fbStatus, trans, blobid, bpb_length, bpb); + IBlob* blob = DB->openBlob(fbStatus, trans, blobid, bpb_length, bpb); if (ISQL_errmsg(fbStatus)) { return ps_ERR; @@ -7671,7 +7674,7 @@ processing_state ISQL_print_item_blob(FILE* fp, const IsqlVar* var, Firebird::IT { unsigned int length; int cc = blob->getSegment(fbStatus, sizeof(buffer) - 1, buffer, &length); - if (cc == Firebird::IStatus::RESULT_NO_DATA || cc == Firebird::IStatus::RESULT_ERROR) + if (cc == IStatus::RESULT_NO_DATA || cc == IStatus::RESULT_ERROR) break; buffer[length] = 0; @@ -7769,7 +7772,7 @@ static void print_item_numeric(SINT64 value, int length, int scale, TEXT* buf) } -static processing_state print_line(Firebird::IMessageMetadata* message, UCHAR* buf, const unsigned pad[], TEXT line[]) +static processing_state print_line(IMessageMetadata* message, UCHAR* buf, const unsigned pad[], TEXT line[]) { /************************************** * @@ -7865,10 +7868,10 @@ static processing_state print_performance(const SINT64* perf_before) { // Translation of report strings. Do not remove "static" modifier. static bool have_report = false; - static Firebird::GlobalPtr diag; + static GlobalPtr diag; SINT64 perf_after[ISQL_COUNTERS]; - Firebird::UtilInterfacePtr()->getPerfCounters(fbStatus, DB, ISQL_COUNTERS_SET, perf_after); + UtilInterfacePtr()->getPerfCounters(fbStatus, DB, ISQL_COUNTERS_SET, perf_after); if (ISQL_errmsg(fbStatus)) { return ps_ERR; @@ -7942,7 +7945,7 @@ static processing_state print_performance(const SINT64* perf_before) // p r i n t _ m e s s a g e // ********************************* // Show the contents of the input msg, used typically for parameters. -static void print_message(Firebird::IMessageMetadata* msg, const char* dir) +static void print_message(IMessageMetadata* msg, const char* dir) { unsigned n = msg->getCount(fbStatus); isqlGlob.printf( @@ -7986,7 +7989,7 @@ static void print_message(Firebird::IMessageMetadata* msg, const char* dir) // *************************** // Write into buffers the information that will be printed as page header for // statements that return data. -static void process_header(Firebird::IMessageMetadata* msg, const unsigned pad[], TEXT header[], TEXT header2[]) +static void process_header(IMessageMetadata* msg, const unsigned pad[], TEXT header[], TEXT header2[]) { // Create the column header : Left justify strings @@ -8052,7 +8055,7 @@ static void process_exec_path() if (!global_Stmt) return; - Firebird::Array pathBuffer; + Array pathBuffer; pathBuffer.getBuffer(MAX_USHORT, false); for (const UCHAR* code = setValues.ExecPathDisplay; *code; ++code) @@ -8164,7 +8167,7 @@ static SINT64 process_record_count(const unsigned statement_type) // p r o c e s s _ m e s s a g e _ d i s p l a y // ********************************************* // Calculate individual column widths and return total line width. -static unsigned process_message_display(Firebird::IMessageMetadata* message, unsigned pad[]) +static unsigned process_message_display(IMessageMetadata* message, unsigned pad[]) { unsigned linelength = 0; unsigned ncols = message->getCount(fbStatus); @@ -8230,13 +8233,13 @@ static unsigned process_message_display(Firebird::IMessageMetadata* message, uns disp_length = DOUBLE_LEN; break; case SQL_DEC16: - disp_length = Firebird::IDecFloat16::STRING_SIZE - 1; + disp_length = IDecFloat16::STRING_SIZE - 1; break; case SQL_INT128: - disp_length = Firebird::IInt128::STRING_SIZE - 1; + disp_length = IInt128::STRING_SIZE - 1; break; case SQL_DEC34: - disp_length = Firebird::IDecFloat34::STRING_SIZE - 1; + disp_length = IDecFloat34::STRING_SIZE - 1; break; case SQL_TEXT: alignment = 1; @@ -8373,7 +8376,7 @@ static processing_state process_statement(const std::string& str) SINT64 perf_before[ISQL_COUNTERS]; if (setValues.Stats) { - Firebird::UtilInterfacePtr()->getPerfCounters(fbStatus, + UtilInterfacePtr()->getPerfCounters(fbStatus, DB, ISQL_COUNTERS_SET, perf_before); if (ISQL_errmsg(fbStatus)) { @@ -8392,7 +8395,7 @@ static processing_state process_statement(const std::string& str) // But put this on the DDL transaction to get maximum visibility of // metadata. - Firebird::ITransaction* prepare_trans = setValues.Autocommit ? D__trans : M__trans; + ITransaction* prepare_trans = setValues.Autocommit ? D__trans : M__trans; if (global_Stmt) { @@ -8401,13 +8404,13 @@ static processing_state process_statement(const std::string& str) return (SKIP); } - unsigned flags = Firebird::IStatement::PREPARE_PREFETCH_METADATA; + unsigned flags = IStatement::PREPARE_PREFETCH_METADATA; if (setValues.Plan) { if (setValues.ExplainPlan) - flags |= Firebird::IStatement::PREPARE_PREFETCH_DETAILED_PLAN; + flags |= IStatement::PREPARE_PREFETCH_DETAILED_PLAN; else - flags |= Firebird::IStatement::PREPARE_PREFETCH_LEGACY_PLAN; + flags |= IStatement::PREPARE_PREFETCH_LEGACY_PLAN; } if (setValues.AutoTerm) @@ -8494,8 +8497,8 @@ static processing_state process_statement(const std::string& str) if (can_have_input_parameters) { - Firebird::RefPtr - input(Firebird::REF_NO_INCR, global_Stmt->getInputMetadata(fbStatus)); + RefPtr + input(REF_NO_INCR, global_Stmt->getInputMetadata(fbStatus)); if (ISQL_errmsg(fbStatus)) { return ps_ERR; @@ -8653,8 +8656,8 @@ static processing_state process_statement(const std::string& str) return ret; } - Firebird::RefPtr - message(Firebird::REF_NO_INCR, global_Stmt->getOutputMetadata(fbStatus)); + RefPtr + message(REF_NO_INCR, global_Stmt->getOutputMetadata(fbStatus)); if (ISQL_errmsg(fbStatus)) { return ps_ERR; @@ -8744,7 +8747,7 @@ static processing_state process_statement(const std::string& str) { // Otherwise, open the cursor to start things up - Firebird::IResultSet* curs = global_Stmt->openCursor(fbStatus, M__trans, + IResultSet* curs = global_Stmt->openCursor(fbStatus, M__trans, NULL, NULL, message, 0); setValues.StmtTimeout = 0; if (ISQL_errmsg(fbStatus)) @@ -8781,7 +8784,7 @@ static processing_state process_statement(const std::string& str) // Fetch the current cursor - if (curs->fetchNext(fbStatus, buffer) == Firebird::IStatus::RESULT_NO_DATA) + if (curs->fetchNext(fbStatus, buffer) == IStatus::RESULT_NO_DATA) break; // Print the header every Pagelength number of lines for @@ -8893,10 +8896,10 @@ static int query_abort(const int reason, const int, void*) if (DB) { - Firebird::LocalStatus ls; - Firebird::CheckStatusWrapper status(&ls); + LocalStatus ls; + CheckStatusWrapper status(&ls); DB->cancelOperation(&status, fb_cancel_raise); - flag = !(status.getState() & Firebird::IStatus::STATE_ERRORS); + flag = !(status.getState() & IStatus::STATE_ERRORS); } if (flag) @@ -9064,7 +9067,7 @@ static const QualifiedMetaString& charset_to_string(CSetId charset) { csMap->put(CS.RDB$CHARACTER_SET_ID, QualifiedMetaString(CS.RDB$CHARACTER_SET_NAME, CS.RDB$SCHEMA_NAME)); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { err = true; ex.stuffException(fbStatus); @@ -9101,14 +9104,14 @@ const char* PerTableStats::m_itemNames[] = }; -void PerTableStats::getStats(Firebird::IAttachment* att, bool initial) +void PerTableStats::getStats(IAttachment* att, bool initial) { if (initial) m_stat.clear(); else if (!m_initialized) return; - Firebird::Array buffer(*getDefaultMemoryPool(), 32 * 1024); + Array buffer(*getDefaultMemoryPool(), 32 * 1024); unsigned char* buff = buffer.begin(); att->getInfo(fbStatus, sizeof(m_items), m_items, buffer.getCapacity(), buff); @@ -9169,7 +9172,7 @@ void PerTableStats::reset() m_relNames.clear(); } -void PerTableStats::printStats(Firebird::IAttachment* att) +void PerTableStats::printStats(IAttachment* att) { if (m_stat.isEmpty()) return; @@ -9257,7 +9260,7 @@ void PerTableStats::printStats(Firebird::IAttachment* att) } } -unsigned PerTableStats::loadRelNames(Firebird::IAttachment* att) +unsigned PerTableStats::loadRelNames(IAttachment* att) { string sIds; @@ -9324,7 +9327,7 @@ unsigned PerTableStats::loadRelNames(Firebird::IAttachment* att) SSHORT* pRelID_Null = (SSHORT*)(msg + outMeta->getNullOffset(fbStatus, 0)); - while (rs->fetchNext(fbStatus, msg) != Firebird::IStatus::RESULT_NO_DATA) + while (rs->fetchNext(fbStatus, msg) != IStatus::RESULT_NO_DATA) { if (*pRelID_Null == FB_TRUE) continue; @@ -9393,10 +9396,10 @@ bool IsqlWireStats::get(bool initial) m_att->getInfo(fbStatus, sizeof(info), info, sizeof(buffer), buffer); - if (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS) + if (fbStatus->getState() & IStatus::STATE_ERRORS) return false; - Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); + ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); for (; !p.isEof(); p.moveNext()) { FB_UINT64* pField = nullptr; @@ -9481,3 +9484,5 @@ bool IsqlWireStats::print(bool initial) return true; } + +} // namespace Firebird::Isql diff --git a/src/isql/isql.h b/src/isql/isql.h index a0a1991a92f..e9e5c5cd097 100644 --- a/src/isql/isql.h +++ b/src/isql/isql.h @@ -34,13 +34,17 @@ #define ISQL_ISQL_H #include "../jrd/flags.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/intl.h" #include #include #include #include "firebird/impl/msg_helper.h" +namespace Firebird::Isql +{ + + // Define lengths used in isql.e inline constexpr int PRINT_BUFFER_LENGTH = 1024; @@ -241,9 +245,9 @@ class IsqlGlobals USHORT major_ods; USHORT minor_ods; CSetId att_charset; - Firebird::IDecFloat16* df16; - Firebird::IDecFloat34* df34; - Firebird::IInt128* i128; + IDecFloat16* df16; + IDecFloat34* df34; + IInt128* i128; void printf(const char* buffer, ...); void prints(const char* buffer); @@ -317,7 +321,7 @@ struct IsqlVar class IsqlWireStats { public: - explicit IsqlWireStats(Firebird::IAttachment* att) noexcept : + explicit IsqlWireStats(IAttachment* att) noexcept : m_att(att) {} @@ -326,7 +330,7 @@ class IsqlWireStats private: - Firebird::IAttachment* m_att; + IAttachment* m_att; FB_UINT64 m_snd_packets = 0; FB_UINT64 m_rcv_packets = 0; FB_UINT64 m_out_packets = 0; @@ -338,4 +342,7 @@ class IsqlWireStats FB_UINT64 m_roundtrips = 0; }; + +} // namespace Firebird::Isql + #endif // ISQL_ISQL_H diff --git a/src/isql/isql_proto.h b/src/isql/isql_proto.h index 34e959d5bed..642f9ac2a67 100644 --- a/src/isql/isql_proto.h +++ b/src/isql/isql_proto.h @@ -30,21 +30,25 @@ #include "../common/classes/QualifiedMetaString.h" #include +namespace Firebird::Isql +{ + struct IsqlVar; -void ISQL_array_dimensions(const Firebird::QualifiedMetaString&); + +void ISQL_array_dimensions(const QualifiedMetaString&); //void ISQL_build_table_list(void**, FILE*, FILE*, FILE*); //void ISQL_build_view_list(void**, FILE*, FILE*, FILE*); //int ISQL_commit_work(int, FILE*, FILE*, FILE*); bool ISQL_dbcheck(); void ISQL_disconnect_database(bool); -bool ISQL_errmsg(Firebird::IStatus*); -void ISQL_warning(Firebird::IStatus*); +bool ISQL_errmsg(IStatus*); +void ISQL_warning(IStatus*); void ISQL_exit_db(); // CVC: Not found. //int ISQL_extract(TEXT*, int, FILE*, FILE*, FILE*); int ISQL_frontend_command(TEXT*, FILE*, FILE*, FILE*); -bool ISQL_get_base_column_null_flag(const Firebird::QualifiedMetaString&, const SSHORT, const Firebird::MetaString&); +bool ISQL_get_base_column_null_flag(const QualifiedMetaString&, const SSHORT, const MetaString&); // Shall become obsolete when collation become a part of data type as in SQL standard enum class Get { @@ -55,29 +59,32 @@ enum class Get bool ISQL_get_character_sets( SSHORT char_set_id, SSHORT collation, SSHORT default_char_set_id, Get what, - bool not_null, Firebird::string& text); + bool not_null, string& text); SSHORT ISQL_get_default_char_set_id(); -void ISQL_get_domain_default_source(const Firebird::QualifiedMetaString&, ISC_QUAD*); -SSHORT ISQL_get_field_length(const Firebird::QualifiedMetaString&); +void ISQL_get_domain_default_source(const QualifiedMetaString&, ISC_QUAD*); +SSHORT ISQL_get_field_length(const QualifiedMetaString&); SSHORT ISQL_get_char_length( SSHORT fieldLength, SSHORT characterLengthNull, SSHORT characterLength, SSHORT characterSetIdNull, SSHORT characterSetId); -SLONG ISQL_get_index_segments(TEXT*, const size_t, const Firebird::QualifiedMetaString&); -bool ISQL_get_null_flag(const Firebird::QualifiedMetaString&, const Firebird::MetaString&); +SLONG ISQL_get_index_segments(TEXT*, const size_t, const QualifiedMetaString&); +bool ISQL_get_null_flag(const QualifiedMetaString&, const MetaString&); void ISQL_get_version(bool); SSHORT ISQL_init(FILE*, FILE*); int ISQL_main(int, char**); -bool ISQL_printNumericType(const Firebird::QualifiedMetaString& fieldName, const int fieldType, +bool ISQL_printNumericType(const QualifiedMetaString& fieldName, const int fieldType, const int fieldSubType, const int fieldPrecision, const int fieldScale); -void ISQL_print_validation(FILE*, ISC_QUAD*, bool, Firebird::ITransaction*); +void ISQL_print_validation(FILE*, ISC_QUAD*, bool, ITransaction*); //void ISQL_query_database(SSHORT*, FILE*, FILE*, FILE*); //void ISQL_reset_settings(); void ISQL_ri_action_print(const TEXT*, const TEXT*, bool); //int ISQL_sql_statement(TEXT*, FILE*, FILE*, FILE*); //void ISQL_win_err(const char*); -processing_state ISQL_print_item_blob(FILE*, const IsqlVar*, Firebird::ITransaction*, int subtype); -processing_state ISQL_fill_var(IsqlVar*, Firebird::IMessageMetadata*, unsigned, UCHAR*); +processing_state ISQL_print_item_blob(FILE*, const IsqlVar*, ITransaction*, int subtype); +processing_state ISQL_fill_var(IsqlVar*, IMessageMetadata*, unsigned, UCHAR*); bool ISQL_statement_ends_in_comment(const char* statement); + +} // namespace Firebird::Isql + #endif // ISQL_ISQL_PROTO_H diff --git a/src/isql/isqlswi.h b/src/isql/isqlswi.h index 4f976c944f7..4e163ea2a8c 100644 --- a/src/isql/isqlswi.h +++ b/src/isql/isqlswi.h @@ -26,7 +26,11 @@ #define ISQL_ISQLSWI_H #include "ibase.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Isql +{ + enum isql_switches { @@ -109,4 +113,7 @@ static const Switches::in_sw_tab_t isql_in_sw_table[] = {IN_SW_ISQL_0 , 0, NULL , 0, 0, 0, false, false, 0 , 0, NULL, iqoArgNone} }; + +} // namespace Firebird::Isql + #endif // ISQL_ISQLSWI_H diff --git a/src/isql/iutils.cpp b/src/isql/iutils.cpp index 52ccae17341..8eff04943a9 100644 --- a/src/isql/iutils.cpp +++ b/src/isql/iutils.cpp @@ -37,7 +37,9 @@ #include "../common/utils_proto.h" #include -using namespace Firebird; +namespace Firebird::Isql +{ + using MsgFormat::SafeArg; @@ -304,3 +306,6 @@ void IUTILS_truncate_term(TEXT* str, USHORT len) --i; str[i + 1] = 0; } + + +} // namespace Firebird::Isql diff --git a/src/isql/iutils_proto.h b/src/isql/iutils_proto.h index f8f9071a0a8..5763d4283af 100644 --- a/src/isql/iutils_proto.h +++ b/src/isql/iutils_proto.h @@ -29,18 +29,21 @@ #include "../common/classes/SafeArg.h" #include -void IUTILS_copy_SQL_id(const TEXT*, TEXT*, TEXT); -void IUTILS_make_upper(TEXT*); -void IUTILS_msg_get(USHORT number, TEXT* msg, - const MsgFormat::SafeArg& args = MsgFormat::SafeArg()); -void IUTILS_msg_get(USHORT number, USHORT size, TEXT* msg, - const MsgFormat::SafeArg& args = MsgFormat::SafeArg()); -Firebird::string IUTILS_name_to_string(const Firebird::MetaString& name); -Firebird::string IUTILS_name_to_string(const Firebird::QualifiedMetaString& name); -void IUTILS_printf(FILE*, const char*); -void IUTILS_printf2(FILE*, const char*, ...); -void IUTILS_put_errmsg(USHORT number, const MsgFormat::SafeArg& args); -void IUTILS_remove_and_unescape_quotes(TEXT* string, const char quote); -void IUTILS_truncate_term(TEXT*, USHORT); +namespace Firebird::Isql +{ + void IUTILS_copy_SQL_id(const TEXT*, TEXT*, TEXT); + void IUTILS_make_upper(TEXT*); + void IUTILS_msg_get(USHORT number, TEXT* msg, + const MsgFormat::SafeArg& args = MsgFormat::SafeArg()); + void IUTILS_msg_get(USHORT number, USHORT size, TEXT* msg, + const MsgFormat::SafeArg& args = MsgFormat::SafeArg()); + string IUTILS_name_to_string(const MetaString& name); + string IUTILS_name_to_string(const QualifiedMetaString& name); + void IUTILS_printf(FILE*, const char*); + void IUTILS_printf2(FILE*, const char*, ...); + void IUTILS_put_errmsg(USHORT number, const MsgFormat::SafeArg& args); + void IUTILS_remove_and_unescape_quotes(TEXT* string, const char quote); + void IUTILS_truncate_term(TEXT*, USHORT); +} // namespace Firebird::Isql #endif // ISQL_IUTILS_PROTO_H diff --git a/src/isql/main.cpp b/src/isql/main.cpp index 69a46d93931..06ccefa7c63 100644 --- a/src/isql/main.cpp +++ b/src/isql/main.cpp @@ -28,13 +28,15 @@ int CLIB_ROUTINE main(int argc, char* argv[]) { + using namespace Firebird; + try { - return ISQL_main(argc, argv); + return Isql::ISQL_main(argc, argv); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { - Firebird::StaticStatusVector st; + StaticStatusVector st; ex.stuffException(st); isc_print_status(st.begin()); } diff --git a/src/isql/show.epp b/src/isql/show.epp index 0b7a0ddcda1..62889196bba 100644 --- a/src/isql/show.epp +++ b/src/isql/show.epp @@ -51,11 +51,11 @@ #include "../isql/isql_proto.h" #include "../isql/show_proto.h" #include "../isql/iutils_proto.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/ods.h" #include "../isql/extra_proto.h" #include "../common/utils_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/UserBlob.h" #include "../common/classes/VaryStr.h" #include "../common/classes/ImplementHelper.h" @@ -69,7 +69,9 @@ #include #endif -using namespace Firebird; +namespace Firebird::Isql +{ + using MsgFormat::SafeArg; @@ -130,11 +132,11 @@ namespace { // and not to stdout if IUtil::version gets called class VersionCallback : - public Firebird::AutoIface > + public AutoIface > { public: // IVersionCallback implementation - void callback(Firebird::CheckStatusWrapper*, const char* text) + void callback(CheckStatusWrapper*, const char* text) { isqlGlob.printf("%s%s", text, NEWLINE); } @@ -392,7 +394,7 @@ void SHOW_comments(bool force) } -void SHOW_dbb_parameters(Firebird::IAttachment* db_handle, +void SHOW_dbb_parameters(IAttachment* db_handle, const UCHAR* db_itemsL, unsigned item_length, bool translate, @@ -415,16 +417,16 @@ void SHOW_dbb_parameters(Firebird::IAttachment* db_handle, UCHAR buffer[BUFFER_LENGTH400]; TEXT msg[MSG_LENGTH]; - Firebird::AutoPtr + AutoPtr status_vector(fbMaster->getStatus()); - Firebird::CheckStatusWrapper statusWrapper(status_vector); + CheckStatusWrapper statusWrapper(status_vector); db_handle->getInfo(&statusWrapper, item_length, db_itemsL, sizeof(buffer), buffer); if (ISQL_errmsg(status_vector)) return; bool crdatePrinted = false; - for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) + for (ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) { const UCHAR item = p.getClumpTag(); SINT64 value_out = 0; @@ -482,7 +484,7 @@ void SHOW_dbb_parameters(Firebird::IAttachment* db_handle, value_out = p.getBigInt(); if (translate) { - Firebird::string s; + string s; if (value_out & fb_info_crypt_encrypted) IUTILS_msg_get(DATABASE_CRYPTED, msg); else @@ -620,9 +622,9 @@ void SHOW_dbb_parameters(Firebird::IAttachment* db_handle, tsz.time_zone = ISQL_vax_integer(t, sizeof(ULONG)); unsigned year, month, day, hours, minutes, seconds, fractions; - char timeZone[Firebird::TimeZoneUtil::MAX_SIZE]; + char timeZone[TimeZoneUtil::MAX_SIZE]; - Firebird::UtilInterfacePtr()->decodeTimeStampTz(fbStatus, &tsz, + UtilInterfacePtr()->decodeTimeStampTz(fbStatus, &tsz, &year, &month, &day, &hours, &minutes, &seconds, &fractions, sizeof(timeZone), timeZone); if (ISQL_errmsg(fbStatus)) @@ -1721,7 +1723,7 @@ void SHOW_print_metadata_text_blob(FILE* fp, ISC_QUAD* blobid, bool escape_squot if (UserBlob::blobIsNull(*blobid)) return; - Firebird::IBlob* blob = DB->openBlob(fbStatus, fbTrans, blobid, + IBlob* blob = DB->openBlob(fbStatus, fbTrans, blobid, sizeof(metadata_text_bpb), metadata_text_bpb); if (ISQL_errmsg(fbStatus)) return; @@ -1734,7 +1736,7 @@ void SHOW_print_metadata_text_blob(FILE* fp, ISC_QUAD* blobid, bool escape_squot { unsigned int length; const int cc = blob->getSegment(fbStatus, sizeof(buffer) - 1, buffer, &length); - if (cc == Firebird::IStatus::RESULT_NO_DATA || cc == Firebird::IStatus::RESULT_ERROR) + if (cc == IStatus::RESULT_NO_DATA || cc == IStatus::RESULT_ERROR) break; // ASF: In Windows, \n characters are printed as \r\n in text mode. @@ -1796,7 +1798,7 @@ void SHOW_print_metadata_text_blob(FILE* fp, ISC_QUAD* blobid, bool escape_squot fullText += "\r"; } - if (fbStatus->getState() & Firebird::IStatus::STATE_ERRORS) + if (fbStatus->getState() & IStatus::STATE_ERRORS) ISQL_errmsg(fbStatus); blob->close(fbStatus); @@ -4593,8 +4595,8 @@ static processing_state show_generators(const std::optional **************************************/ bool found = false; - Firebird::RefPtr - mb(Firebird::REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 1)); + RefPtr + mb(REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 1)); if (ISQL_errmsg (fbStatus)) return ps_ERR; @@ -4606,12 +4608,12 @@ static processing_state show_generators(const std::optional if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::RefPtr - outMetadata(Firebird::REF_NO_INCR, mb->getMetadata(fbStatus)); + RefPtr + outMetadata(REF_NO_INCR, mb->getMetadata(fbStatus)); if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::AlignedBuffer<20> outBuffer; + AlignedBuffer<20> outBuffer; fb_assert(outMetadata->getMessageLength(fbStatus) <= outBuffer.size()); const unsigned off = outMetadata->getOffset(fbStatus, 0); if (ISQL_errmsg (fbStatus)) @@ -6551,8 +6553,8 @@ static processing_state show_users12() (isqlGlob.major_ods >= ODS_VERSION14 ? "SYSTEM." : ""), (isqlGlob.major_ods >= ODS_VERSION14 ? "SYSTEM." : "")); - Firebird::RefPtr - mb(Firebird::REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 3)); + RefPtr + mb(REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 3)); if (ISQL_errmsg (fbStatus)) return ps_ERR; @@ -6574,12 +6576,12 @@ static processing_state show_users12() if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::RefPtr - outMetadata(Firebird::REF_NO_INCR, mb->getMetadata(fbStatus)); + RefPtr + outMetadata(REF_NO_INCR, mb->getMetadata(fbStatus)); if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::AlignedBuffer outBuffer; + AlignedBuffer outBuffer; fb_assert(outMetadata->getMessageLength(fbStatus) <= outBuffer.size()); const char* mark = reinterpret_cast(&outBuffer[outMetadata->getOffset(fbStatus, 0)]); @@ -6592,14 +6594,14 @@ static processing_state show_users12() if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::IResultSet* rs = DB->openCursor(fbStatus, fbTrans, 0, sql.c_str(), isqlGlob.SQL_dialect, + IResultSet* rs = DB->openCursor(fbStatus, fbTrans, 0, sql.c_str(), isqlGlob.SQL_dialect, NULL, NULL, outMetadata, NULL, 0); if (ISQL_errmsg (fbStatus)) return ps_ERR; processing_state rc = OBJECT_NOT_FOUND; - while (rs->fetchNext(fbStatus, outBuffer) == Firebird::IStatus::RESULT_OK) + while (rs->fetchNext(fbStatus, outBuffer) == IStatus::RESULT_OK) { if (rc == OBJECT_NOT_FOUND) { @@ -6645,8 +6647,8 @@ static processing_state show_users() TEXT msg[MSG_LENGTH]; // When messages can be translated. - Firebird::RefPtr - mb(Firebird::REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 1)); + RefPtr + mb(REF_NO_INCR, fbMaster->getMetadataBuilder(fbStatus, 1)); if (ISQL_errmsg (fbStatus)) return ps_ERR; mb->setType(fbStatus, 0, SQL_VARYING); @@ -6656,12 +6658,12 @@ static processing_state show_users() if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::RefPtr - outMetadata(Firebird::REF_NO_INCR, mb->getMetadata(fbStatus)); + RefPtr + outMetadata(REF_NO_INCR, mb->getMetadata(fbStatus)); if (ISQL_errmsg (fbStatus)) return ps_ERR; - Firebird::AlignedBuffer outBuffer; + AlignedBuffer outBuffer; fb_assert(outMetadata->getMessageLength(fbStatus) <= outBuffer.size()); unsigned off = outMetadata->getOffset(fbStatus, 0); if (ISQL_errmsg (fbStatus)) @@ -6685,7 +6687,7 @@ static processing_state show_users() processing_state rc = OBJECT_NOT_FOUND; - for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) + for (ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) { switch (p.getClumpTag()) { @@ -6735,3 +6737,6 @@ static processing_state show_wireStats() return SKIP; } + + +} // namespace Firebird::Isql diff --git a/src/isql/show_proto.h b/src/isql/show_proto.h index c272e0b07d6..fd907ea48c7 100644 --- a/src/isql/show_proto.h +++ b/src/isql/show_proto.h @@ -28,22 +28,25 @@ #include "../common/classes/QualifiedMetaString.h" #include #include "../isql/FrontendParser.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include -void SHOW_comments(bool force); -void SHOW_dbb_parameters (Firebird::IAttachment*, const UCHAR*, unsigned, bool, const char*); -processing_state SHOW_ddl_grants(const std::optional&, - const SCHAR*, ObjectType, const TEXT*); -processing_state SHOW_grants(const std::optional&, - const SCHAR*, ObjectType, const TEXT*); -void SHOW_grant_roles(const SCHAR*, bool*, const TEXT*); -void SHOW_print_metadata_text_blob(FILE*, ISC_QUAD*, bool escape_squote = false, - bool avoid_end_in_single_line_comment = false); -processing_state SHOW_metadata(const FrontendParser::AnyShowNode& node); -void SHOW_read_owner() noexcept; -const Firebird::string SHOW_trigger_action(SINT64); -processing_state SHOW_maps(bool extract, const std::optional& name); -bool SHOW_system_privileges(const Firebird::MetaString& name, const char* prfx, bool lf); +namespace Firebird::Isql +{ + void SHOW_comments(bool force); + void SHOW_dbb_parameters (IAttachment*, const UCHAR*, unsigned, bool, const char*); + processing_state SHOW_ddl_grants(const std::optional&, + const SCHAR*, ObjectType, const TEXT*); + processing_state SHOW_grants(const std::optional&, + const SCHAR*, ObjectType, const TEXT*); + void SHOW_grant_roles(const SCHAR*, bool*, const TEXT*); + void SHOW_print_metadata_text_blob(FILE*, ISC_QUAD*, bool escape_squote = false, + bool avoid_end_in_single_line_comment = false); + processing_state SHOW_metadata(const FrontendParser::AnyShowNode& node); + void SHOW_read_owner() noexcept; + const string SHOW_trigger_action(SINT64); + processing_state SHOW_maps(bool extract, const std::optional& name); + bool SHOW_system_privileges(const MetaString& name, const char* prfx, bool lf); +} // namespace Firebird::Isql #endif // ISQL_SHOW_PROTO_H diff --git a/src/isql/tests/FrontendLexerTest.cpp b/src/isql/tests/FrontendLexerTest.cpp index b17a1c7d6e3..dfe79811dbd 100644 --- a/src/isql/tests/FrontendLexerTest.cpp +++ b/src/isql/tests/FrontendLexerTest.cpp @@ -27,6 +27,7 @@ #include using namespace Firebird; +using namespace Firebird::Isql; BOOST_AUTO_TEST_SUITE(ISqlSuite) BOOST_AUTO_TEST_SUITE(FrontendLexerSuite) diff --git a/src/isql/tests/FrontendParserTest.cpp b/src/isql/tests/FrontendParserTest.cpp index d4f62903351..6987e91c903 100644 --- a/src/isql/tests/FrontendParserTest.cpp +++ b/src/isql/tests/FrontendParserTest.cpp @@ -27,6 +27,7 @@ #include using namespace Firebird; +using namespace Firebird::Isql; BOOST_AUTO_TEST_SUITE(ISqlSuite) BOOST_AUTO_TEST_SUITE(FrontendParserSuite) diff --git a/src/jrd/Attachment.cpp b/src/jrd/Attachment.cpp index cc4c22550da..5fde2dfca2d 100644 --- a/src/jrd/Attachment.cpp +++ b/src/jrd/Attachment.cpp @@ -60,12 +60,13 @@ #include "../common/classes/RefMutex.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + /// class ActiveSnapshots -ActiveSnapshots::ActiveSnapshots(Firebird::MemoryPool& p) : +ActiveSnapshots::ActiveSnapshots(MemoryPool& p) : m_snapshots(p), m_lastCommit(CN_ACTIVE), m_releaseCount(0), @@ -90,7 +91,7 @@ CommitNumber ActiveSnapshots::getSnapshotForVersion(CommitNumber version_cn) // static method -Jrd::Attachment* Jrd::Attachment::create(Database* dbb, JProvider* provider) +Attachment* Attachment::create(Database* dbb, JProvider* provider) { MemoryPool* const pool = dbb->createPool(false); @@ -100,7 +101,7 @@ Jrd::Attachment* Jrd::Attachment::create(Database* dbb, JProvider* provider) pool->setStatsGroup(attachment->att_memory_stats); return attachment; } - catch (const Firebird::Exception&) + catch (const Exception&) { dbb->deletePool(pool); throw; @@ -109,7 +110,7 @@ Jrd::Attachment* Jrd::Attachment::create(Database* dbb, JProvider* provider) // static method -void Jrd::Attachment::destroy(Attachment* const attachment) +void Attachment::destroy(Attachment* const attachment) { if (!attachment) return; @@ -142,7 +143,7 @@ void Jrd::Attachment::destroy(Attachment* const attachment) } MemoryPool* const pool = attachment->att_pool; - Firebird::MemoryStats temp_stats; + MemoryStats temp_stats; pool->setStatsGroup(temp_stats); delete attachment; @@ -151,7 +152,7 @@ void Jrd::Attachment::destroy(Attachment* const attachment) } -bool Jrd::Attachment::backupStateWriteLock(thread_db* tdbb, SSHORT wait) +bool Attachment::backupStateWriteLock(thread_db* tdbb, SSHORT wait) { if (att_backup_state_counter++) return true; @@ -164,14 +165,14 @@ bool Jrd::Attachment::backupStateWriteLock(thread_db* tdbb, SSHORT wait) } -void Jrd::Attachment::backupStateWriteUnLock(thread_db* tdbb) +void Attachment::backupStateWriteUnLock(thread_db* tdbb) { if (--att_backup_state_counter == 0) att_database->dbb_backup_manager->unlockStateWrite(tdbb); } -bool Jrd::Attachment::backupStateReadLock(thread_db* tdbb, SSHORT wait) +bool Attachment::backupStateReadLock(thread_db* tdbb, SSHORT wait) { if (att_backup_state_counter++) return true; @@ -184,14 +185,14 @@ bool Jrd::Attachment::backupStateReadLock(thread_db* tdbb, SSHORT wait) } -void Jrd::Attachment::backupStateReadUnLock(thread_db* tdbb) +void Attachment::backupStateReadUnLock(thread_db* tdbb) { if (--att_backup_state_counter == 0) att_database->dbb_backup_manager->unlockStateRead(tdbb); } -Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, JProvider* provider) +Attachment::Attachment(MemoryPool* pool, Database* dbb, JProvider* provider) : att_pool(pool), att_memory_stats(&dbb->dbb_memory_stats), att_database(dbb), @@ -245,7 +246,7 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, JProvider* provider } -Jrd::Attachment::~Attachment() +Attachment::~Attachment() { if (att_idle_timer) att_idle_timer->stop(); @@ -262,31 +263,31 @@ Jrd::Attachment::~Attachment() } -Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction, - const string& text, Firebird::MemoryPool* pool) +PreparedStatement* Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction, + const string& text, MemoryPool* pool) { pool = pool ? pool : tdbb->getDefaultPool(); return FB_NEW_POOL(*pool) PreparedStatement(tdbb, *pool, this, transaction, text, true); } -Jrd::PreparedStatement* Jrd::Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction, - const PreparedStatement::Builder& builder, Firebird::MemoryPool* pool) +PreparedStatement* Attachment::prepareStatement(thread_db* tdbb, jrd_tra* transaction, + const PreparedStatement::Builder& builder, MemoryPool* pool) { pool = pool ? pool : tdbb->getDefaultPool(); return FB_NEW_POOL(*pool) PreparedStatement(tdbb, *pool, this, transaction, builder, true); } -PreparedStatement* Jrd::Attachment::prepareUserStatement(thread_db* tdbb, jrd_tra* transaction, - const string& text, Firebird::MemoryPool* pool) +PreparedStatement* Attachment::prepareUserStatement(thread_db* tdbb, jrd_tra* transaction, + const string& text, MemoryPool* pool) { pool = pool ? pool : tdbb->getDefaultPool(); return FB_NEW_POOL(*pool) PreparedStatement(tdbb, *pool, this, transaction, text, false); } -MetaName Jrd::Attachment::nameToMetaCharSet(thread_db* tdbb, const MetaName& name) +MetaName Attachment::nameToMetaCharSet(thread_db* tdbb, const MetaName& name) { if (att_charset == CS_METADATA || att_charset == CS_NONE) return name; @@ -300,7 +301,7 @@ MetaName Jrd::Attachment::nameToMetaCharSet(thread_db* tdbb, const MetaName& nam } -MetaName Jrd::Attachment::nameToUserCharSet(thread_db* tdbb, const MetaName& name) +MetaName Attachment::nameToUserCharSet(thread_db* tdbb, const MetaName& name) { if (att_charset == CS_METADATA || att_charset == CS_NONE) return name; @@ -314,7 +315,7 @@ MetaName Jrd::Attachment::nameToUserCharSet(thread_db* tdbb, const MetaName& nam } -string Jrd::Attachment::stringToUserCharSet(thread_db* tdbb, const string& str) +string Attachment::stringToUserCharSet(thread_db* tdbb, const string& str) { if (att_charset == CS_METADATA || att_charset == CS_NONE) return str; @@ -328,7 +329,7 @@ string Jrd::Attachment::stringToUserCharSet(thread_db* tdbb, const string& str) // We store in CS_METADATA. -void Jrd::Attachment::storeMetaDataBlob(thread_db* tdbb, jrd_tra* transaction, +void Attachment::storeMetaDataBlob(thread_db* tdbb, jrd_tra* transaction, bid* blobId, const string& text, USHORT fromCharSet) { UCharBuffer bpb; @@ -351,7 +352,7 @@ void Jrd::Attachment::storeMetaDataBlob(thread_db* tdbb, jrd_tra* transaction, // We store raw stuff; don't attempt to translate. -void Jrd::Attachment::storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction, +void Attachment::storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction, bid* blobId, const ByteChunk& chunk) { blb* blob = blb::create2(tdbb, transaction, blobId, 0, NULL); @@ -368,13 +369,13 @@ void Jrd::Attachment::storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction, blob->BLB_close(tdbb); } -void Jrd::Attachment::releaseBatches() +void Attachment::releaseBatches() { while (att_batches.hasData()) delete att_batches.pop(); } -void Jrd::Attachment::releaseLocalTempTables(thread_db* tdbb) +void Attachment::releaseLocalTempTables(thread_db* tdbb) { HalfStaticArray tempRelations; @@ -392,7 +393,7 @@ void Jrd::Attachment::releaseLocalTempTables(thread_db* tdbb) } } -void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle) +void Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle) { jrd_tra* oldTran = traHandle ? *traHandle : nullptr; if (att_transactions) @@ -509,7 +510,7 @@ void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle) } -void Jrd::Attachment::signalCancel() +void Attachment::signalCancel() { att_flags |= ATT_cancel_raise; @@ -520,7 +521,7 @@ void Jrd::Attachment::signalCancel() } -void Jrd::Attachment::signalShutdown(ISC_STATUS code) +void Attachment::signalShutdown(ISC_STATUS code) { att_flags |= ATT_shutdown; if (getStable()) @@ -533,7 +534,7 @@ void Jrd::Attachment::signalShutdown(ISC_STATUS code) } -void Jrd::Attachment::mergeStats(bool pageStatsOnly) +void Attachment::mergeStats(bool pageStatsOnly) { MutexLockGuard guard(att_database->dbb_stats_mutex, FB_FUNCTION); @@ -564,7 +565,7 @@ bool Attachment::hasActiveRequests() const noexcept } -void Jrd::Attachment::initLocks(thread_db* tdbb) +void Attachment::initLocks(thread_db* tdbb) { // Take out lock on attachment id @@ -605,7 +606,7 @@ void Jrd::Attachment::initLocks(thread_db* tdbb) } } -void Jrd::Attachment::releaseLocks(thread_db* tdbb) +void Attachment::releaseLocks(thread_db* tdbb) { // Release the DSQL cache locks @@ -639,7 +640,7 @@ void Jrd::Attachment::releaseLocks(thread_db* tdbb) LCK_release(tdbb, att_profiler_listener_lock); } -void Jrd::Attachment::detachLocks() +void Attachment::detachLocks() { /************************************** * @@ -668,9 +669,9 @@ void Jrd::Attachment::detachLocks() att_long_locks = NULL; } -int Jrd::Attachment::blockingAstShutdown(void* ast_object) +int Attachment::blockingAstShutdown(void* ast_object) { - Jrd::Attachment* const attachment = static_cast(ast_object); + Attachment* const attachment = static_cast(ast_object); try { @@ -688,9 +689,9 @@ int Jrd::Attachment::blockingAstShutdown(void* ast_object) return 0; } -int Jrd::Attachment::blockingAstCancel(void* ast_object) +int Attachment::blockingAstCancel(void* ast_object) { - Jrd::Attachment* const attachment = static_cast(ast_object); + Attachment* const attachment = static_cast(ast_object); try { @@ -708,9 +709,9 @@ int Jrd::Attachment::blockingAstCancel(void* ast_object) return 0; } -int Jrd::Attachment::blockingAstMonitor(void* ast_object) +int Attachment::blockingAstMonitor(void* ast_object) { - const auto attachment = static_cast(ast_object); + const auto attachment = static_cast(ast_object); try { @@ -739,7 +740,7 @@ int Jrd::Attachment::blockingAstMonitor(void* ast_object) return 0; } -void Jrd::Attachment::SyncGuard::init(const char* f, bool +void Attachment::SyncGuard::init(const char* f, bool #ifdef DEV_BUILD optional #endif @@ -1019,3 +1020,6 @@ void Attachment::qualifyExistingName(thread_db* tdbb, QualifiedName& name, } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/Attachment.h b/src/jrd/Attachment.h index 5361985ba01..12217bb7a1d 100644 --- a/src/jrd/Attachment.h +++ b/src/jrd/Attachment.h @@ -57,17 +57,15 @@ #include -namespace EDS { +namespace Firebird::Jrd::EDS { class Connection; } -namespace Replication -{ +namespace Firebird::Jrd::Replication { class TableMatcher; } -namespace Jrd -{ +namespace Firebird::Jrd { class thread_db; class Database; class jrd_tra; @@ -77,7 +75,6 @@ namespace Jrd class Format; class BufferControl; class PageToBufferMap; - class SparseBitmap; class jrd_rel; class ExternalFile; class ViewContext; @@ -98,9 +95,13 @@ namespace Jrd class Statement; class ProfilerManager; class Validation; - class Applier; enum InternalRequest : USHORT; + namespace Replication + { + class Applier; + } + struct DSqlCacheItem { @@ -112,14 +113,14 @@ struct DSqlCacheItem { } - Firebird::string key; - Firebird::LeftPooledMap obsoleteMap; + string key; + LeftPooledMap obsoleteMap; Lock* lock; bool locked; }; -typedef Firebird::GenericMap > > DSqlCache; +typedef GenericMap > > DSqlCache; struct DdlTriggerContext @@ -134,12 +135,12 @@ struct DdlTriggerContext { } - Firebird::string eventType; - Firebird::string objectType; + string eventType; + string objectType; QualifiedName objectName; QualifiedName oldObjectName; QualifiedName newObjectName; - Firebird::string sqlText; + string sqlText; }; @@ -182,7 +183,7 @@ struct bid; class ActiveSnapshots { public: - explicit ActiveSnapshots(Firebird::MemoryPool& p); + explicit ActiveSnapshots(MemoryPool& p); // Returns snapshot number given version belongs to. // It is not needed to maintain two versions for the same snapshot, so the latter @@ -193,7 +194,7 @@ class ActiveSnapshots CommitNumber getSnapshotForVersion(CommitNumber version_cn); private: - Firebird::SparseBitmap m_snapshots; // List of active snapshots as of the moment of time + SparseBitmap m_snapshots; // List of active snapshots as of the moment of time CommitNumber m_lastCommit; // CN_ACTIVE here means object is not populated ULONG m_releaseCount; // Release event counter when list was last updated ULONG m_slots_used; // Snapshot slots used when list was last updated @@ -205,7 +206,7 @@ class ActiveSnapshots // // RefCounted part of Attachment object, placed into permanent pool // -class StableAttachmentPart : public Firebird::RefCounted, public Firebird::GlobalStorage +class StableAttachmentPart : public RefCounted, public GlobalStorage { public: class Sync @@ -298,7 +299,7 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa } private: - Firebird::Mutex syncMutex; + Mutex syncMutex; std::atomic waiters; ThreadId threadId; std::atomic totalLocksCounter; @@ -337,7 +338,7 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa return useAsync ? &async : &mainSync; } - Firebird::Mutex* getBlockingMutex() noexcept + Mutex* getBlockingMutex() noexcept { return &blockingMutex; } @@ -349,12 +350,12 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa att = NULL; } - jrd_tra* getEngineTransaction(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra) + jrd_tra* getEngineTransaction(CheckStatusWrapper* status, ITransaction* tra) { return getInterface()->getEngineTransaction(status, tra); } - JTransaction* getTransactionInterface(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra) + JTransaction* getTransactionInterface(CheckStatusWrapper* status, ITransaction* tra) { return getInterface()->getTransactionInterface(status, tra); } @@ -374,13 +375,13 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa return shutError; } - void onIdleTimer(Firebird::TimerImpl* timer) + void onIdleTimer(TimerImpl* timer) { doOnIdleTimer(timer); } protected: - virtual void doOnIdleTimer(Firebird::TimerImpl* timer); + virtual void doOnIdleTimer(TimerImpl* timer); private: Attachment* att; @@ -391,11 +392,11 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa // zero att_use_count one should check does attachment still exists calling getHandle(). Sync mainSync, async; // This mutex guarantees attachment is not accessed by more than single external thread. - Firebird::Mutex blockingMutex; + Mutex blockingMutex; }; -typedef Firebird::RaiiLockGuard AttSyncLockGuard; -typedef Firebird::RaiiUnlockGuard AttSyncUnlockGuard; +typedef RaiiLockGuard AttSyncLockGuard; +typedef RaiiUnlockGuard AttSyncUnlockGuard; // // the attachment block; one is created for each attachment to a database @@ -431,7 +432,7 @@ class Attachment : public pool_alloc private: void init(const char* f, bool optional); - Firebird::RefPtr jStable; + RefPtr jStable; }; class InitialOptions @@ -439,9 +440,9 @@ class Attachment : public pool_alloc public: InitialOptions(MemoryPool& pool) : bindings(pool), - schemaSearchPath(FB_NEW_POOL(pool) Firebird::AnyRef>(pool)), + schemaSearchPath(FB_NEW_POOL(pool) AnyRef>(pool)), blrRequestSchemaSearchPath( - FB_NEW_POOL(pool) Firebird::AnyRef>(pool)) + FB_NEW_POOL(pool) AnyRef>(pool)) { } @@ -460,11 +461,11 @@ class Attachment : public pool_alloc } private: - Firebird::DecimalStatus decFloatStatus = Firebird::DecimalStatus::DEFAULT; + DecimalStatus decFloatStatus = DecimalStatus::DEFAULT; CoercionArray bindings; - Firebird::RefPtr>> schemaSearchPath; - Firebird::RefPtr>> blrRequestSchemaSearchPath; - USHORT originalTimeZone = Firebird::TimeZoneUtil::GMT_ZONE; + RefPtr>> schemaSearchPath; + RefPtr>> blrRequestSchemaSearchPath; + USHORT originalTimeZone = TimeZoneUtil::GMT_ZONE; }; class DebugOptions @@ -509,7 +510,7 @@ class Attachment : public pool_alloc static void destroy(Attachment* const attachment); MemoryPool* const att_pool; // Memory pool - Firebird::MemoryStats att_memory_stats; + MemoryStats att_memory_stats; Database* att_database; // Parent database block Attachment* att_next; // Next attachment to database @@ -526,7 +527,7 @@ class Attachment : public pool_alloc StableAttachmentPart* att_stable; public: - Firebird::SortedArray att_requests; // Requests belonging to attachment + SortedArray att_requests; // Requests belonging to attachment Lock* att_id_lock; // Attachment lock (if any) AttNumber att_attachment_id; // Attachment ID @@ -561,25 +562,25 @@ class Attachment : public pool_alloc std::atomic att_wait_owner_handle; // lock owner with which attachment waits currently vec* att_compatibility_table; // hash table of compatible locks Validation* att_validation; - Firebird::PathName att_working_directory; // Current working directory is cached - Firebird::PathName att_filename; // alias used to attach the database + PathName att_working_directory; // Current working directory is cached + PathName att_filename; // alias used to attach the database ISC_TIMESTAMP_TZ att_timestamp; // Connection date and time - Firebird::StringMap att_context_vars; // Context variables for the connection - Firebird::Stack ddlTriggersContext; // Context variables for DDL trigger event - Firebird::string att_network_protocol; // Network protocol used by client for connection - Firebird::PathName att_remote_crypt; // Name of wire crypt plugin (if any) - Firebird::string att_remote_address; // Protocol-specific address of remote client + StringMap att_context_vars; // Context variables for the connection + Stack ddlTriggersContext; // Context variables for DDL trigger event + string att_network_protocol; // Network protocol used by client for connection + PathName att_remote_crypt; // Name of wire crypt plugin (if any) + string att_remote_address; // Protocol-specific address of remote client SLONG att_remote_pid; // Process id of remote client ULONG att_remote_flags; // Flags specific for server/client link - Firebird::PathName att_remote_process; // Process name of remote client - Firebird::string att_client_version; // Version of the client library - Firebird::string att_remote_protocol; // Details about the remote protocol - Firebird::string att_remote_host; // Host name of remote client - Firebird::string att_remote_os_user; // OS user name of remote client + PathName att_remote_process; // Process name of remote client + string att_client_version; // Version of the client library + string att_remote_protocol; // Details about the remote protocol + string att_remote_host; // Host name of remote client + string att_remote_os_user; // OS user name of remote client RandomGenerator att_random_generator; // Random bytes generator Lock* att_temp_pg_lock; // temporary pagespace ID lock DSqlCache att_dsql_cache; // DSQL cache locks - Firebird::SortedArray att_udf_pointers; + SortedArray att_udf_pointers; dsql_dbb* att_dsql_instance; bool att_in_use; // attachment in use (can't be detached or dropped) int att_use_count; // number of API calls running except of asynchronous ones @@ -594,32 +595,32 @@ class Attachment : public pool_alloc CoercionArray* att_dest_bind; USHORT att_original_timezone; USHORT att_current_timezone; - Firebird::RefPtr>> att_schema_search_path; - Firebird::RefPtr>> att_blr_request_schema_search_path; - Firebird::RefPtr>> att_system_schema_search_path; + RefPtr>> att_schema_search_path; + RefPtr>> att_blr_request_schema_search_path; + RefPtr>> att_system_schema_search_path; - Firebird::RefPtr>> + RefPtr>> att_unqualified_charset_resolved_cache_search_path; - Firebird::NonPooledMap att_unqualified_charset_resolved_cache; + NonPooledMap att_unqualified_charset_resolved_cache; int att_parallel_workers; - Firebird::TriState att_opt_first_rows; + TriState att_opt_first_rows; PageToBufferMap* att_bdb_cache; // managed in CCH, created in att_pool, freed with it - Firebird::LeftPooledMap att_local_temporary_tables; + LeftPooledMap att_local_temporary_tables; std::optional att_next_ltt_id; // Next available LTT relation ID - Firebird::RefPtr att_replicator; - Firebird::AutoPtr att_repl_matcher; - Firebird::Array att_repl_appliers; + RefPtr att_replicator; + AutoPtr att_repl_matcher; + Array att_repl_appliers; enum UtilType { UTIL_NONE, UTIL_GBAK, UTIL_GFIX, UTIL_GSTAT }; UtilType att_utility; - Firebird::ICryptKeyCallback* att_crypt_callback; // callback for DB crypt - Firebird::DecimalStatus att_dec_status; // error handling and rounding + ICryptKeyCallback* att_crypt_callback; // callback for DB crypt + DecimalStatus att_dec_status; // error handling and rounding void initLocks(thread_db* tdbb); void releaseLocks(thread_db* tdbb); @@ -653,21 +654,21 @@ class Attachment : public pool_alloc bool isUtility() const noexcept; // gbak, gfix and gstat. PreparedStatement* prepareStatement(thread_db* tdbb, jrd_tra* transaction, - const Firebird::string& text, Firebird::MemoryPool* pool = NULL); + const string& text, MemoryPool* pool = NULL); PreparedStatement* prepareStatement(thread_db* tdbb, jrd_tra* transaction, - const PreparedStatement::Builder& builder, Firebird::MemoryPool* pool = NULL); + const PreparedStatement::Builder& builder, MemoryPool* pool = NULL); PreparedStatement* prepareUserStatement(thread_db* tdbb, jrd_tra* transaction, - const Firebird::string& text, Firebird::MemoryPool* pool = NULL); + const string& text, MemoryPool* pool = NULL); MetaName nameToMetaCharSet(thread_db* tdbb, const MetaName& name); MetaName nameToUserCharSet(thread_db* tdbb, const MetaName& name); - Firebird::string stringToUserCharSet(thread_db* tdbb, const Firebird::string& str); + string stringToUserCharSet(thread_db* tdbb, const string& str); void storeMetaDataBlob(thread_db* tdbb, jrd_tra* transaction, - bid* blobId, const Firebird::string& text, USHORT fromCharSet = CS_METADATA); + bid* blobId, const string& text, USHORT fromCharSet = CS_METADATA); void storeBinaryBlob(thread_db* tdbb, jrd_tra* transaction, bid* blobId, - const Firebird::ByteChunk& chunk); + const ByteChunk& chunk); void releaseBatches(); void releaseLocalTempTables(thread_db* tdbb); @@ -742,15 +743,15 @@ class Attachment : public pool_alloc att_batches.findAndRemove(b); } - UserId* getUserId(const Firebird::MetaString& userName); + UserId* getUserId(const MetaString& userName); - const Firebird::MetaString& getUserName(const Firebird::MetaString& emptyName = "") + const MetaString& getUserName(const MetaString& emptyName = "") { saveMetaString(!att_user, att_retUser, emptyName); return att_user ? att_user->getUserName() : *att_retUser; } - const Firebird::MetaString& getSqlRole(const Firebird::MetaString& emptyName = "") + const MetaString& getSqlRole(const MetaString& emptyName = "") { saveMetaString(!att_user, att_retRole, emptyName); return att_user ? att_user->getSqlRole() : *att_retRole; @@ -763,7 +764,7 @@ class Attachment : public pool_alloc return att_user; } - const Firebird::MetaString& getEffectiveUserName(const Firebird::MetaString& emptyName = "") const + const MetaString& getEffectiveUserName(const MetaString& emptyName = "") const { const auto user = getEffectiveUserId(); return user ? user->getUserName() : emptyName; @@ -797,11 +798,11 @@ class Attachment : public pool_alloc } bool qualifyNewName(thread_db* tdbb, QualifiedName& name, - const Firebird::ObjectsArray* schemaSearchPath = nullptr); + const ObjectsArray* schemaSearchPath = nullptr); void qualifyExistingName(thread_db* tdbb, QualifiedName& name, std::initializer_list objTypes, - const Firebird::ObjectsArray* schemaSearchPath = nullptr); + const ObjectsArray* schemaSearchPath = nullptr); private: Attachment(MemoryPool* pool, Database* dbb, JProvider* provider); @@ -809,23 +810,23 @@ class Attachment : public pool_alloc unsigned int att_idle_timeout; // seconds unsigned int att_stmt_timeout; // milliseconds - Firebird::RefPtr att_idle_timer; + RefPtr att_idle_timer; - Firebird::Array att_batches; + Array att_batches; InitialOptions att_initial_options; // Initial session options DebugOptions att_debug_options; - Firebird::AutoPtr att_profiler_manager; // ProfilerManager + AutoPtr att_profiler_manager; // ProfilerManager Lock* att_repl_lock; // Replication set lock JProvider* att_provider; // Provider which created this attachment - Firebird::AutoPtr att_retUser, att_retRole; - void saveMetaString(bool cond, Firebird::AutoPtr& meta, const Firebird::MetaString& src) + AutoPtr att_retUser, att_retRole; + void saveMetaString(bool cond, AutoPtr& meta, const MetaString& src) { if (cond) { if (!meta) - meta = FB_NEW_POOL(*att_pool) Firebird::MetaString(*att_pool); + meta = FB_NEW_POOL(*att_pool) MetaString(*att_pool); meta->operator=(src); } } @@ -961,7 +962,7 @@ class AttachmentsRefHolder private: AttachmentsRefHolder(const AttachmentsRefHolder&); - Firebird::HalfStaticArray m_attachments; + HalfStaticArray m_attachments; }; // Class used in system background threads @@ -986,9 +987,9 @@ class SysStableAttachment : public StableAttachmentPart void destroy(Attachment* attachment); // "public" interface for internal (system) attachment - Firebird::RefPtr m_JAttachment; + RefPtr m_JAttachment; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_ATTACHMENT_H diff --git a/src/jrd/BlobUtil.cpp b/src/jrd/BlobUtil.cpp index 18ca4a4270c..e3b60f5b58d 100644 --- a/src/jrd/BlobUtil.cpp +++ b/src/jrd/BlobUtil.cpp @@ -25,8 +25,8 @@ #include "../jrd/blb.h" #include "../jrd/tra.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ namespace @@ -59,7 +59,6 @@ namespace } } -namespace Jrd { //-------------------------------------- @@ -198,7 +197,7 @@ void BlobUtilPackage::readDataFunction(ThrowStatusExceptionWrapper* status, //-------------------------------------- -BlobUtilPackage::BlobUtilPackage(Firebird::MemoryPool& pool) +BlobUtilPackage::BlobUtilPackage(MemoryPool& pool) : SystemPackage( pool, "RDB$BLOB_UTIL", @@ -291,4 +290,5 @@ BlobUtilPackage::BlobUtilPackage(Firebird::MemoryPool& pool) { } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/BlobUtil.h b/src/jrd/BlobUtil.h index b26f596c6df..b91a9ce69df 100644 --- a/src/jrd/BlobUtil.h +++ b/src/jrd/BlobUtil.h @@ -30,98 +30,99 @@ #include "../common/status.h" #include "../jrd/SystemPackages.h" -namespace Jrd { +namespace Firebird::Jrd +{ class BlobUtilPackage : public SystemPackage { public: - BlobUtilPackage(Firebird::MemoryPool& pool); + BlobUtilPackage(MemoryPool& pool); private: - FB_MESSAGE(BinaryMessage, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(BinaryMessage, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(MAX_VARY_COLUMN_SIZE, 0), data) ); - FB_MESSAGE(BlobMessage, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(BlobMessage, ThrowStatusExceptionWrapper, (FB_BLOB, blob) ); - FB_MESSAGE(HandleMessage, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(HandleMessage, ThrowStatusExceptionWrapper, (FB_INTEGER, handle) ); - FB_MESSAGE(BooleanMessage, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(BooleanMessage, ThrowStatusExceptionWrapper, (FB_BOOLEAN, boolean) ); //---------- - static Firebird::IExternalResultSet* cancelBlobProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const BlobMessage::Type* in, void* out); + static IExternalResultSet* cancelBlobProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const BlobMessage::Type* in, void* out); //---------- - static Firebird::IExternalResultSet* closeHandleProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const HandleMessage::Type* in, void* out); + static IExternalResultSet* closeHandleProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const HandleMessage::Type* in, void* out); //---------- - static void isWritableFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static void isWritableFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const BlobMessage::Type* in, BooleanMessage::Type* out); //---------- - FB_MESSAGE(NewBlobInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(NewBlobInput, ThrowStatusExceptionWrapper, (FB_BOOLEAN, segmented) (FB_BOOLEAN, tempStorage) ); - static void newBlobFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static void newBlobFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const NewBlobInput::Type* in, BlobMessage::Type* out); //---------- - static void openBlobFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static void openBlobFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const BlobMessage::Type* in, HandleMessage::Type* out); //---------- - FB_MESSAGE(SeekInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(SeekInput, ThrowStatusExceptionWrapper, (FB_INTEGER, handle) (FB_INTEGER, mode) (FB_INTEGER, offset) ); - FB_MESSAGE(SeekOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(SeekOutput, ThrowStatusExceptionWrapper, (FB_INTEGER, offset) ); - static void seekFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const SeekInput::Type* in, SeekOutput::Type* out); + static void seekFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const SeekInput::Type* in, SeekOutput::Type* out); //---------- - FB_MESSAGE(ReadDataInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ReadDataInput, ThrowStatusExceptionWrapper, (FB_INTEGER, handle) (FB_INTEGER, length) ); - static void readDataFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static void readDataFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const ReadDataInput::Type* in, BinaryMessage::Type* out); //---------- - static void makeBlobFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static void makeBlobFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const HandleMessage::Type* in, BlobMessage::Type* out); }; -} // namespace +} // namespace Firebird::Jrd #endif // JRD_BLOB_UTIL_H diff --git a/src/jrd/CacheVector.cpp b/src/jrd/CacheVector.cpp index 0f0db147e07..dd5cf5cc55a 100644 --- a/src/jrd/CacheVector.cpp +++ b/src/jrd/CacheVector.cpp @@ -35,8 +35,9 @@ #include "../jrd/met.h" #include "../jrd/tpc_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + // class TransactionNumber @@ -101,13 +102,13 @@ MdcVersion VersionIncr::getVersion() [[noreturn]] void ElementBase::newVersionBusy(thread_db* tdbb, MetaId id, const char* family, TraNumber traNum) { - Firebird::fatal_exception::raiseFmt("newVersion: %s %d is used by transaction %d\n", + fatal_exception::raiseFmt("newVersion: %s %d is used by transaction %d\n", family, id, traNum); } [[noreturn]] void ElementBase::newVersionScan(thread_db* tdbb, MetaId id, const char* family) { - Firebird::fatal_exception::raiseFmt("newVersion: %s %d is scanned by us\n", + fatal_exception::raiseFmt("newVersion: %s %d is scanned by us\n", family, id); } @@ -161,7 +162,7 @@ void ElementBase::pingLock(thread_db* tdbb, ObjectBase::Flag flags, MetaId id, c { if (!LCK_lock(tdbb, lock, (flags & CacheFlag::ERASED) ? LCK_EX : LCK_PW, LCK_WAIT)) { - Firebird::fatal_exception::raiseFmt("Unable to obtain WRITE rescan lock for %s %d", + fatal_exception::raiseFmt("Unable to obtain WRITE rescan lock for %s %d", family, id); } @@ -176,7 +177,7 @@ void ElementBase::setLock(thread_db* tdbb, MetaId id, const char* family) { if (!LCK_lock(tdbb, lock, LCK_PR, LCK_WAIT)) { - Firebird::fatal_exception::raiseFmt("Unable to obtain READ rescan lock for %s %d", + fatal_exception::raiseFmt("Unable to obtain READ rescan lock for %s %d", family, id); } } @@ -203,3 +204,5 @@ bool ConsistencyCheck::commitNumber(thread_db* tdbb) return false; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/CacheVector.h b/src/jrd/CacheVector.h index 14c00b90278..f8cb3f5079a 100644 --- a/src/jrd/CacheVector.h +++ b/src/jrd/CacheVector.h @@ -36,17 +36,19 @@ #include "../common/StatusArg.h" #include "../jrd/SharedReadVector.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/tra_proto.h" #include "../jrd/QualifiedName.h" -namespace Jrd { +namespace Firebird::Jrd +{ class thread_db; class Lock; class MetadataCache; enum lck_t : UCHAR; + class ObjectBase { public: @@ -733,7 +735,7 @@ class CacheElement : public ElementBase, public P newEntry = FB_NEW_POOL(*getDefaultMemoryPool()) ListEntry(obj, traNum, fl & ~CacheFlag::ERASED); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (obj) // Versioned::create() formally might return nullptr Versioned::destroy(tdbb, obj); @@ -829,7 +831,7 @@ class CacheElement : public ElementBase, public P { auto obj = Versioned::create(tdbb, Permanent::getPool(), this); if (!obj) - (Firebird::Arg::Gds(isc_random) << "Object create failed in makeObject()").raise(); + (Arg::Gds(isc_random) << "Object create failed in makeObject()").raise(); switch (storeObject(tdbb, obj, fl & ~CacheFlag::ERASED)) { @@ -964,7 +966,7 @@ struct NoData }; template -class CacheVector : public Firebird::PermanentStorage +class CacheVector : public PermanentStorage { public: static const unsigned SUBARRAY_SIZE = 1 << SUBARRAY_SHIFT; @@ -977,7 +979,7 @@ class CacheVector : public Firebird::PermanentStorage typedef SharedReadVector Storage; explicit CacheVector(MemoryPool& pool, EXTEND extend = NoData()) - : Firebird::PermanentStorage(pool), + : PermanentStorage(pool), m_objects(), m_extend(extend) {} @@ -1004,7 +1006,7 @@ class CacheVector : public Firebird::PermanentStorage fb_assert(reqSize > 0); reqSize = ((reqSize - 1) >> SUBARRAY_SHIFT) + 1; - Firebird::MutexLockGuard g(m_objectsGrowMutex, FB_FUNCTION); + MutexLockGuard g(m_objectsGrowMutex, FB_FUNCTION); m_objects.grow(reqSize, false); auto wa = m_objects.writeAccessor(); @@ -1095,7 +1097,7 @@ class CacheVector : public Firebird::PermanentStorage return val; } #ifdef DEV_BUILD - (Firebird::Arg::Gds(isc_random) << "Object suddenly disappeared").raise(); + (Arg::Gds(isc_random) << "Object suddenly disappeared").raise(); #endif } @@ -1362,7 +1364,7 @@ class CacheVector : public Firebird::PermanentStorage private: Storage m_objects; - Firebird::Mutex m_objectsGrowMutex; + Mutex m_objectsGrowMutex; EXTEND m_extend; }; @@ -1372,6 +1374,7 @@ auto getPermanent(T* t) -> decltype(t->getPermanent()) return t ? t->getPermanent() : nullptr; } -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_CACHEVECTOR_H diff --git a/src/jrd/CharSetContainer.cpp b/src/jrd/CharSetContainer.cpp index b4bfef4e9a8..707515d49d2 100644 --- a/src/jrd/CharSetContainer.cpp +++ b/src/jrd/CharSetContainer.cpp @@ -26,9 +26,11 @@ #include "firebird.h" #include "../jrd/CharSetContainer.h" #include "../jrd/jrd.h" -#include "../jrd/obj.h" +#include "../common/obj.h" + +namespace Firebird::Jrd +{ -using namespace Jrd; CharSetVers* CharSetVers::create(thread_db* tdbb, MemoryPool& pool, Cached::CharSet* csp) { @@ -64,3 +66,5 @@ QualifiedName CharSetContainer::getName() const return QualifiedName(cs->getName(), SYSTEM_SCHEMA); } + +} // namespace Firebird::Jrd diff --git a/src/jrd/CharSetContainer.h b/src/jrd/CharSetContainer.h index c2945ca489e..55f67b80830 100644 --- a/src/jrd/CharSetContainer.h +++ b/src/jrd/CharSetContainer.h @@ -44,11 +44,13 @@ class CsConvert; } -namespace Jrd { +namespace Firebird::Jrd +{ + struct SubtypeInfo; -class CharSetContainer : public Firebird::PermanentStorage +class CharSetContainer : public PermanentStorage { public: CharSetContainer(thread_db* tdbb, MemoryPool& p, MetaId cs_id, NoData); @@ -57,12 +59,12 @@ class CharSetContainer : public Firebird::PermanentStorage static CharSetContainer* create(thread_db* tdbb, MetaId id); void releaseLock(thread_db*) { } - Firebird::CharSet* getCharSet() + CharSet* getCharSet() { return cs; } - Firebird::CsConvert lookupConverter(thread_db* tdbb, CSetId to_cs); + CsConvert lookupConverter(thread_db* tdbb, CSetId to_cs); static CharSetContainer* lookupCharset(thread_db* tdbb, TTypeId ttype); @@ -86,7 +88,7 @@ class CharSetContainer : public Firebird::PermanentStorage CharsetVariants names; private: - Firebird::CharSet* cs; + CharSet* cs; Lock* cs_lock; }; @@ -133,14 +135,14 @@ class CharSetVers final : public ObjectBase static int objectType(); - bool hash(thread_db*, Firebird::sha512&) + bool hash(thread_db*, sha512&) { return true; } private: Cached::CharSet* perm; - Firebird::HalfStaticArray charset_collations; + HalfStaticArray charset_collations; public: decltype(perm) getPermanent() const @@ -149,7 +151,8 @@ class CharSetVers final : public ObjectBase } }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_CHARSETCONTAINER_H diff --git a/src/jrd/Coercion.cpp b/src/jrd/Coercion.cpp index 8d635bfd580..bb268585459 100644 --- a/src/jrd/Coercion.cpp +++ b/src/jrd/Coercion.cpp @@ -34,8 +34,9 @@ #include "../jrd/align.h" #include "../jrd/DataTypeUtil.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + static const USHORT FROM_MASK = FLD_has_len | FLD_has_chset | FLD_has_scale | FLD_has_sub | FLD_has_prec; @@ -369,3 +370,5 @@ bool CoercionRule::coerce(thread_db* tdbb, dsc* d) const return true; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/Coercion.h b/src/jrd/Coercion.h index 17a8c6a88b1..da5b91596d3 100644 --- a/src/jrd/Coercion.h +++ b/src/jrd/Coercion.h @@ -33,11 +33,12 @@ #include "../common/classes/array.h" #include "../common/dsc.h" -namespace Jrd +namespace Firebird::Jrd { class thread_db; class TypeClause; + class CoercionRule { public: @@ -56,11 +57,11 @@ class CoercionRule USHORT toMask = 0; }; -class CoercionArray : public Firebird::HalfStaticArray +class CoercionArray : public HalfStaticArray { public: CoercionArray(MemoryPool& p) - : Firebird::HalfStaticArray(p) + : HalfStaticArray(p) { } @@ -68,6 +69,7 @@ class CoercionArray : public Firebird::HalfStaticArray void setRule(const TypeClause* from, const TypeClause *to); }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_COERCION_H diff --git a/src/jrd/Collation.cpp b/src/jrd/Collation.cpp index 1eb74293cd6..54ca4ff72cb 100644 --- a/src/jrd/Collation.cpp +++ b/src/jrd/Collation.cpp @@ -104,8 +104,8 @@ #include "../common/TextType.h" #include "../common/SimilarToRegex.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace { @@ -427,7 +427,7 @@ class LikeMatcher final : public PatternMatcher fb_assert(pl % sizeof(CharType) == 0); fb_assert(sl % sizeof(CharType) == 0); - Firebird::LikeEvaluator evaluator(pool, + LikeEvaluator evaluator(pool, reinterpret_cast(p), pl / sizeof(CharType), (escape ? *reinterpret_cast(escape) : 0), escape_length != 0, *reinterpret_cast(sql_match_any), @@ -437,7 +437,7 @@ class LikeMatcher final : public PatternMatcher } private: - Firebird::LikeEvaluator evaluator; + LikeEvaluator evaluator; }; template @@ -510,7 +510,7 @@ class StartsMatcher final : public PatternMatcher StrConverter cvt2(pool, ttype, s, sl); fb_assert(sl % sizeof(CharType) == 0); - Firebird::StartsEvaluator evaluator(pool, + StartsEvaluator evaluator(pool, reinterpret_cast(p), pl / sizeof(CharType)); evaluator.processNextChunk(reinterpret_cast(s), sl / sizeof(CharType)); @@ -519,7 +519,7 @@ class StartsMatcher final : public PatternMatcher } private: - Firebird::StartsEvaluator evaluator; + StartsEvaluator evaluator; SLONG byteLengthLimit; SLONG processedByteLength = 0; }; @@ -567,14 +567,14 @@ class ContainsMatcher final : public PatternMatcher StrConverter cvt2(pool, ttype, s, sl); fb_assert(pl % sizeof(CharType) == 0); fb_assert(sl % sizeof(CharType) == 0); - Firebird::ContainsEvaluator evaluator(pool, + ContainsEvaluator evaluator(pool, reinterpret_cast(p), pl / sizeof(CharType)); evaluator.processNextChunk(reinterpret_cast(s), sl / sizeof(CharType)); return evaluator.getResult(); } private: - Firebird::ContainsEvaluator evaluator; + ContainsEvaluator evaluator; }; template > @@ -1070,8 +1070,6 @@ class CollationImpl : public Collation template Collation* newCollation(MemoryPool& pool, TTypeId id, texttype* tt, USHORT attributes, CharSet* cs) { - using namespace Firebird; - typedef StartsMatcher StartsMatcherUCharDirect; typedef StartsMatcher > StartsMatcherUCharCanonical; typedef ContainsMatcher > ContainsMatcherUCharDirect; @@ -1104,9 +1102,6 @@ Collation* newCollation(MemoryPool& pool, TTypeId id, texttype* tt, USHORT attri //------------- -namespace Jrd { - - Collation* Collation::createInstance(MemoryPool& pool, TTypeId id, texttype* tt, USHORT attributes, CharSet* cs) { switch (tt->texttype_canonical_width) @@ -1136,4 +1131,5 @@ void Collation::destroy(thread_db* tdbb) delete this; } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/Collation.h b/src/jrd/Collation.h index 7fa8b24ec5f..031bb01534b 100644 --- a/src/jrd/Collation.h +++ b/src/jrd/Collation.h @@ -36,27 +36,28 @@ #include "../jrd/Resources.h" -namespace Firebird { - -class CharSet; - +namespace Firebird +{ + class CharSet; } -namespace Jrd { +namespace Firebird::Jrd +{ class Lock; class BaseSubstringSimilarMatcher; class PatternMatcher; -class Collation : public Firebird::TextType + +class Collation : public TextType { public: static Collation* createInstance(MemoryPool& pool, TTypeId id, texttype* tt, - USHORT attributes, Firebird::CharSet* cs); + USHORT attributes, CharSet* cs); protected: - Collation(TTypeId id, texttype *a_tt, USHORT a_attributes, Firebird::CharSet* a_cs) + Collation(TTypeId id, texttype *a_tt, USHORT a_attributes, CharSet* a_cs) : TextType(id, a_tt, a_attributes, a_cs), obsolete(false) { @@ -95,7 +96,7 @@ class Collation : public Firebird::TextType bool obsolete; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_COLLATION_H diff --git a/src/jrd/ConfigTable.cpp b/src/jrd/ConfigTable.cpp index 9fb4f1a2e2b..b000707a26d 100644 --- a/src/jrd/ConfigTable.cpp +++ b/src/jrd/ConfigTable.cpp @@ -24,8 +24,8 @@ #include "../jrd/ini.h" #include "../jrd/ids.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ /// class ConfigTable @@ -123,3 +123,6 @@ RecordBuffer* ConfigTableScan::getRecords(thread_db* tdbb, RelationPermanent* re return impure->table->getRecords(tdbb, relation); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/ConfigTable.h b/src/jrd/ConfigTable.h index a8932f04813..be01d9ede33 100644 --- a/src/jrd/ConfigTable.h +++ b/src/jrd/ConfigTable.h @@ -29,26 +29,27 @@ #include "../jrd/recsrc/RecordSource.h" -namespace Jrd +namespace Firebird::Jrd { + class ConfigTable : public SnapshotData { public: - ConfigTable(MemoryPool& pool, const Firebird::Config* conf); + ConfigTable(MemoryPool& pool, const Config* conf); // return data for RDB$CONFIG RecordBuffer* getRecords(thread_db* tdbb, RelationPermanent* relation); private: - const Firebird::Config* m_conf; + const Config* m_conf; }; class ConfigTableScan final : public VirtualTableScan { public: - ConfigTableScan(CompilerScratch* csb, const Firebird::string& alias, + ConfigTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) { @@ -74,6 +75,7 @@ class ConfigTableScan final : public VirtualTableScan ULONG m_impure; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_CONFIG_TABLE_H diff --git a/src/jrd/CryptoManager.cpp b/src/jrd/CryptoManager.cpp index 6379180e35d..a6da6230907 100644 --- a/src/jrd/CryptoManager.cpp +++ b/src/jrd/CryptoManager.cpp @@ -52,7 +52,9 @@ #include "../common/classes/ClumpletWriter.h" #include "../common/sha.h" -using namespace Firebird; +namespace Firebird::Jrd +{ + namespace { @@ -73,8 +75,6 @@ namespace } -namespace Jrd -{ class Header { protected: @@ -985,7 +985,7 @@ namespace Jrd guard.leave(); // release in advance to avoid races with cryptThread() Thread::start(cryptThreadStatic, (THREAD_ENTRY_PARAM) this, THREAD_medium, &cryptThread); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (!releasingLock) // avoid secondary exception in catch { @@ -993,7 +993,7 @@ namespace Jrd { LCK_release(tdbb, threadLock); } - catch (const Firebird::Exception&) + catch (const Exception&) { } } @@ -1515,11 +1515,10 @@ namespace Jrd } } - const char* CryptoManager::DbInfo::getDatabaseFullPath(Firebird::CheckStatusWrapper* status) + const char* CryptoManager::DbInfo::getDatabaseFullPath(CheckStatusWrapper* status) { if (!cryptoManager) return NULL; return cryptoManager->dbb.dbb_filename.c_str(); } - -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/CryptoManager.h b/src/jrd/CryptoManager.h index d78b897ade8..939a4fe808c 100644 --- a/src/jrd/CryptoManager.h +++ b/src/jrd/CryptoManager.h @@ -45,7 +45,7 @@ // forward -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; @@ -57,7 +57,8 @@ class ClumpletReader; } -namespace Jrd { +namespace Firebird::Jrd +{ class Database; class Attachment; @@ -147,7 +148,7 @@ class BarSync void ioBegin(Jrd::thread_db* tdbb) { - Firebird::MutexLockGuard g(mutex, FB_FUNCTION); + MutexLockGuard g(mutex, FB_FUNCTION); if (counter < 0) { @@ -177,7 +178,7 @@ class BarSync void ioEnd(Jrd::thread_db* tdbb) { - Firebird::MutexLockGuard g(mutex, FB_FUNCTION); + MutexLockGuard g(mutex, FB_FUNCTION); if (--counter < 0 && counter % BIG_VALUE == 0) { @@ -196,7 +197,7 @@ class BarSync void ast(Jrd::thread_db* tdbb) { - Firebird::MutexLockGuard g(mutex, FB_FUNCTION); + MutexLockGuard g(mutex, FB_FUNCTION); if (counter >= 0) { counter -= BIG_VALUE; @@ -206,7 +207,7 @@ class BarSync void lockBegin(Jrd::thread_db* tdbb) { - Firebird::MutexLockGuard g(mutex, FB_FUNCTION); + MutexLockGuard g(mutex, FB_FUNCTION); if ((counter -= BIG_VALUE) != -BIG_VALUE) { @@ -215,7 +216,7 @@ class BarSync { lockCond.wait(mutex); } - catch (const Firebird::Exception&) + catch (const Exception&) { --lockMode; throw; @@ -229,7 +230,7 @@ class BarSync void lockEnd(Jrd::thread_db* tdbb) { - Firebird::MutexLockGuard g(mutex, FB_FUNCTION); + MutexLockGuard g(mutex, FB_FUNCTION); flagWriteLock = false; finishWriteLock(); @@ -252,8 +253,8 @@ class BarSync lockCond.notifyOne(); } - Firebird::Condition barCond, lockCond; - Firebird::Mutex mutex; + Condition barCond, lockCond; + Mutex mutex; IBar* callback; ThreadId thread; int counter; @@ -263,10 +264,10 @@ class BarSync static const int BIG_VALUE = 1000000; }; -class CryptoManager final : public Firebird::PermanentStorage, public BarSync::IBar +class CryptoManager final : public PermanentStorage, public BarSync::IBar { public: - typedef Firebird::GetPlugins Factory; + typedef GetPlugins Factory; explicit CryptoManager(thread_db* tdbb); ~CryptoManager(); @@ -275,7 +276,7 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I void prepareChangeCryptState(thread_db* tdbb, const MetaName& plugName, const MetaName& key); - void changeCryptState(thread_db* tdbb, const Firebird::string& plugName); + void changeCryptState(thread_db* tdbb, const string& plugName); void attach(thread_db* tdbb, Attachment* att); void detach(thread_db* tdbb, Attachment* att); @@ -294,8 +295,8 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I void cryptThreadRoutine(); - bool checkValidation(Firebird::IDbCryptPlugin* crypt); - void setDbInfo(Firebird::IDbCryptPlugin* cp); + bool checkValidation(IDbCryptPlugin* crypt); + void setDbInfo(IDbCryptPlugin* cp); ULONG getCurrentPage(thread_db* tdbb) const; UCHAR getCurrentState(thread_db* tdbb) const; @@ -332,7 +333,7 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I class DbInfo; friend class DbInfo; - class DbInfo final : public Firebird::RefCntIface > + class DbInfo final : public RefCntIface> { public: DbInfo(CryptoManager* cm) @@ -345,7 +346,7 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I } // IDbCryptInfo implementation - const char* getDatabaseFullPath(Firebird::CheckStatusWrapper* status); + const char* getDatabaseFullPath(CheckStatusWrapper* status); private: CryptoManager* cryptoManager; @@ -362,7 +363,7 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I bool validateAttachment(thread_db* tdbb, Attachment* att, bool consume); ULONG getLastPage(thread_db* tdbb); void writeDbHeader(thread_db* tdbb, ULONG runpage); - void calcValidation(Firebird::string& valid, Firebird::IDbCryptPlugin* plugin); + void calcValidation(string& valid, IDbCryptPlugin* plugin); void checkValidation(); void shutdownConsumers(thread_db* tdbb); @@ -371,20 +372,20 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I static const unsigned CRYPT_HDR_NOWAIT = 0x02; static const unsigned CRYPT_RELOAD_PLUGIN = 0x04; - void addClumplet(Firebird::string& value, Firebird::ClumpletReader& block, UCHAR tag); - void calcDigitalSignature(thread_db* tdbb, Firebird::string& signature, const class Header& hdr); + void addClumplet(string& value, ClumpletReader& block, UCHAR tag); + void calcDigitalSignature(thread_db* tdbb, string& signature, const class Header& hdr); void digitalySignDatabase(thread_db* tdbb, class CchHdr& hdr); void checkDigitalSignature(thread_db* tdbb, const class Header& hdr); BarSync sync; MetaName keyName, pluginName; ULONG currentPage; - Firebird::Mutex pluginLoadMtx, cryptThreadMtx, holdersMutex; + Mutex pluginLoadMtx, cryptThreadMtx, holdersMutex; AttachmentsRefHolder keyProviders, keyConsumers; - Firebird::string hash; - Firebird::RefPtr dbInfo; + string hash; + RefPtr dbInfo; Thread cryptThread; - Firebird::IDbCryptPlugin* cryptPlugin; + IDbCryptPlugin* cryptPlugin; Factory* checkFactory; Database& dbb; Lock* stateLock; @@ -418,7 +419,7 @@ class CryptoManager final : public Firebird::PermanentStorage, public BarSync::I bool down() const; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_CRYPTO_MANAGER diff --git a/src/jrd/DataTypeUtil.cpp b/src/jrd/DataTypeUtil.cpp index 0199e78fc9d..21825b780fc 100644 --- a/src/jrd/DataTypeUtil.cpp +++ b/src/jrd/DataTypeUtil.cpp @@ -35,7 +35,8 @@ #include "../jrd/intl_proto.h" #include "../common/gdsassert.h" -using namespace Firebird; +namespace Firebird::Jrd +{ SSHORT DataTypeUtilBase::getResultBlobSubType(const dsc* value1, const dsc* value2) @@ -350,8 +351,6 @@ bool DataTypeUtilBase::makeBlobOrText(dsc* result, const dsc* arg, bool force) } -namespace Jrd { - UCHAR DataTypeUtil::maxBytesPerChar(CSetId charSet) { return INTL_charset_lookup(tdbb, charSet)->maxBytesPerChar(); @@ -402,4 +401,5 @@ bool DataTypeUtil::convertToUTF8(const string& src, string& dst, CSetId charset, return true; } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/DataTypeUtil.h b/src/jrd/DataTypeUtil.h index 957687d713d..80c4933fad3 100644 --- a/src/jrd/DataTypeUtil.h +++ b/src/jrd/DataTypeUtil.h @@ -34,6 +34,10 @@ struct dsc; +namespace Firebird::Jrd +{ + + class DataTypeUtilBase { public: @@ -61,8 +65,6 @@ class DataTypeUtilBase }; -namespace Jrd { - class thread_db; class DataTypeUtil : public DataTypeUtilBase @@ -78,13 +80,14 @@ class DataTypeUtil : public DataTypeUtilBase virtual USHORT getDialect() const; public: - static bool convertToUTF8(const Firebird::string& src, Firebird::string& dst, + static bool convertToUTF8(const string& src, string& dst, CSetId charset = CS_dynamic, ErrorFunction err = ERR_post); private: thread_db* tdbb; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_DATATYPEUTIL_H diff --git a/src/jrd/Database.cpp b/src/jrd/Database.cpp index c133351d659..2a29e486d31 100644 --- a/src/jrd/Database.cpp +++ b/src/jrd/Database.cpp @@ -46,18 +46,17 @@ // Thread data block #include "../common/ThreadData.h" -using namespace Firebird; -namespace +namespace Firebird::Jrd { - void unableToRunSweepException(ISC_STATUS reason) + namespace { - ERR_post(Arg::Gds(isc_sweep_unable_to_run) << Arg::Gds(reason)); + void unableToRunSweepException(ISC_STATUS reason) + { + ERR_post(Arg::Gds(isc_sweep_unable_to_run) << Arg::Gds(reason)); + } } -} -namespace Jrd -{ bool Database::onRawDevice() const { const auto pageSpace = dbb_page_manager.findPageSpace(DB_PAGE_SPACE); @@ -135,7 +134,7 @@ namespace Jrd return dbb_tip_cache->newMonitorGeneration(); } - const Firebird::string& Database::getUniqueFileId() + const string& Database::getUniqueFileId() { if (dbb_file_id.isEmpty()) { @@ -166,7 +165,7 @@ namespace Jrd pool->setStatsGroup(*stats); } - Firebird::SyncLockGuard guard(&dbb_pools_sync, Firebird::SYNC_EXCLUSIVE, "Database::createPool"); + SyncLockGuard guard(&dbb_pools_sync, SYNC_EXCLUSIVE, "Database::createPool"); dbb_pools.add(pool); #ifdef DEBUG_LOST_POOLS @@ -790,9 +789,9 @@ namespace Jrd return m_replMgr; } - Database::Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared) + Database::Database(MemoryPool* p, IPluginConfig* pConf, bool shared) : dbb_permanent(p), - dbb_guid(Firebird::Guid::empty()), + dbb_guid(Guid::empty()), dbb_page_manager(this, *p), dbb_file_id(*p), dbb_modules(*p), @@ -813,7 +812,7 @@ namespace Jrd dbb_stats(*p), dbb_lock_owner_id(getLockOwnerId()), dbb_tip_cache(NULL), - dbb_creation_date(Firebird::TimeZoneUtil::getCurrentGmtTimeStamp()), + dbb_creation_date(TimeZoneUtil::getCurrentGmtTimeStamp()), dbb_external_file_directory_list(NULL), dbb_init_fini(FB_NEW_POOL(*getDefaultMemoryPool()) ExistenceRefMutex()), dbb_linger_seconds(0), @@ -894,6 +893,4 @@ namespace Jrd } return result; } - - -} // namespace +} // namespace Firebird::Jrd diff --git a/src/jrd/Database.h b/src/jrd/Database.h index f8bf181a969..706e1777d51 100644 --- a/src/jrd/Database.h +++ b/src/jrd/Database.h @@ -81,8 +81,7 @@ #define SPTHR_DEBUG(A) -namespace Jrd -{ +namespace Firebird::Jrd { template class vec; class jrd_rel; class Shadow; @@ -150,15 +149,15 @@ class Database : public pool_alloc // The container is destroyed by the last dbb going away and // it automatically destroys all the objects it holds. - class GlobalObjectHolder : public Firebird::RefCounted, public Firebird::GlobalStorage + class GlobalObjectHolder : public RefCounted, public GlobalStorage { struct DbId; - typedef Firebird::HashTable DbIdHash; + typedef HashTable DbIdHash; - struct DbId : public DbIdHash::Entry, public Firebird::GlobalStorage, public Firebird::RefCounted + struct DbId : public DbIdHash::Entry, public GlobalStorage, public RefCounted { - DbId(const Firebird::string& x, GlobalObjectHolder* h) + DbId(const string& x, GlobalObjectHolder* h) : id(getPool(), x), holder(h) {} @@ -167,36 +166,36 @@ class Database : public pool_alloc return this; } - bool isEqual(const Firebird::string& val) const + bool isEqual(const string& val) const { return val == id; } - static const Firebird::string& generate(const DbId& item) + static const string& generate(const DbId& item) { return item.id; } - static FB_SIZE_T hash(const Firebird::string& value, FB_SIZE_T hashSize) + static FB_SIZE_T hash(const string& value, FB_SIZE_T hashSize) { - return Firebird::InternalHash::hash(value.length(), + return InternalHash::hash(value.length(), (const UCHAR*) value.c_str(), hashSize); } - const Firebird::string id; + const string id; GlobalObjectHolder* holder; // This mutex is working very tight with `g_mutex`, so use it carefully to avoid possible deadlocks. - Firebird::Mutex shutdownMutex; + Mutex shutdownMutex; }; - static Firebird::GlobalPtr g_hashTable; - static Firebird::GlobalPtr g_mutex; + static GlobalPtr g_hashTable; + static GlobalPtr g_mutex; public: - static GlobalObjectHolder* init(const Firebird::string& id, - const Firebird::PathName& filename, - Firebird::RefPtr config); + static GlobalObjectHolder* init(const string& id, + const PathName& filename, + RefPtr config); int release() const override; @@ -215,19 +214,19 @@ class Database : public pool_alloc void decTempCacheUsage(FB_SIZE_T size); private: - const Firebird::string m_id; - const Firebird::RefPtr m_config; - const Firebird::AutoPtr m_replConfig; - Firebird::AutoPtr m_lockMgr; - Firebird::AutoPtr m_eventMgr; - Firebird::AutoPtr m_replMgr; - Firebird::Mutex m_mutex; + const string m_id; + const RefPtr m_config; + const AutoPtr m_replConfig; + AutoPtr m_lockMgr; + AutoPtr m_eventMgr; + AutoPtr m_replMgr; + Mutex m_mutex; std::atomic m_tempCacheUsage; // total size of in-memory temp space chunks (see TempSpace class) const FB_UINT64 m_tempCacheLimit; - explicit GlobalObjectHolder(const Firebird::string& id, - const Firebird::PathName& filename, - Firebird::RefPtr config) + explicit GlobalObjectHolder(const string& id, + const PathName& filename, + RefPtr config) : m_id(getPool(), id), m_config(config), m_replConfig(Replication::Config::get(filename)), m_tempCacheUsage(0), @@ -236,7 +235,7 @@ class Database : public pool_alloc }; public: - class ExistenceRefMutex : public Firebird::RefCounted + class ExistenceRefMutex : public RefCounted { public: ExistenceRefMutex() @@ -268,12 +267,12 @@ class Database : public pool_alloc } private: - Firebird::Mutex mutex; + Mutex mutex; bool exist; }; class Linger final : - public Firebird::RefCntIface > + public RefCntIface > { public: explicit Linger(Database* a_dbb) @@ -292,9 +291,9 @@ class Database : public pool_alloc bool active; }; - static Database* create(Firebird::IPluginConfig* pConf, bool shared) + static Database* create(IPluginConfig* pConf, bool shared) { - Firebird::MemoryStats temp_stats; + MemoryStats temp_stats; MemoryPool* const pool = MemoryPool::createPool(NULL, temp_stats); Database* const dbb = FB_NEW_POOL(*pool) Database(pool, pConf, shared); pool->setStatsGroup(dbb->dbb_memory_stats); @@ -316,7 +315,7 @@ class Database : public pool_alloc // Memory pool destruction below decrements memory statistics // situated in database block we are about to deallocate right now - Firebird::MemoryStats temp_stats; + MemoryStats temp_stats; perm->setStatsGroup(temp_stats); delete toDelete; @@ -330,12 +329,12 @@ class Database : public pool_alloc MemoryPool* dbb_permanent; - Firebird::Guid dbb_guid; // database GUID + Guid dbb_guid; // database GUID - Firebird::SyncObject dbb_sync; - Firebird::SyncObject dbb_sys_attach; // synchronize operations with dbb_sys_attachments + SyncObject dbb_sync; + SyncObject dbb_sys_attach; // synchronize operations with dbb_sys_attachments - Firebird::ICryptKeyCallback* dbb_callback; // Parent's crypt callback + ICryptKeyCallback* dbb_callback; // Parent's crypt callback Database* dbb_next; // Next database block in system Attachment* dbb_attachments; // Active attachments Attachment* dbb_sys_attachments; // System attachments @@ -343,9 +342,9 @@ class Database : public pool_alloc Lock* dbb_lock; // database lock Lock* dbb_sweep_lock; // sweep lock - Firebird::SyncObject dbb_sh_counter_sync; + SyncObject dbb_sh_counter_sync; - Firebird::SyncObject dbb_shadow_sync; + SyncObject dbb_shadow_sync; Shadow* dbb_shadow; // shadow control block Lock* dbb_shadow_lock; // lock for synchronizing addition of shadows @@ -356,28 +355,28 @@ class Database : public pool_alloc MonitoringData* dbb_monitoring_data; // monitoring data private: - Firebird::string dbb_file_id; // system-wide unique file ID - Firebird::RefPtr dbb_gblobj_holder; - Firebird::SyncObject dbb_modules_sync; + string dbb_file_id; // system-wide unique file ID + RefPtr dbb_gblobj_holder; + SyncObject dbb_modules_sync; DatabaseModules dbb_modules; // external function/filter modules // Vectors of known pages and their synchronization - Firebird::SyncObject dbb_pages_sync; // guard access to dbb_XXX_pages vectors + SyncObject dbb_pages_sync; // guard access to dbb_XXX_pages vectors vcl* dbb_tip_pages; // known TIP pages vcl* dbb_gen_pages; // known generator pages - Firebird::Array> dbb_internal; // internal statements DEPRECATED - Firebird::Array> dbb_dyn_req; // internal dyn statements DEPRECATED + Array> dbb_internal; // internal statements DEPRECATED + Array> dbb_dyn_req; // internal dyn statements DEPRECATED SharedReadVector, 8> dbb_internal_cached_statements; // dynamic internal statements - Firebird::Mutex dbb_internal_cached_mutex; + Mutex dbb_internal_cached_mutex; public: - Firebird::AutoPtr dbb_extManager; // external engine manager + AutoPtr dbb_extManager; // external engine manager - Firebird::SyncObject dbb_flush_count_mutex; - Firebird::RWLock dbb_ast_lock; // avoids delivering AST to going away database - Firebird::AtomicCounter dbb_ast_flags; // flags modified at AST level - Firebird::AtomicCounter dbb_flags; + SyncObject dbb_flush_count_mutex; + RWLock dbb_ast_lock; // avoids delivering AST to going away database + AtomicCounter dbb_ast_flags; // flags modified at AST level + AtomicCounter dbb_flags; std::atomic dbb_shutdown_mode; // shutdown mode USHORT dbb_ods_version; // major ODS version number USHORT dbb_minor_version; // minor ODS version number @@ -391,18 +390,18 @@ class Database : public pool_alloc USHORT dbb_prefetch_pages; // prefetch pages per request #endif - Firebird::PathName dbb_filename; // filename string - Firebird::PathName dbb_database_name; // database visible name (file name or alias) + PathName dbb_filename; // filename string + PathName dbb_database_name; // database visible name (file name or alias) #ifdef HAVE_ID_BY_NAME - Firebird::UCharBuffer dbb_id; + UCharBuffer dbb_id; #endif MetaName dbb_owner; // database owner - Firebird::SyncObject dbb_pools_sync; - Firebird::Array dbb_pools; // pools + SyncObject dbb_pools_sync; + Array dbb_pools; // pools - Firebird::SyncObject dbb_sortbuf_sync; - Firebird::Array dbb_sort_buffers; // sort buffers ready for reuse + SyncObject dbb_sortbuf_sync; + Array dbb_sort_buffers; // sort buffers ready for reuse TraNumber dbb_oldest_active; // Cached "oldest active" transaction TraNumber dbb_oldest_transaction; // Cached "oldest interesting" transaction @@ -412,13 +411,13 @@ class Database : public pool_alloc ULONG dbb_page_buffers; // Page buffers from header page GarbageCollector* dbb_garbage_collector; // GarbageCollector class - Firebird::Semaphore dbb_gc_sem; // Event to wake up garbage collector - Firebird::Semaphore dbb_gc_init; // Event for initialization garbage collector + Semaphore dbb_gc_sem; // Event to wake up garbage collector + Semaphore dbb_gc_init; // Event for initialization garbage collector ThreadFinishSync dbb_gc_fini; // Sync for finalization garbage collector - Firebird::MemoryStats dbb_memory_stats; + MemoryStats dbb_memory_stats; RuntimeStatistics dbb_stats; - mutable Firebird::Mutex dbb_stats_mutex; + mutable Mutex dbb_stats_mutex; TraNumber dbb_last_header_write; // Transaction id of last header page physical write SLONG dbb_flush_cycle; // Current flush cycle @@ -433,38 +432,37 @@ class Database : public pool_alloc BackupManager* dbb_backup_manager; // physical backup manager ISC_TIMESTAMP_TZ dbb_creation_date; // creation timestamp in GMT ExternalFileDirectoryList* dbb_external_file_directory_list; - Firebird::RefPtr dbb_config; + RefPtr dbb_config; CryptoManager* dbb_crypto_manager; - Firebird::RefPtr dbb_init_fini; - Firebird::XThreadMutex dbb_thread_mutex; // special threads start/stop mutex - Firebird::RefPtr dbb_linger_timer; + RefPtr dbb_init_fini; + XThreadMutex dbb_thread_mutex; // special threads start/stop mutex + RefPtr dbb_linger_timer; unsigned dbb_linger_seconds; time_t dbb_linger_end; - Firebird::RefPtr dbb_plugin_config; + RefPtr dbb_plugin_config; - Firebird::TriState dbb_repl_state; // replication state + TriState dbb_repl_state; // replication state Lock* dbb_repl_lock; // replication state lock - Firebird::SyncObject dbb_repl_sync; + SyncObject dbb_repl_sync; FB_UINT64 dbb_repl_sequence; // replication sequence std::atomic dbb_replica_mode; // replica access mode unsigned dbb_compatibility_index; // datatype backward compatibility level Dictionary dbb_dic; // metanames dictionary - Firebird::InitInstance dbb_keywords; + InitInstance dbb_keywords; MetadataCache* dbb_mdc; private: - Firebird::GenericMap > > dbb_user_ids; // set of used UserIds + GenericMap > > dbb_user_ids; // set of used UserIds public: // returns true if primary file is located on raw device bool onRawDevice() const; // returns an unique ID string for a database file - const Firebird::string& getUniqueFileId(); + const string& getUniqueFileId(); // returns the minimum IO block size ULONG getIOBlockSize() const; @@ -514,7 +512,7 @@ class Database : public pool_alloc void copyKnownPages(SCHAR ptype, ULONG count, ULONG* data); private: - Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared); + Database(MemoryPool* p, IPluginConfig* pConf, bool shared); ~Database(); public: @@ -549,7 +547,7 @@ class Database : public pool_alloc bool clearSweepStarting(); static void garbage_collector(Database* dbb); - void exceptionHandler(const Firebird::Exception& ex, ThreadFinishSync::ThreadRoutine* routine); + void exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* routine); FB_UINT64 getReplSequence(thread_db* tdbb); void setReplSequence(thread_db* tdbb, FB_UINT64 sequence); @@ -596,7 +594,7 @@ class Database : public pool_alloc Request* cacheRequest(InternalRequest which, USHORT id, Request* req); void releaseSystemRequests(thread_db* tdbb); - UserId* getUserId(const Firebird::MetaString& userName); + UserId* getUserId(const MetaString& userName); bool isRestoring() const { @@ -627,6 +625,6 @@ class Database : public pool_alloc const Database& operator =(const Database&) { return *this; } }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_DATABASE_H diff --git a/src/jrd/DbCreators.cpp b/src/jrd/DbCreators.cpp index 01289f892e1..6cced5bd2bb 100644 --- a/src/jrd/DbCreators.cpp +++ b/src/jrd/DbCreators.cpp @@ -31,7 +31,7 @@ #include "../auth/SecureRemotePassword/Message.h" #include "iberror.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/ClumpletWriter.h" #include "../common/classes/init.h" #include "../common/classes/Hash.h" @@ -53,13 +53,13 @@ #define DBC_DEBUG(A) -using namespace Firebird; -using namespace Jrd; -using namespace Auth; +namespace Firebird::Jrd +{ + namespace { -void check(const char* s, IStatus* st) +void checkStatus(const char* s, IStatus* st) { if (!(st->getState() & IStatus::STATE_ERRORS)) return; @@ -84,7 +84,7 @@ bool openDb(const char* securityDb, RefPtr& att, RefPtrgetState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_io_error)) - check("IProvider::attachDatabase", &st); + checkStatus("IProvider::attachDatabase", &st); // missing security DB - checking granted rights not possible return false; @@ -94,7 +94,7 @@ bool openDb(const char* securityDb, RefPtr& att, RefPtrstartTransaction(&st, readOnly.getBufferLength(), readOnly.getBuffer())); - check("IAttachment::startTransaction", &st); + checkStatus("IAttachment::startTransaction", &st); return true; } @@ -102,8 +102,6 @@ bool openDb(const char* securityDb, RefPtr& att, RefPtrgetInfo(&st, sizeof(info), info, sizeof(buffer), buffer); - check("IAttachment::getInfo", &st); + checkStatus("IAttachment::getInfo", &st); int dialect = SQL_DIALECT_V5; // reasonable default @@ -158,7 +156,7 @@ CreateGrant checkCreateDatabaseGrant(const MetaString& userName, const MetaStrin // isc_dsql_relation_err when exec SQL - i.e. table RDB$USER_PRIVILEGES // is missing due to non-FB security DB if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err)) - check("IAttachment::execute", &st); + checkStatus("IAttachment::execute", &st); role = ""; } @@ -200,7 +198,7 @@ CreateGrant checkCreateDatabaseGrant(const MetaString& userName, const MetaStrin // is missing due to non-FB3 security DB return CreateGrant::NONE; } - check("IAttachment::execute", &st); + checkStatus("IAttachment::execute", &st); } if (cnt > 0) @@ -235,7 +233,7 @@ CreateGrant checkCreateDatabaseGrant(const MetaString& userName, const MetaStrin " from role_tree t join system.rdb$roles r on t.nm = r.rdb$role_name "; RefPtr rs(REF_NO_INCR, att->openCursor(&st, tra, 0, sql, SQL_DIALECT_V6, par2.getMetadata(), par2.getBuffer(), res2.getMetadata(), NULL, 0)); - check("IAttachment::execute", &st); + checkStatus("IAttachment::execute", &st); UserId::Privileges privileges, wrk; @@ -245,7 +243,7 @@ CreateGrant checkCreateDatabaseGrant(const MetaString& userName, const MetaStrin privileges |= wrk; } - check("IResultSet::fetchNext", &st); + checkStatus("IResultSet::fetchNext", &st); return wrk.test(CREATE_DATABASE) ? CreateGrant::GRANTED : CreateGrant::NONE; } @@ -310,7 +308,7 @@ RecordBuffer* DbCreatorsList::getList(thread_db* tdbb, RelationPermanent* relati if (st->getState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err)) - check("IAttachment::openCursor", &st); + checkStatus("IAttachment::openCursor", &st); // isc_dsql_relation_err when opening cursor - i.e. table // is missing due to non-FB3 security DB @@ -339,7 +337,7 @@ RecordBuffer* DbCreatorsList::getList(thread_db* tdbb, RelationPermanent* relati buffer->store(record); } - check("IResultSet::fetchNext", &st); + checkStatus("IResultSet::fetchNext", &st); } catch (const Exception&) { @@ -350,4 +348,5 @@ RecordBuffer* DbCreatorsList::getList(thread_db* tdbb, RelationPermanent* relati return getData(relation); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/DbCreators.h b/src/jrd/DbCreators.h index d3a6a5ecc11..a1d3a30c277 100644 --- a/src/jrd/DbCreators.h +++ b/src/jrd/DbCreators.h @@ -34,7 +34,7 @@ #include "../jrd/recsrc/RecordSource.h" #include "../jrd/Monitoring.h" -namespace Jrd { +namespace Firebird::Jrd { enum class CreateGrant { @@ -43,13 +43,13 @@ enum class CreateGrant ASSUMED // User is admin and has all rights }; -CreateGrant checkCreateDatabaseGrant(const Firebird::MetaString& userName, const Firebird::MetaString& trustedRole, - const Firebird::MetaString& sqlRole, const char* securityDb); +CreateGrant checkCreateDatabaseGrant(const MetaString& userName, const MetaString& trustedRole, + const MetaString& sqlRole, const char* securityDb); class DbCreatorsScan: public VirtualTableScan { public: - DbCreatorsScan(CompilerScratch* csb, const Firebird::string& alias, + DbCreatorsScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) {} @@ -71,7 +71,7 @@ class DbCreatorsList : public SnapshotData RecordBuffer* makeBuffer(thread_db* tdbb); }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_DB_CREATORS diff --git a/src/jrd/DebugInterface.cpp b/src/jrd/DebugInterface.cpp index 72e27b971b7..c305bf7f0ab 100644 --- a/src/jrd/DebugInterface.cpp +++ b/src/jrd/DebugInterface.cpp @@ -25,8 +25,10 @@ #include "../jrd/DebugInterface.h" #include "../jrd/blb_proto.h" -using namespace Jrd; -using namespace Firebird; + +namespace Firebird::Jrd +{ + void DBG_parse_debug_info(thread_db* tdbb, bid* blob_id, DbgInfo& dbgInfo) { @@ -272,3 +274,6 @@ void DBG_parse_debug_info(ULONG length, const UCHAR* data, DbgInfo& dbgInfo) ERR_post_warning(Arg::Warning(isc_bad_debug_format)); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/DebugInterface.h b/src/jrd/DebugInterface.h index 63952cfa151..2e796d8f72e 100644 --- a/src/jrd/DebugInterface.h +++ b/src/jrd/DebugInterface.h @@ -28,6 +28,11 @@ #include "../jrd/blb.h" +namespace Firebird::Jrd +{ +class MetaName; + + // Version 2 of the debug information replaces 16-bit values // inside the fb_dbg_map_src2blr tag with 32-bit ones. // Also, it introduces some new tags. @@ -35,12 +40,6 @@ inline constexpr UCHAR DBG_INFO_VERSION_1 = UCHAR(1); inline constexpr UCHAR DBG_INFO_VERSION_2 = UCHAR(2); inline constexpr UCHAR CURRENT_DBG_INFO_VERSION = DBG_INFO_VERSION_2; -namespace Jrd { -class MetaName; -} - -namespace Firebird { - class MapBlrToSrcItem { public: @@ -52,9 +51,9 @@ class MapBlrToSrcItem { return Item.mbs_offset; } }; -typedef Firebird::SortedArray< +typedef SortedArray< MapBlrToSrcItem, - Firebird::EmptyStorage, + EmptyStorage, ULONG, MapBlrToSrcItem> MapBlrToSrc; @@ -112,7 +111,7 @@ struct DbgInfo : public PermanentStorage forCursorOffsetToName.clear(); { // scope - LeftPooledMap::Accessor accessor(&subFuncs); + LeftPooledMap::Accessor accessor(&subFuncs); for (bool found = accessor.getFirst(); found; found = accessor.getNext()) delete accessor.current()->second; @@ -121,7 +120,7 @@ struct DbgInfo : public PermanentStorage } { // scope - LeftPooledMap::Accessor accessor(&subProcs); + LeftPooledMap::Accessor accessor(&subProcs); for (bool found = accessor.getFirst(); found; found = accessor.getNext()) delete accessor.current()->second; @@ -131,17 +130,18 @@ struct DbgInfo : public PermanentStorage } MapBlrToSrc blrToSrc; // mapping between blr offsets and source text position - RightPooledMap varIndexToName; // mapping between variable index and name - RightPooledMap argInfoToName; // mapping between argument info (type, index) and name - RightPooledMap declaredCursorIndexToName; // mapping between declared cursor index and name - RightPooledMap forCursorOffsetToName; // mapping between for-cursor offset and name - LeftPooledMap subFuncs; // sub functions - LeftPooledMap subProcs; // sub procedures + RightPooledMap varIndexToName; // mapping between variable index and name + RightPooledMap argInfoToName; // mapping between argument info (type, index) and name + RightPooledMap declaredCursorIndexToName; // mapping between declared cursor index and name + RightPooledMap forCursorOffsetToName; // mapping between for-cursor offset and name + LeftPooledMap subFuncs; // sub functions + LeftPooledMap subProcs; // sub procedures }; -} // namespace Firebird +void DBG_parse_debug_info(thread_db*, bid*, DbgInfo&); +void DBG_parse_debug_info(ULONG, const UCHAR*, DbgInfo&); + -void DBG_parse_debug_info(Jrd::thread_db*, Jrd::bid*, Firebird::DbgInfo&); -void DBG_parse_debug_info(ULONG, const UCHAR*, Firebird::DbgInfo&); +} // namespace Firebird::Jrd #endif // DEBUG_INTERFACE_H diff --git a/src/jrd/EngineInterface.h b/src/jrd/EngineInterface.h index 3a2adf4fcc6..9e542c711c0 100644 --- a/src/jrd/EngineInterface.h +++ b/src/jrd/EngineInterface.h @@ -28,7 +28,7 @@ #include "../common/StatementMetadata.h" #include "../common/classes/RefCounted.h" -namespace Jrd { +namespace Firebird::Jrd { // Engine objects used by interface objects class blb; @@ -41,7 +41,11 @@ class StableAttachmentPart; class Attachment; class Service; class UserId; -class Applier; + +namespace Replication +{ + class Applier; +} // forward declarations class JStatement; @@ -49,22 +53,22 @@ class JAttachment; class JProvider; class JBlob final : - public Firebird::RefCntIface > + public RefCntIface> { public: // IBlob implementation int release() override; - void getInfo(Firebird::CheckStatusWrapper* status, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - int getSegment(Firebird::CheckStatusWrapper* status, unsigned int length, void* buffer, + int getSegment(CheckStatusWrapper* status, unsigned int length, void* buffer, unsigned int* segmentLength) override; - void putSegment(Firebird::CheckStatusWrapper* status, unsigned int length, const void* buffer) override; - void cancel(Firebird::CheckStatusWrapper* status) override; - void close(Firebird::CheckStatusWrapper* status) override; - int seek(Firebird::CheckStatusWrapper* status, int mode, int offset) override; // returns position - void deprecatedCancel(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; + void putSegment(CheckStatusWrapper* status, unsigned int length, const void* buffer) override; + void cancel(CheckStatusWrapper* status) override; + void close(CheckStatusWrapper* status) override; + int seek(CheckStatusWrapper* status, int mode, int offset) override; // returns position + void deprecatedCancel(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; public: JBlob(blb* handle, StableAttachmentPart* sa); @@ -86,34 +90,34 @@ class JBlob final : private: blb* blob; - Firebird::RefPtr sAtt; + RefPtr sAtt; - void freeEngineData(Firebird::CheckStatusWrapper* status); - void internalClose(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); + void internalClose(CheckStatusWrapper* status); }; class JTransaction final : - public Firebird::RefCntIface > + public RefCntIface > { public: // ITransaction implementation int release() override; - void getInfo(Firebird::CheckStatusWrapper* status, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - void prepare(Firebird::CheckStatusWrapper* status, + void prepare(CheckStatusWrapper* status, unsigned int msg_length = 0, const unsigned char* message = 0) override; - void commit(Firebird::CheckStatusWrapper* status) override; - void commitRetaining(Firebird::CheckStatusWrapper* status) override; - void rollback(Firebird::CheckStatusWrapper* status) override; - void rollbackRetaining(Firebird::CheckStatusWrapper* status) override; - void disconnect(Firebird::CheckStatusWrapper* status) override; - Firebird::ITransaction* join(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction) override; - JTransaction* validate(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* testAtt) override; - JTransaction* enterDtc(Firebird::CheckStatusWrapper* status) override; - void deprecatedCommit(Firebird::CheckStatusWrapper* status) override; - void deprecatedRollback(Firebird::CheckStatusWrapper* status) override; - void deprecatedDisconnect(Firebird::CheckStatusWrapper* status) override; + void commit(CheckStatusWrapper* status) override; + void commitRetaining(CheckStatusWrapper* status) override; + void rollback(CheckStatusWrapper* status) override; + void rollbackRetaining(CheckStatusWrapper* status) override; + void disconnect(CheckStatusWrapper* status) override; + ITransaction* join(CheckStatusWrapper* status, ITransaction* transaction) override; + JTransaction* validate(CheckStatusWrapper* status, IAttachment* testAtt) override; + JTransaction* enterDtc(CheckStatusWrapper* status) override; + void deprecatedCommit(CheckStatusWrapper* status) override; + void deprecatedRollback(CheckStatusWrapper* status) override; + void deprecatedDisconnect(CheckStatusWrapper* status) override; public: JTransaction(jrd_tra* handle, StableAttachmentPart* sa); @@ -141,35 +145,35 @@ class JTransaction final : private: jrd_tra* transaction; - Firebird::RefPtr sAtt; + RefPtr sAtt; JTransaction(JTransaction* from); - void freeEngineData(Firebird::CheckStatusWrapper* status); - void internalCommit(Firebird::CheckStatusWrapper* status); - void internalRollback(Firebird::CheckStatusWrapper* status); - void internalDisconnect(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); + void internalCommit(CheckStatusWrapper* status); + void internalRollback(CheckStatusWrapper* status); + void internalDisconnect(CheckStatusWrapper* status); }; class JResultSet final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IResultSet implementation int release() override; - int fetchNext(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchPrior(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchFirst(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchLast(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchAbsolute(Firebird::CheckStatusWrapper* status, int position, void* message) override; - int fetchRelative(Firebird::CheckStatusWrapper* status, int offset, void* message) override; - FB_BOOLEAN isEof(Firebird::CheckStatusWrapper* status) override; - FB_BOOLEAN isBof(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; - void setDelayedOutputFormat(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* format) override; - void getInfo(Firebird::CheckStatusWrapper* status, + int fetchNext(CheckStatusWrapper* status, void* message) override; + int fetchPrior(CheckStatusWrapper* status, void* message) override; + int fetchFirst(CheckStatusWrapper* status, void* message) override; + int fetchLast(CheckStatusWrapper* status, void* message) override; + int fetchAbsolute(CheckStatusWrapper* status, int position, void* message) override; + int fetchRelative(CheckStatusWrapper* status, int offset, void* message) override; + FB_BOOLEAN isEof(CheckStatusWrapper* status) override; + FB_BOOLEAN isBof(CheckStatusWrapper* status) override; + IMessageMetadata* getMetadata(CheckStatusWrapper* status) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; + void setDelayedOutputFormat(CheckStatusWrapper* status, IMessageMetadata* format) override; + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; @@ -190,37 +194,37 @@ class JResultSet final : private: DsqlCursor* cursor; - Firebird::RefPtr statement; + RefPtr statement; int state; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JBatch final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IBatch implementation int release() override; - void add(Firebird::CheckStatusWrapper* status, unsigned count, const void* inBuffer) override; - void addBlob(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer, ISC_QUAD* blobId, + void add(CheckStatusWrapper* status, unsigned count, const void* inBuffer) override; + void addBlob(CheckStatusWrapper* status, unsigned length, const void* inBuffer, ISC_QUAD* blobId, unsigned parLength, const unsigned char* par) override; - void appendBlobData(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; - void addBlobStream(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; - void registerBlob(Firebird::CheckStatusWrapper* status, const ISC_QUAD* existingBlob, ISC_QUAD* blobId) override; - Firebird::IBatchCompletionState* execute(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* transaction) override; - void cancel(Firebird::CheckStatusWrapper* status) override; - unsigned getBlobAlignment(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override; - void setDefaultBpb(Firebird::CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; - void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, + void appendBlobData(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; + void addBlobStream(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; + void registerBlob(CheckStatusWrapper* status, const ISC_QUAD* existingBlob, ISC_QUAD* blobId) override; + IBatchCompletionState* execute(CheckStatusWrapper* status, + ITransaction* transaction) override; + void cancel(CheckStatusWrapper* status) override; + unsigned getBlobAlignment(CheckStatusWrapper* status) override; + IMessageMetadata* getMetadata(CheckStatusWrapper* status) override; + void setDefaultBpb(CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; public: - JBatch(DsqlBatch* handle, JStatement* aStatement, Firebird::IMessageMetadata* aMetadata); + JBatch(DsqlBatch* handle, JStatement* aStatement, IMessageMetadata* aMetadata); StableAttachmentPart* getAttachment(); @@ -236,31 +240,31 @@ class JBatch final : private: DsqlBatch* batch; - Firebird::RefPtr statement; - Firebird::RefPtr m_meta; + RefPtr statement; + RefPtr m_meta; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JReplicator final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IReplicator implementation int release() override; - void process(Firebird::CheckStatusWrapper* status, unsigned length, const unsigned char* data) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; + void process(CheckStatusWrapper* status, unsigned length, const unsigned char* data) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; public: - JReplicator(Applier* appl, StableAttachmentPart* sa); + JReplicator(Replication::Applier* appl, StableAttachmentPart* sa); StableAttachmentPart* getAttachment() { return sAtt; } - Applier* getHandle() noexcept + Replication::Applier* getHandle() noexcept { return applier; } @@ -271,47 +275,47 @@ class JReplicator final : } private: - Applier* applier; - Firebird::RefPtr sAtt; + Replication::Applier* applier; + RefPtr sAtt; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JStatement final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IStatement implementation int release() override; - void getInfo(Firebird::CheckStatusWrapper* status, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - void free(Firebird::CheckStatusWrapper* status) override; - void deprecatedFree(Firebird::CheckStatusWrapper* status) override; - ISC_UINT64 getAffectedRecords(Firebird::CheckStatusWrapper* userStatus) override; - Firebird::IMessageMetadata* getOutputMetadata(Firebird::CheckStatusWrapper* userStatus) override; - Firebird::IMessageMetadata* getInputMetadata(Firebird::CheckStatusWrapper* userStatus) override; - unsigned getType(Firebird::CheckStatusWrapper* status) override; - const char* getPlan(Firebird::CheckStatusWrapper* status, FB_BOOLEAN detailed) override; - Firebird::ITransaction* execute(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* transaction, Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, void* outBuffer) override; - JResultSet* openCursor(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* transaction, Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, unsigned int flags) override; - void setCursorName(Firebird::CheckStatusWrapper* status, const char* name) override; - unsigned getFlags(Firebird::CheckStatusWrapper* status) override; - - unsigned int getTimeout(Firebird::CheckStatusWrapper* status) override; - void setTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - JBatch* createBatch(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* inMetadata, + void free(CheckStatusWrapper* status) override; + void deprecatedFree(CheckStatusWrapper* status) override; + ISC_UINT64 getAffectedRecords(CheckStatusWrapper* userStatus) override; + IMessageMetadata* getOutputMetadata(CheckStatusWrapper* userStatus) override; + IMessageMetadata* getInputMetadata(CheckStatusWrapper* userStatus) override; + unsigned getType(CheckStatusWrapper* status) override; + const char* getPlan(CheckStatusWrapper* status, FB_BOOLEAN detailed) override; + ITransaction* execute(CheckStatusWrapper* status, + ITransaction* transaction, IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, void* outBuffer) override; + JResultSet* openCursor(CheckStatusWrapper* status, + ITransaction* transaction, IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, unsigned int flags) override; + void setCursorName(CheckStatusWrapper* status, const char* name) override; + unsigned getFlags(CheckStatusWrapper* status) override; + + unsigned int getTimeout(CheckStatusWrapper* status) override; + void setTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + JBatch* createBatch(CheckStatusWrapper* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; - unsigned getMaxInlineBlobSize(Firebird::CheckStatusWrapper* status) override; - void setMaxInlineBlobSize(Firebird::CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxInlineBlobSize(CheckStatusWrapper* status) override; + void setMaxInlineBlobSize(CheckStatusWrapper* status, unsigned size) override; public: - JStatement(DsqlRequest* handle, StableAttachmentPart* sa, Firebird::Array& meta); + JStatement(DsqlRequest* handle, StableAttachmentPart* sa, Array& meta); StableAttachmentPart* getAttachment() { @@ -325,31 +329,31 @@ class JStatement final : private: DsqlRequest* statement; - Firebird::RefPtr sAtt; - Firebird::StatementMetadata metadata; + RefPtr sAtt; + StatementMetadata metadata; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JRequest final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IRequest implementation int release() override; - void receive(Firebird::CheckStatusWrapper* status, int level, unsigned int msg_type, + void receive(CheckStatusWrapper* status, int level, unsigned int msg_type, unsigned int length, void* message) override; - void send(Firebird::CheckStatusWrapper* status, int level, unsigned int msg_type, + void send(CheckStatusWrapper* status, int level, unsigned int msg_type, unsigned int length, const void* message) override; - void getInfo(Firebird::CheckStatusWrapper* status, int level, + void getInfo(CheckStatusWrapper* status, int level, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - void start(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra, int level) override; - void startAndSend(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra, int level, + void start(CheckStatusWrapper* status, ITransaction* tra, int level) override; + void startAndSend(CheckStatusWrapper* status, ITransaction* tra, int level, unsigned int msg_type, unsigned int length, const void* message) override; - void unwind(Firebird::CheckStatusWrapper* status, int level) override; - void free(Firebird::CheckStatusWrapper* status) override; - void deprecatedFree(Firebird::CheckStatusWrapper* status) override; + void unwind(CheckStatusWrapper* status, int level) override; + void free(CheckStatusWrapper* status) override; + void deprecatedFree(CheckStatusWrapper* status) override; public: JRequest(Statement* handle, StableAttachmentPart* sa); @@ -366,21 +370,21 @@ class JRequest final : private: Statement* rq; - Firebird::RefPtr sAtt; + RefPtr sAtt; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; -class JEvents final : public Firebird::RefCntIface > +class JEvents final : public RefCntIface > { public: // IEvents implementation int release() override; - void cancel(Firebird::CheckStatusWrapper* status) override; - void deprecatedCancel(Firebird::CheckStatusWrapper* status) override; + void cancel(CheckStatusWrapper* status) override; + void deprecatedCancel(CheckStatusWrapper* status) override; public: - JEvents(int aId, StableAttachmentPart* sa, Firebird::IEventCallback* aCallback); + JEvents(int aId, StableAttachmentPart* sa, IEventCallback* aCallback); JEvents* getHandle() noexcept { @@ -394,79 +398,79 @@ class JEvents final : public Firebird::RefCntIface sAtt; - Firebird::RefPtr callback; + RefPtr sAtt; + RefPtr callback; - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JAttachment final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IAttachment implementation int release() override; void addRef() override; - void getInfo(Firebird::CheckStatusWrapper* status, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - JTransaction* startTransaction(Firebird::CheckStatusWrapper* status, + JTransaction* startTransaction(CheckStatusWrapper* status, unsigned int tpbLength, const unsigned char* tpb) override; - JTransaction* reconnectTransaction(Firebird::CheckStatusWrapper* status, + JTransaction* reconnectTransaction(CheckStatusWrapper* status, unsigned int length, const unsigned char* id) override; - JRequest* compileRequest(Firebird::CheckStatusWrapper* status, + JRequest* compileRequest(CheckStatusWrapper* status, unsigned int blr_length, const unsigned char* blr) override; - void transactRequest(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + void transactRequest(CheckStatusWrapper* status, ITransaction* transaction, unsigned int blr_length, const unsigned char* blr, unsigned int in_msg_length, const unsigned char* in_msg, unsigned int out_msg_length, unsigned char* out_msg) override; - JBlob* createBlob(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + JBlob* createBlob(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int bpbLength = 0, const unsigned char* bpb = 0) override; - JBlob* openBlob(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + JBlob* openBlob(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int bpbLength = 0, const unsigned char* bpb = 0) override; - int getSlice(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + int getSlice(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int sdl_length, const unsigned char* sdl, unsigned int param_length, const unsigned char* param, int sliceLength, unsigned char* slice) override; - void putSlice(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + void putSlice(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int sdl_length, const unsigned char* sdl, unsigned int param_length, const unsigned char* param, int sliceLength, unsigned char* slice) override; - void executeDyn(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + void executeDyn(CheckStatusWrapper* status, ITransaction* transaction, unsigned int length, const unsigned char* dyn) override; - JStatement* prepare(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra, + JStatement* prepare(CheckStatusWrapper* status, ITransaction* tra, unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, unsigned int flags) override; - Firebird::ITransaction* execute(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, - unsigned int dialect, Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, void* outBuffer) override; - Firebird::IResultSet* openCursor(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, - unsigned int dialect, Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, const char* cursorName, unsigned int cursorFlags) override; - JEvents* queEvents(Firebird::CheckStatusWrapper* status, Firebird::IEventCallback* callback, + ITransaction* execute(CheckStatusWrapper* status, + ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, + unsigned int dialect, IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, void* outBuffer) override; + IResultSet* openCursor(CheckStatusWrapper* status, + ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, + unsigned int dialect, IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, const char* cursorName, unsigned int cursorFlags) override; + JEvents* queEvents(CheckStatusWrapper* status, IEventCallback* callback, unsigned int length, const unsigned char* events) override; - void cancelOperation(Firebird::CheckStatusWrapper* status, int option) override; - void ping(Firebird::CheckStatusWrapper* status) override; - void detach(Firebird::CheckStatusWrapper* status) override; - void dropDatabase(Firebird::CheckStatusWrapper* status) override; - void deprecatedDetach(Firebird::CheckStatusWrapper* status) override; - void deprecatedDropDatabase(Firebird::CheckStatusWrapper* status) override; - - unsigned int getIdleTimeout(Firebird::CheckStatusWrapper* status) override; - void setIdleTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - unsigned int getStatementTimeout(Firebird::CheckStatusWrapper* status) override; - void setStatementTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - Firebird::IBatch* createBatch(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + void cancelOperation(CheckStatusWrapper* status, int option) override; + void ping(CheckStatusWrapper* status) override; + void detach(CheckStatusWrapper* status) override; + void dropDatabase(CheckStatusWrapper* status) override; + void deprecatedDetach(CheckStatusWrapper* status) override; + void deprecatedDropDatabase(CheckStatusWrapper* status) override; + + unsigned int getIdleTimeout(CheckStatusWrapper* status) override; + void setIdleTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + unsigned int getStatementTimeout(CheckStatusWrapper* status) override; + void setStatementTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + IBatch* createBatch(CheckStatusWrapper* status, ITransaction* transaction, unsigned stmtLength, const char* sqlStmt, unsigned dialect, - Firebird::IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; - Firebird::IReplicator* createReplicator(Firebird::CheckStatusWrapper* status) override; + IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; + IReplicator* createReplicator(CheckStatusWrapper* status) override; - unsigned getMaxBlobCacheSize(Firebird::CheckStatusWrapper* status) override; - void setMaxBlobCacheSize(Firebird::CheckStatusWrapper* status, unsigned size) override; - unsigned getMaxInlineBlobSize(Firebird::CheckStatusWrapper* status) override; - void setMaxInlineBlobSize(Firebird::CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxBlobCacheSize(CheckStatusWrapper* status) override; + void setMaxBlobCacheSize(CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxInlineBlobSize(CheckStatusWrapper* status) override; + void setMaxInlineBlobSize(CheckStatusWrapper* status, unsigned size) override; public: explicit JAttachment(StableAttachmentPart* js); @@ -483,54 +487,54 @@ class JAttachment final : return att; } - JTransaction* getTransactionInterface(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra); - jrd_tra* getEngineTransaction(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra); + JTransaction* getTransactionInterface(CheckStatusWrapper* status, ITransaction* tra); + jrd_tra* getEngineTransaction(CheckStatusWrapper* status, ITransaction* tra); private: friend class StableAttachmentPart; StableAttachmentPart* att; - void freeEngineData(Firebird::CheckStatusWrapper* status, bool forceFree); + void freeEngineData(CheckStatusWrapper* status, bool forceFree); void detachEngine() { att = NULL; } - void internalDetach(Firebird::CheckStatusWrapper* status); - void internalDropDatabase(Firebird::CheckStatusWrapper* status); + void internalDetach(CheckStatusWrapper* status); + void internalDropDatabase(CheckStatusWrapper* status); }; class JService final : - public Firebird::RefCntIface > + public RefCntIface > { public: // IService implementation int release() override; - void detach(Firebird::CheckStatusWrapper* status) override; - void deprecatedDetach(Firebird::CheckStatusWrapper* status) override; - void query(Firebird::CheckStatusWrapper* status, + void detach(CheckStatusWrapper* status) override; + void deprecatedDetach(CheckStatusWrapper* status) override; + void query(CheckStatusWrapper* status, unsigned int sendLength, const unsigned char* sendItems, unsigned int receiveLength, const unsigned char* receiveItems, unsigned int bufferLength, unsigned char* buffer) override; - void start(Firebird::CheckStatusWrapper* status, + void start(CheckStatusWrapper* status, unsigned int spbLength, const unsigned char* spb) override; - void cancel(Firebird::CheckStatusWrapper* status) override; + void cancel(CheckStatusWrapper* status) override; public: explicit JService(Jrd::Service* handle); Jrd::Service* svc; private: - void freeEngineData(Firebird::CheckStatusWrapper* status); + void freeEngineData(CheckStatusWrapper* status); }; class JProvider final : - public Firebird::StdPlugin > + public StdPlugin > { public: - explicit JProvider(Firebird::IPluginConfig* pConf) + explicit JProvider(IPluginConfig* pConf) : cryptCallback(NULL), pluginConfig(pConf) { } @@ -541,29 +545,29 @@ class JProvider final : return p; } - Firebird::ICryptKeyCallback* getCryptCallback() + ICryptKeyCallback* getCryptCallback() { return cryptCallback; } // IProvider implementation - JAttachment* attachDatabase(Firebird::CheckStatusWrapper* status, const char* fileName, + JAttachment* attachDatabase(CheckStatusWrapper* status, const char* fileName, unsigned int dpbLength, const unsigned char* dpb); - JAttachment* createDatabase(Firebird::CheckStatusWrapper* status, const char* fileName, + JAttachment* createDatabase(CheckStatusWrapper* status, const char* fileName, unsigned int dpbLength, const unsigned char* dpb); - JService* attachServiceManager(Firebird::CheckStatusWrapper* status, const char* service, + JService* attachServiceManager(CheckStatusWrapper* status, const char* service, unsigned int spbLength, const unsigned char* spb); - void shutdown(Firebird::CheckStatusWrapper* status, unsigned int timeout, const int reason); - void setDbCryptCallback(Firebird::CheckStatusWrapper* status, - Firebird::ICryptKeyCallback* cryptCb); + void shutdown(CheckStatusWrapper* status, unsigned int timeout, const int reason); + void setDbCryptCallback(CheckStatusWrapper* status, + ICryptKeyCallback* cryptCb); private: - JAttachment* internalAttach(Firebird::CheckStatusWrapper* status, const char* const fileName, + JAttachment* internalAttach(CheckStatusWrapper* status, const char* const fileName, unsigned int dpbLength, const unsigned char* dpb, const UserId* existingId); - Firebird::ICryptKeyCallback* cryptCallback; - Firebird::IPluginConfig* pluginConfig; + ICryptKeyCallback* cryptCallback; + IPluginConfig* pluginConfig; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_ENGINE_INTERFACE_H diff --git a/src/jrd/ExtEngineManager.cpp b/src/jrd/ExtEngineManager.cpp index c2facb5fd24..7004fa5f16b 100644 --- a/src/jrd/ExtEngineManager.cpp +++ b/src/jrd/ExtEngineManager.cpp @@ -60,8 +60,8 @@ #include "../common/utils_proto.h" #include "../common/classes/GetPlugins.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ static EngineCheckout::Type checkoutType(IExternalEngine* engine); @@ -693,14 +693,14 @@ IExternalEngine* ExtEngineManager::ExternalContextImpl::getEngine(CheckStatusWra return engine; } -Firebird::IAttachment* ExtEngineManager::ExternalContextImpl::getAttachment( +IAttachment* ExtEngineManager::ExternalContextImpl::getAttachment( CheckStatusWrapper* /*status*/) { externalAttachment->addRef(); return externalAttachment; } -Firebird::ITransaction* ExtEngineManager::ExternalContextImpl::getTransaction( +ITransaction* ExtEngineManager::ExternalContextImpl::getTransaction( CheckStatusWrapper* /*status*/) { externalTransaction->addRef(); @@ -2032,3 +2032,6 @@ static EngineCheckout::Type checkoutType(IExternalEngine* engine) { return engine == SystemEngine::INSTANCE ? EngineCheckout::AVOID : EngineCheckout::REQUIRED; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/ExtEngineManager.h b/src/jrd/ExtEngineManager.h index 5528d6af0c7..ba355bf4f5a 100644 --- a/src/jrd/ExtEngineManager.h +++ b/src/jrd/ExtEngineManager.h @@ -42,7 +42,7 @@ struct dsc; -namespace Jrd { +namespace Firebird::Jrd { class thread_db; class jrd_prc; @@ -61,7 +61,7 @@ struct impure_value; struct record_param; -class ExtEngineManager final : public Firebird::PermanentStorage +class ExtEngineManager final : public PermanentStorage { private: class AttachmentImpl; @@ -69,8 +69,8 @@ class ExtEngineManager final : public Firebird::PermanentStorage class TransactionImpl; class RoutineMetadata final : - public Firebird::VersionedIface >, - public Firebird::PermanentStorage + public VersionedIface >, + public PermanentStorage { public: explicit RoutineMetadata(MemoryPool& pool) @@ -83,91 +83,91 @@ class ExtEngineManager final : public Firebird::PermanentStorage { } - const char* getPackage(Firebird::CheckStatusWrapper* /*status*/) const + const char* getPackage(CheckStatusWrapper* /*status*/) const { return name.package.nullStr(); } - const char* getName(Firebird::CheckStatusWrapper* /*status*/) const + const char* getName(CheckStatusWrapper* /*status*/) const { return name.object.c_str(); } - const char* getEntryPoint(Firebird::CheckStatusWrapper* /*status*/) const + const char* getEntryPoint(CheckStatusWrapper* /*status*/) const { return entryPoint.c_str(); } - const char* getBody(Firebird::CheckStatusWrapper* /*status*/) const + const char* getBody(CheckStatusWrapper* /*status*/) const { return body.c_str(); } - Firebird::IMessageMetadata* getInputMetadata(Firebird::CheckStatusWrapper* /*status*/) const + IMessageMetadata* getInputMetadata(CheckStatusWrapper* /*status*/) const { return getMetadata(inputParameters); } - Firebird::IMessageMetadata* getOutputMetadata(Firebird::CheckStatusWrapper* /*status*/) const + IMessageMetadata* getOutputMetadata(CheckStatusWrapper* /*status*/) const { return getMetadata(outputParameters); } - Firebird::IMessageMetadata* getTriggerMetadata(Firebird::CheckStatusWrapper* /*status*/) const + IMessageMetadata* getTriggerMetadata(CheckStatusWrapper* /*status*/) const { return getMetadata(triggerFields); } - const char* getTriggerTable(Firebird::CheckStatusWrapper* /*status*/) const + const char* getTriggerTable(CheckStatusWrapper* /*status*/) const { return triggerTable.object.c_str(); } - unsigned getTriggerType(Firebird::CheckStatusWrapper* /*status*/) const + unsigned getTriggerType(CheckStatusWrapper* /*status*/) const { return triggerType; } - const char* getSchema(Firebird::CheckStatusWrapper* /*status*/) const + const char* getSchema(CheckStatusWrapper* /*status*/) const { return name.schema.c_str(); } public: QualifiedName name; - Firebird::string entryPoint; - Firebird::string body; - Firebird::RefPtr inputParameters; - Firebird::RefPtr outputParameters; - Firebird::RefPtr triggerFields; + string entryPoint; + string body; + RefPtr inputParameters; + RefPtr outputParameters; + RefPtr triggerFields; QualifiedName triggerTable; unsigned triggerType; private: - static Firebird::IMessageMetadata* getMetadata(const Firebird::IMessageMetadata* par) + static IMessageMetadata* getMetadata(const IMessageMetadata* par) { - Firebird::IMessageMetadata* rc = const_cast(par); + IMessageMetadata* rc = const_cast(par); rc->addRef(); return rc; } }; class ExternalContextImpl : - public Firebird::VersionedIface > + public VersionedIface > { friend class AttachmentImpl; public: - ExternalContextImpl(thread_db* tdbb, Firebird::IExternalEngine* aEngine); + ExternalContextImpl(thread_db* tdbb, IExternalEngine* aEngine); virtual ~ExternalContextImpl(); void releaseTransaction(); void setTransaction(thread_db* tdbb); - Firebird::IMaster* getMaster(); - Firebird::IExternalEngine* getEngine(Firebird::CheckStatusWrapper* status); - Firebird::IAttachment* getAttachment(Firebird::CheckStatusWrapper* status); - Firebird::ITransaction* getTransaction(Firebird::CheckStatusWrapper* status); + IMaster* getMaster(); + IExternalEngine* getEngine(CheckStatusWrapper* status); + IAttachment* getAttachment(CheckStatusWrapper* status); + ITransaction* getTransaction(CheckStatusWrapper* status); const char* getUserName(); const char* getDatabaseName(); const char* getClientCharSet(); @@ -176,18 +176,18 @@ class ExtEngineManager final : public Firebird::PermanentStorage void* setInfo(int code, void* value); private: - Firebird::IExternalEngine* engine; + IExternalEngine* engine; Attachment* internalAttachment; - Firebird::ITransaction* internalTransaction; - Firebird::IAttachment* externalAttachment; - Firebird::ITransaction* externalTransaction; - Firebird::GenericMap > miscInfo; + ITransaction* internalTransaction; + IAttachment* externalAttachment; + ITransaction* externalTransaction; + GenericMap > miscInfo; MetaName clientCharSet; }; struct EngineAttachment { - EngineAttachment(Firebird::IExternalEngine* aEngine, Jrd::Attachment* aAttachment) + EngineAttachment(IExternalEngine* aEngine, Jrd::Attachment* aAttachment) : engine(aEngine), attachment(aAttachment) { @@ -199,7 +199,7 @@ class ExtEngineManager final : public Firebird::PermanentStorage (i1.engine == i2.engine && i1.attachment > i2.attachment); } - Firebird::IExternalEngine* engine; + IExternalEngine* engine; Jrd::Attachment* attachment; }; @@ -212,8 +212,8 @@ class ExtEngineManager final : public Firebird::PermanentStorage { } - Firebird::IExternalEngine* engine; - Firebird::AutoPtr context; + IExternalEngine* engine; + AutoPtr context; TTypeId adminCharSet; }; @@ -222,20 +222,20 @@ class ExtEngineManager final : public Firebird::PermanentStorage { public: ExtRoutine(thread_db* tdbb, ExtEngineManager* aExtManager, - Firebird::IExternalEngine* aEngine, RoutineMetadata* aMetadata); + IExternalEngine* aEngine, RoutineMetadata* aMetadata); virtual ~ExtRoutine() = default; private: class PluginDeleter { public: - void operator()(Firebird::IPluginBase* ptr); + void operator()(IPluginBase* ptr); }; protected: ExtEngineManager* extManager; - std::unique_ptr engine; - Firebird::AutoPtr metadata; + std::unique_ptr engine; + AutoPtr metadata; Database* database; }; @@ -246,11 +246,11 @@ class ExtEngineManager final : public Firebird::PermanentStorage public: Function(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, ExtEngineManager* aExtManager, - Firebird::IExternalEngine* aEngine, + IExternalEngine* aEngine, RoutineMetadata* aMetadata, - Firebird::IExternalFunction* aFunction, - Firebird::RefPtr extInputParameters, - Firebird::RefPtr extOutputParameters, + IExternalFunction* aFunction, + RefPtr extInputParameters, + RefPtr extOutputParameters, const Jrd::Function* aUdf); ~Function() override; @@ -261,11 +261,11 @@ class ExtEngineManager final : public Firebird::PermanentStorage void validateParameters(thread_db* tdbb, UCHAR* msg, bool input) const; private: - Firebird::IExternalFunction* function; + IExternalFunction* function; const Jrd::Function* udf; - Firebird::AutoPtr extInputFormat; - Firebird::AutoPtr extOutputFormat; - Firebird::AutoPtr impl; + AutoPtr extInputFormat; + AutoPtr extOutputFormat; + AutoPtr impl; std::optional extInputImpureOffset; std::optional extOutputImpureOffset; }; @@ -278,16 +278,16 @@ class ExtEngineManager final : public Firebird::PermanentStorage public: Procedure(thread_db* tdbb, ExtEngineManager* aExtManager, - Firebird::IExternalEngine* aEngine, + IExternalEngine* aEngine, RoutineMetadata* aMetadata, - Firebird::IExternalProcedure* aProcedure, + IExternalProcedure* aProcedure, const jrd_prc* aPrc); ~Procedure() override; ResultSet* open(thread_db* tdbb, UCHAR* inMsg, UCHAR* outMsg) const; private: - Firebird::IExternalProcedure* procedure; + IExternalProcedure* procedure; const jrd_prc* prc; }; @@ -304,7 +304,7 @@ class ExtEngineManager final : public Firebird::PermanentStorage Attachment* attachment; bool firstFetch; EngineAttachmentInfo* attInfo; - Firebird::IExternalResultSet* resultSet; + IExternalResultSet* resultSet; CSetId charSet; }; @@ -312,8 +312,8 @@ class ExtEngineManager final : public Firebird::PermanentStorage { public: Trigger(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, ExtEngineManager* aExtManager, - Firebird::IExternalEngine* aEngine, RoutineMetadata* aMetadata, - Firebird::IExternalTrigger* aTrigger, const Jrd::Trigger* aTrg); + IExternalEngine* aEngine, RoutineMetadata* aMetadata, + IExternalTrigger* aTrigger, const Jrd::Trigger* aTrg); ~Trigger() override; void execute(thread_db* tdbb, Request* request, unsigned action, @@ -321,17 +321,17 @@ class ExtEngineManager final : public Firebird::PermanentStorage private: void setupComputedFields(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb); - void setValues(thread_db* tdbb, Request* request, Firebird::Array& msgBuffer, record_param* rpb) const; + void setValues(thread_db* tdbb, Request* request, Array& msgBuffer, record_param* rpb) const; public: - Firebird::Array> computedStatements; + Array> computedStatements; private: - Firebird::AutoPtr format; - Firebird::IExternalTrigger* trigger; + AutoPtr format; + IExternalTrigger* trigger; const Jrd::Trigger* trg; - Firebird::Array fieldsPos; - Firebird::Array varDecls; + Array fieldsPos; + Array varDecls; USHORT computedCount; }; @@ -346,37 +346,37 @@ class ExtEngineManager final : public Firebird::PermanentStorage void closeAttachment(thread_db* tdbb, Attachment* attachment); void makeFunction(thread_db* tdbb, CompilerScratch* csb, Jrd::Function* udf, - const MetaName& engine, const Firebird::string& entryPoint, - const Firebird::string& body); + const MetaName& engine, const string& entryPoint, + const string& body); void makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_prc* prc, - const MetaName& engine, const Firebird::string& entryPoint, - const Firebird::string& body); + const MetaName& engine, const string& entryPoint, + const string& body); void makeTrigger(thread_db* tdbb, CompilerScratch* csb, Jrd::Trigger* trg, - const MetaName& engine, const Firebird::string& entryPoint, - const Firebird::string& body, unsigned type); + const MetaName& engine, const string& entryPoint, + const string& body, unsigned type); private: - Firebird::IExternalEngine* getEngine(thread_db* tdbb, + IExternalEngine* getEngine(thread_db* tdbb, const MetaName& name); EngineAttachmentInfo* getEngineAttachment(thread_db* tdbb, const MetaName& name); EngineAttachmentInfo* getEngineAttachment(thread_db* tdbb, - Firebird::IExternalEngine* engine, bool closing = false); - void setupAdminCharSet(thread_db* tdbb, Firebird::IExternalEngine* engine, + IExternalEngine* engine, bool closing = false); + void setupAdminCharSet(thread_db* tdbb, IExternalEngine* engine, EngineAttachmentInfo* attInfo); private: - typedef Firebird::GenericMap > > EnginesMap; - typedef Firebird::GenericMap > > EnginesMap; + typedef GenericMap >, EngineAttachment> EnginesAttachmentsMap; - Firebird::RWLock enginesLock; + RWLock enginesLock; EnginesMap engines; EnginesAttachmentsMap enginesAttachments; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_EXT_ENGINE_MANAGER_H diff --git a/src/jrd/Function.epp b/src/jrd/Function.epp index d29f41a2a82..188a73196b7 100644 --- a/src/jrd/Function.epp +++ b/src/jrd/Function.epp @@ -52,8 +52,9 @@ #include "../jrd/Function.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + DATABASE DB = FILENAME "ODS.RDB"; @@ -238,7 +239,7 @@ ScanResult Function::scan(thread_db* tdbb, ObjectBase::Flag flags) setDefaultCount(getDefaultCount() + 1); MemoryPool* const csb_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, csb_pool); + JrdContextPoolHolder context(tdbb, csb_pool); try { @@ -307,7 +308,7 @@ ScanResult Function::scan(thread_db* tdbb, ObjectBase::Flag flags) else if (!X.RDB$ENGINE_NAME.NULL || !X.RDB$FUNCTION_BLR.NULL) { MemoryPool* const csb_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, csb_pool); + JrdContextPoolHolder context(tdbb, csb_pool); try { @@ -419,7 +420,7 @@ ScanResult Function::reload(thread_db* tdbb, ObjectBase::Flag /*unused*/) found = true; MemoryPool* const csb_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, csb_pool); + JrdContextPoolHolder context(tdbb, csb_pool); try { @@ -462,3 +463,5 @@ void Function::checkReload(thread_db* tdbb) const getPermanent()->reload(tdbb, 0); } + +} // namespace Firebird::Jrd diff --git a/src/jrd/Function.h b/src/jrd/Function.h index 1bac8bbc65d..8e9a274f6fb 100644 --- a/src/jrd/Function.h +++ b/src/jrd/Function.h @@ -30,7 +30,7 @@ #include "../jrd/CacheVector.h" #include "../jrd/lck.h" -namespace Jrd +namespace Firebird::Jrd { class ValueListNode; @@ -115,7 +115,7 @@ namespace Jrd USHORT fun_return_arg; // return argument ULONG fun_temp_length; // temporary space required - Firebird::string fun_exception_message; // message containing the exception error message + string fun_exception_message; // message containing the exception error message bool fun_deterministic; const ExtEngineManager::Function* fun_external; @@ -127,6 +127,6 @@ namespace Jrd ScanResult reload(thread_db* tdbb, ObjectBase::Flag fl); }; -} +} // namespace Firebird::Jrd #endif // JRD_FUNCTION_H diff --git a/src/jrd/GarbageCollector.cpp b/src/jrd/GarbageCollector.cpp index 9c0642073a0..5a206f64890 100644 --- a/src/jrd/GarbageCollector.cpp +++ b/src/jrd/GarbageCollector.cpp @@ -24,10 +24,9 @@ #include "../jrd/GarbageCollector.h" #include "../jrd/tra.h" -using namespace Jrd; -using namespace Firebird; -namespace Jrd { +namespace Firebird::Jrd +{ void GarbageCollector::RelationData::clear() @@ -216,4 +215,4 @@ GarbageCollector::RelationData* GarbageCollector::getRelData(Sync &sync, const U } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/GarbageCollector.h b/src/jrd/GarbageCollector.h index 8f9ef6791e8..94e36df421d 100644 --- a/src/jrd/GarbageCollector.h +++ b/src/jrd/GarbageCollector.h @@ -30,7 +30,7 @@ #include "../jrd/sbm.h" -namespace Jrd { +namespace Firebird::Jrd { class Database; class Savepoint; @@ -70,7 +70,7 @@ class GarbageCollector return item.pageno; } }; - typedef Firebird::BePlusTree PageTranMap; + typedef BePlusTree PageTranMap; class RelationData @@ -101,26 +101,26 @@ class GarbageCollector void clear(); - Firebird::MemoryPool& m_pool; - Firebird::SyncObject m_sync; + MemoryPool& m_pool; + SyncObject m_sync; PageTranMap m_pages; USHORT m_relID; }; - typedef Firebird::SortedArray< + typedef SortedArray< RelationData*, - Firebird::EmptyStorage, + EmptyStorage, USHORT, RelationData> RelGarbageArray; - RelationData* getRelData(Firebird::Sync& sync, const USHORT relID, bool allowCreate); + RelationData* getRelData(Sync& sync, const USHORT relID, bool allowCreate); - Firebird::MemoryPool& m_pool; - Firebird::SyncObject m_sync; + MemoryPool& m_pool; + SyncObject m_sync; RelGarbageArray m_relations; USHORT m_nextRelID; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_GARBAGE_COLLECTOR_H diff --git a/src/jrd/GlobalRWLock.cpp b/src/jrd/GlobalRWLock.cpp index 57b6dbeeeeb..6244b959eb9 100644 --- a/src/jrd/GlobalRWLock.cpp +++ b/src/jrd/GlobalRWLock.cpp @@ -45,8 +45,8 @@ IMPLEMENT_TRACE_ROUTINE(cos_trace, "COS") #endif -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ int GlobalRWLock::blocking_ast_cached_lock(void* ast_object) @@ -373,3 +373,6 @@ void GlobalRWLock::blockingAstHandler(thread_db* tdbb) blocking = true; } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/GlobalRWLock.h b/src/jrd/GlobalRWLock.h index e5df49a4c73..ec8a5492457 100644 --- a/src/jrd/GlobalRWLock.h +++ b/src/jrd/GlobalRWLock.h @@ -50,11 +50,13 @@ DEFINE_TRACE_ROUTINE(cos_trace); #endif -namespace Jrd { +namespace Firebird::Jrd +{ + enum lck_t : UCHAR; -class GlobalRWLock : public Firebird::PermanentStorage +class GlobalRWLock : public PermanentStorage { public: GlobalRWLock(thread_db* tdbb, MemoryPool& p, @@ -87,17 +89,17 @@ class GlobalRWLock : public Firebird::PermanentStorage virtual void blockingAstHandler(thread_db* tdbb); - Firebird::Mutex counterMutex; // Protects counter and blocking flag + Mutex counterMutex; // Protects counter and blocking flag private: ULONG pendingLock; ULONG readers; - Firebird::Condition noReaders; // Semaphore to wait all readers unlock to start relock + Condition noReaders; // Semaphore to wait all readers unlock to start relock ULONG pendingWriters; bool currentWriter; - Firebird::Condition writerFinished; + Condition writerFinished; // true - unlock keep cached lock and release by AST. // false - unlock releases cached lock if possible @@ -107,6 +109,7 @@ class GlobalRWLock : public Firebird::PermanentStorage static int blocking_ast_cached_lock(void* ast_object); }; -} + +} // namespace Firebird::Jrd #endif // GLOBAL_RW_LOCK diff --git a/src/jrd/HazardPtr.h b/src/jrd/HazardPtr.h index 438aa5bfc0c..9deccf69492 100644 --- a/src/jrd/HazardPtr.h +++ b/src/jrd/HazardPtr.h @@ -38,7 +38,7 @@ extern atomics::atomic totHaz; -namespace Jrd { +namespace Firebird::Jrd { class HazardObject { @@ -256,6 +256,6 @@ bool operator!=(const T* v1, const HazardPtr v2) return v2 != v1; } -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_HAZARDPTR_H diff --git a/src/jrd/InitCDSLib.cpp b/src/jrd/InitCDSLib.cpp index dd27722a90d..c807086a3ac 100644 --- a/src/jrd/InitCDSLib.cpp +++ b/src/jrd/InitCDSLib.cpp @@ -39,11 +39,11 @@ #include //cds::Initialize, cds::Terminate #include //cds::gc::DHP (Hazard Pointer) -using namespace Firebird; -namespace Jrd +namespace Firebird::Jrd { + Array* InitCDS::m_pools = nullptr; MemoryPool* InitCDS::m_pool = nullptr; MemoryStats InitCDS::m_stats; @@ -142,6 +142,7 @@ MemoryPool* InitCDS::createPool() return pool; } -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // CDS_UNAVAILABLE diff --git a/src/jrd/InitCDSLib.h b/src/jrd/InitCDSLib.h index 1aea3705351..4d2aba93991 100644 --- a/src/jrd/InitCDSLib.h +++ b/src/jrd/InitCDSLib.h @@ -35,8 +35,7 @@ //#define DEBUG_CDS_MEMORY -namespace Jrd -{ +namespace Firebird::Jrd { class InitCDS { @@ -47,7 +46,7 @@ class InitCDS // Creates memory pool that will not be deleted until cds finish its work. // Should be used to allocate structures by cds classes. - static Firebird::MemoryPool* createPool(); + static MemoryPool* createPool(); private: static void* alloc(size_t size) @@ -60,9 +59,9 @@ class InitCDS m_pool->deallocate(p); } - static Firebird::Array* m_pools; - static Firebird::MemoryPool* m_pool; - static Firebird::MemoryStats m_stats; + static Array* m_pools; + static MemoryPool* m_pool; + static MemoryStats m_stats; }; class InitPool @@ -101,10 +100,10 @@ class InitPool } private: - Firebird::MemoryPool* m_pool; - Firebird::MemoryStats& m_stats; + MemoryPool* m_pool; + MemoryStats& m_stats; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // FB_INIT_CDSLIB_H diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 3c4c74c1547..e1d8a045c0e 100644 --- a/src/jrd/IntlManager.cpp +++ b/src/jrd/IntlManager.cpp @@ -45,7 +45,8 @@ #include "../common/os/path_utils.h" #endif -using namespace Firebird; +namespace Firebird::Jrd +{ namespace @@ -68,8 +69,6 @@ namespace }; } -namespace Jrd { - struct ExternalInfo { @@ -421,7 +420,7 @@ bool IntlManager::initialize() ObjectsArray conflicts; string builtinConfig; - PathName intlPath = fb_utils::getPrefix(Firebird::IConfigManager::DIR_INTL, ""); + PathName intlPath = fb_utils::getPrefix(IConfigManager::DIR_INTL, ""); ScanDir dir(intlPath.c_str(), "*.conf"); @@ -884,4 +883,4 @@ bool IntlManager::validateCharSet(const QualifiedMetaString& charSetName, charse } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/IntlManager.h b/src/jrd/IntlManager.h index 3b28562697d..c5fb6ae760d 100644 --- a/src/jrd/IntlManager.h +++ b/src/jrd/IntlManager.h @@ -37,29 +37,29 @@ struct charset; struct texttype; -namespace Jrd { +namespace Firebird::Jrd { class IntlManager { public: static bool initialize(); - static bool charSetInstalled(const Firebird::QualifiedMetaString& charSetName); + static bool charSetInstalled(const QualifiedMetaString& charSetName); - static bool collationInstalled(const Firebird::MetaString& collationName, - const Firebird::QualifiedMetaString& charSetName); + static bool collationInstalled(const MetaString& collationName, + const QualifiedMetaString& charSetName); - static bool lookupCharSet(const Firebird::QualifiedMetaString& charSetName, charset* cs); + static bool lookupCharSet(const QualifiedMetaString& charSetName, charset* cs); - static void lookupCollation(const Firebird::MetaString& collationName, + static void lookupCollation(const MetaString& collationName, const CharsetVariants& charsetVariants, USHORT attributes, const UCHAR* specificAttributes, ULONG specificAttributesLen, bool ignoreAttributes, texttype* tt); static bool setupCollationAttributes( - const Firebird::MetaString& collationName, const Firebird::QualifiedMetaString& charSetName, - const Firebird::string& specificAttributes, Firebird::string& newSpecificAttributes); + const MetaString& collationName, const QualifiedMetaString& charSetName, + const string& specificAttributes, string& newSpecificAttributes); public: struct CharSetDefinition @@ -90,15 +90,15 @@ class IntlManager const static CollationDefinition defaultCollations[]; private: - static Firebird::string getConfigInfo(const ConfigFile::Parameter* par); + static string getConfigInfo(const ConfigFile::Parameter* par); - static bool registerCharSetCollation(const Firebird::QualifiedMetaString& charSetName, - const Firebird::string& collationName, const Firebird::PathName& filename, - const Firebird::string& externalName, const Firebird::string& configInfo); + static bool registerCharSetCollation(const QualifiedMetaString& charSetName, + const string& collationName, const PathName& filename, + const string& externalName, const string& configInfo); - static bool validateCharSet(const Firebird::QualifiedMetaString& charSetName, charset* cs); + static bool validateCharSet(const QualifiedMetaString& charSetName, charset* cs); }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_INTLMANAGER_H diff --git a/src/jrd/KeywordsTable.cpp b/src/jrd/KeywordsTable.cpp index e2b7cb7da7d..58f7e3f5df8 100644 --- a/src/jrd/KeywordsTable.cpp +++ b/src/jrd/KeywordsTable.cpp @@ -25,8 +25,8 @@ #include "../jrd/ids.h" #include "../common/Token.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ RecordBuffer* KeywordsTable::getRecords(thread_db* tdbb, RelationPermanent* relation) @@ -101,3 +101,6 @@ RecordBuffer* KeywordsTableScan::getRecords(thread_db* tdbb, RelationPermanent* return impure->table->getRecords(tdbb, relation); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/KeywordsTable.h b/src/jrd/KeywordsTable.h index 6f771d0aefd..cdf7345c227 100644 --- a/src/jrd/KeywordsTable.h +++ b/src/jrd/KeywordsTable.h @@ -29,8 +29,7 @@ #include "../jrd/recsrc/RecordSource.h" -namespace Jrd -{ +namespace Firebird::Jrd { class KeywordsTable : public SnapshotData { @@ -48,7 +47,7 @@ class KeywordsTable : public SnapshotData class KeywordsTableScan final : public VirtualTableScan { public: - KeywordsTableScan(CompilerScratch* csb, const Firebird::string& alias, + KeywordsTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) { @@ -74,6 +73,6 @@ class KeywordsTableScan final : public VirtualTableScan ULONG impureOffset; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_KEYWORDS_TABLE_H diff --git a/src/jrd/LocalTemporaryTable.h b/src/jrd/LocalTemporaryTable.h index f40ea57e7e2..96097119c5f 100644 --- a/src/jrd/LocalTemporaryTable.h +++ b/src/jrd/LocalTemporaryTable.h @@ -24,7 +24,7 @@ #define JRD_LOCAL_TEMPORARY_TABLE_H #include "firebird.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/MetaName.h" #include "../jrd/QualifiedName.h" #include "../common/dsc.h" @@ -32,8 +32,7 @@ #include "../common/classes/objects_array.h" #include -namespace Jrd -{ +namespace Firebird::Jrd { class jrd_rel; class LocalTemporaryTable @@ -104,7 +103,7 @@ namespace Jrd public: QualifiedName name; - Firebird::ObjectsArray columns; + ObjectsArray columns; bool unique = false; bool descending = false; bool inactive = false; @@ -136,9 +135,9 @@ namespace Jrd public: QualifiedName name; - Firebird::ObjectsArray fields; // Committed state (stable) - Firebird::ObjectsArray pendingFields; // Uncommitted changes (working copy) - Firebird::ObjectsArray indexes; + ObjectsArray fields; // Committed state (stable) + ObjectsArray pendingFields; // Uncommitted changes (working copy) + ObjectsArray indexes; rel_t relationType; jrd_rel* relation = nullptr; USHORT relationId = 0; @@ -146,6 +145,6 @@ namespace Jrd USHORT nextIndexId = 0; bool hasPendingChanges = false; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_LOCAL_TEMPORARY_TABLE_H diff --git a/src/jrd/Mapping.cpp b/src/jrd/Mapping.cpp index 10090d0be9b..e1212e78141 100644 --- a/src/jrd/Mapping.cpp +++ b/src/jrd/Mapping.cpp @@ -32,7 +32,7 @@ #include "../auth/SecureRemotePassword/Message.h" #include "iberror.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/init.h" #include "../common/classes/RefMutex.h" #include "../common/classes/SyncObject.h" @@ -56,8 +56,9 @@ #define MAP_DEBUG(A) -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { @@ -75,7 +76,7 @@ constexpr const char* NM_ROLE = "Role"; constexpr const char* NM_USER = "User"; constexpr const char* TYPE_SEEN = "Seen"; -void check(const char* s, const IStatus* st) +void checkStatus(const char* s, const IStatus* st) { if (!(st->getState() & IStatus::STATE_ERRORS)) return; @@ -87,8 +88,6 @@ void check(const char* s, const IStatus* st) } // anonymous namespace -namespace Jrd { - class AuthWriter : public ClumpletWriter { public: @@ -151,10 +150,6 @@ class AuthWriter : public ClumpletWriter unsigned char sequence; }; - -} // namespace Jrd - - Mapping::DbHandle::DbHandle() noexcept { } @@ -187,7 +182,7 @@ bool Mapping::DbHandle::attach(const char* aliasDb, ICryptKeyCallback* cryptCb) if (cryptCb) { prov->setDbCryptCallback(&st, cryptCb); - check("IProvider::setDbCryptCallback", &st); + checkStatus("IProvider::setDbCryptCallback", &st); } ClumpletWriter embeddedSysdba(ClumpletWriter::dpbList, MAX_DPB_SIZE); @@ -208,7 +203,7 @@ bool Mapping::DbHandle::attach(const char* aliasDb, ICryptKeyCallback* cryptCb) const bool missing = fb_utils::containsErrorCode(s, isc_io_error); down = fb_utils::containsErrorCode(s, isc_shutdown); if (!(missing || down)) - check("IProvider::attachDatabase", &st); + checkStatus("IProvider::attachDatabase", &st); // down/missing DB is not a reason to fail mapping } @@ -334,7 +329,7 @@ bool Mapping::Cache::populate(IAttachment *att) readOnly.insertTag(isc_tpb_read); readOnly.insertTag(isc_tpb_wait); tra = att->startTransaction(&st, readOnly.getBufferLength(), readOnly.getBuffer()); - check("IAttachment::startTransaction", &st); + checkStatus("IAttachment::startTransaction", &st); Message mMap; Field usng(mMap, 1); @@ -360,7 +355,7 @@ bool Mapping::Cache::populate(IAttachment *att) dataFlag = true; return false; } - check("IAttachment::openCursor", &st); + checkStatus("IAttachment::openCursor", &st); } while (curs->fetchNext(&st, mMap.getBuffer()) == IStatus::RESULT_OK) @@ -381,14 +376,14 @@ bool Mapping::Cache::populate(IAttachment *att) MAP_DEBUG(fprintf(stderr, "Add = %s\n", map->makeHashKey().c_str())); add(map); } - check("IResultSet::fetchNext", &st); + checkStatus("IResultSet::fetchNext", &st); curs->close(&st); - check("IResultSet::close", &st); + checkStatus("IResultSet::close", &st); curs = nullptr; tra->rollback(&st); - check("ITransaction::rollback", &st); + checkStatus("ITransaction::rollback", &st); tra = nullptr; dataFlag = true; @@ -616,7 +611,7 @@ void resetMap(const char* securityDb, ULONG index); // ---------------------------------------------------- -class MappingHeader final : public Firebird::MemoryHeader +class MappingHeader final : public MemoryHeader { public: SLONG currentProcess; @@ -637,7 +632,7 @@ class MappingHeader final : public Firebird::MemoryHeader static constexpr ULONG FLAG_DELIVER = 0x2; }; -class MappingIpc final : public Firebird::IpcObject +class MappingIpc final : public IpcObject { static constexpr USHORT MAPPING_VERSION = 1; static constexpr size_t DEFAULT_SIZE = 1024 * 1024; @@ -1277,9 +1272,7 @@ void resetMap(const char* db, ULONG index) } // anonymous namespace -namespace Jrd { - -Mapping::Mapping(const ULONG f, Firebird::ICryptKeyCallback* cryptCb) +Mapping::Mapping(const ULONG f, ICryptKeyCallback* cryptCb) : flags(f), internalFlags(0), cryptCallback(cryptCb), @@ -1335,13 +1328,13 @@ bool Mapping::ensureCachePresence(RefPtr& cache, const char* ali } -void Mapping::needAuthMethod(Firebird::string& method) noexcept +void Mapping::needAuthMethod(string& method) noexcept { fb_assert(!authMethod); authMethod = &method; } -void Mapping::needAuthBlock(Firebird::AuthReader::AuthBlock& block) noexcept +void Mapping::needAuthBlock(AuthReader::AuthBlock& block) noexcept { fb_assert(!newAuthBlock); newAuthBlock = █ @@ -1353,7 +1346,7 @@ void Mapping::needSystemPrivileges(UserId::Privileges& privileges) noexcept systemPrivileges = &privileges; } -void Mapping::setAuthBlock(const Firebird::AuthReader::AuthBlock& block) noexcept +void Mapping::setAuthBlock(const AuthReader::AuthBlock& block) noexcept { fb_assert(!authBlock); authBlock = █ @@ -1389,13 +1382,13 @@ void Mapping::setInternalFlags() } } -void Mapping::setSqlRole(const Firebird::string& role) noexcept +void Mapping::setSqlRole(const string& role) noexcept { fb_assert(!sqlRole); sqlRole = &role; } -void Mapping::setDb(const char* a, const char* d, Firebird::IAttachment* attachment) +void Mapping::setDb(const char* a, const char* d, IAttachment* attachment) { fb_assert(!mainAlias); fb_assert(!mainDb); @@ -1716,7 +1709,7 @@ RecordBuffer* MappingList::getList(thread_db* tdbb, const RelationPermanent* rel if (st->getState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_io_error)) - check("IProvider::attachDatabase", &st); + checkStatus("IProvider::attachDatabase", &st); // In embedded mode we are not raising any errors - silent return if (MasterInterfacePtr()->serverMode(-1) < 0) @@ -1729,7 +1722,7 @@ RecordBuffer* MappingList::getList(thread_db* tdbb, const RelationPermanent* rel readOnly.insertTag(isc_tpb_read); readOnly.insertTag(isc_tpb_wait); tra = att->startTransaction(&st, readOnly.getBufferLength(), readOnly.getBuffer()); - check("IAttachment::startTransaction", &st); + checkStatus("IAttachment::startTransaction", &st); Message mMap; Field name(mMap, MAX_SQL_IDENTIFIER_SIZE); @@ -1750,7 +1743,7 @@ RecordBuffer* MappingList::getList(thread_db* tdbb, const RelationPermanent* rel if (st->getState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err)) - check("IAttachment::openCursor", &st); + checkStatus("IAttachment::openCursor", &st); // isc_dsql_relation_err when opening cursor - i.e. table RDB$AUTH_MAPPING // is missing due to non-FB3 security DB @@ -1817,12 +1810,12 @@ RecordBuffer* MappingList::getList(thread_db* tdbb, const RelationPermanent* rel if (!desc.null) { RefPtr blb(REF_NO_INCR, att->openBlob(&st, tra, &desc, 0, nullptr)); - check("IAttachment::openBlob", &st); + checkStatus("IAttachment::openBlob", &st); string buf; constexpr FB_SIZE_T FLD_LIMIT = MAX_COLUMN_SIZE; unsigned length = 0; blb->getSegment(&st, FLD_LIMIT, buf.getBuffer(FLD_LIMIT), &length); - check("IBlob::getSegment", &st); + checkStatus("IBlob::getSegment", &st); putField(tdbb, record, DumpField(f_sec_map_comment, VALUE_STRING, length, buf.c_str())); @@ -1830,18 +1823,18 @@ RecordBuffer* MappingList::getList(thread_db* tdbb, const RelationPermanent* rel buffer->store(record); } - check("IResultSet::fetchNext", &st); + checkStatus("IResultSet::fetchNext", &st); curs->close(&st); - check("IResultSet::close", &st); + checkStatus("IResultSet::close", &st); curs = nullptr; tra->rollback(&st); - check("ITransaction::rollback", &st); + checkStatus("ITransaction::rollback", &st); tra = nullptr; att->detach(&st); - check("IAttachment::detach", &st); + checkStatus("IAttachment::detach", &st); att = nullptr; } catch (const Exception&) @@ -1865,4 +1858,5 @@ void Mapping::shutdownIpc() mappingIpc->shutdown(); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/Mapping.h b/src/jrd/Mapping.h index 298f3e8e325..ed73f050a8e 100644 --- a/src/jrd/Mapping.h +++ b/src/jrd/Mapping.h @@ -38,7 +38,7 @@ #include "../jrd/Monitoring.h" #include "../jrd/scl.h" -namespace Jrd { +namespace Firebird::Jrd { class AuthWriter; @@ -49,29 +49,29 @@ class Mapping static constexpr ULONG MAP_NO_FLAGS = 0; static constexpr ULONG MAP_THROW_NOT_FOUND = 1; static constexpr ULONG MAP_ERROR_HANDLER = 2; - Mapping(const ULONG flags, Firebird::ICryptKeyCallback* cryptCb); + Mapping(const ULONG flags, ICryptKeyCallback* cryptCb); ~Mapping(); // First provide the main input information - old auth block ... - void setAuthBlock(const Firebird::AuthReader::AuthBlock& authBlock) noexcept; + void setAuthBlock(const AuthReader::AuthBlock& authBlock) noexcept; // ... and finally specify additional information when available. - void setSqlRole(const Firebird::string& sqlRole) noexcept; - void setDb(const char* alias, const char* db, Firebird::IAttachment* att); + void setSqlRole(const string& sqlRole) noexcept; + void setDb(const char* alias, const char* db, IAttachment* att); void setSecurityDbAlias(const char* alias, const char* mainExpandedName); void setErrorMessagesContextName(const char* context) noexcept; // This should be done before mapUser(). - void needAuthMethod(Firebird::string& authMethod) noexcept; - void needAuthBlock(Firebird::AuthReader::AuthBlock& newAuthBlock) noexcept; + void needAuthMethod(string& authMethod) noexcept; + void needAuthBlock(AuthReader::AuthBlock& newAuthBlock) noexcept; void needSystemPrivileges(UserId::Privileges& systemPrivileges) noexcept; // bits returned by mapUser static constexpr ULONG MAP_ERROR_NOT_THROWN = 1; static constexpr ULONG MAP_DOWN = 2; // Now mapper is ready to perform main task and provide mapped login and trusted role. - ULONG mapUser(Firebird::string& name, Firebird::string& trustedRole); + ULONG mapUser(string& name, string& trustedRole); // Do not keep mainHandle opened longer than needed void clearMainHandle(); @@ -87,92 +87,92 @@ class Mapping private: const ULONG flags; ULONG internalFlags; - Firebird::ICryptKeyCallback* cryptCallback; - Firebird::string* authMethod; - Firebird::AuthReader::AuthBlock* newAuthBlock; + ICryptKeyCallback* cryptCallback; + string* authMethod; + AuthReader::AuthBlock* newAuthBlock; UserId::Privileges* systemPrivileges; - const Firebird::AuthReader::AuthBlock* authBlock; + const AuthReader::AuthBlock* authBlock; const char* mainAlias; const char* mainDb; const char* securityAlias; const char* errorMessagesContext; - const Firebird::string* sqlRole; + const string* sqlRole; public: - struct ExtInfo final : public Firebird::AuthReader::Info + struct ExtInfo final : public AuthReader::Info { - Firebird::NoCaseString currentRole, currentUser; + NoCaseString currentRole, currentUser; }; - class DbHandle final : public Firebird::RefPtr + class DbHandle final : public RefPtr { public: DbHandle() noexcept; - void setAttachment(Firebird::IAttachment* att); + void setAttachment(IAttachment* att); void clear(); - bool attach(const char* aliasDb, Firebird::ICryptKeyCallback* cryptCb); + bool attach(const char* aliasDb, ICryptKeyCallback* cryptCb); }; class Map; - typedef Firebird::HashTable, Map> MapHash; + typedef HashTable, Map> MapHash; - class Map final : public MapHash::Entry, public Firebird::GlobalStorage + class Map final : public MapHash::Entry, public GlobalStorage { public: Map(const char* aUsing, const char* aPlugin, const char* aDb, const char* aFromType, const char* aFrom, SSHORT aRole, const char* aTo); - explicit Map(Firebird::AuthReader::Info& info); //type, name, plugin, secDb + explicit Map(AuthReader::Info& info); //type, name, plugin, secDb static FB_SIZE_T hash(const Map& value, FB_SIZE_T hashSize); - Firebird::NoCaseString makeHashKey() const; + NoCaseString makeHashKey() const; void trimAll(); bool isEqual(const Map& k) const override; Map* get() override; - Firebird::NoCaseString plugin, db, fromType, from, to; + NoCaseString plugin, db, fromType, from, to; bool toRole; char usng; }; - class Cache final : public MapHash, public Firebird::GlobalStorage, public Firebird::RefCounted + class Cache final : public MapHash, public GlobalStorage, public RefCounted { public: - Cache(const Firebird::NoCaseString& aliasDb, const Firebird::NoCaseString& db); + Cache(const NoCaseString& aliasDb, const NoCaseString& db); ~Cache(); - bool populate(Firebird::IAttachment *att); + bool populate(IAttachment *att); void map(bool flagWild, ExtInfo& info, AuthWriter& newBlock); void search(ExtInfo& info, const Map& from, AuthWriter& newBlock, - const Firebird::NoCaseString& originalUserName); + const NoCaseString& originalUserName); void varPlugin(ExtInfo& info, Map from, AuthWriter& newBlock); void varDb(ExtInfo& info, Map from, AuthWriter& newBlock); void varFrom(ExtInfo& info, Map from, AuthWriter& newBlock); void varUsing(ExtInfo& info, Map from, AuthWriter& newBlock); - bool map4(bool flagWild, unsigned flagSet, Firebird::AuthReader& rdr, + bool map4(bool flagWild, unsigned flagSet, AuthReader& rdr, ExtInfo& info, AuthWriter& newBlock); static void eraseEntry(Map* m) noexcept; public: - Firebird::Mutex populateMutex; - Firebird::NoCaseString alias, name; + Mutex populateMutex; + NoCaseString alias, name; bool dataFlag; }; private: - Firebird::PathName secExpanded; - Firebird::RefPtr dbCache, secCache; + PathName secExpanded; + RefPtr dbCache, secCache; DbHandle mainHandle; void setInternalFlags(); - bool ensureCachePresence(Firebird::RefPtr& cache, const char* alias, - const char* target, DbHandle& hdb, Firebird::ICryptKeyCallback* cryptCb, Cache* c2); + bool ensureCachePresence(RefPtr& cache, const char* alias, + const char* target, DbHandle& hdb, ICryptKeyCallback* cryptCb, Cache* c2); }; class GlobalMappingScan final : public VirtualTableScan { public: - GlobalMappingScan(CompilerScratch* csb, const Firebird::string& alias, + GlobalMappingScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) {} @@ -194,7 +194,7 @@ class MappingList final : public SnapshotData RecordBuffer* makeBuffer(thread_db* tdbb); }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_MAPPING diff --git a/src/jrd/MetaName.cpp b/src/jrd/MetaName.cpp index d1506b384d6..e7011438e98 100644 --- a/src/jrd/MetaName.cpp +++ b/src/jrd/MetaName.cpp @@ -36,7 +36,7 @@ #include "../common/classes/RefMutex.h" #include "../jrd/jrd.h" -namespace Jrd { +namespace Firebird::Jrd { int MetaName::compare(const char* s, FB_SIZE_T len) const { @@ -107,17 +107,17 @@ FB_SIZE_T MetaName::copyTo(char* to, FB_SIZE_T toSize) const return toSize; } -MetaName::operator Firebird::MetaString() const noexcept +MetaName::operator MetaString() const noexcept { - return Firebird::MetaString(c_str(), length()); + return MetaString(c_str(), length()); } -MetaName::MetaName(const Firebird::MetaString& s) +MetaName::MetaName(const MetaString& s) { assign(s.c_str(), s.length()); } -MetaName& MetaName::operator=(const Firebird::MetaString& s) +MetaName& MetaName::operator=(const MetaString& s) { return assign(s.c_str(), s.length()); } @@ -151,7 +151,7 @@ static constexpr unsigned int hashSize[] = { 10007, 100003, 1000003 }; #endif Dictionary::Dictionary(MemoryPool& p) - : Firebird::PermanentStorage(p), + : PermanentStorage(p), #if DIC_STATS > 0 words(0), totLength(0), lostWords(0), conflicts(0), retriesHash(0), retriesSegment(0), #endif @@ -221,7 +221,7 @@ Dictionary::Word* MetaName::get(const char* s, FB_SIZE_T len) Dictionary::TableData* Dictionary::HashTable::getEntryByHash(const char* s, FB_SIZE_T len) { - unsigned h = Firebird::InternalHash::hash(len, reinterpret_cast(s), hashSize[level]); + unsigned h = InternalHash::hash(len, reinterpret_cast(s), hashSize[level]); return &table[h]; } @@ -282,7 +282,7 @@ Dictionary::Word* Dictionary::get(const char* s, FB_SIZE_T len) newWord = segment->getSpace(len DIC_STAT_SEGMENT_CALL); if (!newWord) { - Firebird::MutexEnsureUnlock guard(mutex, FB_FUNCTION); + MutexEnsureUnlock guard(mutex, FB_FUNCTION); if (guard.tryEnter()) { // retry allocation to avoid a case when someone already changed segment @@ -412,7 +412,7 @@ void Dictionary::growHash() Dictionary::HashTable* Dictionary::waitForMutex(Jrd::Dictionary::Word** checkWordPtr) { - Firebird::MutexLockGuard guard(mutex, FB_FUNCTION); + MutexLockGuard guard(mutex, FB_FUNCTION); #if DIC_STATS > 0 ++conflicts; @@ -491,4 +491,4 @@ Dictionary::Word* Dictionary::Segment::getSpace(FB_SIZE_T len DIC_STAT_SEGMENT_P return nullptr; } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/MetaName.h b/src/jrd/MetaName.h index 1d24c150e0c..3289a6dbbdb 100644 --- a/src/jrd/MetaName.h +++ b/src/jrd/MetaName.h @@ -32,7 +32,7 @@ #include "../common/classes/fb_string.h" #include "../common/classes/fb_pair.h" #include "../common/classes/MetaString.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include @@ -52,9 +52,9 @@ #endif -namespace Jrd { +namespace Firebird::Jrd { -class Dictionary : public Firebird::PermanentStorage +class Dictionary : public PermanentStorage { public: Dictionary(MemoryPool& p); @@ -134,7 +134,7 @@ class Dictionary : public Firebird::PermanentStorage Segment* segment; unsigned segCount; - Firebird::Mutex mutex; // The single mutex to protect dictionary when needed + Mutex mutex; // The single mutex to protect dictionary when needed }; class MetaName @@ -160,7 +160,7 @@ class MetaName : word(get(s)) { } - MetaName(const Firebird::MetaString& s); + MetaName(const MetaString& s); MetaName(const char* s, FB_SIZE_T l) : word(get(s, l)) @@ -168,7 +168,7 @@ class MetaName MetaName(const MetaName& m) = default; - MetaName(const Firebird::AbstractString& s) + MetaName(const AbstractString& s) : word(get(s.c_str(), s.length())) { } @@ -190,7 +190,7 @@ class MetaName test(); } - MetaName(MemoryPool&, const Firebird::AbstractString& s) + MetaName(MemoryPool&, const AbstractString& s) : word(get(s.c_str(), s.length())) { } @@ -213,7 +213,7 @@ class MetaName return *this; } - MetaName& operator=(const Firebird::AbstractString& s) + MetaName& operator=(const AbstractString& s) { word = get(s.c_str(), s.length()); return *this; @@ -221,7 +221,7 @@ class MetaName MetaName& operator=(const MetaName& m) = default; - MetaName& operator=(const Firebird::MetaString& s); + MetaName& operator=(const MetaString& s); FB_SIZE_T length() const noexcept { @@ -271,12 +271,12 @@ class MetaName return compare(s, s ? fb_strlen(s) : 0); } - int compare(const Firebird::AbstractString& s) const + int compare(const AbstractString& s) const { return compare(s.c_str(), s.length()); } - int compare(const Firebird::MetaString& s) const + int compare(const MetaString& s) const { return compare(s.c_str(), s.length()); } @@ -289,7 +289,7 @@ class MetaName return compare(m.begin(), m.length()); } - Firebird::string toQuotedString() const + string toQuotedString() const { return Firebird::toQuotedString(*this); } @@ -304,22 +304,22 @@ class MetaName return compare(s) != 0; } - bool operator==(const Firebird::AbstractString& s) const + bool operator==(const AbstractString& s) const { return compare(s) == 0; } - bool operator!=(const Firebird::AbstractString& s) const + bool operator!=(const AbstractString& s) const { return compare(s) != 0; } - bool operator==(const Firebird::MetaString& s) const + bool operator==(const MetaString& s) const { return compare(s) == 0; } - bool operator!=(const Firebird::MetaString& s) const + bool operator!=(const MetaString& s) const { return compare(s) != 0; } @@ -356,7 +356,7 @@ class MetaName void printf(const char*, ...); FB_SIZE_T copyTo(char* to, FB_SIZE_T toSize) const; - operator Firebird::MetaString() const noexcept; + operator MetaString() const noexcept; protected: static void adjustLength(const char* const s, FB_SIZE_T& l) noexcept; @@ -367,8 +367,8 @@ inline bool operator==(const char* s, const MetaName& m) return m.compare(s) == 0; } -typedef Firebird::Pair > MetaNamePair; +typedef Pair > MetaNamePair; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_METANAME_H diff --git a/src/jrd/Monitoring.cpp b/src/jrd/Monitoring.cpp index df41d643ff9..6699f417ad4 100644 --- a/src/jrd/Monitoring.cpp +++ b/src/jrd/Monitoring.cpp @@ -59,8 +59,8 @@ constexpr const char* SCRATCH = "fb_monitor_"; -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace @@ -1793,3 +1793,6 @@ void Monitoring::cleanupAttachment(thread_db* tdbb) } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/Monitoring.h b/src/jrd/Monitoring.h index f86e779edfb..3a7359c20df 100644 --- a/src/jrd/Monitoring.h +++ b/src/jrd/Monitoring.h @@ -33,7 +33,9 @@ #include "../jrd/TempSpace.h" #include -namespace Jrd { +namespace Firebird::Jrd +{ + // forward declarations class jrd_rel; @@ -141,7 +143,7 @@ class SnapshotData storeField(field_id, VALUE_INTEGER, sizeof(SINT64), &value); } - void storeTimestamp(int field_id, const Firebird::TimeStamp& value) + void storeTimestamp(int field_id, const TimeStamp& value) { if (!value.isEmpty()) storeField(field_id, VALUE_TIMESTAMP, sizeof(ISC_TIMESTAMP), &value.value()); @@ -224,7 +226,7 @@ class SnapshotData offset += (ULONG) delta; } - Firebird::HalfStaticArray buffer; + HalfStaticArray buffer; ULONG offset; Writer* const writer; }; @@ -246,20 +248,20 @@ class SnapshotData void clearSnapshot() noexcept; private: - Firebird::Array m_snapshot; - Firebird::GenericMap > > m_map; + Array m_snapshot; + GenericMap > > m_map; int m_counter; }; -struct MonitoringHeader : public Firebird::MemoryHeader +struct MonitoringHeader : public MemoryHeader { ULONG used; ULONG allocated; }; -class MonitoringData final : public Firebird::PermanentStorage, public Firebird::IpcObject +class MonitoringData final : public PermanentStorage, public IpcObject { static constexpr USHORT MONITOR_VERSION = 6; static constexpr ULONG DEFAULT_SIZE = 1048576; @@ -330,10 +332,10 @@ class MonitoringData final : public Firebird::PermanentStorage, public Firebird: private: TempSpace& source; offset_t offset; - Firebird::UCharBuffer buffer; + UCharBuffer buffer; }; - typedef Firebird::HalfStaticArray SessionList; + typedef HalfStaticArray SessionList; explicit MonitoringData(Database*); ~MonitoringData(); @@ -342,10 +344,10 @@ class MonitoringData final : public Firebird::PermanentStorage, public Firebird: MonitoringData(const MonitoringData&) = delete; MonitoringData& operator =(const MonitoringData&) = delete; - bool initialize(Firebird::SharedMemoryBase*, bool) override; + bool initialize(SharedMemoryBase*, bool) override; void mutexBug(int osErrorCode, const char* text) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_DATABASE_SNAPSHOT; } + USHORT getType() const override { return SharedMemoryBase::SRAM_DATABASE_SNAPSHOT; } USHORT getVersion() const override { return MONITOR_VERSION; } const char* getName() const override { return "MonitoringData"; } @@ -364,16 +366,16 @@ class MonitoringData final : public Firebird::PermanentStorage, public Firebird: private: void ensureSpace(ULONG); - const Firebird::string& m_dbId; - Firebird::AutoPtr > m_sharedMemory; - Firebird::Mutex m_localMutex; + const string& m_dbId; + AutoPtr > m_sharedMemory; + Mutex m_localMutex; }; class MonitoringTableScan final : public VirtualTableScan { public: - MonitoringTableScan(CompilerScratch* csb, const Firebird::string& alias, + MonitoringTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) {} @@ -423,16 +425,17 @@ class Monitoring static void putAttachment(thread_db*, SnapshotData::DumpRecord&, Attachment*); static void putTransaction(thread_db*, SnapshotData::DumpRecord&, const jrd_tra*); - static void putStatement(SnapshotData::DumpRecord&, const Statement*, const Firebird::string&); - static void putRequest(thread_db*, SnapshotData::DumpRecord&, const Request*, const Firebird::string&); + static void putStatement(SnapshotData::DumpRecord&, const Statement*, const string&); + static void putRequest(thread_db*, SnapshotData::DumpRecord&, const Request*, const string&); static void putCall(thread_db*, SnapshotData::DumpRecord&, const Request*); static void putStatistics(thread_db*, SnapshotData::DumpRecord&, const RuntimeStatistics&, int, int); static void putLocalTempTables(thread_db*, SnapshotData::DumpRecord&, const Attachment*, const LocalTemporaryTable*); static void putLocalTempTableFields(thread_db*, SnapshotData::DumpRecord&, const Attachment*, const LocalTemporaryTable*); - static void putContextVars(SnapshotData::DumpRecord&, const Firebird::StringMap&, SINT64, bool); - static void putMemoryUsage(SnapshotData::DumpRecord&, const Firebird::MemoryStats&, int, int); + static void putContextVars(SnapshotData::DumpRecord&, const StringMap&, SINT64, bool); + static void putMemoryUsage(SnapshotData::DumpRecord&, const MemoryStats&, int, int); }; -} // namespace + +} // namespace Firebird::Jrd #endif // JRD_DATABASE_SNAPSHOT_H diff --git a/src/jrd/PageToBufferMap.h b/src/jrd/PageToBufferMap.h index 36fe04ea8c3..0fb7ced12a2 100644 --- a/src/jrd/PageToBufferMap.h +++ b/src/jrd/PageToBufferMap.h @@ -29,7 +29,7 @@ #include "../common/classes/Hash.h" #include "../jrd/cch.h" -namespace Jrd { +namespace Firebird::Jrd { // PageToBufferMap used to cache pointers to the often used page buffers. // Its purpose is to avoid more costly usage of shared hash table. @@ -111,7 +111,7 @@ class PageToBufferMap private: struct Item; - using HashTableType = Firebird::HashTable; + using HashTableType = HashTable; struct Item : public HashTableType::Entry { @@ -221,6 +221,6 @@ class PageToBufferMap Item* m_free = nullptr; // unused items }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_PAGE_TO_BUFFER_MAP diff --git a/src/jrd/PreparedStatement.cpp b/src/jrd/PreparedStatement.cpp index 4c4c078747e..c601a41e146 100644 --- a/src/jrd/PreparedStatement.cpp +++ b/src/jrd/PreparedStatement.cpp @@ -32,8 +32,8 @@ #include "../jrd/mov_proto.h" #include "../jrd/Attachment.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace @@ -173,9 +173,6 @@ namespace } -namespace Jrd { - - // Move data from result set message to user variables. void PreparedStatement::Builder::moveFromResultSet(thread_db* tdbb, ResultSet* rs) const { @@ -383,8 +380,8 @@ PreparedStatement::PreparedStatement(thread_db* tdbb, MemoryPool& pool, builder(NULL), inValues(pool), outValues(pool), - inMetadata(FB_NEW Firebird::MsgMetadata), - outMetadata(FB_NEW Firebird::MsgMetadata), + inMetadata(FB_NEW MsgMetadata), + outMetadata(FB_NEW MsgMetadata), inMessage(pool), outMessage(pool), resultSet(NULL) @@ -400,8 +397,8 @@ PreparedStatement::PreparedStatement(thread_db* tdbb, MemoryPool& pool, builder(&aBuilder), inValues(pool), outValues(pool), - inMetadata(FB_NEW Firebird::MsgMetadata), - outMetadata(FB_NEW Firebird::MsgMetadata), + inMetadata(FB_NEW MsgMetadata), + outMetadata(FB_NEW MsgMetadata), inMessage(pool), outMessage(pool), resultSet(NULL) @@ -422,7 +419,7 @@ PreparedStatement::~PreparedStatement() void PreparedStatement::init(thread_db* tdbb, Attachment* attachment, jrd_tra* transaction, - const Firebird::string& text, bool isInternalRequest) + const string& text, bool isInternalRequest) { auto newSchemaSearchPath = isInternalRequest ? attachment->att_system_schema_search_path : @@ -578,4 +575,4 @@ void PreparedStatement::parseDsqlMessage(const dsql_msg* dsqlMsg, Array& va } -} // namespace +} // namespace Firebird::Jrd diff --git a/src/jrd/PreparedStatement.h b/src/jrd/PreparedStatement.h index 5168662e8ec..b18a8ee56b6 100644 --- a/src/jrd/PreparedStatement.h +++ b/src/jrd/PreparedStatement.h @@ -36,7 +36,7 @@ #include "../common/classes/MetaString.h" #include "../jrd/MetaName.h" -namespace Jrd { +namespace Firebird::Jrd { class thread_db; class jrd_tra; @@ -49,7 +49,7 @@ class ResultSet; template struct PreparedStatementTypeDiscriminator {}; -class PreparedStatement : public Firebird::PermanentStorage +class PreparedStatement : public PermanentStorage { friend class ResultSet; @@ -152,7 +152,7 @@ friend class ResultSet; } public: - const Firebird::string& getText() const + const string& getText() const { return text; } @@ -161,7 +161,7 @@ friend class ResultSet; void moveToStatement(thread_db* tdbb, PreparedStatement* stmt) const; private: - void addInput(Type type, const void* address, bool isOptional, Firebird::Array& slots) + void addInput(Type type, const void* address, bool isOptional, Array& slots) { InputSlot slot; slot.type = type; @@ -171,7 +171,7 @@ friend class ResultSet; slots.add(slot); } - void addOutput(Type type, void* address, bool isOptional, Firebird::Array& slots) + void addOutput(Type type, void* address, bool isOptional, Array& slots) { OutputSlot slot; slot.type = type; @@ -182,9 +182,9 @@ friend class ResultSet; } private: - Firebird::string text; - Firebird::Array inputSlots; - Firebird::Array outputSlots; + string text; + Array inputSlots; + Array outputSlots; unsigned outputParams; }; @@ -193,7 +193,7 @@ friend class ResultSet; class PosBuilder { public: - explicit PosBuilder(const Firebird::string& aText) + explicit PosBuilder(const string& aText) : text(aText), params(0) { @@ -212,27 +212,27 @@ friend class ResultSet; return *this; } - operator const Firebird::string& () + operator const string& () { return text; } private: - Firebird::string text; + string text; unsigned params; }; public: // Create a PreparedStatement builder to use positional parameters with C++ variables. - static PosBuilder build(const Firebird::string& text) + static PosBuilder build(const string& text) { return PosBuilder(text); } // Escape a metadata name accordingly to SQL rules. - static Firebird::string escapeName(const MetaName& s) + static string escapeName(const MetaName& s) { - Firebird::string ret; + string ret; for (const char* p = s.begin(); p != s.end(); ++p) { @@ -245,9 +245,9 @@ friend class ResultSet; } // Escape a string accordingly to SQL rules. - template static Firebird::string escapeString(const T& s) + template static string escapeString(const T& s) { - Firebird::string ret; + string ret; for (const char* p = s.begin(); p != s.end(); ++p) { @@ -260,15 +260,15 @@ friend class ResultSet; } public: - PreparedStatement(thread_db* tdbb, Firebird::MemoryPool& aPool, Attachment* attachment, - jrd_tra* transaction, const Firebird::string& text, bool isInternalRequest); - PreparedStatement(thread_db* tdbb, Firebird::MemoryPool& aPool, Attachment* attachment, + PreparedStatement(thread_db* tdbb, MemoryPool& aPool, Attachment* attachment, + jrd_tra* transaction, const string& text, bool isInternalRequest); + PreparedStatement(thread_db* tdbb, MemoryPool& aPool, Attachment* attachment, jrd_tra* transaction, const Builder& aBuilder, bool isInternalRequest); ~PreparedStatement(); private: void init(thread_db* tdbb, Attachment* attachment, jrd_tra* transaction, - const Firebird::string& text, bool isInternalRequest); + const string& text, bool isInternalRequest); public: void setDesc(thread_db* tdbb, unsigned param, const dsc& value); @@ -318,7 +318,7 @@ friend class ResultSet; setDesc(tdbb, param, desc); } - void setString(thread_db* tdbb, unsigned param, const Firebird::string& value) + void setString(thread_db* tdbb, unsigned param, const string& value) { fb_assert(param > 0); @@ -337,7 +337,7 @@ friend class ResultSet; setDesc(tdbb, param, desc); } - void setMetaString(thread_db* tdbb, unsigned param, const Firebird::MetaString& value) + void setMetaString(thread_db* tdbb, unsigned param, const MetaString& value) { fb_assert(param > 0); @@ -358,19 +358,19 @@ friend class ResultSet; return dsqlRequest; } - static void parseDsqlMessage(const dsql_msg* dsqlMsg, Firebird::Array& values, - Firebird::MsgMetadata* msgMetadata, Firebird::UCharBuffer& msg); + static void parseDsqlMessage(const dsql_msg* dsqlMsg, Array& values, + MsgMetadata* msgMetadata, UCharBuffer& msg); private: const Builder* builder; DsqlRequest* dsqlRequest; - Firebird::Array inValues, outValues; - Firebird::RefPtr inMetadata, outMetadata; - Firebird::UCharBuffer inMessage, outMessage; + Array inValues, outValues; + RefPtr inMetadata, outMetadata; + UCharBuffer inMessage, outMessage; ResultSet* resultSet; }; -typedef Firebird::AutoPtr AutoPreparedStatement; +typedef AutoPtr AutoPreparedStatement; // PreparedStatementTypeDiscriminator specializations. @@ -399,7 +399,7 @@ struct PreparedStatementTypeDiscriminator }; template <> -struct PreparedStatementTypeDiscriminator +struct PreparedStatementTypeDiscriminator { static constexpr PreparedStatement::Builder::Type TYPE = PreparedStatement::Builder::TYPE_STRING; }; @@ -411,7 +411,7 @@ struct PreparedStatementTypeDiscriminator }; template <> -struct PreparedStatementTypeDiscriminator +struct PreparedStatementTypeDiscriminator { static constexpr PreparedStatement::Builder::Type TYPE = PreparedStatement::Builder::TYPE_METASTRING; }; diff --git a/src/jrd/ProfilerManager.cpp b/src/jrd/ProfilerManager.cpp index 9a01cc03fd9..3646b94cff5 100644 --- a/src/jrd/ProfilerManager.cpp +++ b/src/jrd/ProfilerManager.cpp @@ -38,11 +38,8 @@ #include "../jrd/Statement.h" #include -using namespace Jrd; -using namespace Firebird; - - -//-------------------------------------- +namespace Firebird::Jrd +{ namespace @@ -177,7 +174,7 @@ namespace } -class Jrd::ProfilerListener final +class ProfilerListener final { public: explicit ProfilerListener(thread_db* tdbb); @@ -187,7 +184,7 @@ class Jrd::ProfilerListener final ProfilerListener& operator=(const ProfilerListener&) = delete; public: - void exceptionHandler(const Firebird::Exception& ex, ThreadFinishSync::ThreadRoutine* routine); + void exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* routine); private: void watcherThread(); @@ -1005,3 +1002,6 @@ ProfilerPackage::ProfilerPackage(MemoryPool& pool) ) { } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/ProfilerManager.h b/src/jrd/ProfilerManager.h index 173ea283a2d..5c425848502 100644 --- a/src/jrd/ProfilerManager.h +++ b/src/jrd/ProfilerManager.h @@ -36,7 +36,8 @@ #include "../jrd/SystemPackages.h" #include "../jrd/Statement.h" -namespace Jrd { +namespace Firebird::Jrd +{ class Attachment; class Request; @@ -47,13 +48,13 @@ class thread_db; class ProfilerListener; -class ProfilerManager final : public Firebird::PerformanceStopWatch +class ProfilerManager final : public PerformanceStopWatch { friend class ProfilerListener; friend class ProfilerPackage; public: - class Stats final : public Firebird::IProfilerStatsImpl + class Stats final : public IProfilerStatsImpl { public: explicit Stats(FB_UINT64 aElapsedTicks) @@ -97,7 +98,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch { lastTicks = profilerManager->queryTicks(); - if (profilerManager->currentSession->flags & Firebird::IProfilerSession::FLAG_BEFORE_EVENTS) + if (profilerManager->currentSession->flags & IProfilerSession::FLAG_BEFORE_EVENTS) { if (event == Event::OPEN) profilerManager->beforeRecordSourceOpen(request, recordSource); @@ -149,9 +150,9 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void operator=(const Statement&) = delete; SINT64 id = 0; - Firebird::NonPooledMap cursorNextSequence; - Firebird::SortedArray definedCursors; - Firebird::NonPooledMap recSourceSequence; + NonPooledMap cursorNextSequence; + SortedArray definedCursors; + NonPooledMap recSourceSequence; }; class Session final @@ -166,10 +167,10 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch Session(const Session&) = delete; void operator=(const Session&) = delete; - Firebird::AutoPlugin plugin; - Firebird::AutoDispose pluginSession; - Firebird::RightPooledMap statements; - Firebird::SortedArray requests; + AutoPlugin plugin; + AutoDispose pluginSession; + RightPooledMap statements; + SortedArray requests; unsigned flags = 0; }; @@ -189,14 +190,14 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch public: SINT64 startSession(thread_db* tdbb, std::optional flushInterval, - const Firebird::PathName& pluginName, const Firebird::string& description, const Firebird::string& options); + const PathName& pluginName, const string& description, const string& options); void prepareCursor(thread_db* tdbb, Request* request, const Select* select); void onRequestFinish(Request* request, Stats& stats); void beforePsqlLineColumn(Request* request, ULONG line, ULONG column) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_BEFORE_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_BEFORE_EVENTS)) { const auto* profileStatement = getStatement(request); currentSession->pluginSession->beforePsqlLineColumn(profileStatement->id, profileRequestId, line, column); @@ -205,7 +206,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void afterPsqlLineColumn(Request* request, ULONG line, ULONG column, Stats& stats) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_AFTER_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_AFTER_EVENTS)) { const auto* profileStatement = getStatement(request); currentSession->pluginSession->afterPsqlLineColumn(profileStatement->id, profileRequestId, @@ -215,7 +216,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void beforeRecordSourceOpen(Request* request, const AccessPath* recordSource) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_BEFORE_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_BEFORE_EVENTS)) { const auto* profileStatement = getStatement(request); @@ -229,7 +230,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void afterRecordSourceOpen(Request* request, const AccessPath* recordSource, Stats& stats) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_AFTER_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_AFTER_EVENTS)) { const auto* profileStatement = getStatement(request); @@ -243,7 +244,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void beforeRecordSourceGetRecord(Request* request, const AccessPath* recordSource) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_BEFORE_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_BEFORE_EVENTS)) { const auto* profileStatement = getStatement(request); @@ -257,7 +258,7 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch void afterRecordSourceGetRecord(Request* request, const AccessPath* recordSource, Stats& stats) { - if (const auto profileRequestId = getRequest(request, Firebird::IProfilerSession::FLAG_AFTER_EVENTS)) + if (const auto profileRequestId = getRequest(request, IProfilerSession::FLAG_AFTER_EVENTS)) { const auto* profileStatement = getStatement(request); @@ -283,10 +284,10 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch { if (interval < 0) { - Firebird::status_exception::raise( - Firebird::Arg::Gds(isc_not_valid_for_var) << + status_exception::raise( + Arg::Gds(isc_not_valid_for_var) << "\"FLUSH_INTERVAL\"" << - Firebird::Arg::Num(interval)); + Arg::Num(interval)); } } @@ -307,8 +308,6 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch SINT64 getRequest(Request* request, unsigned flags) { - using namespace Firebird; - if (!isActive() || (flags && !(currentSession->flags & flags))) return 0; @@ -341,10 +340,10 @@ class ProfilerManager final : public Firebird::PerformanceStopWatch } private: - Firebird::AutoPtr listener; - Firebird::LeftPooledMap> activePlugins; - Firebird::AutoPtr currentSession; - Firebird::RefPtr flushTimer; + AutoPtr listener; + LeftPooledMap> activePlugins; + AutoPtr currentSession; + RefPtr flushTimer; unsigned currentFlushInterval = 0; bool paused = false; }; @@ -356,79 +355,79 @@ class ProfilerPackage final : public SystemPackage friend class ProfilerManager; public: - ProfilerPackage(Firebird::MemoryPool& pool); + ProfilerPackage(MemoryPool& pool); ProfilerPackage(const ProfilerPackage&) = delete; ProfilerPackage& operator=(const ProfilerPackage&) = delete; public: - FB_MESSAGE(DiscardInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(DiscardInput, ThrowStatusExceptionWrapper, (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* discardProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const DiscardInput::Type* in, void* out); + static IExternalResultSet* discardProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const DiscardInput::Type* in, void* out); //---------- - FB_MESSAGE(FlushInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(FlushInput, ThrowStatusExceptionWrapper, (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* flushProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const FlushInput::Type* in, void* out); + static IExternalResultSet* flushProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const FlushInput::Type* in, void* out); //---------- - FB_MESSAGE(CancelSessionInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(CancelSessionInput, ThrowStatusExceptionWrapper, (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* cancelSessionProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const CancelSessionInput::Type* in, void* out); + static IExternalResultSet* cancelSessionProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const CancelSessionInput::Type* in, void* out); //---------- - FB_MESSAGE(FinishSessionInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(FinishSessionInput, ThrowStatusExceptionWrapper, (FB_BOOLEAN, flush) (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* finishSessionProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const FinishSessionInput::Type* in, void* out); + static IExternalResultSet* finishSessionProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const FinishSessionInput::Type* in, void* out); //---------- - FB_MESSAGE(PauseSessionInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(PauseSessionInput, ThrowStatusExceptionWrapper, (FB_BOOLEAN, flush) (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* pauseSessionProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const PauseSessionInput::Type* in, void* out); + static IExternalResultSet* pauseSessionProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const PauseSessionInput::Type* in, void* out); //---------- - FB_MESSAGE(ResumeSessionInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ResumeSessionInput, ThrowStatusExceptionWrapper, (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* resumeSessionProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const ResumeSessionInput::Type* in, void* out); + static IExternalResultSet* resumeSessionProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const ResumeSessionInput::Type* in, void* out); //---------- - FB_MESSAGE(SetFlushIntervalInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(SetFlushIntervalInput, ThrowStatusExceptionWrapper, (FB_INTEGER, flushInterval) (FB_BIGINT, attachmentId) ); - static Firebird::IExternalResultSet* setFlushIntervalProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const SetFlushIntervalInput::Type* in, void* out); + static IExternalResultSet* setFlushIntervalProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const SetFlushIntervalInput::Type* in, void* out); //---------- - FB_MESSAGE(StartSessionInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(StartSessionInput, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(255 * METADATA_BYTES_PER_CHAR, CS_METADATA), description) (FB_INTEGER, flushInterval) (FB_BIGINT, attachmentId) @@ -436,15 +435,15 @@ class ProfilerPackage final : public SystemPackage (FB_INTL_VARCHAR(255 * METADATA_BYTES_PER_CHAR, CS_METADATA), pluginOptions) ); - FB_MESSAGE(StartSessionOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(StartSessionOutput, ThrowStatusExceptionWrapper, (FB_BIGINT, sessionId) ); - static void startSessionFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const StartSessionInput::Type* in, StartSessionOutput::Type* out); + static void startSessionFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const StartSessionInput::Type* in, StartSessionOutput::Type* out); }; -} // namespace +} // namespace Firebird::Jrd #endif // JRD_PROFILER_MANAGER_H diff --git a/src/jrd/ProtectRelations.h b/src/jrd/ProtectRelations.h index cf47eb3617d..aca6b251ff1 100644 --- a/src/jrd/ProtectRelations.h +++ b/src/jrd/ProtectRelations.h @@ -32,7 +32,7 @@ #if (!defined(FB_JRD_PROTECT_RELATIONS)) #define FB_JRD_PROTECT_RELATIONS -namespace Jrd { +namespace Firebird::Jrd { class thread_db; class jrd_tra; @@ -122,7 +122,7 @@ class ProtectRelations thread_db* m_tdbb; jrd_tra* m_transaction; - Firebird::SortedArray, USHORT, relLock> m_locks; + SortedArray, USHORT, relLock> m_locks; }; /* @@ -216,6 +216,6 @@ class ProtectRelations }; */ -} // namespace Jrd +} // namespace Firebird::Jrd #endif // FB_JRD_PROTECT_RELATIONS diff --git a/src/jrd/QualifiedName.h b/src/jrd/QualifiedName.h index a7e90b7763f..bc1b80ef2e8 100644 --- a/src/jrd/QualifiedName.h +++ b/src/jrd/QualifiedName.h @@ -34,12 +34,12 @@ #include "../common/classes/QualifiedMetaString.h" #include "../common/StatusArg.h" -namespace Jrd { +namespace Firebird::Jrd { -using QualifiedName = Firebird::BaseQualifiedName; -using QualifiedNameMetaNamePair = Firebird::FullPooledPair; -using QualifiedNamePair = Firebird::FullPooledPair; +using QualifiedName = BaseQualifiedName; +using QualifiedNameMetaNamePair = FullPooledPair; +using QualifiedNamePair = FullPooledPair; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_QUALIFIEDNAME_H diff --git a/src/jrd/RandomGenerator.cpp b/src/jrd/RandomGenerator.cpp index 673fcf5c027..6b4f5d61c49 100644 --- a/src/jrd/RandomGenerator.cpp +++ b/src/jrd/RandomGenerator.cpp @@ -24,8 +24,8 @@ #include "../jrd/RandomGenerator.h" #include "../common/os/guid.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ RandomGenerator::RandomGenerator() @@ -53,3 +53,6 @@ void RandomGenerator::getBytes(void* p, FB_SIZE_T size) size -= size2; } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/RandomGenerator.h b/src/jrd/RandomGenerator.h index 37718cbb0d5..08d8bfc0925 100644 --- a/src/jrd/RandomGenerator.h +++ b/src/jrd/RandomGenerator.h @@ -24,7 +24,9 @@ #define JRD_RANDOM_GENERATOR_H -namespace Jrd { +namespace Firebird::Jrd +{ + class RandomGenerator { @@ -40,8 +42,8 @@ class RandomGenerator char buffer[BUFFER_SIZE]; }; -} // namespace +} // namespace Firebird::Jrd #endif // JRD_RANDOM_GENERATOR_H diff --git a/src/jrd/Record.h b/src/jrd/Record.h index 1a00d6b785c..cc3e96840fe 100644 --- a/src/jrd/Record.h +++ b/src/jrd/Record.h @@ -27,8 +27,7 @@ #include "../jrd/pag.h" #include "../jrd/val.h" -namespace Jrd -{ +namespace Firebird::Jrd { class Record { friend class AutoTempRecord; @@ -176,7 +175,7 @@ namespace Jrd private: PageStack m_precedence; // stack of higher precedence pages/transactions - Firebird::Array m_data; // space for record data + Array m_data; // space for record data const Format* m_format; // what the data looks like TraNumber m_transaction_nr; // transaction number for a record bool m_fake_nulls; // all fields simulate being NULLs diff --git a/src/jrd/RecordBuffer.cpp b/src/jrd/RecordBuffer.cpp index 1bf837d570a..6643610e5c6 100644 --- a/src/jrd/RecordBuffer.cpp +++ b/src/jrd/RecordBuffer.cpp @@ -27,9 +27,12 @@ #include "../jrd/RecordBuffer.h" +namespace Firebird::Jrd +{ + + const char* const SCRATCH = "fb_recbuf_"; -using namespace Jrd; RecordBuffer::RecordBuffer(MemoryPool& pool, const Format* format) : PermanentStorage(pool) @@ -74,3 +77,6 @@ const Format* RecordBuffer::getFormat() const { return record->getFormat(); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/RecordBuffer.h b/src/jrd/RecordBuffer.h index 4cd7979faf0..f7ca2da895c 100644 --- a/src/jrd/RecordBuffer.h +++ b/src/jrd/RecordBuffer.h @@ -28,12 +28,12 @@ #include "../common/classes/File.h" #include "../jrd/TempSpace.h" -namespace Jrd { +namespace Firebird::Jrd { class Format; class Record; -class RecordBuffer : public Firebird::PermanentStorage +class RecordBuffer : public PermanentStorage { public: RecordBuffer(MemoryPool&, const Format*); @@ -56,8 +56,8 @@ class RecordBuffer : public Firebird::PermanentStorage private: offset_t count = 0; - Firebird::AutoPtr record; - Firebird::AutoPtr space; + AutoPtr record; + AutoPtr space; }; } // namespace diff --git a/src/jrd/RecordNumber.h b/src/jrd/RecordNumber.h index af4ec70197b..52181435657 100644 --- a/src/jrd/RecordNumber.h +++ b/src/jrd/RecordNumber.h @@ -205,8 +205,7 @@ class RecordNumber bool valid; }; -namespace Jrd -{ +namespace Firebird::Jrd { /* Blob id. A blob has two states -- temporary and permanent. In each case, the blob id is 8 bytes (2 longwords) long. In the case of a temporary blob, the first word is NULL and the second word points to @@ -299,7 +298,7 @@ struct bid static_assert(sizeof(bid) == 8); // make sure that compiler packed structure like we wanted -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_RECORDNUMBER_H diff --git a/src/jrd/RecordSourceNodes.cpp b/src/jrd/RecordSourceNodes.cpp index 764effa6f47..580cd915787 100644 --- a/src/jrd/RecordSourceNodes.cpp +++ b/src/jrd/RecordSourceNodes.cpp @@ -40,8 +40,8 @@ #include "../jrd/optimizer/Optimizer.h" #include "../dsql/DSqlDataTypeUtil.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ static RecordSourceNode* dsqlPassRelProc(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* source); @@ -4146,7 +4146,7 @@ TableValueFunctionSourceNode* TableValueFunctionSourceNode::parseFunction(thread return node; } -Firebird::string TableValueFunctionSourceNode::internalPrint(NodePrinter& printer) const +string TableValueFunctionSourceNode::internalPrint(NodePrinter& printer) const { RecordSourceNode::internalPrint(printer); @@ -4920,3 +4920,6 @@ static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const return node; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/RecordSourceNodes.h b/src/jrd/RecordSourceNodes.h index bb2f0d66236..f42308de4c7 100644 --- a/src/jrd/RecordSourceNodes.h +++ b/src/jrd/RecordSourceNodes.h @@ -32,7 +32,9 @@ #include "../dsql/Visitors.h" #include "../dsql/pass1_proto.h" -namespace Jrd { +namespace Firebird::Jrd +{ + class IndexRetrieval; class OptimizerRetrieval; @@ -46,7 +48,7 @@ class SelectExprNode; class ValueListNode; -class SortNode : public Firebird::PermanentStorage, public Printable +class SortNode : public PermanentStorage, public Printable { public: explicit SortNode(MemoryPool& pool) @@ -59,7 +61,7 @@ class SortNode : public Firebird::PermanentStorage, public Printable } public: - virtual Firebird::string internalPrint(NodePrinter& printer) const + virtual string internalPrint(NodePrinter& printer) const { //// FIXME-PRINT: return "SortNode"; @@ -86,11 +88,11 @@ class SortNode : public Firebird::PermanentStorage, public Printable public: bool unique; // sort uses unique key - for DISTINCT and GROUP BY NestValueArray expressions; // sort expressions - Firebird::Array direction; // rse_order_* - Firebird::Array nullOrder; // rse_nulls_* + Array direction; // rse_order_* + Array nullOrder; // rse_nulls_* }; -class MapNode : public Firebird::PermanentStorage, public Printable +class MapNode : public PermanentStorage, public Printable { public: explicit MapNode(MemoryPool& pool) @@ -105,7 +107,7 @@ class MapNode : public Firebird::PermanentStorage, public Printable MapNode* pass2(thread_db* tdbb, CompilerScratch* csb); public: - virtual Firebird::string internalPrint(NodePrinter& printer) const + virtual string internalPrint(NodePrinter& printer) const { /*** FIXME-PRINT: NODE_PRINT(printer, sourceList); @@ -120,7 +122,7 @@ class MapNode : public Firebird::PermanentStorage, public Printable NestValueArray targetList; }; -class PlanNode : public Firebird::PermanentStorage, public Printable +class PlanNode : public PermanentStorage, public Printable { public: enum Type : UCHAR @@ -166,7 +168,7 @@ class PlanNode : public Firebird::PermanentStorage, public Printable } Type const type; - Firebird::ObjectsArray items; + ObjectsArray items; }; public: @@ -181,7 +183,7 @@ class PlanNode : public Firebird::PermanentStorage, public Printable } public: - virtual Firebird::string internalPrint(NodePrinter& printer) const + virtual string internalPrint(NodePrinter& printer) const { //// FIXME-PRINT: return "PlanNode"; @@ -198,8 +200,8 @@ class PlanNode : public Firebird::PermanentStorage, public Printable Type const type; AccessType* accessType; RecordSourceNode* recordSourceNode; - Firebird::Array > subNodes; - Firebird::ObjectsArray* dsqlNames; + Array > subNodes; + ObjectsArray* dsqlNames; }; class InversionNode @@ -268,11 +270,11 @@ class DbKeyRangeNode NestConst upper; }; -class WithClause : public Firebird::Array +class WithClause : public Array { public: - explicit WithClause(Firebird::MemoryPool& pool) - : Firebird::Array(pool), + explicit WithClause(MemoryPool& pool) + : Array(pool), recursive(false) { } @@ -294,7 +296,7 @@ class LocalTableSourceNode final : public TypedNode procedure; NestConst inputSources; NestConst inputTargets; - NestConst> dsqlInputArgNames; + NestConst> dsqlInputArgNames; private: NestConst inputMessage; @@ -534,7 +536,7 @@ class AggregateSourceNode final : public TypedNode > clauses; // RseNode's for union - Firebird::Array > maps; // RseNode's maps + Array > clauses; // RseNode's for union + Array > maps; // RseNode's maps StreamType mapStream; // stream for next level record of recursive union public: @@ -681,7 +683,7 @@ class WindowSourceNode final : public TypedNode rse; - Firebird::ObjectsArray windows; + ObjectsArray windows; }; class RseNode final : public TypedNode @@ -852,7 +854,7 @@ class RseNode final : public TypedNode rse_aggregate; // singleton aggregate for optimizing to index NestConst rse_plan; // user-specified access plan NestConst rse_invariants; // Invariant nodes bound to top-level RSE - Firebird::Array > rse_relations; + Array > rse_relations; USHORT flags = 0; UCHAR rse_jointype = INNER_JOIN; - Firebird::TriState firstRows; // optimize for first rows + TriState firstRows; // optimize for first rows }; class SelectExprNode final : public TypedNode @@ -933,7 +935,7 @@ class SelectExprNode final : public TypedNode orderClause; NestConst rowsClause; NestConst withClause; - Firebird::string alias; - Firebird::ObjectsArray* columns; + string alias; + ObjectsArray* columns; }; class TableValueFunctionSourceNode @@ -1012,7 +1014,7 @@ class TableValueFunctionSourceNode CompilerScratch* csb, const SSHORT blrOp); - Firebird::string internalPrint(NodePrinter& printer) const override; + string internalPrint(NodePrinter& printer) const override; RecordSourceNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) override; bool dsqlMatch(DsqlCompilerScratch* dsqlScratch, const ExprNode* other, bool ignoreMapCast) const override; @@ -1047,7 +1049,7 @@ class TableValueFunctionSourceNode MetaName alias; NestConst inputList; dsql_fld* dsqlField; - Firebird::ObjectsArray dsqlNameColumns; + ObjectsArray dsqlNameColumns; private: jrd_table_value_fun* m_csbTableValueFun; @@ -1091,6 +1093,7 @@ class GenSeriesFunctionSourceNode final : public TableValueFunctionSourceNode } }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_RECORD_SOURCE_NODES_H diff --git a/src/jrd/Relation.cpp b/src/jrd/Relation.cpp index fea7b75dc8e..3d9e94e11dc 100644 --- a/src/jrd/Relation.cpp +++ b/src/jrd/Relation.cpp @@ -40,8 +40,8 @@ // Pick up relation ids #include "../jrd/ini.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ TrigArray::TrigArray(MemoryPool& p) @@ -340,7 +340,7 @@ RelationPages* RelationPermanent::getPagesInternal(thread_db* tdbb, TraNumber tr if (poolCreated) pool = dbb->createPool(false); - Jrd::ContextPoolHolder context(tdbb, pool); + JrdContextPoolHolder context(tdbb, pool); jrd_tra* idxTran = tdbb->getTransaction(); if (!idxTran) @@ -1115,7 +1115,7 @@ void Trigger::free(thread_db* tdbb) // class DbTriggers DbTriggersHeader::DbTriggersHeader(thread_db* tdbb, MemoryPool& p, MetaId& t, NoData) - : Firebird::PermanentStorage(p), + : PermanentStorage(p), type(t) { } @@ -1157,3 +1157,5 @@ GCLock::State GCLock::isGCEnabled() const } #endif //DEV_BUILD + +} // namespace Firebird::Jrd diff --git a/src/jrd/Relation.h b/src/jrd/Relation.h index 0acf552c0e3..741c2b2d25f 100644 --- a/src/jrd/Relation.h +++ b/src/jrd/Relation.h @@ -36,8 +36,7 @@ #include "../common/classes/TriState.h" #include "../common/sha2/sha2.h" -namespace Jrd -{ +namespace Firebird::Jrd { template class vec; class BoolExprNode; @@ -110,8 +109,8 @@ inline constexpr int TRIGGER_COMBINED_MAX = 128; class Trigger { public: - Firebird::HalfStaticArray blr; // BLR code - Firebird::HalfStaticArray debugInfo; // Debug info + HalfStaticArray blr; // BLR code + HalfStaticArray debugInfo; // Debug info Statement* statement = nullptr; // Compiled statement bool releaseInProgress = false; fb_sysflag sysTrigger = fb_sysflag_user; // See fb_sysflag in constants.h @@ -121,9 +120,9 @@ class Trigger QualifiedName name; // Trigger name MetaName engine; // External engine name MetaName owner; // Owner for SQL SECURITY - Firebird::string entryPoint; // External trigger entrypoint - Firebird::string extBody; // External trigger body - Firebird::TriState ssDefiner; // SQL SECURITY + string entryPoint; // External trigger entrypoint + string extBody; // External trigger body + TriState ssDefiner; // SQL SECURITY std::unique_ptr extTrigger; // External trigger MemoryPool& getPool(); @@ -189,10 +188,10 @@ class Triggers static void destroy(thread_db* tdbb, Triggers* trigs); private: - Firebird::HalfStaticArray triggers; + HalfStaticArray triggers; }; -class DbTriggersHeader : public Firebird::PermanentStorage +class DbTriggersHeader : public PermanentStorage { public: DbTriggersHeader(thread_db*, MemoryPool& p, MetaId& t, NoData = NoData()); @@ -240,7 +239,7 @@ class DbTriggers final : public Triggers, public ObjectBase return scan(tdbb, flags); } - bool hash(thread_db*, Firebird::sha512&) + bool hash(thread_db*, sha512&) { return true; } @@ -294,13 +293,13 @@ class ViewContext return vc->vcx_context; } - const Firebird::string vcx_context_name; + const string vcx_context_name; const QualifiedName vcx_relation_name; const USHORT vcx_context; const ViewContextType vcx_type; }; -typedef Firebird::SortedArray, +typedef SortedArray, USHORT, ViewContext> ViewContexts; @@ -325,7 +324,7 @@ class RelationPages ULONG rel_last_free_blb_dp; // last blob data page found with space USHORT rel_pg_space_id; - RelationPages(Firebird::MemoryPool& pool) + RelationPages(MemoryPool& pool) : rel_pages(NULL), rel_instance_id(0), rel_index_root(0), rel_data_pages(0), rel_slot_space(0), rel_pri_data_space(0), rel_sec_data_space(0), @@ -349,7 +348,7 @@ class RelationPages ULONG getDPNumber(ULONG dpSequence) { - Firebird::MutexLockGuard g(dpMutex, FB_FUNCTION); + MutexLockGuard g(dpMutex, FB_FUNCTION); FB_SIZE_T pos; if (dpMap.find(dpSequence, pos)) @@ -364,7 +363,7 @@ class RelationPages void setDPNumber(ULONG dpSequence, ULONG dpNumber) { - Firebird::MutexLockGuard g(dpMutex, FB_FUNCTION); + MutexLockGuard g(dpMutex, FB_FUNCTION); FB_SIZE_T pos; if (dpMap.find(dpSequence, pos)) @@ -388,7 +387,7 @@ class RelationPages void freeOldestMapItems() noexcept { - Firebird::MutexLockGuard g(dpMutex, FB_FUNCTION); + MutexLockGuard g(dpMutex, FB_FUNCTION); ULONG minMark = MAX_ULONG; FB_SIZE_T i; @@ -431,9 +430,9 @@ class RelationPages } }; - Firebird::SortedArray, ULONG, DPItem> dpMap; + SortedArray, ULONG, DPItem> dpMap; ULONG dpMapMark; - Firebird::Mutex dpMutex; + Mutex dpMutex; friend class RelationPermanent; }; @@ -453,7 +452,7 @@ enum IndexStatus // Index block -class IndexPermanent : public Firebird::PermanentStorage +class IndexPermanent : public PermanentStorage { public: IndexPermanent(thread_db* tdbb, MemoryPool& p, MetaId id, RelationPermanent* rel) @@ -541,7 +540,7 @@ class IndexVersion final : public ObjectBase return idv_active; } - bool hash(thread_db*, Firebird::sha512& digest) + bool hash(thread_db*, sha512& digest) { digest.process(sizeof(QualifiedName), &idv_foreignKey); digest.process(sizeof(idv_active), &idv_active); @@ -599,8 +598,8 @@ class jrd_rel final : public ObjectBase TrigArray rel_triggers; - Firebird::TriState rel_ss_definer; - Firebird::TriState rel_repl_state; // replication state + TriState rel_ss_definer; + TriState rel_repl_state; // replication state bool hasData() const; MetaId getId() const noexcept; @@ -635,7 +634,7 @@ class jrd_rel final : public ObjectBase return scan(tdbb, flags); } - bool hash(thread_db* tdbb, Firebird::sha512& digest); + bool hash(thread_db* tdbb, sha512& digest); static const char* objectFamily(RelationPermanent* perm); static int objectType(); @@ -744,7 +743,7 @@ class GCLock { reinterpret_cast(self)->blockingAst(); } - catch(const Firebird::Exception&) { } + catch(const Exception&) { } return 0; } @@ -758,7 +757,7 @@ class GCLock void checkGuard(unsigned flags); private: - Firebird::AutoPtr gcLck; + AutoPtr gcLck; RelationPermanent* gcRel; std::atomic gcFlags = 0u; @@ -772,10 +771,10 @@ class GCLock // Non-versioned part of relation in cache -class RelationPermanent : public Firebird::PermanentStorage +class RelationPermanent : public PermanentStorage { typedef CacheVector Indices; - typedef Firebird::HalfStaticArray GCRecordList; + typedef HalfStaticArray GCRecordList; public: RelationPermanent(thread_db* tdbb, MemoryPool& p, MetaId id, NoData); @@ -816,15 +815,15 @@ class RelationPermanent : public Firebird::PermanentStorage private: GCRecordList rel_gc_records; // records for garbage collection - Firebird::Mutex rel_gc_records_mutex; + Mutex rel_gc_records_mutex; public: std::atomic rel_scan_count; // concurrent sequential scan count - class RelPagesSnapshot : public Firebird::Array + class RelPagesSnapshot : public Array { public: - typedef Firebird::Array inherited; + typedef Array inherited; RelPagesSnapshot(thread_db* tdbb, RelationPermanent* relation) { @@ -918,7 +917,7 @@ class RelationPermanent : public Firebird::PermanentStorage private: SharedReadVector rel_formats; // Known record formats - Firebird::Mutex rel_formats_grow; // Mutex to grow rel_formats + Mutex rel_formats_grow; // Mutex to grow rel_formats public: HazardPtr getFormats() @@ -936,17 +935,17 @@ class RelationPermanent : public Firebird::PermanentStorage QualifiedName rel_security_name; // security class name for relation std::atomic rel_flags; // flags - Firebird::TriState rel_repl_state; // replication state + TriState rel_repl_state; // replication state PrimaryDeps* rel_primary_dpnds = nullptr; // foreign dependencies on this relation's primary key ForeignRefs* rel_foreign_refs = nullptr; // foreign references to other relations' primary keys private: - Firebird::Mutex rel_pages_mutex; + Mutex rel_pages_mutex; - typedef Firebird::SortedArray< + typedef SortedArray< RelationPages*, - Firebird::EmptyStorage, + EmptyStorage, RelationPages::InstanceId, RelationPages> RelationPagesInstances; @@ -959,7 +958,7 @@ class RelationPermanent : public Firebird::PermanentStorage ExternalFile* rel_file; - Firebird::Array rel_clear_deps; + Array rel_clear_deps; }; diff --git a/src/jrd/Resources.cpp b/src/jrd/Resources.cpp index 99962ee616d..44387847e73 100644 --- a/src/jrd/Resources.cpp +++ b/src/jrd/Resources.cpp @@ -16,8 +16,8 @@ #include "../jrd/Function.h" #include "../jrd/met.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ void Resources::transfer(thread_db* tdbb, VersionedObjects* to, bool internal) @@ -67,11 +67,14 @@ jrd_rel* CachedResource::operator()(thread_db* tdbb) return cacheElement->getVersioned(tdbb, cacheElement->isSystem() ? CacheFlag::NOSCAN : 0); } -void Format::hash(Firebird::sha512& digest) const +void Format::hash(sha512& digest) const { - // Here is supposed that in fmt_desc (i.e. Firebird::Array) all elements are located + // Here is supposed that in fmt_desc (i.e. Array) all elements are located // one after another starting with begin() position. // If that became wrong this function to be modified. digest.process(fmt_desc.getCount() * sizeof(dsc), fmt_desc.begin()); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/Resources.h b/src/jrd/Resources.h index cb7f2f9276d..de82a5ba484 100644 --- a/src/jrd/Resources.h +++ b/src/jrd/Resources.h @@ -29,7 +29,7 @@ #include "../common/sha2/sha2.h" #include -namespace Jrd { +namespace Firebird::Jrd { class RelationPermanent; class RoutinePermanent; @@ -69,7 +69,7 @@ union VersionedPartPtr }; class VersionedObjects : public pool_alloc_rpt, - public Firebird::RefCounted + public RefCounted { public: @@ -199,13 +199,13 @@ class Resources final { public: template - class RscArray : public Firebird::Array> + class RscArray : public Array> { public: typedef CacheElement StoredElement; RscArray(MemoryPool& p, FB_SIZE_T& pos) - : Firebird::Array>(p), + : Array>(p), versionCurrentPosition(pos) { } @@ -227,7 +227,7 @@ class Resources final return this->getElement(pos); } - int transfer(thread_db* tdbb, VersionedObjects* to, bool internal, Firebird::sha512& digest) + int transfer(thread_db* tdbb, VersionedObjects* to, bool internal, sha512& digest) { for (auto& resource : *this) { @@ -315,7 +315,7 @@ namespace Rsc }; //namespace Rsc -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_RESOURCES_H diff --git a/src/jrd/ResultSet.cpp b/src/jrd/ResultSet.cpp index 59d0f038613..7227968a179 100644 --- a/src/jrd/ResultSet.cpp +++ b/src/jrd/ResultSet.cpp @@ -30,9 +30,8 @@ #include "../dsql/dsql_proto.h" #include "../jrd/mov_proto.h" -using namespace Firebird; - -namespace Jrd { +namespace Firebird::Jrd +{ ResultSet::ResultSet(thread_db* tdbb, PreparedStatement* aStmt, jrd_tra* aTransaction) @@ -99,7 +98,7 @@ dsc& ResultSet::getDesc(unsigned param) } -Firebird::string ResultSet::getString(thread_db* tdbb, unsigned param) +string ResultSet::getString(thread_db* tdbb, unsigned param) { fb_assert(param > 0); @@ -121,7 +120,7 @@ MetaName ResultSet::getMetaName(thread_db* tdbb, unsigned param) } -Firebird::MetaString ResultSet::getMetaString(thread_db* tdbb, unsigned param) +MetaString ResultSet::getMetaString(thread_db* tdbb, unsigned param) { return getString(tdbb, param); } @@ -143,4 +142,4 @@ void ResultSet::moveDesc(thread_db* tdbb, unsigned param, dsc& desc) } -} // namespace +} // namespace Firebird::Jrd diff --git a/src/jrd/ResultSet.h b/src/jrd/ResultSet.h index 15de4f4e9e8..12a18bdfa8e 100644 --- a/src/jrd/ResultSet.h +++ b/src/jrd/ResultSet.h @@ -33,7 +33,7 @@ struct dsc; -namespace Jrd { +namespace Firebird::Jrd { class thread_db; class jrd_tra; @@ -106,9 +106,9 @@ friend class PreparedStatement; return value; } - Firebird::string getString(thread_db* tdbb, unsigned param); + string getString(thread_db* tdbb, unsigned param); MetaName getMetaName(thread_db* tdbb, unsigned param); - Firebird::MetaString getMetaString(thread_db* tdbb, unsigned param); + MetaString getMetaString(thread_db* tdbb, unsigned param); private: void moveDesc(thread_db* tdbb, unsigned param, dsc& desc); @@ -119,7 +119,7 @@ friend class PreparedStatement; bool firstFetchDone; }; -typedef Firebird::AutoPtr AutoResultSet; +typedef AutoPtr AutoResultSet; } // namespace diff --git a/src/jrd/Routine.cpp b/src/jrd/Routine.cpp index e32096996e9..d5d100b4a52 100644 --- a/src/jrd/Routine.cpp +++ b/src/jrd/Routine.cpp @@ -30,10 +30,9 @@ #include "../jrd/par_proto.h" #include "../jrd/met.h" -using namespace Firebird; - +namespace Firebird::Jrd +{ -namespace Jrd { RoutinePermanent::RoutinePermanent(thread_db* tdbb, MemoryPool& p, MetaId metaId, NoData) : PermanentStorage(p), @@ -233,7 +232,7 @@ void Routine::parseMessages(thread_db* tdbb, CompilerScratch* csb, BlrReader blr } } -bool Routine::hash(thread_db* tdbb, Firebird::sha512& digest) +bool Routine::hash(thread_db* tdbb, sha512& digest) { if (inputFields.hasData()) { @@ -276,4 +275,4 @@ void Routine::destroy(thread_db* tdbb, Routine* routine) delete routine; } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/Routine.h b/src/jrd/Routine.h index 6d79cebe373..01ff4589e26 100644 --- a/src/jrd/Routine.h +++ b/src/jrd/Routine.h @@ -34,8 +34,7 @@ #include "../common/ThreadStart.h" #include "../common/sha2/sha2.h" -namespace Jrd -{ +namespace Firebird::Jrd { class thread_db; class CompilerScratch; class Statement; @@ -44,7 +43,7 @@ namespace Jrd class Parameter; class UserId; - class RoutinePermanent : public Firebird::PermanentStorage + class RoutinePermanent : public PermanentStorage { public: explicit RoutinePermanent(thread_db* tdbb, MemoryPool& p, MetaId metaId, NoData); @@ -108,9 +107,9 @@ namespace Jrd } public: - static Firebird::MsgMetadata* createMetadata( - const Firebird::Array >& parameters, bool isExtern); - static Format* createFormat(MemoryPool& pool, Firebird::IMessageMetadata* params, bool addEof); + static MsgMetadata* createMetadata( + const Array >& parameters, bool isExtern); + static Format* createFormat(MemoryPool& pool, IMessageMetadata* params, bool addEof); public: static void destroy(thread_db* tdbb, Routine* routine); @@ -138,22 +137,22 @@ namespace Jrd const Format* getOutputFormat() const noexcept { return outputFormat; } void setOutputFormat(const Format* value) noexcept { outputFormat = value; } - bool hash(thread_db* tdbb, Firebird::sha512& digest); + bool hash(thread_db* tdbb, sha512& digest); - const Firebird::Array >& getInputFields() const noexcept + const Array >& getInputFields() const noexcept { return inputFields; } - Firebird::Array >& getInputFields() noexcept { return inputFields; } + Array >& getInputFields() noexcept { return inputFields; } - const Firebird::Array >& getOutputFields() const noexcept + const Array >& getOutputFields() const noexcept { return outputFields; } - Firebird::Array >& getOutputFields() noexcept { return outputFields; } + Array >& getOutputFields() noexcept { return outputFields; } void parseBlr(thread_db* tdbb, CompilerScratch* csb, const bid* blob_id, bid* blobDbg); - void parseMessages(thread_db* tdbb, CompilerScratch* csb, Firebird::BlrReader blrReader); + void parseMessages(thread_db* tdbb, CompilerScratch* csb, BlrReader blrReader); virtual void releaseFormat() { @@ -181,8 +180,8 @@ namespace Jrd USHORT defaultCount; // default input arguments const Format* inputFormat; // input format const Format* outputFormat; // output format - Firebird::Array > inputFields; // array of field blocks - Firebird::Array > outputFields; // array of field blocks + Array > inputFields; // array of field blocks + Array > outputFields; // array of field blocks public: bool flReload; diff --git a/src/jrd/RuntimeStatistics.cpp b/src/jrd/RuntimeStatistics.cpp index 41f0a7996fa..5c47e7bbf96 100644 --- a/src/jrd/RuntimeStatistics.cpp +++ b/src/jrd/RuntimeStatistics.cpp @@ -28,9 +28,9 @@ #include "../jrd/ntrace.h" #include "../jrd/met.h" -using namespace Firebird; +namespace Firebird::Jrd +{ -namespace Jrd { GlobalPtr RuntimeStatistics::dummy; @@ -143,4 +143,5 @@ RuntimeStatistics::Accumulator::~Accumulator() m_tdbb->bumpStats(m_type, m_id, m_counter); } -} // namespace + +} // namespace Firebird::Jrd diff --git a/src/jrd/RuntimeStatistics.h b/src/jrd/RuntimeStatistics.h index 3db58932ab0..1cdf581f1e0 100644 --- a/src/jrd/RuntimeStatistics.h +++ b/src/jrd/RuntimeStatistics.h @@ -34,7 +34,7 @@ #include -namespace Jrd { +namespace Firebird::Jrd { class Attachment; class Database; @@ -73,7 +73,7 @@ enum class RecordStatType TOTAL_ITEMS }; -class RuntimeStatistics : protected Firebird::AutoStorage +class RuntimeStatistics : protected AutoStorage { static constexpr size_t PAGE_TOTAL_ITEMS = static_cast(PageStatType::TOTAL_ITEMS); static constexpr size_t RECORD_TOTAL_ITEMS = static_cast(RecordStatType::TOTAL_ITEMS); @@ -213,8 +213,8 @@ class RuntimeStatistics : protected Firebird::AutoStorage class GroupedCountsArray { typedef typename Counts::ID ID; - typedef Firebird::SortedArray< - Counts, Firebird::EmptyStorage, ID, Counts> SortedCountsArray; + typedef SortedArray< + Counts, EmptyStorage, ID, Counts> SortedCountsArray; typedef typename SortedCountsArray::const_iterator ConstIterator; public: @@ -289,7 +289,7 @@ class RuntimeStatistics : protected Firebird::AutoStorage typedef GroupedCountsArray > TableCounters; RuntimeStatistics() - : Firebird::AutoStorage(), + : AutoStorage(), pageCounters(getPool(), DB_PAGE_SPACE + 1), tableCounters(getPool(), rel_MAX) { @@ -297,7 +297,7 @@ class RuntimeStatistics : protected Firebird::AutoStorage } explicit RuntimeStatistics(MemoryPool& pool) - : Firebird::AutoStorage(pool), + : AutoStorage(pool), pageCounters(getPool(), DB_PAGE_SPACE + 1), tableCounters(getPool(), rel_MAX) { @@ -305,7 +305,7 @@ class RuntimeStatistics : protected Firebird::AutoStorage } RuntimeStatistics(const RuntimeStatistics& other) - : Firebird::AutoStorage(), + : AutoStorage(), pageCounters(getPool(), other.pageCounters), tableCounters(getPool(), other.tableCounters) { @@ -320,7 +320,7 @@ class RuntimeStatistics : protected Firebird::AutoStorage } RuntimeStatistics(MemoryPool& pool, const RuntimeStatistics& other) - : Firebird::AutoStorage(pool), + : AutoStorage(pool), pageCounters(getPool(), other.pageCounters), tableCounters(getPool(), other.tableCounters) { @@ -485,7 +485,7 @@ class RuntimeStatistics : protected Firebird::AutoStorage // This dummy RuntimeStatistics is used instead of missing elements in tdbb, // helping us to avoid conditional checks in time-critical places of code. // Values of it contain actually garbage - don't be surprised when debugging. - static Firebird::GlobalPtr dummy; + static GlobalPtr dummy; }; } // namespace diff --git a/src/jrd/Savepoint.cpp b/src/jrd/Savepoint.cpp index 241e30742c0..7aac07ce4ba 100644 --- a/src/jrd/Savepoint.cpp +++ b/src/jrd/Savepoint.cpp @@ -31,8 +31,8 @@ #include "Savepoint.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ // UndoItem implementation @@ -849,3 +849,6 @@ void StableCursorSavePoint::release() m_number = 0; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/Savepoint.h b/src/jrd/Savepoint.h index e5010921264..a0f8750f30e 100644 --- a/src/jrd/Savepoint.h +++ b/src/jrd/Savepoint.h @@ -26,7 +26,7 @@ #include "../jrd/Record.h" #include "../jrd/RecordNumber.h" -namespace Jrd +namespace Firebird::Jrd { class jrd_tra; class LocalTemporaryTable; @@ -75,7 +75,7 @@ namespace Jrd const Format* m_format; }; - typedef Firebird::BePlusTree UndoItemTree; + typedef BePlusTree UndoItemTree; class VerbAction { @@ -125,7 +125,7 @@ namespace Jrd UndoType type; QualifiedName name; - Firebird::AutoPtr original; // Original LTT state (for ALTER/DROP), nullptr for CREATE + AutoPtr original; // Original LTT state (for ALTER/DROP), nullptr for CREATE LttUndoItem* next; }; @@ -399,7 +399,6 @@ namespace Jrd jrd_tra* const m_transaction; SavNumber m_number; }; - -} // namespace +} // namespace Firebird::Jrd #endif // JRD_SAVEPOINT_H diff --git a/src/jrd/SharedReadVector.h b/src/jrd/SharedReadVector.h index 1c1e335c633..27d12a50abd 100644 --- a/src/jrd/SharedReadVector.h +++ b/src/jrd/SharedReadVector.h @@ -48,7 +48,7 @@ #include "../jrd/Database.h" */ -namespace Jrd { +namespace Firebird::Jrd { template class SharedReadVector @@ -231,6 +231,6 @@ class SharedReadVector std::atomic currentData; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SHAREDREADVECTOR_H diff --git a/src/jrd/Statement.cpp b/src/jrd/Statement.cpp index bf5418ee4b0..9da357fcc39 100644 --- a/src/jrd/Statement.cpp +++ b/src/jrd/Statement.cpp @@ -40,8 +40,8 @@ #include "../jrd/recsrc/Cursor.h" #include "../common/classes/auto.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ template static void makeSubRoutines(thread_db* tdbb, Statement* statement, @@ -278,7 +278,7 @@ Statement* Statement::makeStatement(thread_db* tdbb, CompilerScratch* csb, bool #if defined(DEV_BUILD) && defined(DEBUG_LOST_POOLS) MemoryPool* defPool = tdbb->getDefaultPool(); { // scope - Firebird::SyncLockGuard guard(&dbb->dbb_pools_sync, Firebird::SYNC_SHARED, "Statement::makeStatement"); + SyncLockGuard guard(&dbb->dbb_pools_sync, SYNC_SHARED, "Statement::makeStatement"); for (FB_SIZE_T i = 1; i < dbb->dbb_pools.getCount(); ++i) { if (dbb->dbb_pools[i] == defPool) @@ -1049,7 +1049,7 @@ StmtNumber Request::getRequestId() const return req_id; } -Request::Request(Firebird::AutoMemoryPool& pool, Database* dbb, /*const*/ Statement* aStatement) +Request::Request(AutoMemoryPool& pool, Database* dbb, /*const*/ Statement* aStatement) : statement(aStatement), req_inUse(false), req_pool(pool), @@ -1118,7 +1118,7 @@ const int devNodePrint(DmlNode* node) #endif #ifdef DEBUG_SHARED_VECTOR -namespace Jrd { +namespace Firebird::Jrd { struct Acc { @@ -1136,7 +1136,7 @@ GlobalPtr mtx; class Member : public Array { public: - Member(Firebird::MemoryPool& p) + Member(MemoryPool& p) : Array(p) { } @@ -1167,3 +1167,6 @@ void srvDis(void* mem) } #endif // DEBUG_SHARED_VECTOR + + +} // namespace Firebird::Jrd diff --git a/src/jrd/Statement.h b/src/jrd/Statement.h index 01e6faf5cd1..959f7470606 100644 --- a/src/jrd/Statement.h +++ b/src/jrd/Statement.h @@ -30,7 +30,7 @@ #include #include "../common/sha2/sha2.h" -namespace Jrd { +namespace Firebird::Jrd { class PlanEntry; @@ -105,7 +105,7 @@ class Statement : public pool_alloc Request* verifyRequestSynchronization(USHORT level); void release(thread_db* tdbb); - Firebird::string getPlan(thread_db* tdbb, bool detailed) const; + string getPlan(thread_db* tdbb, bool detailed) const; void getPlan(thread_db* tdbb, PlanEntry& planEntry) const; const Resources* getResources() @@ -133,7 +133,7 @@ class Statement : public pool_alloc private: Requests requests; // vector of requests - Firebird::Mutex requestsGrow; // requests' vector protection when adding new element + Mutex requestsGrow; // requests' vector protection when adding new element public: ExternalAccessList externalList; // Access to procedures/triggers to be checked @@ -143,23 +143,23 @@ class Statement : public pool_alloc QualifiedName triggerName; // name of request (trigger), if any Jrd::UserId* triggerInvoker; // user name if trigger run with SQL SECURITY DEFINER Statement* parentStatement; // Sub routine's parent statement - Firebird::Array subStatements; // Array of subroutines' statements + Array subStatements; // Array of subroutines' statements const StmtNode* topNode; // top of execution tree - Firebird::Array fors; // select expressions - Firebird::Array localTables; // local tables - Firebird::Array invariants; // pointer to nodes invariant offsets - Firebird::RefStrPtr sqlText; // SQL text (encoded in the metadata charset) - Firebird::Array blr; // BLR for non-SQL query + Array fors; // select expressions + Array localTables; // local tables + Array invariants; // pointer to nodes invariant offsets + RefStrPtr sqlText; // SQL text (encoded in the metadata charset) + Array blr; // BLR for non-SQL query MapFieldInfo mapFieldInfo; // Map field name to field info private: Resources* resources; // Resources (relations, routines, etc.) - Firebird::RefPtr latestVer; - Firebird::Mutex lvMutex; // Protects upgrade of latestVer - Firebird::Array messages; // Input/output messages + RefPtr latestVer; + Mutex lvMutex; // Protects upgrade of latestVer + Array messages; // Input/output messages }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_STATEMENT_H diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index d34fd07fd99..7dda596c4e0 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -79,8 +79,9 @@ #include #include -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { @@ -334,7 +335,7 @@ dsc* evlHash(thread_db* tdbb, const SysFunction* function, const NestValueArray& dsc* evlLeft(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); dsc* evlLnLog10(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); dsc* evlLog(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); -dsc* evlMakeDbkey(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, Jrd::impure_value* impure); +dsc* evlMakeDbkey(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); dsc* evlMod(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); dsc* evlOverlay(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure); @@ -4572,7 +4573,7 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar { fb_assert(args.getCount() == 2); - Jrd::Attachment* attachment = tdbb->getAttachment(); + Attachment* attachment = tdbb->getAttachment(); Database* dbb = tdbb->getDatabase(); jrd_tra* transaction = tdbb->getTransaction(); Request* request = tdbb->getRequest(); @@ -4911,7 +4912,7 @@ dsc* evlSetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar { fb_assert(args.getCount() == 3); - Jrd::Attachment* attachment = tdbb->getAttachment(); + Attachment* attachment = tdbb->getAttachment(); jrd_tra* transaction = tdbb->getTransaction(); Request* request = tdbb->getRequest(); @@ -5392,7 +5393,7 @@ dsc* evlNormDec(thread_db* tdbb, const SysFunction* function, const NestValueArr } -dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestValueArray& args, Jrd::impure_value* impure) +dsc* evlMakeDbkey(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure) { // MAKE_DBKEY ( REL_NAME | REL_ID, RECNUM [, DPNUM [, PPNUM] ] ) @@ -6788,7 +6789,7 @@ dsc* evlRoleInUse(thread_db* tdbb, const SysFunction*, const NestValueArray& arg fb_assert(args.getCount() == 1); Request* request = tdbb->getRequest(); - const Jrd::Attachment* attachment = tdbb->getAttachment(); + const Attachment* attachment = tdbb->getAttachment(); const dsc* value = EVL_expr(tdbb, request, args[0]); if (!value) // return NULL if value is NULL @@ -6822,7 +6823,7 @@ dsc* evlSystemPrivilege(thread_db* tdbb, const SysFunction*, const NestValueArra fb_assert(value->dsc_dtype == dtype_short); const USHORT p = *((USHORT*) value->dsc_address); - const Jrd::Attachment* attachment = tdbb->getAttachment(); + const Attachment* attachment = tdbb->getAttachment(); impure->vlu_misc.vlu_uchar = (attachment->att_user && attachment->att_user->locksmith(tdbb, p)) ? FB_TRUE : FB_FALSE; impure->vlu_desc.makeBoolean(&impure->vlu_misc.vlu_uchar); @@ -7023,3 +7024,6 @@ void SysFunction::checkArgsMismatch(int count) const status_exception::raise(Arg::Gds(isc_funmismat) << Arg::Str(name)); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/SysFunction.h b/src/jrd/SysFunction.h index 5a2cbc671b9..f8fef9c2980 100644 --- a/src/jrd/SysFunction.h +++ b/src/jrd/SysFunction.h @@ -36,11 +36,10 @@ #include "../dsql/Nodes.h" #include "../common/dsc.h" -namespace Jrd +namespace Firebird::Jrd { class thread_db; struct impure_value; -} class SysFunction @@ -48,8 +47,7 @@ class SysFunction public: typedef void (*SetParamsFunc)(DataTypeUtilBase* dataTypeUtil, const SysFunction* function, int, dsc**); typedef void (*MakeFunc)(DataTypeUtilBase* dataTypeUtil, const SysFunction* function, dsc*, int, const dsc**); - typedef dsc* (*EvlFunc)(Jrd::thread_db*, const SysFunction* function, - const Jrd::NestValueArray&, Jrd::impure_value*); + typedef dsc* (*EvlFunc)(thread_db*, const SysFunction* function, const NestValueArray&, impure_value*); const char* name; int minArgCount; @@ -69,5 +67,7 @@ class SysFunction }; +} // namespace Firebird::Jrd + #endif // JRD_SYSFUNCTION_H diff --git a/src/jrd/SystemPackages.cpp b/src/jrd/SystemPackages.cpp index e61e2c2e431..47002ec285a 100644 --- a/src/jrd/SystemPackages.cpp +++ b/src/jrd/SystemPackages.cpp @@ -27,8 +27,8 @@ #include "../jrd/ProfilerManager.h" #include "../jrd/sys-packages/SqlPackage.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace @@ -57,3 +57,6 @@ ObjectsArray& SystemPackage::get() { return *SystemPackagesInit::INSTANCE().list.get(); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/SystemPackages.h b/src/jrd/SystemPackages.h index acb47b379b3..bc8ee4d4b7a 100644 --- a/src/jrd/SystemPackages.h +++ b/src/jrd/SystemPackages.h @@ -29,14 +29,14 @@ #include "../common/classes/init.h" #include "../common/classes/array.h" #include "../common/classes/objects_array.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ini.h" #include "../jrd/jrd.h" #include "firebird/Interface.h" #include #include -namespace Jrd +namespace Firebird::Jrd { struct SystemProcedureParameter { @@ -55,7 +55,7 @@ namespace Jrd { } - SystemProcedureParameter(Firebird::MemoryPool& pool, const SystemProcedureParameter& other) + SystemProcedureParameter(MemoryPool& pool, const SystemProcedureParameter& other) : defaultBlr(pool) { *this = other; @@ -65,21 +65,21 @@ namespace Jrd USHORT fieldId; bool nullable; const char* defaultText = nullptr; - Firebird::Array defaultBlr; + Array defaultBlr; }; struct SystemProcedure { - typedef std::function Factory; SystemProcedure( - Firebird::MemoryPool& pool, + MemoryPool& pool, const char* aName, Factory aFactory, prc_t aType, @@ -94,7 +94,7 @@ namespace Jrd { } - SystemProcedure(Firebird::MemoryPool& pool, const SystemProcedure& other) + SystemProcedure(MemoryPool& pool, const SystemProcedure& other) : inputParameters(pool), outputParameters(pool) { @@ -104,8 +104,8 @@ namespace Jrd const char* name; Factory factory; prc_t type; - Firebird::ObjectsArray inputParameters; - Firebird::ObjectsArray outputParameters; + ObjectsArray inputParameters; + ObjectsArray outputParameters; }; struct SystemFunctionParameter @@ -125,7 +125,7 @@ namespace Jrd { } - SystemFunctionParameter(Firebird::MemoryPool& pool, const SystemFunctionParameter& other) + SystemFunctionParameter(MemoryPool& pool, const SystemFunctionParameter& other) : defaultBlr(pool) { *this = other; @@ -135,7 +135,7 @@ namespace Jrd USHORT fieldId; bool nullable; const char* defaultText = nullptr; - Firebird::Array defaultBlr; + Array defaultBlr; }; struct SystemFunctionReturnType @@ -146,16 +146,16 @@ namespace Jrd struct SystemFunction { - typedef std::function Factory; SystemFunction( - Firebird::MemoryPool& pool, + MemoryPool& pool, const char* aName, Factory aFactory, std::initializer_list aParameters, @@ -168,7 +168,7 @@ namespace Jrd { } - SystemFunction(Firebird::MemoryPool& pool, const SystemFunction& other) + SystemFunction(MemoryPool& pool, const SystemFunction& other) : parameters(pool) { *this = other; @@ -176,14 +176,14 @@ namespace Jrd const char* name; Factory factory; - Firebird::ObjectsArray parameters; + ObjectsArray parameters; SystemFunctionReturnType returnType; }; struct SystemPackage { SystemPackage( - Firebird::MemoryPool& pool, + MemoryPool& pool, const char* aName, USHORT aOdsVersion, std::initializer_list aProcedures, @@ -196,7 +196,7 @@ namespace Jrd { } - SystemPackage(Firebird::MemoryPool& pool, const SystemPackage& other) + SystemPackage(MemoryPool& pool, const SystemPackage& other) : procedures(pool), functions(pool) { @@ -205,10 +205,10 @@ namespace Jrd const char* name; USHORT odsVersion; - Firebird::ObjectsArray procedures; - Firebird::ObjectsArray functions; + ObjectsArray procedures; + ObjectsArray functions; - static Firebird::ObjectsArray& get(); + static ObjectsArray& get(); private: SystemPackage(const SystemPackage&) = delete; @@ -221,7 +221,7 @@ namespace Jrd typedef void Type; public: - static void setup(Firebird::ThrowStatusExceptionWrapper*, Firebird::IMetadataBuilder*) + static void setup(ThrowStatusExceptionWrapper*, IMetadataBuilder*) { } }; @@ -229,9 +229,9 @@ namespace Jrd template < typename Input, typename Output, - Firebird::IExternalResultSet* (*OpenFunction)( - Firebird::ThrowStatusExceptionWrapper*, - Firebird::IExternalContext*, + IExternalResultSet* (*OpenFunction)( + ThrowStatusExceptionWrapper*, + IExternalContext*, const typename Input::Type*, typename Output::Type* ) @@ -240,15 +240,15 @@ namespace Jrd { class SystemResultSet : public - Firebird::DisposeIface< - Firebird::IExternalResultSetImpl< + DisposeIface< + IExternalResultSetImpl< SystemResultSet, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - SystemResultSet(Attachment* aAttachment, Firebird::IExternalResultSet* aResultSet) + SystemResultSet(Attachment* aAttachment, IExternalResultSet* aResultSet) : attachment(aAttachment), resultSet(aResultSet) { @@ -261,31 +261,31 @@ namespace Jrd } public: - FB_BOOLEAN fetch(Firebird::ThrowStatusExceptionWrapper* status) override + FB_BOOLEAN fetch(ThrowStatusExceptionWrapper* status) override { // See comment in Attachment.h. - // Firebird::AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); + // AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); return resultSet->fetch(status); } private: Attachment* attachment; - Firebird::AutoDispose resultSet; + AutoDispose resultSet; }; class SystemProcedureImpl : public - Firebird::DisposeIface< - Firebird::IExternalProcedureImpl< + DisposeIface< + IExternalProcedureImpl< SystemProcedureImpl, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - SystemProcedureImpl(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IMetadataBuilder* inBuilder, Firebird::IMetadataBuilder* outBuilder) + SystemProcedureImpl(ThrowStatusExceptionWrapper* status, + IMetadataBuilder* inBuilder, IMetadataBuilder* outBuilder) { const auto tdbb = JRD_get_thread_data(); attachment = tdbb->getAttachment(); @@ -301,17 +301,17 @@ namespace Jrd } public: - void getCharSet(Firebird::ThrowStatusExceptionWrapper* status, Firebird::IExternalContext* context, + void getCharSet(ThrowStatusExceptionWrapper* status, IExternalContext* context, char* name, unsigned nameSize) override { strncpy(name, "UTF8", nameSize); } - Firebird::IExternalResultSet* open(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, void* inMsg, void* outMsg) override + IExternalResultSet* open(ThrowStatusExceptionWrapper* status, + IExternalContext* context, void* inMsg, void* outMsg) override { // See comment in Attachment.h. - // Firebird::AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); + // AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); const auto resultSet = OpenFunction(status, context, static_cast(inMsg), @@ -325,11 +325,11 @@ namespace Jrd }; SystemProcedureImpl* operator()( - Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* /*context*/, - Firebird::IRoutineMetadata* /*metadata*/, - Firebird::IMetadataBuilder* inBuilder, - Firebird::IMetadataBuilder* outBuilder) + ThrowStatusExceptionWrapper* status, + IExternalContext* /*context*/, + IRoutineMetadata* /*metadata*/, + IMetadataBuilder* inBuilder, + IMetadataBuilder* outBuilder) { return FB_NEW SystemProcedureImpl(status, inBuilder, outBuilder); } @@ -339,8 +339,8 @@ namespace Jrd typename Input, typename Output, void (*ExecFunction)( - Firebird::ThrowStatusExceptionWrapper*, - Firebird::IExternalContext*, + ThrowStatusExceptionWrapper*, + IExternalContext*, const typename Input::Type*, typename Output::Type* ) @@ -349,16 +349,16 @@ namespace Jrd { class SystemFunctionImpl : public - Firebird::DisposeIface< - Firebird::IExternalFunctionImpl< + DisposeIface< + IExternalFunctionImpl< SystemFunctionImpl, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - SystemFunctionImpl(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IMetadataBuilder* inBuilder, Firebird::IMetadataBuilder* outBuilder) + SystemFunctionImpl(ThrowStatusExceptionWrapper* status, + IMetadataBuilder* inBuilder, IMetadataBuilder* outBuilder) { const auto tdbb = JRD_get_thread_data(); attachment = tdbb->getAttachment(); @@ -368,17 +368,17 @@ namespace Jrd } public: - void getCharSet(Firebird::ThrowStatusExceptionWrapper* status, Firebird::IExternalContext* context, + void getCharSet(ThrowStatusExceptionWrapper* status, IExternalContext* context, char* name, unsigned nameSize) override { strncpy(name, "UTF8", nameSize); } - void execute(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, void* inMsg, void* outMsg) override + void execute(ThrowStatusExceptionWrapper* status, + IExternalContext* context, void* inMsg, void* outMsg) override { // See comment in Attachment.h. - // Firebird::AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); + // AutoSetRestore autoInSystemPackage(&attachment->att_in_system_routine, true); ExecFunction(status, context, static_cast(inMsg), @@ -390,15 +390,15 @@ namespace Jrd }; SystemFunctionImpl* operator()( - Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* /*context*/, - Firebird::IRoutineMetadata* /*metadata*/, - Firebird::IMetadataBuilder* inBuilder, - Firebird::IMetadataBuilder* outBuilder) + ThrowStatusExceptionWrapper* status, + IExternalContext* /*context*/, + IRoutineMetadata* /*metadata*/, + IMetadataBuilder* inBuilder, + IMetadataBuilder* outBuilder) { return FB_NEW SystemFunctionImpl(status, inBuilder, outBuilder); } }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SYSTEM_PACKAGES_H diff --git a/src/jrd/SystemPrivileges.h b/src/jrd/SystemPrivileges.h index 7dd08e809f8..625dd37aa41 100644 --- a/src/jrd/SystemPrivileges.h +++ b/src/jrd/SystemPrivileges.h @@ -33,7 +33,7 @@ #define FB_JRD_SYSTEM_PRIVILEGES #define FB_JRD_SYSTEM_PRIVILEGES_TMP -namespace Jrd { +namespace Firebird::Jrd { enum SystemPrivilege { NULL_PRIVILEGE, @@ -70,7 +70,7 @@ SYSTEM_PRIVILEGE(PROFILE_ANY_ATTACHMENT) #ifdef FB_JRD_SYSTEM_PRIVILEGES_TMP maxSystemPrivilege }; -} // namespace Jrd +} // namespace Firebird::Jrd #undef SYSTEM_PRIVILEGE #undef FB_JRD_SYSTEM_PRIVILEGES_TMP diff --git a/src/jrd/SystemTriggers.epp b/src/jrd/SystemTriggers.epp index ac53b45369c..11c8ee7f88d 100644 --- a/src/jrd/SystemTriggers.epp +++ b/src/jrd/SystemTriggers.epp @@ -25,7 +25,7 @@ #include "firebird/Interface.h" #include "../jrd/SystemTriggers.h" #include "../jrd/acl.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ids.h" #include "../jrd/ini.h" #include "../jrd/req.h" @@ -45,8 +45,8 @@ DATABASE DB = FILENAME "ODS.RDB"; -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace @@ -1869,3 +1869,5 @@ void SystemTriggers::executeAfterUpdateTriggers(thread_db* tdbb, jrd_rel* relati } } + +} // namespace Firebird::Jrd diff --git a/src/jrd/SystemTriggers.h b/src/jrd/SystemTriggers.h index fa68bb1029c..b0ab19f1db6 100644 --- a/src/jrd/SystemTriggers.h +++ b/src/jrd/SystemTriggers.h @@ -25,14 +25,13 @@ #include "firebird.h" -namespace Jrd -{ +namespace Firebird::Jrd { class jrd_rel; class thread_db; class Record; -} // namespace Jrd +} // namespace Firebird::Jrd -namespace Jrd::SystemTriggers +namespace Firebird::Jrd::SystemTriggers { void executeBeforeInsertTriggers(thread_db* tdbb, jrd_rel* relation, Record* record); void executeAfterInsertTriggers(thread_db* tdbb, jrd_rel* relation, Record* record); @@ -42,6 +41,6 @@ namespace Jrd::SystemTriggers void executeBeforeDeleteTriggers(thread_db* tdbb, jrd_rel* relation, Record* record); void executeAfterDeleteTriggers(thread_db* tdbb, jrd_rel* relation, Record* record); -} // namespace Jrd::SystemTriggers +} // namespace Firebird::Jrd::SystemTriggers #endif // JRD_SYSTEM_TRIGGERS_H diff --git a/src/jrd/TempSpace.cpp b/src/jrd/TempSpace.cpp index 6e22ecfd869..eb85cc687f7 100644 --- a/src/jrd/TempSpace.cpp +++ b/src/jrd/TempSpace.cpp @@ -33,8 +33,10 @@ #include "../jrd/TempSpace.h" -using namespace Firebird; -using namespace Jrd; + +namespace Firebird::Jrd +{ + // Static definitions/initializations @@ -802,3 +804,6 @@ ULONG TempSpace::allocateBatch(ULONG count, FB_SIZE_T minSize, FB_SIZE_T maxSize return segments.getCount(); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/TempSpace.h b/src/jrd/TempSpace.h index d172eb50073..6b5e357c16e 100644 --- a/src/jrd/TempSpace.h +++ b/src/jrd/TempSpace.h @@ -31,10 +31,14 @@ #include "../common/classes/init.h" #include "../common/classes/tree.h" -class TempSpace : public Firebird::File +namespace Firebird::Jrd +{ + + +class TempSpace : public File { public: - TempSpace(MemoryPool& pool, const Firebird::PathName& prefix, bool dynamic = true); + TempSpace(MemoryPool& pool, const PathName& prefix, bool dynamic = true); virtual ~TempSpace(); FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length) override; @@ -61,7 +65,7 @@ class TempSpace : public Firebird::File size_t size; }; - typedef Firebird::Array Segments; + typedef Array Segments; ULONG allocateBatch(ULONG count, FB_SIZE_T minSize, FB_SIZE_T maxSize, Segments& segments); @@ -88,7 +92,7 @@ class TempSpace : public Firebird::File virtual FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length) = 0; virtual UCHAR* inMemory(offset_t offset, size_t size) const noexcept = 0; - virtual bool sameFile(const Firebird::TempFile* file) const noexcept = 0; + virtual bool sameFile(const TempFile* file) const noexcept = 0; Block *prev; Block *next; @@ -118,7 +122,7 @@ class TempSpace : public Firebird::File return NULL; } - bool sameFile(const Firebird::TempFile*) const noexcept override + bool sameFile(const TempFile*) const noexcept override { return false; } @@ -143,7 +147,7 @@ class TempSpace : public Firebird::File class FileBlock : public Block { public: - FileBlock(Firebird::TempFile* f, Block* tail, size_t length) + FileBlock(TempFile* f, Block* tail, size_t length) : Block(tail, length), file(f) { fb_assert(file); @@ -163,18 +167,18 @@ class TempSpace : public Firebird::File return NULL; } - bool sameFile(const Firebird::TempFile* aFile) const noexcept override + bool sameFile(const TempFile* aFile) const noexcept override { return (aFile == this->file); } private: - Firebird::TempFile* file; + TempFile* file; offset_t seek; }; Block* findBlock(offset_t& offset) const; - Firebird::TempFile* setupFile(FB_SIZE_T size); + TempFile* setupFile(FB_SIZE_T size); UCHAR* findMemory(offset_t& begin, offset_t end, size_t size) const; @@ -217,18 +221,18 @@ class TempSpace : public Firebird::File }; MemoryPool& pool; - Firebird::PathName filePrefix; + PathName filePrefix; offset_t logicalSize; offset_t physicalSize; offset_t localCacheUsage; Block* head; Block* tail; - Firebird::Array tempFiles; - Firebird::Array initialBuffer; + Array tempFiles; + Array initialBuffer; bool initiallyDynamic; - typedef Firebird::BePlusTree FreeSegmentTree; - typedef Firebird::BePlusTree FreeSegmentsStackTree; + typedef BePlusTree FreeSegmentTree; + typedef BePlusTree FreeSegmentsStackTree; class FreeSegmentBySize { @@ -250,9 +254,12 @@ class TempSpace : public Firebird::File FreeSegmentTree freeSegments; FreeSegmentBySize freeSegmentsBySize; - static Firebird::GlobalPtr initMutex; - static Firebird::TempDirectoryList* tempDirs; + static GlobalPtr initMutex; + static TempDirectoryList* tempDirs; static FB_SIZE_T minBlockSize; }; + +} // namespace Firebird::Jrd + #endif // JRD_TEMP_SPACE_H diff --git a/src/jrd/ThreadCollect.h b/src/jrd/ThreadCollect.h index 497c404c614..c74d86206b5 100644 --- a/src/jrd/ThreadCollect.h +++ b/src/jrd/ThreadCollect.h @@ -37,12 +37,12 @@ #include -namespace Jrd { +namespace Firebird::Jrd { class ThreadCollect { public: - ThreadCollect(Firebird::MemoryPool& p) + ThreadCollect(MemoryPool& p) : threads(p) { } @@ -57,7 +57,7 @@ namespace Jrd { // put thread into completion wait queue when it finished running void ending(Thread&& thd) { - Firebird::MutexLockGuard g(threadsMutex, FB_FUNCTION); + MutexLockGuard g(threadsMutex, FB_FUNCTION); const Thread::Mark mark(thd); @@ -75,7 +75,7 @@ namespace Jrd { void ending(Thread::Mark& m) { - Firebird::MutexLockGuard g(threadsMutex, FB_FUNCTION); + MutexLockGuard g(threadsMutex, FB_FUNCTION); for (auto& n : threads) { @@ -92,7 +92,7 @@ namespace Jrd { // put thread into completion wait queue when it starts running void running(Thread&& thd) { - Firebird::MutexLockGuard g(threadsMutex, FB_FUNCTION); + MutexLockGuard g(threadsMutex, FB_FUNCTION); threads.push_back(Thrd(std::move(thd), false)); } @@ -105,7 +105,7 @@ namespace Jrd { // join finished threads AllThreads finished(threads.get_allocator()); { // mutex scope - Firebird::MutexLockGuard g(threadsMutex, FB_FUNCTION); + MutexLockGuard g(threadsMutex, FB_FUNCTION); for (auto n = threads.begin(); n != threads.end(); ) { @@ -146,17 +146,17 @@ namespace Jrd { bool ending; }; - using AllThreads = std::vector>; + using AllThreads = std::vector>; void waitFor(AllThreads& thr) { - Firebird::MutexLockGuard g(threadsMutex, FB_FUNCTION); + MutexLockGuard g(threadsMutex, FB_FUNCTION); while (!thr.empty()) { Thrd t = std::move(thr.back()); thr.pop_back(); { - Firebird::MutexUnlockGuard u(threadsMutex, FB_FUNCTION); + MutexUnlockGuard u(threadsMutex, FB_FUNCTION); t.thread.waitForCompletion(); fb_assert(t.ending); } @@ -164,10 +164,10 @@ namespace Jrd { } AllThreads threads; - Firebird::Mutex threadsMutex; + Mutex threadsMutex; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_THREADCOLLECT_H diff --git a/src/jrd/TimeZone.cpp b/src/jrd/TimeZone.cpp index 9b6092f344c..c0fbdbf69ce 100644 --- a/src/jrd/TimeZone.cpp +++ b/src/jrd/TimeZone.cpp @@ -27,8 +27,8 @@ #include "../jrd/tra.h" #include "../jrd/ids.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ TimeZoneSnapshot::TimeZoneSnapshot(thread_db* tdbb, MemoryPool& pool) @@ -110,8 +110,8 @@ FB_BOOLEAN TimeZonePackage::TransitionsResultSet::fetch(ThrowStatusExceptionWrap //-------------------------------------- -void TimeZonePackage::databaseVersionFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const void*, DatabaseVersionOutput::Type* out) +void TimeZonePackage::databaseVersionFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const void*, DatabaseVersionOutput::Type* out) { string str; TimeZoneUtil::getDatabaseVersion(str); @@ -124,7 +124,7 @@ void TimeZonePackage::databaseVersionFunction(Firebird::ThrowStatusExceptionWrap //-------------------------------------- -TimeZonePackage::TimeZonePackage(Firebird::MemoryPool& pool) +TimeZonePackage::TimeZonePackage(MemoryPool& pool) : SystemPackage( pool, "RDB$TIME_ZONE_UTIL", @@ -166,3 +166,6 @@ TimeZonePackage::TimeZonePackage(Firebird::MemoryPool& pool) ) { } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/TimeZone.h b/src/jrd/TimeZone.h index eb86d7773ac..9966d3bbb59 100644 --- a/src/jrd/TimeZone.h +++ b/src/jrd/TimeZone.h @@ -30,7 +30,8 @@ #include "../jrd/SystemPackages.h" #include "../jrd/recsrc/RecordSource.h" -namespace Jrd { +namespace Firebird::Jrd +{ class thread_db; class jrd_tra; @@ -46,7 +47,7 @@ class TimeZoneSnapshot : public SnapshotData class TimeZonesTableScan final : public VirtualTableScan { public: - TimeZonesTableScan(CompilerScratch* csb, const Firebird::string& alias, StreamType stream, Rsc::Rel relation); + TimeZonesTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation); protected: const Format* getFormat(thread_db* tdbb, RelationPermanent* relation) const override; @@ -57,16 +58,16 @@ class TimeZonesTableScan final : public VirtualTableScan class TimeZonePackage : public SystemPackage { public: - TimeZonePackage(Firebird::MemoryPool& pool); + TimeZonePackage(MemoryPool& pool); private: - FB_MESSAGE(TransitionsInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(TransitionsInput, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(MAX_SQL_IDENTIFIER_LEN, CS_METADATA), timeZoneName) (FB_TIMESTAMP_TZ, fromTimestamp) (FB_TIMESTAMP_TZ, toTimestamp) ); - FB_MESSAGE(TransitionsOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(TransitionsOutput, ThrowStatusExceptionWrapper, (FB_TIMESTAMP_TZ, startTimestamp) (FB_TIMESTAMP_TZ, endTimestamp) (FB_SMALLINT, zoneOffset) @@ -76,15 +77,15 @@ class TimeZonePackage : public SystemPackage class TransitionsResultSet : public - Firebird::DisposeIface< - Firebird::IExternalResultSetImpl< + DisposeIface< + IExternalResultSetImpl< TransitionsResultSet, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - TransitionsResultSet(Firebird::ThrowStatusExceptionWrapper* status, Firebird::IExternalContext* context, + TransitionsResultSet(ThrowStatusExceptionWrapper* status, IExternalContext* context, const TransitionsInput::Type* in, TransitionsOutput::Type* out); public: @@ -94,15 +95,15 @@ class TimeZonePackage : public SystemPackage } public: - FB_BOOLEAN fetch(Firebird::ThrowStatusExceptionWrapper* status) override; + FB_BOOLEAN fetch(ThrowStatusExceptionWrapper* status) override; private: TransitionsOutput::Type* out; - Firebird::AutoPtr iterator; + AutoPtr iterator; }; - static Firebird::IExternalResultSet* transitionsProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static IExternalResultSet* transitionsProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const TransitionsInput::Type* in, TransitionsOutput::Type* out) { return FB_NEW TransitionsResultSet(status, context, in, out); @@ -110,15 +111,15 @@ class TimeZonePackage : public SystemPackage //---------- - FB_MESSAGE(DatabaseVersionOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(DatabaseVersionOutput, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(10, CS_ASCII), version) ); - static void databaseVersionFunction(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const void* in, DatabaseVersionOutput::Type* out); + static void databaseVersionFunction(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const void* in, DatabaseVersionOutput::Type* out); }; -} // namespace +} // namespace Firebird::Jrd #endif // JRD_TIME_ZONE_H diff --git a/src/jrd/UserManagement.cpp b/src/jrd/UserManagement.cpp index d410f1cb359..7ec3340af39 100644 --- a/src/jrd/UserManagement.cpp +++ b/src/jrd/UserManagement.cpp @@ -32,8 +32,9 @@ #include "../jrd/ini.h" #include "../jrd/ids.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + namespace { @@ -336,8 +337,8 @@ void UserManagement::checkSecurityResult(int errcode, IStatus* status, errcode = Auth::setGsecCode(errcode, operation); Arg::StatusVector tmp; - tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, GSEC_MSG_FAC)); - if (errcode == GsecMsg22) + tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, Gsec::GSEC_MSG_FAC)); + if (errcode == Gsec::GsecMsg22) { tmp << userName; } @@ -638,3 +639,6 @@ RecordBuffer* UserManagement::getList(thread_db* tdbb, RelationPermanent* relati return getData(relation); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/UserManagement.h b/src/jrd/UserManagement.h index eb4980fc78c..504f7d229e5 100644 --- a/src/jrd/UserManagement.h +++ b/src/jrd/UserManagement.h @@ -31,7 +31,9 @@ #include "firebird/Interface.h" #include "../common/security.h" -namespace Jrd { +namespace Firebird::Jrd +{ + class thread_db; class jrd_tra; @@ -40,7 +42,7 @@ class RecordBuffer; class UsersTableScan: public VirtualTableScan { public: - UsersTableScan(CompilerScratch* csb, const Firebird::string& alias, + UsersTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation) : VirtualTableScan(csb, alias, stream, relation) {} @@ -67,24 +69,25 @@ class UserManagement : public SnapshotData // return users list for SEC$USERS RecordBuffer* getList(thread_db* tdbb, RelationPermanent* relation); // callback for users display - void list(Firebird::IUser* u, unsigned cachePosition); + void list(IUser* u, unsigned cachePosition); private: thread_db* threadDbb; - Firebird::HalfStaticArray commands; - typedef Firebird::Pair > Manager; - Firebird::ObjectsArray managers; - Firebird::NoCaseString plugins; + HalfStaticArray commands; + typedef Pair > Manager; + ObjectsArray managers; + NoCaseString plugins; Attachment* att; jrd_tra* tra; - Firebird::IManagement* getManager(const char* name); + IManagement* getManager(const char* name); void openAllManagers(); - Firebird::IManagement* registerManager(Auth::Get& getPlugin, const char* plugName); - static void checkSecurityResult(int errcode, Firebird::IStatus* status, + IManagement* registerManager(Auth::Get& getPlugin, const char* plugName); + static void checkSecurityResult(int errcode, IStatus* status, const char* userName, unsigned operation); }; -} // namespace + +} // namespace Firebird::Jrd #endif // JRD_USER_MANAGEMENT_H diff --git a/src/jrd/VirtualTable.cpp b/src/jrd/VirtualTable.cpp index 55c2aa4636d..3eae53fb247 100644 --- a/src/jrd/VirtualTable.cpp +++ b/src/jrd/VirtualTable.cpp @@ -23,7 +23,7 @@ #include "firebird.h" #include "../common/dsc.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/jrd.h" #include "../jrd/exe.h" #include "../jrd/ids.h" @@ -42,8 +42,8 @@ #include "../jrd/RecordBuffer.h" #include "../jrd/VirtualTable.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ void VirtualTable::erase(thread_db* tdbb, record_param* rpb) @@ -111,3 +111,6 @@ void VirtualTable::store(thread_db* /*tdbb*/, record_param* /*rpb*/) { ERR_post(Arg::Gds(isc_read_only)); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/VirtualTable.h b/src/jrd/VirtualTable.h index 07ebb1e2d3d..9f942a09023 100644 --- a/src/jrd/VirtualTable.h +++ b/src/jrd/VirtualTable.h @@ -24,7 +24,7 @@ #ifndef JRD_VIRTUAL_TABLE_H #define JRD_VIRTUAL_TABLE_H -namespace Jrd +namespace Firebird::Jrd { class VirtualTable { @@ -33,7 +33,6 @@ namespace Jrd static void modify(thread_db*, record_param*, record_param*); static void store(thread_db*, record_param*); }; - -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_VIRTUAL_TABLE_H diff --git a/src/jrd/WorkerAttachment.cpp b/src/jrd/WorkerAttachment.cpp index d1a69ef8682..37fdb8790cd 100644 --- a/src/jrd/WorkerAttachment.cpp +++ b/src/jrd/WorkerAttachment.cpp @@ -40,10 +40,8 @@ #include "../jrd/status.h" #include "../jrd/Monitoring.h" - -using namespace Firebird; - -namespace Jrd { +namespace Firebird::Jrd +{ constexpr unsigned WORKER_IDLE_TIMEOUT = 60; // 1 minute @@ -104,7 +102,7 @@ WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, D return NULL; } -void WorkerStableAttachment::doOnIdleTimer(Firebird::TimerImpl* timer) +void WorkerStableAttachment::doOnIdleTimer(TimerImpl* timer) { WorkerAttachment::detachIdle(this); } @@ -525,4 +523,5 @@ void WorkerAttachment::doDetach(FbStatusVector* status, StableAttachmentPart* sA sAtt->release(); // !! } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/WorkerAttachment.h b/src/jrd/WorkerAttachment.h index ffbce80c0a1..18b8c0d7a6f 100644 --- a/src/jrd/WorkerAttachment.h +++ b/src/jrd/WorkerAttachment.h @@ -41,8 +41,7 @@ #include "../jrd/status.h" -namespace Jrd -{ +namespace Firebird::Jrd { class WorkerAttachment; @@ -55,7 +54,7 @@ class WorkerStableAttachment : public SysStableAttachment void fini(); protected: - virtual void doOnIdleTimer(Firebird::TimerImpl* timer); + virtual void doOnIdleTimer(TimerImpl* timer); private: explicit WorkerStableAttachment(FbStatusVector* status, Jrd::Attachment* att, WorkerAttachment* workers); @@ -92,14 +91,14 @@ class WorkerAttachment static bool detachIdle(Jrd::StableAttachmentPart* sAtt); - static void incUserAtts(const Firebird::PathName& dbname); - static void decUserAtts(const Firebird::PathName& dbname); + static void incUserAtts(const PathName& dbname); + static void decUserAtts(const PathName& dbname); static void shutdown(); static void shutdownDbb(Jrd::Database* dbb); private: - static WorkerAttachment* getByName(const Firebird::PathName& dbname); + static WorkerAttachment* getByName(const PathName& dbname); Jrd::StableAttachmentPart* doAttach(FbStatusVector* status, Jrd::Database* dbb); static void doDetach(FbStatusVector* status, Jrd::StableAttachmentPart* sAtt); void clear(bool checkRefs); @@ -109,17 +108,17 @@ class WorkerAttachment void waitForWorkers(); - typedef Firebird::GenericMap > > + typedef GenericMap > > MapDbIdToWorkAtts; - static Firebird::GlobalPtr m_mapMutex; - static Firebird::GlobalPtr m_map; + static GlobalPtr m_mapMutex; + static GlobalPtr m_map; static bool m_shutdown; - Firebird::Mutex m_mutex; - Firebird::HalfStaticArray m_idleAtts; - Firebird::SortedArray > m_activeAtts; + Mutex m_mutex; + HalfStaticArray m_idleAtts; + SortedArray > m_activeAtts; // count of regular user attachments, used with non-shared Database int m_cntUserAtts = 0; @@ -128,9 +127,9 @@ class WorkerAttachment int m_cntWorkers = 0; // used to wait for "no internal workers" condition - Firebird::Condition m_noWorkers; + Condition m_noWorkers; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_WORKER_ATTACHMENT_H diff --git a/src/jrd/align.h b/src/jrd/align.h index 44a380ce854..e8bf9186772 100644 --- a/src/jrd/align.h +++ b/src/jrd/align.h @@ -25,6 +25,7 @@ * */ +// FIXME: Move this file to src/common #ifndef JRD_ALIGN_H #define JRD_ALIGN_H @@ -35,6 +36,12 @@ Maximum alignments for corresponding data types are defined in dsc.h #include "../common/DecFloat.h" #include "../common/Int128.h" #include "firebird/impl/blr.h" +#include "../common/dsc.h" +#include "../jrd/RecordNumber.h" + +namespace Firebird +{ + /* The following macro must be defined as the highest-numericly-valued * blr which describes a datatype: arrays are sized based on this value. @@ -51,9 +58,6 @@ No need to worry about blr_blob or ?blr_blob_id */ -#include "../common/dsc.h" -#include "../jrd/RecordNumber.h" - static inline constexpr USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] = { 0, 0, 0, 0, 0, 0, 0, @@ -112,8 +116,8 @@ static inline constexpr USHORT type_alignments[DTYPE_TYPE_MAX] = sizeof(SINT64), /* dtype_int64 */ sizeof(ULONG), /* dtype_dbkey */ sizeof(UCHAR), /* dtype_boolean */ - sizeof(Firebird::Decimal64),/* dtype_dec64 */ - sizeof(Firebird::Decimal64),/* dtype_dec128 */ + sizeof(Decimal64),/* dtype_dec64 */ + sizeof(Decimal64),/* dtype_dec128 */ sizeof(SINT64), /* dtype_int128 */ sizeof(GDS_TIME), /* dtype_sql_time_tz */ sizeof(GDS_DATE), /* dtype_timestamp_tz */ @@ -145,9 +149,9 @@ static inline constexpr USHORT type_lengths[DTYPE_TYPE_MAX] = sizeof(SINT64), /* dtype_int64 */ sizeof(RecordNumber::Packed), /* dtype_dbkey */ sizeof(UCHAR), /* dtype_boolean */ - sizeof(Firebird::Decimal64), /* dtype_dec64 */ - sizeof(Firebird::Decimal128), /* dtype_dec128 */ - sizeof(Firebird::Int128), /* dtype_int128 */ + sizeof(Decimal64), /* dtype_dec64 */ + sizeof(Decimal128), /* dtype_dec128 */ + sizeof(Int128), /* dtype_int128 */ sizeof(ISC_TIME_TZ), /* dtype_sql_time_tz */ sizeof(ISC_TIMESTAMP_TZ), /* dtype_timestamp_tz */ sizeof(ISC_TIME_TZ_EX), /* dtype_ex_time_tz */ @@ -190,4 +194,7 @@ static inline constexpr USHORT type_significant_bits[DTYPE_TYPE_MAX] = 0 // dtype_ex_timestamp_tz }; + +} // namespace Firebird + #endif /* JRD_ALIGN_H */ diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index f7e141a1be8..c889e68c635 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -75,8 +75,9 @@ #include "../common/classes/VaryStr.h" #include "../jrd/Statement.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + typedef Ods::blob_page blob_page; @@ -886,7 +887,7 @@ SLONG blb::get_slice(thread_db* tdbb, SET_TDBB(tdbb); //Database* database = GET_DBB(); - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); // Checkout slice description language SLONG variables[64]; @@ -1743,7 +1744,7 @@ void blb::put_slice(thread_db* tdbb, transaction = transaction->getOuter(); SET_TDBB(tdbb); - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); // Do initial parse of slice description to get relation and field identification sdl_info info; @@ -2978,7 +2979,7 @@ void blb::getFromPage(USHORT length, const UCHAR* data) } // Used by DPM_store_blob -void blb::storeToPage(USHORT* length, Firebird::Array& buffer, const UCHAR** data, void* stack) +void blb::storeToPage(USHORT* length, Array& buffer, const UCHAR** data, void* stack) { if (blb_level == 0) { @@ -3029,3 +3030,6 @@ void blb::BLB_cancel() { BLB_cancel(JRD_get_thread_data()); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/blb.h b/src/jrd/blb.h index 4d9b227266e..ae1a29123f6 100644 --- a/src/jrd/blb.h +++ b/src/jrd/blb.h @@ -41,14 +41,12 @@ #include "../common/dsc.h" #include "../jrd/Resources.h" -namespace Ods -{ +namespace Firebird::Jrd::Ods { struct blob_page; struct blh; } -namespace Jrd -{ +namespace Firebird::Jrd { class Attachment; class BlobControl; @@ -124,7 +122,7 @@ class blb : public pool_alloc void fromPageHeader(const Ods::blh* header); void toPageHeader(Ods::blh* header) const; void getFromPage(USHORT length, const UCHAR* data); - void storeToPage(USHORT* length, Firebird::Array& buffer, const UCHAR** data, void* stack); + void storeToPage(USHORT* length, Array& buffer, const UCHAR** data, void* stack); static bid copy(thread_db* tdbb, const bid* source) { @@ -151,7 +149,7 @@ class blb : public pool_alloc bid blb_blob_id{}; // Id of materialized blob vcl* blb_pages = nullptr; // Vector of pages - Firebird::Array blb_buffer; // buffer used in opened blobs - must be longword aligned + Array blb_buffer; // buffer used in opened blobs - must be longword aligned ULONG blb_temp_id = 0; // ID of newly created blob in transaction ULONG blb_sequence = 0; // Blob page sequence @@ -257,7 +255,7 @@ inline USHORT blb::getMaxSegment() const } -} //namespace Jrd +} // namespace Firebird::Jrd namespace Firebird { diff --git a/src/jrd/blb_proto.h b/src/jrd/blb_proto.h index d914affd568..eda41126456 100644 --- a/src/jrd/blb_proto.h +++ b/src/jrd/blb_proto.h @@ -32,9 +32,13 @@ #include "../jrd/req.h" #include "../common/classes/array.h" +namespace Firebird::Jrd +{ + + void BLB_garbage_collect(Jrd::thread_db*, Jrd::RecordStack&, Jrd::RecordStack&, ULONG, Jrd::jrd_rel*); -void BLB_gen_bpb(SSHORT source, SSHORT target, UCHAR sourceCharset, UCHAR targetCharset, Firebird::UCharBuffer& bpb); -void BLB_gen_bpb_from_descs(const dsc*, const dsc*, Firebird::UCharBuffer&); +void BLB_gen_bpb(SSHORT source, SSHORT target, UCHAR sourceCharset, UCHAR targetCharset, UCharBuffer& bpb); +void BLB_gen_bpb_from_descs(const dsc*, const dsc*, UCharBuffer&); class AutoBlb @@ -70,4 +74,7 @@ class AutoBlb Jrd::blb* blob; }; + +} // namespace Firebird::Jrd + #endif // JRD_BLB_PROTO_H diff --git a/src/jrd/blf_proto.h b/src/jrd/blf_proto.h index d5c0dfe6413..9cadc8a0b3c 100644 --- a/src/jrd/blf_proto.h +++ b/src/jrd/blf_proto.h @@ -24,27 +24,21 @@ #ifndef JRD_BLF_PROTO_H #define JRD_BLF_PROTO_H -namespace Jrd { +namespace Firebird::Jrd +{ struct bid; -} -// Does this file really need the extern C for external blob filters? -extern "C" { - -//class Jrd::BlobControl; - -void BLF_close_blob(Jrd::thread_db*, Jrd::BlobControl**); -void BLF_create_blob(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::BlobControl**, Jrd::bid*, - USHORT, const UCHAR*, - Jrd::FPTR_BFILTER_CALLBACK, Jrd::BlobFilter*); -ISC_STATUS BLF_get_segment(Jrd::thread_db*, Jrd::BlobControl**, USHORT*, USHORT, void*); -Jrd::BlobFilter* BLF_lookup_internal_filter(Jrd::thread_db*, SSHORT, SSHORT); -void BLF_open_blob(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::BlobControl**, const Jrd::bid*, - USHORT, const UCHAR*, - Jrd::FPTR_BFILTER_CALLBACK, Jrd::BlobFilter*); -void BLF_put_segment(Jrd::thread_db*, Jrd::BlobControl**, USHORT, const void*); - -} /* extern "C" */ + void BLF_close_blob(thread_db*, BlobControl**); + void BLF_create_blob(thread_db*, jrd_tra*, BlobControl**, bid*, + USHORT, const UCHAR*, + FPTR_BFILTER_CALLBACK, BlobFilter*); + ISC_STATUS BLF_get_segment(thread_db*, BlobControl**, USHORT*, USHORT, void*); + BlobFilter* BLF_lookup_internal_filter(thread_db*, SSHORT, SSHORT); + void BLF_open_blob(thread_db*, jrd_tra*, BlobControl**, const bid*, + USHORT, const UCHAR*, + FPTR_BFILTER_CALLBACK, BlobFilter*); + void BLF_put_segment(thread_db*, BlobControl**, USHORT, const void*); +} // namespace Firebird::Jrd #endif /* JRD_BLF_PROTO_H */ diff --git a/src/jrd/blob_filter.cpp b/src/jrd/blob_filter.cpp index e34d00ea1bf..bae06133b2c 100644 --- a/src/jrd/blob_filter.cpp +++ b/src/jrd/blob_filter.cpp @@ -43,8 +43,9 @@ #include "../common/isc_s_proto.h" #include "iberror.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + // System provided internal filters for filtering internal // subtypes to text. @@ -453,3 +454,5 @@ static void open_blob(thread_db* tdbb, } } + +} // namespace Firebird::Jrd diff --git a/src/jrd/blob_filter.h b/src/jrd/blob_filter.h index 442f5f6867a..b8917967b2c 100644 --- a/src/jrd/blob_filter.h +++ b/src/jrd/blob_filter.h @@ -26,7 +26,9 @@ #include "../include/fb_blk.h" -namespace Jrd { +namespace Firebird::Jrd +{ + /* Note: The BlobControl class is the internal version of the * blob control structure (ISC_BLOB_CTL) which is in ibase.h. @@ -63,7 +65,7 @@ class BlobControl : public pool_alloc ISC_STATUS* ctl_status; // Address of status vector IPTR ctl_data[8]; // Application specific data void* ctl_internal[3]; // Firebird internal-use only - Firebird::string ctl_exception_message; // Message to use in case of filter exception + string ctl_exception_message; // Message to use in case of filter exception public: explicit BlobControl(MemoryPool& p) : ctl_exception_message(p) @@ -74,7 +76,6 @@ class BlobControl : public pool_alloc }; - // Blob filter management class BlobFilter : public pool_alloc @@ -84,7 +85,7 @@ class BlobFilter : public pool_alloc SSHORT blf_from; // Source sub-type SSHORT blf_to; // Target sub-type FPTR_BFILTER_CALLBACK blf_filter; // Entrypoint of filter - Firebird::string blf_exception_message; // message to be used in case of filter exception + string blf_exception_message; // message to be used in case of filter exception public: explicit BlobFilter(MemoryPool& p) : blf_exception_message(p) @@ -109,6 +110,7 @@ static const char* const EXCEPTION_MESSAGE = "The blob filter: \t\t%s\n" "\t in module: \t%s\n" "\tcaused the fatal exception:"; -} //namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_BLF_H diff --git a/src/jrd/btn.cpp b/src/jrd/btn.cpp index 44184e0dddb..ea0a11281de 100644 --- a/src/jrd/btn.cpp +++ b/src/jrd/btn.cpp @@ -30,8 +30,9 @@ #include "../jrd/ods.h" #include "../jrd/btn.h" -using namespace Jrd; -using namespace Ods; +namespace Firebird::Jrd +{ + USHORT IndexNode::computePrefix(const UCHAR* prevString, USHORT prevLength, const UCHAR* string, USHORT length) @@ -66,7 +67,7 @@ USHORT IndexNode::computePrefix(const UCHAR* prevString, USHORT prevLength, } -SLONG IndexNode::findPageInDuplicates(const btree_page* page, UCHAR* pointer, +SLONG IndexNode::findPageInDuplicates(const Ods::btree_page* page, UCHAR* pointer, SLONG previousNumber, RecordNumber findRecordNumber) { /************************************** @@ -629,3 +630,6 @@ UCHAR* IndexNode::writeNode(UCHAR* pagePointer, bool leafNode, bool withData) return pagePointer; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/btn.h b/src/jrd/btn.h index dc48eb6ba84..22ab4c10bcf 100644 --- a/src/jrd/btn.h +++ b/src/jrd/btn.h @@ -33,7 +33,9 @@ #include "../jrd/ods.h" #include "../common/classes/array.h" -namespace Jrd { +namespace Firebird::Jrd +{ + // Flags (3-bits) used for index node inline constexpr int BTN_NORMAL_FLAG = 0; @@ -276,6 +278,7 @@ struct IndexJumpNode UCHAR* writeJumpNode(UCHAR* pagePointer); }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_BTN_H diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 1767eda9b83..7aef527ba1f 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -66,9 +66,9 @@ #include "../jrd/tpc_proto.h" #include "../dsql/DdlNodes.h" -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ + //#define DEBUG_BTR_SPLIT @@ -89,8 +89,8 @@ namespace // // NO_VALUE_PAGE and NO_VALUE are the same constant, but with different size // Sign-extension mechanizm guaranties that they may be compared to each other safely - constexpr ULONG NO_VALUE_PAGE = END_LEVEL; - const RecordNumber NO_VALUE(END_LEVEL); + constexpr ULONG NO_VALUE_PAGE = Ods::END_LEVEL; + const RecordNumber NO_VALUE(Ods::END_LEVEL); // A split page will never have the number 0, because that's the value // of the main page. @@ -180,7 +180,7 @@ namespace struct FastLoadLevel { temporary_mini_key key; - btree_page* bucket; + Ods::btree_page* bucket; win_for_array window; ULONG splitPage; RecordNumber splitRecordNumber; @@ -224,24 +224,24 @@ static ULONG add_node(thread_db*, WIN*, index_insertion*, temporary_key*, Record ULONG*, ULONG*); static void compress(thread_db*, const dsc*, const SSHORT scale, temporary_key*, USHORT, bool, USHORT, bool*); -static USHORT compress_root(thread_db*, index_root_page*); +static USHORT compress_root(thread_db*, Ods::index_root_page*); static void copy_key(const temporary_mini_key*, temporary_mini_key*); static contents delete_node(thread_db*, WIN*, UCHAR*); static void delete_tree(thread_db*, MetaId, MetaId, PageNumber, PageNumber); static ULONG fast_load(thread_db*, IndexCreation&, SelectivityList&); -static const index_root_page* fetch_root(thread_db*, WIN*, const RelationPermanent*, const RelationPages*); -static UCHAR* find_node_start_point(btree_page*, temporary_key*, UCHAR*, USHORT*, +static const Ods::index_root_page* fetch_root(thread_db*, WIN*, const RelationPermanent*, const RelationPages*); +static UCHAR* find_node_start_point(Ods::btree_page*, temporary_key*, UCHAR*, USHORT*, bool, int, bool = false, RecordNumber = NO_VALUE); -static UCHAR* find_area_start_point(btree_page*, const temporary_key*, UCHAR*, +static UCHAR* find_area_start_point(Ods::btree_page*, const temporary_key*, UCHAR*, USHORT*, bool, int, RecordNumber = NO_VALUE); -static ULONG find_page(btree_page*, const temporary_key*, const index_desc*, RecordNumber = NO_VALUE, +static ULONG find_page(Ods::btree_page*, const temporary_key*, const index_desc*, RecordNumber = NO_VALUE, int = 0); static contents garbage_collect(thread_db*, WIN*, ULONG); -static void generate_jump_nodes(thread_db*, btree_page*, JumpNodeList*, USHORT, +static void generate_jump_nodes(thread_db*, Ods::btree_page*, JumpNodeList*, USHORT, USHORT*, USHORT*, USHORT*, USHORT); static ULONG insert_node(thread_db*, WIN*, index_insertion*, temporary_key*, @@ -257,7 +257,7 @@ static contents remove_leaf_node(thread_db*, index_insertion*, WIN*); static bool scan(thread_db*, UCHAR*, RecordBitmap**, RecordBitmap*, index_desc*, const IndexRetrieval*, USHORT, temporary_key*, bool&, const temporary_key&, USHORT); -static void update_selectivity(index_root_page*, MetaId, const SelectivityList&); +static void update_selectivity(Ods::index_root_page*, MetaId, const SelectivityList&); static void checkForLowerKeySkip(bool&, const bool, const IndexNode&, const temporary_key&, const index_desc&, const IndexRetrieval*); @@ -267,17 +267,17 @@ enum class ModifyIrtRepeatValue { Skip, Modified, Relock, Deleted }; class Flags { public: - static const char* state(const index_root_page::irt_repeat& rpt) + static const char* state(const Ods::index_root_page::irt_repeat& rpt) { switch (rpt.getState()) { - case irt_in_progress: return "irt_in_progress"; - case irt_commit: return "irt_commit"; - case irt_drop: return "irt_drop"; - case irt_rollback: return "irt_rollback"; - case irt_normal: return "irt_normal"; - case irt_kill: return "irt_kill"; - case irt_unused: return "irt_unused"; + case Ods::irt_in_progress: return "irt_in_progress"; + case Ods::irt_commit: return "irt_commit"; + case Ods::irt_drop: return "irt_drop"; + case Ods::irt_rollback: return "irt_rollback"; + case Ods::irt_normal: return "irt_normal"; + case Ods::irt_kill: return "irt_kill"; + case Ods::irt_unused: return "irt_unused"; } return "** UNKNOWN **"; @@ -286,7 +286,7 @@ class Flags #ifdef DEBUG_INDEX_ROOT -void dumpIndexRoot(const char* up, const char* from, thread_db* tdbb, WIN* window, const index_root_page* root) +void dumpIndexRoot(const char* up, const char* from, thread_db* tdbb, WIN* window, const Ods::index_root_page* root) { if (root->irt_relation > 127) { @@ -312,23 +312,23 @@ void dumpIndexRoot(...) { } #endif // DEBUG_INDEX_ROOT } -static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* irt_desc, +static bool checkIrtRepeat(thread_db* tdbb, const Ods::index_root_page::irt_repeat* irt_desc, Cached::Relation* relation, WIN* window, MetaId indexId); -static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::irt_repeat* irt_desc, +static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, Ods::index_root_page::irt_repeat* irt_desc, Cached::Relation* relation, WIN* window, MetaId indexId, bool fromActivate = false); -index_root_page* BTR_fetch_root_for_update(const char* from, thread_db* tdbb, WIN* window) +Ods::index_root_page* BTR_fetch_root_for_update(const char* from, thread_db* tdbb, WIN* window) { - index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, window, LCK_write, pag_root); + Ods::index_root_page* root = (Ods::index_root_page*) CCH_FETCH(tdbb, window, LCK_write, pag_root); dumpIndexRoot("Upd", from, tdbb, window, root); return root; } -const index_root_page* BTR_fetch_root(const char* from, thread_db* tdbb, WIN* window) +const Ods::index_root_page* BTR_fetch_root(const char* from, thread_db* tdbb, WIN* window) { - const index_root_page* root = (const index_root_page*) CCH_FETCH(tdbb, window, LCK_read, pag_root); + const Ods::index_root_page* root = (const Ods::index_root_page*) CCH_FETCH(tdbb, window, LCK_read, pag_root); dumpIndexRoot("", from, tdbb, window, root); @@ -539,7 +539,7 @@ TriState IndexCondition::evaluate(Record* record) const try { - Jrd::ContextPoolHolder context(m_tdbb, m_request->req_pool); + JrdContextPoolHolder context(m_tdbb, m_request->req_pool); result = m_condition->execute(m_tdbb, m_request).asBool(); } @@ -647,7 +647,7 @@ dsc* IndexExpression::evaluate(Record* record) const try { - Jrd::ContextPoolHolder context(m_tdbb, m_request->req_pool); + JrdContextPoolHolder context(m_tdbb, m_request->req_pool); result = EVL_expr(m_tdbb, m_request, m_expression); } @@ -776,7 +776,7 @@ idx_e IndexKey::compose(Record* record) if (stuff_count == 0) { *p++ = m_index->idx_count - n; - stuff_count = STUFF_COUNT; + stuff_count = Ods::STUFF_COUNT; if (p - m_key.key_data >= maxKeyLength) return idx_e_keytoobig; @@ -957,7 +957,7 @@ void BTR_all(thread_db* tdbb, Cached::Relation* relation, IndexDescList& idxList WIN window(relPages->rel_pg_space_id, -1); - const index_root_page* const root = fetch_root(tdbb, &window, relation, relPages); + const Ods::index_root_page* const root = fetch_root(tdbb, &window, relation, relPages); if (!root) return; @@ -967,19 +967,19 @@ void BTR_all(thread_db* tdbb, Cached::Relation* relation, IndexDescList& idxList for (MetaId id = 0; id < root->irt_count; id++) { - const index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; + const Ods::index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; const TraNumber descTrans = irt_desc->getTransaction(); switch (irt_desc->getState()) { - case irt_normal: + case Ods::irt_normal: break; - case irt_in_progress: // index creation - skip - case irt_drop: // index removal - skip + case Ods::irt_in_progress: // index creation - skip + case Ods::irt_drop: // index removal - skip continue; - case irt_rollback: // to be removed when irt_transaction dead + case Ods::irt_rollback: // to be removed when irt_transaction dead switch (indexCacheState(tdbb, descTrans, relation, id, true)) { case tra_unknown: // skip - index in unknown state @@ -988,7 +988,7 @@ void BTR_all(thread_db* tdbb, Cached::Relation* relation, IndexDescList& idxList } break; - case irt_commit: // change state on irt_transaction completion + case Ods::irt_commit: // change state on irt_transaction completion switch (indexCacheState(tdbb, descTrans, relation, id, false)) { case tra_unknown: // skip - index in unknown state @@ -1057,7 +1057,7 @@ void BTR_create(thread_db* tdbb, // Index is created. Go back to the index root page and update it to // point to the index. WIN window(relation->getPermanent()->getIndexRootPage(tdbb)); - index_root_page* const root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* const root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); CCH_MARK(tdbb, &window); switch(creation.forRollback) @@ -1096,11 +1096,11 @@ bool BTR_delete_index(thread_db* tdbb, WIN* window, MetaId id, bool withCleanup) CHECK_DBB(dbb); // Get index descriptor. If index doesn't exist, just leave. - index_root_page* const root = (index_root_page*) window->win_buffer; + Ods::index_root_page* const root = (Ods::index_root_page*) window->win_buffer; if (id < root->irt_count) { - index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; + Ods::index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; CCH_MARK(tdbb, window); const auto rootPage = irt_desc->getRoot(); @@ -1128,7 +1128,7 @@ bool BTR_delete_index(thread_db* tdbb, WIN* window, MetaId id, bool withCleanup) } -static void checkTransactionNumber(const index_root_page::irt_repeat* irt_desc, jrd_tra* tra, const char* msg) +static void checkTransactionNumber(const Ods::index_root_page::irt_repeat* irt_desc, jrd_tra* tra, const char* msg) { if (irt_desc->getTransaction() != tra->tra_number) { @@ -1138,14 +1138,14 @@ static void checkTransactionNumber(const index_root_page::irt_repeat* irt_desc, } -[[noreturn]] static void badState (const index_root_page::irt_repeat* irt_desc, const char* set, const char* msg) +[[noreturn]] static void badState (const Ods::index_root_page::irt_repeat* irt_desc, const char* set, const char* msg) { fb_assert(false); fatal_exception::raiseFmt("Invalid index state %s (%d, %s) when %s", Flags::state(*irt_desc), irt_desc->getState(), set, msg); } -void BTR_mark_index_for_delete(thread_db* tdbb, Cached::Relation* rel, MetaId id, WIN* window, index_root_page* root) +void BTR_mark_index_for_delete(thread_db* tdbb, Cached::Relation* rel, MetaId id, WIN* window, Ods::index_root_page* root) { /*********************************************************** * @@ -1196,27 +1196,27 @@ void BTR_mark_index_for_delete(thread_db* tdbb, Cached::Relation* rel, MetaId id switch (irt_desc->getState()) { - case irt_unused: - case irt_drop: // index alredy in process of deletion + case Ods::irt_unused: + case Ods::irt_drop: // index alredy in process of deletion break; - case irt_commit: + case Ods::irt_commit: if (tra->tra_number == irt_desc->getTransaction()) break; // already marked in current transaction [[fallthrough]]; - case irt_in_progress: - case irt_kill: + case Ods::irt_in_progress: + case Ods::irt_kill: badState(irt_desc, "not irt_rollback/irt_normal", msg); - case irt_rollback: // created not long ago + case Ods::irt_rollback: // created not long ago checkTransactionNumber(irt_desc, tra, msg); if (!marked) CCH_MARK(tdbb, window); irt_desc->setKill(tra->tra_number); break; - case irt_normal: + case Ods::irt_normal: if (!marked) CCH_MARK(tdbb, window); irt_desc->setCommit(tra->tra_number); @@ -1247,7 +1247,7 @@ bool BTR_activate_index(thread_db* tdbb, Cached::Relation* relation, MetaId id) CHECK_DBB(dbb); WIN window(relation->getIndexRootPage(tdbb)); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); bool rc = false; // Get index descriptor. If index doesn't exist, just leave. @@ -1285,17 +1285,17 @@ bool BTR_activate_index(thread_db* tdbb, Cached::Relation* relation, MetaId id) switch (irt_desc->getState()) { - case irt_unused: - case irt_drop: + case Ods::irt_unused: + case Ods::irt_drop: rc = false; break; - case irt_in_progress: - case irt_rollback: - case irt_normal: + case Ods::irt_in_progress: + case Ods::irt_rollback: + case Ods::irt_normal: badState(irt_desc, "irt_in_progress/irt_rollback/irt_normal", msg); - case irt_commit: // removed not long ago + case Ods::irt_commit: // removed not long ago checkTransactionNumber(irt_desc, tra, msg); if (!marked) CCH_MARK(tdbb, &window); @@ -1303,7 +1303,7 @@ bool BTR_activate_index(thread_db* tdbb, Cached::Relation* relation, MetaId id) rc = true; break; - case irt_kill: + case Ods::irt_kill: checkTransactionNumber(irt_desc, tra, msg); if (!marked) CCH_MARK(tdbb, &window); @@ -1319,7 +1319,7 @@ bool BTR_activate_index(thread_db* tdbb, Cached::Relation* relation, MetaId id) } -bool BTR_description(thread_db* tdbb, Cached::Relation* relation, const index_root_page* root, index_desc* idx, +bool BTR_description(thread_db* tdbb, Cached::Relation* relation, const Ods::index_root_page* root, index_desc* idx, MetaId id, bool raise) { /************************************** @@ -1338,7 +1338,7 @@ bool BTR_description(thread_db* tdbb, Cached::Relation* relation, const index_ro if (id >= root->irt_count) return false; - const index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id]; + const Ods::index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id]; const ULONG rootPage = irt_desc->getRoot(); if (!rootPage) @@ -1363,11 +1363,11 @@ bool BTR_description(thread_db* tdbb, Cached::Relation* relation, const index_ro index_desc::idx_repeat* idx_desc = idx->idx_rpt; for (int i = 0; i < idx->idx_count; i++, idx_desc++) { - const irtd* key_descriptor = (irtd*) ptr; + const Ods::irtd* key_descriptor = (Ods::irtd*) ptr; idx_desc->idx_field = key_descriptor->irtd_field; idx_desc->idx_itype = key_descriptor->irtd_itype; idx_desc->idx_selectivity = key_descriptor->irtd_selectivity; - ptr += sizeof(irtd); + ptr += sizeof(Ods::irtd); } idx->idx_selectivity = idx->idx_rpt[idx->idx_count - 1].idx_selectivity; @@ -1536,7 +1536,7 @@ void BTR_evaluate(thread_db* tdbb, const IndexRetrieval* retrieval, RecordBitmap return; index_desc idx; - btree_page* page = nullptr; + Ods::btree_page* page = nullptr; do { @@ -1558,7 +1558,7 @@ void BTR_evaluate(thread_db* tdbb, const IndexRetrieval* retrieval, RecordBitmap while (!(pointer = find_node_start_point(page, lower, 0, &prefix, descending, (retrieval->irb_generic & (irb_starting | irb_partial))))) { - page = (btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); } // Compute the number of matching characters in lower and upper bounds @@ -1588,7 +1588,7 @@ void BTR_evaluate(thread_db* tdbb, const IndexRetrieval* retrieval, RecordBitmap while (scan(tdbb, pointer, bitmap, bitmap_and, &idx, retrieval, prefix, upper, skipLowerKey, *lower, forceInclFlag)) { - page = (btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); pointer = page->btr_nodes + page->btr_jump_size; prefix = 0; } @@ -1640,7 +1640,7 @@ void BTR_evaluate(thread_db* tdbb, const IndexRetrieval* retrieval, RecordBitmap continue; } - page = (btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, &window, page->btr_sibling, LCK_read, pag_index); endPointer = (UCHAR*) page + page->btr_length; pointer = page->btr_nodes + page->btr_jump_size; pointer = node.readNode(pointer, true); @@ -1672,7 +1672,7 @@ void BTR_evaluate(thread_db* tdbb, const IndexRetrieval* retrieval, RecordBitmap } -UCHAR* BTR_find_leaf(btree_page* bucket, temporary_key* key, UCHAR* value, +UCHAR* BTR_find_leaf(Ods::btree_page* bucket, temporary_key* key, UCHAR* value, USHORT* return_value, bool descending, int retrieval) { /************************************** @@ -1691,7 +1691,7 @@ UCHAR* BTR_find_leaf(btree_page* bucket, temporary_key* key, UCHAR* value, } -btree_page* BTR_find_page(thread_db* tdbb, +Ods::btree_page* BTR_find_page(thread_db* tdbb, const IndexRetrieval* retrieval, WIN* window, index_desc* idx, @@ -1715,7 +1715,7 @@ btree_page* BTR_find_page(thread_db* tdbb, fb_assert(window->win_page.getPageSpaceID() == relPages->rel_pg_space_id); window->win_page = relPages->rel_index_root; - const index_root_page* rpage = BTR_fetch_root(FB_FUNCTION, tdbb, window); + const Ods::index_root_page* rpage = BTR_fetch_root(FB_FUNCTION, tdbb, window); if (!BTR_description(tdbb, retrieval->getPermRelation(), rpage, idx, retrieval->irb_index)) { @@ -1723,7 +1723,7 @@ btree_page* BTR_find_page(thread_db* tdbb, IBERROR(260); // msg 260 index unexpectedly deleted } - btree_page* page = (btree_page*) CCH_HANDOFF(tdbb, window, idx->idx_root, LCK_read, pag_index); + Ods::btree_page* page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, idx->idx_root, LCK_read, pag_index); // If there is a starting descriptor, search down index to starting position. // This may involve sibling buckets if splits are in progress. If there @@ -1752,13 +1752,13 @@ btree_page* BTR_find_page(thread_db* tdbb, const temporary_key* tkey = ignoreNulls ? &firstNotNullKey : lower; const ULONG number = find_page(page, tkey, idx, NO_VALUE, (retrieval->irb_generic & (irb_starting | irb_partial))); - if (number != END_BUCKET) + if (number != Ods::END_BUCKET) { - page = (btree_page*) CCH_HANDOFF(tdbb, window, number, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, number, LCK_read, pag_index); break; } - page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_read, pag_index); } } } @@ -1776,7 +1776,7 @@ btree_page* BTR_find_page(thread_db* tdbb, if (pointer > endPointer) BUGCHECK(204); // msg 204 index inconsistent - page = (btree_page*) CCH_HANDOFF(tdbb, window, node.pageNumber, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, node.pageNumber, LCK_read, pag_index); } } @@ -1801,7 +1801,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion) index_desc* idx = insertion->iib_descriptor; RelationPages* relPages = insertion->iib_relation->getPages(tdbb); WIN window(relPages->rel_pg_space_id, idx->idx_root); - btree_page* bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_index); + Ods::btree_page* bucket = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_index); UCHAR root_level = bucket->btr_level; if (bucket->btr_level == 0) @@ -1825,10 +1825,10 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion) // The top of the index has split. We need to make a new level and // update the index root page. Oh boy. - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, root_window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, root_window); window.win_page = root->irt_rpt[idx->idx_id].getRoot(); - bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); if (window.win_page.getPageNum() != idx->idx_root) { @@ -1878,7 +1878,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion) } window.win_page = root->irt_rpt[idx->idx_id].getRoot(); - bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); key.key_length = ret_key.key_length; memcpy(key.key_data, ret_key.key_data, ret_key.key_length); key.key_flags = ret_key.key_flags; @@ -1892,7 +1892,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion) lock.enablePageGC(tdbb); WIN new_window(relPages->rel_pg_space_id, split_page); - btree_page* new_bucket = (btree_page*) CCH_FETCH(tdbb, &new_window, LCK_read, pag_index); + Ods::btree_page* new_bucket = (Ods::btree_page*) CCH_FETCH(tdbb, &new_window, LCK_read, pag_index); if (bucket->btr_level != new_bucket->btr_level) { @@ -1924,7 +1924,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion) } // Allocate and format new bucket, this will always be a non-leaf page - new_bucket = (btree_page*) DPM_allocate(tdbb, &new_window); + new_bucket = (Ods::btree_page*) DPM_allocate(tdbb, &new_window); CCH_precedence(tdbb, &new_window, window.win_page); new_bucket->btr_header.pag_type = pag_index; @@ -2100,7 +2100,7 @@ USHORT BTR_key_length(thread_db* tdbb, jrd_rel* relation, index_desc* idx) break; } - key_length += ((length + prefix + STUFF_COUNT - 1) / STUFF_COUNT) * (STUFF_COUNT + 1); + key_length += ((length + prefix + Ods::STUFF_COUNT - 1) / Ods::STUFF_COUNT) * (Ods::STUFF_COUNT + 1); } return key_length; @@ -2123,7 +2123,7 @@ bool BTR_lookup(thread_db* tdbb, Cached::Relation* relation, MetaId id, index_de SET_TDBB(tdbb); WIN window(relPages->rel_pg_space_id, -1); - const index_root_page* const root = fetch_root(tdbb, &window, relation, relPages); + const Ods::index_root_page* const root = fetch_root(tdbb, &window, relation, relPages); if (!root) return false; @@ -2333,7 +2333,7 @@ idx_e BTR_make_key(thread_db* tdbb, if (stuff_count == 0) { *p++ = idx->idx_count - n; - stuff_count = STUFF_COUNT; + stuff_count = Ods::STUFF_COUNT; if (p - current_key->key_data >= maxKeyLength) return idx_e_keytoobig; @@ -2456,7 +2456,7 @@ void BTR_make_null_key(thread_db* tdbb, const index_desc* idx, temporary_key* ke if (stuff_count == 0) { *p++ = idx->idx_count - n; - stuff_count = STUFF_COUNT; + stuff_count = Ods::STUFF_COUNT; } *p++ = *q++; } @@ -2476,7 +2476,7 @@ void BTR_make_null_key(thread_db* tdbb, const index_desc* idx, temporary_key* ke // checks is there a need to modify index descriptor // if yes - we release index root window -static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* irt_desc, +static bool checkIrtRepeat(thread_db* tdbb, const Ods::index_root_page::irt_repeat* irt_desc, Cached::Relation* relation, WIN* window, MetaId indexId) { const TraNumber irtTrans = irt_desc->getTransaction(); @@ -2484,12 +2484,12 @@ static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* i switch (irt_desc->getState()) { - case irt_unused: - case irt_normal: + case Ods::irt_unused: + case Ods::irt_normal: // normal processing return false; - case irt_in_progress: + case Ods::irt_in_progress: // index creation - should wait to know what to do CCH_RELEASE(tdbb, window); @@ -2500,9 +2500,9 @@ static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* i } break; - case irt_rollback: - case irt_commit: - case irt_kill: + case Ods::irt_rollback: + case Ods::irt_commit: + case Ods::irt_kill: // this three states require modification if irtTrans is completed switch (TPC_cache_state(tdbb, irtTrans)) { @@ -2516,7 +2516,7 @@ static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* i CCH_RELEASE(tdbb, window); break; - case irt_drop: + case Ods::irt_drop: // drop index when OAT >= irtTrans if (oldestActive < irtTrans) return false; @@ -2535,7 +2535,7 @@ static bool checkIrtRepeat(thread_db* tdbb, const index_root_page::irt_repeat* i // checks is there a need to modify index descriptor // if yes - modifies it up to index deletion -static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::irt_repeat* irt_desc, +static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, Ods::index_root_page::irt_repeat* irt_desc, Cached::Relation* relation, WIN* window, MetaId indexId, bool fromActivate) { const TraNumber irtTrans = irt_desc->getTransaction(); @@ -2543,12 +2543,12 @@ static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::ir switch (irt_desc->getState()) { - case irt_unused: - case irt_normal: + case Ods::irt_unused: + case Ods::irt_normal: // normal processing return ModifyIrtRepeatValue::Skip; - case irt_in_progress: + case Ods::irt_in_progress: // index creation - should wait to know what to do CCH_RELEASE(tdbb, window); @@ -2560,7 +2560,7 @@ static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::ir return ModifyIrtRepeatValue::Relock; - case irt_rollback: + case Ods::irt_rollback: switch (transactionState(tdbb, irtTrans, relation, indexId, true)) { case tra_committed: // switch to normal state @@ -2576,7 +2576,7 @@ static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::ir } break; - case irt_kill: + case Ods::irt_kill: switch (TPC_cache_state(tdbb, irtTrans)) { case tra_committed: @@ -2588,7 +2588,7 @@ static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::ir } break; - case irt_commit: + case Ods::irt_commit: switch (transactionState(tdbb, irtTrans, relation, indexId, false)) { case tra_committed: // switch to drop state @@ -2609,7 +2609,7 @@ static ModifyIrtRepeatValue modifyIrtRepeat(thread_db* tdbb, index_root_page::ir fb_assert(false); return ModifyIrtRepeatValue::Skip; - case irt_drop: + case Ods::irt_drop: // drop index when OAT >= irtTrans if (oldestActive >= irtTrans) break; @@ -2650,9 +2650,9 @@ bool BTR_next_index(thread_db* tdbb, Cached::Relation* relation, jrd_tra* transa else id = idx->idx_id + 1; - const index_root_page* root; + const Ods::index_root_page* root; if (window->win_bdb) - root = (const index_root_page*) window->win_buffer; + root = (const Ods::index_root_page*) window->win_buffer; else { RelationPages* const relPages = transaction ? @@ -2666,7 +2666,7 @@ bool BTR_next_index(thread_db* tdbb, Cached::Relation* relation, jrd_tra* transa { for (; id < root->irt_count; ++id) { - const index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; + const Ods::index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; if (checkIrtRepeat(tdbb, irt_desc, relation, window, id)) { @@ -2726,11 +2726,11 @@ bool BTR_cleanup_index(thread_db* tdbb, const QualifiedName& relName, jrd_tra* t relation->getPages(tdbb, transaction->tra_number) : relation->getPages(tdbb); WIN window(relPages->rel_pg_space_id, -1); - const index_root_page* root = fetch_root(tdbb, &window, relation, relPages); + const Ods::index_root_page* root = fetch_root(tdbb, &window, relation, relPages); if (!root) return false; - const index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; + const Ods::index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; bool rc = false; if (checkIrtRepeat(tdbb, irt_desc, relation, &window, id)) { @@ -2742,7 +2742,7 @@ bool BTR_cleanup_index(thread_db* tdbb, const QualifiedName& relName, jrd_tra* t { case ModifyIrtRepeatValue::Skip: case ModifyIrtRepeatValue::Modified: - if (irt_write->getState() == irt_drop) + if (irt_write->getState() == Ods::irt_drop) rc = true; CCH_RELEASE(tdbb, &window); break; @@ -2780,7 +2780,7 @@ void BTR_remove(thread_db* tdbb, WIN* root_window, index_insertion* insertion) index_desc* idx = insertion->iib_descriptor; RelationPages* relPages = insertion->iib_relation->getPages(tdbb); WIN window(relPages->rel_pg_space_id, idx->idx_root); - btree_page* page = (btree_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_index); + Ods::btree_page* page = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_index); // If the page is level 0, re-fetch it for write const UCHAR level = page->btr_level; @@ -2806,8 +2806,8 @@ void BTR_remove(thread_db* tdbb, WIN* root_window, index_insertion* insertion) CCH_RELEASE(tdbb, &window); CCH_RELEASE(tdbb, root_window); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, root_window); - page = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, root_window); + page = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index); // get the page number of the child, and check to make sure // the page still has only one node on it @@ -2833,7 +2833,7 @@ void BTR_remove(thread_db* tdbb, WIN* root_window, index_insertion* insertion) CCH_RELEASE(tdbb, root_window); CCH_MARK(tdbb, &window); - page->btr_header.pag_flags |= btr_released; + page->btr_header.pag_flags |= Ods::btr_released; CCH_RELEASE(tdbb, &window); PAG_release_page(tdbb, window.win_page, root_window->win_page); @@ -2885,7 +2885,7 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation, IndexCreateLock& fb_assert(idx->idx_id <= dbb->dbb_max_idx); WIN window(relPages->rel_pg_space_id, relPages->rel_index_root); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); CCH_MARK(tdbb, &window); // check that we create no more indexes than will fit on a single root page @@ -2902,24 +2902,24 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation, IndexCreateLock& if (use_idx_id && (idx->idx_id >= root->irt_count)) { memset(root->irt_rpt + root->irt_count, 0, - sizeof(index_root_page::irt_repeat) * (idx->idx_id - root->irt_count + 1)); + sizeof(Ods::index_root_page::irt_repeat) * (idx->idx_id - root->irt_count + 1)); root->irt_count = idx->idx_id + 1; } UCHAR* desc = 0; USHORT len, space; - index_root_page::irt_repeat* slot = NULL; - index_root_page::irt_repeat* end = NULL; + Ods::index_root_page::irt_repeat* slot = NULL; + Ods::index_root_page::irt_repeat* end = NULL; for (int retry = 0; retry < 2; ++retry) { - len = idx->idx_count * sizeof(irtd); + len = idx->idx_count * sizeof(Ods::irtd); space = dbb->dbb_page_size; slot = NULL; end = root->irt_rpt + root->irt_count; - for (index_root_page::irt_repeat* root_idx = root->irt_rpt; root_idx < end; root_idx++) + for (Ods::index_root_page::irt_repeat* root_idx = root->irt_rpt; root_idx < end; root_idx++) { if (root_idx->isUsed()) space = MIN(space, root_idx->irt_desc); @@ -2998,7 +2998,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel RelationPages* relPages = relation->getPages(tdbb); WIN window(relPages->rel_pg_space_id, -1); - const index_root_page* root = fetch_root(tdbb, &window, relation, relPages); + const Ods::index_root_page* root = fetch_root(tdbb, &window, relation, relPages); if (!root) return; @@ -3009,12 +3009,12 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel } ULONG page = root->irt_rpt[id].getRoot(); - const bool descending = (root->irt_rpt[id].irt_flags & irt_descending); + const bool descending = (root->irt_rpt[id].irt_flags & Ods::irt_descending); const ULONG segments = root->irt_rpt[id].irt_keys; window.win_flags = WIN_large_scan; window.win_scans = 1; - btree_page* bucket = (btree_page*) CCH_HANDOFF(tdbb, &window, page, LCK_read, pag_index); + Ods::btree_page* bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, &window, page, LCK_read, pag_index); // go down the left side of the index to leaf level UCHAR* pointer = bucket->btr_nodes + bucket->btr_jump_size; @@ -3022,7 +3022,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel { IndexNode pageNode; pageNode.readNode(pointer, false); - bucket = (btree_page*) CCH_HANDOFF(tdbb, &window, pageNode.pageNumber, LCK_read, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, &window, pageNode.pageNumber, LCK_read, pag_index); pointer = bucket->btr_nodes + bucket->btr_jump_size; page = pageNode.pageNumber; } @@ -3080,7 +3080,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel { const SSHORT pos = node.prefix; // find the segment number were we're starting. - const SSHORT i = (pos / (STUFF_COUNT + 1)) * (STUFF_COUNT + 1); + const SSHORT i = (pos / (Ods::STUFF_COUNT + 1)) * (Ods::STUFF_COUNT + 1); if (i == pos) { // We _should_ pick number from data if available @@ -3090,7 +3090,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel count = *(p1 + i); // update stuff_count to the current position. - stuff_count = STUFF_COUNT + 1 - (pos - i); + stuff_count = Ods::STUFF_COUNT + 1 - (pos - i); p1 += pos; } @@ -3107,7 +3107,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel count = *p2; p1++; p2++; - stuff_count = STUFF_COUNT; + stuff_count = Ods::STUFF_COUNT; } if (*p1 != *p2) @@ -3156,7 +3156,7 @@ void BTR_selectivity(thread_db* tdbb, Cached::Relation* relation, MetaId id, Sel if (node.isEndLevel || !(page = bucket->btr_sibling)) break; - bucket = (btree_page*) CCH_HANDOFF_TAIL(tdbb, &window, page, LCK_read, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF_TAIL(tdbb, &window, page, LCK_read, pag_index); pointer = bucket->btr_nodes + bucket->btr_jump_size; } @@ -3253,7 +3253,7 @@ static ULONG add_node(thread_db* tdbb, **************************************/ SET_TDBB(tdbb); - btree_page* bucket = (btree_page*) window->win_buffer; + Ods::btree_page* bucket = (Ods::btree_page*) window->win_buffer; // For leaf level guys, loop thru the leaf buckets until insertion // point is found (should be instant) @@ -3267,7 +3267,7 @@ static ULONG add_node(thread_db* tdbb, if (split != NO_VALUE_PAGE) return split; - bucket = (btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_write, pag_index); } } @@ -3280,10 +3280,10 @@ static ULONG add_node(thread_db* tdbb, page = find_page(bucket, insertion->iib_key, insertion->iib_descriptor, insertion->iib_number); - if (page != END_BUCKET) + if (page != Ods::END_BUCKET) break; - bucket = (btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_read, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_read, pag_index); } BtrPageGCLock lockCurrent(tdbb); @@ -3322,7 +3322,7 @@ static ULONG add_node(thread_db* tdbb, // The page at the lower level split, so we need to insert a pointer // to the new page to the page at this level. window->win_page = index; - bucket = (btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index); propagate.iib_number = RecordNumber(split); propagate.iib_descriptor = insertion->iib_descriptor; @@ -3343,7 +3343,7 @@ static ULONG add_node(thread_db* tdbb, if (split != NO_VALUE_PAGE) break; - bucket = (btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, LCK_write, pag_index); } // the split page on the lower level has been propagated, so we can go back to @@ -3917,7 +3917,7 @@ static void compress(thread_db* tdbb, } -static USHORT compress_root(thread_db* tdbb, index_root_page* page) +static USHORT compress_root(thread_db* tdbb, Ods::index_root_page* page) { /************************************** * @@ -3938,13 +3938,13 @@ static USHORT compress_root(thread_db* tdbb, index_root_page* page) memcpy(temp, page, dbb->dbb_page_size); UCHAR* p = (UCHAR*) page + dbb->dbb_page_size; - index_root_page::irt_repeat* root_idx = page->irt_rpt; - for (const index_root_page::irt_repeat* const end = root_idx + page->irt_count; + Ods::index_root_page::irt_repeat* root_idx = page->irt_rpt; + for (const Ods::index_root_page::irt_repeat* const end = root_idx + page->irt_count; root_idx < end; root_idx++) { if (root_idx->getRoot()) { - const USHORT len = root_idx->irt_keys * sizeof(irtd); + const USHORT len = root_idx->irt_keys * sizeof(Ods::irtd); p -= len; memcpy(p, temp + root_idx->irt_desc, len); root_idx->irt_desc = p - (UCHAR*) page; @@ -3993,7 +3993,7 @@ static contents delete_node(thread_db* tdbb, WIN* window, UCHAR* pointer) const Database* dbb = tdbb->getDatabase(); CHECK_DBB(dbb); - btree_page* page = (btree_page*) window->win_buffer; + Ods::btree_page* page = (Ods::btree_page*) window->win_buffer; CCH_MARK(tdbb, window); @@ -4291,7 +4291,7 @@ static void delete_tree(thread_db* tdbb, while (next.getPageNum()) { window.win_page = next; - btree_page* page = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, 0); + Ods::btree_page* page = (Ods::btree_page*) CCH_FETCH(tdbb, &window, LCK_write, 0); // do a little defensive programming--if any of these conditions // are true we have a damaged pointer, so just stop deleting. At @@ -4420,7 +4420,7 @@ static ULONG fast_load(thread_db* tdbb, // of the id and hope for the best. Index buckets are (almost) always // located through the index structure (dmp being an exception used // only for debug) so the id is actually redundant. - btree_page* bucket = (btree_page*) DPM_allocate(tdbb, &leafLevel->window); + Ods::btree_page* bucket = (Ods::btree_page*) DPM_allocate(tdbb, &leafLevel->window); bucket->btr_header.pag_type = pag_index; bucket->btr_relation = relation->getId(); bucket->btr_id = (UCHAR)(idx->idx_id % 256); @@ -4554,7 +4554,7 @@ static ULONG fast_load(thread_db* tdbb, BUGCHECK(205); // msg 205 index bucket overfilled // Allocate new bucket. - btree_page* split = (btree_page*) DPM_allocate(tdbb, &split_window); + Ods::btree_page* split = (Ods::btree_page*) DPM_allocate(tdbb, &split_window); bucket->btr_sibling = split_window.win_page.getPageNum(); split->btr_left_sibling = leafLevel->window.win_page.getPageNum(); split->btr_header.pag_type = pag_index; @@ -4639,7 +4639,7 @@ static ULONG fast_load(thread_db* tdbb, { const SSHORT pos = newNode.prefix; // find the segment number were we're starting. - const SSHORT i = (pos / (STUFF_COUNT + 1)) * (STUFF_COUNT + 1); + const SSHORT i = (pos / (Ods::STUFF_COUNT + 1)) * (Ods::STUFF_COUNT + 1); if (i == pos) { // We _should_ pick number from data if available @@ -4649,7 +4649,7 @@ static ULONG fast_load(thread_db* tdbb, segment = *(p1 + i); // update stuff_count to the current position. - stuff_count = STUFF_COUNT + 1 - (pos - i); + stuff_count = Ods::STUFF_COUNT + 1 - (pos - i); p1 += pos; } @@ -4666,7 +4666,7 @@ static ULONG fast_load(thread_db* tdbb, segment = *p2; p1++; p2++; - stuff_count = STUFF_COUNT; + stuff_count = Ods::STUFF_COUNT; } if (*p1 != *p2) @@ -4776,7 +4776,7 @@ static ULONG fast_load(thread_db* tdbb, // Initialize new level currLevel->window.win_page.setPageSpaceID(pageSpaceID); - currLevel->bucket = bucket = (btree_page*) DPM_allocate(tdbb, window); + currLevel->bucket = bucket = (Ods::btree_page*) DPM_allocate(tdbb, window); bucket->btr_header.pag_type = pag_index; bucket->btr_relation = relation->getId(); bucket->btr_id = (UCHAR)(idx->idx_id % 256); @@ -4870,7 +4870,7 @@ static ULONG fast_load(thread_db* tdbb, if (bucket->btr_length > dbb->dbb_page_size) BUGCHECK(205); // msg 205 index bucket overfilled - btree_page* split = (btree_page*) DPM_allocate(tdbb, &split_window); + Ods::btree_page* split = (Ods::btree_page*) DPM_allocate(tdbb, &split_window); bucket->btr_sibling = split_window.win_page.getPageNum(); split->btr_left_sibling = window->win_page.getPageNum(); split->btr_header.pag_type = pag_index; @@ -5120,7 +5120,7 @@ static ULONG fast_load(thread_db* tdbb, } -static const index_root_page* fetch_root(thread_db* tdbb, WIN* window, const RelationPermanent* relation, +static const Ods::index_root_page* fetch_root(thread_db* tdbb, WIN* window, const RelationPermanent* relation, const RelationPages* relPages) { /************************************** @@ -5154,7 +5154,7 @@ static const index_root_page* fetch_root(thread_db* tdbb, WIN* window, const Rel } -static UCHAR* find_node_start_point(btree_page* bucket, temporary_key* key, +static UCHAR* find_node_start_point(Ods::btree_page* bucket, temporary_key* key, UCHAR* value, USHORT* return_value, bool descending, int retrieval, bool pointer_by_marker, @@ -5241,7 +5241,7 @@ static UCHAR* find_node_start_point(btree_page* bucket, temporary_key* key, if ((retrieval & irb_partial) && !(retrieval & irb_starting)) { // check segment - const bool sameSegment = ((p - STUFF_COUNT > key->key_data) && p[-(STUFF_COUNT + 1)] == *q); + const bool sameSegment = ((p - Ods::STUFF_COUNT > key->key_data) && p[-(Ods::STUFF_COUNT + 1)] == *q); if (sameSegment) break; } @@ -5304,7 +5304,7 @@ static UCHAR* find_node_start_point(btree_page* bucket, temporary_key* key, } -static UCHAR* find_area_start_point(btree_page* bucket, const temporary_key* key, +static UCHAR* find_area_start_point(Ods::btree_page* bucket, const temporary_key* key, UCHAR* value, USHORT* return_prefix, bool descending, int retrieval, RecordNumber find_record_number) @@ -5416,7 +5416,7 @@ static UCHAR* find_area_start_point(btree_page* bucket, const temporary_key* key if ((retrieval & irb_partial) && !(retrieval & irb_starting)) { // check segment - const bool sameSegment = ((keyPointer - STUFF_COUNT > key->key_data) && keyPointer[-(STUFF_COUNT + 1)] == *q); + const bool sameSegment = ((keyPointer - Ods::STUFF_COUNT > key->key_data) && keyPointer[-(Ods::STUFF_COUNT + 1)] == *q); if (!sameSegment) done = true; } @@ -5528,7 +5528,7 @@ static UCHAR* find_area_start_point(btree_page* bucket, const temporary_key* key } -static ULONG find_page(btree_page* bucket, const temporary_key* key, +static ULONG find_page(Ods::btree_page* bucket, const temporary_key* key, const index_desc* idx, RecordNumber find_record_number, int retrieval) { @@ -5723,7 +5723,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe CHECK_DBB(dbb); const USHORT pageSpaceID = window->win_page.getPageSpaceID(); - btree_page* gc_page = (btree_page*) window->win_buffer; + Ods::btree_page* gc_page = (Ods::btree_page*) window->win_buffer; contents result = contents_above_threshold; // check to see if the page was marked not to be garbage collected @@ -5770,7 +5770,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe // released and reused already as another page on this level, but if so, it // won't really matter because we won't find the node on it WIN parent_window(pageSpaceID, parent_number); - btree_page* parent_page = (btree_page*) CCH_FETCH(tdbb, &parent_window, LCK_write, pag_undefined); + Ods::btree_page* parent_page = (Ods::btree_page*) CCH_FETCH(tdbb, &parent_window, LCK_write, pag_undefined); if ((parent_page->btr_header.pag_type != pag_index) || (parent_page->btr_relation != relation_number) || (parent_page->btr_id != (UCHAR)(index_id % 256)) || @@ -5780,7 +5780,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe return contents_above_threshold; } - if (parent_page->btr_header.pag_flags & btr_released) + if (parent_page->btr_header.pag_flags & Ods::btr_released) { CCH_RELEASE(tdbb, &parent_window); #ifdef DEBUG_BTR @@ -5798,7 +5798,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe parentPointer = parentNode.readNode(parentPointer, false); if (parentNode.isEndBucket) { - parent_page = (btree_page*) CCH_HANDOFF(tdbb, &parent_window, + parent_page = (Ods::btree_page*) CCH_HANDOFF(tdbb, &parent_window, parent_page->btr_sibling, LCK_write, pag_index); parentPointer = parent_page->btr_nodes + parent_page->btr_jump_size; continue; @@ -5842,7 +5842,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe // going to the right until we find the page that is our real // left sibling WIN left_window(pageSpaceID, left_number); - btree_page* left_page = (btree_page*) CCH_FETCH(tdbb, &left_window, LCK_write, pag_undefined); + Ods::btree_page* left_page = (Ods::btree_page*) CCH_FETCH(tdbb, &left_window, LCK_write, pag_undefined); if (left_page->btr_header.pag_type != pag_index || left_page->btr_relation != relation_number || left_page->btr_id != UCHAR(index_id % 256) || @@ -5853,7 +5853,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe return contents_above_threshold; } - if (left_page->btr_header.pag_flags & btr_released) + if (left_page->btr_header.pag_flags & Ods::btr_released) { CCH_RELEASE(tdbb, &parent_window); CCH_RELEASE(tdbb, &left_window); @@ -5880,13 +5880,13 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe CCH_RELEASE(tdbb, &left_window); return contents_above_threshold; } - left_page = (btree_page*) CCH_HANDOFF(tdbb, &left_window, + left_page = (Ods::btree_page*) CCH_HANDOFF(tdbb, &left_window, left_page->btr_sibling, LCK_write, pag_index); } // now refetch the original page and make sure it is still // below the threshold for garbage collection. - gc_page = (btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index); + gc_page = (Ods::btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index); if (gc_page->btr_length >= GARBAGE_COLLECTION_BELOW_THRESHOLD || !BtrPageGCLock::isPageGCAllowed(tdbb, window->win_page)) { @@ -5896,7 +5896,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe return contents_above_threshold; } - if (gc_page->btr_header.pag_flags & btr_released) + if (gc_page->btr_header.pag_flags & Ods::btr_released) { CCH_RELEASE(tdbb, &parent_window); CCH_RELEASE(tdbb, &left_window); @@ -5909,12 +5909,12 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe } // fetch the right sibling page - btree_page* right_page = NULL; + Ods::btree_page* right_page = NULL; WIN right_window(pageSpaceID, gc_page->btr_sibling); if (right_window.win_page.getPageNum()) { // right_window.win_flags = 0; redundant, made by the constructor - right_page = (btree_page*) CCH_FETCH(tdbb, &right_window, LCK_write, pag_index); + right_page = (Ods::btree_page*) CCH_FETCH(tdbb, &right_window, LCK_write, pag_index); if (right_page->btr_left_sibling != window->win_page.getPageNum()) { @@ -6010,7 +6010,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe // First copy left page to scratch page. SLONG scratchPage[OVERSIZE]; - btree_page* const newBucket = (btree_page*) scratchPage; + Ods::btree_page* const newBucket = (Ods::btree_page*) scratchPage; pointer = left_page->btr_nodes; const USHORT jumpersOriginalSize = left_page->btr_jump_size; @@ -6169,7 +6169,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe // finally, release the page, and indicate that we should write the // previous page out before we write the TIP page out CCH_MARK(tdbb, window); - gc_page->btr_header.pag_flags |= btr_released; + gc_page->btr_header.pag_flags |= Ods::btr_released; CCH_RELEASE(tdbb, window); PAG_release_page(tdbb, window->win_page, left_page ? left_window.win_page : @@ -6184,7 +6184,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe if (result != contents_above_threshold) { window->win_page = parent_window.win_page; - parent_page = (btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_undefined); + parent_page = (Ods::btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_undefined); if ((parent_page->btr_header.pag_type != pag_index) || (parent_page->btr_relation != relation_number) || (parent_page->btr_id != index_id) || @@ -6220,7 +6220,7 @@ static contents garbage_collect(thread_db* tdbb, WIN* window, ULONG parent_numbe } -static void generate_jump_nodes(thread_db* tdbb, btree_page* page, +static void generate_jump_nodes(thread_db* tdbb, Ods::btree_page* page, JumpNodeList* jumpNodes, USHORT excludeOffset, USHORT* jumpersSize, USHORT* splitIndex, USHORT* splitPrefix, USHORT keyLen) @@ -6382,7 +6382,7 @@ static ULONG insert_node(thread_db* tdbb, const USHORT pageSpaceID = window->win_page.getPageSpaceID(); // find the insertion point for the specified key - btree_page* bucket = (btree_page*) window->win_buffer; + Ods::btree_page* bucket = (Ods::btree_page*) window->win_buffer; temporary_key* key = insertion->iib_key; const index_desc* const idx = insertion->iib_descriptor; @@ -6518,7 +6518,7 @@ static ULONG insert_node(thread_db* tdbb, // Copy data up to insert point to scratch page. SLONG scratchPage[OVERSIZE]; memcpy(scratchPage, bucket, nodeOffset); - btree_page* const newBucket = (btree_page*) scratchPage; + Ods::btree_page* const newBucket = (Ods::btree_page*) scratchPage; // Set pointer of new node to right place. pointer = ((UCHAR*) newBucket + nodeOffset); @@ -6802,7 +6802,7 @@ static ULONG insert_node(thread_db* tdbb, // Allocate and format the overflow page WIN split_window(pageSpaceID, -1); - btree_page* split = (btree_page*) DPM_allocate(tdbb, &split_window); + Ods::btree_page* split = (Ods::btree_page*) DPM_allocate(tdbb, &split_window); // if we're a pointer page, make sure the child page is written first if (!leafPage) @@ -6945,7 +6945,7 @@ static ULONG insert_node(thread_db* tdbb, // left sibling pointer to point to the newly split page if (right_sibling) { - bucket = (btree_page*) CCH_HANDOFF(tdbb, window, right_sibling, LCK_write, pag_index); + bucket = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, right_sibling, LCK_write, pag_index); CCH_MARK(tdbb, window); bucket->btr_left_sibling = split_window.win_page.getPageNum(); } @@ -7127,7 +7127,7 @@ static contents remove_node(thread_db* tdbb, index_insertion* insertion, WIN* wi SET_TDBB(tdbb); //const Database* dbb = tdbb->getDatabase(); index_desc* idx = insertion->iib_descriptor; - btree_page* page = (btree_page*) window->win_buffer; + Ods::btree_page* page = (Ods::btree_page*) window->win_buffer; // if we are on a leaf page, remove the leaf node if (page->btr_level == 0) { @@ -7139,7 +7139,7 @@ static contents remove_node(thread_db* tdbb, index_insertion* insertion, WIN* wi const ULONG number = find_page(page, insertion->iib_key, idx, insertion->iib_number); // we should always find the node, but let's make sure - if (number == END_LEVEL) + if (number == Ods::END_LEVEL) { CCH_RELEASE(tdbb, window); #ifdef DEBUG_BTR @@ -7150,12 +7150,12 @@ static contents remove_node(thread_db* tdbb, index_insertion* insertion, WIN* wi // recurse to the next level down; if we are about to fetch a // level 0 page, make sure we fetch it for write - if (number != END_BUCKET) + if (number != Ods::END_BUCKET) { // handoff down to the next level, retaining the parent page number const ULONG parent_number = window->win_page.getPageNum(); - page = (btree_page*) CCH_HANDOFF(tdbb, window, number, (SSHORT) + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, number, (SSHORT) ((page->btr_level == 1) ? LCK_write : LCK_read), pag_index); // if the removed node caused the page to go below the garbage collection @@ -7173,7 +7173,7 @@ static contents remove_node(thread_db* tdbb, index_insertion* insertion, WIN* wi } // we've hit end of bucket, so go to the sibling looking for the node - page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_read, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_read, pag_index); } // NOTREACHED @@ -7194,7 +7194,7 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI * **************************************/ SET_TDBB(tdbb); - btree_page* page = (btree_page*) window->win_buffer; + Ods::btree_page* page = (Ods::btree_page*) window->win_buffer; temporary_key* key = insertion->iib_key; const index_desc* const idx = insertion->iib_descriptor; @@ -7211,7 +7211,7 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI false, false, (validateDuplicates ? NO_VALUE : insertion->iib_number)))) { - page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); } // Make sure first node looks ok @@ -7281,7 +7281,7 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI // if we hit the end of bucket, go to the right sibling page, // and check that the first node is a duplicate ++pages; - page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); + page = (Ods::btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); pointer = page->btr_nodes + page->btr_jump_size; pointer = node.readNode(pointer, true); @@ -7349,7 +7349,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB if ((flag & irb_partial) && (flag & irb_equality) && !(flag & irb_starting) && !(flag & irb_descending)) { - count = STUFF_COUNT - ((key->key_length + STUFF_COUNT) % (STUFF_COUNT + 1)); + count = Ods::STUFF_COUNT - ((key->key_length + Ods::STUFF_COUNT) % (Ods::STUFF_COUNT + 1)); for (ULONG i = 0; i < count; i++) key->key_data[key->key_length + i] = 0; @@ -7412,7 +7412,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB else if (node.prefix <= prefix) { prefix = node.prefix; - USHORT byteInSegment = prefix % (STUFF_COUNT + 1); + USHORT byteInSegment = prefix % (Ods::STUFF_COUNT + 1); p = key->key_data + prefix; const UCHAR* q = node.data; USHORT l = node.length; @@ -7432,7 +7432,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB return false; } - if (++byteInSegment > STUFF_COUNT) + if (++byteInSegment > Ods::STUFF_COUNT) byteInSegment = 0; } @@ -7449,7 +7449,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB if ((flag & irb_partial) && !(flag & irb_starting)) { - if ((p - STUFF_COUNT > key->key_data) && (p[-(STUFF_COUNT + 1)] == *q)) + if ((p - Ods::STUFF_COUNT > key->key_data) && (p[-(Ods::STUFF_COUNT + 1)] == *q)) { if (descending) break; @@ -7543,7 +7543,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB } -void update_selectivity(index_root_page* root, MetaId id, const SelectivityList& selectivity) +void update_selectivity(Ods::index_root_page* root, MetaId id, const SelectivityList& selectivity) { /************************************** * @@ -7557,12 +7557,12 @@ void update_selectivity(index_root_page* root, MetaId id, const SelectivityList& **************************************/ //const Database* dbb = GET_DBB(); - index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id]; + Ods::index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id]; const USHORT idx_count = irt_desc->irt_keys; fb_assert(selectivity.getCount() == idx_count); // dimitr: per-segment selectivities exist only for ODS11 and above - irtd* key_descriptor = (irtd*) ((UCHAR*) root + irt_desc->irt_desc); + Ods::irtd* key_descriptor = (Ods::irtd*) ((UCHAR*) root + irt_desc->irt_desc); for (int i = 0; i < idx_count; i++, key_descriptor++) key_descriptor->irtd_selectivity = selectivity[i]; } @@ -7604,3 +7604,5 @@ void IndexCreateLock::makeLock(MetaId indexId) lck->setKey(IndexPermanent::makeLockId(relId, indexId)); } + +} // namespace Firebird::Jrd diff --git a/src/jrd/btr.h b/src/jrd/btr.h index 8edc0e34364..49fde1b5df4 100644 --- a/src/jrd/btr.h +++ b/src/jrd/btr.h @@ -27,7 +27,7 @@ #ifndef JRD_BTR_H #define JRD_BTR_H -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/classes/array.h" #include "../include/fb_blk.h" @@ -41,7 +41,7 @@ struct dsc; -namespace Jrd { +namespace Firebird::Jrd { class jrd_rel; class jrd_tra; @@ -75,11 +75,11 @@ struct dep // Primary dependencies from all foreign references to relation's // primary/unique keys -typedef Firebird::HalfStaticArray PrimaryDeps; +typedef HalfStaticArray PrimaryDeps; // Foreign references to other relations' primary/unique keys -typedef Firebird::HalfStaticArray ForeignRefs; +typedef HalfStaticArray ForeignRefs; // Index descriptor block -- used to hold info from index root page @@ -110,7 +110,7 @@ struct index_desc } idx_rpt[MAX_INDEX_SEGMENTS]; }; -typedef Firebird::HalfStaticArray IndexDescList; +typedef HalfStaticArray IndexDescList; inline constexpr USHORT idx_invalid = USHORT(~0); // Applies to idx_id as special value @@ -189,7 +189,7 @@ struct temporary_mini_key struct temporary_key : public temporary_mini_key { - Firebird::AutoPtr key_next; // next key (INTL_KEY_MULTI_STARTING) + AutoPtr key_next; // next key (INTL_KEY_MULTI_STARTING) }; @@ -283,7 +283,7 @@ inline constexpr int irb_unique = 512; // Unique match (currently used only inline constexpr int irb_force_lower = irb_exclude_lower; inline constexpr int irb_force_upper = irb_exclude_upper; -typedef Firebird::HalfStaticArray SelectivityList; +typedef HalfStaticArray SelectivityList; class BtrPageGCLock : public Lock { @@ -306,17 +306,17 @@ class BtrPageGCLock : public Lock static bool isPageGCAllowed(thread_db* tdbb, const PageNumber& page); #ifdef DEBUG_LCK_LIST - BtrPageGCLock(thread_db* tdbb, Firebird::MemoryPool* pool) + BtrPageGCLock(thread_db* tdbb, MemoryPool* pool) : Lock(tdbb, PageNumber::getLockLen(), LCK_btr_dont_gc), m_pool(pool) { } - static bool checkPool(const Lock* lock, Firebird::MemoryPool* pool) + static bool checkPool(const Lock* lock, MemoryPool* pool) { if (!pool || !lock) return false; - const Firebird::MemoryPool* pool2 = NULL; + const MemoryPool* pool2 = NULL; if (lock && (lock->lck_type == LCK_btr_dont_gc)) pool2 = reinterpret_cast(lock)->m_pool; @@ -325,7 +325,7 @@ class BtrPageGCLock : public Lock } private: - const Firebird::MemoryPool* m_pool; + const MemoryPool* m_pool; #endif }; @@ -342,7 +342,7 @@ struct IndexCreation USHORT key_length; USHORT nullIndLen; SINT64 dup_recno; - Firebird::AtomicCounter duplicates; + AtomicCounter duplicates; IdxCreate forRollback; }; @@ -381,7 +381,7 @@ class IndexErrorContext // Index construction lock holder -class IndexCreateLock : public Firebird::AutoStorage +class IndexCreateLock : public AutoStorage { public: IndexCreateLock(thread_db* tdbb, MetaId relId); @@ -412,14 +412,14 @@ class IndexCondition ~IndexCondition(); - Firebird::TriState check(Record* record, idx_e* errCode = nullptr); + TriState check(Record* record, idx_e* errCode = nullptr); private: thread_db* const m_tdbb; BoolExprNode* m_condition = nullptr; Request* m_request = nullptr; - Firebird::TriState evaluate(Record* record) const; + TriState evaluate(Record* record) const; }; class IndexExpression @@ -441,7 +441,7 @@ class IndexExpression Request* m_request = nullptr; }; -typedef Firebird::AutoPtr AutoIndexExpression; +typedef AutoPtr AutoIndexExpression; // Index key wrapper @@ -584,13 +584,13 @@ class IndexScanListIterator void makeKeys(thread_db* tdbb, temporary_key* lower, temporary_key* upper); const IndexRetrieval* const m_retrieval; - Firebird::HalfStaticArray m_listValues; - Firebird::HalfStaticArray m_lowerValues; - Firebird::HalfStaticArray m_upperValues; + HalfStaticArray m_listValues; + HalfStaticArray m_lowerValues; + HalfStaticArray m_upperValues; const ValueExprNode* const* m_iterator; USHORT m_segno = MAX_USHORT; }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_BTR_H diff --git a/src/jrd/btr_proto.h b/src/jrd/btr_proto.h index 4d035afa6a3..7aaf41289ae 100644 --- a/src/jrd/btr_proto.h +++ b/src/jrd/btr_proto.h @@ -30,35 +30,38 @@ #include "../jrd/exe.h" #include "../jrd/QualifiedName.h" -void BTR_all(Jrd::thread_db*, Jrd::Cached::Relation*, Jrd::IndexDescList&, Jrd::RelationPages*); -bool BTR_activate_index(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId); -bool BTR_cleanup_index(Jrd::thread_db*, const Jrd::QualifiedName&, Jrd::jrd_tra*, MetaId); -void BTR_complement_key(Jrd::temporary_key*); -void BTR_create(Jrd::thread_db*, Jrd::IndexCreation&, Jrd::SelectivityList&); -bool BTR_delete_index(Jrd::thread_db*, Jrd::win*, MetaId, bool); -bool BTR_description(Jrd::thread_db*, Jrd::Cached::Relation*, const Ods::index_root_page*, Jrd::index_desc*, - MetaId, bool raise = true); -DSC* BTR_eval_expression(Jrd::thread_db*, Jrd::index_desc*, Jrd::Record*); -void BTR_evaluate(Jrd::thread_db*, const Jrd::IndexRetrieval*, Jrd::RecordBitmap**, Jrd::RecordBitmap*); -UCHAR* BTR_find_leaf(Ods::btree_page*, Jrd::temporary_key*, UCHAR*, USHORT*, bool, int); -Ods::btree_page* BTR_find_page(Jrd::thread_db*, const Jrd::IndexRetrieval*, Jrd::win*, Jrd::index_desc*, - Jrd::temporary_key*, Jrd::temporary_key*); -void BTR_insert(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*); -USHORT BTR_key_length(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::index_desc*); -Ods::btree_page* BTR_left_handoff(Jrd::thread_db*, Jrd::win*, Ods::btree_page*, SSHORT); -bool BTR_lookup(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId, Jrd::index_desc*, Jrd::RelationPages*); -bool BTR_make_bounds(Jrd::thread_db*, const Jrd::IndexRetrieval*, Jrd::IndexScanListIterator*, - Jrd::temporary_key*, Jrd::temporary_key*, USHORT&); -Jrd::idx_e BTR_make_key(Jrd::thread_db*, USHORT, const Jrd::ValueExprNode* const*, const SSHORT*, - const Jrd::index_desc*, Jrd::temporary_key*, USHORT, bool*); -void BTR_make_null_key(Jrd::thread_db*, const Jrd::index_desc*, Jrd::temporary_key*); -void BTR_mark_index_for_delete(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId, Jrd::win*, Ods::index_root_page*); -bool BTR_next_index(Jrd::thread_db*, Jrd::Cached::Relation*, Jrd::jrd_tra*, Jrd::index_desc*, Jrd::win*); -void BTR_remove(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*); -void BTR_reserve_slot(Jrd::thread_db*, Jrd::IndexCreation&, Jrd::IndexCreateLock&); -void BTR_selectivity(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId, Jrd::SelectivityList&); -bool BTR_types_comparable(const dsc& target, const dsc& source); -Ods::index_root_page* BTR_fetch_root_for_update(const char* from, Jrd::thread_db* tdbb, Jrd::win* window); -const Ods::index_root_page* BTR_fetch_root(const char* from, Jrd::thread_db* tdbb, Jrd::win* window); +namespace Firebird::Jrd +{ + void BTR_all(thread_db*, Cached::Relation*, IndexDescList&, RelationPages*); + bool BTR_activate_index(thread_db*, Cached::Relation*, MetaId); + bool BTR_cleanup_index(thread_db*, const QualifiedName&, jrd_tra*, MetaId); + void BTR_complement_key(temporary_key*); + void BTR_create(thread_db*, IndexCreation&, SelectivityList&); + bool BTR_delete_index(thread_db*, win*, MetaId, bool); + bool BTR_description(thread_db*, Cached::Relation*, const Ods::index_root_page*, index_desc*, + MetaId, bool raise = true); + DSC* BTR_eval_expression(thread_db*, index_desc*, Record*); + void BTR_evaluate(thread_db*, const IndexRetrieval*, RecordBitmap**, RecordBitmap*); + UCHAR* BTR_find_leaf(Ods::btree_page*, temporary_key*, UCHAR*, USHORT*, bool, int); + Ods::btree_page* BTR_find_page(thread_db*, const IndexRetrieval*, win*, index_desc*, + temporary_key*, temporary_key*); + void BTR_insert(thread_db*, win*, index_insertion*); + USHORT BTR_key_length(thread_db*, jrd_rel*, index_desc*); + Ods::btree_page* BTR_left_handoff(thread_db*, win*, Ods::btree_page*, SSHORT); + bool BTR_lookup(thread_db*, Cached::Relation*, MetaId, index_desc*, RelationPages*); + bool BTR_make_bounds(thread_db*, const IndexRetrieval*, IndexScanListIterator*, + temporary_key*, temporary_key*, USHORT&); + idx_e BTR_make_key(thread_db*, USHORT, const ValueExprNode* const*, const SSHORT*, + const index_desc*, temporary_key*, USHORT, bool*); + void BTR_make_null_key(thread_db*, const index_desc*, temporary_key*); + void BTR_mark_index_for_delete(thread_db*, Cached::Relation*, MetaId, win*, Ods::index_root_page*); + bool BTR_next_index(thread_db*, Cached::Relation*, jrd_tra*, index_desc*, win*); + void BTR_remove(thread_db*, win*, index_insertion*); + void BTR_reserve_slot(thread_db*, IndexCreation&, IndexCreateLock&); + void BTR_selectivity(thread_db*, Cached::Relation*, MetaId, SelectivityList&); + bool BTR_types_comparable(const dsc& target, const dsc& source); + Ods::index_root_page* BTR_fetch_root_for_update(const char* from, thread_db* tdbb, win* window); + const Ods::index_root_page* BTR_fetch_root(const char* from, thread_db* tdbb, win* window); +} // namespace Firebird::Jrd #endif // JRD_BTR_PROTO_H diff --git a/src/jrd/builtin.cpp b/src/jrd/builtin.cpp index b8a813a9be2..22a21d080aa 100644 --- a/src/jrd/builtin.cpp +++ b/src/jrd/builtin.cpp @@ -29,6 +29,10 @@ #include "../jrd/flu_proto.h" #include "../yvalve/gds_proto.h" +namespace Firebird::Jrd +{ + + struct FN { const TEXT* fn_module; @@ -117,3 +121,5 @@ FPTR_INT BUILTIN_entrypoint(const TEXT* module, const TEXT* entrypoint) return NULL; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/cch.cpp b/src/jrd/cch.cpp index b38f17f5e3e..bf11a0077a1 100644 --- a/src/jrd/cch.cpp +++ b/src/jrd/cch.cpp @@ -76,10 +76,9 @@ #include "../jrd/InitCDSLib.h" #endif +namespace Firebird::Jrd +{ -using namespace Jrd; -using namespace Ods; -using namespace Firebird; // In the superserver mode, no page locks are acquired through the lock manager. // Instead, a latching mechanism is used. So the calls to lock subsystem for @@ -208,9 +207,6 @@ constexpr int PRE_SEARCH_LIMIT = 256; constexpr int PRE_EXISTS = -1; constexpr int PRE_UNKNOWN = -2; -namespace Jrd -{ - #ifdef HASH_USE_CDS_LIST template @@ -285,8 +281,6 @@ class BCBHashTable chain_type* m_chains; }; -} - void CCH_clean_page(thread_db* tdbb, PageNumber page) { @@ -462,14 +456,14 @@ int CCH_down_grade_dbb(void* ast_object) dbb->dbb_ast_flags &= ~DBB_blocking; } - catch (const Firebird::Exception&) + catch (const Exception&) {} // no-op return 0; } -bool CCH_exclusive(thread_db* tdbb, USHORT level, SSHORT wait_flag, Firebird::Sync* guard) +bool CCH_exclusive(thread_db* tdbb, USHORT level, SSHORT wait_flag, Sync* guard) { /************************************** * @@ -680,7 +674,7 @@ bool CCH_expand(thread_db* tdbb, ULONG number) } -pag* CCH_fake(thread_db* tdbb, WIN* window, int wait) +Ods::pag* CCH_fake(thread_db* tdbb, WIN* window, int wait) { /************************************** * @@ -775,7 +769,7 @@ pag* CCH_fake(thread_db* tdbb, WIN* window, int wait) } -pag* CCH_fetch(thread_db* tdbb, WIN* window, int lock_type, SCHAR page_type, int wait, +Ods::pag* CCH_fetch(thread_db* tdbb, WIN* window, int lock_type, SCHAR page_type, int wait, const bool read_shadow) { /************************************** @@ -928,7 +922,7 @@ void CCH_fetch_page(thread_db* tdbb, WIN* window, const bool read_shadow) FbStatusVector* const status = tdbb->tdbb_status_vector; - pag* page = bdb->bdb_buffer; + Ods::pag* page = bdb->bdb_buffer; bdb->bdb_incarnation = ++bcb->bcb_page_incarnation; const ULONG pageSpaceId = bdb->bdb_page.getPageSpaceID(); @@ -1440,7 +1434,7 @@ void CCH_get_related(thread_db* tdbb, PageNumber page, PagesArray &lowPages) } -pag* CCH_handoff(thread_db* tdbb, WIN* window, ULONG page, int lock, SCHAR page_type, +Ods::pag* CCH_handoff(thread_db* tdbb, WIN* window, ULONG page, int lock, SCHAR page_type, int wait, const bool release_tail) { /************************************** @@ -1597,7 +1591,7 @@ void CCH_init(thread_db* tdbb, ULONG number) BCBHashTable(*bcb->bcb_bufferpool, number); break; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(tdbb->tdbb_status_vector); @@ -1646,7 +1640,7 @@ void CCH_init2(thread_db* tdbb) BufferControl* bcb = dbb->dbb_bcb; // Avoid running CCH_init2() in 2 parallel threads - Firebird::MutexEnsureUnlock guard(bcb->bcb_threadStartup, FB_FUNCTION); + MutexEnsureUnlock guard(bcb->bcb_threadStartup, FB_FUNCTION); guard.enter(); if (!(bcb->bcb_flags & BCB_exclusive) || (bcb->bcb_flags & (BCB_cache_writer | BCB_writer_start))) @@ -1884,7 +1878,7 @@ void CCH_prefetch(thread_db* tdbb, SLONG* pages, SSHORT count) } // Switch default pool to permanent pool for setting bits in prefetch bitmap. - Jrd::ContextPoolHolder context(tdbb, bcb->bcb_bufferpool); + JrdContextPoolHolder context(tdbb, bcb->bcb_bufferpool); // The global prefetch bitmap is the key to the I/O coalescense mechanism which dovetails // all thread prefetch requests to minimize sequential I/O requests. @@ -2389,7 +2383,7 @@ void CCH_unwind(thread_db* tdbb, const bool punt) } #ifndef SUPERSERVER - const pag* const page = bdb->bdb_buffer; + const Ods::pag* const page = bdb->bdb_buffer; if (page->pag_type == pag_header || page->pag_type == pag_transactions) { ++bdb->bdb_use_count; @@ -2457,11 +2451,11 @@ bool CCH_write_all_shadows(thread_db* tdbb, Shadow* shadow, BufferDesc* bdb, Ods return true; bool result = true; - Firebird::UCharBuffer spare_buffer; + UCharBuffer spare_buffer; if (bdb->bdb_page == HEADER_PAGE_NUMBER) { - Ods::pag* newPage = (pag*) spare_buffer.getBuffer(dbb->dbb_page_size); + Ods::pag* newPage = (Ods::pag*) spare_buffer.getBuffer(dbb->dbb_page_size); memcpy(newPage, page, HDR_SIZE); page = newPage; memset((UCHAR*) page + HDR_SIZE, 0, dbb->dbb_page_size - HDR_SIZE); @@ -2489,17 +2483,17 @@ bool CCH_write_all_shadows(thread_db* tdbb, Shadow* shadow, BufferDesc* bdb, Ods if (bdb->bdb_page == HEADER_PAGE_NUMBER) { // fixup header for shadow file - header_page* header = (header_page*) page; + Ods::header_page* header = (Ods::header_page*) page; PageSpace* pageSpaceID = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); const UCHAR* q = (UCHAR *) pageSpaceID->file->fil_string; - header->hdr_data[0] = HDR_end; + header->hdr_data[0] = Ods::HDR_end; header->hdr_end = HDR_SIZE; - PAG_add_header_entry(tdbb, header, HDR_root_file_name, + PAG_add_header_entry(tdbb, header, Ods::HDR_root_file_name, (USHORT) strlen((const char*) q), q); - header->hdr_flags |= hdr_active_shadow; + header->hdr_flags |= Ods::hdr_active_shadow; header->hdr_header.pag_pageno = bdb->bdb_page.getPageNum(); } @@ -2638,7 +2632,7 @@ static int blocking_ast_bdb(void* ast_object) if (tdbb->tdbb_status_vector->getState() & IStatus::STATE_ERRORS) iscDbLogStatus(dbb->dbb_filename.c_str(), tdbb->tdbb_status_vector); } - catch (const Firebird::Exception&) + catch (const Exception&) { return -1; } // no-op @@ -2676,7 +2670,7 @@ static void flushDirty(thread_db* tdbb, SLONG transaction_mask, const bool sys_o SET_TDBB(tdbb); Database* dbb = tdbb->getDatabase(); BufferControl* bcb = dbb->dbb_bcb; - Firebird::HalfStaticArray flush; + HalfStaticArray flush; { // dirtySync scope Sync dirtySync(&bcb->bcb_syncDirtyBdbs, "flushDirty"); @@ -2716,7 +2710,7 @@ static void flushAll(thread_db* tdbb, USHORT flush_flag) SET_TDBB(tdbb); Database* dbb = tdbb->getDatabase(); BufferControl* bcb = dbb->dbb_bcb; - Firebird::HalfStaticArray flush(bcb->bcb_dirty_count); + HalfStaticArray flush(bcb->bcb_dirty_count); const bool all_flag = (flush_flag & FLUSH_ALL) != 0; const bool sweep_flag = (flush_flag & FLUSH_SWEEP) != 0; @@ -2888,7 +2882,7 @@ void BufferControl::cache_reader(BufferControl* bcb) Jrd::Attachment* const attachment = Attachment::create(dbb, nullptr); tdbb->setAttachment(attachment); attachment->att_filename = dbb->dbb_filename; - Jrd::ContextPoolHolder context(tdbb, bcb->bcb_bufferpool); + JrdContextPoolHolder context(tdbb, bcb->bcb_bufferpool); // This try block is specifically to protect the LCK_init call: if // LCK_init fails we won't be able to accomplish anything anyway, so @@ -2904,7 +2898,7 @@ void BufferControl::cache_reader(BufferControl* bcb) bcb->bcb_flags |= BCB_cache_reader; dbb->dbb_reader_init.post(); // Notify our creator that we have started } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status_vector); iscDbLogStatus(dbb->dbb_filename.c_str(), status_vector); @@ -3004,7 +2998,7 @@ void BufferControl::cache_reader(BufferControl* bcb) dbb->dbb_reader_fini.post(); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status_vector); iscDbLogStatus(dbb->dbb_filename.c_str(), status_vector); @@ -3120,7 +3114,7 @@ void BufferControl::cache_writer(BufferControl* bcb) } } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(&status_vector); iscDbLogStatus(dbb->dbb_filename.c_str(), &status_vector); @@ -3132,7 +3126,7 @@ void BufferControl::cache_writer(BufferControl* bcb) attachment->releaseLocks(tdbb); LCK_fini(tdbb, LCK_OWNER_attachment); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { bcb->exceptionHandler(ex, cache_writer); } @@ -3147,14 +3141,14 @@ void BufferControl::cache_writer(BufferControl* bcb) bcb->bcb_writer_init.release(); } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { bcb->exceptionHandler(ex, cache_writer); } } -void BufferControl::exceptionHandler(const Firebird::Exception& ex, BcbThreadSync::ThreadRoutine*) +void BufferControl::exceptionHandler(const Exception& ex, BcbThreadSync::ThreadRoutine*) { FbLocalStatus status_vector; ex.stuffException(&status_vector); @@ -4273,7 +4267,7 @@ static ULONG memory_init(thread_db* tdbb, BufferControl* bcb, ULONG number) memory_end = memory + memory_size; break; } - catch (Firebird::BadAlloc&) + catch (BadAlloc&) { // Either there's not enough virtual memory or there is // but it's not virtually contiguous. Let's find out by @@ -4315,7 +4309,7 @@ static ULONG memory_init(thread_db* tdbb, BufferControl* bcb, ULONG number) lock_memory += lock_size; } - tail->bdb_buffer = (pag*) memory; + tail->bdb_buffer = (Ods::pag*) memory; memory += bcb->bcb_page_size; QUE_INSERT(bcb->bcb_empty, tail->bdb_que); @@ -4372,7 +4366,7 @@ static void page_validation_error(thread_db* tdbb, WIN* window, SSHORT type) **************************************/ SET_TDBB(tdbb); BufferDesc* bdb = window->win_bdb; - const pag* page = bdb->bdb_buffer; + const Ods::pag* page = bdb->bdb_buffer; PageSpace* pages = tdbb->getDatabase()->dbb_page_manager.findPageSpace(bdb->bdb_page.getPageSpaceID()); @@ -4381,8 +4375,8 @@ static void page_validation_error(thread_db* tdbb, WIN* window, SSHORT type) Arg::Gds(isc_db_corrupt) << Arg::Str(pages->file->fil_string) << Arg::Gds(isc_page_type_err) << Arg::Gds(isc_badpagtyp) << Arg::Num(bdb->bdb_page.getPageNum()) << - pagtype(type) << - pagtype(page->pag_type)); + Ods::pagtype(type) << + Ods::pagtype(page->pag_type)); // We should invalidate this bad buffer. CCH_unwind(tdbb, true); } @@ -4436,7 +4430,7 @@ static void prefetch_epilogue(Prefetch* prefetch, FbStatusVector* status_vector) { if (*next_bdb) { - pag* page = (*next_bdb)->bdb_buffer; + Ods::pag* page = (*next_bdb)->bdb_buffer; if (next_buffer != reinterpret_cast(page)) memcpy(page, next_buffer, (ULONG) dbb->dbb_page_size); @@ -4887,13 +4881,13 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s } Database* const dbb = tdbb->getDatabase(); - pag* const page = bdb->bdb_buffer; + Ods::pag* const page = bdb->bdb_buffer; // Before writing db header page, make sure that // the next_transaction > oldest_active transaction if (bdb->bdb_page == HEADER_PAGE_NUMBER) { - const auto header = (const header_page*) page; + const auto header = (const Ods::header_page*) page; const TraNumber next_transaction = header->hdr_next_transaction; const TraNumber oldest_transaction = header->hdr_oldest_transaction; @@ -4978,7 +4972,7 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s // We finished. Adjust transaction accounting and get ready for exit if (bdb->bdb_page == HEADER_PAGE_NUMBER) { - const auto header = (const header_page*) page; + const auto header = (const Ods::header_page*) page; dbb->dbb_last_header_write = header->hdr_next_transaction; } } @@ -5011,7 +5005,7 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s if (bdb->bdb_page == HEADER_PAGE_NUMBER) { - const auto header = (const header_page*) page; + const auto header = (const Ods::header_page*) page; dbb->dbb_last_header_write = header->hdr_next_transaction; } @@ -5304,8 +5298,6 @@ void BufferDesc::unLockIO(thread_db* tdbb) } -namespace Jrd { - /// class BCBHashTable void BCBHashTable::resize(ULONG count) @@ -5503,7 +5495,7 @@ void BCBHashTable::remove(BufferDesc* bdb) } -}; // namespace Jrd +// end namespace Firebird::Jrd is below #ifdef HASH_USE_CDS_LIST @@ -5530,3 +5522,6 @@ void suspend() } #endif // HASH_USE_CDS_LIST + + +} // namespace Firebird::Jrd diff --git a/src/jrd/cch.h b/src/jrd/cch.h index 98671de3024..8950aca1efc 100644 --- a/src/jrd/cch.h +++ b/src/jrd/cch.h @@ -50,11 +50,11 @@ DEFINE_TRACE_ROUTINE(cch_trace); #define CCH_TRACEE_AST(message) // nothing #endif -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; } -namespace Jrd { +namespace Firebird::Jrd { class Lock; class Precedence; @@ -77,7 +77,7 @@ inline constexpr ULONG MAX_PAGE_BUFFERS = MAX_SLONG - 1; class BufferControl : public pool_alloc { - BufferControl(MemoryPool& p, Firebird::MemoryStats& parentStats) + BufferControl(MemoryPool& p, MemoryStats& parentStats) : bcb_bufferpool(&p), bcb_memory_stats(&parentStats), bcb_memory(p), @@ -111,8 +111,8 @@ class BufferControl : public pool_alloc Database* bcb_database; - Firebird::MemoryPool* bcb_bufferpool; - Firebird::MemoryStats bcb_memory_stats; + MemoryPool* bcb_bufferpool; + MemoryStats bcb_memory_stats; UCharStack bcb_memory; // Large block partitioned into buffers que bcb_in_use; // Que of buffers in use, main LRU que @@ -128,7 +128,7 @@ class BufferControl : public pool_alloc SLONG bcb_dirty_count; // count of pages in dirty page btree Precedence* bcb_free; // Free precedence blocks - Firebird::AtomicCounter bcb_flags; // see below + AtomicCounter bcb_flags; // see below SSHORT bcb_free_minimum; // Threshold to activate cache writer ULONG bcb_count; // Number of buffers allocated ULONG bcb_inuse; // Number of buffers in use @@ -136,32 +136,32 @@ class BufferControl : public pool_alloc ULONG bcb_page_size; // Database page size in bytes ULONG bcb_page_incarnation; // Cache page incarnation counter - Firebird::SyncObject bcb_syncObject; - Firebird::SyncObject bcb_syncDirtyBdbs; - Firebird::SyncObject bcb_syncEmpty; - Firebird::SyncObject bcb_syncPrecedence; - Firebird::SyncObject bcb_syncLRU; + SyncObject bcb_syncObject; + SyncObject bcb_syncDirtyBdbs; + SyncObject bcb_syncEmpty; + SyncObject bcb_syncPrecedence; + SyncObject bcb_syncLRU; // If we make bcb_flags atomic this mutex will become unneeded: XCHG of bcb_flags is enough - Firebird::Mutex bcb_threadStartup; + Mutex bcb_threadStartup; typedef ThreadFinishSync BcbThreadSync; static void cache_writer(BufferControl* bcb); - Firebird::Semaphore bcb_writer_sem; // Wake up cache writer - Firebird::Semaphore bcb_writer_init; // Cache writer initialization + Semaphore bcb_writer_sem; // Wake up cache writer + Semaphore bcb_writer_init; // Cache writer initialization BcbThreadSync bcb_writer_fini; // Cache writer finalization #ifdef SUPERSERVER_V2 static void cache_reader(BufferControl* bcb); // the code in cch.cpp is not tested for semaphore instead event !!! - Firebird::Semaphore bcb_reader_sem; // Wake up cache reader - Firebird::Semaphore bcb_reader_init; // Cache reader initialization + Semaphore bcb_reader_sem; // Wake up cache reader + Semaphore bcb_reader_init; // Cache reader initialization BcbThreadSync bcb_reader_fini; // Cache reader finalization PageBitmap* bcb_prefetch; // Bitmap of pages to prefetch #endif - void exceptionHandler(const Firebird::Exception& ex, BcbThreadSync::ThreadRoutine* routine); + void exceptionHandler(const Exception& ex, BcbThreadSync::ThreadRoutine* routine); BCBHashTable* bcb_hashTable; @@ -171,7 +171,7 @@ class BufferControl : public pool_alloc BufferDesc* m_bdbs; ULONG m_count; }; - Firebird::Array bcb_bdbBlocks; // all allocated BufferDesc's + Array bcb_bdbBlocks; // all allocated BufferDesc's }; inline constexpr int BCB_keep_pages = 1; // set during btc_flush(), pages not removed from dirty binary tree @@ -215,9 +215,9 @@ class BufferDesc : public pool_alloc bdb_prec_walk_mark = 0; } - bool addRef(thread_db* tdbb, Firebird::SyncType syncType, int wait = 1); - bool addRefConditional(thread_db* tdbb, Firebird::SyncType syncType); - void downgrade(Firebird::SyncType syncType); + bool addRef(thread_db* tdbb, SyncType syncType, int wait = 1); + bool addRefConditional(thread_db* tdbb, SyncType syncType); + void downgrade(SyncType syncType); void release(thread_db* tdbb, bool repost); void lockIO(thread_db*); @@ -239,7 +239,7 @@ class BufferDesc : public pool_alloc } BufferControl* bdb_bcb; - Firebird::SyncObject bdb_syncPage; + SyncObject bdb_syncPage; Lock* bdb_lock; // Lock block for buffer que bdb_que; // Either mod que in hash table or bcb_empty que if never used que bdb_in_use; // queue of buffers in use @@ -256,15 +256,15 @@ class BufferDesc : public pool_alloc private: thread_db* bdb_io; // thread holding io latch - Firebird::SyncObject bdb_syncIO; + SyncObject bdb_syncIO; public: - Firebird::AtomicCounter bdb_ast_flags; // flags manipulated at AST level - Firebird::AtomicCounter bdb_flags; - Firebird::AtomicCounter bdb_use_count; // Number of active users + AtomicCounter bdb_ast_flags; // flags manipulated at AST level + AtomicCounter bdb_flags; + AtomicCounter bdb_use_count; // Number of active users SSHORT bdb_writers; // Number of recursively taken exclusive locks SSHORT bdb_io_locks; // Number of recursively taken IO locks - Firebird::AtomicCounter bdb_scan_count; // concurrent sequential scans + AtomicCounter bdb_scan_count; // concurrent sequential scans ULONG bdb_difference_page; // Number of page in difference file, NBAK ULONG bdb_prec_walk_mark; // mark value used in precedence graph walk }; @@ -377,9 +377,9 @@ class Prefetch : public pool_alloc inline constexpr int PRF_active = 1; // prefetch block currently in use #endif // SUPERSERVER_V2 -typedef Firebird::SortedArray, SLONG> PagesArray; +typedef SortedArray, SLONG> PagesArray; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_CCH_H diff --git a/src/jrd/cch_proto.h b/src/jrd/cch_proto.h index ee57bade70d..38c120ac3c0 100644 --- a/src/jrd/cch_proto.h +++ b/src/jrd/cch_proto.h @@ -24,7 +24,7 @@ #ifndef JRD_CCH_PROTO_H #define JRD_CCH_PROTO_H -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; } @@ -32,6 +32,15 @@ namespace Firebird { class Sync; } +namespace Firebird::Jrd { + class thread_db; + class PageNumber; + struct win; + class Database; + class jrd_file; + class Shadow; + class BufferDesc; + enum LockState { lsLatchTimeout = -2, // was -2 *** now unused *** lsLockTimeout, // was -1 @@ -40,102 +49,101 @@ enum LockState { lsError }; -void CCH_clean_page(Jrd::thread_db*, Jrd::PageNumber); +void CCH_clean_page(thread_db*, PageNumber); int CCH_down_grade_dbb(void*); -bool CCH_exclusive(Jrd::thread_db*, USHORT, SSHORT, Firebird::Sync*); -bool CCH_exclusive_attachment(Jrd::thread_db*, USHORT, SSHORT, Firebird::Sync*); -bool CCH_expand(Jrd::thread_db*, ULONG); -Ods::pag* CCH_fake(Jrd::thread_db*, Jrd::win*, int); -Ods::pag* CCH_fetch(Jrd::thread_db*, Jrd::win*, int, SCHAR, int, const bool); -LockState CCH_fetch_lock(Jrd::thread_db*, Jrd::win*, int, int, SCHAR); -void CCH_fetch_page(Jrd::thread_db*, Jrd::win*, const bool); -void CCH_fini(Jrd::thread_db*); -void CCH_forget_page(Jrd::thread_db*, Jrd::win*); -void CCH_flush(Jrd::thread_db* tdbb, USHORT flush_flag, TraNumber tra_number); -bool CCH_free_page(Jrd::thread_db*); -SLONG CCH_get_incarnation(Jrd::win*); -void CCH_get_related(Jrd::thread_db*, Jrd::PageNumber, Jrd::PagesArray&); -Ods::pag* CCH_handoff(Jrd::thread_db*, Jrd::win*, ULONG, int, SCHAR, int, const bool); -void CCH_init(Jrd::thread_db*, ULONG); -void CCH_init2(Jrd::thread_db*); -void CCH_mark(Jrd::thread_db*, Jrd::win*, bool, bool); -void CCH_must_write(Jrd::thread_db*, Jrd::win*); -void CCH_precedence(Jrd::thread_db*, Jrd::win*, ULONG); -void CCH_precedence(Jrd::thread_db*, Jrd::win*, Jrd::PageNumber); -void CCH_tra_precedence(Jrd::thread_db*, Jrd::win*, TraNumber traNum); +bool CCH_exclusive(thread_db*, USHORT, SSHORT, Sync*); +bool CCH_exclusive_attachment(thread_db*, USHORT, SSHORT, Sync*); +bool CCH_expand(thread_db*, ULONG); +Ods::pag* CCH_fake(thread_db*, win*, int); +Ods::pag* CCH_fetch(thread_db*, win*, int, SCHAR, int, const bool); +LockState CCH_fetch_lock(thread_db*, win*, int, int, SCHAR); +void CCH_fetch_page(thread_db*, win*, const bool); +void CCH_fini(thread_db*); +void CCH_forget_page(thread_db*, win*); +void CCH_flush(thread_db* tdbb, USHORT flush_flag, TraNumber tra_number); +bool CCH_free_page(thread_db*); +SLONG CCH_get_incarnation(win*); +void CCH_get_related(thread_db*, PageNumber, Jrd::PagesArray&); +Ods::pag* CCH_handoff(thread_db*, win*, ULONG, int, SCHAR, int, const bool); +void CCH_init(thread_db*, ULONG); +void CCH_init2(thread_db*); +void CCH_mark(thread_db*, win*, bool, bool); +void CCH_must_write(thread_db*, win*); +void CCH_precedence(thread_db*, win*, ULONG); +void CCH_precedence(thread_db*, win*, PageNumber); +void CCH_tra_precedence(thread_db*, win*, TraNumber traNum); #ifdef SUPERSERVER_V2 -void CCH_prefetch(Jrd::thread_db*, SLONG*, SSHORT); -bool CCH_prefetch_pages(Jrd::thread_db*); +void CCH_prefetch(thread_db*, SLONG*, SSHORT); +bool CCH_prefetch_pages(thread_db*); #endif -void CCH_release(Jrd::thread_db*, Jrd::win*, const bool); -void CCH_release_exclusive(Jrd::thread_db*); -bool CCH_rollover_to_shadow(Jrd::thread_db* tdbb, Jrd::Database* dbb, Jrd::jrd_file*, const bool); -void CCH_shutdown(Jrd::thread_db*); -void CCH_unwind(Jrd::thread_db*, const bool); -bool CCH_validate(Jrd::win*); -void CCH_flush_ast(Jrd::thread_db*); -bool CCH_write_all_shadows(Jrd::thread_db*, Jrd::Shadow*, Jrd::BufferDesc*, Ods::pag*, - Jrd::FbStatusVector*, const bool); +void CCH_release(thread_db*, win*, const bool); +void CCH_release_exclusive(thread_db*); +bool CCH_rollover_to_shadow(thread_db* tdbb, Database* dbb, jrd_file*, const bool); +void CCH_shutdown(thread_db*); +void CCH_unwind(thread_db*, const bool); +bool CCH_validate(win*); +void CCH_flush_ast(thread_db*); +bool CCH_write_all_shadows(thread_db*, Shadow*, BufferDesc*, Ods::pag*, Jrd::FbStatusVector*, const bool); // macros for dealing with cache pages -inline Ods::pag* CCH_FETCH(Jrd::thread_db* tdbb, Jrd::win* window, USHORT lock_type, SCHAR page_type) +inline Ods::pag* CCH_FETCH(thread_db* tdbb, win* window, USHORT lock_type, SCHAR page_type) { return CCH_fetch (tdbb, window, lock_type, page_type, 1, true); } -inline Ods::pag* CCH_FETCH_NO_SHADOW(Jrd::thread_db* tdbb, Jrd::win* window, USHORT lock_type, SCHAR page_type) +inline Ods::pag* CCH_FETCH_NO_SHADOW(thread_db* tdbb, win* window, USHORT lock_type, SCHAR page_type) { return CCH_fetch (tdbb, window, lock_type, page_type, 1, false); } -inline Ods::pag* CCH_FETCH_TIMEOUT(Jrd::thread_db* tdbb, Jrd::win* window, USHORT lock_type, SCHAR page_type, SSHORT latch_wait) +inline Ods::pag* CCH_FETCH_TIMEOUT(thread_db* tdbb, win* window, USHORT lock_type, SCHAR page_type, SSHORT latch_wait) { return CCH_fetch (tdbb, window, lock_type, page_type, latch_wait, true); } -inline void CCH_RELEASE(Jrd::thread_db* tdbb, Jrd::win* window) +inline void CCH_RELEASE(thread_db* tdbb, win* window) { CCH_release(tdbb, window, false); } -inline void CCH_RELEASE_TAIL(Jrd::thread_db* tdbb, Jrd::win* window) +inline void CCH_RELEASE_TAIL(thread_db* tdbb, win* window) { CCH_release(tdbb, window, true); } -inline void CCH_MARK(Jrd::thread_db* tdbb, Jrd::win* window) +inline void CCH_MARK(thread_db* tdbb, win* window) { CCH_mark (tdbb, window, 0, 0); } -inline void CCH_MARK_SYSTEM(Jrd::thread_db* tdbb, Jrd::win* window) +inline void CCH_MARK_SYSTEM(thread_db* tdbb, win* window) { CCH_mark (tdbb, window, 1, 0); } -inline Ods::pag* CCH_HANDOFF(Jrd::thread_db* tdbb, Jrd::win* window, ULONG page, SSHORT lock, SCHAR page_type) +inline Ods::pag* CCH_HANDOFF(thread_db* tdbb, win* window, ULONG page, SSHORT lock, SCHAR page_type) { return CCH_handoff (tdbb, window, page, lock, page_type, 1, false); } -inline Ods::pag* CCH_HANDOFF_TIMEOUT(Jrd::thread_db* tdbb, Jrd::win* window, ULONG page, SSHORT lock, SCHAR page_type, SSHORT latch_wait) +inline Ods::pag* CCH_HANDOFF_TIMEOUT(thread_db* tdbb, win* window, ULONG page, SSHORT lock, SCHAR page_type, SSHORT latch_wait) { return CCH_handoff (tdbb, window, page, lock, page_type, latch_wait, false); } -inline Ods::pag* CCH_HANDOFF_TAIL(Jrd::thread_db* tdbb, Jrd::win* window, ULONG page, SSHORT lock, SCHAR page_type) +inline Ods::pag* CCH_HANDOFF_TAIL(thread_db* tdbb, win* window, ULONG page, SSHORT lock, SCHAR page_type) { return CCH_handoff (tdbb, window, page, lock, page_type, 1, true); } -inline void CCH_MARK_MUST_WRITE(Jrd::thread_db* tdbb, Jrd::win* window) +inline void CCH_MARK_MUST_WRITE(thread_db* tdbb, win* window) { CCH_mark(tdbb, window, 0, 1); } #ifdef SUPERSERVER_V2 -inline void CCH_PREFETCH(Jrd::thread_db* tdbb, SLONG* pages, SSHORT count) +inline void CCH_PREFETCH(thread_db* tdbb, SLONG* pages, SSHORT count) { CCH_prefetch (tdbb, pages, count); } @@ -165,4 +173,6 @@ inline constexpr USHORT FLUSH_SWEEP = 8; // flush dirty buffers from garbage c inline constexpr USHORT FLUSH_SYSTEM = 16; // flush system transaction only from dirty btree inline constexpr USHORT FLUSH_FINI = (FLUSH_ALL | FLUSH_RLSE); +} // namespace Firebird::Jrd + #endif // JRD_CCH_PROTO_H diff --git a/src/jrd/cmp.cpp b/src/jrd/cmp.cpp index 84d0fafcc55..b7a52bfd11b 100644 --- a/src/jrd/cmp.cpp +++ b/src/jrd/cmp.cpp @@ -92,8 +92,8 @@ #include "../dsql/ExprNodes.h" #include "../dsql/StmtNodes.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ #ifdef CMP_DEBUG @@ -157,7 +157,7 @@ Statement* CMP_compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool try { - Jrd::ContextPoolHolder context(tdbb, newPool); + JrdContextPoolHolder context(tdbb, newPool); const auto csb = PAR_parse(tdbb, blr, blrLength, internalFlag, dbginfoLength, dbginfo); @@ -187,7 +187,7 @@ Statement* CMP_compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool delete csb; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(tdbb->tdbb_status_vector); if (statement) @@ -635,3 +635,6 @@ RecordSource* CMP_post_rse(thread_db* tdbb, CompilerScratch* csb, RseNode* rse) return rsb; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/cmp_proto.h b/src/jrd/cmp_proto.h index d9dde4ed085..ab288dc7257 100644 --- a/src/jrd/cmp_proto.h +++ b/src/jrd/cmp_proto.h @@ -29,37 +29,40 @@ #include "../jrd/scl.h" #include "../jrd/Resources.h" -StreamType* CMP_alloc_map(Jrd::thread_db*, Jrd::CompilerScratch*, StreamType stream); -Jrd::ValueExprNode* CMP_clone_node_opt(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::ValueExprNode*); -Jrd::BoolExprNode* CMP_clone_node_opt(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::BoolExprNode*); -Jrd::ValueExprNode* CMP_clone_node(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::ValueExprNode*); -Jrd::Statement* CMP_compile(Jrd::thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool internalFlag, - ULONG dbginfoLength, const UCHAR* dbginfo); -Jrd::Request* CMP_compile_request(Jrd::thread_db*, const UCHAR* blr, ULONG blrLength, bool internalFlag); -Jrd::CompilerScratch::csb_repeat* CMP_csb_element(Jrd::CompilerScratch*, StreamType element); -const Jrd::Format* CMP_format(Jrd::thread_db*, Jrd::CompilerScratch*, StreamType); -Jrd::Request* CMP_make_request(Jrd::thread_db*, Jrd::CompilerScratch*, bool); -Jrd::ItemInfo* CMP_pass2_validation(Jrd::thread_db*, Jrd::CompilerScratch*, const Jrd::Item&); +namespace Firebird::Jrd +{ + StreamType* CMP_alloc_map(thread_db*, CompilerScratch*, StreamType stream); + ValueExprNode* CMP_clone_node_opt(thread_db*, CompilerScratch*, ValueExprNode*); + BoolExprNode* CMP_clone_node_opt(thread_db*, CompilerScratch*, BoolExprNode*); + ValueExprNode* CMP_clone_node(thread_db*, CompilerScratch*, ValueExprNode*); + Statement* CMP_compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool internalFlag, + ULONG dbginfoLength, const UCHAR* dbginfo); + Request* CMP_compile_request(thread_db*, const UCHAR* blr, ULONG blrLength, bool internalFlag); + CompilerScratch::csb_repeat* CMP_csb_element(CompilerScratch*, StreamType element); + const Format* CMP_format(thread_db*, CompilerScratch*, StreamType); + Request* CMP_make_request(thread_db*, CompilerScratch*, bool); + ItemInfo* CMP_pass2_validation(thread_db*, CompilerScratch*, const Item&); -bool CMP_procedure_arguments( - Jrd::thread_db* tdbb, - Jrd::CompilerScratch* csb, - Jrd::Routine* routine, - bool isInput, - USHORT argCount, - Firebird::ObjectsArray* argNames, - NestConst& sources, - NestConst& targets, - NestConst& message, - Firebird::Arg::StatusVector& mismatchStatus); + bool CMP_procedure_arguments( + thread_db* tdbb, + CompilerScratch* csb, + Routine* routine, + bool isInput, + USHORT argCount, + ObjectsArray* argNames, + NestConst& sources, + NestConst& targets, + NestConst& message, + Arg::StatusVector& mismatchStatus); -void CMP_post_access(Jrd::thread_db*, Jrd::CompilerScratch*, const Jrd::MetaName&, SLONG ssRelationId, - Jrd::SecurityClass::flags_t, ObjectType obj_type, - const Jrd::QualifiedName&, - const Jrd::MetaName& = {}); + void CMP_post_access(thread_db*, CompilerScratch*, const MetaName&, SLONG ssRelationId, + SecurityClass::flags_t, ObjectType obj_type, + const QualifiedName&, + const MetaName& = {}); -void CMP_post_procedure_access(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::Cached::Procedure*); -Jrd::RecordSource* CMP_post_rse(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::RseNode*); -void CMP_release(Jrd::thread_db*, Jrd::Request*); + void CMP_post_procedure_access(thread_db*, CompilerScratch*, Cached::Procedure*); + RecordSource* CMP_post_rse(thread_db*, CompilerScratch*, RseNode*); + void CMP_release(thread_db*, Request*); +} // namespace Firebird::Jrd #endif // JRD_CMP_PROTO_H diff --git a/src/jrd/constants.h b/src/jrd/constants.h index b40a51dbf77..38bca2477dc 100644 --- a/src/jrd/constants.h +++ b/src/jrd/constants.h @@ -2,519 +2,11 @@ * PROGRAM: JRD Access Method * MODULE: constants.h * DESCRIPTION: Misc system constants - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * - * 2001.10.08 Claudio Valderrama: fb_sysflag enum with numbering - * for automatically created triggers that aren't system triggers. */ #ifndef JRD_CONSTANTS_H #define JRD_CONSTANTS_H -// BLOb Subtype definitions - -/* Subtypes < 0 are user defined - * Subtype 0 means "untyped" - * Subtypes > 0 are Firebird defined - */ - -// BRS 29-Apr-2004 -// replace those constants with public defined ones isc_blob_* -// -//const int BLOB_untyped = 0; -// -//const int BLOB_text = 1; -//const int BLOB_blr = 2; -//const int BLOB_acl = 3; -//const int BLOB_ranges = 4; -//const int BLOB_summary = 5; -//const int BLOB_format = 6; -//const int BLOB_tra = 7; -//const int BLOB_extfile = 8; -//const int BLOB_max_predefined_subtype = 9; -// - -// Column Limits (in bytes) - -inline constexpr ULONG MAX_COLUMN_SIZE = 32767; -inline constexpr ULONG MAX_VARY_COLUMN_SIZE = MAX_COLUMN_SIZE - sizeof(USHORT); - -inline constexpr ULONG MAX_STR_SIZE = 65535; - -inline constexpr int TEMP_STR_LENGTH = 128; - -// Metadata constants - -inline constexpr unsigned METADATA_IDENTIFIER_CHAR_LEN = 63; -inline constexpr unsigned METADATA_BYTES_PER_CHAR = 4; - -// Misc constant values - -inline constexpr unsigned int USERNAME_LENGTH = METADATA_IDENTIFIER_CHAR_LEN * METADATA_BYTES_PER_CHAR; - -inline constexpr FB_SIZE_T MAX_SQL_IDENTIFIER_LEN = METADATA_IDENTIFIER_CHAR_LEN * METADATA_BYTES_PER_CHAR; -inline constexpr FB_SIZE_T MAX_SQL_IDENTIFIER_SIZE = MAX_SQL_IDENTIFIER_LEN + 1; -inline constexpr FB_SIZE_T MAX_CONFIG_NAME_LEN = 63; - -// Every character of the name may be a double-quote needed to be escaped (with another double-quote). -// The name would also need to be enclosed in double-quotes. -// There is two names, separated by a dot. -inline constexpr FB_SIZE_T MAX_QUALIFIED_NAME_TO_STRING_LEN = - ((METADATA_IDENTIFIER_CHAR_LEN * 2 + 2) * 2 + 1) * METADATA_BYTES_PER_CHAR; - -inline constexpr ULONG MAX_SQL_LENGTH = 10 * 1024 * 1024; // 10 MB - just a safety check - -inline constexpr const char* DB_KEY_NAME = "DB_KEY"; -inline constexpr const char* RDB_DB_KEY_NAME = "RDB$DB_KEY"; -inline constexpr const char* RDB_RECORD_VERSION_NAME = "RDB$RECORD_VERSION"; - -inline constexpr const char* NULL_STRING_MARK = "*** null ***"; -inline constexpr const char* UNKNOWN_STRING_MARK = "*** unknown ***"; - -inline constexpr const char* ISC_USER = "ISC_USER"; -inline constexpr const char* ISC_PASSWORD = "ISC_PASSWORD"; - -inline constexpr const char* NULL_ROLE = "NONE"; -#define ADMIN_ROLE "RDB$ADMIN" // It's used in C-string concatenations - -// User name assigned to any user granted USR_locksmith rights. -// If this name is changed, modify also the trigger in -// jrd/grant.gdl (which turns into jrd/trig.h. -inline constexpr const char* DBA_USER_NAME = "SYSDBA"; - -inline constexpr const char* PRIMARY_KEY = "PRIMARY KEY"; -inline constexpr const char* FOREIGN_KEY = "FOREIGN KEY"; -inline constexpr const char* UNIQUE_CNSTRT = "UNIQUE"; -inline constexpr const char* CHECK_CNSTRT = "CHECK"; -inline constexpr const char* NOT_NULL_CNSTRT = "NOT NULL"; - -inline constexpr const char* REL_SCOPE_PERSISTENT = "persistent table %s"; -inline constexpr const char* REL_SCOPE_GTT_PRESERVE = "global temporary table %s of type ON COMMIT PRESERVE ROWS"; -inline constexpr const char* REL_SCOPE_GTT_DELETE = "global temporary table %s of type ON COMMIT DELETE ROWS"; -inline constexpr const char* REL_SCOPE_EXTERNAL = "external table %s"; -inline constexpr const char* REL_SCOPE_VIEW = "view %s"; -inline constexpr const char* REL_SCOPE_VIRTUAL = "virtual table %s"; - -// literal strings in rdb$ref_constraints to be used to identify -// the cascade actions for referential constraints. Used -// by isql/show and isql/extract for now. - -inline constexpr const char* RI_ACTION_CASCADE = "CASCADE"; -inline constexpr const char* RI_ACTION_NULL = "SET NULL"; -inline constexpr const char* RI_ACTION_DEFAULT = "SET DEFAULT"; -inline constexpr const char* RI_ACTION_NONE = "NO ACTION"; -inline constexpr const char* RI_RESTRICT = "RESTRICT"; - -// Automatically created domains for fields with direct data type. -// Also, automatically created indices that are unique or non-unique, but not PK. -inline constexpr const char* IMPLICIT_DOMAIN_PREFIX = "RDB$"; -inline constexpr int IMPLICIT_DOMAIN_PREFIX_LEN = 4; - -// Automatically created indices for PKs. -inline constexpr const char* IMPLICIT_PK_PREFIX = "RDB$PRIMARY"; -inline constexpr int IMPLICIT_PK_PREFIX_LEN = 11; - -// The invisible "id zero" generator. -inline constexpr const char* MASTER_GENERATOR = ""; //Was "RDB$GENERATORS"; - -inline constexpr const char* SYSTEM_SCHEMA = "SYSTEM"; -inline constexpr const char* PUBLIC_SCHEMA = "PUBLIC"; -inline constexpr const char* PLG_LEGACY_SEC_SCHEMA = "PLG$LEGACY_SEC"; - -// Automatically created security classes for SQL objects. -// Keep in sync with trig.h -inline constexpr const char* DEFAULT_CLASS = "SQL$DEFAULT"; -inline constexpr const char* SQL_SECCLASS_GENERATOR = "RDB$SECURITY_CLASS"; -inline constexpr const char* SQL_SECCLASS_PREFIX = "SQL$"; -inline constexpr int SQL_SECCLASS_PREFIX_LEN = 4; -inline constexpr const char* SQL_FLD_SECCLASS_PREFIX = "SQL$GRANT"; -inline constexpr int SQL_FLD_SECCLASS_PREFIX_LEN = 9; - -inline constexpr const char* SQL_DDL_SECCLASS_FORMAT = "SQL$D%02d%s"; -inline constexpr int SQL_DDL_SECCLASS_PREFIX_LEN = 7; - -inline constexpr const char* GEN_SECCLASS_PREFIX = "GEN$"; -inline constexpr int GEN_SECCLASS_PREFIX_LEN = 4; - -inline constexpr const char* PROCEDURES_GENERATOR = "RDB$PROCEDURES"; -inline constexpr const char* FUNCTIONS_GENERATOR = "RDB$FUNCTIONS"; - -// Automatically created check constraints for unnamed PRIMARY and UNIQUE declarations. -inline constexpr const char* IMPLICIT_INTEGRITY_PREFIX = "INTEG_"; -inline constexpr int IMPLICIT_INTEGRITY_PREFIX_LEN = 6; - -// Default publication name -inline constexpr const char* DEFAULT_PUBLICATION = "RDB$DEFAULT"; - -//***************************************** -// System flag meaning - mainly Firebird. -//***************************************** - -enum fb_sysflag { - fb_sysflag_user = 0, - fb_sysflag_system = 1, - fb_sysflag_qli = 2, - fb_sysflag_check_constraint = 3, - fb_sysflag_referential_constraint = 4, - fb_sysflag_view_check = 5, - fb_sysflag_identity_generator = 6 -}; - -enum ViewContextType { - VCT_TABLE, - VCT_VIEW, - VCT_PROCEDURE -}; - -enum IdentityType { - IDENT_TYPE_ALWAYS, - IDENT_TYPE_BY_DEFAULT -}; - -enum SubRoutineType -{ - SUB_ROUTINE_TYPE_PSQL -}; - -// UDF Arguments are numbered from 0 to MAX_UDF_ARGUMENTS -- -// argument 0 is reserved for the return-type of the UDF - -inline constexpr unsigned MAX_UDF_ARGUMENTS = 15; - -// Maximum length of single line returned from pretty printer -inline constexpr int PRETTY_BUFFER_SIZE = 1024; - -inline constexpr int MAX_INDEX_SEGMENTS = 16; - -// Maximum index key length (must be in sync with MAX_PAGE_SIZE in ods.h) -inline constexpr ULONG MAX_KEY = 8192; // Maximum page size possible divide by 4 (MAX_PAGE_SIZE / 4) - -inline constexpr USHORT SQL_MATCH_1_CHAR = '_'; -inline constexpr USHORT SQL_MATCH_ANY_CHARS = '%'; - -inline constexpr size_t MAX_CONTEXT_VARS = 1000; // Maximum number of context variables allowed for a single object - -// Time precision limits and defaults for TIME/TIMESTAMP values. -// Currently they're applied to CURRENT_TIME[STAMP] expressions only. - -// Should be more than 6 as per SQL spec, but we don't support more than 3 yet -inline constexpr size_t MAX_TIME_PRECISION = 3; -// Consistent with the SQL spec -inline constexpr size_t DEFAULT_TIME_PRECISION = 0; -// Should be 6 as per SQL spec -inline constexpr size_t DEFAULT_TIMESTAMP_PRECISION = 3; - -// SQL spec requires an implementation-specific default (6.1 , syntax rules 6 (VARBINARY) and 7 (VARCHAR)) -inline constexpr size_t DEFAULT_VARCHAR_LENGTH = 255; -inline constexpr size_t DEFAULT_VARBINARY_LENGTH = 255; - -// SQL spec requires a default length of 1 (6.1 , syntax rule 5) -inline constexpr size_t DEFAULT_CHAR_LENGTH = 1; -inline constexpr size_t DEFAULT_BINARY_LENGTH = 1; - -inline constexpr size_t MAX_ARRAY_DIMENSIONS = 16; - -inline constexpr size_t MAX_SORT_ITEMS = 255; // ORDER BY f1,...,f255 - -inline constexpr size_t MAX_DB_PER_TRANS = 256; // A multi-db txn can span up to 256 dbs - -// relation types - -enum rel_t { - rel_persistent = 0, - rel_view = 1, - rel_external = 2, - rel_virtual = 3, - rel_temp_preserve = 4, - rel_temp_delete = 5 -}; - -// procedure types - -enum prc_t { - prc_legacy = 0, - prc_selectable = 1, - prc_executable = 2 -}; - -// procedure parameter mechanism - -enum prm_mech_t { - prm_mech_normal = 0, - prm_mech_type_of = 1 -}; - -// states - -enum mon_state_t { - mon_state_idle = 0, - mon_state_active = 1, - mon_state_stalled = 2 -}; - -// shutdown modes (match hdr_nbak_* in ods.h) - -enum shut_mode_t { - shut_mode_online = 0, - shut_mode_multi = 1, - shut_mode_single = 2, - shut_mode_full = 3 -}; - -// backup states (match hdr_backup_* in ods.h) - -enum backup_state_t { - backup_state_unknown = -1, - backup_state_normal = 0, - backup_state_stalled = 1, - backup_state_merge = 2 -}; - -// transaction isolation levels - -enum tra_iso_mode_t { - iso_mode_consistency = 0, - iso_mode_concurrency = 1, - iso_mode_rc_version = 2, - iso_mode_rc_no_version = 3, - iso_mode_rc_read_consistency = 4 -}; - -// statistics groups - -enum stat_group_t { - stat_database = 0, - stat_attachment = 1, - stat_transaction = 2, - stat_statement = 3, - stat_call = 4, - stat_cmp_statement = 5 -}; - -enum InfoType -{ - INFO_TYPE_CONNECTION_ID = 1, - INFO_TYPE_TRANSACTION_ID = 2, - INFO_TYPE_GDSCODE = 3, - INFO_TYPE_SQLCODE = 4, - INFO_TYPE_ROWS_AFFECTED = 5, - INFO_TYPE_TRIGGER_ACTION = 6, - INFO_TYPE_SQLSTATE = 7, - INFO_TYPE_EXCEPTION = 8, - INFO_TYPE_ERROR_MSG = 9, - INFO_TYPE_SESSION_RESETTING = 10, - MAX_INFO_TYPE -}; - -// Replica modes (match hdr_replica_* in ods.h) - -enum ReplicaMode -{ - REPLICA_NONE = 0, - REPLICA_READ_ONLY = 1, - REPLICA_READ_WRITE = 2 -}; - -enum TriggerType -{ - PRE_STORE_TRIGGER = 1, - POST_STORE_TRIGGER = 2, - PRE_MODIFY_TRIGGER = 3, - POST_MODIFY_TRIGGER = 4, - PRE_ERASE_TRIGGER = 5, - POST_ERASE_TRIGGER = 6 -}; - -enum TriggerAction -{ - // Order should be maintained because the numbers are stored in BLR - // and should be in sync with IExternalTrigger::ACTION_* . - TRIGGER_INSERT = 1, - TRIGGER_UPDATE = 2, - TRIGGER_DELETE = 3, - TRIGGER_CONNECT = 4, - TRIGGER_DISCONNECT = 5, - TRIGGER_TRANS_START = 6, - TRIGGER_TRANS_COMMIT = 7, - TRIGGER_TRANS_ROLLBACK = 8, - TRIGGER_DDL = 9 -}; - -inline constexpr unsigned TRIGGER_TYPE_SHIFT = 13; -inline constexpr FB_UINT64 TRIGGER_TYPE_MASK = (QUADCONST(3) << TRIGGER_TYPE_SHIFT); - -inline constexpr FB_UINT64 TRIGGER_TYPE_DML = (QUADCONST(0) << TRIGGER_TYPE_SHIFT); -inline constexpr FB_UINT64 TRIGGER_TYPE_DB = (QUADCONST(1) << TRIGGER_TYPE_SHIFT); -inline constexpr FB_UINT64 TRIGGER_TYPE_DDL = (QUADCONST(2) << TRIGGER_TYPE_SHIFT); - -inline constexpr unsigned DB_TRIGGER_CONNECT = 0; -inline constexpr unsigned DB_TRIGGER_DISCONNECT = 1; -inline constexpr unsigned DB_TRIGGER_TRANS_START = 2; -inline constexpr unsigned DB_TRIGGER_TRANS_COMMIT = 3; -inline constexpr unsigned DB_TRIGGER_TRANS_ROLLBACK = 4; -inline constexpr unsigned DB_TRIGGER_DDL = 5; -inline constexpr unsigned DB_TRIGGERS_COUNT = 6; - -static inline constexpr const char* DDL_TRIGGER_ACTION_NAMES[][2] = -{ - {NULL, NULL}, - {"CREATE", "TABLE"}, - {"ALTER", "TABLE"}, - {"DROP", "TABLE"}, - {"CREATE", "PROCEDURE"}, - {"ALTER", "PROCEDURE"}, - {"DROP", "PROCEDURE"}, - {"CREATE", "FUNCTION"}, - {"ALTER", "FUNCTION"}, - {"DROP", "FUNCTION"}, - {"CREATE", "TRIGGER"}, - {"ALTER", "TRIGGER"}, - {"DROP", "TRIGGER"}, - {"", ""}, {"", ""}, {"", ""}, // gap for TRIGGER_TYPE_MASK - 3 bits - {"CREATE", "EXCEPTION"}, - {"ALTER", "EXCEPTION"}, - {"DROP", "EXCEPTION"}, - {"CREATE", "VIEW"}, - {"ALTER", "VIEW"}, - {"DROP", "VIEW"}, - {"CREATE", "DOMAIN"}, - {"ALTER", "DOMAIN"}, - {"DROP", "DOMAIN"}, - {"CREATE", "ROLE"}, - {"ALTER", "ROLE"}, - {"DROP", "ROLE"}, - {"CREATE", "INDEX"}, - {"ALTER", "INDEX"}, - {"DROP", "INDEX"}, - {"CREATE", "SEQUENCE"}, - {"ALTER", "SEQUENCE"}, - {"DROP", "SEQUENCE"}, - {"CREATE", "USER"}, - {"ALTER", "USER"}, - {"DROP", "USER"}, - {"CREATE", "COLLATION"}, - {"DROP", "COLLATION"}, - {"ALTER", "CHARACTER SET"}, - {"CREATE", "PACKAGE"}, - {"ALTER", "PACKAGE"}, - {"DROP", "PACKAGE"}, - {"CREATE", "PACKAGE BODY"}, - {"DROP", "PACKAGE BODY"}, - {"CREATE", "MAPPING"}, - {"ALTER", "MAPPING"}, - {"DROP", "MAPPING"}, - {"CREATE", "SCHEMA"}, - {"ALTER", "SCHEMA"}, - {"DROP", "SCHEMA"} -}; - -inline constexpr int DDL_TRIGGER_BEFORE = 0; -inline constexpr int DDL_TRIGGER_AFTER = 1; - -inline constexpr FB_UINT64 DDL_TRIGGER_ANY = 0x7FFFFFFFFFFFFFFFULL & ~(FB_UINT64) TRIGGER_TYPE_MASK & ~1ULL; - -inline constexpr int DDL_TRIGGER_CREATE_TABLE = 1; -inline constexpr int DDL_TRIGGER_ALTER_TABLE = 2; -inline constexpr int DDL_TRIGGER_DROP_TABLE = 3; -inline constexpr int DDL_TRIGGER_CREATE_PROCEDURE = 4; -inline constexpr int DDL_TRIGGER_ALTER_PROCEDURE = 5; -inline constexpr int DDL_TRIGGER_DROP_PROCEDURE = 6; -inline constexpr int DDL_TRIGGER_CREATE_FUNCTION = 7; -inline constexpr int DDL_TRIGGER_ALTER_FUNCTION = 8; -inline constexpr int DDL_TRIGGER_DROP_FUNCTION = 9; -inline constexpr int DDL_TRIGGER_CREATE_TRIGGER = 10; -inline constexpr int DDL_TRIGGER_ALTER_TRIGGER = 11; -inline constexpr int DDL_TRIGGER_DROP_TRIGGER = 12; -// gap for TRIGGER_TYPE_MASK - 3 bits -inline constexpr int DDL_TRIGGER_CREATE_EXCEPTION = 16; -inline constexpr int DDL_TRIGGER_ALTER_EXCEPTION = 17; -inline constexpr int DDL_TRIGGER_DROP_EXCEPTION = 18; -inline constexpr int DDL_TRIGGER_CREATE_VIEW = 19; -inline constexpr int DDL_TRIGGER_ALTER_VIEW = 20; -inline constexpr int DDL_TRIGGER_DROP_VIEW = 21; -inline constexpr int DDL_TRIGGER_CREATE_DOMAIN = 22; -inline constexpr int DDL_TRIGGER_ALTER_DOMAIN = 23; -inline constexpr int DDL_TRIGGER_DROP_DOMAIN = 24; -inline constexpr int DDL_TRIGGER_CREATE_ROLE = 25; -inline constexpr int DDL_TRIGGER_ALTER_ROLE = 26; -inline constexpr int DDL_TRIGGER_DROP_ROLE = 27; -inline constexpr int DDL_TRIGGER_CREATE_INDEX = 28; -inline constexpr int DDL_TRIGGER_ALTER_INDEX = 29; -inline constexpr int DDL_TRIGGER_DROP_INDEX = 30; -inline constexpr int DDL_TRIGGER_CREATE_SEQUENCE = 31; -inline constexpr int DDL_TRIGGER_ALTER_SEQUENCE = 32; -inline constexpr int DDL_TRIGGER_DROP_SEQUENCE = 33; -inline constexpr int DDL_TRIGGER_CREATE_USER = 34; -inline constexpr int DDL_TRIGGER_ALTER_USER = 35; -inline constexpr int DDL_TRIGGER_DROP_USER = 36; -inline constexpr int DDL_TRIGGER_CREATE_COLLATION = 37; -inline constexpr int DDL_TRIGGER_DROP_COLLATION = 38; -inline constexpr int DDL_TRIGGER_ALTER_CHARACTER_SET = 39; -inline constexpr int DDL_TRIGGER_CREATE_PACKAGE = 40; -inline constexpr int DDL_TRIGGER_ALTER_PACKAGE = 41; -inline constexpr int DDL_TRIGGER_DROP_PACKAGE = 42; -inline constexpr int DDL_TRIGGER_CREATE_PACKAGE_BODY = 43; -inline constexpr int DDL_TRIGGER_DROP_PACKAGE_BODY = 44; -inline constexpr int DDL_TRIGGER_CREATE_MAPPING = 45; -inline constexpr int DDL_TRIGGER_ALTER_MAPPING = 46; -inline constexpr int DDL_TRIGGER_DROP_MAPPING = 47; -inline constexpr int DDL_TRIGGER_CREATE_SCHEMA = 48; -inline constexpr int DDL_TRIGGER_ALTER_SCHEMA = 49; -inline constexpr int DDL_TRIGGER_DROP_SCHEMA = 50; - -// that's how database trigger action types are encoded -// (TRIGGER_TYPE_DB | type) - -// that's how DDL trigger action types are encoded -// (TRIGGER_TYPE_DDL | DDL_TRIGGER_{AFTER | BEFORE} [ | DDL_TRIGGER_??? ...]) - -// switches for username and password used when an username and/or password -// is specified by the client application -#define USERNAME_SWITCH "USER" -#define PASSWORD_SWITCH "PASSWORD" - -// The highest transaction number possible -inline constexpr TraNumber MAX_TRA_NUMBER = 0x0000FFFFFFFFFFFF; // ~2.8 * 10^14 - -// Number of streams, conjuncts, indices that will be statically allocated -// in various arrays. Larger numbers will have to be allocated dynamically -inline constexpr unsigned OPT_STATIC_ITEMS = 16; -inline constexpr unsigned OPT_STATIC_STREAMS = 64; - -#define CURRENT_ENGINE "Engine14" -#define EMBEDDED_PROVIDERS "Providers=" CURRENT_ENGINE - -// Features set for current version of engine provider -#define ENGINE_FEATURES {fb_feature_multi_statements, \ - fb_feature_multi_transactions, \ - fb_feature_session_reset, \ - fb_feature_read_consistency, \ - fb_feature_statement_timeout, \ - fb_feature_statement_long_life} - -inline constexpr int WITH_GRANT_OPTION = 1; -inline constexpr int WITH_ADMIN_OPTION = 2; - -// Max length of the string returned by ERROR_TEXT context variable -inline constexpr USHORT MAX_ERROR_MSG_LENGTH = 1024 * METADATA_BYTES_PER_CHAR; // 1024 UTF-8 characters - -// Prefix of index that's getting dropped -inline constexpr const char* TEMP_DEPEND = "RDB$TEMP_DEPEND"; +#include "../common/constants.h" #endif // JRD_CONSTANTS_H diff --git a/src/jrd/cvt.cpp b/src/jrd/cvt.cpp index 7a921428d0d..5cdd80df16f 100644 --- a/src/jrd/cvt.cpp +++ b/src/jrd/cvt.cpp @@ -59,6 +59,10 @@ #include "../jrd/intl_classes.h" +namespace Firebird::Jrd +{ + + /* ERR_post is used to flag whether we were called from mov.cpp or anywhere else CVT is used from (by comparing with param err) */ @@ -85,9 +89,6 @@ #define INT64_LIMIT ((((SINT64) 1) << 62) / 5) #define NUMERIC_LIMIT (INT64_LIMIT) -using namespace Jrd; -using namespace Firebird; - double CVT_date_to_double(const dsc* desc) { @@ -455,7 +456,7 @@ ISC_TIMESTAMP_TZ CVT_get_timestamp_tz(const dsc* desc) } -Firebird::GlobalPtr EngineCallbacks::instance; +GlobalPtr EngineCallbacks::instance; bool EngineCallbacks::transliterate(const dsc* from, dsc* to, CSetId& charset2) @@ -621,3 +622,6 @@ void EngineCallbacks::isVersion4(bool& v4) v4 = (tdbb->getRequest()->getStatement()->blrVersion == 4); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/cvt2.cpp b/src/jrd/cvt2.cpp index 81ca4658ce8..78bd1f7aed2 100644 --- a/src/jrd/cvt2.cpp +++ b/src/jrd/cvt2.cpp @@ -47,13 +47,15 @@ #include "../jrd/blb_proto.h" #include "../jrd/tra.h" #include "../jrd/req.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/utils_proto.h" #include "../common/classes/Aligner.h" #include "../common/classes/VaryStr.h" -using namespace Jrd; -using namespace Firebird; + +namespace Firebird::Jrd +{ + /* The original order of dsc_type values corresponded to the priority of conversion (that is, always convert the lesser to the greater @@ -203,7 +205,7 @@ bool CVT2_get_binary_comparable_desc(dsc* result, const dsc* arg1, const dsc* ar } -static int cmp_numeric_string(const dsc* arg1, const dsc* arg2, Firebird::DecimalStatus decSt) +static int cmp_numeric_string(const dsc* arg1, const dsc* arg2, DecimalStatus decSt) { /************************************** * @@ -236,7 +238,7 @@ static int cmp_numeric_string(const dsc* arg1, const dsc* arg2, Firebird::Decima } -int CVT2_compare(const dsc* arg1, const dsc* arg2, Firebird::DecimalStatus decSt) +int CVT2_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt) { /************************************** * @@ -821,8 +823,8 @@ int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt) CharSet* charSet1 = obj1->getCharSet(); CharSet* charSet2 = obj2->getCharSet(); - Firebird::HalfStaticArray buffer1; - Firebird::HalfStaticArray buffer2; + HalfStaticArray buffer1; + HalfStaticArray buffer2; fb_assert(BUFFER_LARGE % 4 == 0); // 4 is our maximum character length UCHAR bpb[] = {isc_bpb_version1, @@ -906,7 +908,7 @@ int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt) CharSet* charSet1 = obj1->getCharSet(); - Firebird::HalfStaticArray buffer1; + HalfStaticArray buffer1; UCHAR* p; MoveBuffer temp_str; @@ -1041,3 +1043,6 @@ USHORT CVT2_make_string2(const dsc* desc, TTypeId to_interp, UCHAR** address, Mo return vtmp->vary_length; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/cvt2_proto.h b/src/jrd/cvt2_proto.h index 2db1caf9385..9a1f48b0f63 100644 --- a/src/jrd/cvt2_proto.h +++ b/src/jrd/cvt2_proto.h @@ -27,12 +27,15 @@ #include "../jrd/jrd.h" #include "../jrd/intl.h" -extern const BYTE CVT2_compare_priority[]; +namespace Firebird::Jrd +{ + extern const BYTE CVT2_compare_priority[]; -bool CVT2_get_binary_comparable_desc(dsc*, const dsc*, const dsc*); -int CVT2_compare(const dsc*, const dsc*, Firebird::DecimalStatus); -int CVT2_blob_compare(const dsc*, const dsc*, Firebird::DecimalStatus); -USHORT CVT2_make_string2(const dsc*, TTypeId, UCHAR**, Jrd::MoveBuffer&, Firebird::DecimalStatus); -void CVT2_make_metaname(const dsc* desc, Jrd::MetaName& name, Firebird::DecimalStatus); + bool CVT2_get_binary_comparable_desc(dsc*, const dsc*, const dsc*); + int CVT2_compare(const dsc*, const dsc*, DecimalStatus); + int CVT2_blob_compare(const dsc*, const dsc*, DecimalStatus); + USHORT CVT2_make_string2(const dsc*, TTypeId, UCHAR**, Jrd::MoveBuffer&, DecimalStatus); + void CVT2_make_metaname(const dsc* desc, Jrd::MetaName& name, DecimalStatus); +} // namespace Firebird::Jrd #endif // JRD_CVT2_PROTO_H diff --git a/src/jrd/cvt_proto.h b/src/jrd/cvt_proto.h index be85df5feb7..87bcfeff20f 100644 --- a/src/jrd/cvt_proto.h +++ b/src/jrd/cvt_proto.h @@ -33,18 +33,18 @@ namespace Firebird class CharSet; } -double CVT_date_to_double(const dsc*); -void CVT_double_to_date(double, SLONG[2]); -UCHAR CVT_get_numeric(const UCHAR*, const USHORT, SSHORT*, void*); -GDS_DATE CVT_get_sql_date(const dsc*); -GDS_TIME CVT_get_sql_time(const dsc*); -ISC_TIME_TZ CVT_get_sql_time_tz(const dsc*); -GDS_TIMESTAMP CVT_get_timestamp(const dsc*); -ISC_TIMESTAMP_TZ CVT_get_timestamp_tz(const dsc*); - -namespace Jrd +namespace Firebird::Jrd { - class EngineCallbacks : public Firebird::Callbacks + double CVT_date_to_double(const dsc*); + void CVT_double_to_date(double, SLONG[2]); + UCHAR CVT_get_numeric(const UCHAR*, const USHORT, SSHORT*, void*); + GDS_DATE CVT_get_sql_date(const dsc*); + GDS_TIME CVT_get_sql_time(const dsc*); + ISC_TIME_TZ CVT_get_sql_time_tz(const dsc*); + GDS_TIMESTAMP CVT_get_timestamp(const dsc*); + ISC_TIMESTAMP_TZ CVT_get_timestamp_tz(const dsc*); + + class EngineCallbacks : public Callbacks { public: explicit EngineCallbacks(ErrorFunction aErr) @@ -52,7 +52,7 @@ namespace Jrd { } - explicit EngineCallbacks(Firebird::MemoryPool&) + explicit EngineCallbacks(MemoryPool&) : Callbacks(ERR_post) { } @@ -60,9 +60,9 @@ namespace Jrd public: virtual bool transliterate(const dsc* from, dsc* to, CSetId&); virtual CSetId getChid(const dsc* d); - virtual Firebird::CharSet* getToCharset(CSetId charset2); - virtual void validateData(Firebird::CharSet* toCharset, SLONG length, const UCHAR* q); - virtual ULONG validateLength(Firebird::CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, + virtual CharSet* getToCharset(CSetId charset2); + virtual void validateData(CharSet* toCharset, SLONG length, const UCHAR* q); + virtual ULONG validateLength(CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, const USHORT size); virtual SLONG getLocalDate(); virtual ISC_TIMESTAMP getCurrentGmtTimeStamp(); @@ -70,7 +70,7 @@ namespace Jrd virtual void isVersion4(bool& v4); public: - static Firebird::GlobalPtr instance; + static GlobalPtr instance; }; class TruncateCallbacks : public EngineCallbacks @@ -81,24 +81,24 @@ namespace Jrd { } - virtual ULONG validateLength(Firebird::CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, + virtual ULONG validateLength(CharSet* charSet, CSetId charSetId, ULONG length, const UCHAR* start, const USHORT size); private: const ISC_STATUS truncateReason; }; -} -inline void CVT_move(const dsc* from, dsc* to, Firebird::DecimalStatus decSt) -{ - CVT_move_common(from, to, decSt, &Jrd::EngineCallbacks::instance); -} + inline void CVT_move(const dsc* from, dsc* to, DecimalStatus decSt) + { + CVT_move_common(from, to, decSt, &EngineCallbacks::instance); + } -inline USHORT CVT_get_string_ptr(const dsc* desc, TTypeId* ttype, UCHAR** address, - vary* temp, USHORT length, Firebird::DecimalStatus decSt) -{ - return CVT_get_string_ptr_common(desc, ttype, address, temp, length, decSt, - &Jrd::EngineCallbacks::instance); -} + inline USHORT CVT_get_string_ptr(const dsc* desc, TTypeId* ttype, UCHAR** address, + vary* temp, USHORT length, DecimalStatus decSt) + { + return CVT_get_string_ptr_common(desc, ttype, address, temp, length, decSt, + &EngineCallbacks::instance); + } +} // namespace Firebird::Jrd #endif // JRD_CVT_PROTO_H diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index aadb253cd90..9aae2dad78d 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -142,15 +142,15 @@ // Pick up system relation ids #include "../jrd/ini.h" +namespace Firebird::Jrd +{ + + inline constexpr int COMPUTED_FLAG = 128; inline constexpr int WAIT_PERIOD = -1; DATABASE DB = FILENAME "ODS.RDB"; -using namespace Jrd; -using namespace Firebird; - -namespace Jrd { typedef HashTable< DeferredWork, @@ -362,8 +362,6 @@ public: DeferredJob() : work(NULL), end(&work) { } }; -} // namespace Jrd - /*================================================================== * @@ -421,7 +419,7 @@ static bool set_statistics(thread_db*, SSHORT, DeferredWork*, jrd_tra*); static void check_computed_dependencies(thread_db* tdbb, jrd_tra* transaction, const QualifiedName& fieldName); -static void check_filename(thread_db*, const Firebird::string&, bool); +static void check_filename(thread_db*, const string&, bool); static bool find_depend_in_dfw(thread_db*, const QualifiedName&, USHORT, USHORT, jrd_tra*); static void get_trigger_dependencies(DeferredWork*, bool, jrd_tra*); @@ -721,13 +719,13 @@ namespace MemoryPool* newPool = dbb->createPool(); try { - Jrd::ContextPoolHolder context(tdbb, newPool); + JrdContextPoolHolder context(tdbb, newPool); // compile the routine to know if the BLR is still valid if (lookupById(tdbb, work->dfw_id, CacheFlag::AUTOCREATE)) validBlr = TRUE; } - catch (const Firebird::Exception&) + catch (const Exception&) { fb_utils::init_status(tdbb->tdbb_status_vector); } @@ -851,7 +849,7 @@ namespace // block is used to ensure verify_cache() // works in not deleted context { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, nullptr, NULL, 0, NULL, &blobId, (compile ? &statement : NULL), NULL, depName, @@ -1398,7 +1396,7 @@ void DFW_perform_work(thread_db* tdbb, jrd_tra* transaction) if (dsql && dsql->dbb_statement_cache) dsql->dbb_statement_cache->purgeAllAttachments(tdbb); - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); /* Loop for as long as any of the deferred work routines says that it has more to do. A deferred work routine should be able to deal with any @@ -1448,7 +1446,7 @@ void DFW_perform_work(thread_db* tdbb, jrd_tra* transaction) ++phase; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { // Do any necessary cleanup if (!phase) @@ -1752,7 +1750,7 @@ static bool add_shadow(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_tr AutoRequest handle; Shadow* shadow; bool finished; - Firebird::PathName expanded_fname; + PathName expanded_fname; SET_TDBB(tdbb); Database* const dbb = tdbb->getDatabase(); @@ -2299,7 +2297,7 @@ static bool change_repl_state(thread_db* tdbb, SSHORT phase, DeferredWork* work, return false; } -static void check_filename(thread_db* tdbb, const Firebird::string& name, bool shareExpand) +static void check_filename(thread_db* tdbb, const string& name, bool shareExpand) { /************************************** * @@ -2315,8 +2313,8 @@ static void check_filename(thread_db* tdbb, const Firebird::string& name, bool s if (tdbb->tdbb_flags & TDBB_replicator) return; - const Firebird::PathName file_name(name.ToPathName()); - const bool valid = file_name.find("::") == Firebird::PathName::npos; + const PathName file_name(name.ToPathName()); + const bool valid = file_name.find("::") == PathName::npos; if (!valid || ISC_check_if_remote(file_name, shareExpand)) { ERR_post(Arg::Gds(isc_no_meta_update) << @@ -2377,14 +2375,14 @@ string DFW_remove_icu_info_from_attributes(const QualifiedName& charsetName, con { DbgRebuildIntl::Lvl debLevel; - Firebird::AutoPtr cs(FB_NEW charset); + AutoPtr cs(FB_NEW charset); memset(cs, 0, sizeof(*cs)); if (IntlManager::lookupCharSet(charsetName, cs)) { DbgRebuildIntl::out("Remove_icu_info_from_attributes for charset '%s'\n", charsetName.toQuotedString().c_str()); - AutoPtr charSet(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); + AutoPtr charSet(CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); IntlUtil::SpecificAttributesMap map; if (IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(), (const UCHAR*) specificAttributes.begin(), &map)) @@ -2641,7 +2639,7 @@ void DFW_reset_icu(thread_db* tdbb) transaction = NULL; tdbb->setTransaction(oldTransaction); } - catch (const Firebird::Exception&) + catch (const Exception&) { if (transaction) { @@ -2711,8 +2709,8 @@ static void check_computed_dependencies(thread_db* tdbb, jrd_tra* transaction, SET_TDBB(tdbb); bool err = false; - Firebird::SortedObjectsArray sortedNames(*tdbb->getDefaultPool()); - Firebird::ObjectsArray names; + SortedObjectsArray sortedNames(*tdbb->getDefaultPool()); + ObjectsArray names; sortedNames.add(fieldName); names.add(fieldName); @@ -2947,7 +2945,7 @@ static bool create_field(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_ { Jrd::Database* dbb = tdbb->getDatabase(); MemoryPool* new_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, nullptr, NULL, 0, NULL, &validation, NULL, NULL, depName, obj_validation, 0, transaction, depName); @@ -3119,7 +3117,7 @@ static bool modify_field(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_ { Jrd::Database* dbb = tdbb->getDatabase(); MemoryPool* new_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_get_dependencies(tdbb, nullptr, NULL, 0, NULL, &validation, NULL, NULL, depName, obj_validation, 0, transaction, depName); @@ -4148,7 +4146,7 @@ static bool modify_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); MET_load_trigger(tdbb, rel, work->getQualifiedName(), [&triggers](int t)->Triggers& {return triggers[t];}); @@ -4166,7 +4164,7 @@ static bool modify_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr valid_blr = TRUE; } - catch (const Firebird::Exception&) + catch (const Exception&) { dbb->deletePool(new_pool); throw; @@ -4175,7 +4173,7 @@ static bool modify_trigger(thread_db* tdbb, SSHORT phase, DeferredWork* work, jr dbb->deletePool(new_pool); } } - catch (const Firebird::Exception&) + catch (const Exception&) { } @@ -4316,7 +4314,7 @@ static void get_trigger_dependencies(DeferredWork* work, bool compile, jrd_tra* else par_flags = 0; - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); const auto depName(work->getQualifiedName()); MET_get_dependencies(tdbb, relation, NULL, 0, NULL, &blob_id, (compile ? &statement : NULL), NULL, depName, obj_trigger, par_flags, transaction); @@ -4957,7 +4955,7 @@ static bool make_ltt_version(thread_db* tdbb, SSHORT phase, DeferredWork* work, if (lttField.notNullFlag) { - Jrd::ContextPoolHolder context(tdbb, &attPool); + JrdContextPoolHolder context(tdbb, &attPool); relField->fld_not_null = PAR_validation_blr(tdbb, &relation->getName().schema, relation->getPermanent(), nonnull_validation_blr, sizeof(nonnull_validation_blr), NULL, NULL, 0); } @@ -4998,3 +4996,4 @@ static bool make_ltt_version(thread_db* tdbb, SSHORT phase, DeferredWork* work, } +} // namespace Firebird::Jrd diff --git a/src/jrd/dfw_proto.h b/src/jrd/dfw_proto.h index 64d592c4a42..9ee9d34090a 100644 --- a/src/jrd/dfw_proto.h +++ b/src/jrd/dfw_proto.h @@ -29,32 +29,31 @@ #include "../jrd/Resources.h" #include "../common/classes/fb_string.h" -namespace Jrd -{ +namespace Firebird::Jrd { enum dfw_t : int; class thread_db; class jrd_tra; class DeferredWork; -} -USHORT DFW_assign_index_type(Jrd::thread_db*, const Jrd::QualifiedName&, SSHORT, TTypeId); -void DFW_delete_deferred(Jrd::jrd_tra*, SavNumber); -Firebird::SortedArray& DFW_get_ids(Jrd::DeferredWork* work); -void DFW_merge_work(Jrd::jrd_tra*, SavNumber, SavNumber); -void DFW_perform_work(Jrd::thread_db*, Jrd::jrd_tra*); -void DFW_perform_post_commit_work(Jrd::jrd_tra*); -void DFW_raiseRelationInUseError(const Jrd::Cached::Relation*); -Jrd::DeferredWork* DFW_post_work(Jrd::jrd_tra*, Jrd::dfw_t, const dsc* nameDesc, const dsc* schemaDesc, USHORT, - const Jrd::MetaName& package = {}); -Jrd::DeferredWork* DFW_post_work(Jrd::jrd_tra*, Jrd::dfw_t, const Firebird::string&, const Jrd::MetaName& schema, - USHORT, const Jrd::MetaName& package = {}); -Jrd::DeferredWork* DFW_post_work_arg(Jrd::jrd_tra*, Jrd::DeferredWork*, const dsc* nameDesc, const dsc* schemaDesc, - USHORT); -Jrd::DeferredWork* DFW_post_work_arg(Jrd::jrd_tra*, Jrd::DeferredWork*, const dsc* nameDesc, const dsc* schemaDesc, - USHORT, Jrd::dfw_t); -void DFW_update_index(const Jrd::QualifiedName&, USHORT, const Jrd::SelectivityList&, Jrd::jrd_tra*); -void DFW_reset_icu(Jrd::thread_db*); -Firebird::string DFW_remove_icu_info_from_attributes(const Jrd::QualifiedName&, const Firebird::string&); + USHORT DFW_assign_index_type(thread_db*, const QualifiedName&, SSHORT, TTypeId); + void DFW_delete_deferred(jrd_tra*, SavNumber); + SortedArray& DFW_get_ids(DeferredWork* work); + void DFW_merge_work(jrd_tra*, SavNumber, SavNumber); + void DFW_perform_work(thread_db*, jrd_tra*); + void DFW_perform_post_commit_work(jrd_tra*); + void DFW_raiseRelationInUseError(const Cached::Relation*); + DeferredWork* DFW_post_work(jrd_tra*, dfw_t, const dsc* nameDesc, const dsc* schemaDesc, USHORT, + const MetaName& package = {}); + DeferredWork* DFW_post_work(jrd_tra*, dfw_t, const string&, const MetaName& schema, + USHORT, const MetaName& package = {}); + DeferredWork* DFW_post_work_arg(jrd_tra*, DeferredWork*, const dsc* nameDesc, const dsc* schemaDesc, + USHORT); + DeferredWork* DFW_post_work_arg(jrd_tra*, DeferredWork*, const dsc* nameDesc, const dsc* schemaDesc, + USHORT, dfw_t); + void DFW_update_index(const QualifiedName&, USHORT, const SelectivityList&, jrd_tra*); + void DFW_reset_icu(thread_db*); + string DFW_remove_icu_info_from_attributes(const QualifiedName&, const string&); +} // namespace Firebird::Jrd #endif // JRD_DFW_PROTO_H diff --git a/src/jrd/dpm.epp b/src/jrd/dpm.epp index 3feddb21b9a..a1035355726 100644 --- a/src/jrd/dpm.epp +++ b/src/jrd/dpm.epp @@ -69,12 +69,12 @@ DATABASE DB = FILENAME "ODS.RDB"; #define DECOMPOSE(n, divisor, q, r) {r = n % divisor; q = n / divisor;} //#define DECOMPOSE_QUOTIENT(n, divisor, q) {q = n / divisor;} -#define HIGH_WATER(x) ((USHORT) sizeof (data_page) + (USHORT) sizeof (data_page::dpg_repeat) * (x - 1)) -#define SPACE_FUDGE (ROUNDUP(RHDF_SIZE, ODS_ALIGNMENT) + sizeof(data_page::dpg_repeat)) +#define HIGH_WATER(x) ((USHORT) sizeof (Ods::data_page) + (USHORT) sizeof (Ods::data_page::dpg_repeat) * (x - 1)) +#define SPACE_FUDGE (ROUNDUP(RHDF_SIZE, ODS_ALIGNMENT) + sizeof(Ods::data_page::dpg_repeat)) + +namespace Firebird::Jrd +{ -using namespace Jrd; -using namespace Ods; -using namespace Firebird; inline constexpr SSHORT MRK_commit = 256; // Table to go into pag_drop after transaction commit inline constexpr SSHORT MRK_drop = 257; // Table to be dropped when OAT >= next transaction at mark-set time @@ -82,14 +82,14 @@ inline constexpr SSHORT MRK_rollback = 258; // Table to be dropped after transa static void set_marker(thread_db*, SSHORT, SSHORT, TraNumber); static void check_swept(thread_db*, record_param*); -static USHORT compress(thread_db*, data_page*); -static void delete_tail(thread_db*, rhdf*, const USHORT, USHORT); +static USHORT compress(thread_db*, Ods::data_page*); +static void delete_tail(thread_db*, Ods::rhdf*, const USHORT, USHORT); static void fragment(thread_db*, record_param*, SSHORT, Compressor&, SSHORT, const jrd_tra*); static void extend_relation(thread_db*, Cached::Relation*, WIN*, const Jrd::RecordStorageType type); static UCHAR* find_space(thread_db*, record_param*, SSHORT, PageStack&, Record*, const Jrd::RecordStorageType type); static bool get_header(WIN*, USHORT, record_param*); -static pointer_page* get_pointer_page(thread_db*, RelationPermanent*, RelationPages*, WIN*, ULONG, USHORT); -static rhd* locate_space(thread_db*, record_param*, SSHORT, PageStack&, Record*, const Jrd::RecordStorageType type); +static Ods::pointer_page* get_pointer_page(thread_db*, RelationPermanent*, RelationPages*, WIN*, ULONG, USHORT); +static Ods::rhd* locate_space(thread_db*, record_param*, SSHORT, PageStack&, Record*, const Jrd::RecordStorageType type); static void mark_full(thread_db*, record_param*); static void store_big_record(thread_db*, record_param*, PageStack&, Compressor&, const Jrd::RecordStorageType type); @@ -141,7 +141,7 @@ namespace } -PAG DPM_allocate(thread_db* tdbb, WIN* window) +Ods::PAG DPM_allocate(thread_db* tdbb, WIN* window) { /************************************** * @@ -163,7 +163,7 @@ PAG DPM_allocate(thread_db* tdbb, WIN* window) window ? window->win_page.getPageNum() : 0); #endif - pag* page = PAG_allocate(tdbb, window); + Ods::pag* page = PAG_allocate(tdbb, window); return page; } @@ -201,14 +201,14 @@ void DPM_backout( thread_db* tdbb, record_param* rpb) #endif CCH_MARK(tdbb, &rpb->getWindow(tdbb)); - data_page* page = (data_page*) rpb->getWindow(tdbb).win_buffer; - data_page::dpg_repeat* index1 = page->dpg_rpt + rpb->rpb_line; - data_page::dpg_repeat* index2 = page->dpg_rpt + rpb->rpb_b_line; + Ods::data_page* page = (Ods::data_page*) rpb->getWindow(tdbb).win_buffer; + Ods::data_page::dpg_repeat* index1 = page->dpg_rpt + rpb->rpb_line; + Ods::data_page::dpg_repeat* index2 = page->dpg_rpt + rpb->rpb_b_line; *index1 = *index2; index2->dpg_offset = index2->dpg_length = 0; - rhd* header = (rhd*) ((SCHAR *) page + index1->dpg_offset); - header->rhd_flags &= ~(rhd_chain | rhd_gc_active); + Ods::rhd* header = (Ods::rhd*) ((SCHAR *) page + index1->dpg_offset); + header->rhd_flags &= ~(Ods::rhd_chain | Ods::rhd_gc_active); #ifdef VIO_DEBUG VIO_trace(DEBUG_WRITES_INFO, @@ -233,7 +233,7 @@ void DPM_backout( thread_db* tdbb, record_param* rpb) " new dpg_count %d\n", page->dpg_count); #endif - fb_assert((page->dpg_header.pag_flags & dpg_swept) == 0); + fb_assert((page->dpg_header.pag_flags & Ods::dpg_swept) == 0); CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); } @@ -248,11 +248,11 @@ void DPM_backout_mark(thread_db* tdbb, record_param* rpb, const jrd_tra* transac WIN* window = &rpb->getWindow(tdbb); CCH_MARK(tdbb, window); - data_page* page = (data_page*) window->win_buffer; - data_page::dpg_repeat* index = page->dpg_rpt + rpb->rpb_line; - rhd* header = (rhd*) ((SCHAR*) page + index->dpg_offset); + Ods::data_page* page = (Ods::data_page*) window->win_buffer; + Ods::data_page::dpg_repeat* index = page->dpg_rpt + rpb->rpb_line; + Ods::rhd* header = (Ods::rhd*) ((SCHAR*) page + index->dpg_offset); - header->rhd_flags |= rhd_gc_active; + header->rhd_flags |= Ods::rhd_gc_active; rpb->rpb_flags |= rpb_gc_active; CCH_RELEASE(tdbb, window); @@ -291,7 +291,7 @@ double DPM_cardinality(thread_db* tdbb, jrd_rel* relation, const Format* format) { WIN window(relPages->rel_pg_space_id, -1); - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, getPermanent(relation), relPages, &window, sequence, LCK_read); if (!ppage) { @@ -303,14 +303,14 @@ double DPM_cardinality(thread_db* tdbb, jrd_rel* relation, const Format* format) for (USHORT slot = 0; slot < ppage->ppg_count; slot++) { if (ppage->ppg_page[slot] && - !PPG_DP_BIT_TEST(bits, slot, ppg_dp_secondary) && - !PPG_DP_BIT_TEST(bits, slot, ppg_dp_empty)) + !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_secondary) && + !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_empty)) { Ods::data_page* dpage = (Ods::data_page*) CCH_HANDOFF(tdbb, &window, ppage->ppg_page[slot], LCK_read, pag_data); - const data_page::dpg_repeat* index = dpage->dpg_rpt; - const data_page::dpg_repeat* const end = index + dpage->dpg_count; + const Ods::data_page::dpg_repeat* index = dpage->dpg_rpt; + const Ods::data_page::dpg_repeat* const end = index + dpage->dpg_count; for (; index < end; index++) { if (index->dpg_offset) @@ -325,7 +325,7 @@ double DPM_cardinality(thread_db* tdbb, jrd_rel* relation, const Format* format) } } - done = (recordCount != 0) || (ppage->ppg_header.pag_flags & ppg_eof); + done = (recordCount != 0) || (ppage->ppg_header.pag_flags & Ods::ppg_eof); CCH_RELEASE(tdbb, &window); } } @@ -451,11 +451,11 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) return false; } - data_page* page = (data_page*) org_rpb->getWindow(tdbb).win_buffer; + Ods::data_page* page = (Ods::data_page*) org_rpb->getWindow(tdbb).win_buffer; // If the record obviously isn't going to fit, don't even try - if (size > dbb->dbb_page_size - (sizeof(data_page) + header_size)) + if (size > dbb->dbb_page_size - (sizeof(Ods::data_page) + header_size)) { CCH_RELEASE(tdbb, &org_rpb->getWindow(tdbb)); #ifdef VIO_DEBUG @@ -483,8 +483,8 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) SSHORT available = dbb->dbb_page_size - top; USHORT n = 0; - const data_page::dpg_repeat* index = page->dpg_rpt; - for (const data_page::dpg_repeat* const end = index + page->dpg_count; + const Ods::data_page::dpg_repeat* index = page->dpg_rpt; + for (const Ods::data_page::dpg_repeat* const end = index + page->dpg_count; index < end; index++, n++) { if (!index->dpg_length && slot == page->dpg_count) @@ -499,8 +499,8 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) if (slot == page->dpg_count) { - top += sizeof(data_page::dpg_repeat); - available -= sizeof(data_page::dpg_repeat); + top += sizeof(Ods::data_page::dpg_repeat); + available -= sizeof(Ods::data_page::dpg_repeat); } // If the record doesn't fit, punt @@ -537,15 +537,15 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) new_rpb->rpb_line = org_rpb->rpb_line; new_rpb->rpb_flags &= ~rpb_not_packed; - data_page::dpg_repeat* index2 = page->dpg_rpt + org_rpb->rpb_line; - rhd* header = (rhd*) ((SCHAR *) page + index2->dpg_offset); - header->rhd_flags |= rhd_chain; + Ods::data_page::dpg_repeat* index2 = page->dpg_rpt + org_rpb->rpb_line; + Ods::rhd* header = (Ods::rhd*) ((SCHAR *) page + index2->dpg_offset); + header->rhd_flags |= Ods::rhd_chain; page->dpg_rpt[slot] = *index2; index2->dpg_offset = space; index2->dpg_length = header_size + size + fill; - header = (rhd*) ((SCHAR *) page + space); + header = (Ods::rhd*) ((SCHAR *) page + space); header->rhd_flags = new_rpb->rpb_flags; if (new_rpb->rpb_relation) fb_assert((new_rpb->rpb_relation->getId() != 0) || (new_rpb->rpb_transaction_nr == 0)); @@ -555,7 +555,7 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) header->rhd_b_line = new_rpb->rpb_b_line; if (!dcc.isPacked()) - header->rhd_flags |= rhd_not_packed; + header->rhd_flags |= Ods::rhd_not_packed; UCHAR* const data = (UCHAR*) header + header_size; @@ -573,9 +573,9 @@ bool DPM_chain( thread_db* tdbb, record_param* org_rpb, record_param* new_rpb) new_rpb->rpb_f_line, new_rpb->rpb_flags); #endif - if (page->dpg_header.pag_flags & dpg_swept) + if (page->dpg_header.pag_flags & Ods::dpg_swept) { - page->dpg_header.pag_flags &= ~dpg_swept; + page->dpg_header.pag_flags &= ~Ods::dpg_swept; mark_full(tdbb, org_rpb); } else @@ -656,10 +656,10 @@ void DPM_create_relation_pages(thread_db* tdbb, RelationPermanent* relation, Rel // Allocate first pointer page WIN window(relPages->rel_pg_space_id, -1); - pointer_page* page = (pointer_page*) DPM_allocate(tdbb, &window); + Ods::pointer_page* page = (Ods::pointer_page*) DPM_allocate(tdbb, &window); page->ppg_header.pag_type = pag_pointer; page->ppg_relation = relation->getId(); - page->ppg_header.pag_flags = ppg_eof; + page->ppg_header.pag_flags = Ods::ppg_eof; CCH_RELEASE(tdbb, &window); // If this is relation 0 (RDB$PAGES), update the header @@ -667,7 +667,7 @@ void DPM_create_relation_pages(thread_db* tdbb, RelationPermanent* relation, Rel if (relation->getId() == 0) { WIN root_window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &root_window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &root_window, LCK_write, pag_header); CCH_MARK(tdbb, &root_window); header->hdr_PAGES = window.win_page.getPageNum(); @@ -687,7 +687,7 @@ void DPM_create_relation_pages(thread_db* tdbb, RelationPermanent* relation, Rel // Therefore, I decided that the root_window in the if() above and this one aren't related. // Create an index root page WIN root_window(relPages->rel_pg_space_id, -1); - index_root_page* root = (index_root_page*) DPM_allocate(tdbb, &root_window); + Ods::index_root_page* root = (Ods::index_root_page*) DPM_allocate(tdbb, &root_window); root->irt_header.pag_type = pag_root; root->irt_relation = relation->getId(); //root->irt_count = 0; @@ -725,7 +725,7 @@ ULONG DPM_data_pages(thread_db* tdbb, Cached::Relation* relation) WIN window(relPages->rel_pg_space_id, -1); for (ULONG sequence = 0; true; sequence++) { - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, relation, relPages, &window, sequence, LCK_read); if (!ppage) { @@ -737,14 +737,14 @@ ULONG DPM_data_pages(thread_db* tdbb, Cached::Relation* relation) for (USHORT slot = 0; slot < ppage->ppg_count; slot++) { if (ppage->ppg_page[slot] && - !PPG_DP_BIT_TEST(bits, slot, ppg_dp_secondary) && - !PPG_DP_BIT_TEST(bits, slot, ppg_dp_empty)) + !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_secondary) && + !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_empty)) { pages++; } } - if (ppage->ppg_header.pag_flags & ppg_eof) + if (ppage->ppg_header.pag_flags & Ods::ppg_eof) break; CCH_RELEASE(tdbb, &window); @@ -799,9 +799,9 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) #endif WIN* const window = &rpb->getWindow(tdbb); - data_page* page = (data_page*) window->win_buffer; + Ods::data_page* page = (Ods::data_page*) window->win_buffer; const ULONG sequence = page->dpg_sequence; - data_page::dpg_repeat* index = &page->dpg_rpt[rpb->rpb_line]; + Ods::data_page::dpg_repeat* index = &page->dpg_rpt[rpb->rpb_line]; const RecordNumber number = rpb->rpb_number; if (!get_header(window, rpb->rpb_line, rpb)) @@ -835,7 +835,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) // If the page is not empty and used to be marked as full, change the // state of both the page and the appropriate pointer page. - if (count && (page->dpg_header.pag_flags & dpg_full)) + if (count && (page->dpg_header.pag_flags & Ods::dpg_full)) { // hvlad: delay clearing of page_full flag until page has at least 25% // of free space. It saves few costly mark_full() calls when space is @@ -855,7 +855,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) return; } - page->dpg_header.pag_flags &= ~dpg_full; + page->dpg_header.pag_flags &= ~Ods::dpg_full; mark_full(tdbb, rpb); #ifdef VIO_DEBUG @@ -866,7 +866,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) } if (!count) { - page->dpg_header.pag_flags &= ~dpg_full; // PP will be modified later + page->dpg_header.pag_flags &= ~Ods::dpg_full; // PP will be modified later } const UCHAR flags = page->dpg_header.pag_flags; CCH_RELEASE(tdbb, window); @@ -876,7 +876,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) if (count) return; - if (flags & dpg_orphan) + if (flags & Ods::dpg_orphan) { // The page inventory page will be written after the page being // released, which will be written after the pages from which earlier @@ -891,7 +891,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) // Data page has gone empty. Refetch page thru pointer page. If it's // still empty, remove page from relation. - pointer_page* ppage; + Ods::pointer_page* ppage; USHORT slot; ULONG pp_sequence; DECOMPOSE(sequence, dbb->dbb_dp_per_pp, pp_sequence, slot); @@ -919,7 +919,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) // Since this fetch for exclusive access follows a (pointer page) fetch for // exclusive access, put a timeout on this fetch to be able to recover from // possible deadlocks. - page = (data_page*) CCH_FETCH_TIMEOUT(tdbb, window, LCK_write, pag_data, -1); + page = (Ods::data_page*) CCH_FETCH_TIMEOUT(tdbb, window, LCK_write, pag_data, -1); if (page) break; @@ -957,7 +957,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) { if (s != slot) { - const bool bit_empty = PPG_DP_BIT_TEST(bits, s, ppg_dp_empty); + const bool bit_empty = PPG_DP_BIT_TEST(bits, s, Ods::ppg_dp_empty); empty &= bit_empty; if (!ppage->ppg_page[s]) @@ -993,7 +993,7 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) if (s != slot) { WIN dp_window(relPages->rel_pg_space_id, pages[i]); - data_page* dpage = (data_page*) CCH_FETCH(tdbb, &dp_window, LCK_read, pag_data); + Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, &dp_window, LCK_read, pag_data); if (dpage->dpg_count) { empty = false; @@ -1012,8 +1012,8 @@ void DPM_delete( thread_db* tdbb, record_param* rpb, ULONG prior_page) CCH_precedence(tdbb, &pwindow, window->win_page); CCH_MARK(tdbb, &pwindow); - PPG_DP_BIT_SET(bits, slot, ppg_dp_empty); - PPG_DP_BIT_CLEAR(bits, slot, ppg_dp_full); + PPG_DP_BIT_SET(bits, slot, Ods::ppg_dp_empty); + PPG_DP_BIT_CLEAR(bits, slot, Ods::ppg_dp_full); CCH_RELEASE(tdbb, &pwindow); return; @@ -1137,7 +1137,7 @@ void DPM_delete_relation_pages(Jrd::thread_db* tdbb, Jrd::RelationPermanent* rel for (ULONG sequence = 0; true; sequence++) { - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, relation, relPages, &window, sequence, LCK_read); if (!ppage) BUGCHECK(246); // msg 246 pointer page lost from DPM_delete_relation @@ -1155,21 +1155,21 @@ void DPM_delete_relation_pages(Jrd::thread_db* tdbb, Jrd::RelationPermanent* rel continue; // if (flags[i >> 2] & (2 << ((i & 3) << 1))) - if (PPG_DP_BIT_TEST(flags, i, ppg_dp_large)) + if (PPG_DP_BIT_TEST(flags, i, Ods::ppg_dp_large)) { data_window.win_page = *page; - data_page* dpage = (data_page*) CCH_FETCH(tdbb, &data_window, LCK_write, pag_data); + Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, &data_window, LCK_write, pag_data); - const data_page::dpg_repeat* line = dpage->dpg_rpt; - const data_page::dpg_repeat* const end_line = line + dpage->dpg_count; + const Ods::data_page::dpg_repeat* line = dpage->dpg_rpt; + const Ods::data_page::dpg_repeat* const end_line = line + dpage->dpg_count; for (; line < end_line; line++) { if (line->dpg_length) { - rhd* header = (rhd*) ((UCHAR *) dpage + line->dpg_offset); - if (header->rhd_flags & rhd_large) + Ods::rhd* header = (Ods::rhd*) ((UCHAR *) dpage + line->dpg_offset); + if (header->rhd_flags & Ods::rhd_large) { - delete_tail(tdbb, (rhdf*)header, relPages->rel_pg_space_id, + delete_tail(tdbb, (Ods::rhdf*)header, relPages->rel_pg_space_id, line->dpg_length); } } @@ -1186,7 +1186,7 @@ void DPM_delete_relation_pages(Jrd::thread_db* tdbb, Jrd::RelationPermanent* rel pages.add(window.win_page.getPageNum()); PAG_release_pages(tdbb, relPages->rel_pg_space_id, pages.getCount(), pages.begin(), 0); - if (pag_flags & ppg_eof) + if (pag_flags & Ods::ppg_eof) break; } @@ -1441,7 +1441,7 @@ SINT64 DPM_gen_id(thread_db* tdbb, SLONG generator, bool initialize, SINT64 val) pageNumber = dbb->getKnownPage(pag_ids, sequence); if (!pageNumber) { - generator_page* page = (generator_page*) DPM_allocate(tdbb, &window); + Ods::generator_page* page = (Ods::generator_page*) DPM_allocate(tdbb, &window); page->gpg_header.pag_type = pag_ids; page->gpg_sequence = sequence; CCH_must_write(tdbb, &window); @@ -1466,7 +1466,7 @@ SINT64 DPM_gen_id(thread_db* tdbb, SLONG generator, bool initialize, SINT64 val) generator != BACKUP_HISTORY_GENERATOR); const SSHORT lock_mode = isReadOnly ? LCK_read : LCK_write; - generator_page* const page = (generator_page*) CCH_FETCH(tdbb, &window, lock_mode, pag_ids); + Ods::generator_page* const page = (Ods::generator_page*) CCH_FETCH(tdbb, &window, lock_mode, pag_ids); /* If we are in ODS >= 10, then we have a pointer to an int64 value in the * generator page: if earlier than 10, it's a pointer to a long value. @@ -1509,7 +1509,7 @@ SINT64 DPM_gen_id(thread_db* tdbb, SLONG generator, bool initialize, SINT64 val) if (transaction) transaction->tra_flags |= TRA_write; - REPL_gen_id(tdbb, generator, value, transaction); + Replication::REPL_gen_id(tdbb, generator, value, transaction); return value; } @@ -1560,11 +1560,11 @@ bool DPM_get(thread_db* tdbb, record_param* rpb, SSHORT lock_type) if (page_number) { window->win_page = page_number; - data_page* dpage = (data_page*) CCH_FETCH(tdbb, window, lock_type, pag_undefined); + Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, window, lock_type, pag_undefined); const bool pageOk = dpage->dpg_header.pag_type == pag_data && - !(dpage->dpg_header.pag_flags & (dpg_secondary | dpg_orphan)) && + !(dpage->dpg_header.pag_flags & (Ods::dpg_secondary | Ods::dpg_orphan)) && dpage->dpg_relation == rpb->rpb_relation->getId() && dpage->dpg_sequence == dpSequence && (dpage->dpg_count > 0); @@ -1582,7 +1582,7 @@ bool DPM_get(thread_db* tdbb, record_param* rpb, SSHORT lock_type) } // Find the pointer page, data page, and record - pointer_page* page = get_pointer_page(tdbb, getPermanent(rpb->rpb_relation), + Ods::pointer_page* page = get_pointer_page(tdbb, getPermanent(rpb->rpb_relation), relPages, window, pp_sequence, LCK_read); if (!page) @@ -1657,7 +1657,7 @@ ULONG DPM_get_blob(thread_db* tdbb, // record doesn't exist, or the record isn't a blob, give up and // let somebody else complain. - pointer_page* ppage = get_pointer_page(tdbb, relation->getPermanent(), + Ods::pointer_page* ppage = get_pointer_page(tdbb, relation->getPermanent(), relation->getPages(tdbb), &rpb.getWindow(tdbb), pp_sequence, LCK_read); if (!ppage) { @@ -1672,7 +1672,7 @@ ULONG DPM_get_blob(thread_db* tdbb, if (!page_number) goto punt; - data_page* page = (data_page*) CCH_HANDOFF(tdbb, + Ods::data_page* page = (Ods::data_page*) CCH_HANDOFF(tdbb, &rpb.getWindow(tdbb), page_number, (SSHORT) (delete_flag ? LCK_write : LCK_read), @@ -1680,12 +1680,12 @@ ULONG DPM_get_blob(thread_db* tdbb, if (line >= page->dpg_count) goto punt; - data_page::dpg_repeat* index = &page->dpg_rpt[line]; + Ods::data_page::dpg_repeat* index = &page->dpg_rpt[line]; if (index->dpg_offset == 0) goto punt; - blh* header = (blh*) ((SCHAR *) page + index->dpg_offset); - if (!(header->blh_flags & rhd_blob)) + Ods::blh* header = (Ods::blh*) ((SCHAR *) page + index->dpg_offset); + if (!(header->blh_flags & Ods::rhd_blob)) goto punt; // We've got the blob header and everything looks ducky. Get the header @@ -1708,10 +1708,10 @@ ULONG DPM_get_blob(thread_db* tdbb, blob->blb_flags |= BLB_large_scan; } - if (header->blh_flags & rhd_stream_blob) + if (header->blh_flags & Ods::rhd_stream_blob) blob->blb_flags |= BLB_stream; - if (header->blh_flags & rhd_damaged) + if (header->blh_flags & Ods::rhd_damaged) goto punt; // Retrieve the data either into page clump (level 0) or page vector (levels @@ -1824,11 +1824,11 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, FindNextReco fb_assert(window->win_page.getPageSpaceID() == relPages->rel_pg_space_id); window->win_page = page_number; - const data_page* dpage = (data_page*) CCH_FETCH(tdbb, window, lock_type, pag_undefined); + const Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, window, lock_type, pag_undefined); const bool pageOk = dpage->dpg_header.pag_type == pag_data && - !(dpage->dpg_header.pag_flags & (dpg_secondary | dpg_orphan)) && + !(dpage->dpg_header.pag_flags & (Ods::dpg_secondary | Ods::dpg_orphan)) && dpage->dpg_relation == rpb->rpb_relation->getId() && dpage->dpg_sequence == dpSequence && (dpage->dpg_count > 0); @@ -1857,7 +1857,7 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, FindNextReco while (true) { - const pointer_page* ppage = get_pointer_page(tdbb, getPermanent(rpb->rpb_relation), + const Ods::pointer_page* ppage = get_pointer_page(tdbb, getPermanent(rpb->rpb_relation), relPages, window, pp_sequence, LCK_read); if (!ppage) BUGCHECK(249); // msg 249 pointer page vanished from DPM_next @@ -1866,9 +1866,9 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, FindNextReco { const ULONG page_number = ppage->ppg_page[slot]; const UCHAR* bits = (UCHAR*) (ppage->ppg_page + dbb->dbb_dp_per_pp); - if (page_number && !PPG_DP_BIT_TEST(bits, slot, ppg_dp_secondary) && - !PPG_DP_BIT_TEST(bits, slot, ppg_dp_empty) && - (!sweeper || !PPG_DP_BIT_TEST(bits, slot, ppg_dp_swept)) ) + if (page_number && !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_secondary) && + !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_empty) && + (!sweeper || !PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_swept)) ) { #ifdef SUPERSERVER_V2 // Perform sequential prefetch of relation's data pages. @@ -1895,7 +1895,7 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, FindNextReco #endif dpSequence = ppage->ppg_sequence * dbb->dbb_dp_per_pp + slot; relPages->setDPNumber(dpSequence, page_number); - const data_page* dpage = (data_page*) CCH_HANDOFF(tdbb, window, + const Ods::data_page* dpage = (Ods::data_page*) CCH_HANDOFF(tdbb, window, page_number, lock_type, pag_data); for (; line < dpage->dpg_count; ++line) @@ -1972,7 +1972,7 @@ bool DPM_next(thread_db* tdbb, record_param* rpb, USHORT lock_type, FindNextReco else CCH_RELEASE(tdbb, window); - if ((flags & ppg_eof) || (scope != DPM_next_all)) + if ((flags & Ods::ppg_eof) || (scope != DPM_next_all)) return false; } } @@ -2062,7 +2062,7 @@ SLONG DPM_prefetch_bitmap(thread_db* tdbb, jrd_rel* relation, PageBitmap* bitmap DECOMPOSE(number, dbb->dbb_max_records, dp_sequence, line); DECOMPOSE(dp_sequence, dbb->dbb_dp_per_pp, pp_sequence, slot); - const pointer_page* ppage = get_pointer_page(tdbb, relation->getPermanent(), &window, pp_sequence, LCK_read); + const Ods::pointer_page* ppage = get_pointer_page(tdbb, relation->getPermanent(), &window, pp_sequence, LCK_read); if (!ppage) BUGCHECK(249); // msg 249 pointer page vanished from DPM_prefetch_bitmap @@ -2110,7 +2110,7 @@ ULONG DPM_pointer_pages(thread_db* tdbb, jrd_rel* relation) while (true) { - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, getPermanent(relation), relPages, &window, sequence, LCK_read); if (!ppage) @@ -2119,7 +2119,7 @@ ULONG DPM_pointer_pages(thread_db* tdbb, jrd_rel* relation) // msg 243 missing pointer page in DPM_data_pages } - const bool eof = (ppage->ppg_header.pag_flags & ppg_eof); + const bool eof = (ppage->ppg_header.pag_flags & Ods::ppg_eof); CCH_RELEASE(tdbb, &window); if (eof) @@ -2171,14 +2171,14 @@ void DPM_scan_pages( thread_db* tdbb) vcl* vector = *address; FB_SIZE_T sequence = vector->count() - 1; WIN window(relPages->rel_pg_space_id, (*vector)[sequence]); - pointer_page* ppage = (pointer_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_pointer); + Ods::pointer_page* ppage = (Ods::pointer_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_pointer); while (ppage->ppg_next) { ++sequence; vector->resize(sequence + 1); (*vector)[sequence] = ppage->ppg_next; - ppage = (pointer_page*) CCH_HANDOFF(tdbb, &window, ppage->ppg_next, LCK_read, pag_pointer); + ppage = (Ods::pointer_page*) CCH_HANDOFF(tdbb, &window, ppage->ppg_next, LCK_read, pag_pointer); } CCH_RELEASE(tdbb, &window); @@ -2373,7 +2373,7 @@ void DPM_store( thread_db* tdbb, record_param* rpb, PageStack& stack, const Jrd: const auto size = dcc.getPackedLength(); const ULONG header_size = (rpb->rpb_transaction_nr > MAX_ULONG) ? RHDE_SIZE : RHD_SIZE; - const ULONG max_data = dbb->dbb_page_size - sizeof(data_page) - header_size; + const ULONG max_data = dbb->dbb_page_size - sizeof(Ods::data_page) - header_size; // If the record isn't going to fit on a page, even if fragmented, // handle it a little differently. @@ -2390,7 +2390,7 @@ void DPM_store( thread_db* tdbb, record_param* rpb, PageStack& stack, const Jrd: // Accommodate max record size i.e. 64K const SLONG length = header_size + size + fill; - rhd* header = locate_space(tdbb, rpb, (SSHORT) length, stack, NULL, type); + Ods::rhd* header = locate_space(tdbb, rpb, (SSHORT) length, stack, NULL, type); rpb->rpb_flags &= ~rpb_not_packed; @@ -2403,7 +2403,7 @@ void DPM_store( thread_db* tdbb, record_param* rpb, PageStack& stack, const Jrd: header->rhd_b_line = rpb->rpb_b_line; if (!dcc.isPacked()) - header->rhd_flags |= rhd_not_packed; + header->rhd_flags |= Ods::rhd_not_packed; UCHAR* const data = (UCHAR*) header + header_size; @@ -2427,19 +2427,17 @@ void DPM_store( thread_db* tdbb, record_param* rpb, PageStack& stack, const Jrd: // When restoring, mark primary data page as swept, pointer page already marked by locate_space() if (swept_at_restore(tdbb, rpb->rpb_relation->getPermanent()) && (type == DPM_primary)) { - page->pag_flags |= dpg_swept; + page->pag_flags |= Ods::dpg_swept; CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); } - else if (page->pag_flags & dpg_swept) + else if (page->pag_flags & Ods::dpg_swept) { - page->pag_flags &= ~dpg_swept; + page->pag_flags &= ~Ods::dpg_swept; mark_full(tdbb, rpb); } else CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); } - - RecordNumber DPM_store_blob(thread_db* tdbb, blb* blob, jrd_rel* relation, Record* record) { /************************************** @@ -2467,7 +2465,7 @@ RecordNumber DPM_store_blob(thread_db* tdbb, blb* blob, jrd_rel* relation, Recor USHORT length; const UCHAR* q; PageStack stack; - Firebird::Array buffer; + Array buffer; blob->storeToPage(&length, buffer, &q, &stack); @@ -2483,25 +2481,25 @@ RecordNumber DPM_store_blob(thread_db* tdbb, blb* blob, jrd_rel* relation, Recor if (blob->blb_flags & BLB_bulk) rpb.rpb_stream_flags |= RPB_s_bulk; - blh* header = (blh*) locate_space(tdbb, &rpb, (SSHORT) (BLH_SIZE + length), + Ods::blh* header = (Ods::blh*) locate_space(tdbb, &rpb, (SSHORT) (BLH_SIZE + length), stack, record, DPM_other); - header->blh_flags = rhd_blob; + header->blh_flags = Ods::rhd_blob; if (blob->blb_flags & BLB_stream) - header->blh_flags |= rhd_stream_blob; + header->blh_flags |= Ods::rhd_stream_blob; if (blob->getLevel()) - header->blh_flags |= rhd_large; + header->blh_flags |= Ods::rhd_large; blob->toPageHeader(header); if (length) memcpy(header->blh_page, q, length); - data_page* page = (data_page*) rpb.getWindow(tdbb).win_buffer; - if (blob->getLevel() && !(page->dpg_header.pag_flags & dpg_large)) + Ods::data_page* page = (Ods::data_page*) rpb.getWindow(tdbb).win_buffer; + if (blob->getLevel() && !(page->dpg_header.pag_flags & Ods::dpg_large)) { - page->dpg_header.pag_flags |= dpg_large; + page->dpg_header.pag_flags |= Ods::dpg_large; mark_full(tdbb, &rpb); } else { @@ -2540,8 +2538,8 @@ void DPM_rewrite_header( thread_db* tdbb, record_param* rpb) #endif WIN* window = &rpb->getWindow(tdbb); - data_page* page = (data_page*) window->win_buffer; - rhd* header = (rhd*) ((SCHAR *) page + page->dpg_rpt[rpb->rpb_line].dpg_offset); + Ods::data_page* page = (Ods::data_page*) window->win_buffer; + Ods::rhd* header = (Ods::rhd*) ((SCHAR *) page + page->dpg_rpt[rpb->rpb_line].dpg_offset); #ifdef VIO_DEBUG VIO_trace(DEBUG_WRITES_INFO, @@ -2611,7 +2609,7 @@ void DPM_update( thread_db* tdbb, record_param* rpb, PageStack* stack, const jrd CCH_tra_precedence(tdbb, &rpb->getWindow(tdbb), rpb->rpb_transaction_nr); CCH_MARK(tdbb, &rpb->getWindow(tdbb)); - data_page* page = (data_page*) rpb->getWindow(tdbb).win_buffer; + Ods::data_page* page = (Ods::data_page*) rpb->getWindow(tdbb).win_buffer; Compressor dcc(tdbb, rpb->rpb_length, rpb->rpb_address); const auto size = dcc.getPackedLength(); @@ -2636,8 +2634,8 @@ void DPM_update( thread_db* tdbb, record_param* rpb, PageStack* stack, const jrd const USHORT old_length = page->dpg_rpt[slot].dpg_length; page->dpg_rpt[slot].dpg_length = 0; - const data_page::dpg_repeat* index = page->dpg_rpt; - for (const data_page::dpg_repeat* const end = index + page->dpg_count; index < end; index++) + const Ods::data_page::dpg_repeat* index = page->dpg_rpt; + for (const Ods::data_page::dpg_repeat* const end = index + page->dpg_count; index < end; index++) { if (index->dpg_offset) { @@ -2664,7 +2662,7 @@ void DPM_update( thread_db* tdbb, record_param* rpb, PageStack* stack, const jrd rpb->rpb_flags &= ~rpb_not_packed; - rhd* header = (rhd*) ((SCHAR *) page + space); + Ods::rhd* header = (Ods::rhd*) ((SCHAR *) page + space); header->rhd_flags = rpb->rpb_flags; if (rpb->rpb_relation) fb_assert((rpb->rpb_relation->getId() != 0) || (rpb->rpb_transaction_nr == 0)); @@ -2674,7 +2672,7 @@ void DPM_update( thread_db* tdbb, record_param* rpb, PageStack* stack, const jrd header->rhd_b_line = rpb->rpb_b_line; if (!dcc.isPacked()) - header->rhd_flags |= rhd_not_packed; + header->rhd_flags |= Ods::rhd_not_packed; UCHAR* const data = (UCHAR*) header + header_size; @@ -2693,9 +2691,9 @@ void DPM_update( thread_db* tdbb, record_param* rpb, PageStack* stack, const jrd if (fill) memset(data + size, 0, fill); - if (page->dpg_header.pag_flags & dpg_swept) + if (page->dpg_header.pag_flags & Ods::dpg_swept) { - page->dpg_header.pag_flags &= ~dpg_swept; + page->dpg_header.pag_flags &= ~Ods::dpg_swept; mark_full(tdbb, rpb); } else @@ -2728,28 +2726,28 @@ static void check_swept(thread_db* tdbb, record_param* rpb) rpb->rpb_number.decompose(dbb->dbb_max_records, dbb->dbb_dp_per_pp, line, slot, pp_sequence); - pointer_page* ppage = + Ods::pointer_page* ppage = get_pointer_page(tdbb, getPermanent(rpb->rpb_relation), relPages, window, pp_sequence, LCK_read); if (!ppage) return; const UCHAR* bits = (UCHAR*) (ppage->ppg_page + dbb->dbb_dp_per_pp); if (slot >= ppage->ppg_count || !ppage->ppg_page[slot] || - PPG_DP_BIT_TEST(bits, slot, ppg_dp_secondary | ppg_dp_swept)) + PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_secondary | Ods::ppg_dp_swept)) { CCH_RELEASE(tdbb, window); return; } - data_page* dpage = (data_page*) + Ods::data_page* dpage = (Ods::data_page*) CCH_HANDOFF(tdbb, window, ppage->ppg_page[slot], LCK_write, pag_data); for (USHORT line = 0; line < dpage->dpg_count; ++line) { - const data_page::dpg_repeat* index = &dpage->dpg_rpt[line]; + const Ods::data_page::dpg_repeat* index = &dpage->dpg_rpt[line]; if (index->dpg_offset) { - rhd* header = (rhd*) ((SCHAR*) dpage + index->dpg_offset); + Ods::rhd* header = (Ods::rhd*) ((SCHAR*) dpage + index->dpg_offset); if (Ods::getTraNum(header) > transaction->tra_oldest || (header->rhd_flags & (rpb_blob | rpb_chained | rpb_fragment | rpb_deleted)) || header->rhd_b_page) @@ -2761,12 +2759,12 @@ static void check_swept(thread_db* tdbb, record_param* rpb) } CCH_MARK(tdbb, window); - dpage->dpg_header.pag_flags |= dpg_swept; + dpage->dpg_header.pag_flags |= Ods::dpg_swept; mark_full(tdbb, rpb); } -static USHORT compress(thread_db* tdbb, data_page* page) +static USHORT compress(thread_db* tdbb, Ods::data_page* page) { /************************************** * @@ -2794,9 +2792,9 @@ static USHORT compress(thread_db* tdbb, data_page* page) BUGCHECK(250); // msg 250 temporary page buffer too small USHORT space = dbb->dbb_page_size; - const data_page::dpg_repeat* const end = page->dpg_rpt + page->dpg_count; + const Ods::data_page::dpg_repeat* const end = page->dpg_rpt + page->dpg_count; - for (data_page::dpg_repeat* index = page->dpg_rpt; index < end; index++) + for (Ods::data_page::dpg_repeat* index = page->dpg_rpt; index < end; index++) { if (index->dpg_offset) { @@ -2820,7 +2818,7 @@ static USHORT compress(thread_db* tdbb, data_page* page) } -static void delete_tail(thread_db* tdbb, rhdf* header, const USHORT page_space, USHORT length) +static void delete_tail(thread_db* tdbb, Ods::rhdf* header, const USHORT page_space, USHORT length) { /************************************** * @@ -2853,22 +2851,22 @@ static void delete_tail(thread_db* tdbb, rhdf* header, const USHORT page_space, // If the object isn't a blob, things are a little simpler. - if (!(header->rhdf_flags & rhd_blob)) + if (!(header->rhdf_flags & Ods::rhd_blob)) { USHORT flags = header->rhdf_flags; ULONG page_number = header->rhdf_f_page; - fb_assert(flags & rhd_incomplete); + fb_assert(flags & Ods::rhd_incomplete); - while (flags & rhd_incomplete) + while (flags & Ods::rhd_incomplete) { window.win_page = page_number; - data_page* dpage = (data_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_data); + Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_data); - if (dpage->dpg_header.pag_flags & dpg_orphan && - dpage->dpg_header.pag_flags & dpg_full && + if (dpage->dpg_header.pag_flags & Ods::dpg_orphan && + dpage->dpg_header.pag_flags & Ods::dpg_full && dpage->dpg_count == 1) { - header = (rhdf*) ((UCHAR *) dpage + dpage->dpg_rpt[0].dpg_offset); + header = (Ods::rhdf*) ((UCHAR *) dpage + dpage->dpg_rpt[0].dpg_offset); flags = header->rhdf_flags; page_number = header->rhdf_f_page; @@ -2886,7 +2884,7 @@ static void delete_tail(thread_db* tdbb, rhdf* header, const USHORT page_space, // Object is a blob, and a big one at that - blh* blob = (blh*) header; + Ods::blh* blob = (Ods::blh*) header; const ULONG* page1 = blob->blh_page; const ULONG* const end1 = page1 + (length - BLH_SIZE) / sizeof(ULONG); @@ -2895,7 +2893,7 @@ static void delete_tail(thread_db* tdbb, rhdf* header, const USHORT page_space, if (blob->blh_level == 2) { window.win_page = *page1; - blob_page* bpage = (blob_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_blob); + Ods::blob_page* bpage = (Ods::blob_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_blob); ULONG* page2 = bpage->blp_page; const ULONG* const end2 = page2 + ((bpage->blp_length) / sizeof(ULONG)); @@ -3001,28 +2999,28 @@ static void fragment(thread_db* tdbb, new version. */ WIN* window = &rpb->getWindow(tdbb); - data_page* page = (data_page*) window->win_buffer; + Ods::data_page* page = (Ods::data_page*) window->win_buffer; const USHORT line = rpb->rpb_line; - rhdf* header; + Ods::rhdf* header; if (rpb->rpb_transaction_nr != transaction->tra_number) { - header = (rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); + header = (Ods::rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); page->dpg_rpt[line].dpg_length = available_space = length; } else { if (rpb->rpb_flags & rpb_delta) { - header = (rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); + header = (Ods::rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); header->rhdf_flags |= rpb_delta; page->dpg_rpt[line].dpg_length = available_space = length; } else { const USHORT space = compress(tdbb, page) - available_space; - header = (rhdf*) ((SCHAR *) page + space); - header->rhdf_flags = rhd_deleted; + header = (Ods::rhdf*) ((SCHAR *) page + space); + header->rhdf_flags = Ods::rhd_deleted; header->rhdf_f_page = header->rhdf_f_line = 0; const ULONG header_size = (transaction->tra_number > MAX_ULONG) ? RHDE_SIZE : RHD_SIZE; @@ -3038,7 +3036,7 @@ static void fragment(thread_db* tdbb, header->rhdf_b_line = rpb->rpb_b_line; } - header->rhdf_flags |= rhd_gc_active; + header->rhdf_flags |= Ods::rhd_gc_active; AutoLock gcLockGuard(tdbb, lockGCActive(tdbb, transaction, rpb)); @@ -3083,14 +3081,14 @@ static void fragment(thread_db* tdbb, // That was unreasonablly easy. Now re-fetch the original page and // fill in the fragment pointer - page = (data_page*) CCH_FETCH(tdbb, window, LCK_write, pag_data); + page = (Ods::data_page*) CCH_FETCH(tdbb, window, LCK_write, pag_data); CCH_precedence(tdbb, window, tail_rpb.rpb_page); CCH_MARK(tdbb, window); rpb->rpb_flags &= ~rpb_not_packed; - header = (rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); - header->rhdf_flags = rhd_incomplete | rpb->rpb_flags; + header = (Ods::rhdf*) ((SCHAR *) page + page->dpg_rpt[line].dpg_offset); + header->rhdf_flags = Ods::rhd_incomplete | rpb->rpb_flags; if (rpb->rpb_relation) fb_assert((rpb->rpb_relation->getId() != 0) || (rpb->rpb_transaction_nr == 0)); Ods::writeTraNum(header, rpb->rpb_transaction_nr, RHDF_SIZE); @@ -3105,7 +3103,7 @@ static void fragment(thread_db* tdbb, } if (!dcc.isPacked()) - header->rhdf_flags |= rhd_not_packed; + header->rhdf_flags |= Ods::rhd_not_packed; gcLockGuard.release(); @@ -3128,9 +3126,9 @@ static void fragment(thread_db* tdbb, header->rhdf_b_line); #endif - if (page->dpg_header.pag_flags & dpg_swept) + if (page->dpg_header.pag_flags & Ods::dpg_swept) { - page->dpg_header.pag_flags &= ~dpg_swept; + page->dpg_header.pag_flags &= ~Ods::dpg_swept; mark_full(tdbb, rpb); } else @@ -3170,7 +3168,7 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi // - allocation of a new pointer page requires the fetching of the PIP page with // an exlusive latch. - pointer_page* ppage = NULL; + Ods::pointer_page* ppage = NULL; ULONG pp_sequence; USHORT slot = 0; @@ -3200,12 +3198,12 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi break; } - if (ppage->ppg_header.pag_flags & ppg_eof) + if (ppage->ppg_header.pag_flags & Ods::ppg_eof) { WIN new_pp_window(relPages->rel_pg_space_id, -1); - pointer_page* new_ppage = (pointer_page*) DPM_allocate(tdbb, &new_pp_window); + Ods::pointer_page* new_ppage = (Ods::pointer_page*) DPM_allocate(tdbb, &new_pp_window); new_ppage->ppg_header.pag_type = pag_pointer; - new_ppage->ppg_header.pag_flags |= ppg_eof; + new_ppage->ppg_header.pag_flags |= Ods::ppg_eof; new_ppage->ppg_relation = relation->getId(); new_ppage->ppg_sequence = ++pp_sequence; slot = 0; @@ -3225,7 +3223,7 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi relPages->rel_slot_space = pp_sequence; CCH_MARK(tdbb, &pp_window); - ppage->ppg_header.pag_flags &= ~ppg_eof; + ppage->ppg_header.pag_flags &= ~Ods::ppg_eof; ppage->ppg_next = new_pp_window.win_page.getPageNum(); --pp_sequence; } @@ -3252,14 +3250,14 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi } } - data_page* dpage = (data_page*) PAG_allocate_pages(tdbb, window, cntAlloc, cntAlloc != 1); + Ods::data_page* dpage = (Ods::data_page*) PAG_allocate_pages(tdbb, window, cntAlloc, cntAlloc != 1); const PageNumber firstPage = window->win_page; dpage->dpg_sequence = pp_sequence * dbb->dbb_dp_per_pp + slot; dpage->dpg_relation = relation->getId(); dpage->dpg_header.pag_type = pag_data; if (type != DPM_primary) { - dpage->dpg_header.pag_flags |= dpg_secondary; + dpage->dpg_header.pag_flags |= Ods::dpg_secondary; } CCH_RELEASE(tdbb, window); @@ -3269,7 +3267,7 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi { window->win_page = firstPage.getPageNum() + i; - dpage = (data_page*) CCH_fake(tdbb, window, 1); + dpage = (Ods::data_page*) CCH_fake(tdbb, window, 1); dpage->dpg_sequence = pp_sequence * dbb->dbb_dp_per_pp + slot + i; dpage->dpg_relation = relation->getId(); dpage->dpg_header.pag_type = pag_data; @@ -3284,24 +3282,24 @@ static void extend_relation(thread_db* tdbb, Cached::Relation* relation, WIN* wi ppage->ppg_count = MAX(ppage->ppg_count, slot + cntAlloc); UCHAR* bits = (UCHAR*) (ppage->ppg_page + dbb->dbb_dp_per_pp); - PPG_DP_BIT_CLEAR(bits, slot, PPG_DP_ALL_BITS); + PPG_DP_BIT_CLEAR(bits, slot, Ods::PPG_DP_ALL_BITS); if (type == DPM_primary) { // When restoring, mark slot as swept, data page will be marked by our caller if (swept_at_restore(tdbb, relation)) - PPG_DP_BIT_SET(bits, slot, ppg_dp_swept); + PPG_DP_BIT_SET(bits, slot, Ods::ppg_dp_swept); } else - PPG_DP_BIT_SET(bits, slot, ppg_dp_secondary); + PPG_DP_BIT_SET(bits, slot, Ods::ppg_dp_secondary); for (unsigned i = 1; i < cntAlloc; i++) { fb_assert(ppage->ppg_page[slot + i] == 0); ppage->ppg_page[slot + i] = firstPage.getPageNum() + i; - PPG_DP_BIT_CLEAR(bits, slot + i, PPG_DP_ALL_BITS); - PPG_DP_BIT_SET(bits, slot + i, ppg_dp_empty); + PPG_DP_BIT_CLEAR(bits, slot + i, Ods::PPG_DP_ALL_BITS); + PPG_DP_BIT_SET(bits, slot + i, Ods::ppg_dp_empty); } if (type == DPM_primary) @@ -3356,9 +3354,9 @@ static UCHAR* find_space(thread_db* tdbb, CHECK_DBB(dbb); const SSHORT aligned_size = ROUNDUP(size, ODS_ALIGNMENT); - data_page* page = (data_page*) rpb->getWindow(tdbb).win_buffer; + Ods::data_page* page = (Ods::data_page*) rpb->getWindow(tdbb).win_buffer; - if ((page->dpg_count > 0) && (type == DPM_primary) && (page->dpg_header.pag_flags & dpg_secondary)) + if ((page->dpg_count > 0) && (type == DPM_primary) && (page->dpg_header.pag_flags & Ods::dpg_secondary)) { // Attempt to put primary record on secondary data page - seems // flags on PP is not correct. Fix flags and let caller to find @@ -3377,7 +3375,7 @@ static UCHAR* find_space(thread_db* tdbb, { // scope const bool reserving = !(dbb->dbb_flags & DBB_no_reserve); - const data_page::dpg_repeat* index = page->dpg_rpt; + const Ods::data_page::dpg_repeat* index = page->dpg_rpt; for (USHORT i = 0; i < page->dpg_count; i++, index++) { if (index->dpg_offset) @@ -3386,9 +3384,9 @@ static UCHAR* find_space(thread_db* tdbb, used += ROUNDUP(index->dpg_length, ODS_ALIGNMENT); if (type == DPM_primary && reserving) { - const rhd* header = (rhd*) ((SCHAR *) page + index->dpg_offset); + const Ods::rhd* header = (Ods::rhd*) ((SCHAR *) page + index->dpg_offset); if (!header->rhd_b_page && - !(header->rhd_flags & (rhd_chain | rhd_blob | rhd_deleted | rhd_fragment))) + !(header->rhd_flags & (Ods::rhd_chain | Ods::rhd_blob | Ods::rhd_deleted | Ods::rhd_fragment))) { used += SPACE_FUDGE; } @@ -3400,16 +3398,16 @@ static UCHAR* find_space(thread_db* tdbb, } // scope if (!slot) - used += sizeof(data_page::dpg_repeat); + used += sizeof(Ods::data_page::dpg_repeat); // If there isn't space, give up if (aligned_size > (int) dbb->dbb_page_size - used) { - if (!(page->dpg_header.pag_flags & dpg_full)) + if (!(page->dpg_header.pag_flags & Ods::dpg_full)) { CCH_MARK(tdbb, &rpb->getWindow(tdbb)); - page->dpg_header.pag_flags |= dpg_full; + page->dpg_header.pag_flags |= Ods::dpg_full; mark_full(tdbb, rpb); } else @@ -3439,7 +3437,7 @@ static UCHAR* find_space(thread_db* tdbb, fb_assert(space >= aligned_size); space -= aligned_size; - data_page::dpg_repeat* index = &page->dpg_rpt[slot]; + Ods::data_page::dpg_repeat* index = &page->dpg_rpt[slot]; index->dpg_length = size; index->dpg_offset = space; rpb->rpb_page = rpb->getWindow(tdbb).win_page.getPageNum(); @@ -3452,9 +3450,9 @@ static UCHAR* find_space(thread_db* tdbb, if (page->dpg_count == 1) { if (type == DPM_primary) - page->dpg_header.pag_flags &= ~dpg_secondary; + page->dpg_header.pag_flags &= ~Ods::dpg_secondary; else - page->dpg_header.pag_flags |= dpg_secondary; + page->dpg_header.pag_flags |= Ods::dpg_secondary; } return (UCHAR*) page + space; @@ -3474,15 +3472,15 @@ static bool get_header(WIN* window, USHORT line, record_param* rpb) * the line is empty, return false; * **************************************/ - const data_page* page = (data_page*) window->win_buffer; + const Ods::data_page* page = (Ods::data_page*) window->win_buffer; if (line >= page->dpg_count) return false; - const data_page::dpg_repeat* index = &page->dpg_rpt[line]; + const Ods::data_page::dpg_repeat* index = &page->dpg_rpt[line]; if (index->dpg_offset == 0) return false; - rhdf* header = (rhdf*) ((SCHAR *) page + index->dpg_offset); + Ods::rhdf* header = (Ods::rhdf*) ((SCHAR *) page + index->dpg_offset); rpb->rpb_page = window->win_page.getPageNum(); rpb->rpb_line = line; rpb->rpb_flags = header->rhdf_flags; @@ -3517,7 +3515,7 @@ static bool get_header(WIN* window, USHORT line, record_param* rpb) } -static pointer_page* get_pointer_page(thread_db* tdbb, +static Ods::pointer_page* get_pointer_page(thread_db* tdbb, RelationPermanent* relation, RelationPages* relPages, WIN* window, ULONG sequence, USHORT lock) { @@ -3550,7 +3548,7 @@ static pointer_page* get_pointer_page(thread_db* tdbb, break; // we are in business again window->win_page = (*vector)[vector->count() - 1]; - const pointer_page* page = (pointer_page*) CCH_FETCH(tdbb, window, lock, pag_pointer); + const Ods::pointer_page* page = (Ods::pointer_page*) CCH_FETCH(tdbb, window, lock, pag_pointer); const ULONG next_ppg = page->ppg_next; CCH_RELEASE(tdbb, window); if (!next_ppg) @@ -3563,7 +3561,7 @@ static pointer_page* get_pointer_page(thread_db* tdbb, } window->win_page = (*vector)[sequence]; - pointer_page* page = (pointer_page*) CCH_FETCH(tdbb, window, lock, pag_pointer); + Ods::pointer_page* page = (Ods::pointer_page*) CCH_FETCH(tdbb, window, lock, pag_pointer); if (page->ppg_relation != relation->getId() || page->ppg_sequence != sequence) CORRUPT(259); // msg 259 bad pointer page @@ -3572,7 +3570,7 @@ static pointer_page* get_pointer_page(thread_db* tdbb, } -static rhd* locate_space(thread_db* tdbb, +static Ods::rhd* locate_space(thread_db* tdbb, record_param* rpb, SSHORT size, PageStack& stack, Record* record, const Jrd::RecordStorageType type) { @@ -3607,7 +3605,7 @@ static rhd* locate_space(thread_db* tdbb, USHORT slot, line; rpb->rpb_number.decompose(dbb->dbb_max_records, dbb->dbb_dp_per_pp, line, slot, pp_sequence); - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, relation, relPages, window, pp_sequence, LCK_read); if (ppage) @@ -3617,7 +3615,7 @@ static rhd* locate_space(thread_db* tdbb, CCH_HANDOFF(tdbb, window, dp_primary, LCK_write, pag_data); UCHAR* space = find_space(tdbb, rpb, size, stack, record, type); if (space) - return (rhd*) space; + return (Ods::rhd*) space; if (!window->win_page.isTemporary()) CCH_get_related(tdbb, window->win_page, lowPages); @@ -3633,10 +3631,10 @@ static rhd* locate_space(thread_db* tdbb, { window->win_page = (type == DPM_primary) ? relPages->rel_last_free_pri_dp : relPages->rel_last_free_blb_dp; - data_page* dpage = (data_page*) CCH_FETCH(tdbb, window, LCK_write, pag_undefined); + Ods::data_page* dpage = (Ods::data_page*) CCH_FETCH(tdbb, window, LCK_write, pag_undefined); - const UCHAR wrongFlags = dpg_orphan | - ((type == DPM_primary) ? dpg_secondary : 0); + const UCHAR wrongFlags = Ods::dpg_orphan | + ((type == DPM_primary) ? Ods::dpg_secondary : 0); const bool pageOk = dpage->dpg_header.pag_type == pag_data && @@ -3649,7 +3647,7 @@ static rhd* locate_space(thread_db* tdbb, { UCHAR* space = find_space(tdbb, rpb, size, stack, record, type); if (space) - return (rhd*)space; + return (Ods::rhd*)space; } else CCH_RELEASE(tdbb, window); @@ -3687,7 +3685,7 @@ static rhd* locate_space(thread_db* tdbb, else relPages->rel_sec_data_space = pp_sequence; - const pointer_page* ppage = + const Ods::pointer_page* ppage = get_pointer_page(tdbb, relation, relPages, window, pp_sequence, ppLock); if (!ppage) BUGCHECK(254); // msg 254 pointer page vanished from relation list in locate_space @@ -3700,7 +3698,7 @@ static rhd* locate_space(thread_db* tdbb, continue; UCHAR* bits = (UCHAR *) (ppage->ppg_page + dbb->dbb_dp_per_pp); - if (PPG_DP_BIT_TEST(bits, slot, ppg_dp_full)) + if (PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_full)) continue; // hvlad: avoid creating circle in precedence graph, if possible @@ -3717,9 +3715,9 @@ static rhd* locate_space(thread_db* tdbb, // hvlad: if data page is empty, we could change its primary\secondary // type as needed (i.e. to be same as "type" passed). Also, we must clear - // ppg_dp_empty bit. To do it, we need to re-fetch PP with write lock. - bool dp_is_empty = PPG_DP_BIT_TEST(bits, slot, ppg_dp_empty); - bool dp_is_secondary = PPG_DP_BIT_TEST(bits, slot, ppg_dp_secondary); + // Ods::ppg_dp_empty bit. To do it, we need to re-fetch PP with write lock. + bool dp_is_empty = PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_empty); + bool dp_is_secondary = PPG_DP_BIT_TEST(bits, slot, Ods::ppg_dp_secondary); if (bulkInsert && !dp_is_empty) continue; @@ -3743,17 +3741,17 @@ static rhd* locate_space(thread_db* tdbb, CCH_precedence(tdbb, window, dp_number); CCH_MARK(tdbb, window); - PPG_DP_BIT_CLEAR(bits, slot, ppg_dp_empty); + PPG_DP_BIT_CLEAR(bits, slot, Ods::ppg_dp_empty); if (type == DPM_primary) { - PPG_DP_BIT_CLEAR(bits, slot, ppg_dp_secondary); + PPG_DP_BIT_CLEAR(bits, slot, Ods::ppg_dp_secondary); // When restoring, mark slot as swept, data page will be marked by our caller if (swept_at_restore(tdbb, relation)) - PPG_DP_BIT_SET(bits, slot, ppg_dp_swept); + PPG_DP_BIT_SET(bits, slot, Ods::ppg_dp_swept); } else - PPG_DP_BIT_SET(bits, slot, ppg_dp_secondary); + PPG_DP_BIT_SET(bits, slot, Ods::ppg_dp_secondary); dp_is_secondary = !(type == DPM_primary); tries = 0; @@ -3761,14 +3759,14 @@ static rhd* locate_space(thread_db* tdbb, if ((type == DPM_primary) ^ dp_is_secondary) { - data_page* dpage = NULL; + Ods::data_page* dpage = NULL; if (tries && (slot + 1 < ppage->ppg_count)) { - dpage = (data_page*) CCH_HANDOFF_TIMEOUT(tdbb, window, dp_number, LCK_write, pag_data, 0); + dpage = (Ods::data_page*) CCH_HANDOFF_TIMEOUT(tdbb, window, dp_number, LCK_write, pag_data, 0); tries--; } else - dpage = (data_page*) CCH_HANDOFF(tdbb, window, dp_number, LCK_write, pag_data); + dpage = (Ods::data_page*) CCH_HANDOFF(tdbb, window, dp_number, LCK_write, pag_data); if (dpage) { @@ -3780,13 +3778,13 @@ static rhd* locate_space(thread_db* tdbb, else if (isBlob) relPages->rel_last_free_blb_dp = dp_number; - return (rhd*)space; + return (Ods::rhd*)space; } } ppLock = LCK_read; window->win_page = pp_number; - ppage = (pointer_page*) CCH_FETCH(tdbb, window, ppLock, pag_pointer); + ppage = (Ods::pointer_page*) CCH_FETCH(tdbb, window, ppLock, pag_pointer); if (!ppage) BUGCHECK(254); @@ -3796,7 +3794,7 @@ static rhd* locate_space(thread_db* tdbb, const UCHAR flags = ppage->ppg_header.pag_flags; CCH_RELEASE(tdbb, window); - if (flags & ppg_eof) + if (flags & Ods::ppg_eof) break; } @@ -3833,7 +3831,7 @@ static rhd* locate_space(thread_db* tdbb, relation->getId(), window->win_page.getPageNum(), size); #endif - return (rhd*) space; + return (Ods::rhd*) space; } @@ -3865,7 +3863,7 @@ static void mark_full(thread_db* tdbb, record_param* rpb) // and re-fetch the data page. If the data page is still empty, set // it's "full" bit on the pointer page. - data_page* dpage = (data_page*) rpb->getWindow(tdbb).win_buffer; + Ods::data_page* dpage = (Ods::data_page*) rpb->getWindow(tdbb).win_buffer; const ULONG sequence = dpage->dpg_sequence; CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); @@ -3882,7 +3880,7 @@ static void mark_full(thread_db* tdbb, record_param* rpb) // is accomplished by timing out the second latch request and retrying // the whole thing. - pointer_page* ppage = 0; + Ods::pointer_page* ppage = 0; do { ppage = get_pointer_page(tdbb, relation->getPermanent(), relPages, &pp_window, pp_sequence, LCK_write); if (!ppage) @@ -3897,7 +3895,7 @@ static void mark_full(thread_db* tdbb, record_param* rpb) } // Fetch the data page, but timeout after 1 second to break a possible deadlock. - dpage = (data_page*) CCH_FETCH_TIMEOUT(tdbb, &rpb->getWindow(tdbb), LCK_read, pag_data, -1); + dpage = (Ods::data_page*) CCH_FETCH_TIMEOUT(tdbb, &rpb->getWindow(tdbb), LCK_read, pag_data, -1); // In case of a latch timeout, release the latch on the pointer page and retry. if (!dpage) @@ -3909,19 +3907,19 @@ static void mark_full(thread_db* tdbb, record_param* rpb) CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); // page can't be full and empty at the same time - fb_assert(!(flags & ppg_dp_full) || !dpEmpty); + fb_assert(!(flags & Ods::ppg_dp_full) || !dpEmpty); // Check if PP flags already equal to the DP flags UCHAR* byte = &PPG_DP_BITS_BYTE((UCHAR*) &ppage->ppg_page[dbb->dbb_dp_per_pp], slot); - const UCHAR bit_full_set = ((*byte & PPG_DP_BIT_MASK(slot, ppg_dp_full)) == 0) ? 0 : dpg_full; - const UCHAR bit_large_set = ((*byte & PPG_DP_BIT_MASK(slot, ppg_dp_large)) == 0) ? 0 : dpg_large; - const UCHAR bit_swept_set = ((*byte & PPG_DP_BIT_MASK(slot, ppg_dp_swept)) == 0) ? 0 : dpg_swept; - const UCHAR bit_scnd_set = ((*byte & PPG_DP_BIT_MASK(slot, ppg_dp_secondary)) == 0) ? 0 : dpg_secondary; - const bool bit_empty_set = ((*byte & PPG_DP_BIT_MASK(slot, ppg_dp_empty)) != 0); + const UCHAR bit_full_set = ((*byte & PPG_DP_BIT_MASK(slot, Ods::ppg_dp_full)) == 0) ? 0 : Ods::dpg_full; + const UCHAR bit_large_set = ((*byte & PPG_DP_BIT_MASK(slot, Ods::ppg_dp_large)) == 0) ? 0 : Ods::dpg_large; + const UCHAR bit_swept_set = ((*byte & PPG_DP_BIT_MASK(slot, Ods::ppg_dp_swept)) == 0) ? 0 : Ods::dpg_swept; + const UCHAR bit_scnd_set = ((*byte & PPG_DP_BIT_MASK(slot, Ods::ppg_dp_secondary)) == 0) ? 0 : Ods::dpg_secondary; + const bool bit_empty_set = ((*byte & PPG_DP_BIT_MASK(slot, Ods::ppg_dp_empty)) != 0); - if ((flags & (dpg_full | dpg_large | dpg_swept | dpg_secondary)) == + if ((flags & (Ods::dpg_full | Ods::dpg_large | Ods::dpg_swept | Ods::dpg_secondary)) == (bit_full_set | bit_large_set | bit_swept_set | bit_scnd_set) && (dpEmpty == bit_empty_set)) { @@ -3933,8 +3931,8 @@ static void mark_full(thread_db* tdbb, record_param* rpb) CCH_MARK(tdbb, &pp_window); - UCHAR bit = PPG_DP_BIT_MASK(slot, ppg_dp_full); - if (flags & dpg_full) + UCHAR bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_full); + if (flags & Ods::dpg_full) { *byte |= bit; if (slot == ppage->ppg_min_space) @@ -3943,7 +3941,7 @@ static void mark_full(thread_db* tdbb, record_param* rpb) while (ppage->ppg_min_space < ppage->ppg_count) { ppage->ppg_min_space++; - if (!PPG_DP_BIT_TEST(bits, ppage->ppg_min_space, ppg_dp_full)) + if (!PPG_DP_BIT_TEST(bits, ppage->ppg_min_space, Ods::ppg_dp_full)) break; } } @@ -3953,31 +3951,31 @@ static void mark_full(thread_db* tdbb, record_param* rpb) *byte &= ~bit; ppage->ppg_min_space = MIN(slot, ppage->ppg_min_space); - if (flags & dpg_secondary) + if (flags & Ods::dpg_secondary) relPages->rel_sec_data_space = MIN(pp_sequence, relPages->rel_sec_data_space); else relPages->rel_pri_data_space = MIN(pp_sequence, relPages->rel_pri_data_space); } - bit = PPG_DP_BIT_MASK(slot, ppg_dp_large); - if (flags & dpg_large) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_large); + if (flags & Ods::dpg_large) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_swept); - if (flags & dpg_swept) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_swept); + if (flags & Ods::dpg_swept) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_secondary); - if (flags & dpg_secondary) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_secondary); + if (flags & Ods::dpg_secondary) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_empty); + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_empty); if (dpEmpty) { *byte |= bit; @@ -4025,10 +4023,10 @@ static void store_big_record(thread_db* tdbb, RelationPages* relPages = rpb->rpb_relation->getPages(tdbb); PageNumber prior(relPages->rel_pg_space_id, 0); - // The last fragment should have rhd header because rhd_incomplete flag won't be set for it. - // It's important for get_header() function which relies on rhd_incomplete flag to determine header size. + // The last fragment should have Ods::rhd header because Ods::rhd_incomplete flag won't be set for it. + // It's important for get_header() function which relies on Ods::rhd_incomplete flag to determine header size. ULONG header_size = RHD_SIZE; - ULONG max_data = dbb->dbb_page_size - sizeof(data_page) - header_size; + ULONG max_data = dbb->dbb_page_size - sizeof(Ods::data_page) - header_size; // Fill up data pages tail first until what's left fits on a single page. @@ -4039,9 +4037,9 @@ static void store_big_record(thread_db* tdbb, { // Allocate and format data page and fragment header - data_page* page = (data_page*) DPM_allocate(tdbb, &rpb->getWindow(tdbb)); + Ods::data_page* page = (Ods::data_page*) DPM_allocate(tdbb, &rpb->getWindow(tdbb)); page->dpg_header.pag_type = pag_data; - page->dpg_header.pag_flags = dpg_orphan | dpg_full; + page->dpg_header.pag_flags = Ods::dpg_orphan | Ods::dpg_full; page->dpg_relation = rpb->rpb_relation->getId(); page->dpg_count = 1; @@ -4053,21 +4051,21 @@ static void store_big_record(thread_db* tdbb, const auto tail_size = tailDcc.getPackedLength(); fb_assert(tail_size <= max_data); - // Cast to (rhdf*) but use only rhd fields for the last fragment - rhdf* header = (rhdf*) &page->dpg_rpt[1]; + // Cast to (Ods::rhdf*) but use only Ods::rhd fields for the last fragment + Ods::rhdf* header = (Ods::rhdf*) &page->dpg_rpt[1]; page->dpg_rpt[0].dpg_offset = (UCHAR*) header - (UCHAR*) page; page->dpg_rpt[0].dpg_length = tail_size + header_size; - header->rhdf_flags = rhd_fragment; + header->rhdf_flags = Ods::rhd_fragment; if (prior.getPageNum()) { // This is not the last fragment - header->rhdf_flags |= rhd_incomplete; + header->rhdf_flags |= Ods::rhd_incomplete; header->rhdf_f_page = prior.getPageNum(); } if (!tailDcc.isPacked()) - header->rhdf_flags |= rhd_not_packed; + header->rhdf_flags |= Ods::rhd_not_packed; const auto out = (UCHAR*) header + header_size; tailDcc.pack(in, out); @@ -4089,9 +4087,9 @@ static void store_big_record(thread_db* tdbb, CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); prior = rpb->getWindow(tdbb).win_page; - // Other fragments except the last one should have rhdf header + // Other fragments except the last one should have Ods::rhdf header header_size = RHDF_SIZE; - max_data = dbb->dbb_page_size - sizeof(data_page) - header_size; + max_data = dbb->dbb_page_size - sizeof(Ods::data_page) - header_size; } while (size > max_data); // What's left fits on a page. Store it somewhere. @@ -4100,11 +4098,11 @@ static void store_big_record(thread_db* tdbb, stack.push(prior); - rhdf* header = (rhdf*) locate_space(tdbb, rpb, (SSHORT) (RHDF_SIZE + size), stack, NULL, type); + Ods::rhdf* header = (Ods::rhdf*) locate_space(tdbb, rpb, (SSHORT) (RHDF_SIZE + size), stack, NULL, type); rpb->rpb_flags &= ~rpb_not_packed; - header->rhdf_flags = rhd_incomplete | rhd_large | rpb->rpb_flags; + header->rhdf_flags = Ods::rhd_incomplete | Ods::rhd_large | rpb->rpb_flags; if (rpb->rpb_relation) fb_assert((rpb->rpb_relation->getId() != 0) || (rpb->rpb_transaction_nr == 0)); Ods::writeTraNum(header, rpb->rpb_transaction_nr, RHDF_SIZE); @@ -4115,11 +4113,11 @@ static void store_big_record(thread_db* tdbb, header->rhdf_f_line = 0; if (!dcc.isPacked()) - header->rhdf_flags |= rhd_not_packed; + header->rhdf_flags |= Ods::rhd_not_packed; dcc.pack(rpb->rpb_address, header->rhdf_data); - data_page* page = (data_page*) rpb->getWindow(tdbb).win_buffer; + Ods::data_page* page = (Ods::data_page*) rpb->getWindow(tdbb).win_buffer; #ifdef VIO_DEBUG VIO_trace(DEBUG_WRITES_INFO, @@ -4141,17 +4139,17 @@ static void store_big_record(thread_db* tdbb, // When restoring, mark primary data page as swept, pointer page already marked by locate_space() if (swept_at_restore(tdbb, rpb->rpb_relation->getPermanent()) && (type == DPM_primary)) { - page->dpg_header.pag_flags |= dpg_swept; + page->dpg_header.pag_flags |= Ods::dpg_swept; } - else if (page->dpg_header.pag_flags & dpg_swept) + else if (page->dpg_header.pag_flags & Ods::dpg_swept) { - page->dpg_header.pag_flags &= ~dpg_swept; + page->dpg_header.pag_flags &= ~Ods::dpg_swept; markPP = true; } - if (!(page->dpg_header.pag_flags & dpg_large)) + if (!(page->dpg_header.pag_flags & Ods::dpg_large)) { - page->dpg_header.pag_flags |= dpg_large; + page->dpg_header.pag_flags |= Ods::dpg_large; markPP = true; } @@ -4160,3 +4158,6 @@ static void store_big_record(thread_db* tdbb, else CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/dpm_proto.h b/src/jrd/dpm_proto.h index a882ec53548..c3b32232bd7 100644 --- a/src/jrd/dpm_proto.h +++ b/src/jrd/dpm_proto.h @@ -30,8 +30,7 @@ #include "../jrd/Resources.h" // fwd. decl. -namespace Jrd -{ +namespace Firebird::Jrd { class blb; class jrd_rel; struct record_param; @@ -49,42 +48,46 @@ namespace Jrd }; } -namespace Ods +namespace Firebird::Jrd::Ods { struct pag; struct data_page; } -Ods::pag* DPM_allocate(Jrd::thread_db*, Jrd::win*); -void DPM_backout(Jrd::thread_db*, Jrd::record_param*); -void DPM_backout_mark(Jrd::thread_db*, Jrd::record_param*, const Jrd::jrd_tra*); -double DPM_cardinality(Jrd::thread_db*, Jrd::jrd_rel*, const Jrd::Format*); -bool DPM_chain(Jrd::thread_db*, Jrd::record_param*, Jrd::record_param*); -void DPM_create_relation(Jrd::thread_db*, Jrd::Cached::Relation*); -ULONG DPM_data_pages(Jrd::thread_db*, Jrd::Cached::Relation*); -void DPM_delete(Jrd::thread_db*, Jrd::record_param*, ULONG); -void DPM_delete_relation(Jrd::thread_db*, Jrd::RelationPermanent*); -bool DPM_fetch(Jrd::thread_db*, Jrd::record_param*, USHORT); -bool DPM_fetch_back(Jrd::thread_db*, Jrd::record_param*, USHORT, SSHORT); -void DPM_fetch_fragment(Jrd::thread_db*, Jrd::record_param*, USHORT); -SINT64 DPM_gen_id(Jrd::thread_db*, SLONG, bool, SINT64); -bool DPM_get(Jrd::thread_db*, Jrd::record_param*, SSHORT); -ULONG DPM_get_blob(Jrd::thread_db*, Jrd::blb*, Jrd::jrd_rel*, RecordNumber, bool, ULONG); -void DPM_mark_relation(Jrd::thread_db*, Jrd::Cached::Relation*); -bool DPM_next(Jrd::thread_db*, Jrd::record_param*, USHORT, Jrd::FindNextRecordScope); -void DPM_pages(Jrd::thread_db*, SSHORT, int, ULONG, ULONG); +namespace Firebird::Jrd +{ + Ods::pag* DPM_allocate(thread_db*, win*); + void DPM_backout(thread_db*, record_param*); + void DPM_backout_mark(thread_db*, record_param*, const jrd_tra*); + double DPM_cardinality(thread_db*, jrd_rel*, const Format*); + bool DPM_chain(thread_db*, record_param*, record_param*); + void DPM_create_relation(thread_db*, Cached::Relation*); + ULONG DPM_data_pages(thread_db*, Cached::Relation*); + void DPM_delete(thread_db*, record_param*, ULONG); + void DPM_delete_relation(thread_db*, RelationPermanent*); + bool DPM_fetch(thread_db*, record_param*, USHORT); + bool DPM_fetch_back(thread_db*, record_param*, USHORT, SSHORT); + void DPM_fetch_fragment(thread_db*, record_param*, USHORT); + SINT64 DPM_gen_id(thread_db*, SLONG, bool, SINT64); + bool DPM_get(thread_db*, record_param*, SSHORT); + ULONG DPM_get_blob(thread_db*, blb*, jrd_rel*, RecordNumber, bool, ULONG); + void DPM_mark_relation(thread_db*, Cached::Relation*); + bool DPM_next(thread_db*, record_param*, USHORT, FindNextRecordScope); + void DPM_pages(thread_db*, SSHORT, int, ULONG, ULONG); #ifdef SUPERSERVER_V2 -SLONG DPM_prefetch_bitmap(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::PageBitmap*, SLONG); + SLONG DPM_prefetch_bitmap(thread_db*, jrd_rel*, PageBitmap*, SLONG); #endif -ULONG DPM_pointer_pages(Jrd::thread_db*, Jrd::jrd_rel*); -void DPM_scan_pages(Jrd::thread_db*); -void DPM_store(Jrd::thread_db*, Jrd::record_param*, Jrd::PageStack&, const Jrd::RecordStorageType type); -RecordNumber DPM_store_blob(Jrd::thread_db*, Jrd::blb*, Jrd::jrd_rel*, Jrd::Record*); -void DPM_rewrite_header(Jrd::thread_db*, Jrd::record_param*); -void DPM_scan_marker(Jrd::thread_db*, MetaId); -void DPM_update(Jrd::thread_db*, Jrd::record_param*, Jrd::PageStack*, const Jrd::jrd_tra*); + ULONG DPM_pointer_pages(thread_db*, jrd_rel*); + void DPM_scan_pages(thread_db*); + void DPM_store(thread_db*, record_param*, PageStack&, const RecordStorageType type); + RecordNumber DPM_store_blob(thread_db*, blb*, jrd_rel*, Record*); + void DPM_rewrite_header(thread_db*, record_param*); + void DPM_scan_marker(thread_db*, MetaId); + void DPM_update(thread_db*, record_param*, PageStack*, const jrd_tra*); + + void DPM_create_relation_pages(thread_db*, RelationPermanent*, RelationPages*); + void DPM_delete_relation_pages(thread_db*, RelationPermanent*, RelationPages*); +} // namespace Firebird::Jrd -void DPM_create_relation_pages(Jrd::thread_db*, Jrd::RelationPermanent*, Jrd::RelationPages*); -void DPM_delete_relation_pages(Jrd::thread_db*, Jrd::RelationPermanent*, Jrd::RelationPages*); #endif // JRD_DPM_PROTO_H diff --git a/src/jrd/drq.h b/src/jrd/drq.h index 1f8e344d3b0..db6adee2910 100644 --- a/src/jrd/drq.h +++ b/src/jrd/drq.h @@ -47,6 +47,10 @@ #ifndef JRD_DRQ_H #define JRD_DRQ_H +namespace Firebird::Jrd +{ + + enum drq_type_t { drq_s_rel_con, // store relation constraints @@ -246,4 +250,7 @@ enum drq_type_t drq_MAX }; + +} // namespace Firebird::Jrd + #endif // JRD_DRQ_H diff --git a/src/jrd/dyn.h b/src/jrd/dyn.h index 65c950e2217..a879d0ad7eb 100644 --- a/src/jrd/dyn.h +++ b/src/jrd/dyn.h @@ -40,7 +40,7 @@ inline constexpr const char* ALL_DDL_PRIVILEGES = "CLO"; inline constexpr int DYN_MSG_FAC = FB_IMPL_MSG_FACILITY_DYN; -namespace Jrd { +namespace Firebird::Jrd { class jrd_tra; class thread_db; @@ -75,6 +75,6 @@ class dyn_fld { } }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_DYN_H diff --git a/src/jrd/dyn_ut_proto.h b/src/jrd/dyn_ut_proto.h index bd2a9b65f4d..96514b90f5d 100644 --- a/src/jrd/dyn_ut_proto.h +++ b/src/jrd/dyn_ut_proto.h @@ -25,22 +25,25 @@ #ifndef JRD_DYN_UT_PROTO_H #define JRD_DYN_UT_PROTO_H -void DYN_UTIL_store_check_constraints(Jrd::thread_db*, Jrd::jrd_tra*, - const Jrd::QualifiedName&, const Jrd::MetaName&); -bool DYN_UTIL_find_field_source(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, - const Jrd::QualifiedName& view_name, USHORT context, const TEXT* local_name, - TEXT* output_field_schema_name, TEXT* output_field_name); -void DYN_UTIL_generate_generator_name(Jrd::thread_db*, Jrd::QualifiedName&); -void DYN_UTIL_generate_trigger_name(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::QualifiedName&); -void DYN_UTIL_generate_index_name(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::QualifiedName&, UCHAR); -void DYN_UTIL_generate_field_position(Jrd::thread_db*, const Jrd::QualifiedName&, SLONG*); -void DYN_UTIL_generate_field_name(Jrd::thread_db*, Jrd::QualifiedName&); -void DYN_UTIL_generate_constraint_name(Jrd::thread_db*, Jrd::QualifiedName&); -bool DYN_UTIL_check_unique_name_nothrow(Jrd::thread_db* tdbb, - const Jrd::QualifiedName& object_name, int object_type, USHORT* errorCode = nullptr, - bool freeWhenPossible = false); -void DYN_UTIL_check_unique_name(Jrd::thread_db* tdbb, - const Jrd::QualifiedName& object_name, int object_type); -SINT64 DYN_UTIL_gen_unique_id(Jrd::thread_db*, SSHORT, const char*); +namespace Firebird::Jrd +{ + void DYN_UTIL_store_check_constraints(thread_db*, jrd_tra*, + const QualifiedName&, const MetaName&); + bool DYN_UTIL_find_field_source(thread_db* tdbb, jrd_tra* transaction, + const QualifiedName& view_name, USHORT context, const TEXT* local_name, + TEXT* output_field_schema_name, TEXT* output_field_name); + void DYN_UTIL_generate_generator_name(thread_db*, QualifiedName&); + void DYN_UTIL_generate_trigger_name(thread_db*, jrd_tra*, QualifiedName&); + void DYN_UTIL_generate_index_name(thread_db*, jrd_tra*, QualifiedName&, UCHAR); + void DYN_UTIL_generate_field_position(thread_db*, const QualifiedName&, SLONG*); + void DYN_UTIL_generate_field_name(thread_db*, QualifiedName&); + void DYN_UTIL_generate_constraint_name(thread_db*, QualifiedName&); + bool DYN_UTIL_check_unique_name_nothrow(thread_db* tdbb, + const QualifiedName& object_name, int object_type, USHORT* errorCode = nullptr, + bool freeWhenPossible = false); + void DYN_UTIL_check_unique_name(thread_db* tdbb, + const QualifiedName& object_name, int object_type); + SINT64 DYN_UTIL_gen_unique_id(thread_db*, SSHORT, const char*); +} // namespace Firebird::Jrd #endif // JRD_DYN_UT_PROTO_H diff --git a/src/jrd/dyn_util.epp b/src/jrd/dyn_util.epp index 5f9b769f0f3..bce4b5e5c76 100644 --- a/src/jrd/dyn_util.epp +++ b/src/jrd/dyn_util.epp @@ -53,10 +53,11 @@ #include "../common/utils_proto.h" #include "../jrd/btr_proto.h" -using MsgFormat::SafeArg; +namespace Firebird::Jrd +{ + -using namespace Firebird; -using namespace Jrd; +using MsgFormat::SafeArg; DATABASE DB = STATIC "ODS.RDB"; @@ -387,7 +388,7 @@ SINT64 DYN_UTIL_gen_unique_id(thread_db* tdbb, SSHORT id, const char* generator_ const FB_SIZE_T blr_size = static_cast( sizeof(gen_id_blr1) + sizeof(gen_id_blr2)) + 1 + name_length; - Firebird::UCharBuffer blr; + UCharBuffer blr; UCHAR* p = blr.getBuffer(blr_size); memcpy(p, gen_id_blr1, sizeof(gen_id_blr1)); @@ -746,3 +747,6 @@ void DYN_UTIL_store_check_constraints(thread_db* tdbb, jrd_tra* transaction, } END_STORE } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp index 71eb4f39cc7..8fe3076ecc0 100644 --- a/src/jrd/err.cpp +++ b/src/jrd/err.cpp @@ -46,8 +46,9 @@ #include "../common/config/config.h" #include "../common/utils_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + //#define JRD_FAILURE_SPACE 2048 //#define JRD_FAILURE_UNKNOWN "" // Used when buffer fails @@ -453,3 +454,6 @@ void ERR_build_status(FbStatusVector* status_vector, const Arg::StatusVector& v) ERR_post(Arg::Gds(status) << Arg::Str(errmsg)); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/err_proto.h b/src/jrd/err_proto.h index 944c44413be..ddeabb8802c 100644 --- a/src/jrd/err_proto.h +++ b/src/jrd/err_proto.h @@ -30,7 +30,9 @@ #include "../common/StatusArg.h" #include "../jrd/status.h" -namespace Jrd { +namespace Firebird::Jrd +{ + // Index error types @@ -44,22 +46,23 @@ enum idx_e { idx_e_foreign_references_present }; -} //namespace Jrd - -void ERR_post_warning(const Firebird::Arg::StatusVector& v); +void ERR_post_warning(const Arg::StatusVector& v); //void ERR_assert(const TEXT*, int); [[noreturn]] void ERR_bugcheck(int, const TEXT* = NULL, int = 0); [[noreturn]] void ERR_bugcheck_msg(const TEXT*); [[noreturn]] void ERR_soft_bugcheck(int, const TEXT*, int); [[noreturn]] void ERR_corrupt(int); [[noreturn]] void ERR_error(int); -[[noreturn]] void ERR_post(const Firebird::Arg::StatusVector& v); -void ERR_post_nothrow(const Firebird::Arg::StatusVector& v, Jrd::FbStatusVector* statusVector = NULL); -void ERR_post_nothrow(const Firebird::IStatus* v, Jrd::FbStatusVector* statusVector = NULL); +[[noreturn]] void ERR_post(const Arg::StatusVector& v); +void ERR_post_nothrow(const Arg::StatusVector& v, FbStatusVector* statusVector = NULL); +void ERR_post_nothrow(const IStatus* v, FbStatusVector* statusVector = NULL); [[noreturn]] void ERR_punt(); -void ERR_warning(const Firebird::Arg::StatusVector& v); +void ERR_warning(const Arg::StatusVector& v); void ERR_log(int, int, const TEXT*); -void ERR_append_status(Jrd::FbStatusVector*, const Firebird::Arg::StatusVector& v); -void ERR_build_status(Jrd::FbStatusVector*, const Firebird::Arg::StatusVector& v) noexcept; +void ERR_append_status(FbStatusVector*, const Arg::StatusVector& v); +void ERR_build_status(FbStatusVector*, const Arg::StatusVector& v) noexcept; + + +} // namespace Firebird::Jrd #endif // JRD_ERR_PROTO_H diff --git a/src/jrd/event.cpp b/src/jrd/event.cpp index 59b8139f9ad..f4b005e3150 100644 --- a/src/jrd/event.cpp +++ b/src/jrd/event.cpp @@ -61,9 +61,8 @@ #define SRQ_BASE ((UCHAR*) m_sharedMemory->getHeader()) -using namespace Firebird; - -namespace Jrd { +namespace Firebird::Jrd +{ void EventManager::init(Attachment* attachment) @@ -1361,4 +1360,5 @@ void EventManager::exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* routine); + void exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* routine); private: void acquire_shmem(); @@ -100,11 +100,11 @@ class EventManager final : public Firebird::GlobalStorage, public Firebird::IpcO prb* m_process; SLONG m_processOffset; - const Firebird::string& m_dbId; - const Firebird::Config* const m_config; - Firebird::AutoPtr > m_sharedMemory; + const string& m_dbId; + const Config* const m_config; + AutoPtr > m_sharedMemory; - Firebird::Semaphore m_startupSemaphore; + Semaphore m_startupSemaphore; ThreadFinishSync m_cleanupSync; bool m_sharedFileCreated; diff --git a/src/jrd/evl.cpp b/src/jrd/evl.cpp index 9941f4b7b08..74c7c375a9a 100644 --- a/src/jrd/evl.cpp +++ b/src/jrd/evl.cpp @@ -114,8 +114,8 @@ #include "../common/classes/Aligner.h" #include "../jrd/Function.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ dsc* EVL_assign_to(thread_db* tdbb, const ValueExprNode* node) @@ -671,3 +671,6 @@ void EVL_validate(thread_db* tdbb, const Item& item, const ItemInfo* itemInfo, d ERR_post(Arg::Gds(status) << Arg::Str(arg) << Arg::Str(value)); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/evl_proto.h b/src/jrd/evl_proto.h index 0053be18dbd..582d92ce4d5 100644 --- a/src/jrd/evl_proto.h +++ b/src/jrd/evl_proto.h @@ -27,24 +27,21 @@ #include "../jrd/intl_classes.h" #include "../jrd/req.h" -namespace Jrd +namespace Firebird::Jrd { class DbKeyRangeNode; class InversionNode; struct Item; class ItemInfo; -} -dsc* EVL_assign_to(Jrd::thread_db* tdbb, const Jrd::ValueExprNode*); -Jrd::RecordBitmap** EVL_bitmap(Jrd::thread_db* tdbb, const Jrd::InversionNode*, Jrd::RecordBitmap*); -void EVL_dbkey_bounds(Jrd::thread_db* tdbb, const Firebird::Array&, - Jrd::jrd_rel*, RecordNumber&, RecordNumber&); -bool EVL_field(Jrd::jrd_rel*, Jrd::Record*, USHORT, dsc*); -void EVL_make_value(Jrd::thread_db* tdbb, const dsc*, Jrd::impure_value*, MemoryPool* pool = NULL); -void EVL_validate(Jrd::thread_db*, const Jrd::Item&, const Jrd::ItemInfo*, dsc*, bool); + dsc* EVL_assign_to(thread_db* tdbb, const ValueExprNode*); + RecordBitmap** EVL_bitmap(thread_db* tdbb, const InversionNode*, RecordBitmap*); + void EVL_dbkey_bounds(thread_db* tdbb, const Array&, + jrd_rel*, RecordNumber&, RecordNumber&); + bool EVL_field(jrd_rel*, Record*, USHORT, dsc*); + void EVL_make_value(thread_db* tdbb, const dsc*, impure_value*, MemoryPool* pool = NULL); + void EVL_validate(thread_db*, const Item&, const ItemInfo*, dsc*, bool); -namespace Jrd -{ // Evaluate a value expression. inline dsc* EVL_expr(thread_db* tdbb, Request* request, const ValueExprNode* node) { @@ -57,6 +54,6 @@ namespace Jrd return node->execute(tdbb, request); } -} +} // namespace Firebird::Jrd #endif // JRD_EVL_PROTO_H diff --git a/src/jrd/evl_string.h b/src/jrd/evl_string.h index 00f7bafffee..5667f017e1c 100644 --- a/src/jrd/evl_string.h +++ b/src/jrd/evl_string.h @@ -346,7 +346,7 @@ LikeEvaluator::LikeEvaluator( continue; } } - Firebird::Arg::Gds(isc_escape_invalid).raise(); + Arg::Gds(isc_escape_invalid).raise(); } // percent sign if (sql_match_any && c == sql_match_any) diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 0ec9deafabd..35cd0725fa3 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -113,9 +113,9 @@ #include "../jrd/Function.h" #include "../jrd/ProfilerManager.h" +namespace Firebird::Jrd +{ -using namespace Jrd; -using namespace Firebird; // Item class implementation @@ -1066,7 +1066,7 @@ void EXE_execute_function(thread_db* tdbb, Request* request, jrd_tra* transactio { // Save the old pool and request to restore on exit StmtNode::ExeState exeState(tdbb, request, request->req_transaction); - Jrd::ContextPoolHolder context(tdbb, request->req_pool); + JrdContextPoolHolder context(tdbb, request->req_pool); fb_assert(!request->req_caller); request->req_caller = exeState.oldRequest; @@ -1214,7 +1214,7 @@ void EXE_unwind(thread_db* tdbb, Request* request) if (statement->fors.hasData() || request->req_ext_resultset || request->req_ext_stmt) { - Jrd::ContextPoolHolder context(tdbb, request->req_pool); + JrdContextPoolHolder context(tdbb, request->req_pool); Request* old_request = tdbb->getRequest(); jrd_tra* old_transaction = tdbb->getTransaction(); @@ -1697,7 +1697,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, Request* request, const StmtNode* no // Save the old pool and request to restore on exit StmtNode::ExeState exeState(tdbb, request, request->req_transaction); - Jrd::ContextPoolHolder context(tdbb, request->req_pool); + JrdContextPoolHolder context(tdbb, request->req_pool); fb_assert(request->req_caller == NULL); request->req_caller = exeState.oldRequest; @@ -2078,3 +2078,6 @@ QualifiedName CompilerScratch::csb_repeat::getName(bool allowEmpty) const } } + +} // namespace Firebird::Jrd + diff --git a/src/jrd/exe.h b/src/jrd/exe.h index e361292ab17..b71a5430168 100644 --- a/src/jrd/exe.h +++ b/src/jrd/exe.h @@ -69,9 +69,9 @@ DEFINE_TRACE_ROUTINE(cmp_trace); #define CMP_TRACE(args) // nothing #endif -class VaryingString; +namespace Firebird::Jrd +{ -namespace Jrd { class jrd_rel; class Sort; @@ -91,6 +91,7 @@ class MessageNode; class PlanNode; class RecordSource; class Select; +class VaryingString; // Direction for each column in sort order enum SortDirection { ORDER_ANY, ORDER_ASC, ORDER_DESC }; @@ -130,10 +131,10 @@ inline constexpr int csb_skip_locked = 4096; // skip locked record // Aggregate Sort Block (for DISTINCT aggregates) -class AggregateSort : protected Firebird::PermanentStorage, public Printable +class AggregateSort : protected PermanentStorage, public Printable { public: - explicit AggregateSort(Firebird::MemoryPool& p) + explicit AggregateSort(MemoryPool& p) : PermanentStorage(p), keyItems(p), descOrder(p) @@ -141,7 +142,7 @@ class AggregateSort : protected Firebird::PermanentStorage, public Printable } public: - virtual Firebird::string internalPrint(NodePrinter& printer) const + virtual string internalPrint(NodePrinter& printer) const { return "AggregateSort"; } @@ -151,8 +152,8 @@ class AggregateSort : protected Firebird::PermanentStorage, public Printable ULONG length = 0; bool intl = false; ULONG impure = 0; - Firebird::HalfStaticArray keyItems; - Firebird::HalfStaticArray descOrder; + HalfStaticArray keyItems; + HalfStaticArray descOrder; }; // Inversion (i.e. nod_index) impure area @@ -225,8 +226,8 @@ struct AccessItem {} }; -typedef Firebird::SortedArray, - AccessItem, Firebird::DefaultKeyValue, AccessItem> AccessItemList; +typedef SortedArray, + AccessItem, DefaultKeyValue, AccessItem> AccessItemList; // Triggers and procedures the request accesses struct ExternalAccess @@ -278,8 +279,8 @@ struct ExternalAccess } }; -typedef Firebird::SortedArray, - ExternalAccess, Firebird::DefaultKeyValue, ExternalAccess> ExternalAccessList; +typedef SortedArray, + ExternalAccess, DefaultKeyValue, ExternalAccess> ExternalAccessList; // The three structs below are used for domains DEFAULT and constraints in PSQL struct Item @@ -322,7 +323,7 @@ struct Item return type > x.type; } - Firebird::string getDescription(Request* request, const ItemInfo* itemInfo) const; + string getDescription(Request* request, const ItemInfo* itemInfo) const; }; struct FieldInfo @@ -372,7 +373,7 @@ class ItemInfo : public Printable return !nullable || fullDomain; } - virtual Firebird::string internalPrint(NodePrinter& printer) const + virtual string internalPrint(NodePrinter& printer) const { /*** FIXME-PRINT: NODE_PRINT(printer, name); @@ -393,8 +394,8 @@ class ItemInfo : public Printable bool fullDomain; }; -typedef Firebird::LeftPooledMap MapFieldInfo; -typedef Firebird::RightPooledMap MapItemInfo; +typedef LeftPooledMap MapFieldInfo; +typedef RightPooledMap MapItemInfo; // Table value function block @@ -413,7 +414,7 @@ class jrd_table_value_fun } const Format* recordFormat; - Firebird::LeftPooledMap fields; + LeftPooledMap fields; MetaName name; USHORT funcId; }; @@ -487,7 +488,7 @@ class CompilerScratch : public pool_alloc csb_preferredDesc(NULL), csb_rpt(p) { - csb_dbg_info = FB_NEW_POOL(p) Firebird::DbgInfo(p); + csb_dbg_info = FB_NEW_POOL(p) DbgInfo(p); } // Implemented in Statement.cpp @@ -502,7 +503,7 @@ class CompilerScratch : public pool_alloc StreamType nextStream(bool check = true) { if (csb_n_stream >= MAX_STREAMS && check) - ERR_post(Firebird::Arg::Gds(isc_too_many_contexts)); + ERR_post(Arg::Gds(isc_too_many_contexts)); return csb_n_stream++; } @@ -527,7 +528,7 @@ class CompilerScratch : public pool_alloc if (csb_schema.hasData()) { - Firebird::ObjectsArray schemaSearchPath; + ObjectsArray schemaSearchPath; if (csb_g_flags & csb_search_system_schema) schemaSearchPath.push(SYSTEM_SCHEMA); @@ -546,7 +547,7 @@ class CompilerScratch : public pool_alloc va_list params; va_start(params, format); - Firebird::string s; + string s; s.vprintf(format, params); va_end(params); @@ -554,38 +555,38 @@ class CompilerScratch : public pool_alloc csb_dump += s; } - Firebird::string csb_dump; + string csb_dump; #endif CompilerScratch* mainCsb; - Firebird::BlrReader csb_blr_reader; + BlrReader csb_blr_reader; DmlNode* csb_node; ExternalAccessList csb_external; // Access to outside procedures/triggers to be checked AccessItemList csb_access; // Access items to be checked vec* csb_variables; // Vector of variables, if any Resources* csb_resources; // Resources (relations, indexes, routines, etc.) - Firebird::Array csb_dependencies; // objects that this statement depends upon - Firebird::Array csb_fors; // select expressions - Firebird::Array csb_localTables; // local tables - Firebird::Array csb_invariants; // stack of pointer to nodes invariant offsets - Firebird::Array csb_current_nodes; // RseNode's and other invariant + Array csb_dependencies; // objects that this statement depends upon + Array csb_fors; // select expressions + Array csb_localTables; // local tables + Array csb_invariants; // stack of pointer to nodes invariant offsets + Array csb_current_nodes; // RseNode's and other invariant // candidates within whose scope we are - Firebird::Array csb_current_for_nodes; - Firebird::RightPooledMap csb_forCursorNames; - Firebird::SortedArray csb_computing_fields; // Computed fields being compiled - Firebird::Array csb_inner_booleans; // Inner booleans at the current scope - Firebird::SortedArray csb_variables_used_in_subroutines; + Array csb_current_for_nodes; + RightPooledMap csb_forCursorNames; + SortedArray csb_computing_fields; // Computed fields being compiled + Array csb_inner_booleans; // Inner booleans at the current scope + SortedArray csb_variables_used_in_subroutines; StreamType csb_n_stream; // Next available stream USHORT csb_msg_number; // Highest used message number ULONG csb_impure; // Next offset into impure area USHORT csb_g_flags; MemoryPool& csb_pool; // Memory pool to be used by csb - Firebird::AutoPtr csb_dbg_info; // Debug information + AutoPtr csb_dbg_info; // Debug information MapFieldInfo csb_map_field_info; // Map field name to field info MapItemInfo csb_map_item_info; // Map item to item info // Map of message number to field number to pad for external routines. - Firebird::GenericMap > > csb_message_pad; + GenericMap > > csb_message_pad; QualifiedName csb_domain_validation; // Parsing domain constraint in PSQL @@ -599,10 +600,10 @@ class CompilerScratch : public pool_alloc bool csb_returning_expr; bool csb_implicit_cursor; - Firebird::LeftPooledMap subFunctions; - Firebird::LeftPooledMap subProcedures; - Firebird::NonPooledMap outerMessagesMap; // - Firebird::NonPooledMap outerVarsMap; // + LeftPooledMap subFunctions; + LeftPooledMap subProcedures; + NonPooledMap outerMessagesMap; // + NonPooledMap outerVarsMap; // MetaName csb_schema; @@ -630,7 +631,7 @@ class CompilerScratch : public pool_alloc USHORT csb_flags; Rsc::Rel csb_relation; - Firebird::string* csb_alias; // SQL alias name for this instance of relation + string* csb_alias; // SQL alias name for this instance of relation SubRoutine csb_procedure; Rsc::Rel csb_view; // parent view @@ -648,7 +649,7 @@ class CompilerScratch : public pool_alloc typedef csb_repeat* rpt_itr; typedef const csb_repeat* rpt_const_itr; - Firebird::HalfStaticArray csb_rpt; + HalfStaticArray csb_rpt; }; // We must zero-initialize this one @@ -682,7 +683,7 @@ inline void CompilerScratch::csb_repeat::deactivate() noexcept csb_flags &= ~csb_active; } -class AutoSetCurrentCursorId : private Firebird::AutoSetRestore +class AutoSetCurrentCursorId : private AutoSetRestore { public: explicit AutoSetCurrentCursorId(CompilerScratch* csb) @@ -695,28 +696,29 @@ class AutoSetCurrentCursorId : private Firebird::AutoSetRestore class StatusXcp { - Firebird::FbLocalStatus status; + FbLocalStatus status; public: StatusXcp(); void clear(); - void init(const Jrd::FbStatusVector*) noexcept; - void copyTo(Jrd::FbStatusVector*) const noexcept; + void init(const FbStatusVector*) noexcept; + void copyTo(FbStatusVector*) const noexcept; bool success() const; SLONG as_gdscode() const; SLONG as_sqlcode() const; void as_sqlstate(char*) const; SLONG as_xcpcode() const; - Firebird::string as_text() const; + string as_text() const; }; // must correspond to the declared size of RDB$EXCEPTIONS.RDB$MESSAGE inline constexpr unsigned XCP_MESSAGE_LENGTH = 1023; // Array which stores relative pointers to impure areas of invariant nodes -typedef Firebird::SortedArray VarInvariantArray; +typedef SortedArray VarInvariantArray; + -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_EXE_H diff --git a/src/jrd/exe_proto.h b/src/jrd/exe_proto.h index 7ca051aa174..47e2db462f9 100644 --- a/src/jrd/exe_proto.h +++ b/src/jrd/exe_proto.h @@ -27,38 +27,35 @@ #include "../jrd/cmp_proto.h" #include -namespace Jrd { +namespace Firebird::Jrd { class Request; class jrd_tra; class AssignmentNode; enum InternalRequest : USHORT; -} - -void EXE_assignment(Jrd::thread_db*, const Jrd::AssignmentNode*); -void EXE_assignment(Jrd::thread_db*, const Jrd::ValueExprNode*, const Jrd::ValueExprNode*); -void EXE_assignment(Jrd::thread_db* tdbb, const Jrd::ValueExprNode* to, dsc* from_desc, - const Jrd::ValueExprNode* missing_node, const Jrd::ValueExprNode* missing2_node); - -void EXE_execute_db_triggers(Jrd::thread_db*, Jrd::jrd_tra*, enum TriggerAction); -void EXE_execute_ddl_triggers(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, - bool preTriggers, int action); -void EXE_execute_triggers(Jrd::thread_db*, const Jrd::Triggers&, Jrd::record_param*, Jrd::record_param*, - enum TriggerAction, Jrd::StmtNode::WhichTrigger, int = 0); -void EXE_execute_function(Jrd::thread_db* tdbb, Jrd::Request* request, Jrd::jrd_tra* transaction, - ULONG inMsgLength, UCHAR* inMsg, ULONG outMsgLength, UCHAR* outMsg); -bool EXE_get_stack_trace(const Jrd::Request* request, Firebird::string& sTrace); - -const Jrd::StmtNode* EXE_looper(Jrd::thread_db* tdbb, Jrd::Request* request, - const Jrd::StmtNode* in_node); -void EXE_receive(Jrd::thread_db*, Jrd::Request*, USHORT, ULONG, void*, bool = false); -void EXE_release(Jrd::thread_db*, Jrd::Request*); -void EXE_send(Jrd::thread_db*, Jrd::Request*, USHORT, ULONG, const void*); -void EXE_start(Jrd::thread_db*, Jrd::Request*, Jrd::jrd_tra*); -void EXE_unwind(Jrd::thread_db*, Jrd::Request*); - -namespace Jrd -{ + + void EXE_assignment(thread_db*, const AssignmentNode*); + void EXE_assignment(thread_db*, const ValueExprNode*, const ValueExprNode*); + void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, + const ValueExprNode* missing_node, const ValueExprNode* missing2_node); + + void EXE_execute_db_triggers(thread_db*, jrd_tra*, enum TriggerAction); + void EXE_execute_ddl_triggers(thread_db* tdbb, jrd_tra* transaction, + bool preTriggers, int action); + void EXE_execute_triggers(thread_db*, const Triggers&, record_param*, record_param*, + enum TriggerAction, StmtNode::WhichTrigger, int = 0); + void EXE_execute_function(thread_db* tdbb, Request* request, jrd_tra* transaction, + ULONG inMsgLength, UCHAR* inMsg, ULONG outMsgLength, UCHAR* outMsg); + bool EXE_get_stack_trace(const Request* request, string& sTrace); + + const StmtNode* EXE_looper(thread_db* tdbb, Request* request, + const StmtNode* in_node); + void EXE_receive(thread_db*, Request*, USHORT, ULONG, void*, bool = false); + void EXE_release(thread_db*, Request*); + void EXE_send(thread_db*, Request*, USHORT, ULONG, const void*); + void EXE_start(thread_db*, Request*, jrd_tra*); + void EXE_unwind(thread_db*, Request*); + class CachedRequestId { public: @@ -218,6 +215,6 @@ namespace Jrd private: Request* request; }; -} +} // namespace Firebird::Jrd #endif // JRD_EXE_PROTO_H diff --git a/src/jrd/ext.cpp b/src/jrd/ext.cpp index be3affde92a..a6a506cd821 100644 --- a/src/jrd/ext.cpp +++ b/src/jrd/ext.cpp @@ -80,9 +80,7 @@ __int64 __cdecl _ftelli64(FILE*); #define FSEEK64 fseeko #endif -using namespace Firebird; - -namespace Jrd +namespace Firebird::Jrd { class ExternalFileDirectoryList : public DirectoryList { @@ -111,21 +109,18 @@ namespace Jrd private: RefPtr config; }; -} - -using namespace Jrd; - -namespace { + namespace + { #ifdef WIN_NT - static const char* const FOPEN_TYPE = "a+b"; - static const char* const FOPEN_READ_ONLY = "rb"; + static const char* const FOPEN_TYPE = "a+b"; + static const char* const FOPEN_READ_ONLY = "rb"; #else - static const char* const FOPEN_TYPE = "a+"; - static const char* const FOPEN_READ_ONLY = "r"; + static const char* const FOPEN_TYPE = "a+"; + static const char* const FOPEN_READ_ONLY = "r"; #endif + } // namespace -} // namespace void ExternalFile::open(Database* dbb) { @@ -567,3 +562,6 @@ void ExternalFile::checkOpened() if (!ext_ifi) ERR_post(Arg::Gds(isc_random) << "Error accessing external table's file"); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/ext_proto.h b/src/jrd/ext_proto.h index fbb18312877..595e8a1b906 100644 --- a/src/jrd/ext_proto.h +++ b/src/jrd/ext_proto.h @@ -31,7 +31,7 @@ #ifndef JRD_EXT_PROTO_H #define JRD_EXT_PROTO_H -namespace Jrd { +namespace Firebird::Jrd { class jrd_tra; class RecordSource; @@ -81,7 +81,7 @@ class ExternalFile : public pool_alloc_rpt void release(); private: - Firebird::Mutex ext_sync; + Mutex ext_sync; USHORT ext_flags; // Misc and cruddy flags USHORT ext_tra_cnt; // How many transactions used the file FILE* ext_ifi; // Internal file identifier @@ -93,6 +93,6 @@ const USHORT EXT_readonly = 1; // File could only be opened for read const USHORT EXT_last_read = 2; // last operation was read const USHORT EXT_last_write = 4; // last operation was write -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_EXT_PROTO_H diff --git a/src/jrd/extds/ExtDS.cpp b/src/jrd/extds/ExtDS.cpp index 414e8da4c69..dd31ddf7931 100644 --- a/src/jrd/extds/ExtDS.cpp +++ b/src/jrd/extds/ExtDS.cpp @@ -70,11 +70,9 @@ #endif -using namespace Jrd; -using namespace Firebird; - +namespace Firebird::Jrd::EDS +{ -namespace EDS { // Manager @@ -391,7 +389,7 @@ void Provider::bindConnection(thread_db* tdbb, Connection* conn) } Connection* Provider::getBoundConnection(Jrd::thread_db* tdbb, - const Firebird::PathName& dbName, Firebird::ClumpletReader& dpb, + const PathName& dbName, ClumpletReader& dpb, TraScope tra_scope, bool isCurrentAtt) { Attachment* att = tdbb->getAttachment(); @@ -963,7 +961,7 @@ void ConnectionsPool::putConnection(thread_db* tdbb, Connection* conn) fb_assert(conn->getConnPool() == this); Connection* oldConn = NULL; - Firebird::RefPtr timer; + RefPtr timer; if (m_maxCount > 0) { @@ -1486,7 +1484,7 @@ void ConnectionsPool::IdleTimer::handler() void ConnectionsPool::IdleTimer::start() { FbLocalStatus s; - ITimerControl* timerCtrl = Firebird::TimerInterfacePtr(); + ITimerControl* timerCtrl = TimerInterfacePtr(); const time_t expTime = m_connPool.getIdleExpireTime(); if (expTime == 0) @@ -1520,7 +1518,7 @@ void ConnectionsPool::IdleTimer::stop() m_time = 0; FbLocalStatus s; - ITimerControl* timerCtrl = Firebird::TimerInterfacePtr(); + ITimerControl* timerCtrl = TimerInterfacePtr(); timerCtrl->stop(&s, this); } @@ -2696,7 +2694,7 @@ bool CryptHash::operator==(const CryptHash& h) const // CryptCallbackRedirector -void CryptCallbackRedirector::setRedirect(Firebird::ICryptKeyCallback* originalCallback) +void CryptCallbackRedirector::setRedirect(ICryptKeyCallback* originalCallback) { m_hash.assign(originalCallback); @@ -2704,7 +2702,7 @@ void CryptCallbackRedirector::setRedirect(Firebird::ICryptKeyCallback* originalC m_keyCallback = originalCallback; } -void CryptCallbackRedirector::resetRedirect(Firebird::ICryptKeyCallback* newCallback) +void CryptCallbackRedirector::resetRedirect(ICryptKeyCallback* newCallback) { #ifdef DEV_BUILD CryptHash ch(newCallback); @@ -2721,4 +2719,5 @@ bool CryptCallbackRedirector::operator==(const CryptHash& ch) const return m_hash == ch; } -} // namespace EDS + +} // namespace Firebird::Jrd::EDS diff --git a/src/jrd/extds/ExtDS.h b/src/jrd/extds/ExtDS.h index 8f51e6861fe..d336bd7ab8f 100644 --- a/src/jrd/extds/ExtDS.h +++ b/src/jrd/extds/ExtDS.h @@ -33,14 +33,13 @@ #include -namespace Jrd -{ +namespace Firebird::Jrd { class jrd_tra; class thread_db; class ValueListNode; } -namespace EDS { +namespace Firebird::Jrd::EDS { class Manager; class Provider; @@ -70,10 +69,10 @@ enum TraScope { class CryptHash { public: - explicit CryptHash(Firebird::ICryptKeyCallback* callback); + explicit CryptHash(ICryptKeyCallback* callback); CryptHash(); - void assign(Firebird::ICryptKeyCallback* callback); + void assign(ICryptKeyCallback* callback); bool isValid() const noexcept { @@ -95,19 +94,19 @@ class CryptHash bool operator==(const CryptHash& h) const; private: - Firebird::UCharBuffer m_value; + UCharBuffer m_value; bool m_valid = false; }; class CryptCallbackRedirector : - public Firebird::VersionedIface> + public VersionedIface> { public: CryptCallbackRedirector() = default; - void setRedirect(Firebird::ICryptKeyCallback* originalCallback); - void resetRedirect(Firebird::ICryptKeyCallback* newCallback); + void setRedirect(ICryptKeyCallback* originalCallback); + void resetRedirect(ICryptKeyCallback* newCallback); bool operator==(const CryptHash& h) const; bool isValid() const noexcept @@ -122,12 +121,12 @@ class CryptCallbackRedirector : return m_keyCallback ? m_keyCallback->callback(dataLength, data, bufferLength, buffer) : 0; } - int getHashLength(Firebird::CheckStatusWrapper* status) override + int getHashLength(CheckStatusWrapper* status) override { return m_hash.getLength(); } - void getHashData(Firebird::CheckStatusWrapper* status, void* h) override + void getHashData(CheckStatusWrapper* status, void* h) override { fb_assert(m_hash.isValid()); if (m_hash.isValid()) @@ -146,17 +145,17 @@ extern const char* INTERNAL_PROVIDER_NAME; // Manage providers -class Manager : public Firebird::PermanentStorage +class Manager : public PermanentStorage { public: - explicit Manager(Firebird::MemoryPool& pool); + explicit Manager(MemoryPool& pool); ~Manager(); static void addProvider(Provider* provider); - static Provider* getProvider(const Firebird::string& prvName); + static Provider* getProvider(const string& prvName); static Connection* getConnection(Jrd::thread_db* tdbb, - const Firebird::string& dataSource, const Firebird::string& user, - const Firebird::string& pwd, const Firebird::string& role, TraScope tra_scope); + const string& dataSource, const string& user, + const string& pwd, const string& role, TraScope tra_scope); static ConnectionsPool* getConnPool(bool create); @@ -166,8 +165,8 @@ class Manager : public Firebird::PermanentStorage static int shutdown(); private: - static Firebird::GlobalPtr manager; - static Firebird::Mutex m_mutex; + static GlobalPtr manager; + static Mutex m_mutex; static Provider* m_providers; static ConnectionsPool* m_connPool; }; @@ -175,7 +174,7 @@ class Manager : public Firebird::PermanentStorage // manages connections -class Provider : public Firebird::GlobalStorage +class Provider : public GlobalStorage { friend class Manager; friend class EngineCallbackGuard; @@ -185,7 +184,7 @@ class Provider : public Firebird::GlobalStorage // create new Connection virtual Connection* createConnection(Jrd::thread_db* tdbb, - const Firebird::PathName& dbName, Firebird::ClumpletReader& dpb, + const PathName& dbName, ClumpletReader& dpb, TraScope tra_scope); // bind connection to the current attachment @@ -193,7 +192,7 @@ class Provider : public Firebird::GlobalStorage // get available connection already bound to the current attachment Connection* getBoundConnection(Jrd::thread_db* tdbb, - const Firebird::PathName& dbName, Firebird::ClumpletReader& dpb, + const PathName& dbName, ClumpletReader& dpb, TraScope tra_scope, bool isCurrent); // Connection gets unused, release it into pool or delete it immediately @@ -205,7 +204,7 @@ class Provider : public Firebird::GlobalStorage // cancel execution of every connection void cancelConnections(); - const Firebird::string& getName() const noexcept { return m_name; } + const string& getName() const noexcept { return m_name; } virtual void initialize() = 0; @@ -213,9 +212,9 @@ class Provider : public Firebird::GlobalStorage int getFlags() const noexcept { return m_flags; } // Interprete status and put error description into passed string - virtual void getRemoteError(const Jrd::FbStatusVector* status, Firebird::string& err) const = 0; + virtual void getRemoteError(const Jrd::FbStatusVector* status, string& err) const = 0; - static const Firebird::string* generate(const Provider* item) noexcept + static const string* generate(const Provider* item) noexcept { return &item->m_name; } @@ -225,15 +224,15 @@ class Provider : public Firebird::GlobalStorage void clearConnections(Jrd::thread_db* tdbb); virtual Connection* doCreateConnection() = 0; - void generateDPB(Jrd::thread_db* tdbb, Firebird::ClumpletWriter& dpb, - const Firebird::string& user, const Firebird::string& pwd, - const Firebird::string& role) const; + void generateDPB(Jrd::thread_db* tdbb, ClumpletWriter& dpb, + const string& user, const string& pwd, + const string& role) const; // Protection against simultaneous attach database calls. Not sure we still // need it, but I believe it will not harm - mutable Firebird::Mutex m_mutex; + mutable Mutex m_mutex; - Firebird::string m_name; + string m_name; Provider* m_next = nullptr; class AttToConn @@ -264,7 +263,7 @@ class Provider : public Firebird::GlobalStorage } }; - typedef Firebird::BePlusTree + typedef BePlusTree AttToConnMap; AttToConnMap m_connections; @@ -278,12 +277,12 @@ inline constexpr int prvTrustedAuth = 0x0001; // supports trusted authentication class ConnectionsPool { public: - ConnectionsPool(Firebird::MemoryPool& pool); + ConnectionsPool(MemoryPool& pool); ~ConnectionsPool(); // find and return cached connection or NULL - Connection* getConnection(Jrd::thread_db* tdbb, Provider* prv, ULONG hash, const Firebird::PathName& dbName, - Firebird::ClumpletReader& dpb, const CryptHash& ch); + Connection* getConnection(Jrd::thread_db* tdbb, Provider* prv, ULONG hash, const PathName& dbName, + ClumpletReader& dpb, const CryptHash& ch); // put unused connection into pool or destroy it void putConnection(Jrd::thread_db* tdbb, Connection* conn); @@ -386,13 +385,13 @@ class ConnectionsPool m_connPool = connPool; } - Firebird::string print(); + string print(); int verify(ConnectionsPool *connPool, bool active); }; private: class IdleTimer final : - public Firebird::RefCntIface > + public RefCntIface > { public: explicit IdleTimer(ConnectionsPool& connPool) @@ -408,7 +407,7 @@ class ConnectionsPool private: ConnectionsPool& m_connPool; - Firebird::Mutex m_mutex; + Mutex m_mutex; time_t m_time; // time when timer should fire, or zero }; @@ -461,25 +460,25 @@ class ConnectionsPool void removeFromPool(Data* item, FB_SIZE_T pos); Data* removeOldest(); - void printPool(Firebird::string& s); + void printPool(string& s); bool verifyPool(); // Array of Data*, sorted by [hash, lastUsed desc] - typedef Firebird::SortedArray, Data, Data, Data> + typedef SortedArray, Data, Data, Data> IdleArray; - Firebird::Mutex m_mutex; + Mutex m_mutex; IdleArray m_idleArray; Data* m_idleList; Data* m_activeList; ULONG m_allCount; ULONG m_maxCount; ULONG m_lifeTime; // How long idle connection should wait before destroying, seconds - Firebird::RefPtr m_timer; + RefPtr m_timer; }; -class Connection : public Firebird::PermanentStorage +class Connection : public PermanentStorage { protected: friend class EngineCallbackGuard; @@ -491,9 +490,9 @@ class Connection : public Firebird::PermanentStorage virtual ~Connection(); static void deleteConnection(Jrd::thread_db* tdbb, Connection* conn); - void setup(const Firebird::PathName& dbName, const Firebird::ClumpletReader& dpb); + void setup(const PathName& dbName, const ClumpletReader& dpb); - void setCallbackRedirect(Firebird::ICryptKeyCallback* attCallback) + void setCallbackRedirect(ICryptKeyCallback* attCallback) { m_cryptCallbackRedir.setRedirect(attCallback); } @@ -527,8 +526,8 @@ class Connection : public Firebird::PermanentStorage virtual bool isConnected() const = 0; virtual bool validate(Jrd::thread_db* tdbb) = 0; - virtual bool isSameDatabase(const Firebird::PathName& dbName, - Firebird::ClumpletReader& dpb, const CryptHash& ch) const; + virtual bool isSameDatabase(const PathName& dbName, + ClumpletReader& dpb, const CryptHash& ch) const; // only Internal provider is able to create "current" connections virtual bool isCurrent() const { return false; } @@ -541,7 +540,7 @@ class Connection : public Firebird::PermanentStorage // Search for existing transaction of given scope, may return NULL. Transaction* findTransaction(Jrd::thread_db* tdbb, TraScope traScope) const; - const Firebird::string getDataSourceName() const + const string getDataSourceName() const { return m_provider.getName() + "::" + m_dbName.ToString(); } @@ -564,7 +563,7 @@ class Connection : public Firebird::PermanentStorage // statement into m_statements array, but don't delete freed statement // immediately (as we did pooled statements). Instead keep it in // m_freeStatements list for reuse later - Statement* createStatement(const Firebird::string& sql); + Statement* createStatement(const string& sql); void releaseStatement(Jrd::thread_db* tdbb, Statement* stmt); virtual Blob* createBlob() = 0; @@ -576,7 +575,7 @@ class Connection : public Firebird::PermanentStorage // Clear specified flag void clearFeature(info_features value) noexcept { m_features[value] = false; } - void resetRedirect(Firebird::ICryptKeyCallback* originalCallback) + void resetRedirect(ICryptKeyCallback* originalCallback) { m_cryptCallbackRedir.resetRedirect(originalCallback); } @@ -596,15 +595,15 @@ class Connection : public Firebird::PermanentStorage virtual void doDetach(Jrd::thread_db* tdbb) = 0; // Protection against simultaneous ISC API calls for the same connection - Firebird::Mutex m_mutex; + Mutex m_mutex; Provider& m_provider; - Firebird::PathName m_dbName; - Firebird::UCharBuffer m_dpb; + PathName m_dbName; + UCharBuffer m_dpb; Jrd::Attachment* m_boundAtt; - Firebird::Array m_transactions; - Firebird::Array m_statements; + Array m_transactions; + Array m_statements; Statement* m_freeStatements; ConnectionsPool::Data m_poolData; @@ -621,7 +620,7 @@ class Connection : public Firebird::PermanentStorage CryptCallbackRedirector m_cryptCallbackRedir; }; -class Transaction : public Firebird::PermanentStorage +class Transaction : public PermanentStorage { protected: friend class Connection; @@ -653,11 +652,11 @@ class Transaction : public Firebird::PermanentStorage bool commit, bool retain, bool force); protected: - virtual void generateTPB(Jrd::thread_db* tdbb, Firebird::ClumpletWriter& tpb, + virtual void generateTPB(Jrd::thread_db* tdbb, ClumpletWriter& tpb, TraModes traMode, bool readOnly, bool wait, int lockTimeout) const; void detachFromJrdTran(); - virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, Firebird::ClumpletWriter& tpb) = 0; + virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, ClumpletWriter& tpb) = 0; virtual void doPrepare(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, int info_len, const char* info) = 0; virtual void doCommit(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain) = 0; virtual void doRollback(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain) = 0; @@ -666,14 +665,14 @@ class Transaction : public Firebird::PermanentStorage Connection& m_connection; TraScope m_scope; Transaction* m_nextTran; // next common transaction - Firebird::RefPtr m_jrdTran; // parent JRD transaction + RefPtr m_jrdTran; // parent JRD transaction }; -typedef Firebird::Array ParamNames; -typedef Firebird::Array ParamNumbers; +typedef Array ParamNames; +typedef Array ParamNumbers; -class Statement : public Firebird::PermanentStorage +class Statement : public PermanentStorage { protected: friend class Connection; @@ -691,7 +690,7 @@ class Statement : public Firebird::PermanentStorage Transaction* getTransaction() noexcept { return m_transaction; } - void prepare(Jrd::thread_db* tdbb, Transaction* tran, const Firebird::string& sql, bool named); + void prepare(Jrd::thread_db* tdbb, Transaction* tran, const string& sql, bool named); void setTimeout(Jrd::thread_db* tdbb, unsigned int timeout); void execute(Jrd::thread_db* tdbb, Transaction* tran, const Jrd::MetaName* const* in_names, const Jrd::ValueListNode* in_params, @@ -703,7 +702,7 @@ class Statement : public Firebird::PermanentStorage void close(Jrd::thread_db* tdbb, bool invalidTran = false); void deallocate(Jrd::thread_db* tdbb); - const Firebird::string& getSql() const noexcept { return m_sql; } + const string& getSql() const noexcept { return m_sql; } void setCallerPrivileges(bool use) noexcept { m_callerPrivileges = use; } @@ -720,7 +719,7 @@ class Statement : public Firebird::PermanentStorage // Get error description from provider and put it with additional contex // info into locally raised exception void raise(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, const char* sWhere, - const Firebird::string* sQuery = NULL); + const string* sQuery = NULL); // Active statement must be bound to parent jrd request void bindToRequest(Jrd::Request* request, Statement** impure); @@ -730,7 +729,7 @@ class Statement : public Firebird::PermanentStorage virtual const char* getParameterName(unsigned index) const { return nullptr; } protected: - virtual void doPrepare(Jrd::thread_db* tdbb, const Firebird::string& sql) = 0; + virtual void doPrepare(Jrd::thread_db* tdbb, const string& sql) = 0; virtual void doSetTimeout(Jrd::thread_db* tdbb, unsigned int timeout) = 0; virtual void doExecute(Jrd::thread_db* tdbb) = 0; virtual void doOpen(Jrd::thread_db* tdbb) = 0; @@ -742,7 +741,7 @@ class Statement : public Firebird::PermanentStorage virtual void getOutParams(Jrd::thread_db* tdbb, const Jrd::ValueListNode* params); virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, - const Firebird::MetaString* const* names, const NestConst* params); + const MetaString* const* names, const NestConst* params); virtual void putExtBlob(Jrd::thread_db* tdbb, dsc& src, dsc& dst); virtual void getExtBlob(Jrd::thread_db* tdbb, const dsc& src, dsc& dst); @@ -751,7 +750,7 @@ class Statement : public Firebird::PermanentStorage // and remember correspondence between logical parameter names and unnamed // placeholders numbers. This is needed only if provider didn't support // named parameters natively. - void preprocess(const Firebird::string& sql, Firebird::string& ret); + void preprocess(const string& sql, string& ret); void clearNames(); @@ -766,7 +765,7 @@ class Statement : public Firebird::PermanentStorage Statement* m_nextInReq; Statement* m_prevInReq; - Firebird::string m_sql; + string m_sql; // passed in open() bool m_singleton; @@ -791,18 +790,18 @@ class Statement : public Firebird::PermanentStorage Jrd::Request* m_preparedByReq; // set in preprocess - Firebird::SortedObjectsArray m_sqlParamNames; - Firebird::Array m_sqlParamsMap; + SortedObjectsArray m_sqlParamNames; + Array m_sqlParamsMap; // set in prepare() - Firebird::UCharBuffer m_in_buffer; - Firebird::UCharBuffer m_out_buffer; - Firebird::Array m_inDescs; - Firebird::Array m_outDescs; + UCharBuffer m_in_buffer; + UCharBuffer m_out_buffer; + Array m_inDescs; + Array m_outDescs; }; -class Blob : public Firebird::PermanentStorage +class Blob : public PermanentStorage { friend class Connection; protected: @@ -814,9 +813,9 @@ class Blob : public Firebird::PermanentStorage virtual ~Blob() {} virtual void open(Jrd::thread_db* tdbb, Transaction& tran, const dsc& desc, - const Firebird::UCharBuffer* bpb) = 0; + const UCharBuffer* bpb) = 0; virtual void create(Jrd::thread_db* tdbb, Transaction& tran, dsc& desc, - const Firebird::UCharBuffer* bpb) = 0; + const UCharBuffer* bpb) = 0; virtual USHORT read(Jrd::thread_db* tdbb, UCHAR* buff, USHORT len) = 0; virtual void write(Jrd::thread_db* tdbb, const UCHAR* buff, USHORT len) = 0; virtual void close(Jrd::thread_db* tdbb) = 0; @@ -848,8 +847,8 @@ class EngineCallbackGuard void init(Jrd::thread_db* tdbb, Connection& conn, const char* from); Jrd::thread_db* m_tdbb; - Firebird::RefPtr m_stable; - Firebird::Mutex* m_mutex; + RefPtr m_stable; + Mutex* m_mutex; Connection* m_saveConnection; }; diff --git a/src/jrd/extds/InternalDS.cpp b/src/jrd/extds/InternalDS.cpp index 5c6b040251b..c2ea86784b7 100644 --- a/src/jrd/extds/InternalDS.cpp +++ b/src/jrd/extds/InternalDS.cpp @@ -44,10 +44,9 @@ #include "InternalDS.h" #include "ValidatePassword.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd::EDS +{ -namespace EDS { const char* INTERNAL_PROVIDER_NAME = "Internal"; @@ -882,4 +881,4 @@ void InternalBlob::cancel(thread_db* tdbb) } -} // namespace EDS +} // namespace Firebird::Jrd::EDS diff --git a/src/jrd/extds/InternalDS.h b/src/jrd/extds/InternalDS.h index 90f64c6b46b..4c8a05a8008 100644 --- a/src/jrd/extds/InternalDS.h +++ b/src/jrd/extds/InternalDS.h @@ -26,7 +26,7 @@ #include "ExtDS.h" -namespace EDS { +namespace Firebird::Jrd::EDS { class InternalProvider : public Provider { @@ -42,7 +42,7 @@ class InternalProvider : public Provider virtual void jrdAttachmentEnd(Jrd::thread_db* tdbb, Jrd::Attachment* att, bool forced); virtual void initialize() {} - virtual void getRemoteError(const Jrd::FbStatusVector* status, Firebird::string& err) const; + virtual void getRemoteError(const Jrd::FbStatusVector* status, string& err) const; protected: virtual Connection* doCreateConnection(); @@ -72,8 +72,8 @@ class InternalConnection : public Connection bool isConnected() const override { return (m_attachment != 0); } bool validate(Jrd::thread_db* tdbb) override; - bool isSameDatabase(const Firebird::PathName& dbName, - Firebird::ClumpletReader& dpb, const CryptHash& ch) const override; + bool isSameDatabase(const PathName& dbName, + ClumpletReader& dpb, const CryptHash& ch) const override; bool isCurrent() const override { return m_dpb.isEmpty(); } @@ -86,8 +86,8 @@ class InternalConnection : public Connection Statement* doCreateStatement() override; void doDetach(Jrd::thread_db* tdbb) override; - Firebird::AutoPlugin m_provider; - Firebird::RefPtr m_attachment; + AutoPlugin m_provider; + RefPtr m_attachment; }; @@ -108,13 +108,13 @@ class InternalTransaction : public Transaction Jrd::JTransaction* getJrdTran() { return m_transaction; } protected: - virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, Firebird::ClumpletWriter& tpb); + virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, ClumpletWriter& tpb); virtual void doPrepare(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, int info_len, const char* info); virtual void doCommit(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain); virtual void doRollback(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain); InternalConnection& m_IntConnection; - Firebird::RefPtr m_transaction; + RefPtr m_transaction; }; @@ -127,7 +127,7 @@ class InternalStatement : public Statement ~InternalStatement(); protected: - virtual void doPrepare(Jrd::thread_db* tdbb, const Firebird::string& sql); + virtual void doPrepare(Jrd::thread_db* tdbb, const string& sql); virtual void doSetTimeout(Jrd::thread_db* tdbb, unsigned int timeout); virtual void doExecute(Jrd::thread_db* tdbb); virtual void doOpen(Jrd::thread_db* tdbb); @@ -138,7 +138,7 @@ class InternalStatement : public Statement { if (m_inMetadata && index < m_inMetadata->getCount()) { - Firebird::FbLocalStatus status; + FbLocalStatus status; return m_inMetadata->getAlias(&status, index); } @@ -156,9 +156,9 @@ class InternalStatement : public Statement InternalConnection& m_intConnection; InternalTransaction* m_intTransaction; - Firebird::RefPtr m_request; - Firebird::RefPtr m_cursor; - Firebird::RefPtr m_inMetadata, m_outMetadata; + RefPtr m_request; + RefPtr m_cursor; + RefPtr m_inMetadata, m_outMetadata; }; @@ -172,8 +172,8 @@ class InternalBlob : public Blob ~InternalBlob(); public: - virtual void open(Jrd::thread_db* tdbb, Transaction& tran, const dsc& desc, const Firebird::UCharBuffer* bpb); - virtual void create(Jrd::thread_db* tdbb, Transaction& tran, dsc& desc, const Firebird::UCharBuffer* bpb); + virtual void open(Jrd::thread_db* tdbb, Transaction& tran, const dsc& desc, const UCharBuffer* bpb); + virtual void create(Jrd::thread_db* tdbb, Transaction& tran, dsc& desc, const UCharBuffer* bpb); virtual USHORT read(Jrd::thread_db* tdbb, UCHAR* buff, USHORT len); virtual void write(Jrd::thread_db* tdbb, const UCHAR* buff, USHORT len); virtual void close(Jrd::thread_db* tdbb); @@ -181,7 +181,7 @@ class InternalBlob : public Blob private: InternalConnection& m_connection; - Firebird::RefPtr m_blob; + RefPtr m_blob; ISC_QUAD m_blob_id; }; diff --git a/src/jrd/extds/IscDS.cpp b/src/jrd/extds/IscDS.cpp index 57f6680f4b4..8979dc9edd9 100644 --- a/src/jrd/extds/IscDS.cpp +++ b/src/jrd/extds/IscDS.cpp @@ -40,13 +40,10 @@ #include "../mov_proto.h" #include "../common/utils_proto.h" - -using namespace Jrd; -using namespace Firebird; - -namespace EDS +namespace Firebird::Jrd::EDS { + const char* FIREBIRD_PROVIDER_NAME = "Firebird"; class RegisterFBProvider @@ -62,7 +59,7 @@ class RegisterFBProvider static RegisterFBProvider reg; static bool isConnectionBrokenError(FbStatusVector* status); -static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array& descs); +static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Array& descs); // IscProvider @@ -354,7 +351,7 @@ void IscTransaction::generateTPB(thread_db* tdbb, ClumpletWriter& tpb, Transaction::generateTPB(tdbb, tpb, traMode, readOnly, wait, lockTimeout); } -void IscTransaction::doStart(FbStatusVector* status, thread_db* tdbb, Firebird::ClumpletWriter& tpb) +void IscTransaction::doStart(FbStatusVector* status, thread_db* tdbb, ClumpletWriter& tpb) { fb_assert(!m_handle); FB_API_HANDLE& db_handle = m_iscConnection.getAPIHandle(); @@ -1507,7 +1504,7 @@ ISC_STATUS ISC_EXPORT_VARARG IscProvider::isc_start_transaction(FbStatusVector* if (!m_api.start_multiple) // !!! return notImplemented(user_status); - Firebird::HalfStaticArray tebs; + HalfStaticArray tebs; why_teb* teb = tebs.getBuffer(count); const why_teb* const end = teb + count; @@ -1782,7 +1779,7 @@ static bool isConnectionBrokenError(FbStatusVector* status) } -static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array &descs) +static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Array &descs) { FB_SIZE_T offset = 0; XSQLVAR* xVar = xsqlda->sqlvar; @@ -1850,5 +1847,4 @@ static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array & } - -} // namespace EDS +} // namespace Firebird::Jrd::EDS diff --git a/src/jrd/extds/IscDS.h b/src/jrd/extds/IscDS.h index ad85daffc04..771303241a0 100644 --- a/src/jrd/extds/IscDS.h +++ b/src/jrd/extds/IscDS.h @@ -29,7 +29,7 @@ #include "../jrd/status.h" -namespace EDS { +namespace Firebird::Jrd::EDS { class IscProvider : public Provider { @@ -49,7 +49,7 @@ class IscProvider : public Provider loadAPI(); } - virtual void getRemoteError(const Jrd::FbStatusVector* status, Firebird::string& err) const; + virtual void getRemoteError(const Jrd::FbStatusVector* status, string& err) const; protected: ISC_STATUS notImplemented(Jrd::FbStatusVector*) const; @@ -557,10 +557,10 @@ class IscTransaction : public Transaction virtual ~IscTransaction() {} - virtual void generateTPB(Jrd::thread_db* tdbb, Firebird::ClumpletWriter& tpb, + virtual void generateTPB(Jrd::thread_db* tdbb, ClumpletWriter& tpb, TraModes traMode, bool readOnly, bool wait, int lockTimeout) const; - virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, Firebird::ClumpletWriter& tpb); + virtual void doStart(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, ClumpletWriter& tpb); virtual void doPrepare(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, int info_len, const char* info); virtual void doCommit(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain); virtual void doRollback(Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, bool retain); @@ -583,7 +583,7 @@ class IscStatement : public Statement virtual ~IscStatement(); protected: - virtual void doPrepare(Jrd::thread_db* tdbb, const Firebird::string& sql); + virtual void doPrepare(Jrd::thread_db* tdbb, const string& sql); virtual void doSetTimeout(Jrd::thread_db* tdbb, unsigned int timeout); virtual void doExecute(Jrd::thread_db* tdbb); virtual void doOpen(Jrd::thread_db* tdbb); @@ -604,7 +604,7 @@ class IscStatement : public Statement } virtual void doSetInParams(Jrd::thread_db* tdbb, unsigned int count, - const Firebird::MetaString* const* names, const NestConst* params); + const MetaString* const* names, const NestConst* params); IscTransaction* getIscTransaction() { return (IscTransaction*) m_transaction; } @@ -626,9 +626,9 @@ class IscBlob : public Blob public: virtual void open(Jrd::thread_db* tdbb, Transaction& tran, const dsc& desc, - const Firebird::UCharBuffer* bpb); + const UCharBuffer* bpb); virtual void create(Jrd::thread_db* tdbb, Transaction& tran, dsc& desc, - const Firebird::UCharBuffer* bpb); + const UCharBuffer* bpb); virtual USHORT read(Jrd::thread_db* tdbb, UCHAR* buff, USHORT len); virtual void write(Jrd::thread_db* tdbb, const UCHAR* buff, USHORT len); virtual void close(Jrd::thread_db* tdbb); diff --git a/src/jrd/extds/ValidatePassword.cpp b/src/jrd/extds/ValidatePassword.cpp index c5488aed7d3..782f6ae8046 100644 --- a/src/jrd/extds/ValidatePassword.cpp +++ b/src/jrd/extds/ValidatePassword.cpp @@ -32,22 +32,21 @@ #include "../common/classes/GetPlugins.h" #include "../common/classes/ParsedList.h" - -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd::EDS +{ namespace { class DummyCryptKey final : - public Firebird::AutoIface > + public AutoIface > { public: // ICryptKey implementation - void setSymmetric(Firebird::CheckStatusWrapper* status, const char* type, unsigned keyLength, const void* key) + void setSymmetric(CheckStatusWrapper* status, const char* type, unsigned keyLength, const void* key) { } - void setAsymmetric(Firebird::CheckStatusWrapper* status, const char* type, unsigned encryptKeyLength, + void setAsymmetric(CheckStatusWrapper* status, const char* type, unsigned encryptKeyLength, const void* encryptKey, unsigned decryptKeyLength, const void* decryptKey) { } @@ -80,7 +79,7 @@ class CBlock final : public RefCntIfacesBlock = this; } - // Firebird::IServerBlock implementation + // IServerBlock implementation const char* getLogin() { return cBlock->getLogin(); @@ -142,7 +141,7 @@ class SBlock final : public AutoIfacectl_buffer_length; - Firebird::HalfStaticArray buffer; + HalfStaticArray buffer; bool first = true; BYTE* p; @@ -985,7 +986,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) result_length = aux->ctlaux_obj1.convert(len, p, aux->ctlaux_buffer1_len, aux->ctlaux_buffer1, &err_position); } - catch (const Firebird::status_exception&) + catch (const status_exception&) { return isc_transliteration_failed; } @@ -1112,7 +1113,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) control->ctl_buffer_length, control->ctl_buffer, &err_position); } - catch (const Firebird::status_exception&) + catch (const status_exception&) { return isc_transliteration_failed; } @@ -1571,3 +1572,6 @@ ISC_STATUS filter_debug_info(USHORT action, BlobControl* control) return FB_SUCCESS; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/flu.cpp b/src/jrd/flu.cpp index ddd57c05fcb..b208304a1eb 100644 --- a/src/jrd/flu.cpp +++ b/src/jrd/flu.cpp @@ -68,11 +68,13 @@ #define DYNAMIC_SHARED_LIBRARIES #endif -using namespace Firebird; +namespace Firebird::Jrd +{ + namespace { - Firebird::InitInstance loadedModules; - Firebird::GlobalPtr modulesMutex; + InitInstance loadedModules; + GlobalPtr modulesMutex; template void terminate_at_space(S& s, const char* psz) @@ -116,12 +118,12 @@ namespace { }; // UDF/BLOB filter verifier - class UdfDirectoryList : public Firebird::DirectoryList + class UdfDirectoryList : public DirectoryList { private: - const Firebird::PathName getConfigString() const + const PathName getConfigString() const { - return Firebird::PathName(Config::getUdfAccess()); + return PathName(Config::getUdfAccess()); } public: explicit UdfDirectoryList(MemoryPool& p) @@ -130,18 +132,17 @@ namespace { initialize(); } }; - Firebird::InitInstance iUdfDirectoryList; + InitInstance iUdfDirectoryList; } -namespace Jrd -{ + bool Module::operator>(const Module &im) const { // we need it to sort on some key return interMod > im.interMod; } - Module::InternalModule* Module::scanModule(const Firebird::PathName& name) + Module::InternalModule* Module::scanModule(const PathName& name) { typedef Module::InternalModule** itr; for (itr it = loadedModules().begin(); it != loadedModules().end(); ++it) @@ -164,7 +165,7 @@ namespace Jrd return 0; } - Firebird::string symbol; + string symbol; terminate_at_space(symbol, name); void* rc = m.lookupSymbol(symbol); if (rc) @@ -176,9 +177,9 @@ namespace Jrd // flag 'udf' means pass name-path through UdfDirectoryList Module Module::lookupModule(const char* name) { - Firebird::MutexLockGuard lg(modulesMutex, FB_FUNCTION); + MutexLockGuard lg(modulesMutex, FB_FUNCTION); - Firebird::PathName initialModule; + PathName initialModule; terminate_at_space(initialModule, name); // Look for module in array of already loaded @@ -189,12 +190,12 @@ namespace Jrd } // apply suffix (and/or prefix) and try that name - Firebird::PathName module(initialModule); + PathName module(initialModule); for (size_t i = 0; i < sizeof(libfixes) / sizeof(Libfix); i++) { const Libfix* l = &libfixes[i]; // os-dependent module name modification - Firebird::PathName fixedModule(module); + PathName fixedModule(module); switch (l->kind) { case MOD_PREFIX: @@ -216,7 +217,7 @@ namespace Jrd } // UdfAccess verification - Firebird::PathName path, relative; + PathName path, relative; // Search for module name in UdfAccess restricted // paths list @@ -257,7 +258,7 @@ namespace Jrd { if (interMod) { - Firebird::MutexLockGuard lg(modulesMutex, FB_FUNCTION); + MutexLockGuard lg(modulesMutex, FB_FUNCTION); interMod = NULL; // This makes RefPtr call release() } } @@ -280,4 +281,5 @@ namespace Jrd fb_assert(false); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/flu.h b/src/jrd/flu.h index 45880a24b1a..c6bc7dd670e 100644 --- a/src/jrd/flu.h +++ b/src/jrd/flu.h @@ -33,14 +33,13 @@ #include "../common/os/mod_loader.h" #include "../common/classes/RefCounted.h" -namespace Jrd -{ +namespace Firebird::Jrd { class Database; class Module { private: - class InternalModule : public Firebird::RefCounted + class InternalModule : public RefCounted { private: InternalModule(const InternalModule &im); @@ -48,9 +47,9 @@ namespace Jrd public: ModuleLoader::Module* handle; - Firebird::PathName originalName, loadName; + PathName originalName, loadName; - void* findSymbol(const Firebird::string& name) + void* findSymbol(const string& name) { if (! handle) { @@ -61,8 +60,8 @@ namespace Jrd InternalModule(MemoryPool& p, ModuleLoader::Module* h, - const Firebird::PathName& on, - const Firebird::PathName& ln) + const PathName& on, + const PathName& ln) : handle(h), originalName(p, on), loadName(p, ln) @@ -70,14 +69,14 @@ namespace Jrd ~InternalModule(); - bool operator==(const Firebird::PathName &pn) const + bool operator==(const PathName &pn) const { return originalName == pn || loadName == pn; } }; - Firebird::RefPtr interMod; + RefPtr interMod; explicit Module(InternalModule* h) : interMod(h) @@ -85,10 +84,10 @@ namespace Jrd static Module lookupModule(const char*); - static InternalModule* scanModule(const Firebird::PathName& name); + static InternalModule* scanModule(const PathName& name); public: - typedef Firebird::Array LoadedModules; + typedef Array LoadedModules; Module() { } @@ -111,7 +110,7 @@ namespace Jrd bool operator>(const Module &im) const; - void *lookupSymbol(const Firebird::string& name) + void *lookupSymbol(const string& name) { if (! interMod) { @@ -126,8 +125,8 @@ namespace Jrd } }; - typedef Firebird::SortedObjectsArray DatabaseModules; + typedef SortedObjectsArray DatabaseModules; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_FLU_H diff --git a/src/jrd/flu_proto.h b/src/jrd/flu_proto.h index a56e08278f0..b49a6e0dcae 100644 --- a/src/jrd/flu_proto.h +++ b/src/jrd/flu_proto.h @@ -25,8 +25,10 @@ #ifndef JRD_FLU_PROTO_H #define JRD_FLU_PROTO_H -FPTR_INT BUILTIN_entrypoint(const TEXT*, const TEXT*); -FPTR_INT FUNCTIONS_entrypoint(const char*, const char*); +namespace Firebird::Jrd +{ + FPTR_INT BUILTIN_entrypoint(const TEXT*, const TEXT*); + FPTR_INT FUNCTIONS_entrypoint(const char*, const char*); +} // namespace Firebird::Jrd #endif // JRD_FLU_PROTO_H - diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp index 94163f4de2d..225256426c7 100644 --- a/src/jrd/fun.epp +++ b/src/jrd/fun.epp @@ -73,8 +73,8 @@ #include // dladdr #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ namespace @@ -330,7 +330,7 @@ void FUN_evaluate(thread_db* tdbb, const Function* function, const NestValueArra if (!function->fun_entrypoint) { - Firebird::status_exception::raise(Arg::Gds(isc_funnotdef) << + status_exception::raise(Arg::Gds(isc_funnotdef) << Arg::Str(function->getName().toQuotedString()) << Arg::Gds(isc_modnotfound)); } @@ -1236,9 +1236,12 @@ static bool private_move(Jrd::thread_db* tdbb, dsc* from, dsc* to) MOV_move(tdbb, from, to); return true; } - catch (const Firebird::status_exception& e) + catch (const status_exception& e) { e.stuffException(tdbb->tdbb_status_vector); return false; } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/fun_proto.h b/src/jrd/fun_proto.h index b32cc0503ca..c7cad4fdd1b 100644 --- a/src/jrd/fun_proto.h +++ b/src/jrd/fun_proto.h @@ -27,17 +27,19 @@ #include "../dsql/Nodes.h" -class IbUtil +namespace Firebird::Jrd { -public: - static void initialize(); + class IbUtil + { + public: + static void initialize(); - static void* alloc(long size); - static bool free(void* ptr); -}; + static void* alloc(long size); + static bool free(void* ptr); + }; -void FUN_evaluate(Jrd::thread_db*, const Jrd::Function*, const Jrd::NestValueArray&, - Jrd::impure_value*, Firebird::Array& temp); + void FUN_evaluate(thread_db*, const Function*, const NestValueArray&, impure_value*, Array& temp); +} // namespace Firebird::Jrd #endif // JRD_FUN_PROTO_H diff --git a/src/jrd/grant.epp b/src/jrd/grant.epp index a92f11ef3f3..75be3ead635 100644 --- a/src/jrd/grant.epp +++ b/src/jrd/grant.epp @@ -54,10 +54,11 @@ #include "../common/utils_proto.h" #include "../common/classes/array.h" #include "../common/classes/auto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Jrd +{ -using namespace Firebird; -using namespace Jrd; // privileges given to the owner of a relation @@ -196,7 +197,7 @@ void GRANT_privileges(thread_db* tdbb, const QualifiedName& name, ObjectType id, static void ensure_relation_reload(thread_db* tdbb, MetaId id, jrd_tra* transaction) { - Firebird::AutoSetRestore2 tempTrans(tdbb, + AutoSetRestore2 tempTrans(tdbb, &thread_db::getTransaction, &thread_db::setTransaction, transaction); @@ -1282,3 +1283,6 @@ static bool check_string(const UCHAR* acl, const MetaName& name) return (*string && *string != ' ') ? true : false; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/grant_proto.h b/src/jrd/grant_proto.h index b1fe0ffe708..03e8ebdc157 100644 --- a/src/jrd/grant_proto.h +++ b/src/jrd/grant_proto.h @@ -26,8 +26,11 @@ #include "../common/classes/fb_string.h" #include "../jrd/QualifiedName.h" -#include "../jrd/obj.h" +#include "../common/obj.h" -void GRANT_privileges(Jrd::thread_db*, const Jrd::QualifiedName&, ObjectType, Jrd::jrd_tra*); +namespace Firebird::Jrd +{ + void GRANT_privileges(thread_db*, const QualifiedName&, ObjectType, jrd_tra*); +} // namespace Firebird::Jrd #endif // JRD_GRANT_PROTO_H diff --git a/src/jrd/ibsetjmp.h b/src/jrd/ibsetjmp.h index abe2c1638c6..8f6c7092362 100644 --- a/src/jrd/ibsetjmp.h +++ b/src/jrd/ibsetjmp.h @@ -44,9 +44,9 @@ { \ if ((sig = sigsetjmp(sigenv, 1))) \ ISC_exception_post(sig, err, __isc_error_code); \ - Firebird::syncSignalsSet(&sigenv); \ + syncSignalsSet(&sigenv); \ } -#define END_CHECK_FOR_EXCEPTIONS(err) if (!Config::getBugcheckAbort()) Firebird::syncSignalsReset(); } +#define END_CHECK_FOR_EXCEPTIONS(err) if (!Config::getBugcheckAbort()) syncSignalsReset(); } #endif // UNIX diff --git a/src/jrd/idx.cpp b/src/jrd/idx.cpp index 4a23500f23f..2d77e12c9a6 100644 --- a/src/jrd/idx.cpp +++ b/src/jrd/idx.cpp @@ -68,9 +68,9 @@ #include "../common/Task.h" #include "../jrd/WorkerAttachment.h" -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ + static idx_e check_duplicates(thread_db*, Record*, index_desc*, index_insertion*, jrd_rel*); static idx_e check_foreign_key(thread_db*, Record*, jrd_rel*, jrd_tra*, index_desc*, IndexErrorContext&); @@ -206,8 +206,6 @@ bool IDX_check_master_types(thread_db* tdbb, index_desc& idx, Cached::Relation* } -namespace Jrd { - class IndexCreateTask : public Task { public: @@ -530,7 +528,7 @@ bool IndexCreateTask::handler(WorkItem& _item) fb_assert(!m_exprBlob.isEmpty()); CompilerScratch* csb = NULL; - Jrd::ContextPoolHolder context(tdbb, dbb->createPool()); + JrdContextPoolHolder context(tdbb, dbb->createPool()); idx->idx_expression_node = static_cast (MET_parse_blob(tdbb, &relation->getName().schema, getPermanent(relation), &m_exprBlob, &csb, &idx->idx_expression_statement, false, false)); @@ -543,7 +541,7 @@ bool IndexCreateTask::handler(WorkItem& _item) fb_assert(!m_condBlob.isEmpty()); CompilerScratch* csb = NULL; - Jrd::ContextPoolHolder context(tdbb, dbb->createPool()); + JrdContextPoolHolder context(tdbb, dbb->createPool()); idx->idx_condition_node = static_cast (MET_parse_blob(tdbb, &relation->getName().schema, getPermanent(relation), &m_condBlob, &csb, &idx->idx_condition_statement, false, false)); @@ -815,8 +813,6 @@ int IndexCreateTask::getMaxWorkers() return MIN(parWorkers, m_countPP); } -}; // namespace Jrd - void IDX_create_index(thread_db* tdbb, IdxCreate createMethod, @@ -988,7 +984,7 @@ void IDX_mark_index(thread_db* tdbb, Cached::Relation* relation, MetaId id) auto* relPages = relation->getPages(tdbb); WIN window(relPages->rel_pg_space_id, relPages->rel_index_root); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); // loop through pagespaces and mark for delete %%%%%% // if ((relation->rel_flags & REL_temp_conn) && (relPages->rel_instance_id != 0)) @@ -1014,7 +1010,7 @@ void IDX_delete_indices(thread_db* tdbb, RelationPermanent* relation, RelationPa fb_assert(relPages->rel_index_root); WIN window(relPages->rel_pg_space_id, relPages->rel_index_root); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); // loop through pagespaces and mark for delete %%%%%% // if ((relation->rel_flags & REL_temp_conn) && (relPages->rel_instance_id != 0)) @@ -1048,7 +1044,7 @@ void IDX_mark_indices(thread_db* tdbb, Cached::Relation* relation) fb_assert(relPages->rel_index_root); WIN window(relPages->rel_pg_space_id, relPages->rel_index_root); - index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); + Ods::index_root_page* root = BTR_fetch_root_for_update(FB_FUNCTION, tdbb, &window); // loop through pagespaces and mark for delete %%%%%% // if ((relation->rel_flags & REL_temp_conn) && (relPages->rel_instance_id != 0)) @@ -2053,3 +2049,6 @@ static idx_e insert_key(thread_db* tdbb, return result; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/idx.h b/src/jrd/idx.h index 0e7811a7870..3b22d7540e8 100644 --- a/src/jrd/idx.h +++ b/src/jrd/idx.h @@ -27,6 +27,10 @@ #ifndef JRD_IDX_H #define JRD_IDX_H +namespace Firebird::Jrd +{ + + /* Indices to be created */ /* Maximum number of segments in any existing system index */ @@ -48,13 +52,6 @@ struct ini_idx_t /* Encoded descriptions of system indices */ -using Jrd::idx_unique; -using Jrd::idx_metadata; -using Jrd::idx_numeric; -using Jrd::idx_string; -using Jrd::idx_descending; -using Jrd::idx_timestamp_tz; - #define INDEX(id, rel, unique, count, ods) {(id), (UCHAR) (rel), (unique), (count), (ods), { #define SEGMENT(fld, type) {(fld), (type)} @@ -529,4 +526,7 @@ static inline constexpr struct ini_idx_t indices[] = #define SYSTEM_INDEX_COUNT FB_NELEM(indices) + +} // namespace Firebird::jrd + #endif /* JRD_IDX_H */ diff --git a/src/jrd/idx_proto.h b/src/jrd/idx_proto.h index 2337b6af572..65b26ec4d1b 100644 --- a/src/jrd/idx_proto.h +++ b/src/jrd/idx_proto.h @@ -28,7 +28,7 @@ #include "../jrd/exe.h" #include "../jrd/req.h" -namespace Jrd +namespace Firebird::Jrd { class jrd_rel; class jrd_tra; @@ -36,23 +36,23 @@ namespace Jrd struct index_desc; class CompilerScratch; class thread_db; -} -bool IDX_activate_index(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId); -void IDX_check_access(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::Cached::Relation*, Jrd::Cached::Relation*); -bool IDX_check_master_types (Jrd::thread_db*, Jrd::index_desc&, Jrd::Cached::Relation*, int&); -void IDX_create_index(Jrd::thread_db*, Jrd::IdxCreate createMethod, Jrd::jrd_rel*, Jrd::index_desc*, const Jrd::QualifiedName&, - USHORT*, Jrd::jrd_tra*, Jrd::SelectivityList&); -void IDX_mark_index(Jrd::thread_db*, Jrd::Cached::Relation*, MetaId); -void IDX_delete_indices(Jrd::thread_db*, Jrd::RelationPermanent*, Jrd::RelationPages*, bool); -void IDX_mark_indices(Jrd::thread_db*, Jrd::Cached::Relation*); -void IDX_erase(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -void IDX_garbage_collect(Jrd::thread_db*, Jrd::record_param*, Jrd::RecordStack&, Jrd::RecordStack&); -void IDX_modify(Jrd::thread_db*, Jrd::record_param*, Jrd::record_param*, Jrd::jrd_tra*); -void IDX_modify_check_constraints(Jrd::thread_db*, Jrd::record_param*, Jrd::record_param*, Jrd::jrd_tra*); -void IDX_statistics(Jrd::thread_db*, Jrd::Cached::Relation*, USHORT, Jrd::SelectivityList&); -void IDX_store(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -void IDX_modify_flag_uk_modified(Jrd::thread_db*, Jrd::record_param*, Jrd::record_param*, Jrd::jrd_tra*); + bool IDX_activate_index(thread_db*, Cached::Relation*, MetaId); + void IDX_check_access(thread_db*, CompilerScratch*, Cached::Relation*, Cached::Relation*); + bool IDX_check_master_types (thread_db*, index_desc&, Cached::Relation*, int&); + void IDX_create_index(thread_db*, IdxCreate createMethod, jrd_rel*, index_desc*, const QualifiedName&, + USHORT*, jrd_tra*, SelectivityList&); + void IDX_mark_index(thread_db*, Cached::Relation*, MetaId); + void IDX_delete_indices(thread_db*, RelationPermanent*, RelationPages*, bool); + void IDX_mark_indices(thread_db*, Cached::Relation*); + void IDX_erase(thread_db*, record_param*, jrd_tra*); + void IDX_garbage_collect(thread_db*, record_param*, RecordStack&, RecordStack&); + void IDX_modify(thread_db*, record_param*, record_param*, jrd_tra*); + void IDX_modify_check_constraints(thread_db*, record_param*, record_param*, jrd_tra*); + void IDX_statistics(thread_db*, Cached::Relation*, USHORT, SelectivityList&); + void IDX_store(thread_db*, record_param*, jrd_tra*); + void IDX_modify_flag_uk_modified(thread_db*, record_param*, record_param*, jrd_tra*); +} // namespace Firebird::Jrd #endif // JRD_IDX_PROTO_H diff --git a/src/jrd/inf.cpp b/src/jrd/inf.cpp index 270b3bee1c1..d8e52d1be48 100644 --- a/src/jrd/inf.cpp +++ b/src/jrd/inf.cpp @@ -66,8 +66,9 @@ #include "../jrd/validation.h" #include "../jrd/CryptoManager.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // The variable DBSERVER_BASE_LEVEL was originally IB_MAJOR_VER but with // the change to Firebird this number could no longer be used. @@ -631,7 +632,7 @@ void INF_database_info(thread_db* tdbb, SyncLockGuard sync(&dbb->dbb_sync, SYNC_SHARED, "INF_database_info"); - for (const Jrd::Attachment* att = dbb->dbb_attachments; att; att = att->att_next) + for (const Attachment* att = dbb->dbb_attachments; att; att = att->att_next) { const UserId* const user = att->att_user; @@ -1300,3 +1301,6 @@ void INF_transaction_info(const jrd_tra* transaction, INF_put_item(isc_info_length, length, buffer, start_info, end, true); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/inf_proto.h b/src/jrd/inf_proto.h index 2478689bfc7..a500f21703f 100644 --- a/src/jrd/inf_proto.h +++ b/src/jrd/inf_proto.h @@ -24,17 +24,19 @@ #ifndef JRD_INF_PROTO_H #define JRD_INF_PROTO_H -namespace Jrd { +namespace Firebird::Jrd +{ + class thread_db; class Request; class jrd_tra; class blb; -} -void INF_blob_info(const Jrd::blb*, const ULONG, const UCHAR*, const ULONG, UCHAR*); -USHORT INF_convert(SINT64, UCHAR*); -void INF_database_info(Jrd::thread_db*, const ULONG, const UCHAR*, const ULONG, UCHAR*); -UCHAR* INF_put_item(UCHAR, ULONG, const void*, UCHAR*, const UCHAR*, const bool inserting = false); -ULONG INF_request_info(const Jrd::Request*, const ULONG, const UCHAR*, const ULONG, UCHAR*); -void INF_transaction_info(const Jrd::jrd_tra*, const ULONG, const UCHAR*, const ULONG, UCHAR*); + void INF_blob_info(const blb*, const ULONG, const UCHAR*, const ULONG, UCHAR*); + USHORT INF_convert(SINT64, UCHAR*); + void INF_database_info(thread_db*, const ULONG, const UCHAR*, const ULONG, UCHAR*); + UCHAR* INF_put_item(UCHAR, ULONG, const void*, UCHAR*, const UCHAR*, const bool inserting = false); + ULONG INF_request_info(const Request*, const ULONG, const UCHAR*, const ULONG, UCHAR*); + void INF_transaction_info(const jrd_tra*, const ULONG, const UCHAR*, const ULONG, UCHAR*); +} // namespace Firebird::Jrd #endif // JRD_INF_PROTO_H diff --git a/src/jrd/ini.epp b/src/jrd/ini.epp index 27bf34994b2..d8936492e07 100644 --- a/src/jrd/ini.epp +++ b/src/jrd/ini.epp @@ -53,20 +53,21 @@ #include "../jrd/met_proto.h" #include "../jrd/scl_proto.h" #include "../jrd/tra_proto.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/acl.h" #include "../jrd/dyn.h" #include "../jrd/irq.h" #include "../jrd/met.h" #include "../jrd/IntlManager.h" #include "../jrd/PreparedStatement.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/grant_proto.h" #include "../jrd/SystemPackages.h" #include "../dsql/DdlNodes.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + DATABASE DB = FILENAME "ODS.RDB"; @@ -2159,3 +2160,6 @@ static void store_packages(thread_db* tdbb, NonRelationSecurity& security, USHOR } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/ini.h b/src/jrd/ini.h index 12bd1ba9533..416097b2670 100644 --- a/src/jrd/ini.h +++ b/src/jrd/ini.h @@ -32,12 +32,19 @@ #include "../jrd/intl.h" #include "../intl/country_codes.h" #include "../intl/charsets.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/dflt.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ods.h" #include "../common/dsc.h" +// Should go before types.h +#include "SystemPrivileges.h" + +namespace Firebird::Jrd +{ + + //****************************** // names.h //****************************** @@ -165,13 +172,6 @@ static inline constexpr int relfields[] = #undef FIELD #undef END_RELATION -//****************************** -// SystemPrivileges.h -// should go before types.h -//****************************** - -#include "SystemPrivileges.h" - //****************************** // types.h //****************************** @@ -195,4 +195,7 @@ static inline constexpr rtyp types[] = #undef TYPE + +} // namespace Firebird::Jrd + #endif // JRD_INI_H diff --git a/src/jrd/ini_proto.h b/src/jrd/ini_proto.h index 08e51b68202..b36c892408e 100644 --- a/src/jrd/ini_proto.h +++ b/src/jrd/ini_proto.h @@ -24,16 +24,17 @@ #ifndef JRD_INI_PROTO_H #define JRD_INI_PROTO_H -namespace Jrd { +namespace Firebird::Jrd +{ struct jrd_trg; class dsql_dbb; -} -void INI_format(Jrd::thread_db*, const Firebird::string&); -void INI_init(Jrd::thread_db*); -void INI_init_sys_relations(Jrd::thread_db*); -void INI_init_dsql(Jrd::thread_db*, Jrd::dsql_dbb* database); -Firebird::string INI_owner_privileges(); -void INI_upgrade(Jrd::thread_db*); + void INI_format(thread_db*, const string&); + void INI_init(thread_db*); + void INI_init_sys_relations(thread_db*); + void INI_init_dsql(thread_db*, dsql_dbb* database); + string INI_owner_privileges(); + void INI_upgrade(thread_db*); +} // namespace Firebird::Jrd #endif // JRD_INI_PROTO_H diff --git a/src/jrd/intl.cpp b/src/jrd/intl.cpp index 45bb706547d..0198f146cc5 100644 --- a/src/jrd/intl.cpp +++ b/src/jrd/intl.cpp @@ -124,8 +124,9 @@ #include "../jrd/IntlManager.h" #include "../common/classes/init.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + #define IS_TEXT(x) (((x)->dsc_dtype == dtype_text) ||\ ((x)->dsc_dtype == dtype_varying)||\ @@ -310,7 +311,7 @@ void INTL_adjust_text_descriptor(thread_db* tdbb, dsc* desc) if (charSet->isMultiByte()) { - Firebird::HalfStaticArray buffer; + HalfStaticArray buffer; desc->dsc_length = charSet->substring(TEXT_LEN(desc), desc->dsc_address, TEXT_LEN(desc), buffer.getBuffer(TEXT_LEN(desc)), 0, @@ -539,7 +540,7 @@ CsConvert INTL_convert_lookup(thread_db* tdbb, CSetId to_cs, CSetId from_cs) } -void INTL_convert_string(dsc* to, const dsc* from, Firebird::Callbacks* cb) +void INTL_convert_string(dsc* to, const dsc* from, Callbacks* cb) { /************************************** * @@ -1112,3 +1113,6 @@ static void pad_spaces(thread_db* tdbb, CSetId charset, BYTE* ptr, ULONG len) } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/intl_builtin.cpp b/src/jrd/intl_builtin.cpp index 2a447cc6a91..de505ff54c7 100644 --- a/src/jrd/intl_builtin.cpp +++ b/src/jrd/intl_builtin.cpp @@ -14,8 +14,8 @@ #include "../intl/charsets.h" #include "../common/classes/Aligner.h" -using Firebird::IntlUtil; -using Firebird::UnicodeUtil; +namespace Firebird::Jrd +{ static USHORT internal_keylength(texttype*, USHORT); @@ -214,7 +214,7 @@ static ULONG internal_fss_to_unicode(csconvert* obj, if (p_dest_ptr == NULL) return (src_len * 2); // All single byte narrow characters - Firebird::OutAligner d(p_dest_ptr, dest_len); + OutAligner d(p_dest_ptr, dest_len); UNICODE* dest_ptr = d; const UNICODE* const start = dest_ptr; @@ -263,7 +263,7 @@ ULONG internal_unicode_to_fss(csconvert* obj, if (fss_str == NULL) return ((unicode_len + 1) / 2 * 3); // worst case - all han character input - Firebird::Aligner s(p_unicode_str, unicode_len); + Aligner s(p_unicode_str, unicode_len); const UNICODE* unicode_str = s; const UCHAR* const start = fss_str; @@ -670,7 +670,7 @@ static USHORT utf16_string_to_key(texttype* obj, fb_assert(obj != NULL); fb_assert(srcLen % 2 == 0); - Firebird::Aligner alSrc(src, srcLen); + Aligner alSrc(src, srcLen); if (obj->texttype_pad_option) { @@ -700,8 +700,8 @@ static SSHORT utf16_compare(texttype* obj, fb_assert(len1 % 2 == 0 && len2 % 2 == 0); fb_assert(str1 != NULL && str2 != NULL); - Firebird::Aligner al1(str1, len1); - Firebird::Aligner al2(str2, len2); + Aligner al1(str1, len1); + Aligner al2(str2, len2); if (obj->texttype_pad_option) { @@ -727,8 +727,8 @@ static ULONG utf16_upper(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG ds fb_assert(srcLen % 2 == 0); fb_assert(src != NULL && dst != NULL); - return UnicodeUtil::utf16UpperCase(srcLen, Firebird::Aligner(src, srcLen), - dstLen, Firebird::OutAligner(dst, dstLen), NULL); + return UnicodeUtil::utf16UpperCase(srcLen, Aligner(src, srcLen), + dstLen, OutAligner(dst, dstLen), NULL); } static ULONG utf16_lower(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst) @@ -746,8 +746,8 @@ static ULONG utf16_lower(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG ds fb_assert(srcLen % 2 == 0); fb_assert(src != NULL && dst != NULL); - return UnicodeUtil::utf16LowerCase(srcLen, Firebird::Aligner(src, srcLen), - dstLen, Firebird::OutAligner(dst, dstLen), NULL); + return UnicodeUtil::utf16LowerCase(srcLen, Aligner(src, srcLen), + dstLen, OutAligner(dst, dstLen), NULL); } @@ -787,8 +787,8 @@ static USHORT utf32_string_to_key(texttype* obj, USHORT err_code; ULONG err_position; - Firebird::HalfStaticArray utf16Str; - ULONG sLen = UnicodeUtil::utf32ToUtf16(srcLen, Firebird::Aligner(src, srcLen), + HalfStaticArray utf16Str; + ULONG sLen = UnicodeUtil::utf32ToUtf16(srcLen, Aligner(src, srcLen), dstLen, utf16Str.getBuffer(dstLen / sizeof(USHORT) + 1), &err_code, &err_position); const USHORT* s = utf16Str.begin(); @@ -823,7 +823,7 @@ static ULONG wc_to_nc(csconvert* obj, ULONG nSrc, const UCHAR* ppSrc, if (pDest == NULL) // length estimate needed? return ((nSrc + 1) / 2); - Firebird::Aligner s(ppSrc, nSrc); + Aligner s(ppSrc, nSrc); const USHORT* pSrc = s; const UCHAR* const pStart = pDest; @@ -873,7 +873,7 @@ static ULONG mb_to_wc(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, if (ppDest == NULL) // length estimate needed? return (nSrc); - Firebird::OutAligner d(ppDest, nDest); + OutAligner d(ppDest, nDest); USHORT* pDest = d; const USHORT* const pStart = pDest; @@ -918,7 +918,7 @@ static ULONG wc_to_mb(csconvert* obj, ULONG nSrc, const UCHAR* ppSrc, if (pDest == NULL) // length estimate needed? return (nSrc); - Firebird::Aligner s(ppSrc, nSrc); + Aligner s(ppSrc, nSrc); const USHORT* pSrc = s; const UCHAR* const pStart = pDest; @@ -1074,11 +1074,11 @@ static INTL_BOOL ttype_unicode8_init(texttype* tt, memset(cs, 0, sizeof(*cs)); cs_utf8_init(cs, "UTF8", config_info); - Firebird::UCharBuffer specificAttributes; + UCharBuffer specificAttributes; memcpy(specificAttributes.getBuffer(specific_attributes_length), specific_attributes, specific_attributes_length); - return Firebird::IntlUtil::initUnicodeCollation(tt, cs, POSIX, attributes, specificAttributes, config_info); + return IntlUtil::initUnicodeCollation(tt, cs, POSIX, attributes, specificAttributes, config_info); } @@ -1160,7 +1160,7 @@ static INTL_BOOL cs_utf16_well_formed(charset* cs, *************************************/ fb_assert(cs != NULL); - return UnicodeUtil::utf16WellFormed(len, Firebird::Aligner(str, len), offending_position); + return UnicodeUtil::utf16WellFormed(len, Aligner(str, len), offending_position); } @@ -1177,7 +1177,7 @@ static ULONG cs_utf16_length(charset* cs, ULONG srcLen, const UCHAR* src) * *************************************/ fb_assert(cs != NULL); - return UnicodeUtil::utf16Length(srcLen, Firebird::Aligner(src, srcLen)); + return UnicodeUtil::utf16Length(srcLen, Aligner(src, srcLen)); } @@ -1201,8 +1201,8 @@ static ULONG cs_utf16_substring(charset* cs, *************************************/ fb_assert(cs != NULL); - return UnicodeUtil::utf16Substring(srcLen, Firebird::Aligner(src, srcLen), - dstLen, Firebird::OutAligner(dst, dstLen), startPos, length); + return UnicodeUtil::utf16Substring(srcLen, Aligner(src, srcLen), + dstLen, OutAligner(dst, dstLen), startPos, length); } @@ -1223,7 +1223,7 @@ static INTL_BOOL cs_utf32_well_formed(charset* cs, *************************************/ fb_assert(cs != NULL); - return UnicodeUtil::utf32WellFormed(len, Firebird::Aligner(str, len), offending_position); + return UnicodeUtil::utf32WellFormed(len, Aligner(str, len), offending_position); } @@ -1247,7 +1247,7 @@ static ULONG cvt_none_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, fb_assert((pSrc != NULL) || (ppDest == NULL)); fb_assert(err_code != NULL); - Firebird::OutAligner d(ppDest, nDest); + OutAligner d(ppDest, nDest); USHORT* pDest = d; *err_code = 0; @@ -1297,9 +1297,9 @@ static ULONG cvt_unicode_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* ppS if (ppDest == NULL) // length estimate needed? return nSrc; - Firebird::Aligner s(ppSrc, nSrc); + Aligner s(ppSrc, nSrc); const USHORT* pSrc = s; - Firebird::OutAligner d(ppDest, nDest); + OutAligner d(ppDest, nDest); USHORT* pDest = d; const USHORT* const pStart = pDest; @@ -1384,8 +1384,8 @@ static ULONG cvt_unicode_to_utf32(csconvert* obj, { fb_assert(obj != NULL); fb_assert(obj->csconvert_fn_convert == cvt_unicode_to_utf32); - return UnicodeUtil::utf16ToUtf32(unicode_len, Firebird::Aligner(unicode_str, unicode_len), - utf32_len, Firebird::OutAligner(utf32_str, utf32_len), err_code, err_position); + return UnicodeUtil::utf16ToUtf32(unicode_len, Aligner(unicode_str, unicode_len), + utf32_len, OutAligner(utf32_str, utf32_len), err_code, err_position); } @@ -1400,8 +1400,8 @@ static ULONG cvt_utf32_to_unicode(csconvert* obj, fb_assert(obj != NULL); fb_assert(obj->csconvert_fn_convert == cvt_utf32_to_unicode); - return UnicodeUtil::utf32ToUtf16(utf32_len, Firebird::Aligner(utf32_str, utf32_len), - unicode_len, Firebird::OutAligner(unicode_str, unicode_len), err_code, err_position); + return UnicodeUtil::utf32ToUtf16(utf32_len, Aligner(utf32_str, utf32_len), + unicode_len, OutAligner(unicode_str, unicode_len), err_code, err_position); } @@ -1702,14 +1702,14 @@ INTL_BOOL INTL_builtin_lookup_texttype_status( if (func) { - Firebird::string errorMsg; + string errorMsg; try { return func(tt, texttype_name, charset_name, attributes, specific_attributes, specific_attributes_length, ignore_attributes, config_info); } - catch (const Firebird::status_exception& ex) + catch (const status_exception& ex) { auto status = ex.value(); TEXT temp[BUFFER_LARGE]; @@ -1740,15 +1740,15 @@ ULONG INTL_builtin_setup_attributes(const ASCII* textTypeName, const ASCII* char // the preprocessor, but this is a task for another day. if (strstr(textTypeName, "UNICODE") && strcmp(textTypeName, "UNICODE_FSS") != 0) { - Firebird::AutoPtr cs(FB_NEW charset); + AutoPtr cs(FB_NEW charset); memset(cs, 0, sizeof(*cs)); // test if that charset exists if (!INTL_builtin_lookup_charset(cs, charSetName, configInfo)) return INTL_BAD_STR_LENGTH; - const Firebird::string specificAttributes((const char*) src, srcLen); - Firebird::string newSpecificAttributes = specificAttributes; + const string specificAttributes((const char*) src, srcLen); + string newSpecificAttributes = specificAttributes; if (IntlUtil::setupIcuAttributes(cs, specificAttributes, configInfo, newSpecificAttributes)) { @@ -1767,3 +1767,6 @@ ULONG INTL_builtin_setup_attributes(const ASCII* textTypeName, const ASCII* char return INTL_BAD_STR_LENGTH; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/intl_classes.h b/src/jrd/intl_classes.h index 022cae16a5e..20b2ffac0f0 100644 --- a/src/jrd/intl_classes.h +++ b/src/jrd/intl_classes.h @@ -31,18 +31,18 @@ #include "firebird.h" #include "../common/intlobj_new.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/unicode_util.h" #include "../common/CsConvert.h" #include "../common/CharSet.h" #include "../common/TextType.h" -namespace Jrd { +namespace Firebird::Jrd { class PatternMatcher { public: - PatternMatcher(MemoryPool& aPool, Firebird::TextType* aTextType) noexcept + PatternMatcher(MemoryPool& aPool, TextType* aTextType) noexcept : pool(aPool), textType(aTextType) { @@ -58,13 +58,13 @@ class PatternMatcher protected: MemoryPool& pool; - Firebird::TextType* textType; + TextType* textType; }; class BaseSubstringSimilarMatcher : public PatternMatcher { public: - BaseSubstringSimilarMatcher(MemoryPool& pool, Firebird::TextType* ttype) noexcept + BaseSubstringSimilarMatcher(MemoryPool& pool, TextType* ttype) noexcept : PatternMatcher(pool, ttype) { } @@ -75,7 +75,7 @@ class BaseSubstringSimilarMatcher : public PatternMatcher class NullStrConverter { public: - NullStrConverter(MemoryPool& /*pool*/, const Firebird::TextType* /*obj*/, const UCHAR* /*str*/, SLONG /*len*/) noexcept + NullStrConverter(MemoryPool& /*pool*/, const TextType* /*obj*/, const UCHAR* /*str*/, SLONG /*len*/) noexcept { } }; @@ -84,7 +84,7 @@ template class UpcaseConverter : public PrevConverter { public: - UpcaseConverter(MemoryPool& pool, Firebird::TextType* obj, const UCHAR*& str, SLONG& len) + UpcaseConverter(MemoryPool& pool, TextType* obj, const UCHAR*& str, SLONG& len) : PrevConverter(pool, obj, str, len) { const auto* charSet = obj->getCharSet(); @@ -95,14 +95,14 @@ class UpcaseConverter : public PrevConverter } private: - Firebird::UCharBuffer tempBuffer; + UCharBuffer tempBuffer; }; template class CanonicalConverter : public PrevConverter { public: - CanonicalConverter(MemoryPool& pool, Firebird::TextType* obj, const UCHAR*& str, SLONG& len) + CanonicalConverter(MemoryPool& pool, TextType* obj, const UCHAR*& str, SLONG& len) : PrevConverter(pool, obj, str, len) { const SLONG out_len = len / obj->getCharSet()->minBytesPerChar() * obj->getCanonicalWidth(); @@ -117,10 +117,10 @@ class CanonicalConverter : public PrevConverter } private: - Firebird::UCharBuffer tempBuffer; + UCharBuffer tempBuffer; }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_INTL_CLASSES_H diff --git a/src/jrd/intl_proto.h b/src/jrd/intl_proto.h index 31c5f927d9d..fc5a2d5d909 100644 --- a/src/jrd/intl_proto.h +++ b/src/jrd/intl_proto.h @@ -27,49 +27,44 @@ #include "../jrd/intl_classes.h" #include "../common/cvt.h" -namespace Jrd { +struct dsc; +struct texttype; + +namespace Firebird::Jrd +{ class thread_db; class Lock; class Collation; struct SubtypeInfo; -} - -namespace Firebird { - class CsConvert; - class CharSet; -} -struct dsc; -struct texttype; + void INTL_adjust_text_descriptor(thread_db* tdbb, dsc* desc); + CSetId INTL_charset(thread_db*, TTypeId); + int INTL_compare(thread_db*, const dsc*, const dsc*, ErrorFunction); + ULONG INTL_convert_bytes(thread_db*, CSetId, UCHAR*, const ULONG, CSetId, + const BYTE*, const ULONG, ErrorFunction); + CsConvert INTL_convert_lookup(thread_db*, CSetId, CSetId); + void INTL_convert_string(dsc*, const dsc*, Callbacks* cb); + bool INTL_data(const dsc*); + bool INTL_data_or_binary(const dsc*); + bool INTL_defined_type(thread_db*, TTypeId); + USHORT INTL_key_length(thread_db*, USHORT, USHORT); + CharSet* INTL_charset_lookup(thread_db* tdbb, CSetId parm1); + Collation* INTL_texttype_lookup(thread_db* tdbb, TTypeId parm1); + bool INTL_texttype_validate(thread_db*, const SubtypeInfo*); + void INTL_pad_spaces(thread_db*, dsc*, UCHAR*, ULONG); + USHORT INTL_string_to_key(thread_db*, USHORT, const dsc*, dsc*, USHORT); + void INTL_lookup_texttype(texttype* tt, const SubtypeInfo* info); -void INTL_adjust_text_descriptor(Jrd::thread_db* tdbb, dsc* desc); -CSetId INTL_charset(Jrd::thread_db*, TTypeId); -int INTL_compare(Jrd::thread_db*, const dsc*, const dsc*, ErrorFunction); -ULONG INTL_convert_bytes(Jrd::thread_db*, CSetId, UCHAR*, const ULONG, CSetId, - const BYTE*, const ULONG, ErrorFunction); -Firebird::CsConvert INTL_convert_lookup(Jrd::thread_db*, CSetId, CSetId); -void INTL_convert_string(dsc*, const dsc*, Firebird::Callbacks* cb); -bool INTL_data(const dsc*); -bool INTL_data_or_binary(const dsc*); -bool INTL_defined_type(Jrd::thread_db*, TTypeId); -USHORT INTL_key_length(Jrd::thread_db*, USHORT, USHORT); -Firebird::CharSet* INTL_charset_lookup(Jrd::thread_db* tdbb, CSetId parm1); -Jrd::Collation* INTL_texttype_lookup(Jrd::thread_db* tdbb, TTypeId parm1); -bool INTL_texttype_validate(Jrd::thread_db*, const Jrd::SubtypeInfo*); -void INTL_pad_spaces(Jrd::thread_db*, dsc*, UCHAR*, ULONG); -USHORT INTL_string_to_key(Jrd::thread_db*, USHORT, const dsc*, dsc*, USHORT); -void INTL_lookup_texttype(texttype* tt, const Jrd::SubtypeInfo* info); - -// Built-in charsets/texttypes interface -INTL_BOOL INTL_builtin_lookup_charset(charset* cs, const ASCII* charset_name, const ASCII* config_info); -INTL_BOOL INTL_builtin_lookup_texttype_status( - char* status_buffer, ULONG status_buffer_length, - texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, - USHORT attributes, const UCHAR* specific_attributes, - ULONG specific_attributes_length, INTL_BOOL ignore_attributes, - const ASCII* config_info); -ULONG INTL_builtin_setup_attributes(const ASCII* textTypeName, const ASCII* charSetName, - const ASCII* configInfo, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst); + // Built-in charsets/texttypes interface + INTL_BOOL INTL_builtin_lookup_charset(charset* cs, const ASCII* charset_name, const ASCII* config_info); + INTL_BOOL INTL_builtin_lookup_texttype_status( + char* status_buffer, ULONG status_buffer_length, + texttype* tt, const ASCII* texttype_name, const ASCII* charset_name, + USHORT attributes, const UCHAR* specific_attributes, + ULONG specific_attributes_length, INTL_BOOL ignore_attributes, + const ASCII* config_info); + ULONG INTL_builtin_setup_attributes(const ASCII* textTypeName, const ASCII* charSetName, + const ASCII* configInfo, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst); +} // namespace Firebird::Jrd #endif // JRD_INTL_PROTO_H - diff --git a/src/jrd/irq.h b/src/jrd/irq.h index a1611c9e07a..83bab5b161b 100644 --- a/src/jrd/irq.h +++ b/src/jrd/irq.h @@ -27,6 +27,10 @@ #ifndef JRD_IRQ_H #define JRD_IRQ_H +namespace Firebird::Jrd +{ + + enum irq_type_t { irq_s_pages, // store PAGES @@ -182,4 +186,7 @@ enum irq_type_t irq_MAX }; + +} // namespace Firebird::Jrd + #endif // JRD_IRQ_H diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index f3cb774e90b..67dd36dd462 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -143,13 +143,19 @@ #ifdef WIN_NT #include +#include #define getpid _getpid +// these should stop a most annoying warning +#undef TEXT +#define TEXT SCHAR + #include "../common/dllinst.h" #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + constexpr SSHORT WAIT_PERIOD = -1; @@ -158,9 +164,6 @@ constexpr SSHORT WAIT_PERIOD = -1; #endif -namespace Jrd -{ - int JBlob::release() { int rc = --refCounter; @@ -344,12 +347,12 @@ JRequest::JRequest(Statement* handle, StableAttachmentPart* sa) { } -JEvents::JEvents(int aId, StableAttachmentPart* sa, Firebird::IEventCallback* aCallback) +JEvents::JEvents(int aId, StableAttachmentPart* sa, IEventCallback* aCallback) : id(aId), sAtt(sa), callback(aCallback) { } -JStatement::JStatement(DsqlRequest* handle, StableAttachmentPart* sa, Firebird::Array& meta) +JStatement::JStatement(DsqlRequest* handle, StableAttachmentPart* sa, Array& meta) : statement(handle), sAtt(sa), metadata(getPool(), this, sAtt) { metadata.parse(meta.getCount(), meta.begin()); @@ -466,7 +469,7 @@ class EngineFactory final : public AutoIfaceaddRef(); return p; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -490,14 +493,6 @@ void registerEngine(IPluginManager* iPlugin) module->registerMe(); } -} // namespace Jrd - -extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) -{ - CachedMasterInterface::set(master); - registerEngine(PluginManagerInterfacePtr()); -} - namespace { using Jrd::Attachment; @@ -738,7 +733,7 @@ namespace validateHandle(tdbb, batch->getAttachment()); } - inline void validateHandle(thread_db* tdbb, const Applier* const applier) + inline void validateHandle(thread_db* tdbb, const Replication::Applier* const applier) { if (!applier) status_exception::raise(Arg::Gds(isc_bad_repl_handle)); @@ -806,12 +801,12 @@ namespace return 0; } - int getHashLength(Firebird::CheckStatusWrapper* status) override + int getHashLength(CheckStatusWrapper* status) override { return 0; } - void getHashData(Firebird::CheckStatusWrapper* status, void* h) override + void getHashData(CheckStatusWrapper* status, void* h) override { fb_assert(false); } @@ -869,14 +864,14 @@ AttachmentHolder::AttachmentHolder(thread_db* tdbb, StableAttachmentPart* sa, un attachment->setupIdleTimer(true); } } - catch (const Firebird::Exception&) + catch (const Exception&) { if (!nolock) sAtt->getSync(async)->leave(); throw; } } - catch (const Firebird::Exception&) + catch (const Exception&) { if (blocking) sAtt->getBlockingMutex()->leave(); @@ -921,14 +916,6 @@ template EngineContextHolder::EngineContextHolder( CheckStatusWrapper* status, JAttachment* interfacePtr, const char* from, unsigned lockFlags); -#ifdef WIN_NT -#include -// these should stop a most annoying warning -#undef TEXT -#define TEXT SCHAR -#endif // WIN_NT - - namespace { class DatabaseBindings final : public CoercionArray @@ -986,8 +973,6 @@ namespace } -namespace Jrd -{ // Option block for database parameter block class DatabaseOptions @@ -1069,8 +1054,8 @@ namespace Jrd string dpb_decfloat_round; string dpb_decfloat_traps; string dpb_owner; - Firebird::ObjectsArray dpb_schema_search_path; - Firebird::ObjectsArray dpb_blr_request_schema_search_path; + ObjectsArray dpb_schema_search_path; + ObjectsArray dpb_blr_request_schema_search_path; public: static constexpr ULONG DPB_FLAGS_MASK = DBB_damaged; @@ -1258,7 +1243,7 @@ namespace Jrd attachment->att_schema_search_path = schemaSearchPath; attachment->att_blr_request_schema_search_path = blrRequestSchemaSearchPath; } -} // namespace Jrd + /// trace manager support @@ -1416,7 +1401,7 @@ static ISC_STATUS transliterateException(thread_db* tdbb, const Exception& ex, F // Transliterate status vector to the client charset. -void JRD_transliterate(thread_db* tdbb, Firebird::IStatus* vector) noexcept +void JRD_transliterate(thread_db* tdbb, IStatus* vector) noexcept { const Jrd::Attachment* attachment = tdbb->getAttachment(); CSetId charSet; @@ -1557,8 +1542,6 @@ static void trace_failed_attach(const char* filename, const DatabaseOptions& opt } -namespace Jrd { - JTransaction* JAttachment::getTransactionInterface(CheckStatusWrapper* status, ITransaction* tra) { if (!tra) @@ -2206,7 +2189,7 @@ JAttachment* JProvider::internalAttach(CheckStatusWrapper* user_status, const ch CCH_release_exclusive(tdbb); - REPL_attach(tdbb, cleanupTransactions); + Replication::REPL_attach(tdbb, cleanupTransactions); attachment->att_trace_manager->activate(); if (attachment->att_trace_manager->needs(ITraceFactory::TRACE_EVENT_ATTACH)) @@ -2808,7 +2791,7 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch DatabaseOptions options; PathName org_filename, expanded_name; bool is_alias = false; - Firebird::RefPtr config; + RefPtr config; Mapping mapping(Mapping::MAP_THROW_NOT_FOUND, cryptCallback); LateRefGuard lateBlocking(FB_FUNCTION); @@ -3044,7 +3027,7 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch { allow_overwrite = attachment2->getHandle()->locksmith(tdbb, DROP_DATABASE); if (allow_overwrite) - REPL_journal_cleanup(attachment2->getHandle()->att_database); + Replication::REPL_journal_cleanup(attachment2->getHandle()->att_database); attachment2->detach(user_status); } else @@ -3222,7 +3205,7 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch dbb->dbb_flags &= ~(DBB_new | DBB_creating); guardDbInit.leave(); - REPL_attach(tdbb, false); + Replication::REPL_attach(tdbb, false); // Report that we created attachment to Trace API attachment->att_trace_manager->activate(); @@ -3540,7 +3523,7 @@ void JAttachment::internalDropDatabase(CheckStatusWrapper* user_status) } // Unlink active replication segments - REPL_journal_cleanup(dbb); + Replication::REPL_journal_cleanup(dbb); // Unlink attachment from database release_attachment(tdbb, attachment, &threadGuard); @@ -4819,7 +4802,7 @@ void JAttachment::transactRequest(CheckStatusWrapper* user_status, ITransaction* try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); CompilerScratch* csb = PAR_parse(tdbb, blr, blr_length, false); @@ -4917,7 +4900,7 @@ void JAttachment::transactRequest(CheckStatusWrapper* user_status, ITransaction* successful_completion(user_status); } -unsigned int JAttachment::getIdleTimeout(Firebird::CheckStatusWrapper* user_status) +unsigned int JAttachment::getIdleTimeout(CheckStatusWrapper* user_status) { unsigned int result = 0; try @@ -4937,7 +4920,7 @@ unsigned int JAttachment::getIdleTimeout(Firebird::CheckStatusWrapper* user_stat return result; } -void JAttachment::setIdleTimeout(Firebird::CheckStatusWrapper* user_status, unsigned int timeOut) +void JAttachment::setIdleTimeout(CheckStatusWrapper* user_status, unsigned int timeOut) { try { @@ -4955,7 +4938,7 @@ void JAttachment::setIdleTimeout(Firebird::CheckStatusWrapper* user_status, unsi successful_completion(user_status); } -unsigned int JAttachment::getStatementTimeout(Firebird::CheckStatusWrapper* user_status) +unsigned int JAttachment::getStatementTimeout(CheckStatusWrapper* user_status) { unsigned int result = 0; try @@ -4975,7 +4958,7 @@ unsigned int JAttachment::getStatementTimeout(Firebird::CheckStatusWrapper* user return result; } -void JAttachment::setStatementTimeout(Firebird::CheckStatusWrapper* user_status, unsigned int timeOut) +void JAttachment::setStatementTimeout(CheckStatusWrapper* user_status, unsigned int timeOut) { try { @@ -5330,7 +5313,7 @@ IReplicator* JAttachment::createReplicator(CheckStatusWrapper* user_status) try { - const auto applier = Applier::create(tdbb); + const auto applier = Replication::Applier::create(tdbb); jr = FB_NEW JReplicator(applier, getStable()); jr->addRef(); @@ -5996,7 +5979,7 @@ void JStatement::setCursorName(CheckStatusWrapper* user_status, const char* curs } -void JResultSet::setDelayedOutputFormat(CheckStatusWrapper* user_status, Firebird::IMessageMetadata* outMetadata) +void JResultSet::setDelayedOutputFormat(CheckStatusWrapper* user_status, IMessageMetadata* outMetadata) { try { @@ -6115,7 +6098,7 @@ void JStatement::setTimeout(CheckStatusWrapper* user_status, unsigned int timeOu } -JBatch* JStatement::createBatch(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* inMetadata, +JBatch* JStatement::createBatch(CheckStatusWrapper* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) { JBatch* batch = NULL; @@ -6219,7 +6202,7 @@ void JBatch::close(CheckStatusWrapper* user_status) } -void JBatch::freeEngineData(Firebird::CheckStatusWrapper* user_status) +void JBatch::freeEngineData(CheckStatusWrapper* user_status) { try { @@ -6574,9 +6557,7 @@ void JBatch::getInfo(CheckStatusWrapper* user_status, } - - -JReplicator::JReplicator(Applier* appl, StableAttachmentPart* sa) +JReplicator::JReplicator(Replication::Applier* appl, StableAttachmentPart* sa) : applier(appl), sAtt(sa) { } @@ -6600,7 +6581,7 @@ int JReplicator::release() } -void JReplicator::freeEngineData(Firebird::CheckStatusWrapper* user_status) +void JReplicator::freeEngineData(CheckStatusWrapper* user_status) { try { @@ -6697,7 +6678,6 @@ void JAttachment::ping(CheckStatusWrapper* user_status) successful_completion(user_status); } -} // namespace Jrd #ifdef DEBUG_PROCS void JRD_print_procedure_info(thread_db* tdbb, const char* mesg) @@ -6715,7 +6695,7 @@ void JRD_print_procedure_info(thread_db* tdbb, const char* mesg) ******************************************************/ TEXT fname[MAXPATHLEN]; - Firebird::string fname = fb_utils::getPrefix(IConfigManager::DIR_LOG, "proc_info.log"); + string fname = fb_utils::getPrefix(IConfigManager::DIR_LOG, "proc_info.log"); FILE* fptr = os_utils::fopen(fname.c_str(), "a+"); if (!fptr) { @@ -7608,7 +7588,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam } // end scope // provide context pool for the rest stuff - Jrd::ContextPoolHolder context(tdbb, dbb->dbb_permanent); + JrdContextPoolHolder context(tdbb, dbb->dbb_permanent); // set a garbage collection policy @@ -9200,7 +9180,7 @@ bool TimeoutTimer::getExpireTimestamp(const ISC_TIMESTAMP_TZ start, ISC_TIMESTAM void TimeoutTimer::start() { FbLocalStatus s; - ITimerControl* timerCtrl = Firebird::TimerInterfacePtr(); + ITimerControl* timerCtrl = TimerInterfacePtr(); m_expired = false; @@ -9229,7 +9209,7 @@ void TimeoutTimer::stop() m_started = 0; FbLocalStatus s; - ITimerControl* timerCtrl = Firebird::TimerInterfacePtr(); + ITimerControl* timerCtrl = TimerInterfacePtr(); timerCtrl->stop(&s, this); } } @@ -9957,3 +9937,14 @@ void JRD_cancel_operation(thread_db* /*tdbb*/, Jrd::Attachment* attachment, int } } + +} // namespace Firebird::Jrd + + +using namespace Firebird; + +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) +{ + CachedMasterInterface::set(master); + Jrd::registerEngine(PluginManagerInterfacePtr()); +} diff --git a/src/jrd/jrd.h b/src/jrd/jrd.h index 220634bdcd4..6bab99b73cc 100644 --- a/src/jrd/jrd.h +++ b/src/jrd/jrd.h @@ -36,7 +36,7 @@ #include "../common/dsc.h" #include "../jrd/err_proto.h" #include "../jrd/jrd_proto.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/val.h" #include "../jrd/vec.h" #include "../jrd/status.h" @@ -99,7 +99,7 @@ struct dsc; -namespace EDS { +namespace Firebird::Jrd::EDS { class Connection; } @@ -107,7 +107,7 @@ namespace Firebird { class TextType; } -namespace Jrd { +namespace Firebird::Jrd { inline constexpr unsigned MAX_CALLBACKS = 50; @@ -120,7 +120,6 @@ class Statement; class jrd_file; class Format; class BufferDesc; -class SparseBitmap; class jrd_rel; class ExternalFile; class ViewContext; @@ -247,14 +246,14 @@ class ThreadStatusGuard } private: - Firebird::FbLocalStatus m_local_status; + FbLocalStatus m_local_status; thread_db* const m_tdbb; FbStatusVector* const m_old_status; }; // duplicate context of firebird string -inline char* stringDup(MemoryPool& p, const Firebird::string& s) +inline char* stringDup(MemoryPool& p, const string& s) { char* rc = (char*) p.allocate(s.length() + 1); strcpy(rc, s.c_str()); @@ -279,11 +278,9 @@ inline char* stringDup(MemoryPool& p, const char* s) } // Used in string conversion calls -typedef Firebird::HalfStaticArray MoveBuffer; +typedef HalfStaticArray MoveBuffer; -} //namespace Jrd - -inline bool JRD_reschedule(Jrd::thread_db* tdbb, bool force = false) +inline bool JRD_reschedule(thread_db* tdbb, bool force = false) { if (force || --tdbb->tdbb_quantum < 0) { @@ -294,7 +291,7 @@ inline bool JRD_reschedule(Jrd::thread_db* tdbb, bool force = false) return false; } -inline Jrd::Database* GET_DBB() +inline Database* GET_DBB() { return JRD_get_thread_data()->getDatabase(); } @@ -302,7 +299,7 @@ inline Jrd::Database* GET_DBB() /*-------------------------------------------------------------------------* * macros used to set thread_db and Database pointers when there are not set already * *-------------------------------------------------------------------------*/ -inline void SET_TDBB(Jrd::thread_db*& tdbb) +inline void SET_TDBB(thread_db*& tdbb) { if (tdbb == NULL) { tdbb = JRD_get_thread_data(); @@ -310,7 +307,7 @@ inline void SET_TDBB(Jrd::thread_db*& tdbb) CHECK_TDBB(tdbb); } -inline void SET_DBB(Jrd::Database*& dbb) +inline void SET_DBB(Database*& dbb) { if (dbb == NULL) { dbb = GET_DBB(); @@ -319,16 +316,15 @@ inline void SET_DBB(Jrd::Database*& dbb) } -// global variables for engine + // global variables for engine -namespace Jrd { - typedef Firebird::SubsystemContextPoolHolder ContextPoolHolder; + typedef SubsystemContextPoolHolder JrdContextPoolHolder; - class DatabaseContextHolder : public Jrd::ContextPoolHolder + class DatabaseContextHolder : public JrdContextPoolHolder { public: explicit DatabaseContextHolder(thread_db* tdbb) - : Jrd::ContextPoolHolder(tdbb, tdbb->getDatabase()->dbb_permanent) + : JrdContextPoolHolder(tdbb, tdbb->getDatabase()->dbb_permanent) {} // copying is prohibited @@ -337,13 +333,13 @@ namespace Jrd { }; class BackgroundContextHolder : public ThreadContextHolder, public DatabaseContextHolder, - public Jrd::Attachment::SyncGuard + public Attachment::SyncGuard { public: - BackgroundContextHolder(Database* dbb, Jrd::Attachment* att, FbStatusVector* status, const char* f) + BackgroundContextHolder(Database* dbb, Attachment* att, FbStatusVector* status, const char* f) : ThreadContextHolder(dbb, att, status), DatabaseContextHolder(operator thread_db*()), - Jrd::Attachment::SyncGuard(att, f) + Attachment::SyncGuard(att, f) {} // copying is prohibited @@ -367,7 +363,7 @@ namespace Jrd { AttachmentHolder& operator =(const AttachmentHolder&) = delete; private: - Firebird::RefPtr sAtt; + RefPtr sAtt; bool async; // async mutex should be locked instead normal bool nolock; // if locked manually, no need to take lock recursively bool blocking; // holder instance is blocking other instances @@ -377,32 +373,32 @@ namespace Jrd { { public: template - EngineContextHolder(Firebird::CheckStatusWrapper* status, I* interfacePtr, const char* from, + EngineContextHolder(CheckStatusWrapper* status, I* interfacePtr, const char* from, unsigned lockFlags = 0); }; - class AstLockHolder : public Firebird::ReadLockGuard + class AstLockHolder : public ReadLockGuard { public: AstLockHolder(Database* dbb, const char* f) - : Firebird::ReadLockGuard(dbb->dbb_ast_lock, f) + : ReadLockGuard(dbb->dbb_ast_lock, f) { if (dbb->dbb_flags & DBB_no_ast) { // usually to be swallowed by the AST, but it allows to skip its execution - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_unavailable)); + status_exception::raise(Arg::Gds(isc_unavailable)); } } }; - class AsyncContextHolder : public AstLockHolder, public Jrd::Attachment::SyncGuard, + class AsyncContextHolder : public AstLockHolder, public Attachment::SyncGuard, public ThreadContextHolder, public DatabaseContextHolder { public: AsyncContextHolder(Database* dbb, const char* f, Lock* lck = NULL) : AstLockHolder(dbb, f), - Jrd::Attachment::SyncGuard(lck ? - lck->getLockStable() : Firebird::RefPtr(), f, true), + Attachment::SyncGuard(lck ? + lck->getLockStable() : RefPtr(), f, true), ThreadContextHolder(dbb, lck ? lck->getLockAttachment() : NULL), DatabaseContextHolder(operator thread_db*()) { @@ -414,7 +410,7 @@ namespace Jrd { if (!lck->lck_id) { // usually to be swallowed by the AST, but it allows to skip its execution - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_unavailable)); + status_exception::raise(Arg::Gds(isc_unavailable)); } fb_assert((operator thread_db*())->getAttachment()); @@ -488,14 +484,14 @@ namespace Jrd { private: thread_db* const m_tdbb; - Firebird::RefPtr m_ref; + RefPtr m_ref; const char* m_from; }; class CheckoutLockGuard { public: - CheckoutLockGuard(thread_db* tdbb, Firebird::Mutex& mutex, + CheckoutLockGuard(thread_db* tdbb, Mutex& mutex, const char* from, bool optional = false) : m_mutex(mutex) { @@ -516,14 +512,14 @@ namespace Jrd { CheckoutLockGuard& operator=(const CheckoutLockGuard&) = delete; private: - Firebird::Mutex& m_mutex; + Mutex& m_mutex; }; class CheckoutSyncGuard { public: - CheckoutSyncGuard(thread_db* tdbb, Firebird::SyncObject& sync, - Firebird::SyncType type, + CheckoutSyncGuard(thread_db* tdbb, SyncObject& sync, + SyncType type, const char* from, bool optional = false) : m_sync(&sync, from) { @@ -539,9 +535,10 @@ namespace Jrd { CheckoutSyncGuard& operator=(const CheckoutSyncGuard&) = delete; private: - Firebird::Sync m_sync; + Sync m_sync; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_JRD_H diff --git a/src/jrd/jrd_proto.h b/src/jrd/jrd_proto.h index 2a764f2aaa1..991041565e4 100644 --- a/src/jrd/jrd_proto.h +++ b/src/jrd/jrd_proto.h @@ -29,7 +29,8 @@ #include "../common/classes/objects_array.h" #include "../jrd/status.h" -namespace Jrd { +namespace Firebird::Jrd +{ class Database; class Attachment; class jrd_tra; @@ -42,45 +43,43 @@ namespace Jrd { struct teb; class DsqlRequest; class MetaName; -} -void jrd_vtof(const char*, char*, SSHORT); + void jrd_vtof(const char*, char*, SSHORT); -typedef Firebird::SortedObjectsArray PathNameList; -void JRD_enum_attachments(PathNameList*, ULONG&, ULONG&, ULONG&); + typedef SortedObjectsArray PathNameList; + void JRD_enum_attachments(PathNameList*, ULONG&, ULONG&, ULONG&); #ifdef DEBUG_PROCS -void JRD_print_procedure_info(Jrd::thread_db*, const char*); + void JRD_print_procedure_info(thread_db*, const char*); #endif + void JRD_autocommit_ddl(thread_db* tdbb, jrd_tra* transaction); + void JRD_receive(thread_db* tdbb, Request* request, USHORT msg_type, ULONG msg_length, void* msg); + void JRD_start(thread_db* tdbb, Request* request, jrd_tra* transaction); -void JRD_autocommit_ddl(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_receive(Jrd::thread_db* tdbb, Jrd::Request* request, USHORT msg_type, ULONG msg_length, - void* msg); -void JRD_start(Jrd::thread_db* tdbb, Jrd::Request* request, Jrd::jrd_tra* transaction); + void JRD_commit_transaction(thread_db* tdbb, jrd_tra* transaction); + void JRD_commit_retaining(thread_db* tdbb, jrd_tra* transaction); + void JRD_rollback_transaction(thread_db* tdbb, jrd_tra* transaction); + void JRD_rollback_retaining(thread_db* tdbb, jrd_tra* transaction); + void JRD_run_trans_start_triggers(thread_db* tdbb, jrd_tra* transaction); + void JRD_send(thread_db* tdbb, Request* request, USHORT msg_type, ULONG msg_length, + const void* msg); + void JRD_start_and_send(thread_db* tdbb, Request* request, jrd_tra* transaction, + USHORT msg_type, ULONG msg_length, const void* msg); + void JRD_start_transaction(thread_db* tdbb, jrd_tra** transaction, + Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb); + void JRD_unwind_request(thread_db* tdbb, Request* request); + bool JRD_verify_database_access(const PathName&); + void JRD_shutdown_attachment(Attachment* attachment); + void JRD_shutdown_attachments(Database* dbb); + void JRD_cancel_operation(thread_db* tdbb, Attachment* attachment, int option); + void JRD_transliterate(thread_db* tdbb, IStatus* vector) noexcept; -void JRD_commit_transaction(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_commit_retaining(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_rollback_transaction(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_rollback_retaining(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_run_trans_start_triggers(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void JRD_send(Jrd::thread_db* tdbb, Jrd::Request* request, USHORT msg_type, ULONG msg_length, - const void* msg); -void JRD_start_and_send(Jrd::thread_db* tdbb, Jrd::Request* request, Jrd::jrd_tra* transaction, - USHORT msg_type, ULONG msg_length, const void* msg); -void JRD_start_transaction(Jrd::thread_db* tdbb, Jrd::jrd_tra** transaction, - Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb); -void JRD_unwind_request(Jrd::thread_db* tdbb, Jrd::Request* request); -bool JRD_verify_database_access(const Firebird::PathName&); -void JRD_shutdown_attachment(Jrd::Attachment* attachment); -void JRD_shutdown_attachments(Jrd::Database* dbb); -void JRD_cancel_operation(Jrd::thread_db* tdbb, Jrd::Attachment* attachment, int option); -void JRD_transliterate(Jrd::thread_db* tdbb, Firebird::IStatus* vector) noexcept; - -bool JRD_shutdown_database(Jrd::Database* dbb, const unsigned flags = 0); -// JRD_shutdown_database() flags -static constexpr unsigned SHUT_DBB_RELEASE_POOLS = 0x01; -static constexpr unsigned SHUT_DBB_LINGER = 0x02; -static constexpr unsigned SHUT_DBB_OVERWRITE_CHECK = 0x04; + bool JRD_shutdown_database(Database* dbb, const unsigned flags = 0); + // JRD_shutdown_database() flags + static constexpr unsigned SHUT_DBB_RELEASE_POOLS = 0x01; + static constexpr unsigned SHUT_DBB_LINGER = 0x02; + static constexpr unsigned SHUT_DBB_OVERWRITE_CHECK = 0x04; +} // namespace Firebird::Jrd #endif /* JRD_JRD_PROTO_H */ diff --git a/src/jrd/lck.cpp b/src/jrd/lck.cpp index a1868ed441e..f8057ed1ef9 100644 --- a/src/jrd/lck.cpp +++ b/src/jrd/lck.cpp @@ -54,8 +54,9 @@ #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + static void bug_lck(const TEXT*); static bool compatible(const Lock*, const Lock*, USHORT); @@ -1606,3 +1607,5 @@ Lock* Lock::detach() return next; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/lck.h b/src/jrd/lck.h index ce927051978..83775501b05 100644 --- a/src/jrd/lck.h +++ b/src/jrd/lck.h @@ -35,7 +35,9 @@ #include "../jrd/Attachment.h" #include "../common/classes/auto.h" -namespace Jrd { +namespace Firebird::Jrd +{ + class Database; class thread_db; @@ -111,7 +113,7 @@ class Lock : public pool_alloc_rpt Lock* detach(); - Firebird::RefPtr getLockStable() + RefPtr getLockStable() { return lck_attachment; } @@ -121,13 +123,13 @@ class Lock : public pool_alloc_rpt void setLockAttachment(Attachment* att); #ifdef DEBUG_LCK - Firebird::SyncObject lck_sync; + SyncObject lck_sync; #endif Database* lck_dbb; // Database object is contained in private: - Firebird::RefPtr lck_attachment; // Attachment that owns lock, set only using set_lock_attachment() + RefPtr lck_attachment; // Attachment that owns lock, set only using set_lock_attachment() public: void* lck_compatible; // Enter into internal_enqueue() and treat as compatible @@ -191,26 +193,23 @@ class Lock : public pool_alloc_rpt } }; -} // namespace Jrd -void LCK_assert(Jrd::thread_db*, Jrd::Lock*); -bool LCK_cancel_wait(Jrd::Attachment*); -bool LCK_convert(Jrd::thread_db*, Jrd::Lock*, USHORT, SSHORT); -bool LCK_convert_opt(Jrd::thread_db*, Jrd::Lock*, USHORT); -void LCK_downgrade(Jrd::thread_db*, Jrd::Lock*); -void LCK_fini(Jrd::thread_db*, Jrd::lck_owner_t); -void LCK_init(Jrd::thread_db*, Jrd::lck_owner_t); -bool LCK_lock(Jrd::thread_db*, Jrd::Lock*, USHORT, SSHORT); -bool LCK_lock_opt(Jrd::thread_db*, Jrd::Lock*, USHORT, SSHORT); -LOCK_DATA_T LCK_query_data(Jrd::thread_db*, Jrd::lck_t, USHORT); -LOCK_DATA_T LCK_read_data(Jrd::thread_db*, Jrd::Lock*); -void LCK_release(Jrd::thread_db*, Jrd::Lock*); -void LCK_re_post(Jrd::thread_db*, Jrd::Lock*); -void LCK_write_data(Jrd::thread_db*, Jrd::Lock*, LOCK_DATA_T); +void LCK_assert(thread_db*, Lock*); +bool LCK_cancel_wait(Attachment*); +bool LCK_convert(thread_db*, Lock*, USHORT, SSHORT); +bool LCK_convert_opt(thread_db*, Lock*, USHORT); +void LCK_downgrade(thread_db*, Lock*); +void LCK_fini(thread_db*, lck_owner_t); +void LCK_init(thread_db*, lck_owner_t); +bool LCK_lock(thread_db*, Lock*, USHORT, SSHORT); +bool LCK_lock_opt(thread_db*, Lock*, USHORT, SSHORT); +LOCK_DATA_T LCK_query_data(thread_db*, lck_t, USHORT); +LOCK_DATA_T LCK_read_data(thread_db*, Lock*); +void LCK_release(thread_db*, Lock*); +void LCK_re_post(thread_db*, Lock*); +void LCK_write_data(thread_db*, Lock*, LOCK_DATA_T); -namespace Jrd { - class AutoLock { public: @@ -258,6 +257,7 @@ class AutoLock Lock* m_lock; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_LCK_H diff --git a/src/jrd/lls.h b/src/jrd/lls.h index d741293df7c..0e0a12daf0a 100644 --- a/src/jrd/lls.h +++ b/src/jrd/lls.h @@ -25,19 +25,19 @@ #include "../common/classes/stack.h" -namespace Jrd { +namespace Firebird::Jrd { class Record; class BoolExprNode; class ValueExprNode; class RecordSourceNode; class StmtNode; - typedef Firebird::Stack RecordStack; - typedef Firebird::Stack BoolExprNodeStack; - typedef Firebird::Stack ValueExprNodeStack; - typedef Firebird::Stack RecordSourceNodeStack; - typedef Firebird::Stack StmtNodeStack; - typedef Firebird::Stack UCharStack; + typedef Stack RecordStack; + typedef Stack BoolExprNodeStack; + typedef Stack ValueExprNodeStack; + typedef Stack RecordSourceNodeStack; + typedef Stack StmtNodeStack; + typedef Stack UCharStack; } #endif // JRD_LLS_H diff --git a/src/jrd/met.epp b/src/jrd/met.epp index f68e9cfc824..8b392a02d1d 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -107,10 +107,11 @@ // Pick up relation ids #include "../jrd/ini.h" -DATABASE DB = FILENAME "ODS.RDB"; +namespace Firebird::Jrd +{ -using namespace Jrd; -using namespace Firebird; + +DATABASE DB = FILENAME "ODS.RDB"; static ULONG get_rel_flags_from_FLAGS(USHORT); static void get_trigger(thread_db*, jrd_rel*, bid*, bid*, Triggers&, const QualifiedName&, FB_UINT64, @@ -163,7 +164,7 @@ void MET_get_domain(thread_db* tdbb, MemoryPool& csbPool, const QualifiedName& n { fieldInfo->nullable = FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0; - Jrd::ContextPoolHolder context(tdbb, &csbPool); + JrdContextPoolHolder context(tdbb, &csbPool); if (FLD.RDB$DEFAULT_VALUE.NULL) fieldInfo->defaultValue = NULL; @@ -272,7 +273,7 @@ void MET_get_relation_field(thread_db* tdbb, MemoryPool& csbPool, const Qualifie fieldInfo->nullable = RFL.RDB$NULL_FLAG.NULL ? (FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0) : RFL.RDB$NULL_FLAG == 0; - Jrd::ContextPoolHolder context(tdbb, &csbPool); + JrdContextPoolHolder context(tdbb, &csbPool); bid* defaultId = NULL; if (!RFL.RDB$DEFAULT_VALUE.NULL) @@ -2630,7 +2631,7 @@ ScanResult jrd_prc::scan(thread_db* tdbb, ObjectBase::Flag flags) { setDefaultCount(getDefaultCount() + 1); MemoryPool* pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, pool); + JrdContextPoolHolder context(tdbb, pool); try { @@ -2684,7 +2685,7 @@ ScanResult jrd_prc::scan(thread_db* tdbb, ObjectBase::Flag flags) if (external || !P.RDB$PROCEDURE_BLR.NULL) { MemoryPool* const csb_pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, csb_pool); + JrdContextPoolHolder context(tdbb, csb_pool); try { @@ -2815,7 +2816,7 @@ ScanResult jrd_prc::reload(thread_db* tdbb, ObjectBase::Flag /*unused*/) return ScanResult::REPEAT; MemoryPool* const csb_pool = tdbb->getDatabase()->createPool(); - Jrd::ContextPoolHolder context(tdbb, csb_pool); + JrdContextPoolHolder context(tdbb, csb_pool); try { @@ -2924,7 +2925,7 @@ ScanResult jrd_rel::scan(thread_db* tdbb, ObjectBase::Flag& flags) Attachment* attachment = tdbb->getAttachment(); Database* dbb = tdbb->getDatabase(); - Jrd::ContextPoolHolder context(tdbb, dbb->dbb_permanent); + JrdContextPoolHolder context(tdbb, dbb->dbb_permanent); blb* blob = NULL; jrd_tra* trans = attachment->getMetaTransaction(tdbb); @@ -3915,7 +3916,7 @@ ScanResult CharSetVers::scan(thread_db* tdbb, ObjectBase::Flag flags) if (id != CS_METADATA) { - Firebird::UCharBuffer specificAttributes; + UCharBuffer specificAttributes; ULONG size = info.specificAttributes.getCount() * charset->maxBytesPerChar(); size = INTL_convert_bytes(tdbb, id, @@ -4676,7 +4677,7 @@ void Trigger::compile(thread_db* tdbb) try { - Jrd::ContextPoolHolder context(tdbb, new_pool); + JrdContextPoolHolder context(tdbb, new_pool); AutoPtr auto_csb(FB_NEW_POOL(*new_pool) CompilerScratch(*new_pool)); CompilerScratch* csb = auto_csb; @@ -4828,7 +4829,7 @@ ScanResult IndexVersion::scan(thread_db* tdbb, ObjectBase::Flag flags) MetaId relId = getPermanent()->getRelation()->getId(); bool found = false; - Jrd::ContextPoolHolder context(tdbb, dbb->dbb_permanent); + JrdContextPoolHolder context(tdbb, dbb->dbb_permanent); AutoCacheRequest handle(tdbb, irq_index_scan, IRQ_REQUESTS); FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction) @@ -4869,7 +4870,7 @@ ScanResult IndexVersion::scan(thread_db* tdbb, ObjectBase::Flag flags) MemoryPool* stmtPool = dbb->createPool(); try { - Jrd::ContextPoolHolder context(tdbb, stmtPool); + JrdContextPoolHolder context(tdbb, stmtPool); CompilerScratch* csb = nullptr; Cleanup cc([csb]() {delete csb;}); @@ -4888,7 +4889,7 @@ ScanResult IndexVersion::scan(thread_db* tdbb, ObjectBase::Flag flags) MemoryPool* stmtPool = dbb->createPool(); try { - Jrd::ContextPoolHolder context(tdbb, stmtPool); + JrdContextPoolHolder context(tdbb, stmtPool); CompilerScratch* csb = nullptr; Cleanup cc([csb]() {delete csb;}); @@ -5411,3 +5412,5 @@ jrd_rel* MetadataCache::getLtt(thread_db* tdbb, const QualifiedName& name) return nullptr; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/met.h b/src/jrd/met.h index 16055082e57..967253574a9 100644 --- a/src/jrd/met.h +++ b/src/jrd/met.h @@ -40,7 +40,7 @@ #include "../jrd/CharSetContainer.h" -namespace Jrd { +namespace Firebird::Jrd { // Record types for record summary blob records @@ -94,13 +94,13 @@ class TemporaryField : public pool_alloc inline constexpr int TFB_computed = 1; inline constexpr int TFB_array = 2; -} // namespace Jrd +} // namespace Firebird::Jrd #include "../jrd/exe_proto.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../dsql/sym.h" -namespace Jrd { +namespace Firebird::Jrd { // Forward decl @@ -226,13 +226,13 @@ struct DSqlCacheItem; typedef std::atomic TriggersSet; -class MetadataCache : public Firebird::PermanentStorage +class MetadataCache : public PermanentStorage { friend class CharSetContainer; public: MetadataCache(MemoryPool& pool) - : Firebird::PermanentStorage(pool), + : PermanentStorage(pool), mdc_generators(getPool()), mdc_relations(getPool()), mdc_procedures(getPool()), @@ -504,7 +504,7 @@ class MetadataCache : public Firebird::PermanentStorage class GeneratorFinder { - typedef Firebird::MutexLockGuard Guard; + typedef MutexLockGuard Guard; public: explicit GeneratorFinder(MemoryPool& pool) @@ -556,8 +556,8 @@ class MetadataCache : public Firebird::PermanentStorage } private: - Firebird::Array m_objects; - Firebird::Mutex m_tx; + Array m_objects; + Mutex m_tx; }; class CleanupQueue @@ -592,8 +592,8 @@ class MetadataCache : public Firebird::PermanentStorage { } }; - Firebird::Mutex cq_mutex; - Firebird::HalfStaticArray cq_data; + Mutex cq_mutex; + HalfStaticArray cq_data; TraNumber cq_traNum = MAX_TRA_NUMBER; FB_SIZE_T cq_pos = 0; @@ -662,6 +662,6 @@ inline Cached::Relation* MetadataCache::getPerm(thread_db* tdb return rc; } -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_MET_H diff --git a/src/jrd/met_proto.h b/src/jrd/met_proto.h index 67f21fc19ca..82f2f55e9f7 100644 --- a/src/jrd/met_proto.h +++ b/src/jrd/met_proto.h @@ -29,7 +29,7 @@ #include "../jrd/MetaName.h" #include "../jrd/Resources.h" #include "../jrd/QualifiedName.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/CacheVector.h" #include "../jrd/LocalTemporaryTable.h" @@ -39,8 +39,7 @@ struct dsc; -namespace Jrd -{ +namespace Firebird::Jrd { class jrd_tra; class Request; class Statement; @@ -65,7 +64,7 @@ namespace Jrd class Triggers; class TrigArray; - typedef Firebird::HalfStaticArray CharsetVariants; + typedef HalfStaticArray CharsetVariants; struct SubtypeInfo { @@ -80,66 +79,66 @@ namespace Jrd MetaName baseCollationName; USHORT attributes; bool ignoreAttributes; - Firebird::UCharBuffer specificAttributes; + UCharBuffer specificAttributes; }; -} -void MET_activate_shadow(Jrd::thread_db*); -ULONG MET_align(const dsc*, ULONG); -Jrd::Cached::Relation* MET_change_fields(Jrd::thread_db*, Jrd::jrd_tra*, const dsc*, const dsc*); -void MET_delete_dependencies(Jrd::thread_db*, const Jrd::QualifiedName&, int); -void MET_delete_shadow(Jrd::thread_db*, USHORT); -void MET_error(const TEXT*, ...); -Jrd::Format* MET_format(Jrd::thread_db*, Jrd::RelationPermanent*, USHORT); -bool MET_get_char_coll_subtype_info(Jrd::thread_db*, USHORT, Jrd::SubtypeInfo* info); -Jrd::DmlNode* MET_get_dependencies(Jrd::thread_db*, Jrd::jrd_rel*, const UCHAR*, const ULONG, - Jrd::CompilerScratch*, Jrd::bid*, Jrd::Statement**, - Jrd::CompilerScratch**, const Jrd::QualifiedName&, int, USHORT, - Jrd::jrd_tra*, const Jrd::QualifiedName& = {}); -Jrd::jrd_fld* MET_get_field(const Jrd::jrd_rel*, USHORT); -ULONG MET_get_rel_flags_from_TYPE(USHORT); -bool MET_get_repl_state(Jrd::thread_db*, const Jrd::QualifiedName&); -void MET_get_shadow_files(Jrd::thread_db*, bool); -bool MET_load_exception(Jrd::thread_db*, Jrd::ExceptionItem&); -void MET_load_trigger(Jrd::thread_db*, Jrd::jrd_rel*, const Jrd::QualifiedName&, std::function); -void MET_lookup_index_for_cnstrt(Jrd::thread_db*, Jrd::QualifiedName& index_name, const Jrd::QualifiedName& constraint); -void MET_lookup_cnstrt_for_index(Jrd::thread_db*, Jrd::MetaName& constraint, const Jrd::QualifiedName& index_name); -void MET_lookup_cnstrt_for_trigger(Jrd::thread_db*, Jrd::MetaName&, Jrd::QualifiedName&, const Jrd::QualifiedName&); -void MET_lookup_exception(Jrd::thread_db*, SLONG, /* OUT */ Jrd::QualifiedName&, /* OUT */ Firebird::string*); -Jrd::ElementBase::ReturnedId MET_lookup_field(Jrd::thread_db*, Jrd::jrd_rel*, const Jrd::MetaName&); -Jrd::BlobFilter* MET_lookup_filter(Jrd::thread_db*, SSHORT, SSHORT); -bool MET_load_generator(Jrd::thread_db*, Jrd::GeneratorItem&, bool* sysGen = 0, SLONG* step = 0); -SLONG MET_lookup_generator(Jrd::thread_db*, const Jrd::QualifiedName&, bool* sysGen = 0, SLONG* step = 0); -bool MET_lookup_generator_id(Jrd::thread_db*, SLONG, Jrd::QualifiedName&, bool* sysGen = 0); -void MET_update_generator_increment(Jrd::thread_db* tdbb, SLONG gen_id, SLONG step); -void MET_lookup_index_code(Jrd::thread_db* tdbb, Jrd::Cached::Relation* relation, Jrd::index_desc* idx); -bool MET_lookup_index_expr_cond_blr(Jrd::thread_db* tdbb, const Jrd::QualifiedName& index_name, - Jrd::bid& expr_blob_id, Jrd::bid& cond_blob_id); + void MET_activate_shadow(thread_db*); + ULONG MET_align(const dsc*, ULONG); + Cached::Relation* MET_change_fields(thread_db*, jrd_tra*, const dsc*, const dsc*); + void MET_delete_dependencies(thread_db*, const QualifiedName&, int); + void MET_delete_shadow(thread_db*, USHORT); + void MET_error(const TEXT*, ...); + Format* MET_format(thread_db*, RelationPermanent*, USHORT); + bool MET_get_char_coll_subtype_info(thread_db*, USHORT, SubtypeInfo* info); + DmlNode* MET_get_dependencies(thread_db*, jrd_rel*, const UCHAR*, const ULONG, + CompilerScratch*, bid*, Statement**, + CompilerScratch**, const QualifiedName&, int, USHORT, + jrd_tra*, const QualifiedName& = {}); + jrd_fld* MET_get_field(const jrd_rel*, USHORT); + ULONG MET_get_rel_flags_from_TYPE(USHORT); + bool MET_get_repl_state(thread_db*, const QualifiedName&); + void MET_get_shadow_files(thread_db*, bool); + bool MET_load_exception(thread_db*, ExceptionItem&); + void MET_load_trigger(thread_db*, jrd_rel*, const QualifiedName&, std::function); + void MET_lookup_index_for_cnstrt(thread_db*, QualifiedName& index_name, const QualifiedName& constraint); + void MET_lookup_cnstrt_for_index(thread_db*, MetaName& constraint, const QualifiedName& index_name); + void MET_lookup_cnstrt_for_trigger(thread_db*, MetaName&, QualifiedName&, const QualifiedName&); + void MET_lookup_exception(thread_db*, SLONG, /* OUT */ QualifiedName&, /* OUT */ string*); + ElementBase::ReturnedId MET_lookup_field(thread_db*, jrd_rel*, const MetaName&); + BlobFilter* MET_lookup_filter(thread_db*, SSHORT, SSHORT); + bool MET_load_generator(thread_db*, GeneratorItem&, bool* sysGen = 0, SLONG* step = 0); + SLONG MET_lookup_generator(thread_db*, const QualifiedName&, bool* sysGen = 0, SLONG* step = 0); + bool MET_lookup_generator_id(thread_db*, SLONG, QualifiedName&, bool* sysGen = 0); + void MET_update_generator_increment(thread_db* tdbb, SLONG gen_id, SLONG step); + void MET_lookup_index_code(thread_db* tdbb, Cached::Relation* relation, index_desc* idx); + bool MET_lookup_index_expr_cond_blr(thread_db* tdbb, const QualifiedName& index_name, + bid& expr_blob_id, bid& cond_blob_id); -bool MET_lookup_partner(Jrd::thread_db* tdbb, Jrd::RelationPermanent* relation, Jrd::index_desc* idx, - const Jrd::QualifiedName& index_name); -Jrd::DmlNode* MET_parse_blob(Jrd::thread_db*, const Jrd::MetaName* schema, Jrd::Cached::Relation*, Jrd::bid*, - Jrd::CompilerScratch**, Jrd::Statement**, bool, bool); -void MET_prepare(Jrd::thread_db*, Jrd::jrd_tra*, USHORT, const UCHAR*); -void MET_release_existence(Jrd::thread_db*, Jrd::jrd_rel*); -void MET_revoke(Jrd::thread_db*, Jrd::jrd_tra*, const Jrd::QualifiedName&, - const Jrd::QualifiedName&, const Firebird::string&); -void MET_store_dependencies(Jrd::thread_db*, Firebird::Array&, const Jrd::jrd_rel*, - const Jrd::QualifiedName&, int, Jrd::jrd_tra*); -void MET_trigger_msg(Jrd::thread_db*, Firebird::string&, const Jrd::QualifiedName&, USHORT); -void MET_update_shadow(Jrd::thread_db*, Jrd::Shadow*, USHORT); -void MET_update_transaction(Jrd::thread_db*, Jrd::jrd_tra*, const bool); -void MET_get_domain(Jrd::thread_db*, MemoryPool& csbPool, const Jrd::QualifiedName&, dsc*, Jrd::FieldInfo*); -void MET_get_relation_field(Jrd::thread_db*, MemoryPool& csbPool, - const Jrd::QualifiedName&, const Jrd::MetaName&, dsc*, Jrd::FieldInfo*); -void MET_update_partners(Jrd::thread_db*); -int MET_get_linger(Jrd::thread_db*); -Firebird::TriState MET_get_ss_definer(Jrd::thread_db*, const Jrd::MetaName& schemaName); -std::optional MET_qualify_existing_name(Jrd::thread_db* tdbb, Jrd::QualifiedName& name, - std::initializer_list objTypes, - const Firebird::ObjectsArray* schemaSearchPath = nullptr); -bool MET_check_schema_exists(Jrd::thread_db* tdbb, const Jrd::MetaName& name); -bool MET_get_ltt_index(Jrd::Attachment* attachment, const Jrd::QualifiedName& indexName, - Jrd::LocalTemporaryTable** outLtt = nullptr, Jrd::LocalTemporaryTable::Index** outIndex = nullptr); + bool MET_lookup_partner(thread_db* tdbb, RelationPermanent* relation, index_desc* idx, + const QualifiedName& index_name); + DmlNode* MET_parse_blob(thread_db*, const MetaName* schema, Cached::Relation*, bid*, + CompilerScratch**, Statement**, bool, bool); + void MET_prepare(thread_db*, jrd_tra*, USHORT, const UCHAR*); + void MET_release_existence(thread_db*, jrd_rel*); + void MET_revoke(thread_db*, jrd_tra*, const QualifiedName&, + const QualifiedName&, const string&); + void MET_store_dependencies(thread_db*, Array&, const jrd_rel*, + const QualifiedName&, int, jrd_tra*); + void MET_trigger_msg(thread_db*, string&, const QualifiedName&, USHORT); + void MET_update_shadow(thread_db*, Shadow*, USHORT); + void MET_update_transaction(thread_db*, jrd_tra*, const bool); + void MET_get_domain(thread_db*, MemoryPool& csbPool, const QualifiedName&, dsc*, FieldInfo*); + void MET_get_relation_field(thread_db*, MemoryPool& csbPool, + const QualifiedName&, const MetaName&, dsc*, FieldInfo*); + void MET_update_partners(thread_db*); + int MET_get_linger(thread_db*); + TriState MET_get_ss_definer(thread_db*, const MetaName& schemaName); + std::optional MET_qualify_existing_name(thread_db* tdbb, QualifiedName& name, + std::initializer_list objTypes, + const ObjectsArray* schemaSearchPath = nullptr); + bool MET_check_schema_exists(thread_db* tdbb, const MetaName& name); + bool MET_get_ltt_index(Attachment* attachment, const QualifiedName& indexName, + LocalTemporaryTable** outLtt = nullptr, LocalTemporaryTable::Index** outIndex = nullptr); +} // namespace Firebird::Jrd #endif // JRD_MET_PROTO_H diff --git a/src/jrd/misc/evl_string_test.cpp b/src/jrd/misc/evl_string_test.cpp index faf9fd5f734..4060fe25f19 100644 --- a/src/jrd/misc/evl_string_test.cpp +++ b/src/jrd/misc/evl_string_test.cpp @@ -32,12 +32,11 @@ const isc_like_escape_invalid = 1; void ERR_post(...) { - throw Firebird::LongJump(); + throw LongJump(); } #include "evl_string.h" -using namespace Firebird; class StringLikeEvaluator : public LikeEvaluator { @@ -133,7 +132,7 @@ int main() StringLikeEvaluator t7(p, "%sosome_text\\?", '\\'); assert(false); } - catch (const Firebird::Exception&) { + catch (const Exception&) { } // Test single '%' pattern diff --git a/src/jrd/mov.cpp b/src/jrd/mov.cpp index 7ff880e204b..100db2a3b54 100644 --- a/src/jrd/mov.cpp +++ b/src/jrd/mov.cpp @@ -41,9 +41,11 @@ #include "../jrd/intl_proto.h" #include "../jrd/mov_proto.h" -using namespace Firebird; +namespace Firebird::Jrd +{ + -int MOV_compare(Jrd::thread_db* tdbb, const dsc* arg1, const dsc* arg2) +int MOV_compare(thread_db* tdbb, const dsc* arg1, const dsc* arg2) { /************************************** * @@ -105,7 +107,7 @@ bool MOV_get_boolean(const dsc* desc) } -double MOV_get_double(Jrd::thread_db* tdbb, const dsc* desc) +double MOV_get_double(thread_db* tdbb, const dsc* desc) { /************************************** * @@ -122,7 +124,7 @@ double MOV_get_double(Jrd::thread_db* tdbb, const dsc* desc) } -SLONG MOV_get_long(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) +SLONG MOV_get_long(thread_db* tdbb, const dsc* desc, SSHORT scale) { /************************************** * @@ -140,7 +142,7 @@ SLONG MOV_get_long(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) } -SINT64 MOV_get_int64(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) +SINT64 MOV_get_int64(thread_db* tdbb, const dsc* desc, SSHORT scale) { /************************************** * @@ -158,7 +160,7 @@ SINT64 MOV_get_int64(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) } -void MOV_get_metaname(Jrd::thread_db* tdbb, const dsc* desc, Jrd::MetaName& name) +void MOV_get_metaname(thread_db* tdbb, const dsc* desc, MetaName& name) { /************************************** * @@ -181,7 +183,7 @@ void MOV_get_metaname(Jrd::thread_db* tdbb, const dsc* desc, Jrd::MetaName& name } -SQUAD MOV_get_quad(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) +SQUAD MOV_get_quad(thread_db* tdbb, const dsc* desc, SSHORT scale) { /************************************** * @@ -199,7 +201,7 @@ SQUAD MOV_get_quad(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) } -int MOV_get_string_ptr(Jrd::thread_db* tdbb, +int MOV_get_string_ptr(thread_db* tdbb, const dsc* desc, TTypeId* ttype, UCHAR** address, vary* temp, USHORT length) @@ -225,7 +227,7 @@ int MOV_get_string_ptr(Jrd::thread_db* tdbb, } -int MOV_get_string(Jrd::thread_db* tdbb, const dsc* desc, UCHAR** address, vary* temp, USHORT length) +int MOV_get_string(thread_db* tdbb, const dsc* desc, UCHAR** address, vary* temp, USHORT length) { /************************************** * @@ -242,7 +244,7 @@ int MOV_get_string(Jrd::thread_db* tdbb, const dsc* desc, UCHAR** address, vary* } -void MOV_get_string(Jrd::thread_db* tdbb, const dsc* desc, string& str) +void MOV_get_string(thread_db* tdbb, const dsc* desc, string& str) { VaryStr temp; const char* strPtr = NULL; @@ -336,7 +338,7 @@ ISC_TIMESTAMP_TZ MOV_get_timestamp_tz(const dsc* desc) } -USHORT MOV_make_string(Jrd::thread_db* tdbb, +USHORT MOV_make_string(thread_db* tdbb, const dsc* desc, TTypeId ttype, const char** address, @@ -366,11 +368,11 @@ USHORT MOV_make_string(Jrd::thread_db* tdbb, } -ULONG MOV_make_string2(Jrd::thread_db* tdbb, +ULONG MOV_make_string2(thread_db* tdbb, const dsc* desc, TTypeId ttype, UCHAR** address, - Jrd::MoveBuffer& buffer, + MoveBuffer& buffer, bool limit) { /************************************** @@ -393,11 +395,11 @@ ULONG MOV_make_string2(Jrd::thread_db* tdbb, temp.dsc_dtype = dtype_text; temp.setTextType(ttype); - Firebird::UCharBuffer bpb; + UCharBuffer bpb; BLB_gen_bpb_from_descs(desc, &temp, bpb); - Jrd::blb* blob = Jrd::blb::open2(tdbb, tdbb->getRequest()->req_transaction, - reinterpret_cast(desc->dsc_address), bpb.getCount(), bpb.begin()); + blb* blob = blb::open2(tdbb, tdbb->getRequest()->req_transaction, + reinterpret_cast(desc->dsc_address), bpb.getCount(), bpb.begin()); ULONG size; @@ -428,9 +430,9 @@ ULONG MOV_make_string2(Jrd::thread_db* tdbb, } -Firebird::string MOV_make_string2(Jrd::thread_db* tdbb, const dsc* desc, TTypeId ttype, bool limit) +string MOV_make_string2(thread_db* tdbb, const dsc* desc, TTypeId ttype, bool limit) { - Jrd::MoveBuffer buffer; + MoveBuffer buffer; UCHAR* ptr; int len = MOV_make_string2(tdbb, desc, ttype, &ptr, buffer, limit); @@ -438,7 +440,7 @@ Firebird::string MOV_make_string2(Jrd::thread_db* tdbb, const dsc* desc, TTypeId } -void MOV_move(Jrd::thread_db* tdbb, /*const*/ dsc* from, dsc* to, bool trustedSource) +void MOV_move(thread_db* tdbb, /*const*/ dsc* from, dsc* to, bool trustedSource) { /************************************** * @@ -452,13 +454,13 @@ void MOV_move(Jrd::thread_db* tdbb, /*const*/ dsc* from, dsc* to, bool trustedSo **************************************/ if (DTYPE_IS_BLOB_OR_QUAD(from->dsc_dtype) || DTYPE_IS_BLOB_OR_QUAD(to->dsc_dtype)) - Jrd::blb::move(tdbb, from, to); + blb::move(tdbb, from, to); else - CVT_move_common(from, to, tdbb->getAttachment()->att_dec_status, &Jrd::EngineCallbacks::instance, trustedSource); + CVT_move_common(from, to, tdbb->getAttachment()->att_dec_status, &EngineCallbacks::instance, trustedSource); } -Decimal64 MOV_get_dec64(Jrd::thread_db* tdbb, const dsc* desc) +Decimal64 MOV_get_dec64(thread_db* tdbb, const dsc* desc) { /************************************** * @@ -470,7 +472,7 @@ Decimal64 MOV_get_dec64(Jrd::thread_db* tdbb, const dsc* desc) } -Decimal128 MOV_get_dec128(Jrd::thread_db* tdbb, const dsc* desc) +Decimal128 MOV_get_dec128(thread_db* tdbb, const dsc* desc) { /************************************** * @@ -482,7 +484,7 @@ Decimal128 MOV_get_dec128(Jrd::thread_db* tdbb, const dsc* desc) } -Int128 MOV_get_int128(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) +Int128 MOV_get_int128(thread_db* tdbb, const dsc* desc, SSHORT scale) { /************************************** * @@ -494,9 +496,6 @@ Int128 MOV_get_int128(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) } -namespace Jrd -{ - DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen, TTypeId charSetId) : maxLen(mLen) { @@ -560,4 +559,5 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen, TType } } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/mov_proto.h b/src/jrd/mov_proto.h index 2be6e1a9c27..b5503dc1f67 100644 --- a/src/jrd/mov_proto.h +++ b/src/jrd/mov_proto.h @@ -31,50 +31,52 @@ struct dsc; struct vary; -int MOV_compare(Jrd::thread_db*, const dsc*, const dsc*); +namespace Firebird::Jrd +{ + + +int MOV_compare(thread_db*, const dsc*, const dsc*); double MOV_date_to_double(const dsc*); void MOV_double_to_date(double, SLONG[2]); bool MOV_get_boolean(const dsc*); -double MOV_get_double(Jrd::thread_db*, const dsc*); -SLONG MOV_get_long(Jrd::thread_db*, const dsc*, SSHORT); -void MOV_get_metaname(Jrd::thread_db*, const dsc*, Jrd::MetaName&); -SQUAD MOV_get_quad(Jrd::thread_db*, const dsc*, SSHORT); -SINT64 MOV_get_int64(Jrd::thread_db*, const dsc*, SSHORT); -int MOV_get_string_ptr(Jrd::thread_db*, const dsc*, TTypeId*, UCHAR**, vary*, USHORT); -int MOV_get_string(Jrd::thread_db*, const dsc*, UCHAR**, vary*, USHORT); -void MOV_get_string(Jrd::thread_db* tdbb, const dsc* desc, Firebird::string& str); +double MOV_get_double(thread_db*, const dsc*); +SLONG MOV_get_long(thread_db*, const dsc*, SSHORT); +void MOV_get_metaname(thread_db*, const dsc*, MetaName&); +SQUAD MOV_get_quad(thread_db*, const dsc*, SSHORT); +SINT64 MOV_get_int64(thread_db*, const dsc*, SSHORT); +int MOV_get_string_ptr(thread_db*, const dsc*, TTypeId*, UCHAR**, vary*, USHORT); +int MOV_get_string(thread_db*, const dsc*, UCHAR**, vary*, USHORT); +void MOV_get_string(thread_db* tdbb, const dsc* desc, string& str); GDS_DATE MOV_get_sql_date(const dsc*); GDS_TIME MOV_get_sql_time(const dsc*); ISC_TIME_TZ MOV_get_sql_time_tz(const dsc*); GDS_TIMESTAMP MOV_get_timestamp(const dsc*); ISC_TIMESTAMP_TZ MOV_get_timestamp_tz(const dsc*); -USHORT MOV_make_string(Jrd::thread_db*, const dsc*, TTypeId, const char**, vary*, USHORT); -ULONG MOV_make_string2(Jrd::thread_db*, const dsc*, TTypeId, UCHAR**, Jrd::MoveBuffer&, bool = true); -Firebird::string MOV_make_string2(Jrd::thread_db* tdbb, const dsc* desc, TTypeId ttype, +USHORT MOV_make_string(thread_db*, const dsc*, TTypeId, const char**, vary*, USHORT); +ULONG MOV_make_string2(thread_db*, const dsc*, TTypeId, UCHAR**, MoveBuffer&, bool = true); +string MOV_make_string2(thread_db* tdbb, const dsc* desc, TTypeId ttype, bool limit = true); -void MOV_move(Jrd::thread_db*, /*const*/ dsc*, dsc*, bool trustedSource = false); -Firebird::Decimal64 MOV_get_dec64(Jrd::thread_db*, const dsc*); -Firebird::Decimal128 MOV_get_dec128(Jrd::thread_db*, const dsc*); -Firebird::Int128 MOV_get_int128(Jrd::thread_db*, const dsc*, SSHORT); - -namespace Jrd -{ +void MOV_move(thread_db*, /*const*/ dsc*, dsc*, bool trustedSource = false); +Decimal64 MOV_get_dec64(thread_db*, const dsc*); +Decimal128 MOV_get_dec128(thread_db*, const dsc*); +Int128 MOV_get_int128(thread_db*, const dsc*, SSHORT); class DescPrinter { public: DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen, TTypeId charSetId); - const Firebird::string& get() const + const string& get() const { return value; } private: - Firebird::string value; + string value; FB_SIZE_T maxLen; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_MOV_PROTO_H diff --git a/src/jrd/nbak.cpp b/src/jrd/nbak.cpp index 03e20e228d0..4e956ee4d76 100644 --- a/src/jrd/nbak.cpp +++ b/src/jrd/nbak.cpp @@ -68,8 +68,8 @@ IMPLEMENT_TRACE_ROUTINE(nbak_trace, "NBAK") #endif -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ /******************************** NBackupStateLock ******************************/ @@ -114,14 +114,14 @@ void NBackupStateLock::blockingAstHandler(thread_db* tdbb) backup_manager->beginFlush(); NBAK_TRACE_AST( ("backup_manager->beginFlush()") ); - Firebird::MutexUnlockGuard counterGuard(counterMutex, FB_FUNCTION); + MutexUnlockGuard counterGuard(counterMutex, FB_FUNCTION); CCH_flush_ast(tdbb); NBAK_TRACE_AST(("database FLUSHED")); } { // scope backup_manager->stateBlocking = true; - Firebird::MutexUnlockGuard counterGuard(counterMutex, FB_FUNCTION); + MutexUnlockGuard counterGuard(counterMutex, FB_FUNCTION); backup_manager->stateBlocking = !backup_manager->localStateLock.tryBeginWrite(FB_FUNCTION); if (backup_manager->stateBlocking) return; @@ -159,7 +159,7 @@ void NBackupAllocLock::invalidate(thread_db* tdbb) /******************************** BackupManager::StateWriteGuard ******************************/ -BackupManager::StateWriteGuard::StateWriteGuard(thread_db* tdbb, Jrd::WIN* window) +BackupManager::StateWriteGuard::StateWriteGuard(thread_db* tdbb, WIN* window) : m_tdbb(tdbb), m_window(NULL), m_success(false) { Database* const dbb = tdbb->getDatabase(); @@ -278,7 +278,7 @@ void BackupManager::beginBackup(thread_db* tdbb) NBAK_TRACE(("Creating difference file %s", diff_name.c_str())); diff_file = PIO_create(tdbb, diff_name, true, false); } - catch (const Firebird::Exception&) + catch (const Exception&) { // no reasons to set it to unknown if we just failed to create difference file stateGuard.setSuccess(); @@ -315,7 +315,7 @@ void BackupManager::beginBackup(thread_db* tdbb) if (func) { stateGuard.setSuccess(); - Firebird::system_call_failed::raise(func); + system_call_failed::raise(func); } } #endif @@ -337,7 +337,7 @@ void BackupManager::beginBackup(thread_db* tdbb) PAG_replace_entry_first(tdbb, header, Ods::HDR_backup_guid, Guid::SIZE, Guid::generate().getData()); - REPL_journal_switch(tdbb); + Replication::REPL_journal_switch(tdbb); stateGuard.releaseHeader(); stateGuard.setSuccess(); @@ -495,7 +495,7 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover) NBAK_TRACE(("Setting state %d in header page is over", backup_state)); stateGuard.setSuccess(); } - catch (const Firebird::Exception&) + catch (const Exception&) { endLock.unlockWrite(tdbb); throw; @@ -557,7 +557,7 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover) CCH_flush(tdbb, FLUSH_ALL, 0); NBAK_TRACE(("Merging is over. Database unlocked")); } - catch (const Firebird::Exception&) + catch (const Exception&) { endLock.unlockWrite(tdbb); throw; @@ -604,7 +604,7 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover) NBAK_TRACE(("backup is over")); endLock.unlockWrite(tdbb); } - catch (const Firebird::Exception&) + catch (const Exception&) { endLock.unlockWrite(tdbb); throw; @@ -674,7 +674,7 @@ bool BackupManager::actualizeAlloc(thread_db* tdbb, bool haveGlobalLock) break; // We finished reading allocation table } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { // Handle out of memory error, etc delete alloc_table; @@ -775,7 +775,7 @@ ULONG BackupManager::allocateDifferencePage(thread_db* tdbb, ULONG db_page) { alloc_table->add(AllocItem(db_page, last_allocated_page)); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { // Handle out of memory error delete alloc_table; @@ -1045,3 +1045,6 @@ void BackupManager::shutdown(thread_db* tdbb) stateLock->shutdownLock(tdbb); allocLock->shutdownLock(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/nbak.h b/src/jrd/nbak.h index f4c5a2c679c..b399223bb70 100644 --- a/src/jrd/nbak.h +++ b/src/jrd/nbak.h @@ -50,11 +50,13 @@ DEFINE_TRACE_ROUTINE(nbak_trace); #define NBAK_TRACE_AST(message) /* nothing */ #endif -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; } -namespace Jrd { +namespace Firebird::Jrd +{ + class Lock; class Record; @@ -82,7 +84,7 @@ class AllocItem } }; -typedef Firebird::BePlusTree AllocItemTree; +typedef BePlusTree AllocItemTree; // Class to synchronize access to backup state @@ -135,7 +137,7 @@ class NBackupAllocLock: public GlobalRWLock * return the version which is fresher, because we don't know if it is merged or not. * Merged pages are written only in database file. * - * For synchronization NBAK uses 3 lock types via Firebird::GlobalRWLock: + * For synchronization NBAK uses 3 lock types via GlobalRWLock: * LCK_backup_database, LCK_backup_alloc, LCK_backup_end. * * LCK_backup_database protects "clean" state of database. Database is meant to be @@ -178,7 +180,7 @@ class BackupManager class StateWriteGuard { public: - StateWriteGuard(thread_db* tdbb, Jrd::WIN* window); + StateWriteGuard(thread_db* tdbb, WIN* window); ~StateWriteGuard(); void releaseHeader(); @@ -194,7 +196,7 @@ class BackupManager StateWriteGuard& operator=(const StateWriteGuard&); thread_db* m_tdbb; - Jrd::WIN* m_window; + WIN* m_window; bool m_success; }; @@ -208,7 +210,7 @@ class BackupManager { lock(tdbb, LCK_WAIT); } - catch (const Firebird::Exception&) + catch (const Exception&) { unlock(tdbb); throw; @@ -222,7 +224,7 @@ class BackupManager static bool lock(thread_db* tdbb, SSHORT wait) { - Jrd::Attachment* const att = tdbb->getAttachment(); + Attachment* const att = tdbb->getAttachment(); Database* const dbb = tdbb->getDatabase(); const bool ok = att ? @@ -237,7 +239,7 @@ class BackupManager static void unlock(thread_db* tdbb) { - Jrd::Attachment* const att = tdbb->getAttachment(); + Attachment* const att = tdbb->getAttachment(); Database* const dbb = tdbb->getDatabase(); if (att) @@ -501,10 +503,10 @@ class BackupManager AllocItemTree* alloc_table; // Cached allocation table of pages in difference file UCHAR backup_state; ULONG last_allocated_page; // Last physical page allocated in the difference file - Firebird::Array temp_buffers_space; + Array temp_buffers_space; ULONG *alloc_buffer, *empty_buffer, *spare_buffer; ULONG current_scn; - Firebird::PathName diff_name; + PathName diff_name; bool explicit_diff_name; bool flushInProgress; bool shutDown; @@ -513,10 +515,10 @@ class BackupManager std::atomic_bool stateBlocking; // blocking AST handler doesn't released stateLock NBackupStateLock* stateLock; - Firebird::RWLock localStateLock; // must be acquired before global stateLock + RWLock localStateLock; // must be acquired before global stateLock // Important: this lock must prefer readers to writers ! NBackupAllocLock* allocLock; - Firebird::RWLock localAllocLock; // must be acquired before global allocLock + RWLock localAllocLock; // must be acquired before global allocLock ULONG findPageIndex(thread_db* tdbb, ULONG db_page); void generateFilename(); @@ -546,6 +548,6 @@ class BackupManager }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif /* JRD_NBAK_H */ diff --git a/src/jrd/nodebug.cpp b/src/jrd/nodebug.cpp index 2f040eec65e..0aa2d218f2f 100644 --- a/src/jrd/nodebug.cpp +++ b/src/jrd/nodebug.cpp @@ -23,7 +23,10 @@ #include "firebird.h" -int DBG_supervisor(int /*arg*/) +namespace Firebird::Jrd { - return TRUE; -} + int DBG_supervisor(int /*arg*/) + { + return TRUE; + } +} // namespace Firebird::Jrd diff --git a/src/jrd/obj.h b/src/jrd/obj.h index 5246253b90b..b72fa762959 100644 --- a/src/jrd/obj.h +++ b/src/jrd/obj.h @@ -2,279 +2,11 @@ * PROGRAM: JRD Access Method * MODULE: obj.h * DESCRIPTION: Object types in meta-data - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. */ #ifndef JRD_OBJ_H #define JRD_OBJ_H -#include "../common/gdsassert.h" - -// Object types used in RDB$DEPENDENCIES and RDB$USER_PRIVILEGES and stored in backup. -// Note: some values are hard coded in grant.gdl -// Keep existing constants unchanged. - -typedef SSHORT ObjectType; - -inline constexpr ObjectType obj_relation = 0; -inline constexpr ObjectType obj_view = 1; -inline constexpr ObjectType obj_trigger = 2; -inline constexpr ObjectType obj_computed = 3; -inline constexpr ObjectType obj_validation = 4; -inline constexpr ObjectType obj_procedure = 5; -inline constexpr ObjectType obj_index_expression = 6; -inline constexpr ObjectType obj_exception = 7; -inline constexpr ObjectType obj_user = 8; -inline constexpr ObjectType obj_field = 9; -inline constexpr ObjectType obj_index = 10; -inline constexpr ObjectType obj_charset = 11; -inline constexpr ObjectType obj_user_group = 12; -inline constexpr ObjectType obj_sql_role = 13; -inline constexpr ObjectType obj_generator = 14; -inline constexpr ObjectType obj_udf = 15; -inline constexpr ObjectType obj_blob_filter = 16; -inline constexpr ObjectType obj_collation = 17; -inline constexpr ObjectType obj_package_header = 18; -inline constexpr ObjectType obj_package_body = 19; -inline constexpr ObjectType obj_privilege = 20; - -// objects types for ddl operations -inline constexpr ObjectType obj_database = 21; -inline constexpr ObjectType obj_relations = 22; -inline constexpr ObjectType obj_views = 23; -inline constexpr ObjectType obj_procedures = 24; -inline constexpr ObjectType obj_functions = 25; -inline constexpr ObjectType obj_packages = 26; -inline constexpr ObjectType obj_generators = 27; -inline constexpr ObjectType obj_domains = 28; -inline constexpr ObjectType obj_exceptions = 29; -inline constexpr ObjectType obj_roles = 30; -inline constexpr ObjectType obj_charsets = 31; -inline constexpr ObjectType obj_collations = 32; -inline constexpr ObjectType obj_filters = 33; - -// Add new codes here if they are used in RDB$DEPENDENCIES or RDB$USER_PRIVILEGES or stored in backup -// Codes for DDL operations add in isDdlObject function as well (find it below). -inline constexpr ObjectType obj_jobs = 34; -inline constexpr ObjectType obj_tablespace = 35; -inline constexpr ObjectType obj_tablespaces = 36; -inline constexpr ObjectType obj_index_condition = 37; - -inline constexpr ObjectType obj_schema = 38; -inline constexpr ObjectType obj_schemas = 39; - -inline constexpr ObjectType obj_type_MAX = 40; - -// used in the parser only / no relation with obj_type_MAX (should be greater) -inline constexpr ObjectType obj_user_or_role = 100; -inline constexpr ObjectType obj_parameter = 101; -inline constexpr ObjectType obj_column = 102; -inline constexpr ObjectType obj_publication = 103; - -inline constexpr ObjectType obj_any = 255; - - -inline bool isSchemaBoundObject(ObjectType objectType) noexcept -{ - switch (objectType) - { - case obj_relation: - case obj_view: - case obj_trigger: - case obj_procedure: - case obj_exception: - case obj_field: - case obj_index: - case obj_charset: - case obj_generator: - case obj_udf: - case obj_collation: - case obj_package_header: - return true; - - default: - return false; - } -} - - -inline bool isDdlObject(ObjectType objectType, bool* useSchema = nullptr) noexcept -{ - if (useSchema) - *useSchema = false; - - switch (objectType) - { - case obj_relations: - case obj_views: - case obj_procedures: - case obj_functions: - case obj_packages: - case obj_generators: - case obj_domains: - case obj_exceptions: - case obj_charsets: - case obj_collations: - if (useSchema) - *useSchema = true; - [[fallthrough]]; - - case obj_database: - case obj_filters: - case obj_roles: - case obj_jobs: - case obj_tablespaces: - case obj_schemas: - return true; - - default: - return false; - } -} - - -inline constexpr const char* getDdlSecurityName(ObjectType object_type) noexcept -{ - switch (object_type) - { - case obj_database: - return "SQL$DATABASE"; - case obj_relations: - return "SQL$TABLES"; - case obj_views: - return "SQL$VIEWS"; - case obj_procedures: - return "SQL$PROCEDURES"; - case obj_functions: - return "SQL$FUNCTIONS"; - case obj_packages: - return "SQL$PACKAGES"; - case obj_generators: - return "SQL$GENERATORS"; - case obj_filters: - return "SQL$FILTERS"; - case obj_domains: - return "SQL$DOMAINS"; - case obj_exceptions: - return "SQL$EXCEPTIONS"; - case obj_roles: - return "SQL$ROLES"; - case obj_charsets: - return "SQL$CHARSETS"; - case obj_collations: - return "SQL$COLLATIONS"; - case obj_jobs: - return "SQL$JOBS"; - case obj_tablespaces: - return "SQL$TABLESPACES"; - case obj_schemas: - return "SQL$SCHEMAS"; - default: - return ""; - } -} - - -inline const char* getDdlObjectName(ObjectType object_type) -{ - switch (object_type) - { - case obj_database: - return "DATABASE"; - case obj_relations: - return "TABLE"; - case obj_packages: - return "PACKAGE"; - case obj_procedures: - return "PROCEDURE"; - case obj_functions: - return "FUNCTION"; - case obj_column: - return "COLUMN"; - case obj_charsets: - return "CHARACTER SET"; - case obj_collations: - return "COLLATION"; - case obj_domains: - return "DOMAIN"; - case obj_exceptions: - return "EXCEPTION"; - case obj_generators: - return "GENERATOR"; - case obj_views: - return "VIEW"; - case obj_roles: - return "ROLE"; - case obj_filters: - return "FILTER"; - case obj_jobs: - return "JOB"; - case obj_tablespaces: - return "TABLESPACE"; - case obj_schemas: - return "SCHEMA"; - default: - fb_assert(false); - return ""; - } -} - - -inline const char* getObjectName(ObjectType objType) -{ - switch (objType) - { - case obj_relation: - return "TABLE"; - case obj_trigger: - return "TRIGGER"; - case obj_package_header: - return "PACKAGE"; - case obj_procedure: - return "PROCEDURE"; - case obj_udf: - return "FUNCTION"; - case obj_column: - return "COLUMN"; - case obj_charset: - return "CHARACTER SET"; - case obj_collation: - return "COLLATION"; - case obj_field: - return "DOMAIN"; - case obj_exception: - return "EXCEPTION"; - case obj_generator: - return "GENERATOR"; - case obj_view: - return "VIEW"; - case obj_sql_role: - return "ROLE"; - case obj_blob_filter: - return "FILTER"; - case obj_schema: - return "SCHEMA"; - default: - fb_assert(false); - return ""; - } -} - +#include "../common/obj.h" #endif // JRD_OBJ_H diff --git a/src/jrd/ods.cpp b/src/jrd/ods.cpp index 5a4f2d605c4..19d111fbd5d 100644 --- a/src/jrd/ods.cpp +++ b/src/jrd/ods.cpp @@ -24,9 +24,9 @@ #include "../jrd/ods.h" #include "../jrd/ods_proto.h" -using namespace Firebird; +namespace Firebird::Jrd::Ods +{ -namespace Ods { bool isSupported(const header_page* hdr) noexcept { @@ -127,7 +127,7 @@ ULONG maxIndices(ULONG page_size) noexcept (sizeof(index_root_page::irt_repeat) + sizeof(irtd))); } -Firebird::string pagtype(UCHAR type) +string pagtype(UCHAR type) { // Print pretty name for database page type @@ -145,7 +145,7 @@ Firebird::string pagtype(UCHAR type) "SCN inventory" }; - Firebird::string rc; + string rc; if (type < FB_NELEM(nameArray)) rc = nameArray[type]; else @@ -195,8 +195,6 @@ void writeTraNum(void* ptr, TraNumber number, FB_SIZE_T header_size) noexcept } } -} // namespace - #ifdef DEV_BUILD namespace @@ -221,3 +219,6 @@ namespace static CheckODS doCheck; } #endif // DEV_BUILD + + +} // namespace Firebird::Jrd::Ods diff --git a/src/jrd/ods.h b/src/jrd/ods.h index 32298720432..31ed46046b0 100644 --- a/src/jrd/ods.h +++ b/src/jrd/ods.h @@ -230,7 +230,7 @@ inline constexpr USHORT MAX_PAGE_SIZE = 32768; inline constexpr USHORT DEFAULT_PAGE_SIZE = 8192; -namespace Ods { +namespace Firebird::Jrd::Ods { // Crypt page by type @@ -697,9 +697,9 @@ static_assert(offsetof(struct header_page, hdr_crypt_page) == 112, "hdr_crypt_pa static_assert(offsetof(struct header_page, hdr_crypt_plugin) == 116, "hdr_crypt_plugin offset mismatch"); static_assert(offsetof(struct header_page, hdr_data) == 148, "hdr_data offset mismatch"); -static_assert(sizeof(header_page::hdr_guid) == Firebird::Guid::SIZE, "hdr_guid size mismatch"); +static_assert(sizeof(header_page::hdr_guid) == Guid::SIZE, "hdr_guid size mismatch"); -#define HDR_SIZE static_cast(offsetof(Ods::header_page, hdr_data[0])) +#define HDR_SIZE static_cast(offsetof(Firebird::Jrd::Ods::header_page, hdr_data[0])) // Header page clumplets @@ -1092,9 +1092,9 @@ inline int IAD_LEN(int count) #define IAD_LEN(count) (sizeof (Ods::InternalArrayDesc) + \ (count ? count - 1: count) * sizeof (Ods::InternalArrayDesc::iad_repeat)) -Firebird::string pagtype(UCHAR type); +string pagtype(UCHAR type); -} //namespace Ods +} // namespace Firebird::Jrd::Ods // alignment for raw page access inline constexpr USHORT PAGE_ALIGNMENT = 1024; diff --git a/src/jrd/ods_proto.h b/src/jrd/ods_proto.h index 8d85789a9ca..c6296e2efda 100644 --- a/src/jrd/ods_proto.h +++ b/src/jrd/ods_proto.h @@ -23,7 +23,7 @@ #ifndef ODS_PROTO_H #define ODS_PROTO_H -namespace Ods { +namespace Firebird::Jrd::Ods { bool isSupported(const header_page* hdr) noexcept; diff --git a/src/jrd/opt_proto.h b/src/jrd/opt_proto.h index af6b9bddc54..5adc6071cd8 100644 --- a/src/jrd/opt_proto.h +++ b/src/jrd/opt_proto.h @@ -28,7 +28,7 @@ #include "../jrd/btr.h" #include "../jrd/lls.h" -namespace Jrd { +namespace Firebird::Jrd { class Request; class jrd_rel; class RecordSource; @@ -40,7 +40,7 @@ namespace Jrd { class MapNode; } -Firebird::string OPT_get_plan(Jrd::thread_db* tdbb, const Jrd::Statement* statement, bool detailed); +string OPT_get_plan(Jrd::thread_db* tdbb, const Jrd::Statement* statement, bool detailed); Jrd::RecordSource* OPT_compile(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb, Jrd::RseNode* rse, Jrd::BoolExprNodeStack* parent_stack); void OPT_compile_relation(Jrd::thread_db* tdbb, Jrd::jrd_rel* relation, Jrd::CompilerScratch* csb, diff --git a/src/jrd/optimizer/InnerJoin.cpp b/src/jrd/optimizer/InnerJoin.cpp index 9a6b440f343..a5880840708 100644 --- a/src/jrd/optimizer/InnerJoin.cpp +++ b/src/jrd/optimizer/InnerJoin.cpp @@ -49,8 +49,8 @@ #include "../jrd/optimizer/Optimizer.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ // @@ -788,3 +788,6 @@ void InnerJoin::printStartOrder() const optimizer->printf("\n"); } #endif + + +} // namespace Firebird::Jrd diff --git a/src/jrd/optimizer/Optimizer.cpp b/src/jrd/optimizer/Optimizer.cpp index e3ac4f7f78f..dc426adbeae 100644 --- a/src/jrd/optimizer/Optimizer.cpp +++ b/src/jrd/optimizer/Optimizer.cpp @@ -89,8 +89,9 @@ #include "../jrd/optimizer/Optimizer.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + #ifdef OPT_DEBUG_RETRIEVAL #define OPT_DEBUG @@ -3609,7 +3610,7 @@ void Optimizer::printf(const char* format, ...) noexcept va_list arglist; va_start(arglist, format); - Firebird::string str; + string str; str.vprintf(format, arglist); va_end(arglist); @@ -3617,3 +3618,6 @@ void Optimizer::printf(const char* format, ...) noexcept fflush(debugFile); #endif } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/optimizer/Optimizer.h b/src/jrd/optimizer/Optimizer.h index 6d56dced2e8..be849ff8a4b 100644 --- a/src/jrd/optimizer/Optimizer.h +++ b/src/jrd/optimizer/Optimizer.h @@ -43,7 +43,9 @@ #include "../jrd/Statement.h" #include "../jrd/recsrc/RecordSource.h" -namespace Jrd { +namespace Firebird::Jrd +{ + // AB: 2005-11-05 // Constants below needs some discussions and ideas @@ -150,7 +152,7 @@ class StreamStateHolder CompilerScratch* const m_csb; StreamList m_streams; - Firebird::HalfStaticArray m_flags; + HalfStaticArray m_flags; }; @@ -158,7 +160,7 @@ class StreamStateHolder // River // -typedef Firebird::HalfStaticArray RiverList; +typedef HalfStaticArray RiverList; class River { @@ -237,7 +239,7 @@ class River protected: RecordSource* m_rsb; - Firebird::HalfStaticArray m_nodes; + HalfStaticArray m_nodes; StreamList m_streams; }; @@ -246,7 +248,7 @@ class River // Optimizer // -class Optimizer final : public Firebird::PermanentStorage +class Optimizer final : public PermanentStorage { public: struct Conjunct @@ -260,7 +262,7 @@ class Optimizer final : public Firebird::PermanentStorage static constexpr unsigned CONJUNCT_MATCHED = 2; // conjunct matches an index segment static constexpr unsigned CONJUNCT_JOINED = 4; // conjunct used for equi-join - typedef Firebird::HalfStaticArray ConjunctList; + typedef HalfStaticArray ConjunctList; class ConjunctIterator { @@ -358,7 +360,7 @@ class Optimizer final : public Firebird::PermanentStorage return ConjunctIterator(begin, end); } - static Firebird::string getPlan(thread_db* tdbb, const Statement* statement, bool detailed) + static string getPlan(thread_db* tdbb, const Statement* statement, bool detailed) { return statement ? statement->getPlan(tdbb, detailed) : ""; } @@ -557,8 +559,8 @@ class Optimizer final : public Firebird::PermanentStorage outerStreams.assign(streams); } - Firebird::string getStreamName(StreamType stream); - Firebird::string makeAlias(StreamType stream); + string getStreamName(StreamType stream); + string makeAlias(StreamType stream); void printf(const char* format, ...) noexcept; private: @@ -629,7 +631,7 @@ enum segmentScanType { segmentScanList }; -typedef Firebird::HalfStaticArray BooleanList; +typedef HalfStaticArray BooleanList; struct IndexScratchSegment { @@ -677,11 +679,11 @@ struct IndexScratch bool useMultiStartingKeys = false; // Use INTL_KEY_MULTI_STARTING bool useRootListScan = false; - Firebird::ObjectsArray segments; + ObjectsArray segments; BooleanList matches; // matched booleans (partial indices only) }; -typedef Firebird::ObjectsArray IndexScratchList; +typedef ObjectsArray IndexScratchList; // // InversionCandidate @@ -710,18 +712,18 @@ struct InversionCandidate BooleanList conjuncts; // booleans referring our stream BooleanList matches; // booleans matched to any index - Firebird::Array dbkeyRanges; + Array dbkeyRanges; SortedStreamList dependentFromStreams; }; -typedef Firebird::HalfStaticArray InversionCandidateList; +typedef HalfStaticArray InversionCandidateList; // // Retrieval // -class Retrieval final : private Firebird::PermanentStorage +class Retrieval final : private PermanentStorage { public: Retrieval(thread_db* tdbb, Optimizer* opt, StreamType streamNumber, @@ -745,7 +747,7 @@ class Retrieval final : private Firebird::PermanentStorage bool checkIndexExpression(const index_desc* idx, ValueExprNode* node) const; InversionNode* composeInversion(InversionNode* node1, InversionNode* node2, InversionNode::Type node_type) const; - const Firebird::string& getAlias(); + const string& getAlias(); void getInversionCandidates(InversionCandidateList& inversions, IndexScratchList& indexScratches, unsigned scope) const; InversionNode* makeIndexScanNode(IndexScratch* indexScratch) const; @@ -775,11 +777,11 @@ class Retrieval final : private Firebird::PermanentStorage Rsc::Rel relation; const bool createIndexScanNodes; const bool setConjunctionsMatched; - Firebird::string alias; + string alias; IndexScratchList indexScratches; InversionCandidateList inversionCandidates; - Firebird::AutoPtr finalCandidate; - Firebird::AutoPtr navigationCandidate; + AutoPtr finalCandidate; + AutoPtr navigationCandidate; }; @@ -787,7 +789,7 @@ class Retrieval final : private Firebird::PermanentStorage // InnerJoin // -class InnerJoin final : private Firebird::PermanentStorage +class InnerJoin final : private PermanentStorage { struct IndexRelationship { @@ -832,10 +834,10 @@ class InnerJoin final : private Firebird::PermanentStorage bool unique = false; double cost = 0; double cardinality = 0; - Firebird::Vector depStreams; + Vector depStreams; }; - typedef Firebird::SortedArray IndexedRelationships; + typedef SortedArray IndexedRelationships; class StreamInfo { @@ -892,7 +894,7 @@ class InnerJoin final : private Firebird::PermanentStorage IndexedRelationships indexedRelationships; }; - typedef Firebird::HalfStaticArray StreamInfoList; + typedef HalfStaticArray StreamInfoList; struct JoinedStreamInfo { @@ -907,10 +909,10 @@ class InnerJoin final : private Firebird::PermanentStorage StreamType number; // stream in position of join order double selectivity = 0.0; // position selectivity - Firebird::Vector equiMatches; + Vector equiMatches; }; - typedef Firebird::HalfStaticArray JoinedStreamList; + typedef HalfStaticArray JoinedStreamList; public: InnerJoin(thread_db* tdbb, Optimizer* opt, @@ -957,7 +959,7 @@ class InnerJoin final : private Firebird::PermanentStorage JoinedStreamList bestStreams; }; -class OuterJoin : private Firebird::PermanentStorage +class OuterJoin : private PermanentStorage { struct OuterJoinStream { @@ -993,6 +995,7 @@ class OuterJoin : private Firebird::PermanentStorage OuterJoinStream joinStreams[2]; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // OPTIMIZER_H diff --git a/src/jrd/optimizer/OuterJoin.cpp b/src/jrd/optimizer/OuterJoin.cpp index 7dcea0febad..0cb63902e4b 100644 --- a/src/jrd/optimizer/OuterJoin.cpp +++ b/src/jrd/optimizer/OuterJoin.cpp @@ -29,8 +29,8 @@ #include "../jrd/optimizer/Optimizer.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ // @@ -217,3 +217,4 @@ RecordSource* OuterJoin::process() }; +} // namespace Firebird::Jrd diff --git a/src/jrd/optimizer/Retrieval.cpp b/src/jrd/optimizer/Retrieval.cpp index 32d0cd995db..e70f35a4015 100644 --- a/src/jrd/optimizer/Retrieval.cpp +++ b/src/jrd/optimizer/Retrieval.cpp @@ -52,8 +52,8 @@ #include -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ namespace @@ -2648,3 +2648,6 @@ void Retrieval::printFinalCandidate(const InversionCandidate* candidate) const printCandidate(candidate); } #endif + + +} // namespace Firebird::Jrd diff --git a/src/jrd/os/pio.h b/src/jrd/os/pio.h index bafe5c75191..e8a24ceabf7 100644 --- a/src/jrd/os/pio.h +++ b/src/jrd/os/pio.h @@ -34,7 +34,7 @@ #include "../common/classes/array.h" #include "../common/classes/File.h" -namespace Jrd { +namespace Firebird::Jrd { #ifdef UNIX @@ -42,7 +42,7 @@ class jrd_file : public pool_alloc_rpt { public: int fil_desc; - Firebird::Mutex fil_mutex; + Mutex fil_mutex; USHORT fil_flags; SCHAR fil_string[1]; // Expanded file name }; @@ -65,7 +65,7 @@ class jrd_file : public pool_alloc_rpt } HANDLE fil_desc; // File descriptor - Firebird::RWLock* fil_ext_lock; // file extend lock + RWLock* fil_ext_lock; // file extend lock USHORT fil_flags; SCHAR fil_string[1]; // Expanded file name }; @@ -109,7 +109,7 @@ inline constexpr UCHAR PIOB_success = 2; // I/O successfully completed inline constexpr UCHAR PIOB_pending = 4; // Asynchronous I/O not yet completed #endif -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_PIO_H diff --git a/src/jrd/os/pio_proto.h b/src/jrd/os/pio_proto.h index 99a7dda760b..5066fed3c0b 100644 --- a/src/jrd/os/pio_proto.h +++ b/src/jrd/os/pio_proto.h @@ -26,47 +26,49 @@ #include "../common/classes/fb_string.h" -namespace Jrd { +namespace Firebird::Jrd { class jrd_file; class Database; class BufferDesc; } -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; } -void PIO_close(Jrd::jrd_file*); -Jrd::jrd_file* PIO_create(Jrd::thread_db*, const Firebird::PathName&, - const bool, const bool); -bool PIO_expand(const TEXT*, USHORT, TEXT*, FB_SIZE_T); -bool PIO_fast_extension_is_supported(const Jrd::jrd_file& file) noexcept; -bool PIO_extend(Jrd::thread_db* tdbb, Jrd::jrd_file* file, ULONG extPages, USHORT pageSize); -void PIO_flush(Jrd::thread_db*, Jrd::jrd_file*); -void PIO_force_write(Jrd::jrd_file*, const bool); -ULONG PIO_get_number_of_pages(const Jrd::jrd_file*, const USHORT); -bool PIO_header(Jrd::thread_db*, UCHAR*, unsigned); -USHORT PIO_init_data(Jrd::thread_db* tdbb, Jrd::jrd_file* file, Jrd::FbStatusVector* status_vector, ULONG startPage, USHORT initPages); -Jrd::jrd_file* PIO_open(Jrd::thread_db*, const Firebird::PathName&, - const Firebird::PathName&); -bool PIO_read(Jrd::thread_db*, Jrd::jrd_file*, Jrd::BufferDesc*, Ods::pag*, Jrd::FbStatusVector*); +namespace Firebird::Jrd +{ + void PIO_close(jrd_file*); + jrd_file* PIO_create(thread_db*, const PathName&, + const bool, const bool); + bool PIO_expand(const TEXT*, USHORT, TEXT*, FB_SIZE_T); + bool PIO_fast_extension_is_supported(const jrd_file& file) noexcept; + bool PIO_extend(thread_db* tdbb, jrd_file* file, ULONG extPages, USHORT pageSize); + void PIO_flush(thread_db*, jrd_file*); + void PIO_force_write(jrd_file*, const bool); + ULONG PIO_get_number_of_pages(const jrd_file*, const USHORT); + bool PIO_header(thread_db*, UCHAR*, unsigned); + USHORT PIO_init_data(thread_db* tdbb, jrd_file* file, FbStatusVector* status_vector, ULONG startPage, USHORT initPages); + jrd_file* PIO_open(thread_db*, const PathName&, + const PathName&); + bool PIO_read(thread_db*, jrd_file*, BufferDesc*, Ods::pag*, FbStatusVector*); -#ifdef SUPERSERVER_V2 -bool PIO_read_ahead(Jrd::thread_db*, SLONG, SCHAR*, SLONG, - struct Jrd::phys_io_blk*, Jrd::FbStatusVector*); -bool PIO_status(Jrd::thread_db*, struct Jrd::phys_io_blk*, Jrd::FbStatusVector*); -#endif + #ifdef SUPERSERVER_V2 + bool PIO_read_ahead(thread_db*, SLONG, SCHAR*, SLONG, + struct phys_io_blk*, FbStatusVector*); + bool PIO_status(thread_db*, struct phys_io_blk*, FbStatusVector*); + #endif -#ifdef SUPPORT_RAW_DEVICES -bool PIO_on_raw_device(const Firebird::PathName&); -int PIO_unlink(const Firebird::PathName&); -#else -inline bool PIO_on_raw_device(const Firebird::PathName&) -{ - return false; -} -#endif -bool PIO_write(Jrd::thread_db*, Jrd::jrd_file*, Jrd::BufferDesc*, Ods::pag*, Jrd::FbStatusVector*); + #ifdef SUPPORT_RAW_DEVICES + bool PIO_on_raw_device(const PathName&); + int PIO_unlink(const PathName&); + #else + inline bool PIO_on_raw_device(const PathName&) + { + return false; + } + #endif + bool PIO_write(thread_db*, jrd_file*, BufferDesc*, Ods::pag*, FbStatusVector*); +} // namespace Firebird::Jrd #endif // JRD_PIO_PROTO_H - diff --git a/src/jrd/os/posix/unix.cpp b/src/jrd/os/posix/unix.cpp index 780eeb90500..6f7f7545d40 100644 --- a/src/jrd/os/posix/unix.cpp +++ b/src/jrd/os/posix/unix.cpp @@ -77,8 +77,9 @@ #include "../common/classes/init.h" #include "../common/os/os_utils.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + // Some operating systems have problems with use of write/read with // big (>2Gb) files. On the other hand, pwrite/pread works fine for them. @@ -146,7 +147,7 @@ static SLONG pwrite(int, SCHAR*, SLONG, SLONG); static bool raw_devices_validate_database (int, const PathName&); static int raw_devices_unlink_database (const PathName&); #endif -static int openFile(const Firebird::PathName&, const bool, const bool, const bool); +static int openFile(const PathName&, const bool, const bool, const bool); static void maybeCloseFile(int&); @@ -299,7 +300,7 @@ bool PIO_expand(const TEXT* file_name, USHORT file_length, TEXT* expanded_name, } -bool PIO_fast_extension_is_supported(const Jrd::jrd_file& file) noexcept +bool PIO_fast_extension_is_supported(const jrd_file& file) noexcept { #if defined(HAVE_LINUX_FALLOC_H) && defined(HAVE_FALLOCATE) return !(file.fil_flags & FIL_no_fast_extend); @@ -579,7 +580,7 @@ bool PIO_header(thread_db* tdbb, UCHAR* address, unsigned length) // we need a class here only to return memory on shutdown and avoid // false memory leak reports -static Firebird::InitInstance zeros; +static InitInstance zeros; USHORT PIO_init_data(thread_db* tdbb, jrd_file* file, FbStatusVector* status_vector, @@ -1305,3 +1306,6 @@ static int raw_devices_unlink_database(const PathName& file_name) return 0; } #endif // SUPPORT_RAW_DEVICES + + +} // namespace Firebird::Jrd diff --git a/src/jrd/os/win32/ibinitdll.cpp b/src/jrd/os/win32/ibinitdll.cpp index 7ea8106e933..73d7d2e8bb1 100644 --- a/src/jrd/os/win32/ibinitdll.cpp +++ b/src/jrd/os/win32/ibinitdll.cpp @@ -27,7 +27,6 @@ #include "../../../common/dllinst.h" #include "../../../yvalve/utl_proto.h" - using namespace Firebird; diff --git a/src/jrd/os/win32/winnt.cpp b/src/jrd/os/win32/winnt.cpp index 3b28d4eea35..1ae936ca28a 100644 --- a/src/jrd/os/win32/winnt.cpp +++ b/src/jrd/os/win32/winnt.cpp @@ -54,12 +54,14 @@ #include -namespace Jrd { +namespace Firebird::Jrd +{ + class FileExtendLockGuard { public: - FileExtendLockGuard(Firebird::RWLock* lock, bool exclusive) : + FileExtendLockGuard(RWLock* lock, bool exclusive) : m_lock(lock), m_exclusive(exclusive) { if (m_exclusive) { @@ -90,16 +92,11 @@ class FileExtendLockGuard FileExtendLockGuard& operator=(const FileExtendLockGuard&) = delete; private: - Firebird::RWLock* const m_lock; + RWLock* const m_lock; const bool m_exclusive; }; -} // namespace Jrd - -using namespace Jrd; -using namespace Firebird; - #ifdef TEXT #undef TEXT #endif @@ -107,7 +104,7 @@ using namespace Firebird; static bool maybeCloseFile(HANDLE&); static bool seek_file(jrd_file*, const BufferDesc*, OVERLAPPED*); -static jrd_file* setup_file(Database*, const Firebird::PathName&, HANDLE, USHORT); +static jrd_file* setup_file(Database*, const PathName&, HANDLE, USHORT); static bool nt_error(const TEXT*, const jrd_file*, ISC_STATUS, FbStatusVector* const); inline static DWORD getShareFlags(const bool shared_access, bool temporary = false) noexcept @@ -135,7 +132,7 @@ void PIO_close(jrd_file* file) } -jrd_file* PIO_create(thread_db* tdbb, const Firebird::PathName& string, +jrd_file* PIO_create(thread_db* tdbb, const PathName& string, const bool overwrite, const bool temporary) { /************************************** @@ -185,7 +182,7 @@ jrd_file* PIO_create(thread_db* tdbb, const Firebird::PathName& string, // File open succeeded. Now expand the file name. // workspace is the expanded name here - Firebird::PathName workspace(string); + PathName workspace(string); ISC_expand_filename(workspace, false); const USHORT flags = @@ -378,7 +375,7 @@ bool PIO_header(thread_db* tdbb, UCHAR* address, unsigned length) // we need a class here only to return memory on shutdown and avoid // false memory leak reports -static Firebird::InitInstance zeros; +static InitInstance zeros; USHORT PIO_init_data(thread_db* tdbb, jrd_file* file, FbStatusVector* status_vector, @@ -453,8 +450,8 @@ USHORT PIO_init_data(thread_db* tdbb, jrd_file* file, FbStatusVector* status_vec jrd_file* PIO_open(thread_db* tdbb, - const Firebird::PathName& string, - const Firebird::PathName& file_name) + const PathName& string, + const PathName& file_name) { /************************************** * @@ -786,7 +783,7 @@ static bool seek_file(jrd_file* file, const BufferDesc* bdb, OVERLAPPED* overlap } -static jrd_file* setup_file(Database* dbb, const Firebird::PathName& file_name, HANDLE desc, USHORT flags) +static jrd_file* setup_file(Database* dbb, const PathName& file_name, HANDLE desc, USHORT flags) { /************************************** * @@ -813,9 +810,9 @@ static jrd_file* setup_file(Database* dbb, const Firebird::PathName& file_name, if (pageSpace && pageSpace->file) return file; - file->fil_ext_lock = FB_NEW_POOL(*dbb->dbb_permanent) Firebird::RWLock(); + file->fil_ext_lock = FB_NEW_POOL(*dbb->dbb_permanent) RWLock(); } - catch (const Firebird::Exception&) + catch (const Exception&) { CloseHandle(desc); delete file; @@ -881,3 +878,6 @@ static bool nt_error(const TEXT* string, return false; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/pag.cpp b/src/jrd/pag.cpp index 8b4e1d33697..b3bc50a223e 100644 --- a/src/jrd/pag.cpp +++ b/src/jrd/pag.cpp @@ -96,9 +96,9 @@ #include "../common/classes/DbImplementation.h" #include "../jrd/CryptoManager.h" -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ + namespace { @@ -116,7 +116,7 @@ namespace class HeaderClumplet { public: - HeaderClumplet(header_page* header, USHORT type) noexcept + HeaderClumplet(Ods::header_page* header, USHORT type) noexcept : m_header(header), m_type(type) {} @@ -125,7 +125,7 @@ namespace UCHAR* p = m_header->hdr_data; UCHAR* q = nullptr; - for (; *p != HDR_end; p += 2 + p[1]) + for (; *p != Ods::HDR_end; p += 2 + p[1]) { if (*p == m_type) q = p; @@ -150,7 +150,7 @@ namespace void add(USHORT length, const UCHAR* entry, bool first = false) const { UCHAR* p = (UCHAR*) m_header + m_header->hdr_end; - fb_assert(*p == HDR_end); + fb_assert(*p == Ods::HDR_end); if (first) { @@ -175,7 +175,7 @@ namespace } if (!first) - *p = HDR_end; + *p = Ods::HDR_end; m_header->hdr_end += length + 2; } @@ -186,7 +186,7 @@ namespace const USHORT orgLen = entry[1] + 2; const UCHAR* const tail = entry + orgLen; - const USHORT shift = end - tail + 1; // to preserve HDR_end + const USHORT shift = end - tail + 1; // to preserve Ods::HDR_end memmove(entry, tail, shift); m_header->hdr_end -= orgLen; @@ -205,7 +205,7 @@ namespace } private: - header_page* const m_header; + Ods::header_page* const m_header; const USHORT m_type; }; @@ -218,8 +218,8 @@ namespace ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header); - header_page* header = (header_page*) page; + Ods::pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) page; const HeaderClumplet clump(header, type); @@ -358,7 +358,7 @@ namespace } // namespace -void PAG_add_header_entry(thread_db* tdbb, header_page* header, +void PAG_add_header_entry(thread_db* tdbb, Ods::header_page* header, USHORT type, USHORT len, const UCHAR* entry) { /*********************************************** @@ -388,7 +388,7 @@ void PAG_add_header_entry(thread_db* tdbb, header_page* header, } -bool PAG_replace_entry_first(thread_db* tdbb, header_page* header, +bool PAG_replace_entry_first(thread_db* tdbb, Ods::header_page* header, USHORT type, USHORT len, const UCHAR* entry) { /*********************************************** @@ -427,7 +427,7 @@ bool PAG_replace_entry_first(thread_db* tdbb, header_page* header, } -PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool aligned) +Ods::PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool aligned) { /************************************** * @@ -449,7 +449,7 @@ PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool ali PageSpace* const pageSpace = pageMgr.findPageSpace(window->win_page.getPageSpaceID()); fb_assert(pageSpace); - PAG new_page = NULL; + Ods::PAG new_page = NULL; // Find an allocation page with something on it @@ -459,7 +459,7 @@ PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool ali WIN pip_window(pageSpace->pageSpaceID, (sequence == 0) ? pageSpace->pipFirst : sequence * dbb->dbb_page_manager.pagesPerPIP - 1); - page_inv_page* pip_page = (page_inv_page*) CCH_FETCH(tdbb, &pip_window, LCK_write, pag_pages); + Ods::page_inv_page* pip_page = (Ods::page_inv_page*) CCH_FETCH(tdbb, &pip_window, LCK_write, pag_pages); ULONG firstBit = MAX_ULONG, lastBit = MAX_ULONG; @@ -512,18 +512,18 @@ PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool ali if (lastBit + 1 > pipUsed) pipUsed = ensureDiskSpace(tdbb, &pip_window, window->win_page, pipUsed); - pag* new_page = CCH_fake(tdbb, window, 1); + Ods::pag* new_page = CCH_fake(tdbb, window, 1); if (newSCN) { - scns_page* new_scns_page = (scns_page*) new_page; + Ods::scns_page* new_scns_page = (Ods::scns_page*) new_page; new_scns_page->scn_header.pag_type = pag_scns; new_scns_page->scn_sequence = pageNum / pageMgr.pagesPerSCN; } if (newPIP) { - page_inv_page* new_pip_page = (page_inv_page*) new_page; + Ods::page_inv_page* new_pip_page = (Ods::page_inv_page*) new_page; new_pip_page->pip_header.pag_type = pag_pages; const UCHAR* end = (UCHAR*) new_pip_page + dbb->dbb_page_size; memset(new_pip_page->pip_bits, 0xff, end - new_pip_page->pip_bits); @@ -718,7 +718,7 @@ AttNumber PAG_attachment_id(thread_db* tdbb) else { WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK(tdbb, &window); @@ -750,8 +750,8 @@ bool PAG_delete_clump_entry(thread_db* tdbb, USHORT type) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header); - header_page* header = (header_page*) page; + Ods::pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) page; const HeaderClumplet clump(header, type); @@ -788,7 +788,7 @@ void PAG_format_header(thread_db* tdbb) // Initialize header page WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_fake(tdbb, &window, 1); + Ods::header_page* header = (Ods::header_page*) CCH_fake(tdbb, &window, 1); header->hdr_header.pag_type = pag_header; header->hdr_header.pag_scn = 0; Guid::generate().copyTo(header->hdr_guid); @@ -801,13 +801,13 @@ void PAG_format_header(thread_db* tdbb) header->hdr_ods_minor = ODS_CURRENT; header->hdr_oldest_transaction = 1; header->hdr_end = HDR_SIZE; - header->hdr_data[0] = HDR_end; + header->hdr_data[0] = Ods::HDR_end; if (dbb->dbb_flags & DBB_DB_SQL_dialect_3) - header->hdr_flags |= hdr_SQL_dialect_3; + header->hdr_flags |= Ods::hdr_SQL_dialect_3; if (dbb->dbb_flags & DBB_force_write) - header->hdr_flags |= hdr_force_write; + header->hdr_flags |= Ods::hdr_force_write; dbb->dbb_ods_version = header->hdr_ods_version & ~ODS_FIREBIRD_FLAG; dbb->dbb_minor_version = header->hdr_ods_minor; @@ -842,7 +842,7 @@ void PAG_format_pip(thread_db* tdbb, PageSpace& pageSpace) pageSpace.scnFirst = FIRST_SCN_PAGE; WIN window(pageSpace.pageSpaceID, pageSpace.scnFirst); - scns_page* page = (scns_page*) CCH_fake(tdbb, &window, 1); + Ods::scns_page* page = (Ods::scns_page*) CCH_fake(tdbb, &window, 1); page->scn_header.pag_type = pag_scns; page->scn_sequence = 0; @@ -855,12 +855,12 @@ void PAG_format_pip(thread_db* tdbb, PageSpace& pageSpace) pageSpace.pipFirst = FIRST_PIP_PAGE; WIN window(pageSpace.pageSpaceID, pageSpace.pipFirst); - page_inv_page* pages = (page_inv_page*) CCH_fake(tdbb, &window, 1); + Ods::page_inv_page* pages = (Ods::page_inv_page*) CCH_fake(tdbb, &window, 1); pages->pip_header.pag_type = pag_pages; pages->pip_used = (pageSpace.scnFirst ? pageSpace.scnFirst : pageSpace.pipFirst) + 1; pages->pip_min = pages->pip_used; - const int count = dbb->dbb_page_size - static_cast(offsetof(page_inv_page, pip_bits[0])); + const int count = dbb->dbb_page_size - static_cast(offsetof(Ods::page_inv_page, pip_bits[0])); memset(pages->pip_bits, 0xFF, count); @@ -893,8 +893,8 @@ bool PAG_get_clump(thread_db* tdbb, USHORT type, USHORT* inout_len, UCHAR* entry SET_TDBB(tdbb); WIN window(HEADER_PAGE_NUMBER); - pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header); - header_page* header = (header_page*) page; + Ods::pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header); + Ods::header_page* header = (Ods::header_page*) page; const HeaderClumplet clump(header, type); @@ -942,8 +942,8 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) fb_assert(attachment); WIN window(HEADER_PAGE_NUMBER); - pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header); - header_page* header = (header_page*) page; + Ods::pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header); + Ods::header_page* header = (Ods::header_page*) page; try { @@ -961,7 +961,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) BUGCHECK(267); // next transaction older than oldest transaction } - if (header->hdr_flags & hdr_SQL_dialect_3) + if (header->hdr_flags & Ods::hdr_SQL_dialect_3) dbb->dbb_flags |= DBB_DB_SQL_dialect_3; auto* relation = MetadataCache::getPerm(tdbb, 0u, CacheFlag::AUTOCREATE | CacheFlag::NOSCAN); @@ -990,7 +990,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) dbb->dbb_creation_date.utc_timestamp = *(ISC_TIMESTAMP*) header->hdr_creation_date; dbb->dbb_creation_date.time_zone = TimeZoneUtil::GMT_ZONE; - const bool readOnly = header->hdr_flags & hdr_read_only; + const bool readOnly = header->hdr_flags & Ods::hdr_read_only; if (readOnly) { @@ -999,7 +999,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) dbb->dbb_flags |= DBB_read_only; } - // If hdr_read_only is not set... + // If Ods::hdr_read_only is not set... if (!readOnly && (dbb->dbb_flags & DBB_being_opened_read_only)) { // Looks like the Header page says, it is NOT ReadOnly!! But the database @@ -1012,7 +1012,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) // Determine the actual FW mode to be used. Use the setting stored on the header page // unless something different is explicitly specified in DPB. - const bool currentForceWrite = (header->hdr_flags & hdr_force_write) != 0; + const bool currentForceWrite = (header->hdr_flags & Ods::hdr_force_write) != 0; const bool forceWrite = newForceWrite.valueOr(currentForceWrite); // Adjust the flag inside the database block @@ -1028,7 +1028,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) if (dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_normal) dbb->dbb_backup_manager->setForcedWrites(forceWrite); - if (header->hdr_flags & hdr_no_reserve) + if (header->hdr_flags & Ods::hdr_no_reserve) dbb->dbb_flags |= DBB_no_reserve; const auto shutMode = (shut_mode_t) header->hdr_shutdown_mode; @@ -1045,16 +1045,16 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite) // refetch some data from the header, because it could be changed in the delta file // (as initially PAG_init2 reads the header from the main file and these values // may be outdated there) - for (const UCHAR* p = header->hdr_data; *p != HDR_end; p += 2u + p[1]) + for (const UCHAR* p = header->hdr_data; *p != Ods::HDR_end; p += 2u + p[1]) { switch (*p) { - case HDR_sweep_interval: + case Ods::HDR_sweep_interval: fb_assert(p[1] == sizeof(SLONG)); memcpy(&dbb->dbb_sweep_interval, p + 2, sizeof(SLONG)); break; - case HDR_repl_seq: + case Ods::HDR_repl_seq: fb_assert(p[1] == sizeof(FB_UINT64)); memcpy(&dbb->dbb_repl_sequence, p + 2, sizeof(FB_UINT64)); break; @@ -1113,7 +1113,7 @@ void PAG_header_init(thread_db* tdbb) if (!PIO_header(tdbb, temp_page, headerSize)) ERR_post(Arg::Gds(isc_bad_db_format) << Arg::Str(attachment->att_filename)); - const auto* header = (header_page*) temp_page; + const auto* header = (Ods::header_page*) temp_page; if (header->hdr_header.pag_type != pag_header || header->hdr_header.pag_pageno != HEADER_PAGE) ERR_post(Arg::Gds(isc_bad_db_format) << Arg::Str(attachment->att_filename)); @@ -1231,18 +1231,18 @@ void PAG_init2(thread_db* tdbb) const auto dbb = tdbb->getDatabase(); WIN window(HEADER_PAGE_NUMBER); - const auto* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + const auto* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); - for (const UCHAR* p = header->hdr_data; *p != HDR_end; p += 2 + p[1]) + for (const UCHAR* p = header->hdr_data; *p != Ods::HDR_end; p += 2 + p[1]) { switch (*p) { - case HDR_sweep_interval: + case Ods::HDR_sweep_interval: fb_assert(p[1] == sizeof(SLONG)); memcpy(&dbb->dbb_sweep_interval, p + 2, sizeof(SLONG)); break; - case HDR_repl_seq: + case Ods::HDR_repl_seq: fb_assert(p[1] == sizeof(FB_UINT64)); memcpy(&dbb->dbb_repl_sequence, p + 2, sizeof(FB_UINT64)); break; @@ -1324,7 +1324,7 @@ void PAG_release_pages(thread_db* tdbb, USHORT pageSpaceID, int cntRelease, fb_assert(pageSpace); WIN pip_window(pageSpaceID, -1); - page_inv_page* pages = NULL; + Ods::page_inv_page* pages = NULL; ULONG sequence = 0; #ifdef VIO_DEBUG @@ -1359,7 +1359,7 @@ void PAG_release_pages(thread_db* tdbb, USHORT pageSpaceID, int cntRelease, pip_window.win_page = (sequence == 0) ? pageSpace->pipFirst : sequence * pageMgr.pagesPerPIP - 1; - pages = (page_inv_page*) CCH_FETCH(tdbb, &pip_window, LCK_write, pag_pages); + pages = (Ods::page_inv_page*) CCH_FETCH(tdbb, &pip_window, LCK_write, pag_pages); CCH_precedence(tdbb, &pip_window, prior_page); CCH_MARK(tdbb, &pip_window); } @@ -1409,7 +1409,7 @@ void PAG_set_db_guid(thread_db* tdbb, const Guid& guid) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); const auto dbb = tdbb->getDatabase(); @@ -1437,19 +1437,19 @@ void PAG_set_force_write(thread_db* tdbb, bool flag) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); const auto dbb = tdbb->getDatabase(); if (flag) { - header->hdr_flags |= hdr_force_write; + header->hdr_flags |= Ods::hdr_force_write; dbb->dbb_flags |= DBB_force_write; } else { - header->hdr_flags &= ~hdr_force_write; + header->hdr_flags &= ~Ods::hdr_force_write; dbb->dbb_flags &= ~DBB_force_write; } @@ -1482,19 +1482,19 @@ void PAG_set_no_reserve(thread_db* tdbb, bool flag) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); const auto dbb = tdbb->getDatabase(); if (flag) { - header->hdr_flags |= hdr_no_reserve; + header->hdr_flags |= Ods::hdr_no_reserve; dbb->dbb_flags |= DBB_no_reserve; } else { - header->hdr_flags &= ~hdr_no_reserve; + header->hdr_flags &= ~Ods::hdr_no_reserve; dbb->dbb_flags &= ~DBB_no_reserve; } @@ -1518,7 +1518,7 @@ void PAG_set_db_readonly(thread_db* tdbb, bool flag) const auto dbb = tdbb->getDatabase(); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); if (!flag) { @@ -1526,7 +1526,7 @@ void PAG_set_db_readonly(thread_db* tdbb, bool flag) // in-memory Database flag which indicates that the database is RO. // This will allow the CCH subsystem to allow pages to be MARK'ed // for WRITE operations - header->hdr_flags &= ~hdr_read_only; + header->hdr_flags &= ~Ods::hdr_read_only; dbb->dbb_flags &= ~DBB_read_only; // Take into account current attachment ID, else next attachment @@ -1549,7 +1549,7 @@ void PAG_set_db_readonly(thread_db* tdbb, bool flag) if (flag) { - header->hdr_flags |= hdr_read_only; + header->hdr_flags |= Ods::hdr_read_only; dbb->dbb_flags |= DBB_read_only; } @@ -1573,7 +1573,7 @@ void PAG_set_db_replica(thread_db* tdbb, ReplicaMode mode) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - const auto header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + const auto header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); @@ -1582,15 +1582,15 @@ void PAG_set_db_replica(thread_db* tdbb, ReplicaMode mode) switch (mode) { case REPLICA_NONE: - header->hdr_replica_mode = hdr_replica_none; + header->hdr_replica_mode = Ods::hdr_replica_none; break; case REPLICA_READ_ONLY: - header->hdr_replica_mode = hdr_replica_read_only; + header->hdr_replica_mode = Ods::hdr_replica_read_only; break; case REPLICA_READ_WRITE: - header->hdr_replica_mode = hdr_replica_read_write; + header->hdr_replica_mode = Ods::hdr_replica_read_write; break; default: @@ -1619,7 +1619,7 @@ void PAG_set_db_SQL_dialect(thread_db* tdbb, SSHORT flag) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); const auto dbb = tdbb->getDatabase(); @@ -1629,19 +1629,19 @@ void PAG_set_db_SQL_dialect(thread_db* tdbb, SSHORT flag) { case SQL_DIALECT_V5: - if ((dbb->dbb_flags & DBB_DB_SQL_dialect_3) || (header->hdr_flags & hdr_SQL_dialect_3)) + if ((dbb->dbb_flags & DBB_DB_SQL_dialect_3) || (header->hdr_flags & Ods::hdr_SQL_dialect_3)) { // Check the returned value here! ERR_post_warning(Arg::Warning(isc_dialect_reset_warning)); } dbb->dbb_flags &= ~DBB_DB_SQL_dialect_3; // set to 0 - header->hdr_flags &= ~hdr_SQL_dialect_3; // set to 0 + header->hdr_flags &= ~Ods::hdr_SQL_dialect_3; // set to 0 break; case SQL_DIALECT_V6: dbb->dbb_flags |= DBB_DB_SQL_dialect_3; // set to dialect 3 - header->hdr_flags |= hdr_SQL_dialect_3; // set to dialect 3 + header->hdr_flags |= Ods::hdr_SQL_dialect_3; // set to dialect 3 break; default: @@ -1675,7 +1675,7 @@ void PAG_set_page_buffers(thread_db* tdbb, ULONG buffers) ensureDbWritable(tdbb); WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); header->hdr_page_buffers = buffers; CCH_RELEASE(tdbb, &window); @@ -1695,7 +1695,7 @@ void PAG_set_repl_sequence(thread_db* tdbb, FB_UINT64 sequence) * **************************************/ SET_TDBB(tdbb); - storeClump(tdbb, HDR_repl_seq, sizeof(FB_UINT64), (UCHAR*) &sequence); + storeClump(tdbb, Ods::HDR_repl_seq, sizeof(FB_UINT64), (UCHAR*) &sequence); } @@ -1712,7 +1712,7 @@ void PAG_set_sweep_interval(thread_db* tdbb, SLONG interval) * **************************************/ SET_TDBB(tdbb); - storeClump(tdbb, HDR_sweep_interval, sizeof(SLONG), (UCHAR*) &interval); + storeClump(tdbb, Ods::HDR_sweep_interval, sizeof(SLONG), (UCHAR*) &interval); } @@ -1793,13 +1793,13 @@ ULONG PageSpace::lastUsedPage() while (true) { - const pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_undefined); + const Ods::pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_undefined); if (moveUp) { fb_assert(page->pag_type == pag_pages); - const page_inv_page* pip = (page_inv_page*) page; + const Ods::page_inv_page* pip = (Ods::page_inv_page*) page; if (pip->pip_used != pageMgr.pagesPerPIP) break; @@ -1833,7 +1833,7 @@ ULONG PageSpace::lastUsedPage() window.win_page = pipLast; } - const page_inv_page* pip = (page_inv_page*) window.win_buffer; + const Ods::page_inv_page* pip = (Ods::page_inv_page*) window.win_buffer; int last_bit = pip->pip_used; int byte_num = last_bit / 8; @@ -1914,7 +1914,7 @@ ULONG PageSpace::usedPages() while (true) { - const page_inv_page* pip = (page_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_undefined); + const Ods::page_inv_page* pip = (Ods::page_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_undefined); if (pip->pip_header.pag_type != pag_pages) { CCH_RELEASE(tdbb, &window); @@ -2139,7 +2139,7 @@ USHORT PageManager::getTempPageSpaceID(thread_db* tdbb) fb_assert(tempPageSpaceID != 0); if (!tempFileCreated) { - Firebird::MutexLockGuard guard(initTmpMtx, FB_FUNCTION); + MutexLockGuard guard(initTmpMtx, FB_FUNCTION); if (!tempFileCreated) { FbLocalStatus status; @@ -2181,7 +2181,7 @@ ULONG PAG_page_count(thread_db* tdbb) *********************************************/ Database* const dbb = tdbb->getDatabase(); Array temp; - page_inv_page* pip = reinterpret_cast + Ods::page_inv_page* pip = reinterpret_cast (temp.getAlignedBuffer(dbb->dbb_page_size, dbb->getIOBlockSize())); PageSpace* const pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); @@ -2240,14 +2240,14 @@ void PAG_set_page_scn(thread_db* tdbb, win* window) if (scn_page == page_num) { - scns_page* page = (scns_page*) window->win_buffer; + Ods::scns_page* page = (Ods::scns_page*) window->win_buffer; page->scn_pages[scn_slot] = curr_scn; return; } win scn_window(pageSpace->pageSpaceID, scn_page); - scns_page* page = (scns_page*) CCH_FETCH(tdbb, &scn_window, LCK_write, pag_scns); + Ods::scns_page* page = (Ods::scns_page*) CCH_FETCH(tdbb, &scn_window, LCK_write, pag_scns); if (page->scn_pages[scn_slot] != curr_scn) { CCH_MARK(tdbb, &scn_window); @@ -2265,3 +2265,5 @@ void PageNumber::print(const char* text) const } #endif + +} // namespace Firebird::Jrd diff --git a/src/jrd/pag.h b/src/jrd/pag.h index e11daf85d07..01f7d983339 100644 --- a/src/jrd/pag.h +++ b/src/jrd/pag.h @@ -40,7 +40,7 @@ #include "../jrd/ods.h" #include "../jrd/lls.h" -namespace Jrd { +namespace Firebird::Jrd { // Page control block -- used by PAG to keep track of critical constants /** @@ -91,8 +91,8 @@ class PageSpace : public pool_alloc ~PageSpace(); USHORT pageSpaceID; - Firebird::AtomicCounter pipHighWater; // Lowest PIP with space - Firebird::AtomicCounter pipWithExtent; // Lowest PIP with free extent + AtomicCounter pipHighWater; // Lowest PIP with space + AtomicCounter pipWithExtent; // Lowest PIP with free extent ULONG pipFirst; // First pointer page ULONG scnFirst; // First SCN's page @@ -148,7 +148,7 @@ class PageSpace : public pool_alloc class PageManager : public pool_alloc { public: - explicit PageManager(Database* aDbb, Firebird::MemoryPool& aPool) : + explicit PageManager(Database* aDbb, MemoryPool& aPool) : dbb(aDbb), pageSpaces(aPool), pool(aPool) @@ -184,7 +184,7 @@ class PageManager : public pool_alloc ULONG pagesPerSCN; // Slots per SCN's page private: - typedef Firebird::SortedArray, + typedef SortedArray, USHORT, PageSpace> PageSpaceArray; PageSpace* addPageSpace(const USHORT pageSpaceID); @@ -192,8 +192,8 @@ class PageManager : public pool_alloc Database* dbb; PageSpaceArray pageSpaces; - Firebird::MemoryPool& pool; - Firebird::Mutex initTmpMtx; + MemoryPool& pool; + Mutex initTmpMtx; USHORT tempPageSpaceID; bool tempFileCreated; }; @@ -209,7 +209,7 @@ class PageNumber // fb_assert(pageSpaceID != INVALID_PAGE_SPACE); } - // Required to be able to keep it in Firebird::Stack + // Required to be able to keep it in Stack inline PageNumber() noexcept : pageNum(0), pageSpaceID(INVALID_PAGE_SPACE) { } @@ -321,8 +321,8 @@ class PageNumber const PageNumber ZERO_PAGE_NUMBER(DB_PAGE_SPACE, 0); const PageNumber HEADER_PAGE_NUMBER(DB_PAGE_SPACE, HEADER_PAGE); -typedef Firebird::Stack PageStack; +typedef Stack PageStack; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_PAG_H diff --git a/src/jrd/pag_proto.h b/src/jrd/pag_proto.h index 025b7fd2519..c4ed1eaadff 100644 --- a/src/jrd/pag_proto.h +++ b/src/jrd/pag_proto.h @@ -24,7 +24,7 @@ #ifndef JRD_PAG_PROTO_H #define JRD_PAG_PROTO_H -namespace Jrd { +namespace Firebird::Jrd { class thread_db; class Database; class PageNumber; @@ -32,42 +32,46 @@ namespace Jrd { struct win; } -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; struct header_page; } -void PAG_add_header_entry(Jrd::thread_db* tdbb, Ods::header_page*, USHORT, USHORT, const UCHAR*); -bool PAG_replace_entry_first(Jrd::thread_db* tdbb, Ods::header_page*, USHORT, USHORT, const UCHAR*); -Ods::pag* PAG_allocate_pages(Jrd::thread_db* tdbb, Jrd::win* window, unsigned cntAlloc, bool aligned); -AttNumber PAG_attachment_id(Jrd::thread_db*); -bool PAG_delete_clump_entry(Jrd::thread_db* tdbb, USHORT); -void PAG_format_header(Jrd::thread_db*); -void PAG_format_pip(Jrd::thread_db*, Jrd::PageSpace& pageSpace); -bool PAG_get_clump(Jrd::thread_db*, USHORT, USHORT*, UCHAR*); -void PAG_header(Jrd::thread_db*, bool, const Firebird::TriState newForceWrite = Firebird::TriState::empty()); -void PAG_header_init(Jrd::thread_db*); -void PAG_init(Jrd::thread_db*); -void PAG_init2(Jrd::thread_db*); -SLONG PAG_last_page(Jrd::thread_db* tdbb); -void PAG_release_page(Jrd::thread_db* tdbb, const Jrd::PageNumber&, const Jrd::PageNumber&); -void PAG_release_pages(Jrd::thread_db* tdbb, USHORT pageSpaceID, int cntRelease, - const ULONG* pgNums, const ULONG prior_page); -void PAG_set_db_guid(Jrd::thread_db* tdbb, const Firebird::Guid&); -void PAG_set_force_write(Jrd::thread_db* tdbb, bool); -void PAG_set_no_reserve(Jrd::thread_db* tdbb, bool); -void PAG_set_db_readonly(Jrd::thread_db* tdbb, bool); -void PAG_set_db_replica(Jrd::thread_db* tdbb, ReplicaMode); -void PAG_set_db_SQL_dialect(Jrd::thread_db* tdbb, SSHORT); -void PAG_set_page_buffers(Jrd::thread_db* tdbb, ULONG); -void PAG_set_page_scn(Jrd::thread_db* tdbb, Jrd::win* window); -void PAG_set_repl_sequence(Jrd::thread_db* tdbb, FB_UINT64); -void PAG_set_sweep_interval(Jrd::thread_db* tdbb, SLONG); -ULONG PAG_page_count(Jrd::thread_db*); +namespace Firebird::Jrd { -inline Ods::pag* PAG_allocate(Jrd::thread_db* tdbb, Jrd::win* window) +void PAG_add_header_entry(thread_db* tdbb, Ods::header_page*, USHORT, USHORT, const UCHAR*); +bool PAG_replace_entry_first(thread_db* tdbb, Ods::header_page*, USHORT, USHORT, const UCHAR*); +Ods::pag* PAG_allocate_pages(thread_db* tdbb, win* window, unsigned cntAlloc, bool aligned); +AttNumber PAG_attachment_id(thread_db*); +bool PAG_delete_clump_entry(thread_db* tdbb, USHORT); +void PAG_format_header(thread_db*); +void PAG_format_pip(thread_db*, PageSpace& pageSpace); +bool PAG_get_clump(thread_db*, USHORT, USHORT*, UCHAR*); +void PAG_header(thread_db*, bool, const TriState newForceWrite = TriState::empty()); +void PAG_header_init(thread_db*); +void PAG_init(thread_db*); +void PAG_init2(thread_db*); +SLONG PAG_last_page(thread_db* tdbb); +void PAG_release_page(thread_db* tdbb, const PageNumber&, const PageNumber&); +void PAG_release_pages(thread_db* tdbb, USHORT pageSpaceID, int cntRelease, const ULONG* pgNums, const ULONG prior_page); +void PAG_set_db_guid(thread_db* tdbb, const Guid&); +void PAG_set_force_write(thread_db* tdbb, bool); +void PAG_set_no_reserve(thread_db* tdbb, bool); +void PAG_set_db_readonly(thread_db* tdbb, bool); +void PAG_set_db_replica(thread_db* tdbb, ReplicaMode); +void PAG_set_db_SQL_dialect(thread_db* tdbb, SSHORT); +void PAG_set_page_buffers(thread_db* tdbb, ULONG); +void PAG_set_page_scn(thread_db* tdbb, win* window); +void PAG_set_repl_sequence(thread_db* tdbb, FB_UINT64); +void PAG_set_sweep_interval(thread_db* tdbb, SLONG); +ULONG PAG_page_count(thread_db*); + +inline Ods::pag* PAG_allocate(thread_db* tdbb, win* window) { return PAG_allocate_pages(tdbb, window, 1, false); } +} // namespace Firebird::Jrd + + #endif // JRD_PAG_PROTO_H diff --git a/src/jrd/par.cpp b/src/jrd/par.cpp index 549165478a8..c28202928bf 100644 --- a/src/jrd/par.cpp +++ b/src/jrd/par.cpp @@ -72,8 +72,8 @@ #include "../jrd/intl_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ static NodeParseFunc blr_parsers[256] = {NULL}; @@ -728,7 +728,7 @@ CompoundStmtNode* PAR_make_list(thread_db* tdbb, StmtNodeStack& stack) } -ULONG PAR_marks(Jrd::CompilerScratch* csb) +ULONG PAR_marks(CompilerScratch* csb) { if (csb->csb_blr_reader.getByte() != blr_marks) PAR_syntax_error(csb, "blr_marks"); @@ -791,7 +791,7 @@ CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, ULONG blr_length, } -SLONG PAR_symbol_to_gdscode(const Firebird::string& name) +SLONG PAR_symbol_to_gdscode(const string& name) { /************************************** * @@ -1708,7 +1708,7 @@ static void parseSubRoutines(thread_db* tdbb, CompilerScratch* csb) for (auto& pair : csb->subFunctions) { const auto node = pair.second; - Jrd::ContextPoolHolder context(tdbb, &node->subCsb->csb_pool); + JrdContextPoolHolder context(tdbb, &node->subCsb->csb_pool); PAR_blr(tdbb, &csb->csb_schema, nullptr, node->blrStart, node->blrLength, nullptr, &node->subCsb, nullptr, false, 0); } @@ -1716,7 +1716,7 @@ static void parseSubRoutines(thread_db* tdbb, CompilerScratch* csb) for (auto& pair : csb->subProcedures) { const auto node = pair.second; - Jrd::ContextPoolHolder context(tdbb, &node->subCsb->csb_pool); + JrdContextPoolHolder context(tdbb, &node->subCsb->csb_pool); PAR_blr(tdbb, &csb->csb_schema, nullptr, node->blrStart, node->blrLength, nullptr, &node->subCsb, nullptr, false, 0); } @@ -1738,3 +1738,6 @@ static void setNodeLineColumn(CompilerScratch* csb, DmlNode* node, ULONG blrOffs static_cast(node)->hasLineColumn = true; } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/par_proto.h b/src/jrd/par_proto.h index ada47b9a7a5..21a25de9daf 100644 --- a/src/jrd/par_proto.h +++ b/src/jrd/par_proto.h @@ -24,7 +24,10 @@ #ifndef JRD_PAR_PROTO_H #define JRD_PAR_PROTO_H -namespace Jrd { +struct dsc; + +namespace Firebird::Jrd +{ class CompilerScratch; class jrd_rel; class Request; @@ -41,47 +44,45 @@ namespace Jrd { class ValueListNode; using NodeParseFunc = DmlNode* (*)(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); -} - -struct dsc; -Jrd::ValueListNode* PAR_args(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, USHORT); -Jrd::ValueListNode* PAR_args(Jrd::thread_db*, Jrd::CompilerScratch*); -Jrd::DmlNode* PAR_blr(Jrd::thread_db*, const Jrd::MetaName* schema, Jrd::Cached::Relation*, const UCHAR*, ULONG blr_length, - Jrd::CompilerScratch*, Jrd::CompilerScratch**, Jrd::Statement**, const bool, USHORT); -void PAR_preparsed_node(Jrd::thread_db*, Jrd::Cached::Relation*, Jrd::DmlNode*, - Jrd::CompilerScratch*, Jrd::CompilerScratch**, Jrd::Statement**, const bool, USHORT); -Jrd::BoolExprNode* PAR_validation_blr(Jrd::thread_db*, const Jrd::MetaName* schema, Jrd::Cached::Relation*, const UCHAR* blr, - ULONG blr_length, Jrd::CompilerScratch*, Jrd::CompilerScratch**, USHORT); -StreamType PAR_context(Jrd::CompilerScratch*, SSHORT*); -StreamType PAR_context2(Jrd::CompilerScratch*, SSHORT*); -void PAR_dependency(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb, StreamType stream, - SSHORT id, const Jrd::MetaName& field_name); -USHORT PAR_datatype(Jrd::thread_db*, Firebird::BlrReader&, dsc*); -USHORT PAR_desc(Jrd::thread_db*, Jrd::CompilerScratch*, dsc*, Jrd::ItemInfo* = NULL); -void PAR_error(Jrd::CompilerScratch*, const Firebird::Arg::StatusVector&, bool isSyntaxError = true); -SSHORT PAR_find_proc_field(const Jrd::jrd_prc*, const Jrd::MetaName&); -Jrd::ValueExprNode* PAR_gen_field(Jrd::thread_db* tdbb, StreamType stream, USHORT id, bool byId = false); -void PAR_getBlrVersionAndFlags(Jrd::CompilerScratch* csb); -Jrd::ValueExprNode* PAR_make_field(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, const Jrd::MetaName&); -Jrd::CompoundStmtNode* PAR_make_list(Jrd::thread_db*, Jrd::StmtNodeStack&); -ULONG PAR_marks(Jrd::CompilerScratch*); -Jrd::CompilerScratch* PAR_parse(Jrd::thread_db*, const UCHAR* blr, ULONG blr_length, - bool internal_flag, ULONG = 0, const UCHAR* = NULL); + ValueListNode* PAR_args(thread_db*, CompilerScratch*, USHORT, USHORT); + ValueListNode* PAR_args(thread_db*, CompilerScratch*); + DmlNode* PAR_blr(thread_db*, const MetaName* schema, Cached::Relation*, const UCHAR*, ULONG blr_length, + CompilerScratch*, CompilerScratch**, Statement**, const bool, USHORT); + void PAR_preparsed_node(thread_db*, Cached::Relation*, DmlNode*, + CompilerScratch*, CompilerScratch**, Statement**, const bool, USHORT); + BoolExprNode* PAR_validation_blr(thread_db*, const MetaName* schema, Cached::Relation*, const UCHAR* blr, + ULONG blr_length, CompilerScratch*, CompilerScratch**, USHORT); + StreamType PAR_context(CompilerScratch*, SSHORT*); + StreamType PAR_context2(CompilerScratch*, SSHORT*); + void PAR_dependency(thread_db* tdbb, CompilerScratch* csb, StreamType stream, + SSHORT id, const MetaName& field_name); + USHORT PAR_datatype(thread_db*, BlrReader&, dsc*); + USHORT PAR_desc(thread_db*, CompilerScratch*, dsc*, ItemInfo* = NULL); + void PAR_error(CompilerScratch*, const Arg::StatusVector&, bool isSyntaxError = true); + SSHORT PAR_find_proc_field(const jrd_prc*, const MetaName&); + ValueExprNode* PAR_gen_field(thread_db* tdbb, StreamType stream, USHORT id, bool byId = false); + void PAR_getBlrVersionAndFlags(CompilerScratch* csb); + ValueExprNode* PAR_make_field(thread_db*, CompilerScratch*, USHORT, const MetaName&); + CompoundStmtNode* PAR_make_list(thread_db*, StmtNodeStack&); + ULONG PAR_marks(CompilerScratch*); + CompilerScratch* PAR_parse(thread_db*, const UCHAR* blr, ULONG blr_length, + bool internal_flag, ULONG = 0, const UCHAR* = NULL); -Jrd::RecordSourceNode* PAR_parseRecordSource(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb); -Jrd::RseNode* PAR_rse(Jrd::thread_db*, Jrd::CompilerScratch*, SSHORT); -Jrd::RseNode* PAR_rse(Jrd::thread_db*, Jrd::CompilerScratch*); -Jrd::SortNode* PAR_sort(Jrd::thread_db*, Jrd::CompilerScratch*, UCHAR, bool); -Jrd::SortNode* PAR_sort_internal(Jrd::thread_db*, Jrd::CompilerScratch*, bool, USHORT); -SLONG PAR_symbol_to_gdscode(const Firebird::string&); + RecordSourceNode* PAR_parseRecordSource(thread_db* tdbb, CompilerScratch* csb); + RseNode* PAR_rse(thread_db*, CompilerScratch*, SSHORT); + RseNode* PAR_rse(thread_db*, CompilerScratch*); + SortNode* PAR_sort(thread_db*, CompilerScratch*, UCHAR, bool); + SortNode* PAR_sort_internal(thread_db*, CompilerScratch*, bool, USHORT); + SLONG PAR_symbol_to_gdscode(const string&); -Jrd::BoolExprNode* PAR_parse_boolean(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb); -Jrd::ValueExprNode* PAR_parse_value(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb); -Jrd::StmtNode* PAR_parse_stmt(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb); -Jrd::DmlNode* PAR_parse_node(Jrd::thread_db* tdbb, Jrd::CompilerScratch* csb); -void PAR_register(UCHAR blr, Jrd::NodeParseFunc parseFunc); -void PAR_syntax_error(Jrd::CompilerScratch* csb, const TEXT* string); -void PAR_warning(const Firebird::Arg::StatusVector& v); + BoolExprNode* PAR_parse_boolean(thread_db* tdbb, CompilerScratch* csb); + ValueExprNode* PAR_parse_value(thread_db* tdbb, CompilerScratch* csb); + StmtNode* PAR_parse_stmt(thread_db* tdbb, CompilerScratch* csb); + DmlNode* PAR_parse_node(thread_db* tdbb, CompilerScratch* csb); + void PAR_register(UCHAR blr, NodeParseFunc parseFunc); + void PAR_syntax_error(CompilerScratch* csb, const TEXT* string); + void PAR_warning(const Arg::StatusVector& v); +} // namespace Firebird::Jrd #endif // JRD_PAR_PROTO_H diff --git a/src/jrd/que.h b/src/jrd/que.h index b7e4e362eff..50f34996036 100644 --- a/src/jrd/que.h +++ b/src/jrd/que.h @@ -27,7 +27,7 @@ // // general purpose queue // -namespace Jrd { +namespace Firebird::Jrd { struct que { @@ -81,7 +81,7 @@ inline bool QUE_EMPTY(const que& aque) return aque.que_forward == &aque; } -} // namespace Jrd +} // namespace Firebird::Jrd // QUE_LOOP to visit every node. diff --git a/src/jrd/recsrc/AggregatedStream.cpp b/src/jrd/recsrc/AggregatedStream.cpp index dcc5a43337a..f67f5eb510c 100644 --- a/src/jrd/recsrc/AggregatedStream.cpp +++ b/src/jrd/recsrc/AggregatedStream.cpp @@ -31,8 +31,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------ // Data access: aggregation @@ -370,7 +371,7 @@ bool BaseAggWinStream::getNextRecord(thread_db* tdbb, Reques } // Export the template for WindowedStream::WindowStream. -template class Jrd::BaseAggWinStream; +template class BaseAggWinStream; // ------------------------------ @@ -423,3 +424,6 @@ bool AggregatedStream::internalGetRecord(thread_db* tdbb) const rpb->rpb_number.setValid(true); return true; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/BitmapTableScan.cpp b/src/jrd/recsrc/BitmapTableScan.cpp index e7cb01d77fb..5a31b0f76b2 100644 --- a/src/jrd/recsrc/BitmapTableScan.cpp +++ b/src/jrd/recsrc/BitmapTableScan.cpp @@ -28,8 +28,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // --------------------------------------------- // Data access: Bitmap (DBKEY) driven table scan @@ -152,3 +153,6 @@ void BitmapTableScan::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, uns if (m_alias.hasData() && m_alias != string(m_relation()->getName().object)) planEntry.alias = m_alias; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/BufferedStream.cpp b/src/jrd/recsrc/BufferedStream.cpp index c2b54554195..0f312c100bc 100644 --- a/src/jrd/recsrc/BufferedStream.cpp +++ b/src/jrd/recsrc/BufferedStream.cpp @@ -32,8 +32,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // -------------------------- // Data access: record buffer @@ -391,3 +392,6 @@ FB_UINT64 BufferedStream::getCount(thread_db* tdbb) const return impure->irsb_buffer ? impure->irsb_buffer->getCount() : 0; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/ConditionalStream.cpp b/src/jrd/recsrc/ConditionalStream.cpp index 674e1affcea..6a3893f37cc 100644 --- a/src/jrd/recsrc/ConditionalStream.cpp +++ b/src/jrd/recsrc/ConditionalStream.cpp @@ -31,8 +31,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------------ // Data access: predicate driven filter @@ -175,3 +176,6 @@ void ConditionalStream::nullRecords(thread_db* tdbb) const m_first->nullRecords(tdbb); m_second->nullRecords(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/Cursor.cpp b/src/jrd/recsrc/Cursor.cpp index 652f58ac5aa..625af40710d 100644 --- a/src/jrd/recsrc/Cursor.cpp +++ b/src/jrd/recsrc/Cursor.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" #include "Cursor.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + namespace { @@ -107,7 +108,7 @@ void Select::initializeInvariants(Request* request) const } } -void Select::getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const +void Select::getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const { if (m_line || m_column) { @@ -464,3 +465,6 @@ void Cursor::checkState(Request* request) const getName().toQuotedString()); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/Cursor.h b/src/jrd/recsrc/Cursor.h index 886427dba22..0c5b73808f9 100644 --- a/src/jrd/recsrc/Cursor.h +++ b/src/jrd/recsrc/Cursor.h @@ -26,8 +26,7 @@ #include "../common/classes/array.h" #include "../jrd/MetaName.h" -namespace Jrd -{ +namespace Firebird::Jrd { class thread_db; class CompilerScratch; class RecordSource; @@ -68,9 +67,9 @@ namespace Jrd void initializeInvariants(Request* request) const; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; - void printPlan(thread_db* tdbb, Firebird::string& plan, bool detailed) const + void printPlan(thread_db* tdbb, string& plan, bool detailed) const { if (detailed) { diff --git a/src/jrd/recsrc/ExternalTableScan.cpp b/src/jrd/recsrc/ExternalTableScan.cpp index e42b3c0f0f4..a5e700d3ae3 100644 --- a/src/jrd/recsrc/ExternalTableScan.cpp +++ b/src/jrd/recsrc/ExternalTableScan.cpp @@ -30,8 +30,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // -------------------------------- // Data access: external table scan @@ -136,3 +137,6 @@ void ExternalTableScan::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, u if (m_alias.hasData() && m_alias != string(m_relation()->getName().object)) planEntry.alias = m_alias; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/FilteredStream.cpp b/src/jrd/recsrc/FilteredStream.cpp index bfbfd03aa64..838ab9d49d5 100644 --- a/src/jrd/recsrc/FilteredStream.cpp +++ b/src/jrd/recsrc/FilteredStream.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------------ // Data access: predicate driven filter @@ -171,7 +172,7 @@ void FilteredStream::nullRecords(thread_db* tdbb) const m_next->nullRecords(tdbb); } -Firebird::TriState FilteredStream::evaluateBoolean(thread_db* tdbb) const +TriState FilteredStream::evaluateBoolean(thread_db* tdbb) const { Request* const request = tdbb->getRequest(); @@ -373,3 +374,6 @@ Firebird::TriState FilteredStream::evaluateBoolean(thread_db* tdbb) const return nullFlag && !result ? TriState::empty() : TriState(result); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/FirstRowsStream.cpp b/src/jrd/recsrc/FirstRowsStream.cpp index 1c9aaf41ac5..f5984f7979c 100644 --- a/src/jrd/recsrc/FirstRowsStream.cpp +++ b/src/jrd/recsrc/FirstRowsStream.cpp @@ -30,8 +30,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // -------------------------------- // Data access: first N rows filter @@ -163,3 +164,6 @@ void FirstRowsStream::nullRecords(thread_db* tdbb) const { m_next->nullRecords(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/FullOuterJoin.cpp b/src/jrd/recsrc/FullOuterJoin.cpp index aa629249d71..e00dbcf82b1 100644 --- a/src/jrd/recsrc/FullOuterJoin.cpp +++ b/src/jrd/recsrc/FullOuterJoin.cpp @@ -30,8 +30,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ---------------------------- // Data access: full outer join @@ -141,3 +142,6 @@ void FullOuterJoin::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsig Join::internalGetPlan(tdbb, planEntry, level, recurse); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/FullTableScan.cpp b/src/jrd/recsrc/FullTableScan.cpp index 810abec4eb9..4bc2c54c244 100644 --- a/src/jrd/recsrc/FullTableScan.cpp +++ b/src/jrd/recsrc/FullTableScan.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------------------- // Data access: sequential complete table scan @@ -201,3 +202,6 @@ void FullTableScan::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsig if (m_alias.hasData() && m_alias != string(m_relation()->getName().object)) planEntry.alias = m_alias; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/HashJoin.cpp b/src/jrd/recsrc/HashJoin.cpp index 8b416c15742..76497949271 100644 --- a/src/jrd/recsrc/HashJoin.cpp +++ b/src/jrd/recsrc/HashJoin.cpp @@ -34,8 +34,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + //#define PRINT_HASH_TABLE @@ -671,3 +672,6 @@ bool HashJoin::fetchRecord(thread_db* tdbb, Impure* impure, FB_SIZE_T stream) co } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/IndexTableScan.cpp b/src/jrd/recsrc/IndexTableScan.cpp index 61ac3d9bbea..ae4120d94b4 100644 --- a/src/jrd/recsrc/IndexTableScan.cpp +++ b/src/jrd/recsrc/IndexTableScan.cpp @@ -32,8 +32,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------------ // Data access: index driven table scan @@ -777,3 +778,6 @@ bool IndexTableScan::setupBitmaps(thread_db* tdbb, Impure* impure) const return true; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/LocalTableStream.cpp b/src/jrd/recsrc/LocalTableStream.cpp index 5b72e5111cc..f45211f1c63 100644 --- a/src/jrd/recsrc/LocalTableStream.cpp +++ b/src/jrd/recsrc/LocalTableStream.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------ // Data access: local table @@ -132,3 +133,6 @@ void LocalTableStream::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, un planEntry.lines.add().text = "Local Table Full Scan"; printOptInfo(planEntry.lines); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/LockedStream.cpp b/src/jrd/recsrc/LockedStream.cpp index cdcfe8f3556..3a5dda6f9be 100644 --- a/src/jrd/recsrc/LockedStream.cpp +++ b/src/jrd/recsrc/LockedStream.cpp @@ -28,8 +28,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------------ // Data access: stream locked for write @@ -153,3 +154,6 @@ void LockedStream::nullRecords(thread_db* tdbb) const { m_next->nullRecords(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/MergeJoin.cpp b/src/jrd/recsrc/MergeJoin.cpp index 2259731ddad..18ba6de8d27 100644 --- a/src/jrd/recsrc/MergeJoin.cpp +++ b/src/jrd/recsrc/MergeJoin.cpp @@ -27,8 +27,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + static const char* const SCRATCH = "fb_merge_"; @@ -458,3 +459,6 @@ bool MergeJoin::fetchRecord(thread_db* tdbb, FB_SIZE_T index) const return true; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/NestedLoopJoin.cpp b/src/jrd/recsrc/NestedLoopJoin.cpp index 715690c333a..aadbedf6a3c 100644 --- a/src/jrd/recsrc/NestedLoopJoin.cpp +++ b/src/jrd/recsrc/NestedLoopJoin.cpp @@ -28,8 +28,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------ // Data access: nested loops join @@ -286,3 +287,6 @@ bool NestedLoopJoin::fetchRecord(thread_db* tdbb, FB_SIZE_T n) const return true; } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/ProcedureScan.cpp b/src/jrd/recsrc/ProcedureScan.cpp index 06f05e0df6f..39d01649233 100644 --- a/src/jrd/recsrc/ProcedureScan.cpp +++ b/src/jrd/recsrc/ProcedureScan.cpp @@ -34,8 +34,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // --------------------------- // Data access: procedure scan @@ -384,3 +385,6 @@ void ProcedureScan::assignParams(thread_db* tdbb, } } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/RecordSource.cpp b/src/jrd/recsrc/RecordSource.cpp index 158433b52b4..b9d245a729c 100644 --- a/src/jrd/recsrc/RecordSource.cpp +++ b/src/jrd/recsrc/RecordSource.cpp @@ -38,8 +38,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // Disabled so far, should be uncommented for debugging/testing //#define PRINT_OPT_INFO // print optimizer info (cardinality, cost) in plans @@ -355,3 +356,6 @@ void RecordStream::nullRecords(thread_db* tdbb) const record->fakeNulls(); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/RecordSource.h b/src/jrd/recsrc/RecordSource.h index c05d68a9ad8..9eccd821b75 100644 --- a/src/jrd/recsrc/RecordSource.h +++ b/src/jrd/recsrc/RecordSource.h @@ -34,8 +34,7 @@ #include "../jrd/evl_proto.h" #include "../jrd/vio_proto.h" -namespace Jrd -{ +namespace Firebird::Jrd { class thread_db; class Request; class jrd_prc; @@ -80,7 +79,7 @@ namespace Jrd void getPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const; - virtual void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const = 0; + virtual void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const = 0; protected: virtual void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, @@ -94,7 +93,7 @@ namespace Jrd const ULONG m_recSourceId; }; - class PlanEntry final : public Firebird::AutoStorage + class PlanEntry final : public AutoStorage { public: struct Line @@ -104,7 +103,7 @@ namespace Jrd {} unsigned level = 0; - Firebird::string text; + string text; }; public: @@ -116,17 +115,17 @@ namespace Jrd PlanEntry() = default; public: - void getDescriptionAsString(Firebird::string& str, bool initialIndentation = false) const; - void asFlatList(Firebird::Array>& list) const; - void asString(Firebird::string& str) const; + void getDescriptionAsString(string& str, bool initialIndentation = false) const; + void asFlatList(Array>& list) const; + void asString(string& str) const; public: - Firebird::string className{getPool()}; - Firebird::ObjectsArray lines{getPool()}; - Firebird::ObjectsArray children{getPool()}; + string className{getPool()}; + ObjectsArray lines{getPool()}; + ObjectsArray children{getPool()}; std::optional objectType; QualifiedName objectName; - Firebird::string alias{getPool()}; + string alias{getPool()}; const AccessPath* accessPath = nullptr; ULONG recordLength = 0; ULONG keyLength = 0; @@ -178,16 +177,16 @@ namespace Jrd RecordSource(CompilerScratch* csb); - static Firebird::string printName(thread_db* tdbb, const Firebird::string& name, - const Firebird::string& alias = {}); + static string printName(thread_db* tdbb, const string& name, + const string& alias = {}); static void printInversion(thread_db* tdbb, const InversionNode* inversion, - Firebird::ObjectsArray& planLines, + ObjectsArray& planLines, bool detailed, unsigned level, bool navigation); - static void printLegacyInversion(thread_db* tdbb, const InversionNode* inversion, Firebird::string& plan); + static void printLegacyInversion(thread_db* tdbb, const InversionNode* inversion, string& plan); - void printOptInfo(Firebird::ObjectsArray& plan) const; + void printOptInfo(ObjectsArray& plan) const; static void saveRecord(thread_db* tdbb, record_param* rpb); static void restoreRecord(thread_db* tdbb, record_param* rpb); @@ -238,13 +237,13 @@ namespace Jrd }; public: - FullTableScan(CompilerScratch* csb, const Firebird::string& alias, + FullTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation, - const Firebird::Array& dbkeyRanges); + const Array& dbkeyRanges); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -252,9 +251,9 @@ namespace Jrd bool internalGetRecord(thread_db* tdbb) const override; private: - const Firebird::string m_alias; + const string m_alias; const Rsc::Rel m_relation; - Firebird::Array m_dbkeyRanges; + Array m_dbkeyRanges; }; class BitmapTableScan final : public RecordStream @@ -265,13 +264,13 @@ namespace Jrd }; public: - BitmapTableScan(CompilerScratch* csb, const Firebird::string& alias, + BitmapTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation, InversionNode* inversion, double selectivity); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -279,7 +278,7 @@ namespace Jrd bool internalGetRecord(thread_db* tdbb) const override; private: - const Firebird::string m_alias; + const string m_alias; const Rsc::Rel m_relation; NestConst const m_inversion; }; @@ -306,14 +305,14 @@ namespace Jrd }; public: - IndexTableScan(CompilerScratch* csb, const Firebird::string& alias, + IndexTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation, InversionNode* index, USHORT keyLength, double selectivity); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void setInversion(InversionNode* inversion, BoolExprNode* condition) { @@ -339,7 +338,7 @@ namespace Jrd win* window, const UCHAR*, const temporary_key&) const; bool setupBitmaps(thread_db* tdbb, Impure* impure) const; - const Firebird::string m_alias; + const string m_alias; const Rsc::Rel m_relation; NestConst const m_index; NestConst m_inversion; @@ -356,7 +355,7 @@ namespace Jrd }; public: - ExternalTableScan(CompilerScratch* csb, const Firebird::string& alias, + ExternalTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation); void close(thread_db* tdbb) const override; @@ -364,7 +363,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalOpen(thread_db* tdbb) const override; @@ -373,13 +372,13 @@ namespace Jrd private: const Rsc::Rel m_relation; - const Firebird::string m_alias; + const string m_alias; }; class VirtualTableScan : public RecordStream { public: - VirtualTableScan(CompilerScratch* csb, const Firebird::string& alias, + VirtualTableScan(CompilerScratch* csb, const string& alias, StreamType stream, Rsc::Rel relation); void close(thread_db* tdbb) const override; @@ -387,7 +386,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -400,7 +399,7 @@ namespace Jrd private: const Rsc::Rel m_relation; - const Firebird::string m_alias; + const string m_alias; }; class ProcedureScan final : public RecordStream @@ -412,7 +411,7 @@ namespace Jrd }; public: - ProcedureScan(thread_db* tdbb, CompilerScratch* csb, const Firebird::string& alias, + ProcedureScan(thread_db* tdbb, CompilerScratch* csb, const string& alias, StreamType stream, const SubRoutine& procedure, const ValueListNode* sourceList, const ValueListNode* targetList, MessageNode* message); @@ -422,7 +421,7 @@ namespace Jrd WriteLockResult lockRecord(thread_db* tdbb) const override; bool isDependent(const StreamList& streams) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -433,7 +432,7 @@ namespace Jrd void assignParams(thread_db* tdbb, const dsc* from_desc, const dsc* flag_desc, const UCHAR* msg, const dsc* to_desc, SSHORT to_id, Record* record) const; - const Firebird::string m_alias; + const string m_alias; const SubRoutine m_procedure; const ValueListNode* m_sourceList; const ValueListNode* m_targetList; @@ -453,7 +452,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -484,7 +483,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -517,7 +516,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -556,7 +555,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -591,7 +590,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -620,7 +619,7 @@ namespace Jrd const bool m_invariant; private: - Firebird::TriState evaluateBoolean(thread_db* tdbb) const; + TriState evaluateBoolean(thread_db* tdbb) const; NestConst m_next; NestConst const m_boolean; @@ -658,7 +657,7 @@ namespace Jrd static const SSHORT ID_TRANS = -3; // transaction id of record // Sort map block - class SortMap : public Firebird::PermanentStorage + class SortMap : public PermanentStorage { public: struct Item @@ -700,8 +699,8 @@ namespace Jrd ULONG length; // sort record length ULONG keyLength; // key length USHORT flags; // misc sort flags - Firebird::Array keyItems; // address of key descriptors - Firebird::Array items; + Array keyItems; // address of key descriptors + Array items; }; SortedStream(CompilerScratch* csb, RecordSource* next, SortMap* map); @@ -711,7 +710,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -942,7 +941,7 @@ namespace Jrd const NestValueArray* group, MapNode* map, RecordSource* next); public: - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -1012,7 +1011,7 @@ namespace Jrd public: void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void findUsedStreams(StreamList& streams, bool expandAll = false) const override; bool isDependent(const StreamList& streams) const override; @@ -1039,7 +1038,7 @@ namespace Jrd NestConst m_order; const MapNode* m_windowMap; NestConst m_frameExtent; - Firebird::Array > m_arithNodes; + Array > m_arithNodes; NestValueArray m_aggSources, m_aggTargets; NestValueArray m_winPassSources, m_winPassTargets; Exclusion m_exclusion; @@ -1048,14 +1047,14 @@ namespace Jrd public: WindowedStream(thread_db* tdbb, Optimizer* opt, - Firebird::ObjectsArray& windows, RecordSource* next); + ObjectsArray& windows, RecordSource* next); void close(thread_db* tdbb) const override; bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1122,7 +1121,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1147,13 +1146,13 @@ namespace Jrd private: NestConst m_next; - Firebird::HalfStaticArray m_map; + HalfStaticArray m_map; const Format* m_format; }; // Multiplexing (many -> one) access methods - template + template class Join : public RecordSource { public: @@ -1180,7 +1179,7 @@ namespace Jrd if (m_joinType == JoinType::SEMI || m_joinType == JoinType::ANTI) return m_args.front()->lockRecord(tdbb); - Firebird::status_exception::raise(Firebird::Arg::Gds(isc_record_lock_not_supp)); + status_exception::raise(Arg::Gds(isc_record_lock_not_supp)); } void markRecursive() override @@ -1218,7 +1217,7 @@ namespace Jrd arg->nullRecords(tdbb); } - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override { for (const auto& arg : m_args) { @@ -1241,7 +1240,7 @@ namespace Jrd } } - const Firebird::string printType() const + const string printType() const { switch (m_joinType) { @@ -1267,7 +1266,7 @@ namespace Jrd protected: const JoinType m_joinType; const NestConst m_boolean; - Firebird::Array> m_args; + Array> m_args; }; class NestedLoopJoin : public Join @@ -1279,7 +1278,7 @@ namespace Jrd BoolExprNode* boolean); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -1297,7 +1296,7 @@ namespace Jrd const StreamList& checkStreams); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -1342,7 +1341,7 @@ namespace Jrd double selectivity = 0); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; static unsigned maxCapacity() noexcept; @@ -1360,7 +1359,7 @@ namespace Jrd bool fetchRecord(thread_db* tdbb, Impure* impure, FB_SIZE_T stream) const; SubStream m_leader; - Firebird::Array m_subs; + Array m_subs; }; class MergeJoin : public Join @@ -1399,7 +1398,7 @@ namespace Jrd const NestValueArray* const* keys); void close(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -1413,7 +1412,7 @@ namespace Jrd SLONG getRecordByIndex(thread_db* tdbb, FB_SIZE_T index) const; bool fetchRecord(thread_db* tdbb, FB_SIZE_T index) const; - Firebird::Array m_keys; + Array m_keys; }; class LocalTableStream final : public RecordStream @@ -1426,7 +1425,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override; @@ -1454,7 +1453,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1467,8 +1466,8 @@ namespace Jrd bool internalGetRecord(thread_db* tdbb) const override; private: - Firebird::Array > m_args; - Firebird::Array > m_maps; + Array > m_args; + Array > m_maps; StreamList m_streams; }; @@ -1498,7 +1497,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1539,7 +1538,7 @@ namespace Jrd bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1569,11 +1568,11 @@ namespace Jrd public: TableValueFunctionScan(CompilerScratch* csb, StreamType stream, - const Firebird::string& alias); + const string& alias); bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; protected: bool internalGetRecord(thread_db* tdbb) const override; @@ -1583,7 +1582,7 @@ namespace Jrd virtual bool nextBuffer(thread_db* tdbb) const = 0; MetaName m_name; - const Firebird::string m_alias; + const string m_alias; }; class UnlistFunctionScan final : public TableValueFunctionScan @@ -1598,12 +1597,12 @@ namespace Jrd struct Impure final : public TableValueFunctionScan::Impure { blb* m_blob; - Firebird::string* m_separatorStr; - Firebird::string* m_resultStr; + string* m_separatorStr; + string* m_resultStr; }; public: - UnlistFunctionScan(CompilerScratch* csb, StreamType stream, const Firebird::string& alias, + UnlistFunctionScan(CompilerScratch* csb, StreamType stream, const string& alias, ValueListNode* list); protected: @@ -1640,7 +1639,7 @@ namespace Jrd }; public: - GenSeriesFunctionScan(CompilerScratch* csb, StreamType stream, const Firebird::string& alias, + GenSeriesFunctionScan(CompilerScratch* csb, StreamType stream, const string& alias, ValueListNode* list); protected: diff --git a/src/jrd/recsrc/RecursiveStream.cpp b/src/jrd/recsrc/RecursiveStream.cpp index 44c18c78ce5..3e37f4e32d0 100644 --- a/src/jrd/recsrc/RecursiveStream.cpp +++ b/src/jrd/recsrc/RecursiveStream.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ---------------------------- // Data access: recursive union @@ -321,3 +322,6 @@ void RecursiveStream::cleanupLevel(Request* request, Impure* impure) const delete[] tmp; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/SingularStream.cpp b/src/jrd/recsrc/SingularStream.cpp index c5b961afff1..48ff4396299 100644 --- a/src/jrd/recsrc/SingularStream.cpp +++ b/src/jrd/recsrc/SingularStream.cpp @@ -26,8 +26,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------ // Data access: single row stream @@ -189,3 +190,6 @@ void SingularStream::nullRecords(thread_db* tdbb) const { m_next->nullRecords(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/SkipRowsStream.cpp b/src/jrd/recsrc/SkipRowsStream.cpp index 1ebc2650bdc..1729dd8f10d 100644 --- a/src/jrd/recsrc/SkipRowsStream.cpp +++ b/src/jrd/recsrc/SkipRowsStream.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------- // Data access: skip N rows filter @@ -159,3 +160,6 @@ void SkipRowsStream::nullRecords(thread_db* tdbb) const { m_next->nullRecords(tdbb); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/SortedStream.cpp b/src/jrd/recsrc/SortedStream.cpp index f4c7ab1d388..09f27f238ab 100644 --- a/src/jrd/recsrc/SortedStream.cpp +++ b/src/jrd/recsrc/SortedStream.cpp @@ -36,8 +36,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ----------------------------- // Data access: external sorting @@ -619,3 +620,6 @@ void SortedStream::mapData(thread_db* tdbb, Request* request, UCHAR* data) const VIO_copy_record(tdbb, relation, tempRecord, record); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/TableValueFunctionScan.cpp b/src/jrd/recsrc/TableValueFunctionScan.cpp index b0b5bbe30b3..0d3225e419d 100644 --- a/src/jrd/recsrc/TableValueFunctionScan.cpp +++ b/src/jrd/recsrc/TableValueFunctionScan.cpp @@ -31,8 +31,9 @@ #include "RecordSource.h" #include -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + TableValueFunctionScan::TableValueFunctionScan(CompilerScratch* csb, StreamType stream, const string& alias) @@ -532,3 +533,6 @@ bool GenSeriesFunctionScan::nextBuffer(thread_db* tdbb) const return false; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/Union.cpp b/src/jrd/recsrc/Union.cpp index c7fbb29ac6c..4ee33e88205 100644 --- a/src/jrd/recsrc/Union.cpp +++ b/src/jrd/recsrc/Union.cpp @@ -26,8 +26,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // -------------------------- // Data access: regular union @@ -222,3 +223,6 @@ bool Union::isDependent(const StreamList& streams) const return false; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/VirtualTableScan.cpp b/src/jrd/recsrc/VirtualTableScan.cpp index 8e2298beda8..ace91c0350a 100644 --- a/src/jrd/recsrc/VirtualTableScan.cpp +++ b/src/jrd/recsrc/VirtualTableScan.cpp @@ -29,8 +29,9 @@ #include "RecordSource.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------- // Data access: virtual table scan @@ -134,3 +135,6 @@ void VirtualTableScan::internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, un if (m_alias.hasData() && m_alias != string(m_relation()->getName().object)) planEntry.alias = m_alias; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/recsrc/WindowedStream.cpp b/src/jrd/recsrc/WindowedStream.cpp index 7063e9bdeaf..6f6378a16db 100644 --- a/src/jrd/recsrc/WindowedStream.cpp +++ b/src/jrd/recsrc/WindowedStream.cpp @@ -31,8 +31,9 @@ #include "RecordSource.h" #include -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ + // ------------------------------ // Data access: window expression @@ -57,7 +58,7 @@ namespace bool refetchRecord(thread_db* tdbb) const override; WriteLockResult lockRecord(thread_db* tdbb) const override; - void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override; + void getLegacyPlan(thread_db* tdbb, string& plan, unsigned level) const override; void markRecursive() override; void invalidateRecords(Request* request) const override; @@ -1163,3 +1164,6 @@ bool SlidingWindow::moveWithinFrame(SINT64 delta) return moveWithinPartition(delta); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/replication/Applier.cpp b/src/jrd/replication/Applier.cpp index e28e2a52d4f..02c56f7c8c2 100644 --- a/src/jrd/replication/Applier.cpp +++ b/src/jrd/replication/Applier.cpp @@ -49,16 +49,15 @@ #include "Publisher.h" #include "Utils.h" +namespace Firebird::Jrd::Replication +{ + // Log conflicts as warnings #define LOG_CONFLICTS // Detect and resolve record-level conflicts (in favor of master copy) #define RESOLVE_CONFLICTS -using namespace Firebird; -using namespace Ods; -using namespace Jrd; -using namespace Replication; namespace { @@ -202,11 +201,11 @@ namespace } }; - class LocalThreadContext : Firebird::ContextPoolHolder + class LocalThreadContext : ContextPoolHolder { public: LocalThreadContext(thread_db* tdbb, jrd_tra* tra, Request* req = NULL) - : Firebird::ContextPoolHolder(req ? req->req_pool : tdbb->getDefaultPool()), + : ContextPoolHolder(req ? req->req_pool : tdbb->getDefaultPool()), m_tdbb(tdbb) { tdbb->setTransaction(tra); @@ -243,7 +242,7 @@ Applier* Applier::create(thread_db* tdbb) try { - Jrd::ContextPoolHolder context(tdbb, req_pool); + JrdContextPoolHolder context(tdbb, req_pool); AutoPtr csb(FB_NEW_POOL(*req_pool) CompilerScratch(*req_pool)); request = Statement::makeRequest(tdbb, csb, true); @@ -549,7 +548,7 @@ void Applier::insertRecord(thread_db* tdbb, TraNumber traNum, raiseError("Transaction %" SQUADFORMAT" is not found", traNum); LocalThreadContext context(tdbb, transaction, m_request); - Jrd::ContextPoolHolder context2(tdbb, m_request->req_pool); + JrdContextPoolHolder context2(tdbb, m_request->req_pool); const auto attachment = tdbb->getAttachment(); TRA_attach_request(transaction, m_request); @@ -713,7 +712,7 @@ void Applier::updateRecord(thread_db* tdbb, TraNumber traNum, raiseError("Transaction %" SQUADFORMAT" is not found", traNum); LocalThreadContext context(tdbb, transaction, m_request); - Jrd::ContextPoolHolder context2(tdbb, m_request->req_pool); + JrdContextPoolHolder context2(tdbb, m_request->req_pool); const auto attachment = tdbb->getAttachment(); TRA_attach_request(transaction, m_request); @@ -859,7 +858,7 @@ void Applier::deleteRecord(thread_db* tdbb, TraNumber traNum, raiseError("Transaction %" SQUADFORMAT" is not found", traNum); LocalThreadContext context(tdbb, transaction, m_request); - Jrd::ContextPoolHolder context2(tdbb, m_request->req_pool); + JrdContextPoolHolder context2(tdbb, m_request->req_pool); const auto attachment = tdbb->getAttachment(); TRA_attach_request(transaction, m_request); @@ -1055,7 +1054,7 @@ bool Applier::lookupKey(thread_db* tdbb, Cached::Relation* relation, index_desc& const PageNumber root_page(relPages->rel_pg_space_id, page); win window(root_page); - const auto root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_root); + const auto root = (Ods::index_root_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_root); index_desc idx; idx.idx_id = key.idx_id = idx_invalid; @@ -1277,7 +1276,7 @@ void Applier::doInsert(thread_db* tdbb, record_param* rpb, jrd_tra* transaction) VIO_store(tdbb, rpb, transaction); IDX_store(tdbb, rpb, transaction); if (m_enableCascade) - REPL_store(tdbb, rpb, transaction); + Replication::REPL_store(tdbb, rpb, transaction); } void Applier::doUpdate(thread_db* tdbb, record_param* orgRpb, record_param* newRpb, @@ -1376,7 +1375,7 @@ void Applier::doUpdate(thread_db* tdbb, record_param* orgRpb, record_param* newR VIO_modify(tdbb, orgRpb, newRpb, transaction); IDX_modify(tdbb, orgRpb, newRpb, transaction); if (m_enableCascade) - REPL_modify(tdbb, orgRpb, newRpb, transaction); + Replication::REPL_modify(tdbb, orgRpb, newRpb, transaction); } void Applier::doDelete(thread_db* tdbb, record_param* rpb, jrd_tra* transaction) @@ -1389,7 +1388,7 @@ void Applier::doDelete(thread_db* tdbb, record_param* rpb, jrd_tra* transaction) VIO_erase(tdbb, rpb, transaction); if (m_enableCascade) - REPL_erase(tdbb, rpb, transaction); + Replication::REPL_erase(tdbb, rpb, transaction); } void Applier::logConflict(const char* msg, ...) @@ -1405,3 +1404,6 @@ void Applier::logConflict(const char* msg, ...) logReplicaWarning(m_database, buffer); #endif } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Applier.h b/src/jrd/replication/Applier.h index f6609268750..699d5f7b245 100644 --- a/src/jrd/replication/Applier.h +++ b/src/jrd/replication/Applier.h @@ -32,15 +32,14 @@ #include "Utils.h" -namespace Jrd -{ - class Applier : private Firebird::PermanentStorage +namespace Firebird::Jrd::Replication { + class Applier : private PermanentStorage { - typedef Firebird::GenericMap > > TransactionMap; - typedef Firebird::HalfStaticArray BlobList; - typedef Firebird::GenericMap ConstraintIndexMap; + typedef GenericMap > > TransactionMap; + typedef HalfStaticArray BlobList; + typedef GenericMap ConstraintIndexMap; /* - class ReplicatedTransaction : public Firebird::IReplicatedTransaction + class ReplicatedTransaction : public IReplicatedTransaction { public: // IDispose methods @@ -80,25 +79,25 @@ namespace Jrd } bool insertRecord(const char* name, - Firebird::IReplicatedRecord* record) + IReplicatedRecord* record) { return m_applier->insertRecord(this, name, record); } bool updateRecord(const char* name, - Firebird::IReplicatedRecord* orgRecord, - Firebird::IReplicatedRecord* newRecord) + IReplicatedRecord* orgRecord, + IReplicatedRecord* newRecord) { return m_applier->updateRecord(this, name, orgRecord, newRecord); } bool deleteRecord(const char* name, - Firebird::IReplicatedRecord* record) + IReplicatedRecord* record) { return m_applier->insertRecord(this, name, record); } - bool storeBlob(ISC_QUAD blobId, Firebird::IReplicatedBlob* blob) + bool storeBlob(ISC_QUAD blobId, IReplicatedBlob* blob) { return m_applier->storeBlob(this, blobId, blob); } @@ -125,8 +124,8 @@ namespace Jrd }; */ public: - Applier(Firebird::MemoryPool& pool, - const Firebird::PathName& database, + Applier(MemoryPool& pool, + const PathName& database, Request* request, bool cascade) : PermanentStorage(pool), m_txnMap(pool), m_database(pool, database), @@ -152,7 +151,7 @@ namespace Jrd private: TransactionMap m_txnMap; - const Firebird::PathName m_database; + const PathName m_database; Request* m_request; RecordBitmap* m_bitmap = nullptr; Record* m_record = nullptr; @@ -186,8 +185,8 @@ namespace Jrd void executeSql(thread_db* tdbb, TraNumber traNum, CSetId charset, - const Firebird::string& schemaSearchPath, - const Firebird::string& sql, + const string& schemaSearchPath, + const string& sql, const MetaName& owner); bool lookupKey(thread_db* tdbb, Cached::Relation* relation, index_desc& idx); diff --git a/src/jrd/replication/ChangeLog.cpp b/src/jrd/replication/ChangeLog.cpp index 735d474df9f..439c952c9ff 100644 --- a/src/jrd/replication/ChangeLog.cpp +++ b/src/jrd/replication/ChangeLog.cpp @@ -56,9 +56,9 @@ #define O_BINARY 0 #endif -using namespace Firebird; -using namespace Jrd; -using namespace Replication; +namespace Firebird::Jrd::Replication +{ + #if !defined(WIN_NT) && !defined(LINUX) #pragma FB_COMPILER_MESSAGE("Add support for your platform!") @@ -1105,3 +1105,6 @@ ChangeLog::Segment* ChangeLog::getSegment(ULONG length) return NULL; } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/ChangeLog.h b/src/jrd/replication/ChangeLog.h index 87bd1eea7b7..37d7287621c 100644 --- a/src/jrd/replication/ChangeLog.h +++ b/src/jrd/replication/ChangeLog.h @@ -33,7 +33,7 @@ #include "Utils.h" -namespace Replication +namespace Firebird::Jrd::Replication { struct Config; @@ -60,11 +60,11 @@ namespace Replication inline constexpr USHORT CHANGELOG_VERSION_1 = 1; inline constexpr USHORT CHANGELOG_CURRENT_VERSION = CHANGELOG_VERSION_1; - class ChangeLog : protected Firebird::PermanentStorage, public Firebird::IpcObject + class ChangeLog : protected PermanentStorage, public IpcObject { // Shared state of the changelog - struct State : public Firebird::MemoryHeader + struct State : public MemoryHeader { ULONG version; // changelog version time_t timestamp; // timestamp of last write @@ -137,16 +137,16 @@ namespace Replication // Changelog segment (physical file on disk) - class Segment : public Firebird::RefCounted + class Segment : public RefCounted { public: - Segment(MemoryPool& pool, const Firebird::PathName& filename, int handle); + Segment(MemoryPool& pool, const PathName& filename, int handle); virtual ~Segment(); - void init(FB_UINT64 sequence, const Firebird::Guid& guid); - bool validate(const Firebird::Guid& guid) const; + void init(FB_UINT64 sequence, const Guid& guid); + bool validate(const Guid& guid) const; void append(ULONG length, const UCHAR* data); - void copyTo(const Firebird::PathName& filename) const; + void copyTo(const PathName& filename) const; bool isEmpty() const noexcept { @@ -178,9 +178,9 @@ namespace Replication void truncate(); void flush(bool data); - Firebird::PathName getFileName() const; + PathName getFileName() const; - const Firebird::PathName& getPathName() const noexcept + const PathName& getPathName() const noexcept { return m_filename; } @@ -191,7 +191,7 @@ namespace Replication void mapHeader(); void unmapHeader(); - Firebird::PathName m_filename; + PathName m_filename; int m_handle; SegmentHeader* m_header; SegmentHeader m_builtinHeader; // used by free segments when there is no mapping @@ -202,9 +202,9 @@ namespace Replication }; public: - ChangeLog(Firebird::MemoryPool& pool, - const Firebird::string& dbId, - const Firebird::Guid& guid, + ChangeLog(MemoryPool& pool, + const string& dbId, + const Guid& guid, const FB_UINT64 sequence, const Config* config); virtual ~ChangeLog(); @@ -224,10 +224,10 @@ namespace Replication void linkSelf(); bool unlinkSelf(); - bool initialize(Firebird::SharedMemoryBase* shmem, bool init) override; + bool initialize(SharedMemoryBase* shmem, bool init) override; void mutexBug(int osErrorCode, const char* text) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_CHANGELOG_STATE; } + USHORT getType() const override { return SharedMemoryBase::SRAM_CHANGELOG_STATE; } USHORT getVersion() const override { return STATE_VERSION; }; const char* getName() const override { return "ChangeLog"; } @@ -248,18 +248,18 @@ namespace Replication void switchActiveSegment(); - const Firebird::string& m_dbId; - const Firebird::Guid& m_guid; + const string& m_dbId; + const Guid& m_guid; const Config* const m_config; - Firebird::Array m_segments; - Firebird::AutoPtr > m_sharedMemory; - Firebird::Mutex m_localMutex; + Array m_segments; + AutoPtr > m_sharedMemory; + Mutex m_localMutex; const FB_UINT64 m_sequence; ULONG m_generation; - Firebird::Semaphore m_startupSemaphore; - Firebird::Semaphore m_cleanupSemaphore; - Firebird::Semaphore m_workingSemaphore; + Semaphore m_startupSemaphore; + Semaphore m_cleanupSemaphore; + Semaphore m_workingSemaphore; volatile bool m_shutdown; }; diff --git a/src/jrd/replication/Config.cpp b/src/jrd/replication/Config.cpp index bd35d5c8266..313a7ab22f8 100644 --- a/src/jrd/replication/Config.cpp +++ b/src/jrd/replication/Config.cpp @@ -28,7 +28,7 @@ #include "../common/StatusArg.h" #include "../common/utils_proto.h" #include "../common/os/os_utils.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "Utils.h" #include "Config.h" @@ -46,8 +46,9 @@ #include #include -using namespace Firebird; -using namespace Replication; +namespace Firebird::Jrd::Replication +{ + namespace { @@ -555,3 +556,6 @@ void Config::splitConnectionString(const string& input, string& database, string } } } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Config.h b/src/jrd/replication/Config.h index 7a6e4f2ba59..6428a3a627d 100644 --- a/src/jrd/replication/Config.h +++ b/src/jrd/replication/Config.h @@ -31,7 +31,7 @@ #include "../common/classes/fb_string.h" #include "../common/os/guid.h" -namespace Replication +namespace Firebird::Jrd::Replication { struct SyncReplica { @@ -43,45 +43,45 @@ namespace Replication : database(p, other.database), username(p, other.username), password(p, other.password) {} - Firebird::string database; - Firebird::string username; - Firebird::string password; + string database; + string username; + string password; }; - struct Config : public Firebird::GlobalStorage + struct Config : public GlobalStorage { - typedef Firebird::HalfStaticArray ReplicaList; + typedef HalfStaticArray ReplicaList; Config(); Config(const Config& other); - static Config* get(const Firebird::PathName& dbName); + static Config* get(const PathName& dbName); static void enumerate(ReplicaList& replicas); - static void splitConnectionString(const Firebird::string& input, Firebird::string& database, - Firebird::string& username, Firebird::string& password); + static void splitConnectionString(const string& input, string& database, + string& username, string& password); - Firebird::PathName dbName; + PathName dbName; ULONG bufferSize; - Firebird::string includeSchemaFilter; - Firebird::string excludeSchemaFilter; - Firebird::string includeFilter; - Firebird::string excludeFilter; + string includeSchemaFilter; + string excludeSchemaFilter; + string includeFilter; + string excludeFilter; ULONG segmentSize; ULONG segmentCount; - Firebird::PathName journalDirectory; - Firebird::PathName filePrefix; + PathName journalDirectory; + PathName filePrefix; ULONG groupFlushDelay; - Firebird::PathName archiveDirectory; - Firebird::string archiveCommand; + PathName archiveDirectory; + string archiveCommand; ULONG archiveTimeout; - Firebird::ObjectsArray syncReplicas; - Firebird::PathName sourceDirectory; - std::optional sourceGuid; + ObjectsArray syncReplicas; + PathName sourceDirectory; + std::optional sourceGuid; bool verboseLogging; ULONG applyIdleTimeout; ULONG applyErrorTimeout; - Firebird::string schemaSearchPath; - Firebird::string pluginName; + string schemaSearchPath; + string pluginName; bool logErrors; bool reportErrors; bool disableOnError; diff --git a/src/jrd/replication/Manager.cpp b/src/jrd/replication/Manager.cpp index 610fe213d8b..3b7931ccd9c 100644 --- a/src/jrd/replication/Manager.cpp +++ b/src/jrd/replication/Manager.cpp @@ -31,14 +31,9 @@ #include "Protocol.h" #include "Utils.h" -using namespace Firebird; -using namespace Jrd; -using namespace Replication; - -namespace Replication +namespace Firebird::Jrd::Replication { constexpr size_t MAX_BG_WRITER_LAG = 10 * 1024 * 1024; // 10 MB -} // Table matcher @@ -121,7 +116,7 @@ bool TableMatcher::matchTable(const QualifiedName& tableName) // Replication manager Manager::Manager(const string& dbId, - const Replication::Config* config) + const Config* config) : m_config(config), m_replicas(getPool()), m_buffers(getPool()), @@ -413,8 +408,11 @@ void Manager::bgWriter() { m_cleanupSemaphore.release(); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { iscLogException("Error while exiting replicator thread", ex); } } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Manager.h b/src/jrd/replication/Manager.h index 12b02ce9111..beaf3806745 100644 --- a/src/jrd/replication/Manager.h +++ b/src/jrd/replication/Manager.h @@ -35,52 +35,52 @@ #include "Config.h" #include "ChangeLog.h" -namespace Replication +namespace Firebird::Jrd::Replication { class TableMatcher { - typedef Firebird::GenericMap > > TablePermissionMap; + typedef GenericMap > > TablePermissionMap; public: TableMatcher(MemoryPool& pool, - const Firebird::string& includeSchemaFilter, - const Firebird::string& excludeSchemaFilter, - const Firebird::string& includeFilter, - const Firebird::string& excludeFilter); + const string& includeSchemaFilter, + const string& excludeSchemaFilter, + const string& includeFilter, + const string& excludeFilter); bool matchTable(const Jrd::QualifiedName& tableName); private: - Firebird::AutoPtr m_includeSchemaMatcher; - Firebird::AutoPtr m_excludeSchemaMatcher; - Firebird::AutoPtr m_includeMatcher; - Firebird::AutoPtr m_excludeMatcher; + AutoPtr m_includeSchemaMatcher; + AutoPtr m_excludeSchemaMatcher; + AutoPtr m_includeMatcher; + AutoPtr m_excludeMatcher; TablePermissionMap m_tables; }; - class Manager final : public Firebird::GlobalStorage + class Manager final : public GlobalStorage { struct SyncReplica { - SyncReplica(Firebird::MemoryPool& pool, Firebird::IAttachment* att, Firebird::IReplicator* repl) + SyncReplica(MemoryPool& pool, IAttachment* att, IReplicator* repl) : status(pool), attachment(att), replicator(repl) {} - Firebird::FbLocalStatus status; - Firebird::IAttachment* attachment; - Firebird::IReplicator* replicator; + FbLocalStatus status; + IAttachment* attachment; + IReplicator* replicator; }; public: - Manager(const Firebird::string& dbId, const Replication::Config* config); + Manager(const string& dbId, const Config* config); ~Manager(); void shutdown(); - Firebird::UCharBuffer* getBuffer(); - void releaseBuffer(Firebird::UCharBuffer* buffer); + UCharBuffer* getBuffer(); + void releaseBuffer(UCharBuffer* buffer); - void flush(Firebird::UCharBuffer* buffer, bool sync, bool prepare); + void flush(UCharBuffer* buffer, bool sync, bool prepare); void forceJournalSwitch() { @@ -94,7 +94,7 @@ namespace Replication m_changeLog->cleanup(); } - const Replication::Config* getConfig() const noexcept + const Config* getConfig() const noexcept { return m_config; } @@ -109,24 +109,24 @@ namespace Replication return 0; } - Firebird::Semaphore m_startupSemaphore; - Firebird::Semaphore m_cleanupSemaphore; - Firebird::Semaphore m_workingSemaphore; + Semaphore m_startupSemaphore; + Semaphore m_cleanupSemaphore; + Semaphore m_workingSemaphore; - const Replication::Config* const m_config; - Firebird::Array m_replicas; - Firebird::Array m_buffers; - Firebird::Mutex m_buffersMutex; - Firebird::Array m_queue; - Firebird::Mutex m_queueMutex; + const Config* const m_config; + Array m_replicas; + Array m_buffers; + Mutex m_buffersMutex; + Array m_queue; + Mutex m_queueMutex; ULONG m_queueSize; FB_UINT64 m_sequence; volatile bool m_shutdown; volatile bool m_signalled; - Firebird::AutoPtr m_changeLog; - Firebird::RWLock m_lock; + AutoPtr m_changeLog; + RWLock m_lock; }; } diff --git a/src/jrd/replication/Protocol.h b/src/jrd/replication/Protocol.h index 9e5f708b673..f6818f3124e 100644 --- a/src/jrd/replication/Protocol.h +++ b/src/jrd/replication/Protocol.h @@ -24,7 +24,7 @@ #ifndef JRD_REPLICATION_PROTOCOL_H #define JRD_REPLICATION_PROTOCOL_H -namespace Replication +namespace Firebird::Jrd::Replication { // Supported protocol versions inline constexpr USHORT PROTOCOL_VERSION_1 = 1; diff --git a/src/jrd/replication/Publisher.cpp b/src/jrd/replication/Publisher.cpp index c8c4caf1696..2eb5117b525 100644 --- a/src/jrd/replication/Publisher.cpp +++ b/src/jrd/replication/Publisher.cpp @@ -40,9 +40,9 @@ #include "Replicator.h" #include -using namespace Firebird; -using namespace Jrd; -using namespace Replication; +namespace Firebird::Jrd::Replication +{ + namespace { @@ -412,7 +412,7 @@ void REPL_attach(thread_db* tdbb, bool cleanupTransactions) attachment->att_flags |= ATT_replicating; if (cleanupTransactions) - REPL_trans_cleanup(tdbb, 0); + Replication::REPL_trans_cleanup(tdbb, 0); // else defer creation of replicator till really needed } @@ -720,3 +720,6 @@ void REPL_journal_cleanup(Database* dbb) if (const auto replMgr = dbb->replManager(true)) replMgr->journalCleanup(); } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Publisher.h b/src/jrd/replication/Publisher.h index c69d25215b9..d4a470eee1b 100644 --- a/src/jrd/replication/Publisher.h +++ b/src/jrd/replication/Publisher.h @@ -23,7 +23,7 @@ #ifndef JRD_REPLICATION_PUBLISHER_H #define JRD_REPLICATION_PUBLISHER_H -namespace Jrd +namespace Firebird::Jrd { class thread_db; class jrd_tra; @@ -32,22 +32,25 @@ namespace Jrd struct record_param; } -void REPL_attach(Jrd::thread_db* tdbb, bool cleanupTransactions); -void REPL_trans_prepare(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void REPL_trans_commit(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void REPL_trans_rollback(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); -void REPL_trans_cleanup(Jrd::thread_db* tdbb, TraNumber number); -void REPL_save_cleanup(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, - const Jrd::Savepoint* savepoint, bool undo); -void REPL_store(Jrd::thread_db* tdbb, const Jrd::record_param* rpb, - Jrd::jrd_tra* transaction); -void REPL_modify(Jrd::thread_db* tdbb, const Jrd::record_param* orgRpb, - const Jrd::record_param* newRpb, Jrd::jrd_tra* transaction); -void REPL_erase(Jrd::thread_db* tdbb, const Jrd::record_param* rpb, Jrd::jrd_tra* transaction); -void REPL_gen_id(Jrd::thread_db* tdbb, SLONG genId, SINT64 value, Jrd::jrd_tra* transaction); -void REPL_exec_sql(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, const Firebird::string& sql, - const Firebird::ObjectsArray& schemaSearchPath); -void REPL_journal_switch(Jrd::thread_db* tdbb); -void REPL_journal_cleanup(Jrd::Database* dbb); +namespace Firebird::Jrd::Replication +{ + void REPL_attach(thread_db* tdbb, bool cleanupTransactions); + void REPL_trans_prepare(thread_db* tdbb, jrd_tra* transaction); + void REPL_trans_commit(thread_db* tdbb, jrd_tra* transaction); + void REPL_trans_rollback(thread_db* tdbb, jrd_tra* transaction); + void REPL_trans_cleanup(thread_db* tdbb, TraNumber number); + void REPL_save_cleanup(thread_db* tdbb, jrd_tra* transaction, + const Savepoint* savepoint, bool undo); + void REPL_store(thread_db* tdbb, const record_param* rpb, + jrd_tra* transaction); + void REPL_modify(thread_db* tdbb, const record_param* orgRpb, + const record_param* newRpb, jrd_tra* transaction); + void REPL_erase(thread_db* tdbb, const record_param* rpb, jrd_tra* transaction); + void REPL_gen_id(thread_db* tdbb, SLONG genId, SINT64 value, jrd_tra* transaction); + void REPL_exec_sql(thread_db* tdbb, jrd_tra* transaction, const string& sql, + const ObjectsArray& schemaSearchPath); + void REPL_journal_switch(thread_db* tdbb); + void REPL_journal_cleanup(Database* dbb); +} // namespace Firebird::Jrd::Replication #endif // JRD_REPLICATION_PUBLISHER_H diff --git a/src/jrd/replication/Replicator.cpp b/src/jrd/replication/Replicator.cpp index e0ee95027e5..00e693e22fe 100644 --- a/src/jrd/replication/Replicator.cpp +++ b/src/jrd/replication/Replicator.cpp @@ -28,9 +28,8 @@ #include "Replicator.h" #include "Utils.h" -using namespace Firebird; -using namespace Jrd; -using namespace Replication; +namespace Firebird::Jrd::Replication +{ Replicator::Replicator(MemoryPool& pool, @@ -494,3 +493,6 @@ void Replicator::setSequence2(CheckStatusWrapper* status, ex.stuffException(status); } } + + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Replicator.h b/src/jrd/replication/Replicator.h index 6bbce609af7..beaf4b1bb81 100644 --- a/src/jrd/replication/Replicator.h +++ b/src/jrd/replication/Replicator.h @@ -34,13 +34,13 @@ #include "Manager.h" #include -namespace Replication +namespace Firebird::Jrd::Replication { class Replicator final : - public Firebird::StdPlugin > + public StdPlugin > { - typedef Firebird::ObjectsArray NameCache; - typedef Firebird::HalfStaticArray SavepointStack; + typedef ObjectsArray NameCache; + typedef HalfStaticArray SavepointStack; struct GeneratorValue { @@ -48,12 +48,12 @@ namespace Replication SINT64 value = 0; }; - typedef Firebird::Array GeneratorCache; + typedef Array GeneratorCache; struct BatchBlock { Block header{}; - Firebird::UCharBuffer* buffer; + UCharBuffer* buffer; NameCache atoms; ULONG lastAtom; ULONG flushes; @@ -97,7 +97,7 @@ namespace Replication buffer->add(ptr, sizeof(SINT64)); } - ULONG defineAtom(const Firebird::string& name) + ULONG defineAtom(const string& name) { if (lastAtom < atoms.getCount() && atoms[lastAtom] == name) return lastAtom; @@ -115,7 +115,7 @@ namespace Replication return lastAtom; } - std::pair defineQualifiedAtom(const Firebird::QualifiedMetaString& name) + std::pair defineQualifiedAtom(const QualifiedMetaString& name) { const auto schemaAtom = defineAtom(name.schema); const auto objectAtom = defineAtom(name.object); @@ -123,7 +123,7 @@ namespace Replication return std::make_pair(schemaAtom, objectAtom); } - void putMetaName(const Firebird::MetaString& name) + void putMetaName(const MetaString& name) { const auto length = name.length(); fb_assert(length <= MAX_UCHAR); @@ -131,7 +131,7 @@ namespace Replication buffer->add((const UCHAR*) name.c_str(), length); } - void putString(const Firebird::string& str) + void putString(const string& str) { const auto length = str.length(); putInt32(length); @@ -161,10 +161,10 @@ namespace Replication }; class Transaction final : - public Firebird::AutoIface > + public AutoIface > { public: - explicit Transaction(Replicator* replicator, Firebird::ITransaction* trans) + explicit Transaction(Replicator* replicator, ITransaction* trans) : m_replicator(replicator), m_transaction(trans), m_data(replicator->getPool()) {} @@ -173,7 +173,7 @@ namespace Replication return m_data; } - Firebird::ITransaction* getInterface() noexcept + ITransaction* getInterface() noexcept { return m_transaction.getPtr(); } @@ -188,85 +188,85 @@ namespace Replication // IReplicatedTransaction methods - void prepare(Firebird::CheckStatusWrapper* status) override + void prepare(CheckStatusWrapper* status) override { m_replicator->prepareTransaction(status, this); } - void commit(Firebird::CheckStatusWrapper* status) override + void commit(CheckStatusWrapper* status) override { m_replicator->commitTransaction(status, this); } - void rollback(Firebird::CheckStatusWrapper* status) override + void rollback(CheckStatusWrapper* status) override { m_replicator->rollbackTransaction(status, this); } - void startSavepoint(Firebird::CheckStatusWrapper* status) override + void startSavepoint(CheckStatusWrapper* status) override { m_replicator->startSavepoint(status, this); } - void releaseSavepoint(Firebird::CheckStatusWrapper* status) override + void releaseSavepoint(CheckStatusWrapper* status) override { m_replicator->releaseSavepoint(status, this); } - void rollbackSavepoint(Firebird::CheckStatusWrapper* status) override + void rollbackSavepoint(CheckStatusWrapper* status) override { m_replicator->rollbackSavepoint(status, this); } - void deprecatedInsertRecord(Firebird::CheckStatusWrapper* status, const char* name, - Firebird::IReplicatedRecord* record) override + void deprecatedInsertRecord(CheckStatusWrapper* status, const char* name, + IReplicatedRecord* record) override { insertRecord2(status, nullptr, name, record); } - void insertRecord2(Firebird::CheckStatusWrapper* status, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* record) override + void insertRecord2(CheckStatusWrapper* status, const char* schemaName, const char* tableName, + IReplicatedRecord* record) override { m_replicator->insertRecord(status, this, schemaName, tableName, record); } - void deprecatedUpdateRecord(Firebird::CheckStatusWrapper* status, const char* name, - Firebird::IReplicatedRecord* orgRecord, Firebird::IReplicatedRecord* newRecord) override + void deprecatedUpdateRecord(CheckStatusWrapper* status, const char* name, + IReplicatedRecord* orgRecord, IReplicatedRecord* newRecord) override { updateRecord2(status, nullptr, name, orgRecord, newRecord); } - void updateRecord2(Firebird::CheckStatusWrapper* status, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* orgRecord, - Firebird::IReplicatedRecord* newRecord) override + void updateRecord2(CheckStatusWrapper* status, const char* schemaName, const char* tableName, + IReplicatedRecord* orgRecord, + IReplicatedRecord* newRecord) override { m_replicator->updateRecord(status, this, schemaName, tableName, orgRecord, newRecord); } - void deprecatedDeleteRecord(Firebird::CheckStatusWrapper* status, const char* name, - Firebird::IReplicatedRecord* record) override + void deprecatedDeleteRecord(CheckStatusWrapper* status, const char* name, + IReplicatedRecord* record) override { deleteRecord2(status, nullptr, name, record); } - void deleteRecord2(Firebird::CheckStatusWrapper* status, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* record) override + void deleteRecord2(CheckStatusWrapper* status, const char* schemaName, const char* tableName, + IReplicatedRecord* record) override { m_replicator->deleteRecord(status, this, schemaName, tableName, record); } - void deprecatedExecuteSql(Firebird::CheckStatusWrapper* status, const char* sql) override + void deprecatedExecuteSql(CheckStatusWrapper* status, const char* sql) override { m_replicator->executeSql(status, this, sql); } - void deprecatedExecuteSqlIntl(Firebird::CheckStatusWrapper* status, unsigned charset, + void deprecatedExecuteSqlIntl(CheckStatusWrapper* status, unsigned charset, const char* sql) override { executeSqlIntl2(status, charset, "", sql); } - void executeSqlIntl2(Firebird::CheckStatusWrapper* status, unsigned charset, const char* schemaSearchPath, + void executeSqlIntl2(CheckStatusWrapper* status, unsigned charset, const char* schemaSearchPath, const char* sql) override { m_replicator->executeSqlIntl(status, this, charset, schemaSearchPath, sql); @@ -274,7 +274,7 @@ namespace Replication private: Replicator* const m_replicator; - Firebird::RefPtr m_transaction; + RefPtr m_transaction; BatchBlock m_data; }; @@ -286,38 +286,38 @@ namespace Replication }; public: - Replicator(Firebird::MemoryPool& pool, + Replicator(MemoryPool& pool, Manager* manager, - const Firebird::Guid& dbGuid, - const Firebird::MetaString& userName); + const Guid& dbGuid, + const MetaString& userName); // IReplicatedSession methods - FB_BOOLEAN init(Firebird::CheckStatusWrapper* /*status*/, Firebird::IAttachment* att) override + FB_BOOLEAN init(CheckStatusWrapper* /*status*/, IAttachment* att) override { m_attachment = att; return FB_TRUE; } - Firebird::IReplicatedTransaction* startTransaction(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* trans, SINT64 number) override; - void cleanupTransaction(Firebird::CheckStatusWrapper* status, SINT64 number) override; + IReplicatedTransaction* startTransaction(CheckStatusWrapper* status, ITransaction* trans, SINT64 number) override; + void cleanupTransaction(CheckStatusWrapper* status, SINT64 number) override; - void deprecatedSetSequence(Firebird::CheckStatusWrapper* status, const char* name, SINT64 value) override + void deprecatedSetSequence(CheckStatusWrapper* status, const char* name, SINT64 value) override { setSequence2(status, nullptr, name, value); } - void setSequence2(Firebird::CheckStatusWrapper* status, const char* schemaName, const char* genName, + void setSequence2(CheckStatusWrapper* status, const char* schemaName, const char* genName, SINT64 value) override; private: Manager* const m_manager; const Config* const m_config; - Firebird::Guid m_guid; - const Firebird::MetaString m_user; - Firebird::Array m_transactions; + Guid m_guid; + const MetaString m_user; + Array m_transactions; GeneratorCache m_generators; - Firebird::RefPtr m_attachment; + RefPtr m_attachment; void initialize(); void flush(BatchBlock& txnData, FlushReason reason, ULONG flags = 0); @@ -325,32 +325,32 @@ namespace Replication void storeBlob(Transaction* transaction, ISC_QUAD blobId); void releaseTransaction(Transaction* transaction); - void prepareTransaction(Firebird::CheckStatusWrapper* status, Transaction* transaction); - void commitTransaction(Firebird::CheckStatusWrapper* status, Transaction* transaction); - void rollbackTransaction(Firebird::CheckStatusWrapper* status, Transaction* transaction); + void prepareTransaction(CheckStatusWrapper* status, Transaction* transaction); + void commitTransaction(CheckStatusWrapper* status, Transaction* transaction); + void rollbackTransaction(CheckStatusWrapper* status, Transaction* transaction); - void startSavepoint(Firebird::CheckStatusWrapper* status, Transaction* transaction); - void releaseSavepoint(Firebird::CheckStatusWrapper* status, Transaction* transaction); - void rollbackSavepoint(Firebird::CheckStatusWrapper* status, Transaction* transaction); + void startSavepoint(CheckStatusWrapper* status, Transaction* transaction); + void releaseSavepoint(CheckStatusWrapper* status, Transaction* transaction); + void rollbackSavepoint(CheckStatusWrapper* status, Transaction* transaction); - void insertRecord(Firebird::CheckStatusWrapper* status, Transaction* transaction, + void insertRecord(CheckStatusWrapper* status, Transaction* transaction, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* record); - void updateRecord(Firebird::CheckStatusWrapper* status, Transaction* transaction, + IReplicatedRecord* record); + void updateRecord(CheckStatusWrapper* status, Transaction* transaction, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* orgRecord, - Firebird::IReplicatedRecord* newRecord); - void deleteRecord(Firebird::CheckStatusWrapper* status, Transaction* transaction, + IReplicatedRecord* orgRecord, + IReplicatedRecord* newRecord); + void deleteRecord(CheckStatusWrapper* status, Transaction* transaction, const char* schemaName, const char* tableName, - Firebird::IReplicatedRecord* record); + IReplicatedRecord* record); - void executeSql(Firebird::CheckStatusWrapper* status, Transaction* transaction, + void executeSql(CheckStatusWrapper* status, Transaction* transaction, const char* sql) { executeSqlIntl(status, transaction, CS_UTF8, "", sql); } - void executeSqlIntl(Firebird::CheckStatusWrapper* status, Transaction* transaction, + void executeSqlIntl(CheckStatusWrapper* status, Transaction* transaction, unsigned charset, const char* schemaSearchPath, const char* sql); diff --git a/src/jrd/replication/Utils.cpp b/src/jrd/replication/Utils.cpp index 1c3f36fc3bc..416496bad27 100644 --- a/src/jrd/replication/Utils.cpp +++ b/src/jrd/replication/Utils.cpp @@ -29,7 +29,7 @@ #include "../common/ScanDir.h" #include "../common/os/mod_loader.h" #include "../common/os/path_utils.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "Utils.h" @@ -51,8 +51,9 @@ #include #include -using namespace Firebird; -using namespace Replication; +namespace Firebird::Jrd::Replication +{ + namespace { @@ -215,8 +216,7 @@ namespace } // namespace -namespace Replication -{ + void raiseError(const char* msg, ...) { char buffer[BUFFER_LARGE]; @@ -291,4 +291,5 @@ namespace Replication logMessage(REPLICA_SIDE, VERBOSE_MSG, database, message); } -} // namespace + +} // namespace Firebird::Jrd::Replication diff --git a/src/jrd/replication/Utils.h b/src/jrd/replication/Utils.h index 96fc9da1807..eb4e6b61c76 100644 --- a/src/jrd/replication/Utils.h +++ b/src/jrd/replication/Utils.h @@ -32,7 +32,7 @@ #include -namespace Replication +namespace Firebird::Jrd::Replication { enum LogMsgSide { @@ -48,28 +48,28 @@ namespace Replication }; [[noreturn]] void raiseError(const char* msg, ...); - int executeShell(const Firebird::string& command); + int executeShell(const string& command); - void logPrimaryError(const Firebird::PathName& database, - const Firebird::string& message); + void logPrimaryError(const PathName& database, + const string& message); - void logPrimaryWarning(const Firebird::PathName& database, - const Firebird::string& message); + void logPrimaryWarning(const PathName& database, + const string& message); - void logPrimaryStatus(const Firebird::PathName& database, - const Firebird::CheckStatusWrapper* status); + void logPrimaryStatus(const PathName& database, + const CheckStatusWrapper* status); - void logReplicaError(const Firebird::PathName& database, - const Firebird::string& message); + void logReplicaError(const PathName& database, + const string& message); - void logReplicaWarning(const Firebird::PathName& database, - const Firebird::string& message); + void logReplicaWarning(const PathName& database, + const string& message); - void logReplicaStatus(const Firebird::PathName& database, - const Firebird::CheckStatusWrapper* status); + void logReplicaStatus(const PathName& database, + const CheckStatusWrapper* status); - void logReplicaVerbose(const Firebird::PathName& database, - const Firebird::string& message); + void logReplicaVerbose(const PathName& database, + const string& message); class AutoFile { diff --git a/src/jrd/req.h b/src/jrd/req.h index 0be07103dda..ed37b8ac04b 100644 --- a/src/jrd/req.h +++ b/src/jrd/req.h @@ -37,11 +37,11 @@ #include "../common/classes/timestamp.h" #include "../common/TimeZoneUtil.h" -namespace EDS { +namespace Firebird::Jrd::EDS { class Statement; } -namespace Jrd { +namespace Firebird::Jrd { class Lock; class jrd_rel; @@ -176,7 +176,7 @@ inline constexpr USHORT RPB_CLEAR_FLAGS = (RPB_UNDO_FLAGS | RPB_just_deleted | R // List of active blobs controlled by request -typedef Firebird::BePlusTree TempBlobIdTree; +typedef BePlusTree TempBlobIdTree; // Affected rows counter class @@ -271,7 +271,7 @@ class Request : public pool_alloc timeStamp.utc_timestamp = gmtTimeStamp.value(); timeStamp.time_zone = timeZone; - timeTz = Firebird::TimeZoneUtil::timeStampTzToTimeTz(timeStamp); + timeTz = TimeZoneUtil::timeStampTzToTimeTz(timeStamp); localTime = timeTz.utc_time; localTimeValid = true; @@ -284,7 +284,7 @@ class Request : public pool_alloc { if (gmtTimeStamp.isEmpty()) { - Firebird::TimeZoneUtil::validateGmtTimeStamp(gmtTimeStamp); + TimeZoneUtil::validateGmtTimeStamp(gmtTimeStamp); update(currentTimeZone, false); } } @@ -294,7 +294,7 @@ class Request : public pool_alloc { if (updateLocalTimeStamp) { - localTimeStamp = Firebird::TimeZoneUtil::timeStampTzToTimeStamp( + localTimeStamp = TimeZoneUtil::timeStampTzToTimeStamp( getTimeStampTz(currentTimeZone), currentTimeZone); } @@ -304,7 +304,7 @@ class Request : public pool_alloc } private: - Firebird::TimeStamp gmtTimeStamp; // Start time of request in GMT time zone + TimeStamp gmtTimeStamp; // Start time of request in GMT time zone mutable bool localTimeStampValid = false; // localTimeStamp calculation is expensive. So is it valid (calculated)? mutable bool localTimeValid = false; // localTime calculation is expensive. So is it valid (calculated)? @@ -353,7 +353,7 @@ class Request : public pool_alloc }; public: - Request(Firebird::AutoMemoryPool& pool, Database* dbb, /*const*/ Statement* aStatement); + Request(AutoMemoryPool& pool, Database* dbb, /*const*/ Statement* aStatement); private: ~Request(); // destroyed only by pool @@ -403,7 +403,7 @@ class Request : public pool_alloc public: MemoryPool* req_pool; - Firebird::MemoryStats req_memory_stats; + MemoryStats req_memory_stats; Attachment* req_attachment; // database attachment USHORT req_incarnation; // incarnation number @@ -429,16 +429,16 @@ class Request : public pool_alloc const StmtNode* req_next; // next node for execution EDS::Statement* req_ext_stmt; // head of list of active dynamic statements - Firebird::Array req_cursors; // named cursors + Array req_cursors; // named cursors ExtEngineManager::ResultSet* req_ext_resultset; // external result set USHORT req_label; // label for leave ULONG req_flags; // misc request flags Savepoint* req_savepoints; // Looper savepoint list Savepoint* req_proc_sav_point; // procedure savepoint list unsigned int req_timeout; // query timeout in milliseconds, set by the DsqlRequest::setupTimer - Firebird::RefPtr req_timer; // timeout timer, shared with DsqlRequest + RefPtr req_timer; // timeout timer, shared with DsqlRequest - Firebird::AutoPtr req_fetch_baseline; // State of request performance counters when we reported it last time + AutoPtr req_fetch_baseline; // State of request performance counters when we reported it last time SINT64 req_fetch_elapsed; // Number of clock ticks spent while fetching rows for this request since we reported it last time SINT64 req_fetch_rowcount; // Total number of rows returned by this request Request* req_proc_caller; // Procedure's caller request @@ -449,25 +449,25 @@ class Request : public pool_alloc ULONG req_src_column; dsc* req_domain_validation; // Current VALUE for constraint validation - Firebird::Stack req_auto_trans; // Autonomous transactions + Stack req_auto_trans; // Autonomous transactions SortOwner req_sorts; - Firebird::Array req_rpb; // record parameter blocks - Firebird::Array impureArea; // impure area + Array req_rpb; // record parameter blocks + Array impureArea; // impure area TriggerAction req_trigger_action; // action that caused trigger to fire SnapshotData req_snapshot; StatusXcp req_last_xcp; // last known exception bool req_batch_mode; private: - Firebird::RefPtr req_resources; + RefPtr req_resources; public: - const Firebird::RefPtr& getResources() + const RefPtr& getResources() { return req_resources; } - typedef Firebird::Array RecordParameters; + typedef Array RecordParameters; void setResources(VersionedObjects* r, RecordParameters& rpbsSetup); enum req_s { @@ -573,7 +573,7 @@ inline constexpr ULONG req_reserved = 0x400L; // Request reserved for client inline constexpr ULONG req_update_conflict = 0x800L; // We need to restart request due to update conflict inline constexpr ULONG req_restart_ready = 0x1000L; // Request is ready to restart in case of update conflict -} //namespace Jrd +} // namespace Firebird::Jrd namespace Firebird { diff --git a/src/jrd/rlck.cpp b/src/jrd/rlck.cpp index 18b8a15d6c9..3035d48843c 100644 --- a/src/jrd/rlck.cpp +++ b/src/jrd/rlck.cpp @@ -32,8 +32,9 @@ #include "../jrd/lck.h" #include "../jrd/rlck_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + Lock* RLCK_reserve_relation(thread_db* tdbb, jrd_tra* transaction, Cached::Relation* relation, bool write_flag) { @@ -177,3 +178,6 @@ Lock* RLCK_transaction_relation_lock(thread_db* tdbb, jrd_tra* transaction, Cach return lock; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/rlck_proto.h b/src/jrd/rlck_proto.h index 69486b4997b..73d6b5bbe9c 100644 --- a/src/jrd/rlck_proto.h +++ b/src/jrd/rlck_proto.h @@ -24,18 +24,18 @@ #ifndef JRD_RLCK_PROTO_H #define JRD_RLCK_PROTO_H -namespace Jrd { +#include "../jrd/Resources.h" + +namespace Firebird::Jrd +{ class Lock; class jrd_tra; struct record_param; class Attachment; class thread_db; -} -#include "../jrd/Resources.h" - -Jrd::Lock* RLCK_reserve_relation(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::Cached::Relation*, bool); -Jrd::Lock* RLCK_transaction_relation_lock(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::Cached::Relation*); + Lock* RLCK_reserve_relation(thread_db*, jrd_tra*, Cached::Relation*, bool); + Lock* RLCK_transaction_relation_lock(thread_db*, jrd_tra*, Cached::Relation*); +} // namespace Firebird::Jrd #endif // JRD_RLCK_PROTO_H - diff --git a/src/jrd/rpb_chain.cpp b/src/jrd/rpb_chain.cpp index c7214481815..a2e61c2b862 100644 --- a/src/jrd/rpb_chain.cpp +++ b/src/jrd/rpb_chain.cpp @@ -23,8 +23,6 @@ #include "firebird.h" #include "../jrd/rpb_chain.h" -using namespace Jrd; - #ifdef DEV_BUILD #define ExecAssert(x) fb_assert(x) #else // DEV_BUILD @@ -33,6 +31,10 @@ using namespace Jrd; // rpb_chain.h includes req.h => struct record_param. +namespace Firebird::Jrd +{ + + int traRpbList::PushRpb(record_param* value) { if (value->rpb_relation->rel_view_rse || // this is view @@ -73,3 +75,5 @@ bool traRpbList::PopRpb(record_param* value, int Level) return rc; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/rpb_chain.h b/src/jrd/rpb_chain.h index 1b63aed3628..9944a8d5607 100644 --- a/src/jrd/rpb_chain.h +++ b/src/jrd/rpb_chain.h @@ -32,7 +32,7 @@ // req.h defines struct record_param -namespace Jrd { +namespace Firebird::Jrd { class traRpbListElement { @@ -60,20 +60,20 @@ class traRpbListElement }; -typedef Firebird::SortedArray, traRpbListElement, +typedef SortedArray, traRpbListElement, traRpbListElement, traRpbListElement> traRpbArray; class traRpbList : public traRpbArray { public: - explicit traRpbList(Firebird::MemoryPool& p) + explicit traRpbList(MemoryPool& p) : traRpbArray(p) {} int PushRpb(record_param* value); bool PopRpb(record_param* value, int Level); }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif //JRD_RPB_CHAIN_H diff --git a/src/jrd/sbm.h b/src/jrd/sbm.h index a5ffe167e41..ed82f37e8aa 100644 --- a/src/jrd/sbm.h +++ b/src/jrd/sbm.h @@ -31,19 +31,19 @@ #include "../common/classes/sparse_bitmap.h" -namespace Jrd { +namespace Firebird::Jrd { // Bitmap of record numbers -typedef Firebird::SparseBitmap RecordBitmap; +typedef SparseBitmap RecordBitmap; // Bitmap of page numbers -typedef Firebird::SparseBitmap PageBitmap; +typedef SparseBitmap PageBitmap; // Bitmap of generic 32-bit integers -typedef Firebird::SparseBitmap UInt32Bitmap; +typedef SparseBitmap UInt32Bitmap; // Bitmap of transaction numbers -typedef Firebird::SparseBitmap TransactionBitmap; +typedef SparseBitmap TransactionBitmap; // Please do not try to turn these macros to inline routines simply. // They are used in very performance-sensitive places and we don't want @@ -68,7 +68,7 @@ typedef Firebird::SparseBitmap TransactionBitmap; #define TBM_SET(POOL_PTR, BITMAP_PPTR, VALUE) \ (*(BITMAP_PPTR) ? *(BITMAP_PPTR) : (*(BITMAP_PPTR) = FB_NEW_POOL(*(POOL_PTR)) Jrd::TransactionBitmap(*(POOL_PTR))))->set(VALUE) -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SBM_H diff --git a/src/jrd/scl.epp b/src/jrd/scl.epp index 174e8ac9891..50b66b0990f 100644 --- a/src/jrd/scl.epp +++ b/src/jrd/scl.epp @@ -36,7 +36,7 @@ #include "../jrd/acl.h" #include "../jrd/blb.h" #include "../jrd/irq.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/req.h" #include "../jrd/tra.h" #include "../jrd/met.h" @@ -51,7 +51,7 @@ #include "../jrd/met_proto.h" #include "../jrd/grant_proto.h" #include "../jrd/scl_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "fb_exception.h" #include "../common/utils_proto.h" #include "../common/classes/array.h" @@ -64,11 +64,12 @@ inline constexpr int UIC_BASE = 10; -using namespace Jrd; -using namespace Firebird; - DATABASE DB = FILENAME "ODS.RDB"; +namespace Firebird::Jrd +{ + + static bool check_number(const UCHAR*, USHORT); static bool check_user_group(thread_db* tdbb, const UCHAR*, USHORT); static bool check_string(const UCHAR*, const MetaName&); @@ -120,7 +121,7 @@ static void raiseError(thread_db* tdbb, SecurityClass::flags_t mask, ObjectType } const char* const ddlObjectName = getDdlObjectName(type); - const Firebird::string fullName = col_name.hasData() ? + const string fullName = col_name.hasData() ? name.toQuotedString() + "." + col_name.toQuotedString() : name.toQuotedString(); Arg::StatusVector status; @@ -1218,7 +1219,7 @@ void SCL_clear_classes(thread_db* tdbb, const MetaName& name) return; MetaNamePair key(name, {}); - if (!list->locate(Firebird::locGreatEqual, key)) + if (!list->locate(locGreatEqual, key)) return; while (list->current()->sclClassUser.first == name) @@ -1362,7 +1363,7 @@ static bool check_user_group(thread_db* tdbb, const UCHAR* acl, USHORT number) } else // processing group name { - Firebird::string user_group_name; + string user_group_name; do { const TEXT one_char = *acl++; user_group_name += LOWWER(one_char); @@ -1724,7 +1725,7 @@ static SecurityClass::flags_t walk_acl(thread_db* tdbb, return privilege; } -void UserId::populateDpb(Firebird::ClumpletWriter& dpb, bool embeddedSupport) +void UserId::populateDpb(ClumpletWriter& dpb, bool embeddedSupport) { if (usr_auth_block.hasData()) dpb.insertBytes(isc_dpb_auth_block, usr_auth_block.begin(), usr_auth_block.getCount()); @@ -1735,7 +1736,7 @@ void UserId::populateDpb(Firebird::ClumpletWriter& dpb, bool embeddedSupport) dpb.insertString(isc_dpb_sql_role_name, usr_sql_role_name); } -void UserId::makeRoleName(Firebird::MetaString& role, const int dialect) +void UserId::makeRoleName(MetaString& role, const int dialect) { if (role.isEmpty()) return; @@ -1747,7 +1748,7 @@ void UserId::makeRoleName(Firebird::MetaString& role, const int dialect) // For unquoted string nothing bad happens fb_utils::dpbItemUpper(role); { - Firebird::string tmp(role); + string tmp(role); tmp.upper(); role = tmp; } @@ -1764,7 +1765,7 @@ void UserId::makeRoleName(Firebird::MetaString& role, const int dialect) } // get privilege bit by name -USHORT SCL_convert_privilege(thread_db* tdbb, jrd_tra* transaction, const Firebird::string& priv) +USHORT SCL_convert_privilege(thread_db* tdbb, jrd_tra* transaction, const string& priv) { static GlobalPtr privCacheMutex; static bool cacheFlag = false; @@ -1817,3 +1818,5 @@ static bool check_object(thread_db* tdbb, return found; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/scl.h b/src/jrd/scl.h index 99633b4ac7c..c84e6062540 100644 --- a/src/jrd/scl.h +++ b/src/jrd/scl.h @@ -28,14 +28,14 @@ #include "../jrd/QualifiedName.h" #include "../common/classes/tree.h" #include "../common/security.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/SystemPrivileges.h" namespace Firebird { class ClumpletWriter; } -namespace Jrd { +namespace Firebird::Jrd { class thread_db; @@ -49,7 +49,7 @@ class SecurityClass typedef ULONG flags_t; enum BlobAccessCheck { BA_UNKNOWN, BA_SUCCESS, BA_FAILURE }; - SecurityClass(Firebird::MemoryPool& pool, const MetaName& name, const MetaName& userName) + SecurityClass(MemoryPool& pool, const MetaName& name, const MetaName& userName) : scl_flags(0), sclClassUser(pool, {name, userName}), scl_blb_access(BA_UNKNOWN) {} @@ -63,7 +63,7 @@ class SecurityClass } }; -typedef Firebird::BePlusTree SecurityClassList; +typedef BePlusTree SecurityClassList; inline constexpr SecurityClass::flags_t SCL_select = 1; // SELECT access @@ -198,16 +198,16 @@ class UserId typedef Bits Privileges; private: - Firebird::MetaString usr_user_name; // User name - Firebird::MetaString usr_sql_role_name; // Role name - mutable Firebird::SortedArray usr_granted_roles; // Granted roles list - Firebird::MetaString usr_trusted_role; // Trusted role if set - Firebird::MetaString usr_init_role; // Initial role, assigned at sclInit() + MetaString usr_user_name; // User name + MetaString usr_sql_role_name; // Role name + mutable SortedArray usr_granted_roles; // Granted roles list + MetaString usr_trusted_role; // Trusted role if set + MetaString usr_init_role; // Initial role, assigned at sclInit() public: - Firebird::string usr_project_name; // Project name - Firebird::string usr_org_name; // Organization name - Firebird::string usr_auth_method; // Authentication method + string usr_project_name; // Project name + string usr_org_name; // Organization name + string usr_auth_method; // Authentication method private: mutable Privileges usr_privileges; // Privileges granted to user by default @@ -225,7 +225,7 @@ class UserId : usr_user_id(0), usr_group_id(0), usr_flags(0) {} - UserId(Firebird::MemoryPool& p, const UserId& ui) + UserId(MemoryPool& p, const UserId& ui) : usr_user_name(p, ui.usr_user_name), usr_sql_role_name(p, ui.usr_sql_role_name), usr_granted_roles(p), @@ -245,7 +245,7 @@ class UserId usr_granted_roles = ui.usr_granted_roles; } - UserId(Firebird::MemoryPool& p) + UserId(MemoryPool& p) : usr_user_name(p), usr_sql_role_name(p), usr_granted_roles(p), @@ -300,7 +300,7 @@ class UserId return *this; } - void populateDpb(Firebird::ClumpletWriter& dpb, bool embeddedSupport); + void populateDpb(ClumpletWriter& dpb, bool embeddedSupport); bool locksmith(thread_db* tdbb, ULONG sp) const { @@ -311,7 +311,7 @@ class UserId void sclInit(thread_db* tdbb, bool create); - void setUserName(const Firebird::MetaString& userName) + void setUserName(const MetaString& userName) { if (userName != usr_user_name) { @@ -320,22 +320,22 @@ class UserId } } - const Firebird::MetaString& getUserName() const + const MetaString& getUserName() const { return usr_user_name; } - void setTrustedRole(const Firebird::MetaString& roleName) + void setTrustedRole(const MetaString& roleName) { usr_trusted_role = roleName; } - const Firebird::MetaString& getTrustedRole() const + const MetaString& getTrustedRole() const { return usr_trusted_role; } - void setSqlRole(const Firebird::MetaString& roleName) + void setSqlRole(const MetaString& roleName) { if (roleName != usr_sql_role_name) { @@ -344,7 +344,7 @@ class UserId } } - const Firebird::MetaString& getSqlRole() const + const MetaString& getSqlRole() const { return usr_sql_role_name; } @@ -388,13 +388,13 @@ class UserId usr_flags |= mask; } - static void makeRoleName(Firebird::MetaString& role, const int dialect); + static void makeRoleName(MetaString& role, const int dialect); private: void findGrantedRoles(thread_db* tdbb) const; }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SCL_H diff --git a/src/jrd/scl_proto.h b/src/jrd/scl_proto.h index 8e0597a4cbf..c11a370fae8 100644 --- a/src/jrd/scl_proto.h +++ b/src/jrd/scl_proto.h @@ -29,48 +29,47 @@ #include "../common/classes/fb_string.h" #include "../jrd/MetaName.h" -//namespace Jrd { -// class SecurityClass; -//} - struct dsc; -void SCL_check_access(Jrd::thread_db*, const Jrd::SecurityClass*, - SLONG, const Jrd::QualifiedName&, - Jrd::SecurityClass::flags_t, ObjectType type, bool recursive, const Jrd::QualifiedName&, - const Jrd::MetaName& = {}); -void SCL_check_create_access(Jrd::thread_db*, ObjectType type, const Jrd::MetaName& schema); -void SCL_check_charset(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, Jrd::SecurityClass::flags_t); -void SCL_check_collation(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, Jrd::SecurityClass::flags_t); -void SCL_check_database(Jrd::thread_db* tdbb, Jrd::SecurityClass::flags_t mask); -void SCL_check_domain(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, Jrd::SecurityClass::flags_t); -bool SCL_check_exception(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, Jrd::SecurityClass::flags_t); -bool SCL_check_generator(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, Jrd::SecurityClass::flags_t); -void SCL_check_index(Jrd::thread_db*, const Jrd::QualifiedName&, UCHAR, Jrd::SecurityClass::flags_t); -bool SCL_check_package(Jrd::thread_db* tdbb, const Jrd::QualifiedName& name, Jrd::SecurityClass::flags_t); -bool SCL_check_procedure(Jrd::thread_db* tdbb, const Jrd::QualifiedName& name, Jrd::SecurityClass::flags_t); -bool SCL_check_function(Jrd::thread_db* tdbb, const Jrd::QualifiedName& name, Jrd::SecurityClass::flags_t); -void SCL_check_filter(Jrd::thread_db* tdbb, const Jrd::MetaName& name, Jrd::SecurityClass::flags_t); -void SCL_check_relation(Jrd::thread_db* tdbb, const Jrd::QualifiedName& name, Jrd::SecurityClass::flags_t, - bool protectSys = true); -bool SCL_check_schema(Jrd::thread_db* tdbb, const Jrd::MetaName&, Jrd::SecurityClass::flags_t); -bool SCL_check_view(Jrd::thread_db* tdbb, const Jrd::QualifiedName& name, Jrd::SecurityClass::flags_t); -void SCL_check_role(Jrd::thread_db* tdbb, const Jrd::MetaName&, Jrd::SecurityClass::flags_t); -Jrd::SecurityClass* SCL_get_class(Jrd::thread_db*, const Jrd::MetaName& name); -Jrd::SecurityClass::flags_t SCL_get_mask(Jrd::thread_db* tdbb, const Jrd::QualifiedName&, const TEXT*); -void SCL_clear_classes(Jrd::thread_db*, const Jrd::MetaName&); -void SCL_release_all(Jrd::SecurityClassList*&); -bool SCL_role_granted(Jrd::thread_db* tdbb, const Jrd::UserId& usr, const TEXT* sql_role); -Jrd::SecurityClass::flags_t SCL_get_object_mask(ObjectType object_type, const Jrd::MetaName& schema); -ULONG SCL_get_number(const UCHAR*); -USHORT SCL_convert_privilege(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, const Firebird::string& priv); +namespace Firebird::Jrd +{ + -namespace Jrd { -typedef Firebird::Array Acl; -} -bool SCL_move_priv(Jrd::SecurityClass::flags_t, Jrd::Acl&); + void SCL_check_access(thread_db*, const SecurityClass*, + SLONG, const QualifiedName&, + SecurityClass::flags_t, ObjectType type, bool recursive, const QualifiedName&, + const MetaName& = {}); + void SCL_check_create_access(thread_db*, ObjectType type, const MetaName& schema); + void SCL_check_charset(thread_db* tdbb, const QualifiedName&, SecurityClass::flags_t); + void SCL_check_collation(thread_db* tdbb, const QualifiedName&, SecurityClass::flags_t); + void SCL_check_database(thread_db* tdbb, SecurityClass::flags_t mask); + void SCL_check_domain(thread_db* tdbb, const QualifiedName&, SecurityClass::flags_t); + bool SCL_check_exception(thread_db* tdbb, const QualifiedName&, SecurityClass::flags_t); + bool SCL_check_generator(thread_db* tdbb, const QualifiedName&, SecurityClass::flags_t); + void SCL_check_index(thread_db*, const QualifiedName&, UCHAR, SecurityClass::flags_t); + bool SCL_check_package(thread_db* tdbb, const QualifiedName& name, SecurityClass::flags_t); + bool SCL_check_procedure(thread_db* tdbb, const QualifiedName& name, SecurityClass::flags_t); + bool SCL_check_function(thread_db* tdbb, const QualifiedName& name, SecurityClass::flags_t); + void SCL_check_filter(thread_db* tdbb, const MetaName& name, SecurityClass::flags_t); + void SCL_check_relation(thread_db* tdbb, const QualifiedName& name, SecurityClass::flags_t, + bool protectSys = true); + bool SCL_check_schema(thread_db* tdbb, const MetaName&, SecurityClass::flags_t); + bool SCL_check_view(thread_db* tdbb, const QualifiedName& name, SecurityClass::flags_t); + void SCL_check_role(thread_db* tdbb, const MetaName&, SecurityClass::flags_t); + SecurityClass* SCL_get_class(thread_db*, const MetaName& name); + SecurityClass::flags_t SCL_get_mask(thread_db* tdbb, const QualifiedName&, const TEXT*); + void SCL_clear_classes(thread_db*, const MetaName&); + void SCL_release_all(SecurityClassList*&); + bool SCL_role_granted(thread_db* tdbb, const UserId& usr, const TEXT* sql_role); + SecurityClass::flags_t SCL_get_object_mask(ObjectType object_type, const MetaName& schema); + ULONG SCL_get_number(const UCHAR*); + USHORT SCL_convert_privilege(thread_db* tdbb, jrd_tra* transaction, const string& priv); -inline Jrd::MetaName SCL_getDdlSecurityClassName(ObjectType objectType, const Jrd::MetaName& schema) + typedef Array Acl; + + bool SCL_move_priv(SecurityClass::flags_t, Acl&); + +inline MetaName SCL_getDdlSecurityClassName(ObjectType objectType, const MetaName& schema) { switch (objectType) { @@ -91,7 +90,7 @@ inline Jrd::MetaName SCL_getDdlSecurityClassName(ObjectType objectType, const Jr case obj_tablespaces: case obj_schemas: { - Firebird::string str; + string str; str.printf(SQL_DDL_SECCLASS_FORMAT, (int) objectType, schema.c_str()); return str; } @@ -103,4 +102,7 @@ inline Jrd::MetaName SCL_getDdlSecurityClassName(ObjectType objectType, const Jr } +} // namespace Firebird::Jrd + + #endif // JRD_SCL_PROTO_H diff --git a/src/jrd/sdw.cpp b/src/jrd/sdw.cpp index 44f3303e7f7..66a0d6b75a2 100644 --- a/src/jrd/sdw.cpp +++ b/src/jrd/sdw.cpp @@ -50,9 +50,8 @@ #include "../jrd/Attachment.h" #include "../jrd/CryptoManager.h" -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ // Out of alpha order because the first one was public. @@ -398,7 +397,7 @@ void SDW_get_shadows(thread_db* tdbb) // fb_assert (lock->lck_physical == LCK_none); WIN window(HEADER_PAGE_NUMBER); - const header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + const Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); lock->setKey(header->hdr_shadow_count); LCK_lock(tdbb, lock, LCK_SR, LCK_WAIT); CCH_RELEASE(tdbb, &window); @@ -440,7 +439,7 @@ void SDW_init(thread_db* tdbb, bool activate, bool delete_files) // set up the lock block for synchronizing addition of new shadows - header_page* header; // for sizeof here, used later + Ods::header_page* header; // for sizeof here, used later constexpr USHORT key_length = sizeof(header->hdr_shadow_count); Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, key_length) Lock(tdbb, key_length, LCK_shadow, dbb, blocking_ast_shadowing); @@ -453,7 +452,7 @@ void SDW_init(thread_db* tdbb, bool activate, bool delete_files) WIN window(HEADER_PAGE_NUMBER); - header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); lock->setKey(header->hdr_shadow_count); LCK_lock(tdbb, lock, LCK_SR, LCK_WAIT); CCH_RELEASE(tdbb, &window); @@ -540,7 +539,7 @@ void SDW_notify(thread_db* tdbb) // on the shadow count, this is effectively an uninterruptible operation WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); // get an exclusive lock on the current shadowing semaphore to @@ -797,7 +796,7 @@ void SDW_start(thread_db* tdbb, const TEXT* file_name, // check to see if the shadow is the same as the current database -- // if so, a shadow file is being accessed as a database - Firebird::PathName expanded_name(file_name); + PathName expanded_name(file_name); ISC_expand_filename(expanded_name, false); PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); jrd_file* dbb_file = pageSpace->file; @@ -839,22 +838,22 @@ void SDW_start(thread_db* tdbb, const TEXT* file_name, // 3. make sure that the shadow has not already been activated window.win_page = HEADER_PAGE_NUMBER; - const header_page* database_header = - (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + const Ods::header_page* database_header = + (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); header_fetched++; - if (!PIO_read(tdbb, shadow_file, window.win_bdb, (PAG) spare_page, tdbb->tdbb_status_vector)) + if (!PIO_read(tdbb, shadow_file, window.win_bdb, (Ods::PAG) spare_page, tdbb->tdbb_status_vector)) { ERR_punt(); } - const header_page* shadow_header = (header_page*) spare_page; + const Ods::header_page* shadow_header = (Ods::header_page*) spare_page; const UCHAR* p = shadow_header->hdr_data; - while (*p != HDR_end && *p != HDR_root_file_name) { + while (*p != Ods::HDR_end && *p != Ods::HDR_root_file_name) { p += 2 + p[1]; } - if (*p++ == HDR_end) + if (*p++ == Ods::HDR_end) BUGCHECK(163); // msg 163 root file name not listed for shadow // if the database file is not the same and the original file is @@ -870,7 +869,7 @@ void SDW_start(thread_db* tdbb, const TEXT* file_name, if ((shadow_header->hdr_creation_date[0] != database_header->hdr_creation_date[0]) || (shadow_header->hdr_creation_date[1] != database_header->hdr_creation_date[1]) || - !(shadow_header->hdr_flags & hdr_active_shadow)) + !(shadow_header->hdr_flags & Ods::hdr_active_shadow)) { ERR_punt(); } @@ -888,7 +887,7 @@ void SDW_start(thread_db* tdbb, const TEXT* file_name, } } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(tdbb->tdbb_status_vector); if (header_fetched) { @@ -936,9 +935,9 @@ static void activate_shadow(thread_db* tdbb) // clear the shadow bit on the header page WIN window(HEADER_PAGE_NUMBER); - header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); CCH_MARK_MUST_WRITE(tdbb, &window); - header->hdr_flags &= ~hdr_active_shadow; + header->hdr_flags &= ~Ods::hdr_active_shadow; CCH_RELEASE(tdbb, &window); } @@ -1021,7 +1020,7 @@ static int blocking_ast_shadowing(void* ast_object) LCK_release(tdbb, lock); } - catch (const Firebird::Exception&) + catch (const Exception&) {} // no-op return 0; @@ -1043,7 +1042,7 @@ static bool check_for_file(thread_db* tdbb, const SCHAR* name, USHORT length) **************************************/ SET_TDBB(tdbb); - const Firebird::PathName path(name, length); + const PathName path(name, length); try { // This use of PIO_open is NOT checked against DatabaseAccess configuration @@ -1052,7 +1051,7 @@ static bool check_for_file(thread_db* tdbb, const SCHAR* name, USHORT length) jrd_file* temp_file = PIO_open(tdbb, path, path); PIO_close(temp_file); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(tdbb->tdbb_status_vector); return false; @@ -1131,3 +1130,6 @@ static void update_dbb_to_sdw(Database* dbb) pageSpace->file = shadow->sdw_file; shadow->sdw_flags |= SDW_rollover; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/sdw.h b/src/jrd/sdw.h index 98b24e75d5a..f06bf4fadb3 100644 --- a/src/jrd/sdw.h +++ b/src/jrd/sdw.h @@ -26,7 +26,7 @@ #include "../include/fb_blk.h" -namespace Jrd { +namespace Firebird::Jrd { class jrd_file; // Shadowing block @@ -58,6 +58,6 @@ inline constexpr USHORT SDW_conditional = 64; // shadow to be used if another sh inline constexpr USHORT SDW_INVALID = (SDW_shutdown | SDW_delete | SDW_rollover | SDW_conditional); inline constexpr USHORT SDW_IGNORE = (SDW_shutdown | SDW_delete); -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SDW_H diff --git a/src/jrd/sdw_proto.h b/src/jrd/sdw_proto.h index 6c41ff42ecf..84c138ef25f 100644 --- a/src/jrd/sdw_proto.h +++ b/src/jrd/sdw_proto.h @@ -23,24 +23,25 @@ #ifndef JRD_SDW_PROTO_H #define JRD_SDW_PROTO_H -namespace Jrd { + +namespace Firebird::Jrd +{ class jrd_file; class Shadow; -} -void SDW_add(Jrd::thread_db* tdbb, const TEXT*, USHORT, USHORT); -void SDW_check(Jrd::thread_db* tdbb); -bool SDW_check_conditional(Jrd::thread_db* tdbb); -void SDW_close(); -void SDW_dump_pages(Jrd::thread_db* tdbb); -void SDW_get_shadows(Jrd::thread_db* tdbb); -void SDW_init(Jrd::thread_db* tdbb, bool, bool); -bool SDW_lck_update(Jrd::thread_db*, SLONG); -void SDW_notify(Jrd::thread_db* tdbb); -bool SDW_rollover_to_shadow(Jrd::thread_db* tdbb, const Jrd::jrd_file*, const bool); -// It's never called directly, but through SDW_check(). -//void SDW_shutdown_shadow(Jrd::Shadow*); -void SDW_start(Jrd::thread_db* tdbb, const TEXT*, USHORT, USHORT, bool); + void SDW_add(thread_db* tdbb, const TEXT*, USHORT, USHORT); + void SDW_check(thread_db* tdbb); + bool SDW_check_conditional(thread_db* tdbb); + void SDW_close(); + void SDW_dump_pages(thread_db* tdbb); + void SDW_get_shadows(thread_db* tdbb); + void SDW_init(thread_db* tdbb, bool, bool); + bool SDW_lck_update(thread_db*, SLONG); + void SDW_notify(thread_db* tdbb); + bool SDW_rollover_to_shadow(thread_db* tdbb, const jrd_file*, const bool); + // It's never called directly, but through SDW_check(). + //void SDW_shutdown_shadow(Shadow*); + void SDW_start(thread_db* tdbb, const TEXT*, USHORT, USHORT, bool); +} // namespace Firebird::Jrd #endif // JRD_SDW_PROTO_H - diff --git a/src/jrd/shut.cpp b/src/jrd/shut.cpp index 9ab356e0e40..db2f5973816 100644 --- a/src/jrd/shut.cpp +++ b/src/jrd/shut.cpp @@ -37,8 +37,9 @@ #include "../jrd/tra_proto.h" #include "../jrd/extds/ExtDS.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ + // Shutdown lock data union shutdown_data @@ -541,3 +542,6 @@ static bool shutdown(thread_db* tdbb, SSHORT flag, bool force) return false; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/shut_proto.h b/src/jrd/shut_proto.h index 36ce6ab1a46..8f374a9e54c 100644 --- a/src/jrd/shut_proto.h +++ b/src/jrd/shut_proto.h @@ -24,17 +24,18 @@ #ifndef JRD_SHUT_PROTO_H #define JRD_SHUT_PROTO_H -namespace Jrd { - class Database; -} - namespace Firebird { class Sync; } -bool SHUT_blocking_ast(Jrd::thread_db*, bool); -void SHUT_database(Jrd::thread_db*, SSHORT, SSHORT, Firebird::Sync*); -void SHUT_init(Jrd::thread_db*); -void SHUT_online(Jrd::thread_db*, SSHORT, Firebird::Sync*); +namespace Firebird::Jrd { + class Database; + class thread_db; + + bool SHUT_blocking_ast(thread_db*, bool); + void SHUT_database(thread_db*, SSHORT, SSHORT, Sync*); + void SHUT_init(thread_db*); + void SHUT_online(thread_db*, SSHORT, Sync*); +} // namespace Firebird::Jrd #endif // JRD_SHUT_PROTO_H diff --git a/src/jrd/sort.cpp b/src/jrd/sort.cpp index b1a0a7fe19c..862d4835a05 100644 --- a/src/jrd/sort.cpp +++ b/src/jrd/sort.cpp @@ -62,12 +62,13 @@ #include // lseek, read, write, close #endif +namespace Firebird::Jrd +{ + + constexpr USHORT RUN_GROUP = 8; constexpr USHORT MAX_MERGE_LEVEL = 2; -using namespace Jrd; -using namespace Firebird; - // The sort buffer size should be just under a multiple of the // hardware memory page size to account for memory allocator // overhead. On most platforms, this saves 4KB to 8KB per sort @@ -247,12 +248,12 @@ Sort::Sort(Database* dbb, } catch (const BadAlloc&) { - Firebird::Arg::Gds(isc_sort_mem_err).raise(); + Arg::Gds(isc_sort_mem_err).raise(); } catch (const status_exception& ex) { - Firebird::Arg::Gds status(isc_sort_err); - status.append(Firebird::Arg::StatusVector(ex.value())); + Arg::Gds status(isc_sort_err); + status.append(Arg::StatusVector(ex.value())); status.raise(); } } @@ -319,12 +320,12 @@ void Sort::get(thread_db* tdbb, ULONG** record_address) } catch (const BadAlloc&) { - Firebird::Arg::Gds(isc_sort_mem_err).raise(); + Arg::Gds(isc_sort_mem_err).raise(); } catch (const status_exception& ex) { - Firebird::Arg::Gds status(isc_sort_err); - status.append(Firebird::Arg::StatusVector(ex.value())); + Arg::Gds status(isc_sort_err); + status.append(Arg::StatusVector(ex.value())); status.raise(); } } @@ -394,12 +395,12 @@ void Sort::put(thread_db* tdbb, ULONG** record_address) } catch (const BadAlloc&) { - Firebird::Arg::Gds(isc_sort_mem_err).raise(); + Arg::Gds(isc_sort_mem_err).raise(); } catch (const status_exception& ex) { - Firebird::Arg::Gds status(isc_sort_err); - status.append(Firebird::Arg::StatusVector(ex.value())); + Arg::Gds status(isc_sort_err); + status.append(Arg::StatusVector(ex.value())); status.raise(); } } @@ -591,12 +592,12 @@ void Sort::sort(thread_db* tdbb) } catch (const BadAlloc&) { - Firebird::Arg::Gds(isc_sort_mem_err).raise(); + Arg::Gds(isc_sort_mem_err).raise(); } catch (const status_exception& ex) { - Firebird::Arg::Gds status(isc_sort_err); - status.append(Firebird::Arg::StatusVector(ex.value())); + Arg::Gds status(isc_sort_err); + status.append(Arg::StatusVector(ex.value())); status.raise(); } } @@ -2442,3 +2443,5 @@ sort_record* PartitionedSort::getMerge() return eof ? NULL : record; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/sort.h b/src/jrd/sort.h index 1758583c4cf..cfb8119c9aa 100644 --- a/src/jrd/sort.h +++ b/src/jrd/sort.h @@ -29,7 +29,9 @@ #include "../jrd/TempSpace.h" #include "../jrd/align.h" -namespace Jrd { +namespace Firebird::Jrd +{ + // Forward declaration class Attachment; @@ -179,12 +181,12 @@ struct sort_key_def switch (dtype) { case SKD_dec64: - fb_assert(dscLength == sizeof(Firebird::Decimal64)); - skd_length = Firebird::Decimal64::getKeyLength(); + fb_assert(dscLength == sizeof(Decimal64)); + skd_length = Decimal64::getKeyLength(); break; case SKD_dec128: - fb_assert(dscLength == sizeof(Firebird::Decimal128)); - skd_length = Firebird::Decimal128::getKeyLength(); + fb_assert(dscLength == sizeof(Decimal128)); + skd_length = Decimal128::getKeyLength(); break; default: skd_length = dscLength; @@ -282,9 +284,9 @@ class Sort FPTR_REJECT_DUP_CALLBACK, void*, FB_UINT64 = 0); ~Sort(); - void get(Jrd::thread_db*, ULONG**); - void put(Jrd::thread_db*, ULONG**); - void sort(Jrd::thread_db*); + void get(thread_db*, ULONG**); + void put(thread_db*, ULONG**); + void sort(thread_db*); bool isSorted() const noexcept { @@ -316,9 +318,9 @@ class Sort void init(); void mergeRuns(USHORT); ULONG order(); - void orderAndSave(Jrd::thread_db*); - void putRun(Jrd::thread_db*); - void sortBuffer(Jrd::thread_db*); + void orderAndSave(thread_db*); + void putRun(thread_db*); + void sortBuffer(thread_db*); void sortRunsBySeek(int); #ifdef DEV_BUILD @@ -352,7 +354,7 @@ class Sort ULONG m_min_alloc_size; // MIN and MAX values ULONG m_max_alloc_size; // for the run buffer size - Firebird::Array m_description; + Array m_description; }; @@ -362,7 +364,7 @@ class PartitionedSort PartitionedSort(Database*, SortOwner*); ~PartitionedSort(); - void get(Jrd::thread_db*, ULONG**); + void get(thread_db*, ULONG**); void addPartition(Sort* sort) { @@ -380,8 +382,8 @@ class PartitionedSort sort_record* getMerge(); SortOwner* m_owner; - Firebird::HalfStaticArray m_parts; - Firebird::HalfStaticArray m_nodes; // nodes of merge tree + HalfStaticArray m_parts; + HalfStaticArray m_nodes; // nodes of merge tree merge_control* m_merge; // root of merge tree }; @@ -432,10 +434,11 @@ class SortOwner private: MemoryPool& pool; Database* const dbb; - Firebird::SortedArray sorts; - Firebird::HalfStaticArray buffers; + SortedArray sorts; + HalfStaticArray buffers; }; -} //namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_SORT_H diff --git a/src/jrd/sqz.cpp b/src/jrd/sqz.cpp index 5ebcc7db49d..a4758991394 100644 --- a/src/jrd/sqz.cpp +++ b/src/jrd/sqz.cpp @@ -28,7 +28,9 @@ #include "../jrd/err_proto.h" #include "../yvalve/gds_proto.h" -using namespace Jrd; +namespace Firebird::Jrd +{ + // Compression (run-length encoding aka RLE) scheme: // @@ -670,3 +672,6 @@ ULONG Difference::make(ULONG length1, const UCHAR* rec1, return (diffLength <= MAX_DIFFERENCES) ? diffLength : 0; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/sqz.h b/src/jrd/sqz.h index 073a1d9f3ef..52f2191e6ec 100644 --- a/src/jrd/sqz.h +++ b/src/jrd/sqz.h @@ -27,7 +27,7 @@ #include "../include/fb_blk.h" #include "../../common/classes/array.h" -namespace Jrd +namespace Firebird::Jrd { class thread_db; @@ -58,7 +58,7 @@ namespace Jrd private: unsigned nonCompressableRun(unsigned length); - Firebird::HalfStaticArray m_runs; + HalfStaticArray m_runs; ULONG m_length = 0; // Compatibility options @@ -95,7 +95,6 @@ namespace Jrd private: UCHAR m_differences[MAX_DIFFERENCES]; }; - -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SQZ_H diff --git a/src/jrd/status.h b/src/jrd/status.h index 1f8bb906ee0..b6d5fab208b 100644 --- a/src/jrd/status.h +++ b/src/jrd/status.h @@ -31,9 +31,8 @@ #include "../common/status.h" -namespace Jrd -{ - typedef Firebird::CheckStatusWrapper FbStatusVector; +namespace Firebird::Jrd { + typedef CheckStatusWrapper FbStatusVector; } #endif // JRD_STATUS_H diff --git a/src/jrd/svc.cpp b/src/jrd/svc.cpp index dfa81d24fc2..a11e9d55b39 100644 --- a/src/jrd/svc.cpp +++ b/src/jrd/svc.cpp @@ -38,7 +38,7 @@ #include #include "../jrd/jrd.h" #include "../jrd/svc.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "iberror.h" #include "../jrd/license.h" #include "../jrd/err_proto.h" @@ -79,7 +79,6 @@ // Service threads #include "../burp/burp_proto.h" #include "../alice/alice_proto.h" -int main_gstat(Firebird::UtilSvc* uSvc); #include "../utilities/nbackup/nbk_proto.h" #include "../utilities/gsec/gsec_proto.h" #include "../jrd/trace/TraceService.h" @@ -117,11 +116,15 @@ int main_gstat(Firebird::UtilSvc* uSvc); #include +int main_gstat(Firebird::UtilSvc* uSvc); + +namespace Firebird::Jrd +{ + + #define statistics stat -using namespace Firebird; -using namespace Jrd; inline constexpr int SVC_user_dba = 2; inline constexpr int SVC_user_any = 1; @@ -157,27 +160,27 @@ namespace { namespace { inline constexpr serv_entry services[] = { - { isc_action_svc_backup, "Backup Database", BURP_main }, - { isc_action_svc_restore, "Restore Database", BURP_main }, - { isc_action_svc_repair, "Repair Database", ALICE_main }, - { isc_action_svc_add_user, "Add User", GSEC_main }, - { isc_action_svc_delete_user, "Delete User", GSEC_main }, - { isc_action_svc_modify_user, "Modify User", GSEC_main }, - { isc_action_svc_display_user, "Display User", GSEC_main }, - { isc_action_svc_properties, "Database Properties", ALICE_main }, + { isc_action_svc_backup, "Backup Database", Burp::BURP_main }, + { isc_action_svc_restore, "Restore Database", Burp::BURP_main }, + { isc_action_svc_repair, "Repair Database", Alice::ALICE_main }, + { isc_action_svc_add_user, "Add User", Gsec::GSEC_main }, + { isc_action_svc_delete_user, "Delete User", Gsec::GSEC_main }, + { isc_action_svc_modify_user, "Modify User", Gsec::GSEC_main }, + { isc_action_svc_display_user, "Display User", Gsec::GSEC_main }, + { isc_action_svc_properties, "Database Properties", Alice::ALICE_main }, { isc_action_svc_db_stats, "Database Stats", main_gstat }, { isc_action_svc_get_fb_log, "Get Log File", Service::readFbLog }, - { isc_action_svc_nbak, "Incremental Backup Database", NBACKUP_main }, - { isc_action_svc_nrest, "Incremental Restore Database", NBACKUP_main }, - { isc_action_svc_nfix, "Fixup Database after FS Copy", NBACKUP_main }, + { isc_action_svc_nbak, "Incremental Backup Database", Nbackup::NBACKUP_main }, + { isc_action_svc_nrest, "Incremental Restore Database", Nbackup::NBACKUP_main }, + { isc_action_svc_nfix, "Fixup Database after FS Copy", Nbackup::NBACKUP_main }, { isc_action_svc_trace_start, "Start Trace Session", TRACE_main }, { isc_action_svc_trace_stop, "Stop Trace Session", TRACE_main }, { isc_action_svc_trace_suspend, "Suspend Trace Session", TRACE_main }, { isc_action_svc_trace_resume, "Resume Trace Session", TRACE_main }, { isc_action_svc_trace_list, "List Trace Sessions", TRACE_main }, - { isc_action_svc_set_mapping, "Set Domain Admins Mapping to RDB$ADMIN", GSEC_main }, - { isc_action_svc_drop_mapping, "Drop Domain Admins Mapping to RDB$ADMIN", GSEC_main }, - { isc_action_svc_display_user_adm, "Display User with Admin Info", GSEC_main }, + { isc_action_svc_set_mapping, "Set Domain Admins Mapping to RDB$ADMIN", Gsec::GSEC_main }, + { isc_action_svc_drop_mapping, "Drop Domain Admins Mapping to RDB$ADMIN", Gsec::GSEC_main }, + { isc_action_svc_display_user_adm, "Display User with Admin Info", Gsec::GSEC_main }, { isc_action_svc_validate, "Validate Database", VAL_service}, { 0, NULL, NULL } }; @@ -634,7 +637,7 @@ bool Service::utf8FileNames() return svc_utf8; } -Firebird::ICryptKeyCallback* Service::getCryptCallback() +ICryptKeyCallback* Service::getCryptCallback() { return svc_crypt_callback; } @@ -670,7 +673,7 @@ namespace val |= QUOTED_FILENAME_SUPPORT; #endif // WIN_NT - Firebird::MasterInterfacePtr master; + MasterInterfacePtr master; switch (master->serverMode(-1)) { case 1: // super @@ -688,7 +691,7 @@ namespace } Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_data, - Firebird::ICryptKeyCallback* crypt_callback) + ICryptKeyCallback* crypt_callback) : svc_status(getPool()), svc_parsed_sw(getPool()), svc_stdout_head(0), svc_stdout_tail(0), svc_service_run(NULL), svc_resp_alloc(getPool()), svc_resp_buf(0), svc_resp_ptr(0), svc_resp_buf_len(0), @@ -805,7 +808,7 @@ Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_d svc_trace_manager = FB_NEW_POOL(*getDefaultMemoryPool()) TraceManager(this); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { TraceManager* trace_manager = NULL; FbLocalStatus status_vector; @@ -833,7 +836,7 @@ Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_d if (!hasTrace) delete trace_manager; } - catch (const Firebird::Exception&) + catch (const Exception&) { } @@ -1529,7 +1532,7 @@ ISC_STATUS Service::query2(thread_db* /*tdbb*/, } } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { if (svc_trace_manager->needs(ITraceFactory::TRACE_EVENT_SERVICE_QUERY)) { @@ -1905,7 +1908,7 @@ void Service::query(USHORT send_item_length, *info = isc_info_end; } } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { if (svc_trace_manager->needs(ITraceFactory::TRACE_EVENT_SERVICE_QUERY)) { @@ -2149,7 +2152,7 @@ void Service::start(USHORT spb_length, const UCHAR* spb_data) } } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { if (svc_trace_manager->needs(ITraceFactory::TRACE_EVENT_SERVICE_START)) { @@ -2189,7 +2192,7 @@ void Service::readFbLog() { bool svc_started = false; - Firebird::PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); + PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); FILE* file = os_utils::fopen(name.c_str(), "r"); try @@ -2227,7 +2230,7 @@ void Service::readFbLog() } } } - catch (const Firebird::Exception& e) + catch (const Exception& e) { setDataMode(false); @@ -2691,14 +2694,14 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) break; case isc_spb_options: - if (!get_action_svc_bitmask(spb, nbackup_in_sw_table, switches)) + if (!get_action_svc_bitmask(spb, Nbackup::nbackup_in_sw_table, switches)) { return false; } break; case isc_spb_nbk_direct: - if (!get_action_svc_parameter(spb.getClumpTag(), nbackup_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Nbackup::nbackup_in_sw_table, switches)) { return false; } @@ -2710,7 +2713,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) { (Arg::Gds(isc_unexp_spb_form) << Arg::Str("only one isc_spb_nbk_clean_history")).raise(); } - if (!get_action_svc_parameter(spb.getClumpTag(), nbackup_action_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Nbackup::nbackup_action_in_sw_table, switches)) { return false; } @@ -2748,7 +2751,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) break; case isc_spb_options: - if (!get_action_svc_bitmask(spb, nbackup_in_sw_table, switches)) + if (!get_action_svc_bitmask(spb, Nbackup::nbackup_in_sw_table, switches)) { return false; } @@ -2763,7 +2766,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_action_svc_drop_mapping: if (!found) { - if (!get_action_svc_parameter(svc_action, gsec_action_in_sw_table, switches)) + if (!get_action_svc_parameter(svc_action, Gsec::gsec_action_in_sw_table, switches)) { return false; } @@ -2779,7 +2782,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) { case isc_spb_sql_role_name: case isc_spb_dbname: - if (!get_action_svc_parameter(spb.getClumpTag(), gsec_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Gsec::gsec_in_sw_table, switches)) { return false; } @@ -2796,7 +2799,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_action_svc_display_user_adm: if (!found) { - if (!get_action_svc_parameter(svc_action, gsec_action_in_sw_table, switches)) + if (!get_action_svc_parameter(svc_action, Gsec::gsec_action_in_sw_table, switches)) { return false; } @@ -2820,7 +2823,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) { case isc_spb_sql_role_name: case isc_spb_dbname: - if (!get_action_svc_parameter(spb.getClumpTag(), gsec_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Gsec::gsec_in_sw_table, switches)) { return false; } @@ -2842,7 +2845,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_action_svc_modify_user: if (!found) { - if (!get_action_svc_parameter(svc_action, gsec_action_in_sw_table, switches)) + if (!get_action_svc_parameter(svc_action, Gsec::gsec_action_in_sw_table, switches)) { return false; } @@ -2858,7 +2861,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) { case isc_spb_sec_userid: case isc_spb_sec_groupid: - if (!get_action_svc_parameter(spb.getClumpTag(), gsec_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Gsec::gsec_in_sw_table, switches)) { return false; } @@ -2866,7 +2869,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) break; case isc_spb_sec_admin: - if (!get_action_svc_parameter(spb.getClumpTag(), gsec_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Gsec::gsec_in_sw_table, switches)) { return false; } @@ -2880,7 +2883,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_spb_sec_middlename: case isc_spb_sec_lastname: case isc_spb_dbname: - if (!get_action_svc_parameter(spb.getClumpTag(), gsec_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Gsec::gsec_in_sw_table, switches)) { return false; } @@ -2968,7 +2971,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) break; case isc_spb_options: burp_options |= spb.getInt(); - if (!get_action_svc_bitmask(spb, reference_burp_in_sw_table, switches)) + if (!get_action_svc_bitmask(spb, Burp::reference_burp_in_sw_table, switches)) { return false; } @@ -2984,33 +2987,33 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_spb_res_buffers: case isc_spb_res_page_size: case isc_spb_verbint: - if (!get_action_svc_parameter(spb.getClumpTag(), reference_burp_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Burp::reference_burp_in_sw_table, switches)) { return false; } get_action_svc_data(spb, switches, bigint); break; case isc_spb_res_access_mode: - if (!get_action_svc_parameter(*(spb.getBytes()), reference_burp_in_sw_table, switches)) + if (!get_action_svc_parameter(*(spb.getBytes()), Burp::reference_burp_in_sw_table, switches)) { return false; } break; case isc_spb_res_replica_mode: - if (get_action_svc_parameter(spb.getClumpTag(), reference_burp_in_sw_table, switches)) + if (get_action_svc_parameter(spb.getClumpTag(), Burp::reference_burp_in_sw_table, switches)) { const unsigned int val = spb.getInt(); - if (val >= FB_NELEM(burp_repl_mode_sw_table)) + if (val >= FB_NELEM(Burp::burp_repl_mode_sw_table)) { return false; } - switches += burp_repl_mode_sw_table[val]; + switches += Burp::burp_repl_mode_sw_table[val]; switches += " "; break; } return false; case isc_spb_verbose: - if (!get_action_svc_parameter(spb.getClumpTag(), reference_burp_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Burp::reference_burp_in_sw_table, switches)) { return false; } @@ -3023,7 +3026,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_spb_bkp_keyholder: case isc_spb_bkp_keyname: case isc_spb_bkp_crypt: - if (!get_action_svc_parameter(spb.getClumpTag(), reference_burp_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Burp::reference_burp_in_sw_table, switches)) { return false; } @@ -3042,7 +3045,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) get_action_svc_string(spb, switches); break; case isc_spb_options: - if (!get_action_svc_bitmask(spb, alice_in_sw_table, switches)) + if (!get_action_svc_bitmask(spb, Alice::alice_in_sw_table, switches)) { return false; } @@ -3065,7 +3068,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_spb_rpr_rollback_trans: case isc_spb_rpr_recover_two_phase: case isc_spb_rpr_par_workers: - if (!get_action_svc_parameter(spb.getClumpTag(), alice_in_sw_table, switches)) + if (!get_action_svc_parameter(spb.getClumpTag(), Alice::alice_in_sw_table, switches)) { return false; } @@ -3074,34 +3077,34 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) case isc_spb_prp_write_mode: case isc_spb_prp_access_mode: case isc_spb_prp_reserve_space: - if (!get_action_svc_parameter(*(spb.getBytes()), alice_in_sw_table, switches)) + if (!get_action_svc_parameter(*(spb.getBytes()), Alice::alice_in_sw_table, switches)) { return false; } break; case isc_spb_prp_shutdown_mode: case isc_spb_prp_online_mode: - if (get_action_svc_parameter(spb.getClumpTag(), alice_in_sw_table, switches)) + if (get_action_svc_parameter(spb.getClumpTag(), Alice::alice_in_sw_table, switches)) + { + const unsigned int val = spb.getInt(); + if (val >= FB_NELEM(Alice::alice_shut_mode_sw_table)) { - const unsigned int val = spb.getInt(); - if (val >= FB_NELEM(alice_shut_mode_sw_table)) - { - return false; - } - switches += alice_shut_mode_sw_table[val]; + return false; + } + switches += Alice::alice_shut_mode_sw_table[val]; switches += " "; break; } return false; case isc_spb_prp_replica_mode: - if (get_action_svc_parameter(spb.getClumpTag(), alice_in_sw_table, switches)) + if (get_action_svc_parameter(spb.getClumpTag(), Alice::alice_in_sw_table, switches)) + { + const unsigned int val = spb.getInt(); + if (val >= FB_NELEM(Alice::alice_repl_mode_sw_table)) { - const unsigned int val = spb.getInt(); - if (val >= FB_NELEM(alice_repl_mode_sw_table)) - { - return false; - } - switches += alice_repl_mode_sw_table[val]; + return false; + } + switches += Alice::alice_repl_mode_sw_table[val]; switches += " "; break; } @@ -3214,7 +3217,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) (Arg::Gds(isc_missing_required_spb) << Arg::Str("isc_spb_nbk_file")).raise(); } - if (!get_action_svc_parameter(svc_action, nbackup_action_in_sw_table, switches)) + if (!get_action_svc_parameter(svc_action, Nbackup::nbackup_action_in_sw_table, switches)) { return false; } @@ -3253,7 +3256,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches) (Arg::Gds(isc_missing_required_spb) << Arg::Str("isc_spb_dbname")).raise(); } - if (!get_action_svc_parameter(svc_action, nbackup_action_in_sw_table, switches)) + if (!get_action_svc_parameter(svc_action, Nbackup::nbackup_action_in_sw_table, switches)) { return false; } @@ -3359,3 +3362,6 @@ bool Service::getUserAdminFlag() const noexcept { return (svc_user_flag & SVC_user_dba); } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/svc.h b/src/jrd/svc.h index 4fe3a327fd0..26d52da383a 100644 --- a/src/jrd/svc.h +++ b/src/jrd/svc.h @@ -50,9 +50,9 @@ namespace Firebird { } } -namespace Jrd { +namespace Firebird::Jrd { -typedef int ServiceEntry(Firebird::UtilSvc*); +typedef int ServiceEntry(UtilSvc*); struct serv_entry { @@ -106,7 +106,7 @@ class thread_db; class TraceManager; // Service manager -class Service : public Firebird::UtilSvc, public TypedHandle +class Service : public UtilSvc, public TypedHandle { public: // utilities interface with service // output to svc_stdout verbose info @@ -145,11 +145,11 @@ class Service : public Firebird::UtilSvc, public TypedHandle // no-op for services void checkService() override; // add address path and utf8 flag (taken from spb) to dpb if present - void fillDpb(Firebird::ClumpletWriter& dpb) override; + void fillDpb(ClumpletWriter& dpb) override; // encoding for string parameters passed to utility bool utf8FileNames() override; // get database encryption key transfer callback routine - Firebird::ICryptKeyCallback* getCryptCallback() override; + ICryptKeyCallback* getCryptCallback() override; int getParallelWorkers() override { return svc_parallel_workers; } TraceManager* getTraceManager() noexcept @@ -169,7 +169,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle public: // external interface with service // Attach - service ctor Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_data, - Firebird::ICryptKeyCallback* crypt_callback); + ICryptKeyCallback* crypt_callback); // Start service thread void start(USHORT spb_length, const UCHAR* spb_data); // Query service state (v. 1 & 2) @@ -188,7 +188,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle } // Firebird log reader - static int readFbLog(Firebird::UtilSvc* uSvc); + static int readFbLog(UtilSvc* uSvc); // Shuts all service threads (should be called after databases shutdown) static void shutdownServices(); @@ -198,12 +198,12 @@ class Service : public Firebird::UtilSvc, public TypedHandle const char* getServiceMgr() const noexcept; const char* getServiceName() const noexcept; - const Firebird::string& getUserName() const noexcept + const string& getUserName() const noexcept { return svc_username; } - const Firebird::string& getRoleName() const noexcept + const string& getRoleName() const noexcept { return svc_sql_role; } @@ -212,11 +212,11 @@ class Service : public Firebird::UtilSvc, public TypedHandle // for service user authentication bool getUserAdminFlag() const noexcept; - const Firebird::string& getNetworkProtocol() const noexcept { return svc_network_protocol; } - const Firebird::string& getRemoteAddress() const noexcept { return svc_remote_address; } - const Firebird::string& getRemoteProcess() const noexcept { return svc_remote_process; } + const string& getNetworkProtocol() const noexcept { return svc_network_protocol; } + const string& getRemoteAddress() const noexcept { return svc_remote_address; } + const string& getRemoteProcess() const noexcept { return svc_remote_process; } int getRemotePID() const noexcept { return svc_remote_pid; } - const Firebird::PathName& getExpectedDb() const noexcept { return svc_expected_db; } + const PathName& getExpectedDb() const noexcept { return svc_expected_db; } private: // Service must have private destructor, called from finish @@ -254,7 +254,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle // Returns number of bytes service wants more ULONG put(const UCHAR* buffer, ULONG length); // Copies argument value to status vector - void put_status_arg(Firebird::Arg::StatusVector& status, const MsgFormat::safe_cell& value); + void put_status_arg(Arg::StatusVector& status, const MsgFormat::safe_cell& value); // Increment circular buffer pointer static ULONG add_one(ULONG i) noexcept; @@ -263,51 +263,51 @@ class Service : public Firebird::UtilSvc, public TypedHandle #ifndef DEV_BUILD static #endif - void conv_switches(Firebird::ClumpletReader& spb, Firebird::string& switches); + void conv_switches(ClumpletReader& spb, string& switches); // Find spb switch in switch table static const TEXT* find_switch(int in_spb_sw, const Switches::in_sw_tab_t* table, bool bitmask); // Loop through the appropriate switch table looking for the text for the given command switch #ifndef DEV_BUILD static #endif - bool process_switches(Firebird::ClumpletReader& spb, Firebird::string& switches); + bool process_switches(ClumpletReader& spb, string& switches); // Get bitmask from within spb buffer, find corresponding switches within specified table, // add them to the command line - static bool get_action_svc_bitmask(const Firebird::ClumpletReader& spb, + static bool get_action_svc_bitmask(const ClumpletReader& spb, const Switches::in_sw_tab_t* table, - Firebird::string& sw); + string& sw); // Get string from within spb buffer, add it to the command line - static void get_action_svc_string(const Firebird::ClumpletReader& spb, Firebird::string& sw); + static void get_action_svc_string(const ClumpletReader& spb, string& sw); // Get string from within spb buffer, insert it at given position into command line - static void get_action_svc_string_pos(const Firebird::ClumpletReader& spb, Firebird::string& switches, - Firebird::string::size_type p = Firebird::string::npos); + static void get_action_svc_string_pos(const ClumpletReader& spb, string& switches, + string::size_type p = string::npos); // Get integer from within spb buffer, add it to the command line - static void get_action_svc_data(const Firebird::ClumpletReader& spb, Firebird::string& sw, bool bigint); + static void get_action_svc_data(const ClumpletReader& spb, string& sw, bool bigint); // Get parameter from within spb buffer, find corresponding switch within specified table, // add it to the command line static bool get_action_svc_parameter(UCHAR tag, const Switches::in_sw_tab_t* table, - Firebird::string&); + string&); // Create 'SYSDBA needed' error in status vector - static void need_admin_privs(Firebird::Arg::StatusVector& status, const char* message) noexcept; + static void need_admin_privs(Arg::StatusVector& status, const char* message) noexcept; // Does info buffer have enough space for SLONG? static bool ck_space_for_numeric(UCHAR*& info, const UCHAR* const end) noexcept; // Make status vector permamnent, if one present in worker thread's space void makePermanentStatusVector() noexcept; // Read SPB on attach - void getOptions(Firebird::ClumpletReader&); + void getOptions(ClumpletReader&); // Invoke appropriate service thread entry and finalize it correctly static THREAD_ENTRY_DECLARE run(THREAD_ENTRY_PARAM arg); private: - Firebird::FbLocalStatus svc_status; // status vector for running service - Firebird::Mutex svc_status_mutex; // protects svc_status from access in different threads - Firebird::string svc_parsed_sw; // Here point elements of argv + FbLocalStatus svc_status; // status vector for running service + Mutex svc_status_mutex; // protects svc_status from access in different threads + string svc_parsed_sw; // Here point elements of argv ULONG svc_stdout_head; ULONG svc_stdout_tail; UCHAR svc_stdout[SVC_STDOUT_BUFFER_SIZE]; // output from service - Firebird::Semaphore svcStart; + Semaphore svcStart; const serv_entry* svc_service_run; // running service's entry - Firebird::Array svc_resp_alloc; + Array svc_resp_alloc; UCHAR* svc_resp_buf; const UCHAR* svc_resp_ptr; USHORT svc_resp_buf_len; @@ -322,30 +322,30 @@ class Service : public Firebird::UtilSvc, public TypedHandle char svc_arg_conv[MsgFormat::SAFEARG_MAX_ARG * 2]; char* svc_arg_ptr; - Firebird::string svc_username; - Firebird::string svc_sql_role; - Firebird::AuthReader::AuthBlock svc_auth_block; - Firebird::PathName svc_expected_db; + string svc_username; + string svc_sql_role; + AuthReader::AuthBlock svc_auth_block; + PathName svc_expected_db; bool svc_trusted_role; bool svc_utf8; - Firebird::string svc_switches; // Full set of switches - Firebird::string svc_perm_sw; // Switches, taken from services table and/or passed using spb_command_line - Firebird::UCharBuffer svc_address_path; - Firebird::string svc_command_line; + string svc_switches; // Full set of switches + string svc_perm_sw; // Switches, taken from services table and/or passed using spb_command_line + UCharBuffer svc_address_path; + string svc_command_line; int svc_parallel_workers; - Firebird::string svc_network_protocol; - Firebird::string svc_remote_address; - Firebird::string svc_remote_process; + string svc_network_protocol; + string svc_remote_address; + string svc_remote_process; SLONG svc_remote_pid; TraceManager* svc_trace_manager; - Firebird::ICryptKeyCallback* svc_crypt_callback; + ICryptKeyCallback* svc_crypt_callback; public: - Firebird::Semaphore svc_detach_sem; + Semaphore svc_detach_sem; - class SvcMutex : public Firebird::RefMutex + class SvcMutex : public RefMutex { public: explicit SvcMutex(Service* svc) @@ -355,10 +355,10 @@ class Service : public Firebird::UtilSvc, public TypedHandle Service* link; }; - Firebird::RefPtr svc_existence; + RefPtr svc_existence; private: - Firebird::Semaphore svc_sem_empty, svc_sem_full; + Semaphore svc_sem_empty, svc_sem_full; bool svc_output_overflow; void unblockQueryGet(bool over = false); @@ -368,7 +368,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle { public: explicit Validate(Service* svc); - Firebird::MutexEnsureUnlock sharedGuard; + MutexEnsureUnlock sharedGuard; }; private: @@ -379,7 +379,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle bool lock(); protected: - Firebird::RefPtr existenceMutex; + RefPtr existenceMutex; const char* from; }; @@ -405,8 +405,8 @@ class Service : public Firebird::UtilSvc, public TypedHandle }; // Data pipe from client to service - Firebird::Semaphore svc_stdin_semaphore; - Firebird::Mutex svc_stdin_mutex; + Semaphore svc_stdin_semaphore; + Mutex svc_stdin_mutex; // Size of data, requested by service (set in getBytes, reset in put) ULONG svc_stdin_size_requested; // Buffer passed by service @@ -414,7 +414,7 @@ class Service : public Firebird::UtilSvc, public TypedHandle // Size of data, preloaded by user (set in put, reset in getBytes) ULONG svc_stdin_size_preload; // Buffer for datam preloaded by user - Firebird::AutoPtr svc_stdin_preload; + AutoPtr svc_stdin_preload; // Size of data, requested from user to preload (set in getBytes) ULONG svc_stdin_preload_requested; // Size of data, placed into svc_stdin_buffer (set in put) @@ -428,6 +428,6 @@ class Service : public Firebird::UtilSvc, public TypedHandle #endif }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_SVC_H diff --git a/src/jrd/sys-packages/SqlPackage.cpp b/src/jrd/sys-packages/SqlPackage.cpp index d7d2a66bc5d..b21d2876f4b 100644 --- a/src/jrd/sys-packages/SqlPackage.cpp +++ b/src/jrd/sys-packages/SqlPackage.cpp @@ -28,8 +28,8 @@ #include "../dsql/dsql_proto.h" #include "../jrd/mov_proto.h" -using namespace Jrd; -using namespace Firebird; +namespace Firebird::Jrd +{ //-------------------------------------- @@ -259,3 +259,6 @@ SqlPackage::SqlPackage(MemoryPool& pool) ) { } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/sys-packages/SqlPackage.h b/src/jrd/sys-packages/SqlPackage.h index 264922c08c2..c198440f737 100644 --- a/src/jrd/sys-packages/SqlPackage.h +++ b/src/jrd/sys-packages/SqlPackage.h @@ -30,23 +30,24 @@ #include "../common/classes/objects_array.h" #include "../jrd/SystemPackages.h" -namespace Jrd { +namespace Firebird::Jrd +{ class SqlPackage final : public SystemPackage { public: - SqlPackage(Firebird::MemoryPool& pool); + SqlPackage(MemoryPool& pool); SqlPackage(const SqlPackage&) = delete; SqlPackage& operator=(const SqlPackage&) = delete; private: - FB_MESSAGE(ExplainInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ExplainInput, ThrowStatusExceptionWrapper, (FB_BLOB, sql) ); - FB_MESSAGE(ExplainOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ExplainOutput, ThrowStatusExceptionWrapper, (FB_INTEGER, planLine) (FB_BIGINT, recordSourceId) (FB_BIGINT, parentRecordSourceId) @@ -64,15 +65,15 @@ class SqlPackage final : public SystemPackage class ExplainResultSet : public - Firebird::DisposeIface< - Firebird::IExternalResultSetImpl< + DisposeIface< + IExternalResultSetImpl< ExplainResultSet, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - ExplainResultSet(Firebird::ThrowStatusExceptionWrapper* status, Firebird::IExternalContext* context, + ExplainResultSet(ThrowStatusExceptionWrapper* status, IExternalContext* context, const ExplainInput::Type* in, ExplainOutput::Type* out); public: @@ -82,38 +83,38 @@ class SqlPackage final : public SystemPackage } public: - FB_BOOLEAN fetch(Firebird::ThrowStatusExceptionWrapper* status) override; + FB_BOOLEAN fetch(ThrowStatusExceptionWrapper* status) override; private: ExplainOutput::Type* out; - Firebird::Array resultEntries{*getDefaultMemoryPool()}; - Firebird::Array::const_iterator resultIterator = nullptr; + Array resultEntries{*getDefaultMemoryPool()}; + Array::const_iterator resultIterator = nullptr; }; - static Firebird::IExternalResultSet* explainProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, const ExplainInput::Type* in, ExplainOutput::Type* out); + static IExternalResultSet* explainProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const ExplainInput::Type* in, ExplainOutput::Type* out); //---------- - FB_MESSAGE(ParseUnqualifiedNamesInput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ParseUnqualifiedNamesInput, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(MAX_VARY_COLUMN_SIZE / METADATA_BYTES_PER_CHAR * METADATA_BYTES_PER_CHAR, CS_METADATA), names) ); - FB_MESSAGE(ParseUnqualifiedNamesOutput, Firebird::ThrowStatusExceptionWrapper, + FB_MESSAGE(ParseUnqualifiedNamesOutput, ThrowStatusExceptionWrapper, (FB_INTL_VARCHAR(METADATA_IDENTIFIER_CHAR_LEN * METADATA_BYTES_PER_CHAR, CS_METADATA), name) ); class ParseUnqualifiedNamesResultSet : public - Firebird::DisposeIface< - Firebird::IExternalResultSetImpl< + DisposeIface< + IExternalResultSetImpl< ParseUnqualifiedNamesResultSet, - Firebird::ThrowStatusExceptionWrapper + ThrowStatusExceptionWrapper > > { public: - ParseUnqualifiedNamesResultSet(Firebird::ThrowStatusExceptionWrapper* status, Firebird::IExternalContext* context, + ParseUnqualifiedNamesResultSet(ThrowStatusExceptionWrapper* status, IExternalContext* context, const ParseUnqualifiedNamesInput::Type* in, ParseUnqualifiedNamesOutput::Type* out); public: @@ -123,20 +124,20 @@ class SqlPackage final : public SystemPackage } public: - FB_BOOLEAN fetch(Firebird::ThrowStatusExceptionWrapper* status) override; + FB_BOOLEAN fetch(ThrowStatusExceptionWrapper* status) override; private: ParseUnqualifiedNamesOutput::Type* out; - Firebird::ObjectsArray resultEntries{*getDefaultMemoryPool()}; - Firebird::ObjectsArray::const_iterator resultIterator; + ObjectsArray resultEntries{*getDefaultMemoryPool()}; + ObjectsArray::const_iterator resultIterator; }; - static Firebird::IExternalResultSet* parseUnqualifiedNamesProcedure(Firebird::ThrowStatusExceptionWrapper* status, - Firebird::IExternalContext* context, + static IExternalResultSet* parseUnqualifiedNamesProcedure(ThrowStatusExceptionWrapper* status, + IExternalContext* context, const ParseUnqualifiedNamesInput::Type* in, ParseUnqualifiedNamesOutput::Type* out); }; -} // namespace +} // namespace Firebird::Jrd #endif // JRD_SYS_PACKAGES_SQL_PACKAGE_H diff --git a/src/jrd/tdbb.h b/src/jrd/tdbb.h index 7d5406c8294..324b1724867 100644 --- a/src/jrd/tdbb.h +++ b/src/jrd/tdbb.h @@ -45,16 +45,16 @@ #define BUGCHECK(number) ERR_bugcheck(number, __FILE__, __LINE__) -namespace Firebird { - -class MemoryPool; - +namespace Firebird +{ + class MemoryPool; } -namespace Jrd +namespace Firebird::Jrd { + class Database; class Attachment; class jrd_tra; @@ -65,7 +65,7 @@ class Lock; #ifdef USE_ITIMER class TimeoutTimer final : - public Firebird::RefCntIface > + public RefCntIface > { public: explicit TimeoutTimer() noexcept @@ -116,7 +116,7 @@ class TimeoutTimer final : ISC_STATUS m_error; }; #else -class TimeoutTimer final : public Firebird::RefCounted +class TimeoutTimer final : public RefCounted { public: explicit TimeoutTimer() noexcept @@ -187,7 +187,7 @@ inline constexpr ULONG TDBB_repl_in_progress = 8192; // Prevent recursion in re inline constexpr ULONG TDBB_replicator = 16384; // Replicator inline constexpr ULONG TDBB_async = 32768; // Async context (set in AST) -class thread_db final : public Firebird::ThreadData +class thread_db final : public ThreadData { static constexpr int QUANTUM = 100; // Default quantum static constexpr int SWEEP_QUANTUM = 10; // Make sweeps less disruptive @@ -198,7 +198,7 @@ class thread_db final : public Firebird::ThreadData { defaultPool = p; } - friend class Firebird::SubsystemContextPoolHolder ; + friend class SubsystemContextPoolHolder ; Database* database; Attachment* attachment; jrd_tra* transaction; @@ -218,7 +218,7 @@ class thread_db final : public Firebird::ThreadData tdbb_flags(0), tdbb_temp_traid(0), tdbb_bdbs(*getDefaultMemoryPool()), - tdbb_thread(Firebird::ThreadSync::getThread("thread_db")) + tdbb_thread(ThreadSync::getThread("thread_db")) { reqStat = traStat = attStat = dbbStat = RuntimeStatistics::getDummy(); fb_utils::init_status(tdbb_status_vector); @@ -243,8 +243,8 @@ class thread_db final : public Firebird::ThreadData TraNumber tdbb_temp_traid; // current temporary table scope // BDB's held by thread - Firebird::HalfStaticArray tdbb_bdbs; - Firebird::ThreadSync* tdbb_thread; + HalfStaticArray tdbb_bdbs; + ThreadSync* tdbb_thread; MemoryPool* getDefaultPool() noexcept { @@ -443,18 +443,18 @@ class thread_db final : public Firebird::ThreadData private: thread_db* m_tdbb; bool m_autoStop; - Firebird::RefPtr m_saveTimer; + RefPtr m_saveTimer; }; private: - Firebird::RefPtr tdbb_reqTimer; + RefPtr tdbb_reqTimer; }; class ThreadContextHolder { public: - explicit ThreadContextHolder(Firebird::CheckStatusWrapper* status = NULL) + explicit ThreadContextHolder(CheckStatusWrapper* status = NULL) : context(status ? status : &localStatus) { context.putSpecific(); @@ -480,7 +480,7 @@ class ThreadContextHolder ~ThreadContextHolder() { - Firebird::ThreadData::restoreSpecific(); + ThreadData::restoreSpecific(); } // copying is prohibited @@ -498,10 +498,11 @@ class ThreadContextHolder } private: - Firebird::FbLocalStatus localStatus; + FbLocalStatus localStatus; thread_db context; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_TDBB_H diff --git a/src/jrd/tests/BlrGenTest.cpp b/src/jrd/tests/BlrGenTest.cpp index be65b9e7b71..ec26a3504d1 100644 --- a/src/jrd/tests/BlrGenTest.cpp +++ b/src/jrd/tests/BlrGenTest.cpp @@ -3,7 +3,7 @@ #include "../dsql/DsqlCompilerScratch.h" using namespace Firebird; -using namespace Jrd; +using namespace Firebird::Jrd; BOOST_AUTO_TEST_SUITE(EngineSuite) BOOST_AUTO_TEST_SUITE(BlrGenSuite) diff --git a/src/jrd/tests/CompressorTest.cpp b/src/jrd/tests/CompressorTest.cpp index 2b54c411e06..25de5770fed 100644 --- a/src/jrd/tests/CompressorTest.cpp +++ b/src/jrd/tests/CompressorTest.cpp @@ -3,7 +3,7 @@ #include "../jrd/sqz.h" using namespace Firebird; -using namespace Jrd; +using namespace Firebird::Jrd; BOOST_AUTO_TEST_SUITE(EngineSuite) BOOST_AUTO_TEST_SUITE(CompressorSuite) diff --git a/src/jrd/tests/RecordNumberTest.cpp b/src/jrd/tests/RecordNumberTest.cpp index 620dc7cb14b..c2acbf7ce6f 100644 --- a/src/jrd/tests/RecordNumberTest.cpp +++ b/src/jrd/tests/RecordNumberTest.cpp @@ -3,7 +3,7 @@ #include "../jrd/RecordNumber.h" using namespace Firebird; -using namespace Jrd; +using namespace Firebird::Jrd; BOOST_AUTO_TEST_SUITE(EngineSuite) BOOST_AUTO_TEST_SUITE(RecordNumberSuite) diff --git a/src/jrd/tpc.cpp b/src/jrd/tpc.cpp index a7a72efa8a4..6c3fc0a8028 100644 --- a/src/jrd/tpc.cpp +++ b/src/jrd/tpc.cpp @@ -36,9 +36,9 @@ #include -using namespace Firebird; +namespace Firebird::Jrd +{ -namespace Jrd { void TipCache::MemoryInitializer::mutexBug(int osErrorCode, const char* text) { @@ -703,7 +703,7 @@ CommitNumber TipCache::snapshotState(thread_db* tdbb, TraNumber number) // to avoid more work in the future if (state == tra_active) { - REPL_trans_cleanup(tdbb, number); + Replication::REPL_trans_cleanup(tdbb, number); TRA_set_state(tdbb, 0, number, tra_dead); // This will update TIP cache return CN_DEAD; } @@ -1241,4 +1241,4 @@ int TPC_snapshot_state(thread_db* tdbb, TraNumber number) } -} // namespace Jrd +} // namespace Firebird::Jrd diff --git a/src/jrd/tpc_proto.h b/src/jrd/tpc_proto.h index 0090a34491c..33d61f66a22 100644 --- a/src/jrd/tpc_proto.h +++ b/src/jrd/tpc_proto.h @@ -30,13 +30,13 @@ #include "../common/classes/SyncObject.h" #include "../jrd/tra.h" -namespace Ods { +namespace Firebird::Jrd::Ods { struct tx_inv_page; } -namespace Jrd { +namespace Firebird::Jrd { class Database; class thread_db; @@ -61,7 +61,7 @@ class TipCache static TipCache* create(thread_db* tdbb) { const auto dbb = tdbb->getDatabase(); - Firebird::AutoPtr tipCache(FB_NEW_POOL(*dbb->dbb_permanent) TipCache(dbb)); + AutoPtr tipCache(FB_NEW_POOL(*dbb->dbb_permanent) TipCache(dbb)); tipCache->initializeTpc(tdbb); return tipCache.release(); } @@ -195,7 +195,7 @@ class TipCache } private: - class GlobalTpcHeader : public Firebird::MemoryHeader + class GlobalTpcHeader : public MemoryHeader { public: std::atomic latest_commit_number; @@ -232,7 +232,7 @@ class TipCache // Note: when maintaining this structure, we are extra careful // to keep it consistent at all times, so that the process using it // can be killed at any time without adverse consequences. - class SnapshotList : public Firebird::MemoryHeader + class SnapshotList : public MemoryHeader { public: std::atomic slots_allocated; @@ -241,7 +241,7 @@ class TipCache SnapshotData slots[1]; }; - class TransactionStatusBlock : public Firebird::MemoryHeader + class TransactionStatusBlock : public MemoryHeader { public: std::atomic data[1]; @@ -259,7 +259,7 @@ class TipCache ~StatusBlockData(); TpcBlockNumber blockNumber; - Firebird::SharedMemory* memory; + SharedMemory* memory; Lock existenceLock; TipCache* cache; bool acceptAst; @@ -271,10 +271,10 @@ class TipCache void clear(thread_db* tdbb); - static Firebird::PathName makeSharedMemoryFileName(Database* dbb, TpcBlockNumber n, bool fullPath); + static PathName makeSharedMemoryFileName(Database* dbb, TpcBlockNumber n, bool fullPath); }; - class MemoryInitializer : public Firebird::IpcObject + class MemoryInitializer : public IpcObject { public: explicit MemoryInitializer(TipCache *cache) noexcept : m_cache(cache) {} @@ -288,9 +288,9 @@ class TipCache { public: explicit GlobalTpcInitializer(TipCache *cache) noexcept : MemoryInitializer(cache) {} - bool initialize(Firebird::SharedMemoryBase* sm, bool initFlag) override; + bool initialize(SharedMemoryBase* sm, bool initFlag) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TPC_HEADER; } + USHORT getType() const override { return SharedMemoryBase::SRAM_TPC_HEADER; } const char* getName() const override { return "TipCache:Global"; } }; @@ -298,9 +298,9 @@ class TipCache { public: explicit SnapshotsInitializer(TipCache *cache) noexcept : MemoryInitializer(cache) {} - bool initialize(Firebird::SharedMemoryBase* sm, bool initFlag) override; + bool initialize(SharedMemoryBase* sm, bool initFlag) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TPC_SNAPSHOTS; } + USHORT getType() const override { return SharedMemoryBase::SRAM_TPC_SNAPSHOTS; } const char* getName() const override { return "TipCache:Snapshots"; } }; @@ -308,22 +308,22 @@ class TipCache { public: explicit MemBlockInitializer(TipCache *cache) noexcept : MemoryInitializer(cache) {} - bool initialize(Firebird::SharedMemoryBase* sm, bool initFlag) override; + bool initialize(SharedMemoryBase* sm, bool initFlag) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TPC_BLOCK; } + USHORT getType() const override { return SharedMemoryBase::SRAM_TPC_BLOCK; } const char* getName() const override { return "TipCache:TranBlock"; } }; - typedef Firebird::BePlusTree BlocksMemoryMap; + typedef BePlusTree BlocksMemoryMap; static constexpr ULONG TPC_VERSION = 2; static constexpr int SAFETY_GAP_BLOCKS = 1; - Firebird::SharedMemory* m_tpcHeader; // final - Firebird::SharedMemory* m_snapshots; // final + SharedMemory* m_tpcHeader; // final + SharedMemory* m_snapshots; // final ULONG m_transactionsPerBlock; // final. When set, we assume TPC has been initialized. - Firebird::AutoPtr m_lock; + AutoPtr m_lock; GlobalTpcInitializer globalTpcInitializer; SnapshotsInitializer snapshotsInitializer; @@ -333,7 +333,7 @@ class TipCache // Reads and writes to the tree are protected with m_sync_status. BlocksMemoryMap m_blocks_memory; - Firebird::SyncObject m_sync_status; + SyncObject m_sync_status; // Attach to shared memory objects and populate process-local structures. // If shared memory area did not exist - populate initial TIP by reading cache @@ -348,7 +348,7 @@ class TipCache // Returns NULL if requested block is too old and is no longer cached. // Sync should be bound to m_sync_status. On enter, sync must be unlocked. // If returns not NULL then sync remains locked. - TransactionStatusBlock* getTransactionStatusBlock(const GlobalTpcHeader* header, TpcBlockNumber blockNumber, Firebird::Sync& sync); + TransactionStatusBlock* getTransactionStatusBlock(const GlobalTpcHeader* header, TpcBlockNumber blockNumber, Sync& sync); // Map shared memory for a block. // Assume exclusive lock of m_sync_status. @@ -390,6 +390,6 @@ inline void TPC_set_state(thread_db* tdbb, TraNumber number, int state) int TPC_snapshot_state(thread_db* tdbb, TraNumber number); -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_TPC_PROTO_H diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index 6d03cceb0bb..0c8dc88dc04 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -81,22 +81,22 @@ #include "firebird/impl/msg_helper.h" -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ + -typedef Firebird::GenericMap > > RelationLockTypeMap; +typedef GenericMap > > RelationLockTypeMap; #ifdef SUPERSERVER_V2 static TraNumber bump_transaction_id(thread_db*, WIN*); #else -static header_page* bump_transaction_id(thread_db*, WIN*, bool); +static Ods::header_page* bump_transaction_id(thread_db*, WIN*, bool); #endif static void retain_context(thread_db* tdbb, jrd_tra* transaction, bool commit, int state); static void expand_view_lock(thread_db* tdbb, jrd_tra*, jrd_rel*, UCHAR lock_type, const char* option_name, RelationLockTypeMap& lockmap, const int level); -static tx_inv_page* fetch_inventory_page(thread_db*, WIN* window, ULONG sequence, USHORT lock_level); +static Ods::tx_inv_page* fetch_inventory_page(thread_db*, WIN* window, ULONG sequence, USHORT lock_level); static constexpr const char* get_lockname_v3(const UCHAR lock) noexcept; static ULONG inventory_page(thread_db*, ULONG); static int limbo_transaction(thread_db*, TraNumber id); @@ -330,7 +330,7 @@ bool TRA_cleanup(thread_db* tdbb) // transaction is automatically marked active. WIN window(HEADER_PAGE_NUMBER); - const header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); + const Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header); const TraNumber ceiling = header->hdr_next_transaction; const TraNumber active = header->hdr_oldest_active; CCH_RELEASE(tdbb, &window); @@ -349,7 +349,7 @@ bool TRA_cleanup(thread_db* tdbb) for (ULONG sequence = active / trans_per_tip; sequence <= last; sequence++, number = 0) { window.win_page = inventory_page(tdbb, sequence); - tx_inv_page* tip = (tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); + Ods::tx_inv_page* tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); TraNumber max = ceiling - (TraNumber) sequence * trans_per_tip; if (max >= trans_per_tip) max = trans_per_tip - 1; @@ -398,13 +398,13 @@ bool TRA_cleanup(thread_db* tdbb) #ifdef SUPERSERVER_V2 window.win_page = inventory_page(tdbb, last); - tx_inv_page* tip = (tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); + Ods::tx_inv_page* tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); while (tip->tip_next) { CCH_RELEASE(tdbb, &window); window.win_page = inventory_page(tdbb, ++last); - tip = (tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); + tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_transactions); CCH_MARK(tdbb, &window); for (number = 0; number < trans_per_tip; number++) { @@ -471,7 +471,7 @@ void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag if (transaction->tra_flags & TRA_invalidated) ERR_post(Arg::Gds(isc_trans_invalid)); - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); // Get rid of all user savepoints while (transaction->tra_save_point && !transaction->tra_save_point->isRoot()) @@ -479,7 +479,7 @@ void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag // Let replicator perform heavy and error-prone part of work - REPL_trans_prepare(tdbb, transaction); + Replication::REPL_trans_prepare(tdbb, transaction); // Perform any meta data work deferred @@ -538,7 +538,7 @@ void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag // Set the state on the inventory page to be committed - REPL_trans_commit(tdbb, transaction); + Replication::REPL_trans_commit(tdbb, transaction); TRA_set_state(tdbb, transaction, transaction->tra_number, tra_committed); // Perform any post commit work @@ -576,14 +576,14 @@ void TRA_extend_tip(thread_db* tdbb, ULONG sequence) //, WIN* precedence_window) CHECK_DBB(dbb); // Start by fetching prior transaction page, if any - tx_inv_page* prior_tip = NULL; + Ods::tx_inv_page* prior_tip = NULL; WIN prior_window(DB_PAGE_SPACE, -1); if (sequence) prior_tip = fetch_inventory_page(tdbb, &prior_window, (sequence - 1), LCK_write); // Allocate and format new page WIN window(DB_PAGE_SPACE, -1); - tx_inv_page* tip = (tx_inv_page*) DPM_allocate(tdbb, &window); + Ods::tx_inv_page* tip = (Ods::tx_inv_page*) DPM_allocate(tdbb, &window); tip->tip_header.pag_type = pag_transactions; CCH_must_write(tdbb, &window); @@ -633,7 +633,7 @@ int TRA_fetch_state(thread_db* tdbb, TraNumber number) const ULONG trans_per_tip = dbb->dbb_page_manager.transPerTIP; const ULONG tip_seq = number / trans_per_tip; WIN window(DB_PAGE_SPACE, -1); - const tx_inv_page* tip = fetch_inventory_page(tdbb, &window, tip_seq, LCK_read); + const Ods::tx_inv_page* tip = fetch_inventory_page(tdbb, &window, tip_seq, LCK_read); // calculate the state of the desired transaction @@ -677,7 +677,7 @@ void TRA_get_inventory(thread_db* tdbb, UCHAR* bit_vector, TraNumber base, TraNu // fetch the first inventory page WIN window(DB_PAGE_SPACE, -1); - const tx_inv_page* tip = fetch_inventory_page(tdbb, &window, sequence++, LCK_read); + const Ods::tx_inv_page* tip = fetch_inventory_page(tdbb, &window, sequence++, LCK_read); // move the first page into the bit vector @@ -697,7 +697,7 @@ void TRA_get_inventory(thread_db* tdbb, UCHAR* bit_vector, TraNumber base, TraNu // release the read lock as we go, so that some one else can // commit without having to signal all other transactions. - tip = (tx_inv_page*) CCH_HANDOFF(tdbb, &window, inventory_page(tdbb, sequence++), + tip = (Ods::tx_inv_page*) CCH_HANDOFF(tdbb, &window, inventory_page(tdbb, sequence++), LCK_read, pag_transactions); l = TRANS_OFFSET(MIN((top + TRA_MASK + 1 - base), trans_per_tip)); @@ -754,7 +754,7 @@ void TRA_header_write(thread_db* tdbb, Database* dbb, TraNumber number) if (!number || dbb->dbb_last_header_write < number) { WIN window(HEADER_PAGE_NUMBER); - const auto header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + const auto header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); const TraNumber next_transaction = header->hdr_next_transaction; const TraNumber oldest_transaction = header->hdr_oldest_transaction; @@ -915,7 +915,7 @@ void TRA_update_counters(thread_db* tdbb, Database* dbb) } WIN window(HEADER_PAGE_NUMBER); - const auto header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + const auto header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); const TraNumber next_transaction = header->hdr_next_transaction; const TraNumber oldest_transaction = header->hdr_oldest_transaction; @@ -1160,7 +1160,7 @@ jrd_tra* TRA_reconnect(thread_db* tdbb, const UCHAR* id, USHORT length) } MemoryPool* const pool = dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, pool); + JrdContextPoolHolder context(tdbb, pool); jrd_tra* const trans = jrd_tra::create(pool, attachment, NULL); trans->tra_number = number; trans->tra_flags |= TRA_prepared | TRA_reconnected | TRA_write; @@ -1217,7 +1217,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction, Jrd::TraceTr { const ULONG temp_id = current->bli_temp_id; current->bli_blob_object->BLB_cancel(tdbb); - if (!transaction->tra_blobs->locate(Firebird::locGreat, temp_id)) + if (!transaction->tra_blobs->locate(locGreat, temp_id)) break; } } @@ -1335,7 +1335,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl EDS::Transaction::jrdTransactionEnd(tdbb, transaction, false, retaining_flag, false /*force_flag ?*/); - Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); + JrdContextPoolHolder context(tdbb, transaction->tra_pool); if (transaction->tra_flags & (TRA_prepare2 | TRA_reconnected)) MET_update_transaction(tdbb, transaction, false); @@ -1371,7 +1371,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl // because record data won't be updated with intermediate versions while (transaction->tra_save_point && !transaction->tra_save_point->isRoot()) { - REPL_save_cleanup(tdbb, transaction, transaction->tra_save_point, true); + Replication::REPL_save_cleanup(tdbb, transaction, transaction->tra_save_point, true); transaction->tra_save_point = transaction->tra_save_point->rollforward(tdbb); } @@ -1399,7 +1399,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl state = tra_committed; } } - catch (const Firebird::Exception&) + catch (const Exception&) { // Prevent a bugcheck in TRA_set_state to cause a loop // Clear the error because the rollback will succeed. @@ -1434,7 +1434,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl return; } - REPL_trans_rollback(tdbb, transaction); + Replication::REPL_trans_rollback(tdbb, transaction); TRA_set_state(tdbb, transaction, transaction->tra_number, state); TRA_release_transaction(tdbb, transaction, &trace); @@ -1478,7 +1478,7 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, TraNumber number, int const USHORT shift = TRANS_SHIFT(number); WIN window(DB_PAGE_SPACE, -1); - tx_inv_page* tip = fetch_inventory_page(tdbb, &window, sequence, LCK_write); + Ods::tx_inv_page* tip = fetch_inventory_page(tdbb, &window, sequence, LCK_write); UCHAR* address = tip->tip_transactions + byte; const int old_state = ((*address) >> shift) & TRA_MASK; @@ -1522,7 +1522,7 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, TraNumber number, int Database::Checkout dcoHolder(dbb, FB_FUNCTION); Thread::yield(); } - tip = reinterpret_cast(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions)); + tip = reinterpret_cast(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions)); if (generation == tip->tip_header.pag_generation) CCH_MARK_MUST_WRITE(tdbb, &window); CCH_RELEASE(tdbb, &window); @@ -1679,7 +1679,7 @@ jrd_tra* TRA_start(thread_db* tdbb, ULONG flags, SSHORT lock_timeout, Jrd::jrd_t // transaction block first, seize relation locks, then go ahead and // make up the real transaction block. MemoryPool* const pool = outer ? outer->getAutonomousPool() : dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, pool); + JrdContextPoolHolder context(tdbb, pool); jrd_tra* const transaction = jrd_tra::create(pool, attachment, outer); transaction->tra_flags = flags & TRA_OPTIONS_MASK; @@ -1736,7 +1736,7 @@ jrd_tra* TRA_start(thread_db* tdbb, int tpb_length, const UCHAR* tpb, Jrd::jrd_t // transaction block first, seize relation locks, then go ahead and // make up the real transaction block. MemoryPool* const pool = outer ? outer->getAutonomousPool() : dbb->createPool(); - Jrd::ContextPoolHolder context(tdbb, pool); + JrdContextPoolHolder context(tdbb, pool); jrd_tra* const transaction = jrd_tra::create(pool, attachment, outer); try @@ -1870,7 +1870,7 @@ void TRA_sweep(thread_db* tdbb) CCH_flush(tdbb, FLUSH_SWEEP, 0); WIN window(HEADER_PAGE_NUMBER); - header_page* const header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); + Ods::header_page* const header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header); if (header->hdr_oldest_transaction < --transaction_oldest_active) { @@ -1890,7 +1890,7 @@ void TRA_sweep(thread_db* tdbb) tdbb->setTransaction(tdbb_old_trans); dbb->clearSweepFlags(tdbb); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { PathName message = "Error during sweep of "; message += dbb->dbb_database_name; @@ -1905,7 +1905,7 @@ void TRA_sweep(thread_db* tdbb) { TRA_commit(tdbb, transaction, false); } - catch (const Firebird::Exception& ex2) + catch (const Exception& ex2) { ex2.stuffException(tdbb->tdbb_status_vector); } @@ -1975,7 +1975,7 @@ int TRA_wait(thread_db* tdbb, jrd_tra* trans, TraNumber number, tra_wait_t wait) if (state == tra_active) { state = tra_dead; - REPL_trans_cleanup(tdbb, number); + Replication::REPL_trans_cleanup(tdbb, number); TRA_set_state(tdbb, 0, number, tra_dead); } @@ -2034,7 +2034,7 @@ static TraNumber bump_transaction_id(thread_db* tdbb, WIN* window) #else -static header_page* bump_transaction_id(thread_db* tdbb, WIN* window, bool dontWrite) +static Ods::header_page* bump_transaction_id(thread_db* tdbb, WIN* window, bool dontWrite) { /************************************** * @@ -2052,7 +2052,7 @@ static header_page* bump_transaction_id(thread_db* tdbb, WIN* window, bool dontW CHECK_DBB(dbb); window->win_page = HEADER_PAGE_NUMBER; - header_page* header = (header_page*) CCH_FETCH(tdbb, window, LCK_write, pag_header); + Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, window, LCK_write, pag_header); const TraNumber next_transaction = header->hdr_next_transaction; const TraNumber oldest_transaction = header->hdr_oldest_transaction; @@ -2246,7 +2246,7 @@ static void expand_view_lock(thread_db* tdbb, jrd_tra* transaction, jrd_rel* rel } -static tx_inv_page* fetch_inventory_page(thread_db* tdbb, +static Ods::tx_inv_page* fetch_inventory_page(thread_db* tdbb, WIN* window, ULONG sequence, USHORT lock_level) @@ -2266,7 +2266,7 @@ static tx_inv_page* fetch_inventory_page(thread_db* tdbb, SET_TDBB(tdbb); window->win_page = inventory_page(tdbb, sequence); - tx_inv_page* tip = (tx_inv_page*) CCH_FETCH(tdbb, window, lock_level, pag_transactions); + Ods::tx_inv_page* tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, window, lock_level, pag_transactions); return tip; } @@ -2335,14 +2335,14 @@ static ULONG inventory_page(thread_db* tdbb, ULONG sequence) BUGCHECK(165); // msg 165 cannot find tip page WIN window(DB_PAGE_SPACE, dbb->getKnownPage(pag_transactions, tipCount - 1)); - tx_inv_page* tip = (tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_transactions); + Ods::tx_inv_page* tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_transactions); const ULONG next = tip->tip_next; CCH_RELEASE(tdbb, &window); if (!(window.win_page = next)) BUGCHECK(165); // msg 165 cannot find tip page // Type check it - tip = (tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_transactions); + tip = (Ods::tx_inv_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_transactions); CCH_RELEASE(tdbb, &window); DPM_pages(tdbb, 0, pag_transactions, tipCount, window.win_page.getPageNum()); } @@ -2377,7 +2377,7 @@ static int limbo_transaction(thread_db* tdbb, TraNumber id) const ULONG number = id % trans_per_tip; WIN window(DB_PAGE_SPACE, -1); - const tx_inv_page* tip = fetch_inventory_page(tdbb, &window, page, LCK_write); + const Ods::tx_inv_page* tip = fetch_inventory_page(tdbb, &window, page, LCK_write); const ULONG trans_offset = TRANS_OFFSET(number); const UCHAR* byte = tip->tip_transactions + trans_offset; @@ -2616,9 +2616,9 @@ static void retain_context(thread_db* tdbb, jrd_tra* transaction, bool commit, i if (!dbb->readOnly()) { if (commit) - REPL_trans_commit(tdbb, transaction); + Replication::REPL_trans_commit(tdbb, transaction); else - REPL_trans_rollback(tdbb, transaction); + Replication::REPL_trans_rollback(tdbb, transaction); // Set the state on the inventory page TRA_set_state(tdbb, transaction, old_number, state); @@ -3816,7 +3816,7 @@ static void transaction_start(thread_db* tdbb, jrd_tra* trans) if (dbb->isReplicating(tdbb)) trans->tra_flags |= TRA_replicating; } - catch (const Firebird::Exception&) + catch (const Exception&) { LCK_release(tdbb, lock); trans->tra_lock = nullptr; @@ -4043,12 +4043,12 @@ void jrd_tra::rollbackSavepoint(thread_db* tdbb, bool preserveLocks) { if (tra_save_point && !(tra_flags & TRA_system)) { - REPL_save_cleanup(tdbb, this, tra_save_point, true); + Replication::REPL_save_cleanup(tdbb, this, tra_save_point, true); if (tra_flags & TRA_ex_restart) preserveLocks = true; - Jrd::ContextPoolHolder context(tdbb, tra_pool); + JrdContextPoolHolder context(tdbb, tra_pool); tra_save_point = tra_save_point->rollback(tdbb, NULL, preserveLocks); } } @@ -4068,13 +4068,13 @@ void jrd_tra::rollbackToSavepoint(thread_db* tdbb, SavNumber number) * **************************************/ { - Jrd::ContextPoolHolder context(tdbb, tra_pool); + JrdContextPoolHolder context(tdbb, tra_pool); // Merge all savepoints (except the given one) into a single one while (tra_save_point && tra_save_point->getNumber() > number && tra_save_point->getNext() && tra_save_point->getNext()->getNumber() >= number) { - REPL_save_cleanup(tdbb, this, tra_save_point, true); + Replication::REPL_save_cleanup(tdbb, this, tra_save_point, true); tra_save_point = tra_save_point->rollforward(tdbb); } @@ -4104,9 +4104,9 @@ void jrd_tra::releaseSavepoint(thread_db* tdbb) { if (tra_save_point && !(tra_flags & TRA_system)) { - REPL_save_cleanup(tdbb, this, tra_save_point, false); + Replication::REPL_save_cleanup(tdbb, this, tra_save_point, false); - Jrd::ContextPoolHolder context(tdbb, tra_pool); + JrdContextPoolHolder context(tdbb, tra_pool); tra_save_point = tra_save_point->rollforward(tdbb); } } @@ -4381,3 +4381,5 @@ void jrd_tra::eraseSecDbContext() noexcept tra_sec_db_context = NULL; } + +} // namespace Firebird::Jrd diff --git a/src/jrd/tra.h b/src/jrd/tra.h index e10079bebb4..f98c430fcaa 100644 --- a/src/jrd/tra.h +++ b/src/jrd/tra.h @@ -43,16 +43,16 @@ #include "../jrd/Monitoring.h" #include "../jrd/TempSpace.h" -#include "../jrd/obj.h" +#include "../common/obj.h" #include "../jrd/EngineInterface.h" #include "../jrd/Savepoint.h" #include "../jrd/tra_proto.h" -namespace EDS { +namespace Firebird::Jrd::EDS { class Transaction; } -namespace Jrd { +namespace Firebird::Jrd { class blb; class Lock; @@ -73,11 +73,11 @@ class Resources; class SecDbContext { public: - SecDbContext(Firebird::IAttachment* a, Firebird::ITransaction* t) noexcept; + SecDbContext(IAttachment* a, ITransaction* t) noexcept; ~SecDbContext(); - Firebird::IAttachment* att; - Firebird::ITransaction* tra; + IAttachment* att; + ITransaction* tra; int savePoint; }; @@ -104,14 +104,14 @@ struct BlobIndex { } }; -typedef Firebird::BePlusTree BlobIndexTree; -typedef Firebird::BePlusTree FetchedBlobIdTree; +typedef BePlusTree BlobIndexTree; +typedef BePlusTree FetchedBlobIdTree; // Transaction block struct CallerName { - CallerName(int aType, const QualifiedName& aName, const Firebird::MetaString& aUserName) + CallerName(int aType, const QualifiedName& aName, const MetaString& aUserName) : type(aType), name(aName), userName(aUserName) @@ -142,11 +142,11 @@ struct CallerName int type; QualifiedName name; - Firebird::MetaString userName; + MetaString userName; }; -typedef Firebird::GenericMap > > ReplBlobMap; -typedef Firebird::GenericMap > > BlobUtilMap; +typedef GenericMap > > ReplBlobMap; +typedef GenericMap > > BlobUtilMap; inline constexpr int DEFAULT_LOCK_TIMEOUT = -1; // infinite inline constexpr const char* TRA_BLOB_SPACE = "fb_blob_"; @@ -155,13 +155,13 @@ inline constexpr ULONG MAX_TEMP_BLOBS = 1000; class jrd_tra final : public pool_alloc { - typedef Firebird::GenericMap > > GenIdCache; + typedef GenericMap > > GenIdCache; static constexpr size_t MAX_UNDO_RECORDS = 2; - typedef Firebird::HalfStaticArray UndoRecordList; + typedef HalfStaticArray UndoRecordList; public: - jrd_tra(MemoryPool* p, Firebird::MemoryStats* parent_stats, + jrd_tra(MemoryPool* p, MemoryStats* parent_stats, Attachment* attachment, jrd_tra* outer) : tra_attachment(attachment), tra_pool(p), @@ -177,7 +177,7 @@ class jrd_tra final : public pool_alloc traLttRel(*p), tra_context_vars(*p), tra_lock_timeout(DEFAULT_LOCK_TIMEOUT), - tra_timestamp(Firebird::TimeZoneUtil::getCurrentSystemTimeStamp()), + tra_timestamp(TimeZoneUtil::getCurrentSystemTimeStamp()), tra_stats(*p), tra_open_cursors(*p), tra_outer(outer), @@ -238,7 +238,7 @@ class jrd_tra final : public pool_alloc else { MemoryPool* const pool = transaction->tra_pool; - Firebird::MemoryStats temp_stats; + MemoryStats temp_stats; pool->setStatsGroup(temp_stats); delete transaction; attachment->att_database->deletePool(pool); @@ -270,7 +270,7 @@ class jrd_tra final : public pool_alloc TraNumber tra_initial_number; // initial transaction number, not changed by retain context jrd_tra* tra_next; // next transaction in attachment MemoryPool* const tra_pool; // pool for transaction - Firebird::MemoryStats tra_memory_stats; + MemoryStats tra_memory_stats; BlobIndexTree tra_blobs_tree; // list of active blobs BlobIndexTree* tra_blobs; // pointer to actual list of active blobs FetchedBlobIdTree tra_fetched_blobs; // list of fetched blobs @@ -286,9 +286,9 @@ class jrd_tra final : public pool_alloc SavNumber tra_save_point_number; // next save point number to use ULONG tra_flags; DeferredJob* tra_deferred_job; // work deferred to commit time - Firebird::SortedArray traExtRel; // extfile access list - Firebird::SortedArray traLttRel; // LTT access list - Firebird::StringMap tra_context_vars; // Context variables for the transaction + SortedArray traExtRel; // extfile access list + SortedArray traLttRel; // LTT access list + StringMap tra_context_vars; // Context variables for the transaction traRpbList* tra_rpblist; // active record_param's of given transaction UCHAR tra_use_count; // use count for safe AST delivery UCHAR tra_callback_count; // callback count for 'execute statement' @@ -299,7 +299,7 @@ class jrd_tra final : public pool_alloc Request* tra_requests; // Doubly linked list of requests active in this transaction MonitoringSnapshot* tra_mon_snapshot; // Database state snapshot (for monitoring purposes) RuntimeStatistics tra_stats; - Firebird::Array tra_open_cursors; + Array tra_open_cursors; bool tra_in_use; // transaction in use (can't be committed or rolled back) jrd_tra* const tra_outer; // outer transaction of an autonomous transaction CallerName tra_caller_name; // caller object name @@ -311,8 +311,8 @@ class jrd_tra final : public pool_alloc EDS::Transaction *tra_ext_common; //Transaction *tra_ext_two_phase; GenIdCache* tra_gen_ids; - Firebird::IReplicatedTransaction* tra_replicator; - Firebird::LeftPooledMap tra_cache_rels; // accessed DSQL relations + IReplicatedTransaction* tra_replicator; + LeftPooledMap tra_cache_rels; // accessed DSQL relations MdcVersion tra_mdc_version = 0; private: @@ -393,7 +393,7 @@ class jrd_tra final : public pool_alloc TimeZoneSnapshot* getTimeZoneSnapshot(thread_db* tdbb); UserManagement* getUserManagement(); SecDbContext* getSecDbContext() noexcept; - SecDbContext* setSecDbContext(Firebird::IAttachment* att, Firebird::ITransaction* tra); + SecDbContext* setSecDbContext(IAttachment* att, ITransaction* tra); void eraseSecDbContext() noexcept; MappingList* getMappingList(); Record* findNextUndo(VerbAction* before_this, jrd_rel* relation, SINT64 number); @@ -550,6 +550,6 @@ enum dfw_t : int { dfw_set_statistics // set statistics support }; -} //namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_TRA_H diff --git a/src/jrd/tra_proto.h b/src/jrd/tra_proto.h index 6ef327d85c0..9f60acb65af 100644 --- a/src/jrd/tra_proto.h +++ b/src/jrd/tra_proto.h @@ -24,60 +24,61 @@ #ifndef JRD_TRA_PROTO_H #define JRD_TRA_PROTO_H -namespace Jrd { -class Attachment; -class Database; -class TraceTransactionEnd; -class DsqlCursor; -class Request; +namespace Firebird::Jrd +{ + class Attachment; + class Database; + class TraceTransactionEnd; + class DsqlCursor; + class Request; -class Resources; -class thread_db; -class jrd_tra; + class Resources; + class thread_db; + class jrd_tra; -enum tra_wait_t { - tra_no_wait, - tra_probe, - tra_wait -}; -} // namespace Jrd + enum tra_wait_t { + tra_no_wait, + tra_probe, + tra_wait + }; -bool TRA_active_transactions(Jrd::thread_db* tdbb, Jrd::Database*); -bool TRA_cleanup(Jrd::thread_db*); -void TRA_commit(Jrd::thread_db* tdbb, Jrd::jrd_tra*, const bool); -void TRA_extend_tip(Jrd::thread_db* tdbb, ULONG /*, struct Jrd::win* */); -int TRA_fetch_state(Jrd::thread_db* tdbb, TraNumber number); -void TRA_get_inventory(Jrd::thread_db* tdbb, UCHAR*, TraNumber base, TraNumber top); -int TRA_get_state(Jrd::thread_db* tdbb, TraNumber number); + bool TRA_active_transactions(thread_db* tdbb, Database*); + bool TRA_cleanup(thread_db*); + void TRA_commit(thread_db* tdbb, jrd_tra*, const bool); + void TRA_extend_tip(thread_db* tdbb, ULONG /*, struct win* */); + int TRA_fetch_state(thread_db* tdbb, TraNumber number); + void TRA_get_inventory(thread_db* tdbb, UCHAR*, TraNumber base, TraNumber top); + int TRA_get_state(thread_db* tdbb, TraNumber number); -#ifdef SUPERSERVER_V2 -void TRA_header_write(Jrd::thread_db* tdbb, Jrd::Database* dbb, TraNumber number); -#endif -void TRA_init(Jrd::Attachment*); -void TRA_invalidate(Jrd::thread_db* tdbb, ULONG); -void TRA_link_cursor(Jrd::jrd_tra*, Jrd::DsqlCursor*); -void TRA_unlink_cursor(Jrd::jrd_tra*, Jrd::DsqlCursor*); + #ifdef SUPERSERVER_V2 + void TRA_header_write(thread_db* tdbb, Database* dbb, TraNumber number); + #endif + void TRA_init(Attachment*); + void TRA_invalidate(thread_db* tdbb, ULONG); + void TRA_link_cursor(jrd_tra*, DsqlCursor*); + void TRA_unlink_cursor(jrd_tra*, DsqlCursor*); -void TRA_post_resources(Jrd::thread_db* tdbb, Jrd::jrd_tra*, Jrd::Resources&); + void TRA_post_resources(thread_db* tdbb, jrd_tra*, Resources&); -bool TRA_is_active(Jrd::thread_db*, TraNumber); -void TRA_prepare(Jrd::thread_db* tdbb, Jrd::jrd_tra*, USHORT, const UCHAR*); -Jrd::jrd_tra* TRA_reconnect(Jrd::thread_db* tdbb, const UCHAR*, USHORT); -void TRA_release_transaction(Jrd::thread_db* tdbb, Jrd::jrd_tra*, Jrd::TraceTransactionEnd*); -void TRA_rollback(Jrd::thread_db* tdbb, Jrd::jrd_tra*, const bool, const bool); -void TRA_set_state(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, TraNumber number, int state); -int TRA_snapshot_state(Jrd::thread_db* tdbb, const Jrd::jrd_tra* trans, TraNumber number, CommitNumber* snapshot = NULL); -Jrd::jrd_tra* TRA_start(Jrd::thread_db* tdbb, ULONG flags, SSHORT lock_timeout, Jrd::jrd_tra* outer = NULL); -Jrd::jrd_tra* TRA_start(Jrd::thread_db* tdbb, int, const UCHAR*, Jrd::jrd_tra* outer = NULL); -int TRA_state(const UCHAR*, TraNumber oldest, TraNumber number) noexcept; -void TRA_sweep(Jrd::thread_db* tdbb); -void TRA_update_counters(Jrd::thread_db*, Jrd::Database*); -int TRA_wait(Jrd::thread_db* tdbb, Jrd::jrd_tra* trans, TraNumber number, Jrd::tra_wait_t wait); -void TRA_attach_request(Jrd::jrd_tra* transaction, Jrd::Request* request); -void TRA_detach_request(Jrd::Request* request); -void TRA_setup_request_snapshot(Jrd::thread_db*, Jrd::Request* request); -void TRA_release_request_snapshot(Jrd::thread_db*, Jrd::Request* request); -Jrd::Request* TRA_get_prior_request(Jrd::thread_db*); -void TRA_shutdown_sweep(); + bool TRA_is_active(thread_db*, TraNumber); + void TRA_prepare(thread_db* tdbb, jrd_tra*, USHORT, const UCHAR*); + jrd_tra* TRA_reconnect(thread_db* tdbb, const UCHAR*, USHORT); + void TRA_release_transaction(thread_db* tdbb, jrd_tra*, TraceTransactionEnd*); + void TRA_rollback(thread_db* tdbb, jrd_tra*, const bool, const bool); + void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, TraNumber number, int state); + int TRA_snapshot_state(thread_db* tdbb, const jrd_tra* trans, TraNumber number, CommitNumber* snapshot = NULL); + jrd_tra* TRA_start(thread_db* tdbb, ULONG flags, SSHORT lock_timeout, jrd_tra* outer = NULL); + jrd_tra* TRA_start(thread_db* tdbb, int, const UCHAR*, jrd_tra* outer = NULL); + int TRA_state(const UCHAR*, TraNumber oldest, TraNumber number) noexcept; + void TRA_sweep(thread_db* tdbb); + void TRA_update_counters(thread_db*, Database*); + int TRA_wait(thread_db* tdbb, jrd_tra* trans, TraNumber number, tra_wait_t wait); + void TRA_attach_request(jrd_tra* transaction, Request* request); + void TRA_detach_request(Request* request); + void TRA_setup_request_snapshot(thread_db*, Request* request); + void TRA_release_request_snapshot(thread_db*, Request* request); + Request* TRA_get_prior_request(thread_db*); + void TRA_shutdown_sweep(); +} // namespace Firebird::Jrd #endif // JRD_TRA_PROTO_H diff --git a/src/jrd/trace/TraceCmdLine.cpp b/src/jrd/trace/TraceCmdLine.cpp index b5fee6282ee..3b5b4a9cc62 100644 --- a/src/jrd/trace/TraceCmdLine.cpp +++ b/src/jrd/trace/TraceCmdLine.cpp @@ -39,11 +39,12 @@ #include "../common/classes/ClumpletReader.h" #include "../jrd/license.h" +namespace Firebird::Jrd +{ + namespace { - using namespace Firebird; - using MsgFormat::SafeArg; constexpr USHORT TRACEMGR_MSG_FAC = FB_IMPL_MSG_FACILITY_FBTRACEMGR; @@ -127,9 +128,6 @@ namespace } -namespace Firebird -{ - void fbtrace(UtilSvc* uSvc, TraceSvcIntf* traceSvc) { UtilSvc::ArgvType& argv = uSvc->argv; @@ -430,8 +428,6 @@ void fbtrace(UtilSvc* uSvc, TraceSvcIntf* traceSvc) } } - - traceSvc->setAttachInfo(svc_name, user, role, pwd, trusted); switch (action_sw->in_sw) @@ -461,4 +457,4 @@ void fbtrace(UtilSvc* uSvc, TraceSvcIntf* traceSvc) } } -} // namespace Firebird +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceConfigStorage.cpp b/src/jrd/trace/TraceConfigStorage.cpp index 67ea28fee70..62dae2906d9 100644 --- a/src/jrd/trace/TraceConfigStorage.cpp +++ b/src/jrd/trace/TraceConfigStorage.cpp @@ -60,10 +60,9 @@ #define getpid _getpid #endif +namespace Firebird::Jrd +{ -using namespace Firebird; - -namespace Jrd { static constexpr FB_UINT64 TOUCH_INTERVAL = 60 * 60; // in seconds, one hour should be enough @@ -470,7 +469,7 @@ void ConfigStorage::compact() check_used = check_size = sizeof(TraceCSHeader); // Track undeleted slots from dead processes - Firebird::SortedArray> deadProcesses; + SortedArray> deadProcesses; // collect used slots, sort them by offset for (TraceCSHeader::Slot* slot = header->slots; slot < header->slots + header->slots_cnt; slot++) @@ -733,7 +732,7 @@ void ConfigStorage::addSession(TraceSession& session) writer.write(tagEnd, 0, NULL); } -bool ConfigStorage::getSession(Firebird::TraceSession& session, GET_FLAGS getFlag) +bool ConfigStorage::getSession(TraceSession& session, GET_FLAGS getFlag) { ULONG idx; if (!findSession(session.ses_id, idx)) @@ -1003,4 +1002,5 @@ void ConfigStorage::TouchFile::stop() // ignore error in stop timer } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceConfigStorage.h b/src/jrd/trace/TraceConfigStorage.h index 2b569389754..b9a8c1245d2 100644 --- a/src/jrd/trace/TraceConfigStorage.h +++ b/src/jrd/trace/TraceConfigStorage.h @@ -37,7 +37,7 @@ #include "../../common/classes/RefCounted.h" #include -namespace Jrd { +namespace Firebird::Jrd { /* Session ID and flags are stored within slot itself. @@ -52,7 +52,7 @@ namespace Jrd { class StorageGuard; -struct TraceCSHeader final : public Firebird::MemoryHeader +struct TraceCSHeader final : public MemoryHeader { static constexpr USHORT TRACE_STORAGE_VERSION = 2; static constexpr USHORT TRACE_STORAGE_MAX_SLOTS = 1000; @@ -85,7 +85,7 @@ static_assert(sizeof(TraceCSHeader) < TraceCSHeader::TRACE_STORAGE_MIN_SIZE, "TraceCSHeader not fits TRACE_STORAGE_MIN_SIZE"); -class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::IpcObject, public Firebird::Reasons +class ConfigStorage final : public GlobalStorage, public IpcObject, public Reasons { public: enum GET_FLAGS {ALL, FLAGS, AUTH}; @@ -93,12 +93,12 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc ConfigStorage(); ~ConfigStorage(); - void addSession(Firebird::TraceSession& session); - void updateFlags(const Firebird::TraceSession& session); + void addSession(TraceSession& session); + void updateFlags(const TraceSession& session); void removeSession(ULONG id); // get session by sesion id - bool getSession(Firebird::TraceSession& session, GET_FLAGS getFlag); + bool getSession(TraceSession& session, GET_FLAGS getFlag); ULONG getChangeNumber() const { return m_sharedMemory && m_sharedMemory->getHeader() ? m_sharedMemory->getHeader()->change_number.load() : 0; } @@ -108,7 +108,7 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc void shutdown(); - mutable Firebird::Mutex m_localMutex; + mutable Mutex m_localMutex; class Accessor { @@ -129,7 +129,7 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc m_nextIdx = 0; } - bool getNext(Firebird::TraceSession& session, GET_FLAGS getFlag); + bool getNext(TraceSession& session, GET_FLAGS getFlag); private: ConfigStorage* const m_storage; @@ -141,18 +141,18 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc private: void mutexBug(int osErrorCode, const char* text) override; - bool initialize(Firebird::SharedMemoryBase*, bool) override; + bool initialize(SharedMemoryBase*, bool) override; void initSharedFile(); - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TRACE_CONFIG; } + USHORT getType() const override { return SharedMemoryBase::SRAM_TRACE_CONFIG; } USHORT getVersion() const override { return TraceCSHeader::TRACE_STORAGE_VERSION; } const char* getName() const override { return "TraceConfigStorage"; } void checkAudit(); class TouchFile final : - public Firebird::RefCntIface > + public RefCntIface > { public: TouchFile() : @@ -164,9 +164,9 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc void stop(); private: - Firebird::PathName fileName; + PathName fileName; }; - Firebird::RefPtr m_timer; + RefPtr m_timer; void checkDirty() noexcept { @@ -206,14 +206,14 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc void compact(); bool validate(); - ULONG getSessionSize(const Firebird::TraceSession& session) noexcept; + ULONG getSessionSize(const TraceSession& session) noexcept; bool findSession(ULONG sesId, ULONG& idx); - bool readSession(const TraceCSHeader::Slot* slot, Firebird::TraceSession& session, GET_FLAGS getFlag); + bool readSession(const TraceCSHeader::Slot* slot, TraceSession& session, GET_FLAGS getFlag); // Search for used slot starting from nextIdx and increments nextIdx to point to the next slot // returns false, if used slot was not found - bool getNextSession(Firebird::TraceSession& session, GET_FLAGS getFlag, ULONG& nextIdx); + bool getNextSession(TraceSession& session, GET_FLAGS getFlag, ULONG& nextIdx); class Reader { @@ -241,7 +241,7 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc void write(ITEM tag, ULONG len, const void* data); - inline void writeData(const ITEM tag, const Firebird::AbstractString& data) + inline void writeData(const ITEM tag, const AbstractString& data) { if (data.empty()) return; @@ -254,8 +254,8 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc const char* const m_end; }; - Firebird::AutoPtr > m_sharedMemory; - Firebird::PathName m_filename; + AutoPtr > m_sharedMemory; + PathName m_filename; int m_recursive; ThreadId m_mutexTID; bool m_dirty; @@ -265,11 +265,11 @@ class ConfigStorage final : public Firebird::GlobalStorage, public Firebird::Ipc class StorageInstance { private: - Firebird::Mutex initMtx; + Mutex initMtx; ConfigStorage* storage; public: - explicit StorageInstance(Firebird::MemoryPool&) : + explicit StorageInstance(MemoryPool&) : storage(NULL) {} @@ -282,7 +282,7 @@ class StorageInstance { if (!storage) { - Firebird::MutexLockGuard guard(initMtx, FB_FUNCTION); + MutexLockGuard guard(initMtx, FB_FUNCTION); if (!storage) { storage = FB_NEW ConfigStorage; @@ -293,11 +293,11 @@ class StorageInstance }; -class StorageGuard final : public Firebird::MutexLockGuard +class StorageGuard final : public MutexLockGuard { public: explicit StorageGuard(ConfigStorage* storage) : - Firebird::MutexLockGuard(storage->m_localMutex, FB_FUNCTION), m_storage(storage) + MutexLockGuard(storage->m_localMutex, FB_FUNCTION), m_storage(storage) { m_storage->acquire(); } diff --git a/src/jrd/trace/TraceDSQLHelpers.h b/src/jrd/trace/TraceDSQLHelpers.h index 1941edcac42..f153cf42a07 100644 --- a/src/jrd/trace/TraceDSQLHelpers.h +++ b/src/jrd/trace/TraceDSQLHelpers.h @@ -33,10 +33,9 @@ #include -namespace Jrd { +namespace Firebird::Jrd +{ -using Firebird::ITracePlugin; -using Firebird::ITraceFactory; class TraceDSQLPrepare { @@ -94,7 +93,7 @@ class TraceDSQLPrepare } else { - Firebird::string str(*getDefaultMemoryPool(), m_string, m_string_len); + string str(*getDefaultMemoryPool(), m_string, m_string_len); TraceFailedSQLStatement stmt(str); TraceManager::event_dsql_prepare(m_attachment, m_transaction, &stmt, millis, result); @@ -250,6 +249,6 @@ class TraceDSQLFetch }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_TRACE_DSQL_HELPERS_H diff --git a/src/jrd/trace/TraceJrdHelpers.h b/src/jrd/trace/TraceJrdHelpers.h index 9fcc1ee2975..b85404ff009 100644 --- a/src/jrd/trace/TraceJrdHelpers.h +++ b/src/jrd/trace/TraceJrdHelpers.h @@ -32,10 +32,9 @@ #include "../../jrd/trace/TraceManager.h" #include "../../jrd/trace/TraceObjects.h" -namespace Jrd { +namespace Firebird::Jrd +{ -using Firebird::ITracePlugin; -using Firebird::ITraceFactory; class TraceTransactionEnd { @@ -88,14 +87,14 @@ class TraceTransactionEnd jrd_tra* const m_transaction; const ISC_INT64 m_prevID; SINT64 m_start_clock; - Firebird::AutoPtr m_baseline; + AutoPtr m_baseline; }; class TraceProcCompile { public: - TraceProcCompile(thread_db* tdbb, const Firebird::string& name) : + TraceProcCompile(thread_db* tdbb, const string& name) : m_tdbb(tdbb), m_name(name) { const auto attachment = m_tdbb->getAttachment(); @@ -136,7 +135,7 @@ class TraceProcCompile private: bool m_need_trace; thread_db* const m_tdbb; - const Firebird::string m_name; + const string m_name; SINT64 m_start_clock; }; @@ -290,7 +289,7 @@ class TraceProcFetch class TraceFuncCompile { public: - TraceFuncCompile(thread_db* tdbb, const Firebird::string& name) : + TraceFuncCompile(thread_db* tdbb, const string& name) : m_tdbb(tdbb), m_name(name) { @@ -332,7 +331,7 @@ class TraceFuncCompile private: bool m_need_trace; thread_db* const m_tdbb; - const Firebird::string m_name; + const string m_name; SINT64 m_start_clock; }; @@ -510,8 +509,8 @@ class TraceTrigCompile private: bool m_need_trace; thread_db* const m_tdbb; - Firebird::string m_name; - Firebird::string m_relationName; + string m_name; + string m_relationName; int m_which = 0; int m_action = 0; SINT64 m_start_clock; @@ -742,6 +741,6 @@ class TraceSweepEvent // implementation is in tra.cpp }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // JRD_TRACE_JRD_HELPERS_H diff --git a/src/jrd/trace/TraceLog.cpp b/src/jrd/trace/TraceLog.cpp index ad024044f39..bbb453a5530 100644 --- a/src/jrd/trace/TraceLog.cpp +++ b/src/jrd/trace/TraceLog.cpp @@ -48,9 +48,9 @@ #include "../../common/utils_proto.h" #include "../../common/StatusHolder.h" -using namespace Firebird; +namespace Firebird::Jrd +{ -namespace Jrd { constexpr unsigned int INIT_LOG_SIZE = 1024*1024; // 1MB constexpr unsigned int FREE_SPACE_THRESHOLD = INIT_LOG_SIZE / 4; @@ -344,4 +344,5 @@ void TraceLog::unlock() m_sharedMemory->mutexUnlock(); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceLog.h b/src/jrd/trace/TraceLog.h index 702a41e2315..6ed48cde42b 100644 --- a/src/jrd/trace/TraceLog.h +++ b/src/jrd/trace/TraceLog.h @@ -31,9 +31,9 @@ #include "../../common/classes/fb_string.h" #include "../../common/isc_s_proto.h" -namespace Jrd { +namespace Firebird::Jrd { -struct TraceLogHeader final : public Firebird::MemoryHeader +struct TraceLogHeader final : public MemoryHeader { static constexpr USHORT TRACE_LOG_VERSION = 2; @@ -44,10 +44,10 @@ struct TraceLogHeader final : public Firebird::MemoryHeader ULONG flags; }; -class TraceLog final : public Firebird::IpcObject +class TraceLog final : public IpcObject { public: - TraceLog(Firebird::MemoryPool& pool, const Firebird::PathName& fileName, bool reader); + TraceLog(MemoryPool& pool, const PathName& fileName, bool reader); virtual ~TraceLog(); FB_SIZE_T read(void* buf, FB_SIZE_T size); @@ -62,9 +62,9 @@ class TraceLog final : public Firebird::IpcObject static constexpr ULONG FLAG_DONE = 0x0002; // set when reader is gone void mutexBug(int osErrorCode, const char* text) override; - bool initialize(Firebird::SharedMemoryBase*, bool) override; + bool initialize(SharedMemoryBase*, bool) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TRACE_LOG; } + USHORT getType() const override { return SharedMemoryBase::SRAM_TRACE_LOG; } USHORT getVersion() const override { return TraceLogHeader::TRACE_LOG_VERSION; } const char* getName() const override { return "TraceLog"; } @@ -75,9 +75,9 @@ class TraceLog final : public Firebird::IpcObject FB_SIZE_T getFree(bool useMax); // available for write void extend(FB_SIZE_T size); - Firebird::AutoPtr > m_sharedMemory; + AutoPtr > m_sharedMemory; bool m_reader; - Firebird::string m_fullMsg; + string m_fullMsg; class TraceLogGuard { @@ -98,6 +98,6 @@ class TraceLog final : public Firebird::IpcObject }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif // TRACE_LOG diff --git a/src/jrd/trace/TraceManager.cpp b/src/jrd/trace/TraceManager.cpp index 0a2f0857745..541b44b300a 100644 --- a/src/jrd/trace/TraceManager.cpp +++ b/src/jrd/trace/TraceManager.cpp @@ -41,9 +41,9 @@ #include #endif -using namespace Firebird; +namespace Firebird::Jrd +{ -namespace Jrd { GlobalPtr TraceManager::storageInstance; @@ -606,4 +606,5 @@ void TraceManager::event_sweep(ITraceDatabaseConnection* connection, ITraceSweep (connection, sweep, sweep_state)); } -} + +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceManager.h b/src/jrd/trace/TraceManager.h index 91c3b6b2dea..2216a194913 100644 --- a/src/jrd/trace/TraceManager.h +++ b/src/jrd/trace/TraceManager.h @@ -45,7 +45,7 @@ class ICryptKeyCallback; } -namespace Jrd { +namespace Firebird::Jrd { class Database; class Attachment; @@ -59,7 +59,7 @@ class TraceManager /* Initializes plugins. */ explicit TraceManager(Attachment* in_att); explicit TraceManager(Service* in_svc); - TraceManager(const char* in_filename, Firebird::ICryptKeyCallback* callback, bool failedAttach); + TraceManager(const char* in_filename, ICryptKeyCallback* callback, bool failedAttach); /* Finalize plugins. Called when database is closed by the engine */ ~TraceManager(); @@ -67,67 +67,67 @@ class TraceManager static ConfigStorage* getStorage() { return storageInstance->getStorage(); } - void event_attach(Firebird::ITraceDatabaseConnection* connection, bool create_db, + void event_attach(ITraceDatabaseConnection* connection, bool create_db, ntrace_result_t att_result); - void event_detach(Firebird::ITraceDatabaseConnection* connection, bool drop_db); + void event_detach(ITraceDatabaseConnection* connection, bool drop_db); /* Start/end transaction */ - void event_transaction_start(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + void event_transaction_start(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, unsigned tpb_length, const ntrace_byte_t* tpb, ntrace_result_t tra_result); - void event_transaction_end(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + void event_transaction_end(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, bool commit, bool retain_context, ntrace_result_t tra_result); - void event_set_context(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceContextVariable* variable); + void event_set_context(ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceContextVariable* variable); - void event_proc_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceProcedure* procedure, ntrace_counter_t time_millis, ntrace_result_t proc_result); + void event_proc_compile(ITraceDatabaseConnection* connection, + ITraceProcedure* procedure, ntrace_counter_t time_millis, ntrace_result_t proc_result); - void event_proc_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceProcedure* procedure, bool started, ntrace_result_t proc_result); + void event_proc_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceProcedure* procedure, bool started, ntrace_result_t proc_result); - void event_func_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceFunction* function, ntrace_counter_t time_millis, ntrace_result_t func_result); + void event_func_compile(ITraceDatabaseConnection* connection, + ITraceFunction* function, ntrace_counter_t time_millis, ntrace_result_t func_result); - void event_func_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceFunction* function, bool started, ntrace_result_t func_result); + void event_func_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceFunction* function, bool started, ntrace_result_t func_result); - void event_trigger_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTrigger* trigger, ntrace_counter_t time_millis, ntrace_result_t trig_result); + void event_trigger_compile(ITraceDatabaseConnection* connection, + ITraceTrigger* trigger, ntrace_counter_t time_millis, ntrace_result_t trig_result); - void event_trigger_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceTrigger* trigger, bool started, ntrace_result_t trig_result); + void event_trigger_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceTrigger* trigger, bool started, ntrace_result_t trig_result); - void event_blr_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceBLRStatement* statement, + void event_blr_compile(ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceBLRStatement* statement, ntrace_counter_t time_millis, ntrace_result_t req_result); - void event_blr_execute(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceBLRStatement* statement, + void event_blr_execute(ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceBLRStatement* statement, ntrace_result_t req_result); - void event_dyn_execute(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceDYNRequest* request, + void event_dyn_execute(ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceDYNRequest* request, ntrace_counter_t time_millis, ntrace_result_t req_result); - void event_service_attach(Firebird::ITraceServiceConnection* service, ntrace_result_t att_result); + void event_service_attach(ITraceServiceConnection* service, ntrace_result_t att_result); - void event_service_start(Firebird::ITraceServiceConnection* service, + void event_service_start(ITraceServiceConnection* service, unsigned switches_length, const char* switches, ntrace_result_t start_result); - void event_service_query(Firebird::ITraceServiceConnection* service, + void event_service_query(ITraceServiceConnection* service, unsigned send_item_length, const ntrace_byte_t* send_items, unsigned recv_item_length, const ntrace_byte_t* recv_items, ntrace_result_t query_result); - void event_service_detach(Firebird::ITraceServiceConnection* service, ntrace_result_t detach_result); + void event_service_detach(ITraceServiceConnection* service, ntrace_result_t detach_result); - void event_error(Firebird::ITraceConnection* connection, Firebird::ITraceStatusVector* status, const char* function); + void event_error(ITraceConnection* connection, ITraceStatusVector* status, const char* function); - void event_sweep(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceSweepInfo* sweep, + void event_sweep(ITraceDatabaseConnection* connection, ITraceSweepInfo* sweep, ntrace_process_state_t sweep_state); typedef ntrace_mask_t NotificationNeeds; @@ -167,13 +167,13 @@ class TraceManager static bool need_dsql_free(Attachment* att); static bool need_dsql_execute(Attachment* att); - static void event_dsql_prepare(Attachment* att, jrd_tra* transaction, Firebird::ITraceSQLStatement* statement, + static void event_dsql_prepare(Attachment* att, jrd_tra* transaction, ITraceSQLStatement* statement, ntrace_counter_t time_millis, ntrace_result_t req_result); - static void event_dsql_free(Attachment* att, Firebird::ITraceSQLStatement* statement, + static void event_dsql_free(Attachment* att, ITraceSQLStatement* statement, unsigned short option); - static void event_dsql_execute(Attachment* att, jrd_tra* transaction, Firebird::ITraceSQLStatement* statement, + static void event_dsql_execute(Attachment* att, jrd_tra* transaction, ITraceSQLStatement* statement, bool started, ntrace_result_t req_result); static void event_dsql_restart(Attachment* att, jrd_tra* transaction, DsqlRequest* statement, const UCHAR* data, @@ -185,7 +185,7 @@ class TraceManager Attachment* attachment; Service* service; const char* filename; - Firebird::ICryptKeyCallback* callback; + ICryptKeyCallback* callback; NotificationNeeds trace_needs, new_needs; // This structure should be POD-like to be stored in Array @@ -194,11 +194,11 @@ class TraceManager { char pluginName[MAXPATHLEN] = {}; - Firebird::ITracePlugin* plugin; - Firebird::ITraceFactory* factory; + ITracePlugin* plugin; + ITraceFactory* factory; ULONG ses_id; - inline void release(Firebird::PluginManagerInterfacePtr& pi) + inline void release(PluginManagerInterfacePtr& pi) { plugin->release(); pi->releasePlugin(factory); @@ -206,7 +206,7 @@ class TraceManager inline void release() { - Firebird::PluginManagerInterfacePtr pi; + PluginManagerInterfacePtr pi; release(pi); } @@ -214,16 +214,16 @@ class TraceManager static ULONG generate(const SessionInfo& item) { return item.ses_id; } }; - class Sessions : public Firebird::SortedArray, ULONG, SessionInfo> + class Sessions : public SortedArray, ULONG, SessionInfo> { public: explicit Sessions(MemoryPool& p) - : Firebird::SortedArray, ULONG, SessionInfo>(p) + : SortedArray, ULONG, SessionInfo>(p) { } ~Sessions() { - Firebird::PluginManagerInterfacePtr pi; + PluginManagerInterfacePtr pi; for (unsigned int i = 0; i < getCount(); ++i) { @@ -235,26 +235,26 @@ class TraceManager void init(); void update_sessions(); - void update_session(const Firebird::TraceSession& session); + void update_session(const TraceSession& session); - bool check_result(Firebird::ITracePlugin* plugin, const char* module, const char* function, bool result); + bool check_result(ITracePlugin* plugin, const char* module, const char* function, bool result); /* DSQL statement lifecycle. To be moved to public and used directly when DSQL becomes a part of JRD */ - void event_dsql_prepare(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, + void event_dsql_prepare(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, ntrace_counter_t time_millis, ntrace_result_t req_result); - void event_dsql_free(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceSQLStatement* statement, unsigned short option); + void event_dsql_free(ITraceDatabaseConnection* connection, + ITraceSQLStatement* statement, unsigned short option); - void event_dsql_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, + void event_dsql_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, bool started, ntrace_result_t req_result); - void event_dsql_restart(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, Firebird::ITraceSQLStatement* statement, + void event_dsql_restart(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, ITraceSQLStatement* statement, unsigned number); - static Firebird::GlobalPtr storageInstance; + static GlobalPtr storageInstance; ULONG changeNumber; bool active, failedAttach; diff --git a/src/jrd/trace/TraceObjects.cpp b/src/jrd/trace/TraceObjects.cpp index b91d579523d..ca62df4c8a8 100644 --- a/src/jrd/trace/TraceObjects.cpp +++ b/src/jrd/trace/TraceObjects.cpp @@ -55,7 +55,9 @@ #include #endif -using namespace Firebird; +namespace Firebird::Jrd +{ + namespace { @@ -108,7 +110,7 @@ bool descToUTF8(const paramdsc* param, string& result) if (!Jrd::DataTypeUtil::convertToUTF8(src, result, CSetId(param->dsc_sub_type), status_exception::raise)) result = src; } - catch (const Firebird::Exception&) + catch (const Exception&) { result = src; } @@ -118,7 +120,6 @@ bool descToUTF8(const paramdsc* param, string& result) } // namespace -namespace Jrd { const char* StatementHolder::ensurePlan(bool explained) { @@ -134,7 +135,7 @@ const char* StatementHolder::ensurePlan(bool explained) /// StatementHolder -Firebird::string StatementHolder::getName() const +string StatementHolder::getName() const { if (m_statement) { @@ -662,14 +663,14 @@ TraceRuntimeStats::TraceRuntimeStats(Attachment* attachment, m_globalCounters[PerformanceInfo::MARKS] = (*baseline)[PageStatType::MARKS]; m_globalCounters[PerformanceInfo::WRITES] = (*baseline)[PageStatType::WRITES]; - auto getTablespaceName = [&](MetaId id) -> Firebird::string + auto getTablespaceName = [&](MetaId id) -> string { return ""; // TODO }; m_pageCounters.reset(&baseline->getPageCounters(), getTablespaceName); - auto getTableName = [&](MetaId id) -> Firebird::string + auto getTableName = [&](MetaId id) -> string { auto* mdc = attachment->att_database->dbb_mdc; if (const auto* relation = mdc->lookupRelationNoChecks(id)) @@ -729,4 +730,5 @@ const char* TraceStatusVectorImpl::getText() return m_error.c_str(); } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceObjects.h b/src/jrd/trace/TraceObjects.h index 00b0d466228..bd0352a105c 100644 --- a/src/jrd/trace/TraceObjects.h +++ b/src/jrd/trace/TraceObjects.h @@ -48,7 +48,8 @@ #include "../../common/prett_proto.h" //// TODO: DDL triggers, packages and external procedures and functions support -namespace Jrd { +namespace Firebird::Jrd +{ class Database; class Attachment; @@ -71,30 +72,30 @@ class StatementHolder return m_statement ? m_statement->getStatementId() : 0; } - Firebird::string getName() const; + string getName() const; const char* ensurePlan(bool explained); private: const Statement* const m_statement; - Firebird::string m_plan; + string m_plan; bool m_planExplained = false; }; class TraceRuntimeStats : - public Firebird::AutoIface > + public AutoIface> { static constexpr unsigned GLOBAL_COUNTERS = 4; // PerformanceInfo::{FETCHES|READS|MARKS|WRITES} template class GenericCounters : - public Firebird::AutoIface, Firebird::CheckStatusWrapper> > + public AutoIface, CheckStatusWrapper>> { public: GenericCounters() = default; ~GenericCounters() = default; - void reset(const T* counters, std::function getName) + void reset(const T* counters, std::function getName) { m_counts = counters; m_names.clear(); @@ -145,7 +146,7 @@ class TraceRuntimeStats : } private: - Firebird::ObjectsArray m_names; + ObjectsArray m_names; const T* m_counts = nullptr; }; @@ -167,9 +168,9 @@ class TraceRuntimeStats : return m_info.pin_records_fetched; } - Firebird::IPerformanceCounters* getCounters(unsigned group) + IPerformanceCounters* getCounters(unsigned group) { - Firebird::IPerformanceCounters* counters = nullptr; + IPerformanceCounters* counters = nullptr; switch (group) { @@ -188,22 +189,22 @@ class TraceRuntimeStats : return counters; } - Firebird::PerformanceInfo* getInfo() + PerformanceInfo* getInfo() { return &m_info; } private: - Firebird::PerformanceInfo m_info; + PerformanceInfo m_info; PageCounters m_pageCounters; TableCounters m_tableCounters; SINT64 m_globalCounters[GLOBAL_COUNTERS]; - Firebird::HalfStaticArray m_legacyCounts; + HalfStaticArray m_legacyCounts; }; class TraceConnectionImpl : - public Firebird::AutoIface > + public AutoIface> { public: TraceConnectionImpl(Attachment* att) : @@ -230,7 +231,7 @@ class TraceConnectionImpl : class TraceTransactionImpl : - public Firebird::AutoIface > + public AutoIface> { public: TraceTransactionImpl(const jrd_tra* tran, TraceRuntimeStats* stats = nullptr, ISC_INT64 prevID = 0) : @@ -251,12 +252,12 @@ class TraceTransactionImpl : return m_prevID; } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; } - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; } @@ -270,7 +271,7 @@ class TraceTransactionImpl : template class BLRPrinter : - public Firebird::AutoIface > + public AutoIface> { public: BLRPrinter(const unsigned char* blr, unsigned length) : @@ -302,14 +303,14 @@ class BLRPrinter : { BLRPrinter* blr = (BLRPrinter*) arg; - Firebird::string temp; + string temp; temp.printf("%4d %s\n", offset, line); blr->m_text.append(temp); } const unsigned char* const m_blr; const unsigned m_length; - Firebird::string m_text; + string m_text; }; @@ -327,12 +328,12 @@ class TraceBLRStatementImpl : public BLRPrinter return m_stmt->getStatementId(); } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; } - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; } @@ -351,13 +352,13 @@ class TraceFailedBLRStatement : public BLRPrinter {} ISC_INT64 getStmtID() { return 0; } - Firebird::PerformanceInfo* getPerf() { return nullptr; } - Firebird::IPerformanceStats* getPerfStats() { return nullptr; } + PerformanceInfo* getPerf() { return nullptr; } + IPerformanceStats* getPerfStats() { return nullptr; } }; class TraceSQLStatementImpl : - public Firebird::AutoIface >, + public AutoIface>, public StatementHolder { public: @@ -373,7 +374,7 @@ class TraceSQLStatementImpl : const char* getText(); const char* getTextUTF8(); - Firebird::ITraceParams* getInputs() + ITraceParams* getInputs() { return &m_inputs; } @@ -388,19 +389,19 @@ class TraceSQLStatementImpl : return ensurePlan(true); } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; } - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; } private: class DSQLParamsImpl : - public Firebird::AutoIface > + public AutoIface> { public: explicit DSQLParamsImpl(DsqlRequest* const stmt, const UCHAR* const inputBuffer) : @@ -409,50 +410,50 @@ class TraceSQLStatementImpl : FB_SIZE_T getCount(); const paramdsc* getParam(FB_SIZE_T idx); - const char* getTextUTF8(Firebird::CheckStatusWrapper* status, FB_SIZE_T idx); + const char* getTextUTF8(CheckStatusWrapper* status, FB_SIZE_T idx); private: void fillParams(); DsqlRequest* const m_stmt; const UCHAR* m_buffer; - Firebird::HalfStaticArray m_descs; - Firebird::string m_tempUTF8; + HalfStaticArray m_descs; + string m_tempUTF8; }; DsqlRequest* const m_stmt; DSQLParamsImpl m_inputs; - Firebird::string m_textUTF8; + string m_textUTF8; TraceRuntimeStats* const m_stats; }; class TraceFailedSQLStatement : - public Firebird::AutoIface > + public AutoIface> { public: - TraceFailedSQLStatement(Firebird::string& text) : + TraceFailedSQLStatement(string& text) : m_text(text) {} // TraceSQLStatement implementation ISC_INT64 getStmtID() { return 0; } - Firebird::ITraceParams* getInputs() { return nullptr; } + ITraceParams* getInputs() { return nullptr; } const char* getText() { return m_text.c_str(); } const char* getPlan() { return ""; } const char* getTextUTF8(); const char* getExplainedPlan() { return ""; } - Firebird::PerformanceInfo* getPerf() { return nullptr; } - Firebird::IPerformanceStats* getPerfStats() { return nullptr; } + PerformanceInfo* getPerf() { return nullptr; } + IPerformanceStats* getPerfStats() { return nullptr; } private: - Firebird::string& m_text; - Firebird::string m_textUTF8; + string& m_text; + string m_textUTF8; }; class TraceContextVarImpl : - public Firebird::AutoIface > + public AutoIface> { public: TraceContextVarImpl(const char* ns, const char* name, const char* value) : @@ -477,7 +478,7 @@ class TraceContextVarImpl : class TraceDescriptors; class TraceParamsImpl : - public Firebird::AutoIface > + public AutoIface> { public: explicit TraceParamsImpl(TraceDescriptors *descs) : @@ -487,11 +488,11 @@ class TraceParamsImpl : // TraceParams implementation FB_SIZE_T getCount(); const paramdsc* getParam(FB_SIZE_T idx); - const char* getTextUTF8(Firebird::CheckStatusWrapper* status, FB_SIZE_T idx); + const char* getTextUTF8(CheckStatusWrapper* status, FB_SIZE_T idx); private: TraceDescriptors* m_descs; - Firebird::string m_tempUTF8; + string m_tempUTF8; }; @@ -519,7 +520,7 @@ class TraceDescriptors return NULL; } - operator Firebird::ITraceParams* () + operator ITraceParams* () { return &m_traceParams; } @@ -527,7 +528,7 @@ class TraceDescriptors protected: virtual void fillParams() = 0; - Firebird::HalfStaticArray m_descs; + HalfStaticArray m_descs; private: TraceParamsImpl m_traceParams; @@ -590,11 +591,11 @@ class TraceDscFromDsc : public TraceDescriptors class TraceProcedureImpl : - public Firebird::AutoIface >, + public AutoIface>, public StatementHolder { public: - TraceProcedureImpl(const Firebird::string& name, const Statement* statement) : + TraceProcedureImpl(const string& name, const Statement* statement) : StatementHolder(statement), m_name(name), m_inputs(nullptr, nullptr), @@ -614,7 +615,7 @@ class TraceProcedureImpl : return m_name.c_str(); } - Firebird::ITraceParams* getInputs() + ITraceParams* getInputs() { return m_inputs; } @@ -634,29 +635,29 @@ class TraceProcedureImpl : return ensurePlan(true); } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; } - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; } private: - const Firebird::string m_name; + const string m_name; TraceDscFromValues m_inputs; TraceRuntimeStats* const m_stats; }; class TraceFunctionImpl : - public Firebird::AutoIface >, + public AutoIface>, public StatementHolder { public: - TraceFunctionImpl(const Firebird::string& name, const Statement* statement) : + TraceFunctionImpl(const string& name, const Statement* statement) : StatementHolder(statement), m_name(name), m_inputs(nullptr), @@ -665,7 +666,7 @@ class TraceFunctionImpl : {} TraceFunctionImpl(Request* request, TraceRuntimeStats* stats, - Firebird::ITraceParams* inputs, const dsc* value) : + ITraceParams* inputs, const dsc* value) : StatementHolder(request), m_name(getName()), m_inputs(inputs), @@ -679,12 +680,12 @@ class TraceFunctionImpl : return m_name.c_str(); } - Firebird::ITraceParams* getInputs() + ITraceParams* getInputs() { return m_inputs; } - Firebird::ITraceParams* getResult() + ITraceParams* getResult() { return m_value; } @@ -704,30 +705,30 @@ class TraceFunctionImpl : return ensurePlan(true); } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; }; - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; }; private: - Firebird::string m_name; - Firebird::ITraceParams* const m_inputs; + string m_name; + ITraceParams* const m_inputs; TraceDscFromDsc m_value; TraceRuntimeStats* const m_stats; }; class TraceTriggerImpl : - public Firebird::AutoIface >, + public AutoIface>, public StatementHolder { public: - TraceTriggerImpl(const Firebird::string& name, const Firebird::string& relationName, + TraceTriggerImpl(const string& name, const string& relationName, int which, int action, const Statement* statement) : StatementHolder(statement), m_name(name), @@ -783,19 +784,19 @@ class TraceTriggerImpl : return ensurePlan(true); } - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; }; - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; }; private: - const Firebird::string m_name; - const Firebird::string m_relationName; + const string m_name; + const string m_relationName; const int m_which; const int m_action; TraceRuntimeStats* const m_stats; @@ -803,7 +804,7 @@ class TraceTriggerImpl : class TraceServiceImpl : - public Firebird::AutoIface > + public AutoIface> { public: TraceServiceImpl(const Service* svc) : @@ -831,10 +832,10 @@ class TraceServiceImpl : class TraceInitInfoImpl : - public Firebird::AutoIface > + public AutoIface> { public: - TraceInitInfoImpl(const Firebird::TraceSession& session, Attachment* att, + TraceInitInfoImpl(const TraceSession& session, Attachment* att, const char* filename) : m_session(session), m_trace_conn(att), @@ -854,7 +855,7 @@ class TraceInitInfoImpl : const char* getFirebirdRootDirectory(); const char* getDatabaseName() { return m_filename; } - Firebird::ITraceDatabaseConnection* getConnection() + ITraceDatabaseConnection* getConnection() { if (m_attachment) return &m_trace_conn; @@ -862,11 +863,11 @@ class TraceInitInfoImpl : return NULL; } - Firebird::ITraceLogWriter* getLogWriter(); + ITraceLogWriter* getLogWriter(); private: - const Firebird::TraceSession& m_session; - Firebird::RefPtr m_logWriter; + const TraceSession& m_session; + RefPtr m_logWriter; TraceConnectionImpl m_trace_conn; const char* m_filename; const Attachment* const m_attachment; @@ -874,7 +875,7 @@ class TraceInitInfoImpl : class TraceStatusVectorImpl : - public Firebird::AutoIface > + public AutoIface> { public: enum Kind {TS_ERRORS, TS_WARNINGS}; @@ -886,15 +887,15 @@ class TraceStatusVectorImpl : FB_BOOLEAN hasError() { - return m_status->getState() & Firebird::IStatus::STATE_ERRORS; + return m_status->getState() & IStatus::STATE_ERRORS; } FB_BOOLEAN hasWarning() { - return m_status->getState() & Firebird::IStatus::STATE_WARNINGS; + return m_status->getState() & IStatus::STATE_WARNINGS; } - Firebird::IStatus* getStatus() + IStatus* getStatus() { return m_status; } @@ -902,13 +903,13 @@ class TraceStatusVectorImpl : const char* getText(); private: - Firebird::string m_error; + string m_error; FbStatusVector* m_status; Kind kind; }; class TraceSweepImpl : - public Firebird::AutoIface > + public AutoIface> { public: TraceSweepImpl() = default; @@ -931,12 +932,12 @@ class TraceSweepImpl : ISC_INT64 getOAT() { return m_oat; }; ISC_INT64 getNext() { return m_next; }; - Firebird::PerformanceInfo* getPerf() + PerformanceInfo* getPerf() { return m_stats ? m_stats->getInfo() : nullptr; }; - Firebird::IPerformanceStats* getPerfStats() + IPerformanceStats* getPerfStats() { return m_stats; }; @@ -949,6 +950,7 @@ class TraceSweepImpl : TraceRuntimeStats* m_stats = nullptr; }; -} // namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_TRACE_OBJECTS_H diff --git a/src/jrd/trace/TraceService.cpp b/src/jrd/trace/TraceService.cpp index 6762f266394..424f35fe3e4 100644 --- a/src/jrd/trace/TraceService.cpp +++ b/src/jrd/trace/TraceService.cpp @@ -43,8 +43,8 @@ #include "../../jrd/scl.h" #include "../../jrd/Mapping.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Jrd +{ class TraceSvcJrd : public TraceSvcIntf @@ -412,3 +412,6 @@ int TRACE_main(UtilSvc* arg) return exit_code; } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/trace/TraceService.h b/src/jrd/trace/TraceService.h index 1a950bdc845..55415837c85 100644 --- a/src/jrd/trace/TraceService.h +++ b/src/jrd/trace/TraceService.h @@ -39,11 +39,11 @@ #include "../../common/ThreadData.h" #include "../../jrd/trace/TraceSession.h" - -int TRACE_main(Firebird::UtilSvc*); +namespace Firebird::Jrd +{ -namespace Firebird { +int TRACE_main(UtilSvc*); class TraceSvcIntf { @@ -61,7 +61,7 @@ class TraceSvcIntf void fbtrace(UtilSvc* uSvc, TraceSvcIntf* traceSvc); -} // namespace Firebird +} // namespace Firebird::Jrd #endif // JRD_TRACESERVICE_H diff --git a/src/jrd/trace/traceswi.h b/src/jrd/trace/traceswi.h index 10452849ed0..85f6f47f107 100644 --- a/src/jrd/trace/traceswi.h +++ b/src/jrd/trace/traceswi.h @@ -26,6 +26,10 @@ #include "../../jrd/constants.h" +namespace Firebird::Jrd +{ + + inline constexpr int IN_SW_TRACE_START = 1; inline constexpr int IN_SW_TRACE_STOP = 2; inline constexpr int IN_SW_TRACE_SUSPEND = 3; @@ -78,3 +82,6 @@ static inline constexpr struct Switches::in_sw_tab_t trace_auth_in_sw_table [] = {IN_SW_TRACE_ROLE, 0, "ROLE", 0, 0, 0, false, false, 0, 3, NULL}, {0, 0, NULL, 0, 0, 0, false, false, 0, 0, NULL} // End of List }; + + +} // namespace Firebird::Jrd diff --git a/src/jrd/trig.h b/src/jrd/trig.h index 53bb6bba270..23d5ad9a7fd 100644 --- a/src/jrd/trig.h +++ b/src/jrd/trig.h @@ -30,7 +30,9 @@ check out GRANT.GDL, modify the trigger source to generate the proper blr, replace the blr in TRIG.H, and check both files back in. */ -namespace Jrd { +namespace Firebird::Jrd +{ + /* trigger definition structure */ @@ -65,8 +67,6 @@ struct gen USHORT gen_ods_version; }; -} //namespace Jrd - /* generators needed by the system triggers */ // Keep in sync with constants.h static inline constexpr Jrd::gen generators[] = @@ -86,4 +86,6 @@ static inline constexpr Jrd::gen generators[] = }; +} // namespace Firebird::Jrd + #endif /* JRD_TRIG_H */ diff --git a/src/jrd/types.h b/src/jrd/types.h index c9698f97408..3ca6fa732d8 100644 --- a/src/jrd/types.h +++ b/src/jrd/types.h @@ -195,7 +195,7 @@ TYPE("DETERMINISTIC", 1, nam_deterministic_flag) TYPE("USER", 0, nam_map_to_type) TYPE("ROLE", 1, nam_map_to_type) -#define SYSTEM_PRIVILEGE(p) TYPE(STRINGIZE(p), int(Jrd::p), nam_system_privileges) +#define SYSTEM_PRIVILEGE(p) TYPE(STRINGIZE(p), int(p), nam_system_privileges) #include "SystemPrivileges.h" #undef SYSTEM_PRIVILEGE diff --git a/src/jrd/val.h b/src/jrd/val.h index 06da4f8ad9e..4fe1cbab1d1 100644 --- a/src/jrd/val.h +++ b/src/jrd/val.h @@ -41,6 +41,10 @@ #define FLAG_BYTES(n) (((n + BITS_PER_LONG) & ~((ULONG)BITS_PER_LONG - 1)) >> 3) +namespace Firebird::Jrd +{ + + // Random string block -- as long as impure areas don't have // constructors and destructors, the need this varying string @@ -53,8 +57,6 @@ class VaryingString : public pool_alloc_rpt inline constexpr ULONG MAX_RECORD_SIZE = 1048576; // 1 MB -- just to protect from possible misuse -namespace Jrd { - class ArrayField; class blb; class Request; @@ -91,7 +93,7 @@ struct SortValueItem const dsc* desc; }; -typedef Firebird::SortedArray SortedValueList; +typedef SortedArray SortedValueList; class LookupValueList { @@ -103,10 +105,10 @@ class LookupValueList ValueExprNode** end() { return m_values.end(); } const SortedValueList* init(thread_db* tdbb, Request* request) const; - Firebird::TriState find(thread_db* tdbb, Request* request, const ValueExprNode* value, const dsc* desc) const; + TriState find(thread_db* tdbb, Request* request, const ValueExprNode* value, const dsc* desc) const; private: - Firebird::HalfStaticArray m_values; + HalfStaticArray m_values; const ULONG m_impureOffset; }; @@ -129,7 +131,7 @@ struct impure_value ULONG keySize; USHORT ttype; USHORT patternLen; - Firebird::AutoPtr matcher; + AutoPtr matcher; USHORT escapeLen; UCHAR key[1]; }; @@ -148,9 +150,9 @@ struct impure_value SLONG vlu_dbkey[2]; float vlu_float; double vlu_double; - Firebird::Decimal64 vlu_dec64; - Firebird::Decimal128 vlu_dec128; - Firebird::Int128 vlu_int128; + Decimal64 vlu_dec64; + Decimal128 vlu_dec128; + Int128 vlu_int128; GDS_TIMESTAMP vlu_timestamp; ISC_TIMESTAMP_TZ vlu_timestamp_tz; GDS_TIME vlu_sql_time; @@ -159,7 +161,7 @@ struct impure_value bid vlu_bid; // Pre-compiled invariant object for pattern matcher functions - Jrd::PatternMatcher* vlu_invariant; + PatternMatcher* vlu_invariant; PatternMatcherCache* vlu_patternMatcherCache; SortedValueList* vlu_sortedList; } vlu_misc; @@ -167,8 +169,8 @@ struct impure_value void make_long(const SLONG val, const signed char scale = 0); void make_int64(const SINT64 val, const signed char scale = 0); void make_double(const double val); - void make_decimal128(const Firebird::Decimal128 val); - void make_decimal_fixed(const Firebird::Int128 val, const signed char scale); + void make_decimal128(const Decimal128 val); + void make_decimal_fixed(const Int128 val, const signed char scale); template VaryingString* getString(MemoryPool& pool, const T length) = delete; // Prevent dangerous length shrink @@ -209,21 +211,21 @@ inline void impure_value::make_double(const double val) this->vlu_desc.dsc_address = reinterpret_cast(&this->vlu_misc.vlu_double); } -inline void impure_value::make_decimal128(const Firebird::Decimal128 val) +inline void impure_value::make_decimal128(const Decimal128 val) { this->vlu_misc.vlu_dec128 = val; this->vlu_desc.dsc_dtype = dtype_dec128; - this->vlu_desc.dsc_length = sizeof(Firebird::Decimal128); + this->vlu_desc.dsc_length = sizeof(Decimal128); this->vlu_desc.dsc_scale = 0; this->vlu_desc.dsc_sub_type = 0; this->vlu_desc.dsc_address = reinterpret_cast(&this->vlu_misc.vlu_dec128); } -inline void impure_value::make_decimal_fixed(const Firebird::Int128 val, const signed char scale) +inline void impure_value::make_decimal_fixed(const Int128 val, const signed char scale) { this->vlu_misc.vlu_int128 = val; this->vlu_desc.dsc_dtype = dtype_int128; - this->vlu_desc.dsc_length = sizeof(Firebird::Int128); + this->vlu_desc.dsc_length = sizeof(Int128); this->vlu_desc.dsc_scale = scale; this->vlu_desc.dsc_sub_type = 0; this->vlu_desc.dsc_address = reinterpret_cast(&this->vlu_misc.vlu_int128); @@ -314,18 +316,18 @@ class Format : public pool_alloc return fmt_desc == v.fmt_desc; } - void hash(Firebird::sha512& digest) const; + void hash(sha512& digest) const; ULONG fmt_length; USHORT fmt_count; USHORT fmt_version; - Firebird::Array fmt_desc; - Firebird::Array fmt_defaults; + Array fmt_desc; + Array fmt_defaults; - typedef Firebird::Array::iterator fmt_desc_iterator; - typedef Firebird::Array::const_iterator fmt_desc_const_iterator; + typedef Array::iterator fmt_desc_iterator; + typedef Array::const_iterator fmt_desc_const_iterator; - typedef Firebird::Array::iterator fmt_defaults_iterator; + typedef Array::iterator fmt_defaults_iterator; }; @@ -394,6 +396,7 @@ struct udf_blob SLONG (*blob_seek) (blb*, USHORT, SLONG); }; -} //namespace Jrd + +} // namespace Firebird::Jrd #endif // JRD_VAL_H diff --git a/src/jrd/val_proto.h b/src/jrd/val_proto.h index 1272059dd14..5c4e0caf742 100644 --- a/src/jrd/val_proto.h +++ b/src/jrd/val_proto.h @@ -24,8 +24,12 @@ #ifndef JRD_VAL_PROTO_H #define JRD_VAL_PROTO_H -bool VAL_validate(Jrd::thread_db*, USHORT); -int VAL_service(Firebird::UtilSvc*); +namespace Firebird::Jrd +{ + + +bool VAL_validate(thread_db*, USHORT); +int VAL_service(UtilSvc*); inline constexpr int IN_SW_VAL_TAB_INCL = 1; inline constexpr int IN_SW_VAL_TAB_EXCL = 2; @@ -49,5 +53,7 @@ static inline constexpr Switches::in_sw_tab_t val_option_in_sw_table[] = {0, 0, NULL, 0, 0, 0, false, false, 0, 0, NULL} // End of List }; -#endif // JRD_VAL_PROTO_H +} // namespace Firebird::Jrd + +#endif // JRD_VAL_PROTO_H diff --git a/src/jrd/validation.cpp b/src/jrd/validation.cpp index 183e2489a34..d07fed8d158 100644 --- a/src/jrd/validation.cpp +++ b/src/jrd/validation.cpp @@ -582,13 +582,12 @@ VI. ADDITIONAL NOTES static USHORT VAL_debug_level = 0; #endif -using namespace Jrd; -using namespace Ods; -using namespace Firebird; +namespace Firebird::Jrd +{ #ifdef DEBUG_VAL_VERBOSE -static void print_rhd(USHORT, const rhd*); +static void print_rhd(USHORT, const Ods::rhd*); #endif @@ -619,33 +618,33 @@ static SimilarToRegex* createPatternMatcher(thread_db* tdbb, const char* pattern } -static void explain_pp_bits(const UCHAR bits, Firebird::string& names) +static void explain_pp_bits(const UCHAR bits, string& names) { - if (bits & ppg_dp_full) + if (bits & Ods::ppg_dp_full) names = "full"; - if (bits & ppg_dp_large) + if (bits & Ods::ppg_dp_large) { if (!names.empty()) names.append(", "); names.append("large"); } - if (bits & ppg_dp_swept) + if (bits & Ods::ppg_dp_swept) { if (!names.empty()) names.append(", "); names.append("swept"); } - if (bits & ppg_dp_secondary) + if (bits & Ods::ppg_dp_secondary) { if (!names.empty()) names.append(", "); names.append("secondary"); } - if (bits & ppg_dp_empty) + if (bits & Ods::ppg_dp_empty) { if (!names.empty()) names.append(", "); @@ -687,7 +686,7 @@ bool VAL_validate(thread_db* tdbb, USHORT switches) } -static int validate(Firebird::UtilSvc* svc) +static int validate(UtilSvc* svc) { PathName dbName; string userName; @@ -760,7 +759,7 @@ static int validate(Firebird::UtilSvc* svc) att->att_use_count++; val_pool = dbb->createPool(false); - Jrd::ContextPoolHolder context(tdbb, val_pool); + JrdContextPoolHolder context(tdbb, val_pool); Validation control(tdbb, svc); control.run(tdbb, Validation::VDR_records | Validation::VDR_online | Validation::VDR_partial); @@ -781,7 +780,7 @@ static int validate(Firebird::UtilSvc* svc) } -int VAL_service(Firebird::UtilSvc* svc) +int VAL_service(UtilSvc* svc) { svc->getStatusAccessor().init(); @@ -805,9 +804,6 @@ int VAL_service(Firebird::UtilSvc* svc) } -namespace Jrd -{ - const Validation::MSG_ENTRY Validation::vdr_msg_table[VAL_MAX_ERROR] = { {true, isc_info_page_errors, "Page %" ULONGFORMAT" wrong type (expected %s encountered %s)"}, // 0 @@ -1023,12 +1019,12 @@ bool Validation::run(thread_db* tdbb, USHORT flags) vdr_tdbb = tdbb; MemoryPool* val_pool = NULL; Database* dbb = tdbb->getDatabase(); - Firebird::PathName fileName = tdbb->getAttachment()->att_filename; + PathName fileName = tdbb->getAttachment()->att_filename; try { val_pool = dbb->createPool(false); - Jrd::ContextPoolHolder context(tdbb, val_pool); + JrdContextPoolHolder context(tdbb, val_pool); vdr_flags = flags; @@ -1061,11 +1057,11 @@ bool Validation::run(thread_db* tdbb, USHORT flags) gds__log("Database: %s\n\tValidation finished: %d errors, %d warnings, %d fixed", fileName.c_str(), vdr_errors, vdr_warns, vdr_fixed); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(tdbb->tdbb_status_vector); - Firebird::string err; + string err; err.printf("Database: %s\n\tValidation aborted", fileName.c_str()); iscLogStatus(err.c_str(), tdbb->tdbb_status_vector); @@ -1205,7 +1201,7 @@ Validation::FETCH_CODE Validation::fetch_page(bool mark, ULONG page_number, window->win_page = page_number; window->win_flags = 0; - pag** page_pointer = reinterpret_cast(aPage_pointer); + Ods::pag** page_pointer = reinterpret_cast(aPage_pointer); FB_SIZE_T pos; if (vdr_used_bdbs.find(page_number, pos)) @@ -1230,7 +1226,7 @@ Validation::FETCH_CODE Validation::fetch_page(bool mark, ULONG page_number, if ((*page_pointer)->pag_type != type && type != pag_undefined) { corrupt(VAL_PAG_WRONG_TYPE, 0, page_number, - pagtype(type).c_str(), pagtype((*page_pointer)->pag_type).c_str()); + Ods::pagtype(type).c_str(), Ods::pagtype((*page_pointer)->pag_type).c_str()); return fetch_type; } @@ -1274,7 +1270,7 @@ Validation::FETCH_CODE Validation::fetch_page(bool mark, ULONG page_number, const ULONG page_scn = (*page_pointer)->pag_scn; WIN scns_window(DB_PAGE_SPACE, scn_page_num); - scns_page* scns = (scns_page*) *page_pointer; + Ods::scns_page* scns = (Ods::scns_page*) *page_pointer; if (scn_page_num != page_number) { fetch_page(mark, scn_page_num, pag_scns, &scns_window, &scns); @@ -1345,7 +1341,7 @@ void Validation::garbage_collect() for (ULONG sequence = 0, number = 0; number < vdr_max_page; sequence++) { const ULONG page_number = sequence ? sequence * pageSpaceMgr.pagesPerPIP - 1 : pageSpace->pipFirst; - page_inv_page* page = 0; + Ods::page_inv_page* page = 0; fetch_page(false, page_number, pag_pages, &window, &page); UCHAR* p = page->pip_bits; const UCHAR* const end = p + pageSpaceMgr.bytesBitPIP; @@ -1411,7 +1407,7 @@ void Validation::garbage_collect() } #ifdef DEBUG_VAL_VERBOSE -static void print_rhd(USHORT length, const rhd* header) +static void print_rhd(USHORT length, const Ods::rhd* header) { /************************************** * @@ -1430,26 +1426,26 @@ static void print_rhd(USHORT length, const rhd* header) length, Ods::getTraNum(header), (int) header->rhd_format); fprintf(stdout, "BP %d/%d flags 0x%x ", header->rhd_b_page, header->rhd_b_line, header->rhd_flags); - if (header->rhd_flags & rhd_incomplete) + if (header->rhd_flags & Ods::rhd_incomplete) { - const rhdf* fragment = (rhdf*) header; + const Ods::rhdf* fragment = (Ods::rhdf*) header; fprintf(stdout, "FP %d/%d ", fragment->rhdf_f_page, fragment->rhdf_f_line); } - fprintf(stdout, "%s ", (header->rhd_flags & rhd_deleted) ? "DEL" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_chain) ? "CHN" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_fragment) ? "FRG" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_incomplete) ? "INC" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_blob) ? "BLB" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_delta) ? "DLT" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_large) ? "LRG" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_damaged) ? "DAM" : " "); - fprintf(stdout, "%s ", (header->rhd_flags & rhd_not_packed) ? "NPK" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_deleted) ? "DEL" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_chain) ? "CHN" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_fragment) ? "FRG" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_incomplete) ? "INC" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_blob) ? "BLB" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_delta) ? "DLT" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_large) ? "LRG" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_damaged) ? "DAM" : " "); + fprintf(stdout, "%s ", (header->rhd_flags & Ods::rhd_not_packed) ? "NPK" : " "); fprintf(stdout, "\n"); } } #endif -Validation::RTN Validation::walk_blob(jrd_rel* relation, const blh* header, USHORT length, +Validation::RTN Validation::walk_blob(jrd_rel* relation, const Ods::blh* header, USHORT length, RecordNumber number) { /************************************** @@ -1498,7 +1494,7 @@ Validation::RTN Validation::walk_blob(jrd_rel* relation, const blh* header, USHO for (; pages1 < end1; pages1++) { - blob_page* page1 = 0; + Ods::blob_page* page1 = 0; fetch_page(true, *pages1, pag_blob, &window1, &page1); if (page1->blp_lead_page != header->blh_lead_page) { corrupt(VAL_BLOB_INCONSISTENT, relation, number.getValue()); @@ -1517,7 +1513,7 @@ Validation::RTN Validation::walk_blob(jrd_rel* relation, const blh* header, USHO const ULONG* const end2 = pages2 + (page1->blp_length >> SHIFTLONG); for (; pages2 < end2; pages2++, sequence++) { - blob_page* page2 = 0; + Ods::blob_page* page2 = 0; fetch_page(true, *pages2, pag_blob, &window2, &page2); if (page2->blp_lead_page != header->blh_lead_page || page2->blp_sequence != sequence) { @@ -1538,7 +1534,7 @@ Validation::RTN Validation::walk_blob(jrd_rel* relation, const blh* header, USHO return rtn_ok; } -Validation::RTN Validation::walk_chain(jrd_rel* relation, const rhd* header, +Validation::RTN Validation::walk_chain(jrd_rel* relation, const Ods::rhd* header, RecordNumber head_number) { /************************************** @@ -1562,13 +1558,13 @@ Validation::RTN Validation::walk_chain(jrd_rel* relation, const rhd* header, while (page_number) { - const bool delta_flag = (header->rhd_flags & rhd_delta) ? true : false; + const bool delta_flag = (header->rhd_flags & Ods::rhd_delta) ? true : false; #ifdef DEBUG_VAL_VERBOSE if (VAL_debug_level) fprintf(stdout, " BV %02d: ", ++counter); #endif vdr_rel_chain_counter++; - data_page* page = 0; + Ods::data_page* page = 0; fetch_page(true, page_number, pag_data, &window, &page); if (page->dpg_relation != relation->getId()) @@ -1580,11 +1576,11 @@ Validation::RTN Validation::walk_chain(jrd_rel* relation, const rhd* header, vdr_rel_chain_counter++; PBM_SET(vdr_tdbb->getDefaultPool(), &vdr_chain_pages, page_number); - const data_page::dpg_repeat* line = &page->dpg_rpt[line_number]; - header = (const rhd*) ((UCHAR*) page + line->dpg_offset); + const Ods::data_page::dpg_repeat* line = &page->dpg_rpt[line_number]; + header = (const Ods::rhd*) ((UCHAR*) page + line->dpg_offset); if (page->dpg_count <= line_number || !line->dpg_length || - (header->rhd_flags & (rhd_blob | rhd_fragment)) || - !(header->rhd_flags & rhd_chain) || + (header->rhd_flags & (Ods::rhd_blob | Ods::rhd_fragment)) || + !(header->rhd_flags & Ods::rhd_chain) || walk_record(relation, header, line->dpg_length, head_number, delta_flag) != rtn_ok) { @@ -1624,14 +1620,14 @@ void Validation::walk_database() DPM_scan_pages(vdr_tdbb); WIN window(DB_PAGE_SPACE, -1); - header_page* page = 0; + Ods::header_page* page = 0; fetch_page(true, HEADER_PAGE, pag_header, &window, &page); const TraNumber next = vdr_max_transaction = page->hdr_next_transaction; if (vdr_flags & VDR_online) release_page(&window); - Firebird::Cleanup hdrPage([&] { + Cleanup hdrPage([&] { if (!(vdr_flags & VDR_online)) release_page(&window); }); @@ -1723,7 +1719,7 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, WIN window(DB_PAGE_SPACE, -1); window.win_flags = WIN_garbage_collector; - data_page* page = 0; + Ods::data_page* page = 0; fetch_page(true, page_number, pag_data, &window, &page); #ifdef DEBUG_VAL_VERBOSE @@ -1747,25 +1743,25 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, // Evaluate what flags should be set on PP - if (dp_flags & dpg_full) - pp_bits |= ppg_dp_full; + if (dp_flags & Ods::dpg_full) + pp_bits |= Ods::ppg_dp_full; - if (dp_flags & dpg_large) - pp_bits |= ppg_dp_large; + if (dp_flags & Ods::dpg_large) + pp_bits |= Ods::ppg_dp_large; - if (dp_flags & dpg_swept) - pp_bits |= ppg_dp_swept; + if (dp_flags & Ods::dpg_swept) + pp_bits |= Ods::ppg_dp_swept; - if (dp_flags & dpg_secondary) - pp_bits |= ppg_dp_secondary; + if (dp_flags & Ods::dpg_secondary) + pp_bits |= Ods::ppg_dp_secondary; if (page->dpg_count == 0) - pp_bits |= ppg_dp_empty; + pp_bits |= Ods::ppg_dp_empty; // Walk records const UCHAR* const end_page = (UCHAR*) page + dbb->dbb_page_size; - const data_page::dpg_repeat* const end = page->dpg_rpt + page->dpg_count; + const Ods::data_page::dpg_repeat* const end = page->dpg_rpt + page->dpg_count; RecordNumber number((SINT64)sequence * dbb->dbb_max_records); int primary_versions = 0; bool marked = false; @@ -1776,7 +1772,7 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, // releasing data page, to avoid deadlocks. HalfStaticArray recnums; - for (const data_page::dpg_repeat* line = page->dpg_rpt; line < end; line++, number.increment()) + for (const Ods::data_page::dpg_repeat* line = page->dpg_rpt; line < end; line++, number.increment()) { #ifdef DEBUG_VAL_VERBOSE if (VAL_debug_level) @@ -1787,14 +1783,14 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, #endif if (line->dpg_length) { - rhd* header = (rhd*) ((UCHAR*) page + line->dpg_offset); + Ods::rhd* header = (Ods::rhd*) ((UCHAR*) page + line->dpg_offset); if ((UCHAR*) header < (UCHAR*) end || (UCHAR*) header + line->dpg_length > end_page) { release_page(&window); return corrupt(VAL_DATA_PAGE_LINE_ERR, relation, page_number, sequence, (ULONG) (line - page->dpg_rpt)); } - if (header->rhd_flags & rhd_chain) + if (header->rhd_flags & Ods::rhd_chain) { vdr_rel_backversion_counter++; PBM_SET(pool, &vdr_backversion_pages, page_number); @@ -1803,7 +1799,7 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, // Record the existence of a primary version of a record if ((vdr_flags & VDR_records) && - !(header->rhd_flags & (rhd_chain | rhd_fragment | rhd_blob))) + !(header->rhd_flags & (Ods::rhd_chain | Ods::rhd_fragment | Ods::rhd_blob))) { // Only set committed (or limbo) records in the bitmap. If there // is a backversion then at least one of the record versions is @@ -1812,7 +1808,7 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, // Note, if the primary record version is deleted and committed, the // existence of an index entry is not required for such version chain // because it is all garbage. - const bool deleted_flag = header->rhd_flags & rhd_deleted; + const bool deleted_flag = header->rhd_flags & Ods::rhd_deleted; if (header->rhd_b_page && !deleted_flag) RBM_SET(pool, &vdr_rel_records, number.getValue()); @@ -1834,19 +1830,19 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, #ifdef DEBUG_VAL_VERBOSE if (VAL_debug_level) { - if (header->rhd_flags & rhd_chain) + if (header->rhd_flags & Ods::rhd_chain) fprintf(stdout, "(backvers)"); - if (header->rhd_flags & rhd_fragment) + if (header->rhd_flags & Ods::rhd_fragment) fprintf(stdout, "(fragment)"); - if (header->rhd_flags & (rhd_fragment | rhd_chain)) + if (header->rhd_flags & (Ods::rhd_fragment | Ods::rhd_chain)) print_rhd(line->dpg_length, header); } #endif - if (!(header->rhd_flags & rhd_chain) && - ((header->rhd_flags & rhd_large) || (vdr_flags & VDR_records))) + if (!(header->rhd_flags & Ods::rhd_chain) && + ((header->rhd_flags & Ods::rhd_large) || (vdr_flags & VDR_records))) { - const RTN result = (header->rhd_flags & rhd_blob) ? - walk_blob(relation, (const blh*) header, line->dpg_length, number) : + const RTN result = (header->rhd_flags & Ods::rhd_blob) ? + walk_blob(relation, (const Ods::blh*) header, line->dpg_length, number) : walk_record(relation, header, line->dpg_length, number, false); if ((result == rtn_corrupt) && (vdr_flags & VDR_repair)) @@ -1857,12 +1853,12 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, marked = true; } - header->rhd_flags |= rhd_damaged; + header->rhd_flags |= Ods::rhd_damaged; vdr_fixed++; } } - if (!(header->rhd_flags & (rhd_chain | rhd_fragment | rhd_blob | rhd_damaged)) && + if (!(header->rhd_flags & (Ods::rhd_chain | Ods::rhd_fragment | Ods::rhd_blob | Ods::rhd_damaged)) && (vdr_flags & VDR_records) && vdr_cond_idx.hasData()) { recnums.add(number.getValue()); @@ -1874,7 +1870,7 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, #endif } - if (primary_versions && (dp_flags & dpg_secondary)) + if (primary_versions && (dp_flags & Ods::dpg_secondary)) { corrupt(VAL_DATA_PAGE_SEC_PRI, relation, page_number, sequence); @@ -1886,8 +1882,8 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number, marked = true; } - page->dpg_header.pag_flags &= ~dpg_secondary; - pp_bits &= ~ppg_dp_secondary; + page->dpg_header.pag_flags &= ~Ods::dpg_secondary; + pp_bits &= ~Ods::ppg_dp_secondary; vdr_fixed++; } } @@ -1967,8 +1963,8 @@ void Validation::walk_generators() if (VAL_debug_level) fprintf(stdout, "walk_generator: page %d\n", pageNumber); #endif - // It doesn't make a difference generator_page or pointer_page because it's not used. - generator_page* page = NULL; + // It doesn't make a difference Ods::generator_page or Ods::pointer_page because it's not used. + Ods::generator_page* page = NULL; fetch_page(true, pageNumber, pag_ids, &window, &page); release_page(&window); } @@ -1976,7 +1972,7 @@ void Validation::walk_generators() } } -Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_page, USHORT id) +Validation::RTN Validation::walk_index(jrd_rel* relation, Ods::index_root_page* root_page, USHORT id) { /************************************** * @@ -2000,9 +1996,9 @@ Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_ if (!page_number) return rtn_ok; - const bool unique = (root_page->irt_rpt[id].irt_flags & (irt_unique | idx_primary)); - const bool descending = (root_page->irt_rpt[id].irt_flags & irt_descending); - const bool condition = (root_page->irt_rpt[id].irt_flags & irt_condition); + const bool unique = (root_page->irt_rpt[id].irt_flags & (Ods::irt_unique | idx_primary)); + const bool descending = (root_page->irt_rpt[id].irt_flags & Ods::irt_descending); + const bool condition = (root_page->irt_rpt[id].irt_flags & Ods::irt_condition); temporary_key nullKey, *null_key = nullptr; if (unique) @@ -2011,7 +2007,7 @@ Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_ { // No need to evaluate index expression and/or condition AutoSetRestoreFlag flags(&root_page->irt_rpt[id].irt_flags, - irt_expression | irt_condition, false); + Ods::irt_expression | Ods::irt_condition, false); BTR_description(vdr_tdbb, getPermanent(relation), root_page, &idx, id); } @@ -2041,7 +2037,7 @@ Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_ WIN window(DB_PAGE_SPACE, -1); window.win_flags = WIN_garbage_collector; - btree_page* page = 0; + Ods::btree_page* page = 0; fetch_page(true, next, pag_index, &window, &page); // remember each page for circular reference detection @@ -2283,7 +2279,7 @@ Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_ WIN down_window(DB_PAGE_SPACE, -1); down_window.win_flags = WIN_garbage_collector; - btree_page* down_page = 0; + Ods::btree_page* down_page = 0; fetch_page(false, down_number, pag_index, &down_window, &down_page); const bool downLeafPage = (down_page->btr_level == 0); @@ -2444,7 +2440,7 @@ void Validation::walk_pip() const PageSpace* pageSpace = pageSpaceMgr.findPageSpace(DB_PAGE_SPACE); fb_assert(pageSpace); - page_inv_page* page = 0; + Ods::page_inv_page* page = 0; for (USHORT sequence = 0; true; sequence++) { @@ -2574,7 +2570,7 @@ Validation::RTN Validation::walk_pointer_page(jrd_rel* relation, ULONG sequence) if (!vector || sequence >= vector->count()) return corrupt(VAL_P_PAGE_LOST, relation, sequence); - pointer_page* page = 0; + Ods::pointer_page* page = 0; WIN window(DB_PAGE_SPACE, -1); window.win_flags = WIN_garbage_collector; @@ -2643,7 +2639,7 @@ Validation::RTN Validation::walk_pointer_page(jrd_rel* relation, ULONG sequence) UCHAR &pp_bits = PPG_DP_BITS_BYTE(bits, slot); if (pp_bits != new_pp_bits) { - Firebird::string s_pp, s_dp; + string s_pp, s_dp; explain_pp_bits(pp_bits, s_pp); explain_pp_bits(new_pp_bits, s_dp); @@ -2668,7 +2664,7 @@ Validation::RTN Validation::walk_pointer_page(jrd_rel* relation, ULONG sequence) // If this is the last pointer page in the relation, we're done - if (page->ppg_header.pag_flags & ppg_eof) + if (page->ppg_header.pag_flags & Ods::ppg_eof) { release_page(&window); return rtn_eof; @@ -2715,7 +2711,7 @@ Validation::RTN Validation::walk_pointer_page(jrd_rel* relation, ULONG sequence) } -Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, USHORT length, +Validation::RTN Validation::walk_record(jrd_rel* relation, const Ods::rhd* header, USHORT length, RecordNumber number, bool delta_flag) { /************************************** @@ -2740,7 +2736,7 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US } #endif - if (header->rhd_flags & rhd_damaged) + if (header->rhd_flags & Ods::rhd_damaged) { corrupt(VAL_REC_DAMAGED, relation, number.getValue()); return rtn_ok; @@ -2753,7 +2749,7 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US // If there's a back pointer, verify that it's good - if (header->rhd_b_page && !(header->rhd_flags & rhd_chain)) + if (header->rhd_b_page && !(header->rhd_flags & Ods::rhd_chain)) { const RTN result = walk_chain(relation, header, number); if (result != rtn_ok) @@ -2763,26 +2759,26 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US // If the record is a fragment, not large, or we're not interested in // chasing records, skip the record - if ((header->rhd_flags & (rhd_fragment | rhd_deleted)) || - !((header->rhd_flags & rhd_large) || (vdr_flags & VDR_records))) + if ((header->rhd_flags & (Ods::rhd_fragment | Ods::rhd_deleted)) || + !((header->rhd_flags & Ods::rhd_large) || (vdr_flags & VDR_records))) { return rtn_ok; } // Pick up what length there is on the fragment - const rhdf* fragment = (rhdf*) header; + const Ods::rhdf* fragment = (Ods::rhdf*) header; const UCHAR* p; - if (header->rhd_flags & rhd_incomplete) + if (header->rhd_flags & Ods::rhd_incomplete) { p = fragment->rhdf_data; length -= RHDF_SIZE; } - else if (header->rhd_flags & rhd_long_tranum) + else if (header->rhd_flags & Ods::rhd_long_tranum) { - p = ((rhde*) header)->rhde_data; + p = ((Ods::rhde*) header)->rhde_data; length -= RHDE_SIZE; } else @@ -2815,7 +2811,7 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US return Compressor::getUnpackedLength(length, data); }; - bool notPacked = (fragment->rhdf_flags & rhd_not_packed) != 0; + bool notPacked = (fragment->rhdf_flags & Ods::rhd_not_packed) != 0; remainingLength -= calculateLength(length, p, notPacked); // Next, chase down fragments, if any @@ -2824,15 +2820,15 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US USHORT line_number = fragment->rhdf_f_line; USHORT flags = fragment->rhdf_flags; - data_page* page = 0; - while (flags & rhd_incomplete) + Ods::data_page* page = 0; + while (flags & Ods::rhd_incomplete) { WIN window(DB_PAGE_SPACE, -1); window.win_flags = WIN_garbage_collector; fetch_page(true, page_number, pag_data, &window, &page); - const data_page::dpg_repeat* line = &page->dpg_rpt[line_number]; + const Ods::data_page::dpg_repeat* line = &page->dpg_rpt[line_number]; if (page->dpg_relation != relation->getId() || line_number >= page->dpg_count || !(length = line->dpg_length)) @@ -2842,33 +2838,33 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US return rtn_corrupt; } - fragment = (rhdf*) ((UCHAR*) page + line->dpg_offset); + fragment = (Ods::rhdf*) ((UCHAR*) page + line->dpg_offset); #ifdef DEBUG_VAL_VERBOSE if (VAL_debug_level) { fprintf(stdout, "fragment: pg %d/%d ", page_number, line_number); - print_rhd(line->dpg_length, (rhd*) fragment); + print_rhd(line->dpg_length, (Ods::rhd*) fragment); } #endif - if (fragment->rhdf_flags & rhd_incomplete) + if (fragment->rhdf_flags & Ods::rhd_incomplete) { p = fragment->rhdf_data; length -= RHDF_SIZE; } - else if (fragment->rhdf_flags & rhd_long_tranum) + else if (fragment->rhdf_flags & Ods::rhd_long_tranum) { - p = ((rhde*) fragment)->rhde_data; + p = ((Ods::rhde*) fragment)->rhde_data; length -= RHDE_SIZE; } else { - p = ((rhd*) fragment)->rhd_data; + p = ((Ods::rhd*) fragment)->rhd_data; length -= RHD_SIZE; } - notPacked = (fragment->rhdf_flags & rhd_not_packed) != 0; + notPacked = (fragment->rhdf_flags & Ods::rhd_not_packed) != 0; remainingLength -= calculateLength(length, p, notPacked); page_number = fragment->rhdf_f_page; @@ -2889,32 +2885,32 @@ Validation::RTN Validation::walk_record(jrd_rel* relation, const rhd* header, US void restoreFlags(UCHAR* byte, UCHAR flags, bool empty) { - UCHAR bit = PPG_DP_BIT_MASK(slot, ppg_dp_full); + UCHAR bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_full); - if (flags & dpg_full) + if (flags & Ods::dpg_full) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_large); - if (flags & dpg_large) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_large); + if (flags & Ods::dpg_large) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_swept); - if (flags & dpg_swept) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_swept); + if (flags & Ods::dpg_swept) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_secondary); - if (flags & dpg_secondary) + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_secondary); + if (flags & Ods::dpg_secondary) *byte |= bit; else *byte &= ~bit; - bit = PPG_DP_BIT_MASK(slot, ppg_dp_empty); + bit = PPG_DP_BIT_MASK(slot, Ods::ppg_dp_empty); if (empty) *byte |= bit; else @@ -2932,7 +2928,7 @@ void Validation::checkDPinPP(jrd_rel* relation, ULONG page_number) **************************************/ WIN window(DB_PAGE_SPACE, page_number); - data_page* dpage; + Ods::data_page* dpage; fetch_page(false, page_number, pag_data, &window, &dpage); const ULONG sequence = dpage->dpg_sequence; const bool dpEmpty = (dpage->dpg_count == 0); @@ -2944,7 +2940,7 @@ void Validation::checkDPinPP(jrd_rel* relation, ULONG page_number) DECOMPOSE(sequence, dbb->dbb_dp_per_pp, pp_sequence, slot); const vcl* vector = getPermanent(relation)->getBasePages()->rel_pages; - pointer_page* ppage = 0; + Ods::pointer_page* ppage = 0; if (pp_sequence < vector->count()) { fetch_page(false, (*vector)[pp_sequence], pag_pointer, &window, &ppage); @@ -3012,7 +3008,7 @@ void Validation::checkDPinPIP(jrd_rel* relation, ULONG page_number) WIN pip_window(DB_PAGE_SPACE, (sequence == 0) ? pageSpace->pipFirst : sequence * pageMgr.pagesPerPIP - 1); - page_inv_page* pages; + Ods::page_inv_page* pages; fetch_page(false, pip_window.win_page.getPageNum(), pag_pages, &pip_window, &pages); if (pages->pip_bits[relative_bit >> 3] & (1 << (relative_bit & 7))) { @@ -3081,7 +3077,7 @@ Validation::RTN Validation::walk_relation(jrd_rel* relation) } WIN window(DB_PAGE_SPACE, -1); - header_page* page = NULL; + Ods::header_page* page = NULL; fetch_page(false, HEADER_PAGE, pag_header, &window, &page); vdr_max_transaction = page->hdr_next_transaction; release_page(&window); @@ -3178,7 +3174,7 @@ Validation::RTN Validation::walk_relation(jrd_rel* relation) } } // try - catch (const Firebird::Exception&) + catch (const Exception&) { if (!(vdr_flags & VDR_online)) { @@ -3225,7 +3221,7 @@ Validation::RTN Validation::walk_root(jrd_rel* relation, bool getInfo) if (!relPages->rel_index_root) return corrupt(VAL_INDEX_ROOT_MISSING, relation); - index_root_page* page = nullptr; + Ods::index_root_page* page = nullptr; WIN window(DB_PAGE_SPACE, -1); fetch_page(!getInfo, relPages->rel_index_root, pag_root, &window, &page); @@ -3268,10 +3264,10 @@ Validation::RTN Validation::walk_root(jrd_rel* relation, bool getInfo) if (getInfo) { - if (page->irt_rpt[i].irt_flags & irt_condition) + if (page->irt_rpt[i].irt_flags & Ods::irt_condition) { // No need to evaluate index expression - AutoSetRestoreFlag flag(&page->irt_rpt[i].irt_flags, irt_expression, false); + AutoSetRestoreFlag flag(&page->irt_rpt[i].irt_flags, Ods::irt_expression, false); IdxInfo info; if (BTR_description(vdr_tdbb, getPermanent(relation), page, &info.m_desc, i)) @@ -3306,7 +3302,7 @@ Validation::RTN Validation::walk_tip(TraNumber transaction) if (!dbb->getKnownPagesCount(pag_transactions)) return corrupt(VAL_TIP_LOST, 0); - tx_inv_page* page = 0; + Ods::tx_inv_page* page = 0; const ULONG pages = transaction / dbb->dbb_page_manager.transPerTIP; for (ULONG sequence = 0; sequence <= pages; sequence++) @@ -3368,7 +3364,7 @@ Validation::RTN Validation::walk_scns() { const ULONG scnPage = pageSpace->getSCNPageNum(sequence); WIN scnWindow(pageSpace->pageSpaceID, scnPage); - scns_page* scns = NULL; + Ods::scns_page* scns = NULL; fetch_page(true, scnPage, pag_scns, &scnWindow, &scns); if (scns->scn_sequence != sequence) @@ -3389,4 +3385,5 @@ Validation::RTN Validation::walk_scns() return rtn_ok; } -} // namespace Jrd + +} // namespace Firebird::Jrd diff --git a/src/jrd/validation.h b/src/jrd/validation.h index b1f42913d2f..3cd38872036 100644 --- a/src/jrd/validation.h +++ b/src/jrd/validation.h @@ -40,8 +40,7 @@ namespace Firebird class UtilSvc; } -namespace Jrd -{ +namespace Firebird::Jrd { class Attachment; class Database; @@ -157,23 +156,23 @@ class Validation PageBitmap* vdr_chain_pages; // 1 bit per visited record chain page RecordBitmap* vdr_rel_records; // 1 bit per valid record RecordBitmap* vdr_idx_records; // 1 bit per index item - Firebird::Array vdr_cond_idx; // one entry per condition index for current relation + Array vdr_cond_idx; // one entry per condition index for current relation PageBitmap* vdr_page_bitmap; ULONG vdr_err_counts[VAL_MAX_ERROR]; - Firebird::UtilSvc* vdr_service; - Firebird::AutoPtr vdr_sch_incl; - Firebird::AutoPtr vdr_sch_excl; - Firebird::AutoPtr vdr_tab_incl; - Firebird::AutoPtr vdr_tab_excl; - Firebird::AutoPtr vdr_idx_incl; - Firebird::AutoPtr vdr_idx_excl; + UtilSvc* vdr_service; + AutoPtr vdr_sch_incl; + AutoPtr vdr_sch_excl; + AutoPtr vdr_tab_incl; + AutoPtr vdr_tab_excl; + AutoPtr vdr_idx_incl; + AutoPtr vdr_idx_excl; int vdr_lock_tout; void checkDPinPP(jrd_rel *relation, ULONG page_number); void checkDPinPIP(jrd_rel *relation, ULONG page_number); public: - explicit Validation(thread_db*, Firebird::UtilSvc* uSvc = NULL); + explicit Validation(thread_db*, UtilSvc* uSvc = NULL); ~Validation(); bool run(thread_db* tdbb, USHORT flags); @@ -193,9 +192,9 @@ class Validation } }; - typedef Firebird::SortedArray< + typedef SortedArray< UsedBdb, - Firebird::EmptyStorage, + EmptyStorage, ULONG, UsedBdb> UsedBdbs; @@ -225,6 +224,6 @@ class Validation RTN walk_tip(TraNumber); }; -} // namespace Jrd +} // namespace Firebird::Jrd #endif diff --git a/src/jrd/vec.cpp b/src/jrd/vec.cpp index 08b58133ec9..fac055d215f 100644 --- a/src/jrd/vec.cpp +++ b/src/jrd/vec.cpp @@ -30,25 +30,27 @@ #if defined(DEV_BUILD) -using namespace Jrd; +namespace Firebird::Jrd +{ + thread_db* JRD_get_thread_data() { - Firebird::ThreadData* p1 = Firebird::ThreadData::getSpecific(); - if (p1 && p1->getType() == Firebird::ThreadData::tddDBB) + ThreadData* p1 = ThreadData::getSpecific(); + if (p1 && p1->getType() == ThreadData::tddDBB) { - Jrd::thread_db* p2 = (Jrd::thread_db*) p1; + thread_db* p2 = (thread_db*) p1; if (p2->getDatabase() && !p2->getDatabase()->checkHandle()) { BUGCHECK(147); } } - return (Jrd::thread_db*) p1; + return (thread_db*) p1; } -void CHECK_TDBB(const Jrd::thread_db* tdbb) +void CHECK_TDBB(const thread_db* tdbb) { - fb_assert(tdbb && (tdbb->getType() == Firebird::ThreadData::tddDBB) && + fb_assert(tdbb && (tdbb->getType() == ThreadData::tddDBB) && (!tdbb->getDatabase() || tdbb->getDatabase()->checkHandle())); } @@ -57,4 +59,7 @@ void CHECK_DBB(const Database* dbb) fb_assert(dbb && dbb->checkHandle()); } + +} // namespace Firebird::Jrd + #endif // DEV_BUILD diff --git a/src/jrd/vec.h b/src/jrd/vec.h index ec83b598b71..50c53d5b510 100644 --- a/src/jrd/vec.h +++ b/src/jrd/vec.h @@ -29,15 +29,15 @@ #include "../common/ThreadData.h" #include "../common/classes/array.h" -namespace Jrd { +namespace Firebird::Jrd { // general purpose vector template class vec_base : protected pool_alloc { public: - typedef typename Firebird::Array::iterator iterator; - typedef typename Firebird::Array::const_iterator const_iterator; + typedef typename Array::iterator iterator; + typedef typename Array::const_iterator const_iterator; /* static vec_base* newVector(MemoryPool& p, int len) @@ -97,7 +97,7 @@ class vec_base : protected pool_alloc } private: - Firebird::Array v; + Array v; }; template @@ -162,8 +162,6 @@ typedef vec TransactionsVector; class Database; class thread_db; -} // namespace Jrd - /* Define JRD_get_thread_data off the platform specific version. * If we're in DEV mode, also do consistancy checks on the * retrieved memory structure. This was originally done to @@ -181,26 +179,28 @@ class thread_db; #if defined(DEV_BUILD) -Jrd::thread_db* JRD_get_thread_data(); -void CHECK_TDBB(const Jrd::thread_db* tdbb); -void CHECK_DBB(const Jrd::Database* dbb); +thread_db* JRD_get_thread_data(); +void CHECK_TDBB(const thread_db* tdbb); +void CHECK_DBB(const Database* dbb); #else // PROD_BUILD -inline Jrd::thread_db* JRD_get_thread_data() +inline thread_db* JRD_get_thread_data() { - return (Jrd::thread_db*) Firebird::ThreadData::getSpecific(); + return (thread_db*) ThreadData::getSpecific(); } -inline void CHECK_DBB(const Jrd::Database*) +inline void CHECK_DBB(const Database*) { } -inline void CHECK_TDBB(const Jrd::thread_db*) +inline void CHECK_TDBB(const thread_db*) { } #endif -#endif // JRD_VEC_H +} // namespace Firebird::Jrd + +#endif // JRD_VEC_H diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 7a223ddfd6d..9610d2ffde4 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -95,8 +95,14 @@ #include "../common/Task.h" #include "../jrd/WorkerAttachment.h" -using namespace Jrd; -using namespace Firebird; +#ifdef VIO_DEBUG +#include +#include +#endif + +namespace Firebird::Jrd +{ + static void check_class(thread_db*, jrd_tra*, record_param*, record_param*, USHORT); static bool check_nullify_source(thread_db*, record_param*, record_param*, int, int = -1); @@ -113,9 +119,6 @@ static void garbage_collect(thread_db*, record_param*, ULONG, RecordStack&); #ifdef VIO_DEBUG -#include -#include - int vio_debug_flag = DEBUG_TRACE_ALL_INFO; void VIO_trace(int level, const char* format, ...) @@ -123,7 +126,7 @@ void VIO_trace(int level, const char* format, ...) if (vio_debug_flag <= level) return; - Firebird::string buffer; + string buffer; va_list params; va_start(params, format); buffer.vprintf(format, params); @@ -186,9 +189,6 @@ static bool set_security_class(thread_db*, Record*, USHORT); static void set_system_flag(thread_db*, Record*, USHORT); static void verb_post(thread_db*, jrd_tra*, record_param*, Record*); -namespace Jrd -{ - class SweepTask : public Task { struct RelInfo; // forward decl @@ -566,8 +566,6 @@ bool SweepTask::getWorkItem(WorkItem** pItem) return false; } -}; // namespace Jrd - namespace { @@ -1151,7 +1149,7 @@ bool VIO_chase_record_version(thread_db* tdbb, record_param* rpb, **************************************/ SET_TDBB(tdbb); Database* const dbb = tdbb->getDatabase(); - Jrd::Attachment* const attachment = transaction->tra_attachment; + Attachment* const attachment = transaction->tra_attachment; jrd_rel* const relation = rpb->rpb_relation; const bool gcPolicyCooperative = dbb->dbb_flags & DBB_gc_cooperative; @@ -2814,7 +2812,7 @@ bool VIO_garbage_collect(thread_db* tdbb, record_param* rpb, jrd_tra* transactio * **************************************/ SET_TDBB(tdbb); - Jrd::Attachment* attachment = transaction->tra_attachment; + Attachment* attachment = transaction->tra_attachment; #ifdef VIO_DEBUG jrd_rel* relation = rpb->rpb_relation; @@ -3200,7 +3198,7 @@ void VIO_init(thread_db* tdbb) * **************************************/ Database* dbb = tdbb->getDatabase(); - Jrd::Attachment* attachment = tdbb->getAttachment(); + Attachment* attachment = tdbb->getAttachment(); if (dbb->readOnly() || !(dbb->dbb_flags & DBB_gc_background)) return; @@ -4715,7 +4713,7 @@ bool VIO_sweep(thread_db* tdbb, jrd_tra* transaction, TraceSweepEvent* traceSwee **************************************/ SET_TDBB(tdbb); Database* const dbb = tdbb->getDatabase(); - Jrd::Attachment* attachment = tdbb->getAttachment(); + Attachment* attachment = tdbb->getAttachment(); #ifdef VIO_DEBUG VIO_trace(DEBUG_TRACE, @@ -5423,7 +5421,7 @@ static void expunge(thread_db* tdbb, record_param* rpb, const jrd_tra* transacti * **************************************/ SET_TDBB(tdbb); - Jrd::Attachment* attachment = transaction->tra_attachment; + Attachment* attachment = transaction->tra_attachment; fb_assert(assert_gc_enabled(transaction, rpb->rpb_relation)); @@ -5631,7 +5629,7 @@ void Database::garbage_collector(Database* dbb) UserId user; user.setUserName("Garbage Collector"); - Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb, nullptr); + Attachment* const attachment = Attachment::create(dbb, nullptr); RefPtr sAtt(FB_NEW SysStableAttachment(attachment)); attachment->setStable(sAtt); attachment->att_filename = dbb->dbb_filename; @@ -5639,7 +5637,7 @@ void Database::garbage_collector(Database* dbb) attachment->att_user = &user; BackgroundContextHolder tdbb(dbb, attachment, &status_vector, FB_FUNCTION); - Jrd::Attachment::UseCountHolder use(attachment); + Attachment::UseCountHolder use(attachment); tdbb->markAsSweeper(); jrd_rel* relation; @@ -5834,7 +5832,7 @@ void Database::garbage_collector(Database* dbb) } } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(&status_vector); iscDbLogStatus(dbb->dbb_filename.c_str(), &status_vector); @@ -5853,7 +5851,7 @@ void Database::garbage_collector(Database* dbb) attachment->releaseLocks(tdbb); LCK_fini(tdbb, LCK_OWNER_attachment); } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { dbb->exceptionHandler(ex, NULL); } @@ -5869,14 +5867,14 @@ void Database::garbage_collector(Database* dbb) dbb->dbb_gc_init.release(); } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { dbb->exceptionHandler(ex, NULL); } } -void Database::exceptionHandler(const Firebird::Exception& ex, +void Database::exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* /*routine*/) { FbLocalStatus status_vector; @@ -7418,3 +7416,6 @@ static void verb_post(thread_db* tdbb, action->garbageCollectIdxLite(tdbb, transaction, rpb->rpb_number.getValue(), action, old_data); } } + + +} // namespace Firebird::Jrd diff --git a/src/jrd/vio_debug.h b/src/jrd/vio_debug.h index be796cf5dd8..24d5e5dee73 100644 --- a/src/jrd/vio_debug.h +++ b/src/jrd/vio_debug.h @@ -23,8 +23,12 @@ #ifndef JRD_VIO_DEBUG_H #define JRD_VIO_DEBUG_H +namespace Firebird::Jrd +{ + //#define VIO_DEBUG + inline constexpr int DEBUG_WRITES = 1; inline constexpr int DEBUG_WRITES_INFO = 2; inline constexpr int DEBUG_READS = 3; @@ -38,5 +42,7 @@ inline constexpr int DEBUG_TRACE_ALL_INFO = 8; extern int vio_debug_flag; void VIO_trace(int level, const char* format, ...); -#endif /* JRD_VIO_DEBUG_H */ +} // namespace Firebird::Jrd + +#endif /* JRD_VIO_DEBUG_H */ diff --git a/src/jrd/vio_proto.h b/src/jrd/vio_proto.h index a0647e057f5..7540bba7914 100644 --- a/src/jrd/vio_proto.h +++ b/src/jrd/vio_proto.h @@ -26,7 +26,7 @@ #ifndef JRD_VIO_PROTO_H #define JRD_VIO_PROTO_H -namespace Jrd +namespace Firebird::Jrd { class jrd_rel; class jrd_tra; @@ -50,30 +50,30 @@ namespace Jrd CONFLICTED, SKIPPED }; -} -void VIO_backout(Jrd::thread_db*, Jrd::record_param*, const Jrd::jrd_tra*); -bool VIO_chase_record_version(Jrd::thread_db*, Jrd::record_param*, - Jrd::jrd_tra*, MemoryPool*, bool, bool); -void VIO_copy_record(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::Record*, Jrd::Record*); -void VIO_data(Jrd::thread_db*, Jrd::record_param*, MemoryPool*); -bool VIO_erase(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -void VIO_fini(Jrd::thread_db*); -bool VIO_garbage_collect(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -bool VIO_get(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*, MemoryPool*); -bool VIO_get_current(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*, - MemoryPool*, bool, bool&); -void VIO_init(Jrd::thread_db*); -Jrd::WriteLockResult VIO_writelock(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -bool VIO_modify(Jrd::thread_db*, Jrd::record_param*, Jrd::record_param*, Jrd::jrd_tra*); -bool VIO_next_record(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*, MemoryPool*, - Jrd::FindNextRecordScope, const RecordNumber* = nullptr); -Jrd::Record* VIO_record(Jrd::thread_db*, Jrd::record_param*, const Jrd::Format*, MemoryPool*); -bool VIO_refetch_record(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*, bool, bool); -void VIO_store(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*); -bool VIO_sweep(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::TraceSweepEvent*); -void VIO_intermediate_gc(Jrd::thread_db* tdbb, Jrd::record_param* rpb, Jrd::jrd_tra* transaction); -void VIO_garbage_collect_idx(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::record_param*, Jrd::Record*); -void VIO_update_in_place(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::record_param*, Jrd::record_param*); + void VIO_backout(thread_db*, record_param*, const jrd_tra*); + bool VIO_chase_record_version(thread_db*, record_param*, + jrd_tra*, MemoryPool*, bool, bool); + void VIO_copy_record(thread_db*, jrd_rel*, Record*, Record*); + void VIO_data(thread_db*, record_param*, MemoryPool*); + bool VIO_erase(thread_db*, record_param*, jrd_tra*); + void VIO_fini(thread_db*); + bool VIO_garbage_collect(thread_db*, record_param*, jrd_tra*); + bool VIO_get(thread_db*, record_param*, jrd_tra*, MemoryPool*); + bool VIO_get_current(thread_db*, record_param*, jrd_tra*, + MemoryPool*, bool, bool&); + void VIO_init(thread_db*); + WriteLockResult VIO_writelock(thread_db*, record_param*, jrd_tra*); + bool VIO_modify(thread_db*, record_param*, record_param*, jrd_tra*); + bool VIO_next_record(thread_db*, record_param*, jrd_tra*, MemoryPool*, + FindNextRecordScope, const RecordNumber* = nullptr); + Record* VIO_record(thread_db*, record_param*, const Format*, MemoryPool*); + bool VIO_refetch_record(thread_db*, record_param*, jrd_tra*, bool, bool); + void VIO_store(thread_db*, record_param*, jrd_tra*); + bool VIO_sweep(thread_db*, jrd_tra*, TraceSweepEvent*); + void VIO_intermediate_gc(thread_db* tdbb, record_param* rpb, jrd_tra* transaction); + void VIO_garbage_collect_idx(thread_db*, jrd_tra*, record_param*, Record*); + void VIO_update_in_place(thread_db*, jrd_tra*, record_param*, record_param*); +} // namespace Firebird::Jrd #endif // JRD_VIO_PROTO_H diff --git a/src/lock/lock.cpp b/src/lock/lock.cpp index 42cc614f17b..989fbbe7f70 100644 --- a/src/lock/lock.cpp +++ b/src/lock/lock.cpp @@ -128,7 +128,9 @@ SSHORT LOCK_debug_level = 0; #define DEBUG_DELAY #endif -using namespace Firebird; +namespace Firebird::Jrd +{ + // hvlad: enable to log deadlocked owners and its PIDs in firebird.log //#define DEBUG_TRACE_DEADLOCKS @@ -162,9 +164,6 @@ static constexpr bool compatibility[LCK_max][LCK_max] = }; -namespace Jrd { - - LockManager::LockManager(const string& id, const Config* conf) : PID(getpid()), m_bugcheck(false), @@ -4065,4 +4064,5 @@ void LockManager::Extent::assign(const SharedMemoryBase& p) } #endif // USE_SHMEM_EXT -} // namespace + +} // namespace Firebird::Jrd diff --git a/src/lock/lock_proto.h b/src/lock/lock_proto.h index a44e86c8062..8cd12a14ed4 100644 --- a/src/lock/lock_proto.h +++ b/src/lock/lock_proto.h @@ -48,6 +48,17 @@ #include "../common/file_params.h" #include "../jrd/que.h" +namespace Firebird { + class AtomicCounter; + class Mutex; + class RWLock; + class Config; +} + +namespace Firebird::Jrd +{ + + typedef FB_UINT64 LOCK_OWNER_T; // Data type for the Owner ID typedef SINT64 LOCK_DATA_T; @@ -105,7 +116,7 @@ inline constexpr USHORT LHB_VERSION = BASE_LHB_VERSION; // Lock header block -- one per lock file, lives up front -struct lhb : public Firebird::MemoryHeader +struct lhb : public MemoryHeader { USHORT lhb_type; // memory tag - always type_lhb SRQ_PTR lhb_secondary; // Secondary lock header block @@ -215,7 +226,7 @@ struct prc int prc_process_id; // Process ID srq prc_lhb_processes; // Process que srq prc_owners; // Owners - Firebird::event_t prc_blocking; // Blocking event block + event_t prc_blocking; // Blocking event block USHORT prc_flags; // Unused. Misc flags }; @@ -237,7 +248,7 @@ struct own FB_UINT64 own_acquire_time; // lhb_acquires when owner last tried acquire() USHORT own_waits; // Number of requests we are waiting on USHORT own_ast_count; // Number of ASTs being delivered - Firebird::event_t own_wakeup; // Wakeup event block + event_t own_wakeup; // Wakeup event block USHORT own_flags; // Misc stuff }; @@ -281,16 +292,8 @@ inline constexpr UCHAR his_cleanup = 18; inline constexpr UCHAR his_del_owner = 19; inline constexpr UCHAR his_MAX = his_del_owner; -namespace Firebird { - class AtomicCounter; - class Mutex; - class RWLock; - class Config; -} -namespace Jrd { - -class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcObject +class LockManager final : public GlobalStorage, public IpcObject { public: class Callbacks @@ -329,7 +332,7 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb m_lm->m_localMutex.leave(); } - catch (const Firebird::Exception&) + catch (const Exception&) { DtorException::devHalt(); } @@ -379,7 +382,7 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb m_lm->acquire_shmem(m_owner); } - catch (const Firebird::Exception&) + catch (const Exception&) { DtorException::devHalt(); } @@ -401,16 +404,16 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb const int PID; public: - explicit LockManager(const Firebird::string&, const Firebird::Config* conf); + explicit LockManager(const string&, const Config* conf); ~LockManager(); - bool initializeOwner(Firebird::CheckStatusWrapper*, LOCK_OWNER_T, UCHAR, SRQ_PTR*); + bool initializeOwner(CheckStatusWrapper*, LOCK_OWNER_T, UCHAR, SRQ_PTR*); void shutdownOwner(const Callbacks&, SRQ_PTR*); - SRQ_PTR enqueue(const Callbacks&, Firebird::CheckStatusWrapper*, SRQ_PTR, const USHORT, + SRQ_PTR enqueue(const Callbacks&, CheckStatusWrapper*, SRQ_PTR, const USHORT, const UCHAR*, const USHORT, UCHAR, lock_ast_t, void*, LOCK_DATA_T, SSHORT, SRQ_PTR); - bool convert(const Callbacks&, Firebird::CheckStatusWrapper*, SRQ_PTR, UCHAR, SSHORT, lock_ast_t, void*); - UCHAR downgrade(const Callbacks&, Firebird::CheckStatusWrapper*, const SRQ_PTR); + bool convert(const Callbacks&, CheckStatusWrapper*, SRQ_PTR, UCHAR, SSHORT, lock_ast_t, void*); + UCHAR downgrade(const Callbacks&, CheckStatusWrapper*, const SRQ_PTR); bool dequeue(const SRQ_PTR); void repost(const Callbacks&, lock_ast_t, void*, SRQ_PTR); @@ -421,18 +424,18 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb LOCK_DATA_T readData2(USHORT, const UCHAR*, USHORT, SRQ_PTR); LOCK_DATA_T writeData(SRQ_PTR, LOCK_DATA_T); - void exceptionHandler(const Firebird::Exception& ex, ThreadFinishSync::ThreadRoutine* routine); + void exceptionHandler(const Exception& ex, ThreadFinishSync::ThreadRoutine* routine); private: void acquire_shmem(SRQ_PTR); - UCHAR* alloc(USHORT, Firebird::CheckStatusWrapper*); - lbl* alloc_lock(USHORT, Firebird::CheckStatusWrapper*); + UCHAR* alloc(USHORT, CheckStatusWrapper*); + lbl* alloc_lock(USHORT, CheckStatusWrapper*); void blocking_action(const Callbacks&, SRQ_PTR); void blocking_action_thread(); - void bug(Firebird::CheckStatusWrapper*, const TEXT*); + void bug(CheckStatusWrapper*, const TEXT*); void bug_assert(const TEXT*, ULONG); - SRQ_PTR create_owner(Firebird::CheckStatusWrapper*, LOCK_OWNER_T, UCHAR); - bool create_process(Firebird::CheckStatusWrapper*); + SRQ_PTR create_owner(CheckStatusWrapper*, LOCK_OWNER_T, UCHAR); + bool create_process(CheckStatusWrapper*); void deadlock_clear(); lrq* deadlock_scan(own*, lrq*); lrq* deadlock_walk(lrq*, bool*); @@ -441,10 +444,10 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb lrq* get_request(SRQ_PTR); void grant(lrq*, lbl*); bool grant_or_que(const Callbacks&, lrq*, lbl*, SSHORT); - bool init_owner_block(Firebird::CheckStatusWrapper*, own*, UCHAR, LOCK_OWNER_T); + bool init_owner_block(CheckStatusWrapper*, own*, UCHAR, LOCK_OWNER_T); void insert_data_que(lbl*); void insert_tail(SRQ, SRQ); - bool internal_convert(const Callbacks&, Firebird::CheckStatusWrapper*, SRQ_PTR, UCHAR, SSHORT, + bool internal_convert(const Callbacks&, CheckStatusWrapper*, SRQ_PTR, UCHAR, SSHORT, lock_ast_t, void*); void internal_dequeue(SRQ_PTR); static USHORT lock_state(const lbl*); @@ -469,19 +472,19 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb void validate_shb(const SRQ_PTR); void wait_for_request(const Callbacks&, lrq*, SSHORT); - bool init_shared_file(Firebird::CheckStatusWrapper*); - void get_shared_file_name(Firebird::PathName&, ULONG extend = 0) const; + bool init_shared_file(CheckStatusWrapper*); + void get_shared_file_name(PathName&, ULONG extend = 0) const; static void blocking_action_thread(LockManager* lockMgr) { lockMgr->blocking_action_thread(); } - bool initialize(Firebird::SharedMemoryBase* sm, bool init) override; + bool initialize(SharedMemoryBase* sm, bool init) override; void mutexBug(int osErrorCode, const char* text) override; - bool checkHeader(const Firebird::MemoryHeader* header, bool raiseError = true) override; + bool checkHeader(const MemoryHeader* header, bool raiseError = true) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_LOCK_MANAGER; } + USHORT getType() const override { return SharedMemoryBase::SRAM_LOCK_MANAGER; } USHORT getVersion() const override { return LHB_VERSION; } const char* getName() const override { return "LockManager"; } @@ -489,21 +492,21 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb prc* m_process; SRQ_PTR m_processOffset; - Firebird::Mutex m_localMutex; - Firebird::RWLock m_remapSync; - Firebird::AtomicCounter m_waitingOwners; + Mutex m_localMutex; + RWLock m_remapSync; + AtomicCounter m_waitingOwners; ThreadFinishSync m_cleanupSync; - Firebird::Semaphore m_startupSemaphore; + Semaphore m_startupSemaphore; public: - Firebird::AutoPtr > m_sharedMemory; + AutoPtr > m_sharedMemory; private: bool m_blockage; - const Firebird::string& m_dbId; - const Firebird::Config* const m_config; + const string& m_dbId; + const Config* const m_config; // configurations parameters - cached values const ULONG m_acquireSpins; @@ -512,7 +515,7 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb const bool m_useBlockingThread; #ifdef USE_SHMEM_EXT - struct SecondaryFile : public Jrd::MemoryHeader + struct SecondaryFile : public MemoryHeader { }; @@ -520,14 +523,14 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb { public: Extent() { } - explicit Extent(Firebird::MemoryPool&) { } + explicit Extent(MemoryPool&) { } Extent(const SharedMemoryBase& p) { assign(p); } - Extent(Firebird::MemoryPool&, const SharedMemoryBase& p) + Extent(MemoryPool&, const SharedMemoryBase& p) { assign(p); } @@ -549,7 +552,7 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb void mutexBug(int osErrorCode, const char* text); }; - Firebird::ObjectsArray m_extents; + ObjectsArray m_extents; ULONG getTotalMapped() const { @@ -572,6 +575,7 @@ class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcOb #endif }; -} // namespace + +} // namespace Firebird::Jrd #endif // LOCK_LOCK_PROTO_H diff --git a/src/lock/print.cpp b/src/lock/print.cpp index 5a4f47130ea..01a16d950fc 100644 --- a/src/lock/print.cpp +++ b/src/lock/print.cpp @@ -78,6 +78,10 @@ #define FPRINTF fprintf #endif +namespace Firebird::Jrd +{ + + typedef FILE* OUTFILE; constexpr USHORT SW_I_ACQUIRE = 1; @@ -93,8 +97,6 @@ struct waitque SRQ_PTR waitque_entry[30]; }; -using namespace Firebird; - namespace { class sh_mem final : public IpcObject @@ -116,7 +118,7 @@ namespace // Do nothing - lock print always ignored mutex errors } - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_LOCK_MANAGER; } + USHORT getType() const override { return SharedMemoryBase::SRAM_LOCK_MANAGER; } USHORT getVersion() const override { return LHB_VERSION; } const char* getName() const override { return "LockManager"; } @@ -233,9 +235,13 @@ static constexpr UCHAR compatibility[LCK_max][LCK_max] = /* EX */ {true, true, false, false, false, false, false} }; + +} // namespace Firebird::Jrd + + //#define COMPATIBLE(st1, st2) compatibility [st1 * LCK_max + st2] -int CLIB_ROUTINE main( int argc, char *argv[]) +int CLIB_ROUTINE main(int argc, char *argv[]) { /************************************** * @@ -253,6 +259,9 @@ int CLIB_ROUTINE main( int argc, char *argv[]) setlocale(LC_CTYPE, ""); #endif + using namespace Firebird; + using namespace Firebird::Jrd; + OUTFILE outfile = stdout; // Perform some special handling when run as a Firebird service. The @@ -892,6 +901,9 @@ int CLIB_ROUTINE main( int argc, char *argv[]) } +namespace Firebird::Jrd { + + static void prt_lock_activity(OUTFILE outfile, const lhb* LOCK_header, USHORT flag, @@ -1010,23 +1022,23 @@ static void prt_lock_activity(OUTFILE outfile, { FPRINTF(outfile, "%9" UQUADFORMAT" %9" UQUADFORMAT" %9" UQUADFORMAT " %9" UQUADFORMAT" %9" UQUADFORMAT" %9" UQUADFORMAT" ", - (LOCK_header->lhb_operations[Jrd::LCK_database] - - prior.lhb_operations[Jrd::LCK_database]) / seconds, - (LOCK_header->lhb_operations[Jrd::LCK_relation] - - prior.lhb_operations[Jrd::LCK_relation]) / seconds, - (LOCK_header->lhb_operations[Jrd::LCK_bdb] - - prior.lhb_operations[Jrd::LCK_bdb]) / seconds, - (LOCK_header->lhb_operations[Jrd::LCK_tra] - - prior.lhb_operations[Jrd::LCK_tra]) / seconds, - (LOCK_header->lhb_operations[Jrd::LCK_attachment] - - prior.lhb_operations[Jrd::LCK_attachment]) / seconds, + (LOCK_header->lhb_operations[LCK_database] - + prior.lhb_operations[LCK_database]) / seconds, + (LOCK_header->lhb_operations[LCK_relation] - + prior.lhb_operations[LCK_relation]) / seconds, + (LOCK_header->lhb_operations[LCK_bdb] - + prior.lhb_operations[LCK_bdb]) / seconds, + (LOCK_header->lhb_operations[LCK_tra] - + prior.lhb_operations[LCK_tra]) / seconds, + (LOCK_header->lhb_operations[LCK_attachment] - + prior.lhb_operations[LCK_attachment]) / seconds, (LOCK_header->lhb_operations[0] - prior.lhb_operations[0]) / seconds); - prior.lhb_operations[Jrd::LCK_database] = LOCK_header->lhb_operations[Jrd::LCK_database]; - prior.lhb_operations[Jrd::LCK_relation] = LOCK_header->lhb_operations[Jrd::LCK_relation]; - prior.lhb_operations[Jrd::LCK_bdb] = LOCK_header->lhb_operations[Jrd::LCK_bdb]; - prior.lhb_operations[Jrd::LCK_tra] = LOCK_header->lhb_operations[Jrd::LCK_tra]; - prior.lhb_operations[Jrd::LCK_attachment] = LOCK_header->lhb_operations[Jrd::LCK_attachment]; + prior.lhb_operations[LCK_database] = LOCK_header->lhb_operations[LCK_database]; + prior.lhb_operations[LCK_relation] = LOCK_header->lhb_operations[LCK_relation]; + prior.lhb_operations[LCK_bdb] = LOCK_header->lhb_operations[LCK_bdb]; + prior.lhb_operations[LCK_tra] = LOCK_header->lhb_operations[LCK_tra]; + prior.lhb_operations[LCK_attachment] = LOCK_header->lhb_operations[LCK_attachment]; prior.lhb_operations[0] = LOCK_header->lhb_operations[0]; } @@ -1092,16 +1104,16 @@ static void prt_lock_activity(OUTFILE outfile, { FPRINTF(outfile, "%9" UQUADFORMAT" %9" UQUADFORMAT" %9" UQUADFORMAT " %9" UQUADFORMAT" %9" UQUADFORMAT" %9" UQUADFORMAT" ", - (LOCK_header->lhb_operations[Jrd::LCK_database] - - base.lhb_operations[Jrd::LCK_database]) / factor, - (LOCK_header->lhb_operations[Jrd::LCK_relation] - - base.lhb_operations[Jrd::LCK_relation]) / factor, - (LOCK_header->lhb_operations[Jrd::LCK_bdb] - - base.lhb_operations[Jrd::LCK_bdb]) / factor, - (LOCK_header->lhb_operations[Jrd::LCK_tra] - - base.lhb_operations[Jrd::LCK_tra]) / factor, - (LOCK_header->lhb_operations[Jrd::LCK_attachment] - - base.lhb_operations[Jrd::LCK_attachment]) / factor, + (LOCK_header->lhb_operations[LCK_database] - + base.lhb_operations[LCK_database]) / factor, + (LOCK_header->lhb_operations[LCK_relation] - + base.lhb_operations[LCK_relation]) / factor, + (LOCK_header->lhb_operations[LCK_bdb] - + base.lhb_operations[LCK_bdb]) / factor, + (LOCK_header->lhb_operations[LCK_tra] - + base.lhb_operations[LCK_tra]) / factor, + (LOCK_header->lhb_operations[LCK_attachment] - + base.lhb_operations[LCK_attachment]) / factor, (LOCK_header->lhb_operations[0] - base.lhb_operations[0]) / factor); } @@ -1183,8 +1195,8 @@ static void prt_lock(OUTFILE outfile, const lhb* LOCK_header, const lbl* lock, U "\tSeries: %d, State: %d, Size: %d, Length: %d, Data: %" SQUADFORMAT"\n", lock->lbl_series, lock->lbl_state, lock->lbl_size, lock->lbl_length, lock->lbl_data); - if ((lock->lbl_series == Jrd::LCK_bdb || lock->lbl_series == Jrd::LCK_btr_dont_gc) && - lock->lbl_length == Jrd::PageNumber::getLockLen()) + if ((lock->lbl_series == LCK_bdb || lock->lbl_series == LCK_btr_dont_gc) && + lock->lbl_length == PageNumber::getLockLen()) { // Since fb 2.1 lock keys for page numbers (series == 3) contains // page space number in high long of two-longs key. Lets print it @@ -1200,8 +1212,8 @@ static void prt_lock(OUTFILE outfile, const lhb* LOCK_header, const lbl* lock, U FPRINTF(outfile, "\tKey: %04" ULONGFORMAT":%06" ULONGFORMAT",", pg_space, pageno); } - else if ((lock->lbl_series == Jrd::LCK_relation || lock->lbl_series == Jrd::LCK_rel_gc) && - lock->lbl_length == sizeof(ULONG) + sizeof(SINT64)) // Jrd::jrd_rel::getRelLockKeyLength() + else if ((lock->lbl_series == LCK_relation || lock->lbl_series == LCK_rel_gc) && + lock->lbl_length == sizeof(ULONG) + sizeof(SINT64)) // jrd_rel::getRelLockKeyLength() { const UCHAR* q = lock->lbl_key; @@ -1214,10 +1226,10 @@ static void prt_lock(OUTFILE outfile, const lhb* LOCK_header, const lbl* lock, U FPRINTF(outfile, "\tKey: %04" ULONGFORMAT":%09" SQUADFORMAT",", rel_id, instance_id); } - else if ((lock->lbl_series == Jrd::LCK_tra || - lock->lbl_series == Jrd::LCK_attachment || - lock->lbl_series == Jrd::LCK_monitor || - lock->lbl_series == Jrd::LCK_cancel) && + else if ((lock->lbl_series == LCK_tra || + lock->lbl_series == LCK_attachment || + lock->lbl_series == LCK_monitor || + lock->lbl_series == LCK_cancel) && lock->lbl_length == sizeof(SINT64)) { SINT64 key; @@ -1225,7 +1237,7 @@ static void prt_lock(OUTFILE outfile, const lhb* LOCK_header, const lbl* lock, U FPRINTF(outfile, "\tKey: %09" SQUADFORMAT",", key); } - else if (lock->lbl_series == Jrd::LCK_record_gc && + else if (lock->lbl_series == LCK_record_gc && lock->lbl_length == sizeof(SINT64)) { SINT64 key; @@ -1236,7 +1248,7 @@ static void prt_lock(OUTFILE outfile, const lhb* LOCK_header, const lbl* lock, U FPRINTF(outfile, "\tKey: %06" ULONGFORMAT":%04" ULONGFORMAT",", pageno, line); } - else if (lock->lbl_series == Jrd::LCK_idx_rescan && + else if (lock->lbl_series == LCK_idx_rescan && lock->lbl_length == sizeof(SLONG)) { SLONG key; @@ -1642,3 +1654,6 @@ static void prt_html_end(OUTFILE outfile) FPRINTF(outfile, ""); FPRINTF(outfile, ""); } + + +} // namespace Firebird::Jrd diff --git a/src/lock/tests/LockManagerTest.cpp b/src/lock/tests/LockManagerTest.cpp index 26717b30d87..bc7e65ec163 100644 --- a/src/lock/tests/LockManagerTest.cpp +++ b/src/lock/tests/LockManagerTest.cpp @@ -17,7 +17,7 @@ #include "../jrd/lck.h" using namespace Firebird; -using namespace Jrd; +using namespace Firebird::Jrd; namespace diff --git a/src/msgs/build_file.cpp b/src/msgs/build_file.cpp index 8a1b261a45c..292ae6ed1a0 100644 --- a/src/msgs/build_file.cpp +++ b/src/msgs/build_file.cpp @@ -41,13 +41,13 @@ #endif constexpr int max_levels = 4; -typedef msgnod* msgnod_ptr_array[max_levels]; +typedef Firebird::msgnod* msgnod_ptr_array[max_levels]; static char* copy_terminate(char* dest, const char* src, size_t bufsize); static void do_codes(const TEXT* gen_c_filename, const TEXT* gen_pas_filename); static USHORT do_msgs(const TEXT*); -static void propagate(msgnod**, msgnod**, ULONG, ULONG); -static SLONG write_bucket(const msgnod*, USHORT); +static void propagate(Firebird::msgnod**, Firebird::msgnod**, ULONG, ULONG); +static SLONG write_bucket(const Firebird::msgnod*, USHORT); static SLONG global_file_position; static int global_file; @@ -295,9 +295,9 @@ static USHORT do_msgs(const TEXT* filename) // Divy up memory among various buffers // Memory leaking until the program finishes? - msgrec* leaf_node = (msgrec*) malloc((SLONG) MSG_BUCKET); - msgrec* const leaf = leaf_node; - const TEXT* const end_leaf = (TEXT*) leaf + MSG_BUCKET; + Firebird::msgrec* leaf_node = (Firebird::msgrec*) malloc((SLONG) Firebird::MSG_BUCKET); + Firebird::msgrec* const leaf = leaf_node; + const TEXT* const end_leaf = (TEXT*) leaf + Firebird::MSG_BUCKET; // Open output file @@ -310,14 +310,14 @@ static USHORT do_msgs(const TEXT* filename) global_file_position = 0; // Format and write header - isc_msghdr header; - header.msghdr_major_version = MSG_MAJOR_VERSION; - header.msghdr_minor_version = MSG_MINOR_VERSION; - header.msghdr_bucket_size = MSG_BUCKET; + Firebird::isc_msghdr header; + header.msghdr_major_version = Firebird::MSG_MAJOR_VERSION; + header.msghdr_minor_version = Firebird::MSG_MINOR_VERSION; + header.msghdr_bucket_size = Firebird::MSG_BUCKET; // CVC: Since this is an unused field that holds garbage in the *.msg file, // we'll initialize it to the date the FB project was registered with SF. header.msghdr_origin = 20000730; // 2000-07-30 - write_bucket((msgnod*) &header, sizeof(header)); + write_bucket((Firebird::msgnod*) &header, sizeof(header)); // Write out messages building B-tree @@ -333,7 +333,7 @@ static USHORT do_msgs(const TEXT* filename) if (leaf_node->msgrec_text + textLen >= end_leaf) { - position = write_bucket((msgnod*) leaf, n); + position = write_bucket((Firebird::msgnod*) leaf, n); propagate(buckets, nodes, prior_code, position); leaf_node = leaf; } @@ -352,7 +352,7 @@ static USHORT do_msgs(const TEXT* filename) leaf_node->msgrec_length = static_cast(textLen); // Let's not store trash in flags. leaf_node->msgrec_flags = 0; - //n = offsetof(msgrec, msgrec_text) + textLen; // useless? See assignment below. + //n = offsetof(Firebird::msgrec, msgrec_text) + textLen; // useless? See assignment below. TEXT* p = leaf_node->msgrec_text; memcpy(p, message.text, textLen); n = static_cast(p + textLen - (SCHAR*) leaf); // For the next iteration. @@ -364,7 +364,7 @@ static USHORT do_msgs(const TEXT* filename) if (leaf_node->msgrec_text + len >= end_leaf) { n = (SCHAR *) leaf_node - (SCHAR *) leaf; - position = write_bucket((msgnod*) leaf, n); + position = write_bucket((Firebird::msgnod*) leaf, n); propagate(buckets, nodes, prior_code, position); leaf_node = leaf; } @@ -373,15 +373,15 @@ static USHORT do_msgs(const TEXT* filename) leaf_node->msgrec_length = 0; leaf_node->msgrec_flags = 0; n = (SCHAR *) leaf_node - (SCHAR *) leaf; - position = write_bucket((msgnod*) leaf, n); + position = write_bucket((Firebird::msgnod*) leaf, n); // Finish off upper levels of tree header.msghdr_levels = 1; - for (msgnod** ptr = nodes, **ptr2 = buckets; *ptr; ptr++, ptr2++) + for (Firebird::msgnod** ptr = nodes, **ptr2 = buckets; *ptr; ptr++, ptr2++) { - msgnod* node = *ptr; + Firebird::msgnod* node = *ptr; node->msgnod_code = ~0; node->msgnod_seek = position; n = (SCHAR *) (node + 1) - (SCHAR *) * ptr2; @@ -402,7 +402,7 @@ static USHORT do_msgs(const TEXT* filename) } -static void propagate(msgnod** buckets, msgnod** nodes, ULONG prior_code, ULONG position) +static void propagate(Firebird::msgnod** buckets, Firebird::msgnod** nodes, ULONG prior_code, ULONG position) { /************************************** * @@ -419,32 +419,32 @@ static void propagate(msgnod** buckets, msgnod** nodes, ULONG prior_code, ULONG if (!*nodes) { - *nodes = *buckets = (msgnod*) malloc((SLONG) MSG_BUCKET); + *nodes = *buckets = (Firebird::msgnod*) malloc((SLONG) Firebird::MSG_BUCKET); nodes[1] = NULL; } // Insert into current bucket - msgnod* node = (*nodes)++; + Firebird::msgnod* node = (*nodes)++; node->msgnod_code = prior_code; node->msgnod_seek = position; // Check for full bucket. If not, we're done - const msgnod* const end = (msgnod*) ((SCHAR*) *buckets + MSG_BUCKET); + const Firebird::msgnod* const end = (Firebird::msgnod*) ((SCHAR*) *buckets + Firebird::MSG_BUCKET); if (*nodes < end) return; // Bucket is full -- write it out, propagate the split, and re-initialize - position = write_bucket(*buckets, MSG_BUCKET); + position = write_bucket(*buckets, Firebird::MSG_BUCKET); propagate(buckets + 1, nodes + 1, prior_code, position); *nodes = *buckets; } -static SLONG write_bucket(const msgnod* bucket, USHORT length) +static SLONG write_bucket(const Firebird::msgnod* bucket, USHORT length) { /************************************** * diff --git a/src/plugins/crypt/arc4/Arc4.h b/src/plugins/crypt/arc4/Arc4.h index 06abc299e44..f557c2a0778 100644 --- a/src/plugins/crypt/arc4/Arc4.h +++ b/src/plugins/crypt/arc4/Arc4.h @@ -33,6 +33,6 @@ namespace Crypt { void registerArc4(Firebird::IPluginManager* iPlugin); -} // namespace Auth +} // namespace Firebird::Auth #endif // CRYPT_ARC4_H diff --git a/src/plugins/crypt/chacha/ChaCha.cpp b/src/plugins/crypt/chacha/ChaCha.cpp index 02cb9c76f71..7ba6d1a4790 100644 --- a/src/plugins/crypt/chacha/ChaCha.cpp +++ b/src/plugins/crypt/chacha/ChaCha.cpp @@ -46,7 +46,7 @@ void tomCheck(int err, const char* text, int specErr = CRYPT_OK, const char* sp buf = specText; else buf.printf("TomCrypt library error %s: %s", text, error_to_string(err)); - (Arg::Gds(isc_random) << buf).raise(); + (Firebird::Arg::Gds(isc_random) << buf).raise(); } @@ -70,7 +70,7 @@ class Cipher : public GlobalStorage tomCheck(chacha_ivctr64(&chacha, iv, 8, 0), "setting IV for CHACHA#20"); break; default: - (Arg::Gds(isc_random) << "Wrong IV length, need 8, 12 or 16").raise(); + (Firebird::Arg::Gds(isc_random) << "Wrong IV length, need 8, 12 or 16").raise(); break; } } @@ -169,7 +169,7 @@ class ChaCha final : public StdPlugin, Chec Cipher* createCypher(unsigned int l, const void* key) { if (l < 16) - (Arg::Gds(isc_random) << "Key too short").raise(); + (Firebird::Arg::Gds(isc_random) << "Key too short").raise(); hash_state md; tomCheck(sha256_init(&md), "initializing sha256"); diff --git a/src/plugins/profiler/Profiler.cpp b/src/plugins/profiler/Profiler.cpp index 0652db25e49..0c9b219da70 100644 --- a/src/plugins/profiler/Profiler.cpp +++ b/src/plugins/profiler/Profiler.cpp @@ -36,7 +36,8 @@ #include "../intl/charsets.h" #include "../jrd/intl.h" -using namespace Firebird; +namespace Firebird::Profiler +{ namespace @@ -1583,9 +1584,15 @@ SimpleFactory factory; } // anonymous namespace + +} // namespace Firebird::Profiler + + +using namespace Firebird; + extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { CachedMasterInterface::set(master); - PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_PROFILER, "Default_Profiler", &factory); + PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_PROFILER, "Default_Profiler", &Profiler::factory); getUnloadDetector()->registerMe(); } diff --git a/src/remote/SockAddr.h b/src/remote/SockAddr.h index 27bcd2b85ab..648ecb8f550 100644 --- a/src/remote/SockAddr.h +++ b/src/remote/SockAddr.h @@ -45,6 +45,10 @@ #include "../remote/remote.h" +namespace Firebird::Remote +{ + + class SockAddr { private: @@ -276,4 +280,6 @@ inline void SockAddr::unmapV4() } +} // namespace Firebird::Remote + #endif // REMOTE_SOCKADDR_H diff --git a/src/remote/client/BlrFromMessage.cpp b/src/remote/client/BlrFromMessage.cpp index 71970b73860..5168be736e4 100644 --- a/src/remote/client/BlrFromMessage.cpp +++ b/src/remote/client/BlrFromMessage.cpp @@ -33,11 +33,10 @@ #include "firebird/impl/sqlda_pub.h" #include "../remote/protocol.h" -using namespace Firebird; - -namespace Remote +namespace Firebird::Remote { + BlrFromMessage::BlrFromMessage(IMessageMetadata* metadata, unsigned aDialect, unsigned aProtocol) : BlrWriter(*getDefaultMemoryPool()), expectedMessageLength(0), dialect(aDialect), protocol(aProtocol) @@ -276,4 +275,5 @@ bool BlrFromMessage::isVersion4() return dialect <= 1; } -} + +} // namespace Firebird::Remote diff --git a/src/remote/client/BlrFromMessage.h b/src/remote/client/BlrFromMessage.h index f73b261c581..8267ce5c7b9 100644 --- a/src/remote/client/BlrFromMessage.h +++ b/src/remote/client/BlrFromMessage.h @@ -32,12 +32,14 @@ #include "firebird/Interface.h" #include "../common/classes/BlrWriter.h" -namespace Remote { +namespace Firebird::Remote +{ + -class BlrFromMessage : public Firebird::BlrWriter +class BlrFromMessage : public BlrWriter { public: - BlrFromMessage(Firebird::IMessageMetadata* metadata, unsigned dialect, unsigned protocol); + BlrFromMessage(IMessageMetadata* metadata, unsigned dialect, unsigned protocol); unsigned getLength(); const unsigned char* getBytes(); @@ -46,13 +48,14 @@ class BlrFromMessage : public Firebird::BlrWriter virtual bool isVersion4(); private: - void buildBlr(Firebird::IMessageMetadata* metadata); + void buildBlr(IMessageMetadata* metadata); unsigned expectedMessageLength; unsigned dialect; unsigned protocol; }; -} // namespace Firebird + +} // namespace Firebird::Remote #endif // FB_REMOTE_CLIENT_BLR_FROM_MESSAGE diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index 731b68266ec..9eb04717542 100644 --- a/src/remote/client/interface.cpp +++ b/src/remote/client/interface.cpp @@ -88,6 +88,9 @@ #include "../remote/os/win32/xnet_proto.h" #endif +namespace Firebird::Remote +{ + const char* const PROTOCOL_INET = "inet"; const char* const PROTOCOL_INET4 = "inet4"; @@ -101,8 +104,6 @@ const char* const INET_SEPARATOR = "/"; const char* const INET_LOCALHOST = "localhost"; -using namespace Firebird; - namespace { [[noreturn]] void handle_error(ISC_STATUS code) { @@ -181,8 +182,6 @@ namespace { GlobalPtr outPorts; } -namespace Remote { - // Provider stuff class Attachment; class Statement; @@ -1102,8 +1101,6 @@ void registerRedirector(IPluginManager* iPlugin) Crypt::registerArc4(iPlugin); } -} // namespace Remote - /* extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { @@ -1113,8 +1110,6 @@ extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) } */ -namespace Remote { - static Rvnt* add_event(rem_port*); static void add_other_params(rem_port*, ClumpletWriter&, const ParametersSet&); static void add_working_directory(ClumpletWriter&, const PathName&); @@ -10107,8 +10102,6 @@ static void cleanDpb(ClumpletWriter& dpb, const ParametersSet* tags) dpb.deleteWithTag(tags->trusted_auth); } -} //namespace Remote - void ClientPortsCleanup::closePort(rem_port* port) { @@ -10563,15 +10556,18 @@ void ClntAuthBlock::ClientCrypt::dispose() } } -int ClntAuthBlock::ClientCrypt::getHashLength(Firebird::CheckStatusWrapper* status) +int ClntAuthBlock::ClientCrypt::getHashLength(CheckStatusWrapper* status) { getHashData(status, nullptr); return -1; } -void ClntAuthBlock::ClientCrypt::getHashData(Firebird::CheckStatusWrapper* status, void*) +void ClntAuthBlock::ClientCrypt::getHashData(CheckStatusWrapper* status, void*) { ISC_STATUS err[] = {isc_arg_gds, isc_wish_list}; status->setErrors2(FB_NELEM(err), err); } + + +} // namespace Firebird::Remote diff --git a/src/remote/client/interface.h b/src/remote/client/interface.h index 6029819b896..9ecd5e4a633 100644 --- a/src/remote/client/interface.h +++ b/src/remote/client/interface.h @@ -29,9 +29,14 @@ #ifndef REMOTE_CLIENT_INTERFACE_H #define REMOTE_CLIENT_INTERFACE_H -namespace Remote +namespace Firebird { - void registerRedirector(Firebird::IPluginManager* iPlugin); + class IPluginManager; +} + +namespace Firebird::Remote +{ + void registerRedirector(IPluginManager* iPlugin); } #endif // REMOTE_CLIENT_INTERFACE_H diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index dd18c041126..2ae47961c30 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -118,7 +118,8 @@ constexpr int INET_RETRY_CALL = 5; extern int h_errno; #endif -using namespace Firebird; +namespace Firebird::Remote +{ #ifdef WIN_NT @@ -3370,7 +3371,11 @@ void setStopMainThread(FPTR_INT func) tryStopMainThread = func; } -namespace os_utils +} // namespace Firebird::Remote + + +// FIXME: Move this part to src/common/os +namespace Firebird::os_utils { // force socket descriptor to have SOCK_CLOEXEC set diff --git a/src/remote/inet_proto.h b/src/remote/inet_proto.h index 0db635a6dd9..e65c8cb696f 100644 --- a/src/remote/inet_proto.h +++ b/src/remote/inet_proto.h @@ -33,13 +33,16 @@ namespace Firebird class ClumpletReader; } -rem_port* INET_analyze(ClntAuthBlock*, const Firebird::PathName&, const TEXT*, - bool, Firebird::ClumpletReader&, Firebird::RefPtr*, - const Firebird::PathName*, Firebird::ICryptKeyCallback*, int af = AF_UNSPEC); -rem_port* INET_connect(const TEXT*, struct packet*, USHORT, Firebird::ClumpletReader*, - Firebird::RefPtr*, int af = AF_UNSPEC); -rem_port* INET_reconnect(SOCKET); -rem_port* INET_server(SOCKET); -void setStopMainThread(FPTR_INT func); +namespace Firebird::Remote +{ + rem_port* INET_analyze(ClntAuthBlock*, const PathName&, const TEXT*, + bool, ClumpletReader&, RefPtr*, + const PathName*, ICryptKeyCallback*, int af = AF_UNSPEC); + rem_port* INET_connect(const TEXT*, struct packet*, USHORT, ClumpletReader*, + RefPtr*, int af = AF_UNSPEC); + rem_port* INET_reconnect(SOCKET); + rem_port* INET_server(SOCKET); + void setStopMainThread(FPTR_INT func); +} // namespace Firebird::Remote #endif // REMOTE_INET_PROTO_H diff --git a/src/remote/merge.cpp b/src/remote/merge.cpp index e19f20047d2..818e24c9f65 100644 --- a/src/remote/merge.cpp +++ b/src/remote/merge.cpp @@ -29,7 +29,9 @@ #include "../yvalve/gds_proto.h" #include "../common/classes/DbImplementation.h" -using namespace Firebird; +namespace Firebird::Remote +{ + inline void PUT_WORD(UCHAR*& ptr, USHORT value) { @@ -227,3 +229,6 @@ static ISC_STATUS merge_setup(const ClumpletReader& input, UCHAR** out, const UC return FB_SUCCESS; } + + +} // namespace Firebird::Remote diff --git a/src/remote/merge_proto.h b/src/remote/merge_proto.h index 2991f6e8c44..b99af69f0e1 100644 --- a/src/remote/merge_proto.h +++ b/src/remote/merge_proto.h @@ -24,8 +24,10 @@ #ifndef REMOTE_MERGE_PROTO_H #define REMOTE_MERGE_PROTO_H -USHORT MERGE_database_info(const UCHAR*, UCHAR*, USHORT, USHORT, - USHORT, USHORT, const UCHAR*, const UCHAR*, USHORT); +namespace Firebird::Remote +{ + USHORT MERGE_database_info(const UCHAR*, UCHAR*, USHORT, USHORT, + USHORT, USHORT, const UCHAR*, const UCHAR*, USHORT); +} // namespace Firebird::Remote #endif // REMOTE_MERGE_PROTO_H - diff --git a/src/remote/os/win32/xnet.cpp b/src/remote/os/win32/xnet.cpp index 92fbac1a804..d6fb0c00740 100644 --- a/src/remote/os/win32/xnet.cpp +++ b/src/remote/os/win32/xnet.cpp @@ -50,8 +50,9 @@ #pragma FB_COMPILER_MESSAGE("POSIX implementation is required") #endif // WIN_NT -using namespace Firebird; -using namespace Remote; +namespace Firebird::Remote +{ + static bool accept_connection(rem_port*, const P_CNCT*); static rem_port* alloc_port(rem_port*, UCHAR*, ULONG, UCHAR*, ULONG); @@ -84,8 +85,7 @@ static DWORD current_process_id; static volatile bool xnet_shutdown = false; static GlobalPtr xnet_ports; -namespace Remote -{ + class XnetEndPoint { public: @@ -186,7 +186,6 @@ namespace Remote static GlobalPtr xnet_client; static GlobalPtr xnet_server; -} // namespace Remote inline void XnetEndPoint::make_obj_name(char* buffer, size_t size, const char* format) @@ -2547,3 +2546,6 @@ rem_port* XnetServerEndPoint::get_server_port(ULONG client_pid, return port; } + + +} // namespace Firebird::Remote diff --git a/src/remote/os/win32/xnet.h b/src/remote/os/win32/xnet.h index d9f7960da38..021bb8391a0 100644 --- a/src/remote/os/win32/xnet.h +++ b/src/remote/os/win32/xnet.h @@ -37,6 +37,11 @@ #define FILE_ID HANDLE #endif +namespace Firebird::Remote +{ + class XnetEndPoint; + + // Receive wait timeout (ms) inline constexpr DWORD XNET_RECV_WAIT_TIMEOUT = 500; @@ -96,23 +101,18 @@ typedef struct xch ULONG xch_dummy2; // with 32-bit builds } *XCH; - -namespace Remote { -class XnetEndPoint; -}; - // Thread connection control block typedef struct xcc { - explicit xcc(Remote::XnetEndPoint* endPoint) + explicit xcc(XnetEndPoint* endPoint) { memset(this, 0, sizeof(*this)); xcc_endpoint = endPoint; } struct xcc *xcc_next; // pointer to next thread - Remote::XnetEndPoint* xcc_endpoint; // XnetEndPoint + XnetEndPoint* xcc_endpoint; // XnetEndPoint XPM xcc_xpm; // pointer back to xpm ULONG xcc_map_num; // this thread's mapped file number ULONG xcc_slot; // this thread's slot number @@ -201,4 +201,7 @@ inline constexpr const char* XNET_E_C2S_EVNT_CHAN_EMPTED = "%s_E_C2S_EVNT_EMPTED inline constexpr const char* XNET_E_S2C_EVNT_CHAN_FILLED = "%s_E_S2C_EVNT_FILLED_%" ULONGFORMAT"_%" ULONGFORMAT"_%" ULONGFORMAT; inline constexpr const char* XNET_E_S2C_EVNT_CHAN_EMPTED = "%s_E_S2C_EVNT_EMPTED_%" ULONGFORMAT"_%" ULONGFORMAT"_%" ULONGFORMAT; + +} // namespace Firebird::Remote + #endif // REMOTE_XNET_H diff --git a/src/remote/os/win32/xnet_proto.h b/src/remote/os/win32/xnet_proto.h index c453e7e1a73..68088771e06 100644 --- a/src/remote/os/win32/xnet_proto.h +++ b/src/remote/os/win32/xnet_proto.h @@ -32,9 +32,12 @@ #define rem_port void #endif -rem_port* XNET_analyze(ClntAuthBlock*, const Firebird::PathName&, bool, Firebird::RefPtr*, - const Firebird::PathName*); -rem_port* XNET_connect(struct packet*, USHORT, Firebird::RefPtr*); -rem_port* XNET_reconnect(ULONG); +namespace Firebird::Remote +{ + rem_port* XNET_analyze(ClntAuthBlock*, const PathName&, bool, RefPtr*, + const PathName*); + rem_port* XNET_connect(struct packet*, USHORT, RefPtr*); + rem_port* XNET_reconnect(ULONG); +} // namespace Firebird::Remote #endif // REMOTE_XNET_PROTO_H diff --git a/src/remote/parse_proto.h b/src/remote/parse_proto.h index 908b5e3445e..50b4c2d2715 100644 --- a/src/remote/parse_proto.h +++ b/src/remote/parse_proto.h @@ -24,7 +24,10 @@ #ifndef REMOTE_PARSE_PROTO_H #define REMOTE_PARSE_PROTO_H -struct RMessage* PARSE_messages(const UCHAR*, size_t); -struct rem_fmt* PARSE_msg_format(const UCHAR*, size_t); +namespace Firebird::Remote +{ + struct RMessage* PARSE_messages(const UCHAR*, size_t); + struct rem_fmt* PARSE_msg_format(const UCHAR*, size_t); +} // namespace Firebird::Remote #endif // REMOTE_PARSE_PROTO_H diff --git a/src/remote/parser.cpp b/src/remote/parser.cpp index ca462e6ed6b..086576ec017 100644 --- a/src/remote/parser.cpp +++ b/src/remote/parser.cpp @@ -36,7 +36,9 @@ #include "../yvalve/gds_proto.h" // gds__log() #endif -using namespace Firebird; +namespace Firebird::Remote +{ + static rem_fmt* parse_format(const UCHAR*& blr, size_t& blr_length); @@ -383,3 +385,5 @@ static rem_fmt* parse_format(const UCHAR*& blr, size_t& blr_length) return format.release(); } + +} // namespace Firebird::Remote diff --git a/src/remote/proto_proto.h b/src/remote/proto_proto.h index 71039ea347c..f3ad0fc78a6 100644 --- a/src/remote/proto_proto.h +++ b/src/remote/proto_proto.h @@ -24,10 +24,13 @@ #ifndef REMOTE_PROTO_PROTO_H #define REMOTE_PROTO_PROTO_H +namespace Firebird::Remote +{ #ifdef DEBUG_XDR_MEMORY -void xdr_debug_memory (RemoteXdr*, enum xdr_op, const void*, const void*, ULONG); + void xdr_debug_memory(RemoteXdr*, enum xdr_op, const void*, const void*, ULONG); #endif -bool_t xdr_protocol (RemoteXdr*, struct packet*); -ULONG xdr_protocol_overhead (P_OP) noexcept; + bool_t xdr_protocol(RemoteXdr*, struct packet*); + ULONG xdr_protocol_overhead(P_OP) noexcept; +} // namespace Firebird::Remote #endif // REMOTE_PROTO_PROTO_H diff --git a/src/remote/protocol.cpp b/src/remote/protocol.cpp index 94cba4733a9..64679d5e3b5 100644 --- a/src/remote/protocol.cpp +++ b/src/remote/protocol.cpp @@ -45,7 +45,9 @@ #include "../common/utils_proto.h" #include "../dsql/DsqlBatch.h" -using namespace Firebird; +namespace Firebird::Remote +{ + #ifdef DEBUG_XDR_MEMORY inline bool_t P_TRUE(RemoteXdr* xdrs, PACKET* p) @@ -2602,3 +2604,6 @@ static bool_t xdr_blobBuffer(RemoteXdr* xdrs, RemBlobBuffer* buff) return FALSE; } + + +} // namespace Firebird::Remote diff --git a/src/remote/protocol.h b/src/remote/protocol.h index 975d344b84a..ea64c999d82 100644 --- a/src/remote/protocol.h +++ b/src/remote/protocol.h @@ -34,13 +34,17 @@ #define REMOTE_PROTOCOL_H // forward -namespace Firebird { +namespace Firebird +{ class DynamicStatusVector; } -class RemBlobBuffer; // see remote.h +namespace Firebird::Remote +{ +class RemBlobBuffer; // see remote.h + // dimitr: ask for asymmetric protocols only. // Comment it out to return back to FB 1.0 behaviour. #define ASYMMETRIC_PROTOCOLS_ONLY @@ -468,7 +472,7 @@ typedef struct p_resp OBJCT p_resp_object; // Object id SQUAD p_resp_blob_id; // Blob id CSTRING p_resp_data; // Data - Firebird::DynamicStatusVector* p_resp_status_vector; + DynamicStatusVector* p_resp_status_vector; } P_RESP; #define p_resp_partner p_resp_blob_id.bid_number @@ -848,4 +852,7 @@ typedef struct packet } } PACKET; + +} // namespace Firebird::Remote + #endif // REMOTE_PROTOCOL_H diff --git a/src/remote/remot_proto.h b/src/remote/remot_proto.h index 712de8f522e..7d685a5da5c 100644 --- a/src/remote/remot_proto.h +++ b/src/remote/remot_proto.h @@ -37,7 +37,12 @@ namespace Firebird class ClumpletReader; } +namespace Firebird::Remote +{ + + struct rem_port; + struct RemoteXdr : public xdr_t { RemoteXdr() noexcept @@ -56,7 +61,7 @@ enum LegacyPlugin {PLUGIN_NEW = 0, PLUGIN_LEGACY, PLUGIN_TRUSTED}; void REMOTE_cleanup_transaction (struct Rtr *); USHORT REMOTE_compute_batch_size(const rem_port*, USHORT, P_OP, const rem_fmt*) noexcept; -void REMOTE_get_timeout_params(rem_port* port, Firebird::ClumpletReader* pb); +void REMOTE_get_timeout_params(rem_port* port, ClumpletReader* pb); struct Rrq* REMOTE_find_request (struct Rrq *, USHORT); void REMOTE_free_packet(rem_port*, PACKET*, bool = false); struct rem_str* REMOTE_make_string (const SCHAR*); @@ -66,9 +71,9 @@ void REMOTE_reset_request(struct Rrq*, const struct RMessage*); void REMOTE_reset_statement(struct Rsr*) noexcept; bool_t REMOTE_getbytes (RemoteXdr*, SCHAR*, unsigned); LegacyPlugin REMOTE_legacy_auth(const char* nm, int protocol) noexcept; -Firebird::RefPtr REMOTE_get_config(const Firebird::PathName* dbName, - const Firebird::string* dpb_config = NULL); -void REMOTE_check_response(Firebird::IStatus* warning, Rdb* rdb, const PACKET* packet, bool checkKeys = false); +RefPtr REMOTE_get_config(const PathName* dbName, + const string* dpb_config = NULL); +void REMOTE_check_response(IStatus* warning, Rdb* rdb, const PACKET* packet, bool checkKeys = false); bool REMOTE_inflate(rem_port*, PacketReceive*, UCHAR*, SSHORT, SSHORT*); bool REMOTE_deflate(RemoteXdr*, ProtoWrite*, PacketSend*, bool flash); @@ -77,4 +82,7 @@ extern const signed char wcCompatible[3][3]; #define HANDSHAKE_DEBUG(A) #define WIRECRYPT_DEBUG(A) + +} // namespace Firebird::Remote + #endif // REMOTE_REMOT_PROTO_H diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp index 7de4d2ded74..3e248dbbf40 100644 --- a/src/remote/remote.cpp +++ b/src/remote/remote.cpp @@ -40,7 +40,9 @@ #include "../common/classes/ImplementHelper.h" #include "../common/utils_proto.h" -using namespace Firebird; +namespace Firebird::Remote +{ + #ifdef DEV_BUILD AtomicCounter rem_port::portCounter; @@ -1826,3 +1828,6 @@ const signed char wcCompatible[3][3] = { /* ENABLED */ {WIRECRYPT_DISABLED, WIRECRYPT_ENABLED, WIRECRYPT_REQUIRED}, /* REQUIRED */ {WIRECRYPT_BROKEN, WIRECRYPT_REQUIRED, WIRECRYPT_REQUIRED} }; + + +} // namespace Firebird::Remote diff --git a/src/remote/remote.h b/src/remote/remote.h index 90b60bd0163..abef9eacb10 100644 --- a/src/remote/remote.h +++ b/src/remote/remote.h @@ -42,7 +42,7 @@ #include "../common/StatusHolder.h" #include "../common/classes/RefCounted.h" #include "../common/classes/GetPlugins.h" - +#include "../remote/remot_proto.h" #include "firebird/Interface.h" #include // std::is_unsigned @@ -88,10 +88,36 @@ DEFINE_TRACE_ROUTINE(remote_trace); #endif -inline constexpr int BLOB_LENGTH = 16384; - #include "../remote/protocol.h" #include "fb_blk.h" +#include "../common/dsc.h" + +#ifdef WIN_NT +#include +#else +typedef int SOCKET; +#endif + + +// fwd. decl. +namespace Firebird +{ + class Exception; + class BatchCompletionState; +} + +namespace Firebird::os_utils +{ + // force descriptor to have O_CLOEXEC set + SOCKET socket(int domain, int type, int protocol); + SOCKET accept(SOCKET sockfd, sockaddr *addr, socklen_t *addrlen); +} + +namespace Firebird::Remote +{ + + +inline constexpr int BLOB_LENGTH = 16384; // Prefetch constants @@ -107,38 +133,19 @@ inline constexpr ULONG DEFAULT_BLOBS_CACHE_SIZE = 10 * 1024 * 1024; // 10 MB inline constexpr ULONG MAX_INLINE_BLOB_SIZE = MAX_USHORT; inline constexpr ULONG DEFAULT_INLINE_BLOB_SIZE = MAX_USHORT; -// fwd. decl. -namespace Firebird { - class Exception; - class BatchCompletionState; -} - -#ifdef WIN_NT -#include -#else -typedef int SOCKET; -#endif - -namespace os_utils -{ - // force descriptor to have O_CLOEXEC set - SOCKET socket(int domain, int type, int protocol); - SOCKET accept(SOCKET sockfd, sockaddr *addr, socklen_t *addrlen); -} - struct rem_port; -typedef Firebird::AutoPtr UCharArrayAutoPtr; +typedef AutoPtr UCharArrayAutoPtr; -typedef Firebird::RefPtr ServAttachment; -typedef Firebird::RefPtr ServBlob; -typedef Firebird::RefPtr ServTransaction; -typedef Firebird::RefPtr ServStatement; -typedef Firebird::RefPtr ServCursor; -typedef Firebird::RefPtr ServBatch; -typedef Firebird::RefPtr ServRequest; -typedef Firebird::RefPtr ServEvents; -typedef Firebird::RefPtr ServService; +typedef RefPtr ServAttachment; +typedef RefPtr ServBlob; +typedef RefPtr ServTransaction; +typedef RefPtr ServStatement; +typedef RefPtr ServCursor; +typedef RefPtr ServBatch; +typedef RefPtr ServRequest; +typedef RefPtr ServEvents; +typedef RefPtr ServService; // this set of parameters helps using same functions @@ -157,7 +164,7 @@ struct ParametersSet extern const ParametersSet dpbParam, spbParam, connectParam; -struct Svc : public Firebird::GlobalStorage +struct Svc : public GlobalStorage { ServService svc_iface; // service interface Svc() : @@ -166,11 +173,11 @@ struct Svc : public Firebird::GlobalStorage }; -struct Rdb : public Firebird::GlobalStorage, public TypedHandle +struct Rdb : public GlobalStorage, public TypedHandle { ServAttachment rdb_iface; // attachment interface rem_port* rdb_port; // communication port - Firebird::AutoPtr rdb_svc; // service-specific block + AutoPtr rdb_svc; // service-specific block struct Rtr* rdb_transactions; // linked list of transactions struct Rrq* rdb_requests; // compiled requests struct Rvnt* rdb_events; // known events @@ -232,7 +239,7 @@ struct Rbl; class BlobsContainer { public: - BlobsContainer(Firebird::MemoryPool& pool) : + BlobsContainer(MemoryPool& pool) : m_tree(pool) { } @@ -309,10 +316,10 @@ class BlobsContainer Rbl* m_blob; }; - Firebird::BePlusTree m_tree; + BePlusTree m_tree; }; -struct Rtr : public Firebird::GlobalStorage, public TypedHandle +struct Rtr : public GlobalStorage, public TypedHandle { Rdb* rtr_rdb; Rtr* rtr_next; @@ -321,7 +328,7 @@ struct Rtr : public Firebird::GlobalStorage, public TypedHandle USHORT rtr_id; bool rtr_limbo; - Firebird::Array rtr_cursors; + Array rtr_cursors; Rtr** rtr_self; Rbl* rtr_inline_blob; @@ -363,12 +370,12 @@ struct RBlobInfo }; // Used in XDR -class RemBlobBuffer : public Firebird::Array +class RemBlobBuffer : public Array { - using Firebird::Array::Array; + using Array::Array; }; -struct Rbl : public Firebird::GlobalStorage, public TypedHandle +struct Rbl : public GlobalStorage, public TypedHandle { RemBlobBuffer rbl_data; Rdb* rbl_rdb; @@ -427,7 +434,7 @@ struct Rbl : public Firebird::GlobalStorage, public TypedHandle inline Rbl* BlobsContainer::locate(SQUAD blob_id) { Rbl* blob = nullptr; - if (m_tree.locate(Firebird::LocType::locGreat, Item(blob_id))) + if (m_tree.locate(LocType::locGreat, Item(blob_id))) { blob = m_tree.current().m_blob; if (blob->rbl_blob_id == blob_id) @@ -443,17 +450,17 @@ inline BlobsContainer::Item::Item(Rbl* blob) noexcept } -struct Rvnt : public Firebird::GlobalStorage, public TypedHandle +struct Rvnt : public GlobalStorage, public TypedHandle { Rvnt* rvnt_next; Rdb* rvnt_rdb; - Firebird::RefPtr rvnt_callback; + RefPtr rvnt_callback; ServEvents rvnt_iface; rem_port* rvnt_port; // used to id server from whence async came SLONG rvnt_id; // used to store client-side id USHORT rvnt_length; Rvnt** rvnt_self; - Firebird::AtomicCounter rvnt_destroyed; + AtomicCounter rvnt_destroyed; public: Rvnt() : @@ -476,19 +483,15 @@ struct rem_str : public pool_alloc_rpt }; -// Include definition of descriptor - -#include "../common/dsc.h" - // Note, currently the only routine that created and changed rem_fmt is // parse_format() in parse.cpp -struct rem_fmt : public Firebird::GlobalStorage +struct rem_fmt : public GlobalStorage { ULONG fmt_length; ULONG fmt_net_length; - Firebird::Array fmt_desc; - Firebird::HalfStaticArray fmt_blob_idx; // indices of blob's in fmt_desc + Array fmt_desc; + HalfStaticArray fmt_blob_idx; // indices of blob's in fmt_desc public: explicit rem_fmt(FB_SIZE_T rpt) : @@ -508,7 +511,7 @@ struct rem_fmt : public Firebird::GlobalStorage // Windows declares a msg structure, so rename the structure // to avoid overlap problems. -struct RMessage : public Firebird::GlobalStorage +struct RMessage : public GlobalStorage { RMessage* msg_next; // Next available message USHORT msg_number; // Message number @@ -525,7 +528,7 @@ struct RMessage : public Firebird::GlobalStorage // remote stored procedure request -struct Rpr : public Firebird::GlobalStorage +struct Rpr : public GlobalStorage { Rdb* rpr_rdb; Rtr* rpr_rtr; @@ -541,7 +544,7 @@ struct Rpr : public Firebird::GlobalStorage { } }; -struct Rrq : public Firebird::GlobalStorage, public TypedHandle +struct Rrq : public GlobalStorage, public TypedHandle { Rdb* rrq_rdb; Rtr* rrq_rtr; @@ -551,7 +554,7 @@ struct Rrq : public Firebird::GlobalStorage, public TypedHandle USHORT rrq_id; USHORT rrq_max_msg; USHORT rrq_level; - Firebird::StatusHolder rrqStatus; + StatusHolder rrqStatus; struct rrq_repeat { @@ -564,7 +567,7 @@ struct Rrq : public Firebird::GlobalStorage, public TypedHandle USHORT rrq_batch_count; // Count of batches in pipeline }; - Firebird::Array rrq_rpt; + Array rrq_rpt; Rrq** rrq_self; public: @@ -596,8 +599,8 @@ struct Rrq : public Firebird::GlobalStorage, public TypedHandle static constexpr ISC_STATUS badHandle() noexcept { return isc_bad_req_handle; } - void saveStatus(const Firebird::Exception& ex) noexcept; - void saveStatus(Firebird::IStatus* ex) noexcept; + void saveStatus(const Exception& ex) noexcept; + void saveStatus(IStatus* ex) noexcept; }; @@ -644,7 +647,7 @@ class RFlags // remote SQL request -struct Rsr : public Firebird::GlobalStorage, public TypedHandle +struct Rsr : public GlobalStorage, public TypedHandle { Rsr* rsr_next; Rdb* rsr_rdb; @@ -658,7 +661,7 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle rem_fmt* rsr_format; // Format of current message RMessage* rsr_message; // Next message to process RMessage* rsr_buffer; // Next buffer to use - Firebird::StatusHolder* rsr_status; // saved status for buffered errors + StatusHolder* rsr_status; // saved status for buffered errors USHORT rsr_id; RFlags rsr_flags; ULONG rsr_fmt_length; @@ -668,7 +671,7 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle USHORT rsr_reorder_level; // Trigger pipelining at this level USHORT rsr_batch_count; // Count of batches in pipeline - Firebird::string rsr_cursor_name; // Name for cursor to be set on open + string rsr_cursor_name; // Name for cursor to be set on open bool rsr_delayed_format; // Out format was delayed on execute, set it on fetch unsigned int rsr_timeout; // Statement timeout to be set on open\execute Rsr** rsr_self; @@ -677,8 +680,8 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle ULONG rsr_batch_flags; // Flags for batch processing union // BatchCS passed to XDR protocol { - Firebird::IBatchCompletionState* rsr_batch_ics; // server - Firebird::BatchCompletionState* rsr_batch_cs; // client + IBatchCompletionState* rsr_batch_ics; // server + BatchCompletionState* rsr_batch_cs; // client }; P_FETCH rsr_fetch_operation; // Last performed fetch operation @@ -693,7 +696,7 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle static constexpr ULONG SIZEOF_BLOB_HEAD = sizeof(ISC_QUAD) + 2 * sizeof(ULONG); - typedef Firebird::HalfStaticArray Bpb; + typedef HalfStaticArray Bpb; Bpb curBpb; UCHAR hdr[SIZEOF_BLOB_HEAD]; ULONG blobRemaining; // Remaining to transfer size of blob data @@ -758,8 +761,8 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle delete rsr_status; } - void saveException(Firebird::IStatus* status, bool overwrite); - void saveException(const Firebird::Exception& ex, bool overwrite); + void saveException(IStatus* status, bool overwrite); + void saveException(const Exception& ex, bool overwrite); void clearException(); ISC_STATUS haveException(); void raiseException(); @@ -809,7 +812,7 @@ class RemoteObject { if (!r || !r->checkHandle()) { - Firebird::status_exception::raise(Firebird::Arg::Gds(R::badHandle())); + status_exception::raise(Arg::Gds(R::badHandle())); } return r; } @@ -832,10 +835,10 @@ class RemoteObject -inline void Rsr::saveException(Firebird::IStatus* status, bool overwrite) +inline void Rsr::saveException(IStatus* status, bool overwrite) { if (!rsr_status) { - rsr_status = FB_NEW Firebird::StatusHolder(); + rsr_status = FB_NEW StatusHolder(); } if (overwrite || !rsr_status->getError()) { rsr_status->save(status); @@ -865,9 +868,6 @@ inline void Rsr::releaseException() noexcept rsr_status = NULL; } -#include "../remote/remot_proto.h" - - // Generalized port definition. ////////////////////////////////////////////////////////////////// @@ -884,7 +884,7 @@ struct rem_que_packet bool sent; }; -typedef Firebird::Array PacketQueue; +typedef Array PacketQueue; class ServerAuthBase { @@ -901,15 +901,15 @@ class ServerCallbackBase public: virtual ~ServerCallbackBase(); virtual void wakeup(unsigned int length, const void* data) = 0; - virtual Firebird::ICryptKeyCallback* getInterface() = 0; + virtual ICryptKeyCallback* getInterface() = 0; virtual void stop() = 0; virtual void destroy() = 0; }; // CryptKey implementation class InternalCryptKey final : - public Firebird::VersionedIface >, - public Firebird::GlobalStorage + public VersionedIface>, + public GlobalStorage { public: InternalCryptKey() @@ -919,17 +919,17 @@ class InternalCryptKey final : { } // ICryptKey implementation - void setSymmetric(Firebird::CheckStatusWrapper* status, const char* type, unsigned keyLength, const void* key); - void setAsymmetric(Firebird::CheckStatusWrapper* status, const char* type, unsigned encryptKeyLength, + void setSymmetric(CheckStatusWrapper* status, const char* type, unsigned keyLength, const void* key); + void setAsymmetric(CheckStatusWrapper* status, const char* type, unsigned encryptKeyLength, const void* encryptKey, unsigned decryptKeyLength, const void* decryptKey); const void* getEncryptKey(unsigned* length); const void* getDecryptKey(unsigned* length); - class Key : public Firebird::UCharBuffer + class Key : public UCharBuffer { public: Key(MemoryPool& pool) - : Firebird::UCharBuffer(pool) + : UCharBuffer(pool) { } void set(unsigned keyLength, const void* key) @@ -950,43 +950,43 @@ class InternalCryptKey final : }; Key encrypt, decrypt; - Firebird::PathName keyName; + PathName keyName; }; // Type of known by server key, received from it by client -class KnownServerKey : public Firebird::AutoStorage +class KnownServerKey : public AutoStorage { public: - Firebird::PathName type, plugins; - typedef Firebird::Pair > PluginSpecific; - Firebird::ObjectsArray specificData; + PathName type, plugins; + typedef Pair> PluginSpecific; + ObjectsArray specificData; KnownServerKey() - : Firebird::AutoStorage(), type(getPool()), plugins(getPool()), specificData(getPool()) + : AutoStorage(), type(getPool()), plugins(getPool()), specificData(getPool()) { } - explicit KnownServerKey(Firebird::MemoryPool& p) - : Firebird::AutoStorage(p), type(getPool()), plugins(getPool()), specificData(getPool()) + explicit KnownServerKey(MemoryPool& p) + : AutoStorage(p), type(getPool()), plugins(getPool()), specificData(getPool()) { } - KnownServerKey(Firebird::MemoryPool& p, const KnownServerKey& v) - : Firebird::AutoStorage(p), type(getPool(), v.type), plugins(getPool(), v.plugins), + KnownServerKey(MemoryPool& p, const KnownServerKey& v) + : AutoStorage(p), type(getPool(), v.type), plugins(getPool(), v.plugins), specificData(getPool(), v.specificData) { } KnownServerKey(const KnownServerKey&) = delete; KnownServerKey& operator=(const KnownServerKey&) = delete; - void addSpecificData(const Firebird::PathName& plugin, unsigned len, const void* data) + void addSpecificData(const PathName& plugin, unsigned len, const void* data) { PluginSpecific& p = specificData.add(); p.first = plugin; memcpy(p.second.getBuffer(len), data, len); } - const Firebird::UCharBuffer* findSpecificData(const Firebird::PathName& plugin) const + const UCharBuffer* findSpecificData(const PathName& plugin) const { for (unsigned i = 0; i < specificData.getCount(); ++i) { @@ -1007,58 +1007,58 @@ inline constexpr UCHAR TAG_KNOWN_PLUGINS = 2; inline constexpr UCHAR TAG_PLUGIN_SPECIFIC = 3; -typedef Firebird::GetPlugins AuthClientPlugins; +typedef GetPlugins AuthClientPlugins; // Representation of authentication data, visible for plugin // Transferred in format, depending upon type of the packet (phase of handshake) class RmtAuthBlock final : - public Firebird::VersionedIface > + public VersionedIface> { public: - RmtAuthBlock(const Firebird::AuthReader::AuthBlock& aBlock); + RmtAuthBlock(const AuthReader::AuthBlock& aBlock); -// Firebird::IAuthBlock implementation +// IAuthBlock implementation const char* getType(); const char* getName(); const char* getPlugin(); const char* getSecurityDb(); const char* getOriginalPlugin(); - FB_BOOLEAN next(Firebird::CheckStatusWrapper* status); - FB_BOOLEAN first(Firebird::CheckStatusWrapper* status); + FB_BOOLEAN next(CheckStatusWrapper* status); + FB_BOOLEAN first(CheckStatusWrapper* status); private: - Firebird::AuthReader::AuthBlock buffer; - Firebird::AuthReader rdr; - Firebird::AuthReader::Info info; + AuthReader::AuthBlock buffer; + AuthReader rdr; + AuthReader::Info info; FB_BOOLEAN loadInfo(); }; class ClntAuthBlock final : - public Firebird::RefCntIface > + public RefCntIface> { private: - Firebird::PathName pluginList; // To be passed to server - Firebird::PathName serverPluginList; // Received from server - Firebird::string cliUserName, cliPassword; // Used by plugin, taken from DPB - Firebird::string cliOrigUserName; // Original user name, passed to server + PathName pluginList; // To be passed to server + PathName serverPluginList; // Received from server + string cliUserName, cliPassword; // Used by plugin, taken from DPB + string cliOrigUserName; // Original user name, passed to server // These two are legacy encrypted password, trusted auth data and so on - what plugin needs - Firebird::UCharBuffer dataForPlugin, dataFromPlugin; - Firebird::HalfStaticArray cryptKeys; // Wire crypt keys that came from plugin(s) last time - Firebird::string dpbConfig; // User's configuration parameters - Firebird::PathName dpbPlugins; // User's plugin list - Firebird::RefPtr clntConfig; // Used to get plugins list and pass to port - Firebird::AutoPtr remAuthBlock; //Authentication block if present + UCharBuffer dataForPlugin, dataFromPlugin; + HalfStaticArray cryptKeys; // Wire crypt keys that came from plugin(s) last time + string dpbConfig; // User's configuration parameters + PathName dpbPlugins; // User's plugin list + RefPtr clntConfig; // Used to get plugins list and pass to port + AutoPtr remAuthBlock; //Authentication block if present unsigned nextKey; // First key to be analyzed class ClientCrypt final : - public Firebird::VersionedIface >, - public Firebird::GlobalStorage + public VersionedIface>, + public GlobalStorage { public: ClientCrypt() - : pluginItr(Firebird::IPluginManager::TYPE_KEY_HOLDER, "NoDefault"), + : pluginItr(IPluginManager::TYPE_KEY_HOLDER, "NoDefault"), currentIface(nullptr), afterIface(nullptr), triedPlugins(getPool()) { } @@ -1068,25 +1068,25 @@ class ClntAuthBlock final : dispose(); } - Firebird::ICryptKeyCallback* create(const Firebird::Config* conf); + ICryptKeyCallback* create(const Config* conf); - // Firebird::ICryptKeyCallback implementation + // ICryptKeyCallback implementation unsigned callback(unsigned dataLength, const void* data, unsigned bufferLength, void* buffer) override; - unsigned afterAttach(Firebird::CheckStatusWrapper* st, const char* dbName, const Firebird::IStatus* attStatus) override; + unsigned afterAttach(CheckStatusWrapper* st, const char* dbName, const IStatus* attStatus) override; void dispose() override; - int getHashLength(Firebird::CheckStatusWrapper* status) override; - void getHashData(Firebird::CheckStatusWrapper* status, void* hash) override; + int getHashLength(CheckStatusWrapper* status) override; + void getHashData(CheckStatusWrapper* status, void* hash) override; private: - typedef Firebird::GetPlugins KeyHolderItr; + typedef GetPlugins KeyHolderItr; KeyHolderItr pluginItr; - Firebird::ICryptKeyCallback* currentIface; - Firebird::ICryptKeyCallback* afterIface; + ICryptKeyCallback* currentIface; + ICryptKeyCallback* afterIface; class TriedPlugins { - typedef Firebird::Pair > TriedPlugin; - Firebird::ObjectsArray data; + typedef Pair > TriedPlugin; + ObjectsArray data; public: TriedPlugins(MemoryPool& p) @@ -1118,7 +1118,7 @@ class ClntAuthBlock final : return data.hasData(); } - Firebird::IKeyHolderPlugin* get() + IKeyHolderPlugin* get() { return data[0].second; } @@ -1127,14 +1127,14 @@ class ClntAuthBlock final : TriedPlugins triedPlugins; }; ClientCrypt clientCrypt; - Firebird::ICryptKeyCallback** createdInterface; + ICryptKeyCallback** createdInterface; public: AuthClientPlugins plugins; bool authComplete; // Set as response from client that authentication accepted bool firstTime; // Invoked first time after reset - ClntAuthBlock(const Firebird::PathName* fileName, Firebird::ClumpletReader* dpb, + ClntAuthBlock(const PathName* fileName, ClumpletReader* dpb, const ParametersSet* tags); ~ClntAuthBlock() @@ -1147,44 +1147,44 @@ class ClntAuthBlock final : void storeDataForPlugin(unsigned int length, const unsigned char* data); void resetDataFromPlugin(); - void extractDataFromPluginTo(Firebird::ClumpletWriter& dpb, const ParametersSet* tags, int protocol); + void extractDataFromPluginTo(ClumpletWriter& dpb, const ParametersSet* tags, int protocol); void extractDataFromPluginTo(CSTRING* to); void extractDataFromPluginTo(P_AUTH_CONT* to); - void loadClnt(Firebird::ClumpletWriter& dpb, const ParametersSet*); - void extractDataFromPluginTo(Firebird::ClumpletWriter& user_id); + void loadClnt(ClumpletWriter& dpb, const ParametersSet*); + void extractDataFromPluginTo(ClumpletWriter& user_id); void resetClnt(const CSTRING* listStr = NULL); - bool checkPluginName(Firebird::PathName& nameToCheck); - Firebird::PathName getPluginName(); + bool checkPluginName(PathName& nameToCheck); + PathName getPluginName(); void tryNewKeys(rem_port*); void releaseKeys(unsigned from); - Firebird::RefPtr* getConfig() noexcept; - void createCryptCallback(Firebird::ICryptKeyCallback** callback); + RefPtr* getConfig() noexcept; + void createCryptCallback(ICryptKeyCallback** callback); - // Firebird::IClientBlock implementation + // IClientBlock implementation const char* getLogin(); const char* getPassword(); const unsigned char* getData(unsigned int* length); - void putData(Firebird::CheckStatusWrapper* status, unsigned int length, const void* data); - Firebird::ICryptKey* newKey(Firebird::CheckStatusWrapper* status); - Firebird::IAuthBlock* getAuthBlock(Firebird::CheckStatusWrapper* status); + void putData(CheckStatusWrapper* status, unsigned int length, const void* data); + ICryptKey* newKey(CheckStatusWrapper* status); + IAuthBlock* getAuthBlock(CheckStatusWrapper* status); }; // Representation of authentication data, visible for plugin // Transferred from client data in format, suitable for plugins access -typedef Firebird::GetPlugins AuthServerPlugins; +typedef GetPlugins AuthServerPlugins; class SrvAuthBlock final : - public Firebird::VersionedIface >, - public Firebird::GlobalStorage + public VersionedIface>, + public GlobalStorage { private: rem_port* port; - Firebird::string userName; - Firebird::PathName pluginName, pluginList; + string userName; + PathName pluginName, pluginList; // These two may be legacy encrypted password, trusted auth data and so on - Firebird::UCharBuffer dataForPlugin, dataFromPlugin; - Firebird::ClumpletWriter lastExtractedKeys; - Firebird::HalfStaticArray newKeys; + UCharBuffer dataForPlugin, dataFromPlugin; + ClumpletWriter lastExtractedKeys; + HalfStaticArray newKeys; bool flComplete, firstTime; public: @@ -1199,7 +1199,7 @@ class SrvAuthBlock final : : port(p_port), userName(getPool()), pluginName(getPool()), pluginList(getPool()), dataForPlugin(getPool()), dataFromPlugin(getPool()), - lastExtractedKeys(getPool(), Firebird::ClumpletReader::UnTagged, MAX_DPB_SIZE), + lastExtractedKeys(getPool(), ClumpletReader::UnTagged, MAX_DPB_SIZE), newKeys(getPool()), flComplete(false), firstTime(true), plugins(NULL) @@ -1215,14 +1215,14 @@ class SrvAuthBlock final : void extractDataFromPluginTo(P_AUTH_CONT* to); void extractDataFromPluginTo(P_ACPD* to); bool authCompleted(bool flag = false); - void setLogin(const Firebird::string& user); - void load(Firebird::ClumpletReader& userId); + void setLogin(const string& user); + void load(ClumpletReader& userId); const char* getPluginName(); - void setPluginList(const Firebird::string& name); + void setPluginList(const string& name); const char* getPluginList(); - void setPluginName(const Firebird::string& name); + void setPluginName(const string& name); void extractPluginName(cstring* to); - void setDataForPlugin(const Firebird::UCharBuffer& data); + void setDataForPlugin(const UCharBuffer& data); void setDataForPlugin(const cstring& data); void createPluginsItr(); void setDataForPlugin(const p_auth_continue* data); @@ -1230,11 +1230,11 @@ class SrvAuthBlock final : bool extractNewKeys(CSTRING* to, ULONG flags); bool hasDataForPlugin(); - // Firebird::IServerBlock implementation + // IServerBlock implementation const char* getLogin() noexcept; const unsigned char* getData(unsigned int* length); - void putData(Firebird::CheckStatusWrapper* status, unsigned int length, const void* data); - Firebird::ICryptKey* newKey(Firebird::CheckStatusWrapper* status); + void putData(CheckStatusWrapper* status, unsigned int length, const void* data); + ICryptKey* newKey(CheckStatusWrapper* status); }; @@ -1266,19 +1266,19 @@ class RemotePortGuard; typedef rem_port* (*t_port_connect)(rem_port*, PACKET*); -typedef Firebird::RefPtr RemPortPtr; +typedef RefPtr RemPortPtr; -struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted +struct rem_port : public GlobalStorage, public RefCounted { #ifdef DEV_BUILD - static Firebird::AtomicCounter portCounter; + static AtomicCounter portCounter; #endif // sync objects - Firebird::RefPtr port_sync; - Firebird::RefPtr port_que_sync; - Firebird::RefPtr port_write_sync; - Firebird::RefPtr port_cancel_sync; + RefPtr port_sync; + RefPtr port_que_sync; + RefPtr port_write_sync; + RefPtr port_cancel_sync; // port function pointers (C "emulation" of virtual functions) bool (*port_accept)(rem_port*, const p_cnct*); @@ -1328,47 +1328,47 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted HANDLE port_pipe; // port pipe handle HANDLE port_event; // event associated with a port #endif - Firebird::AutoPtr port_receive; - Firebird::AutoPtr port_send; + AutoPtr port_receive; + AutoPtr port_send; #ifdef DEBUG_XDR_MEMORY r e m _ v e c* port_packet_vector; // Vector of send/receive packets #endif - Firebird::Array port_objects; + Array port_objects; rem_str* port_version; rem_str* port_host; // Our name rem_str* port_connection; // Name of connection P_ARCH port_client_arch; - Firebird::string port_login; - Firebird::string port_user_name; - Firebird::string port_peer_name; - Firebird::string port_protocol_id; // String containing protocol name for this port - Firebird::string port_address; // Protocol-specific address string for the port + string port_login; + string port_user_name; + string port_peer_name; + string port_protocol_id; // String containing protocol name for this port + string port_address; // Protocol-specific address string for the port Rpr* port_rpr; // port stored procedure reference Rsr* port_statement; // Statement for execute immediate rmtque* port_receive_rmtque; // for client, responses waiting - Firebird::AtomicCounter port_requests_queued; // requests currently queued + AtomicCounter port_requests_queued; // requests currently queued xcc* port_xcc; // interprocess structure PacketQueue* port_deferred_packets; // queue of deferred packets OBJCT port_last_object_id; // cached last id - Firebird::ObjectsArray< Firebird::Array > port_queue; + ObjectsArray< Array > port_queue; FB_SIZE_T port_qoffset; // current packet in the queue - Firebird::RefPtr port_config; // connection-specific configuration info + RefPtr port_config; // connection-specific configuration info // Authentication and crypt stuff ServerAuthBase* port_srv_auth; SrvAuthBlock* port_srv_auth_block; - Firebird::HalfStaticArray port_crypt_keys; // available wire crypt keys + HalfStaticArray port_crypt_keys; // available wire crypt keys bool port_crypt_complete; // wire crypt init is complete one way or another, // up to being turned off in firebird.conf signed char port_crypt_level; // encryption level for port - Firebird::ObjectsArray port_known_server_keys; // Server sends to client + ObjectsArray port_known_server_keys; // Server sends to client // keys known by it, they are stored here - Firebird::IWireCryptPlugin* port_crypt_plugin; // plugin used by port, when not NULL - crypts wire data - Firebird::ICryptKeyCallback* port_client_crypt_callback; // client callback to transfer database crypt key + IWireCryptPlugin* port_crypt_plugin; // plugin used by port, when not NULL - crypts wire data + ICryptKeyCallback* port_client_crypt_callback; // client callback to transfer database crypt key ServerCallbackBase* port_server_crypt_callback; // server callback to transfer database crypt key - Firebird::PathName port_crypt_name; // name of actual wire crypt plugin + PathName port_crypt_name; // name of actual wire crypt plugin - Firebird::RefPtr port_replicator; + RefPtr port_replicator; UCharArrayAutoPtr port_buffer; @@ -1474,10 +1474,10 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted public: rem_port(rem_port_t t, size_t rpt) : - port_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), - port_que_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), - port_write_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), - port_cancel_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), + port_sync(FB_NEW_POOL(getPool()) RefMutex()), + port_que_sync(FB_NEW_POOL(getPool()) RefMutex()), + port_write_sync(FB_NEW_POOL(getPool()) RefMutex()), + port_cancel_sync(FB_NEW_POOL(getPool()) RefMutex()), port_accept(0), port_disconnect(0), port_force_close(0), port_receive_packet(0), port_send_packet(0), port_send_partial(0), port_connect(0), port_request(0), port_select_multi(0), port_type(t), port_state(PENDING), port_clients(0), port_next(0), @@ -1526,16 +1526,16 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted return RefCounted::release(); } - friend class Firebird::RefPtr; + friend class RefPtr; public: void initCompression(); static bool checkCompression(); void linkParent(rem_port* const parent); void unlinkParent() noexcept; - Firebird::RefPtr getPortConfig(); - const Firebird::RefPtr& getPortConfig() const; - void versionInfo(Firebird::string& version) const; + RefPtr getPortConfig(); + const RefPtr& getPortConfig() const; + void versionInfo(string& version) const; bool extractNewKeys(CSTRING* to, bool flagPlugList = false) { @@ -1553,7 +1553,7 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted } if (id >= port_objects.getCount() || port_objects[id].isMissing()) { - Firebird::status_exception::raise(Firebird::Arg::Gds(T::badHandle())); + status_exception::raise(Arg::Gds(T::badHandle())); } blk = port_objects[id]; } @@ -1608,7 +1608,7 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted // release reference that was created in constructor bool releasePort() { - Firebird::RefMutexEnsureUnlock portGuard(*port_sync, FB_FUNCTION); + RefMutexEnsureUnlock portGuard(*port_sync, FB_FUNCTION); const bool locked = portGuard.tryEnter(); fb_assert(locked); @@ -1635,13 +1635,13 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted bool haveRecvData() { - Firebird::RefMutexGuard queGuard(*port_que_sync, FB_FUNCTION); + RefMutexGuard queGuard(*port_que_sync, FB_FUNCTION); return ((port_receive->x_handy > 0) || (port_qoffset < port_queue.getCount())); } void clearRecvQue() { - Firebird::RefMutexGuard queGuard(*port_que_sync, FB_FUNCTION); + RefMutexGuard queGuard(*port_que_sync, FB_FUNCTION); port_queue.clear(); port_qoffset = 0; port_receive->x_private = port_receive->x_base; @@ -1671,7 +1671,7 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted { if (rs.save_qoffset > 0 && (rs.save_qoffset != port_qoffset)) { - Firebird::Array& q = port_queue[rs.save_qoffset - 1]; + Array& q = port_queue[rs.save_qoffset - 1]; memcpy(port_receive->x_base, q.begin(), q.getCount()); } port_qoffset = rs.save_qoffset; @@ -1705,13 +1705,13 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted ISC_STATUS put_segment(P_OP, P_SGMT*, PACKET*); ISC_STATUS put_slice(P_SLC*, PACKET*); ISC_STATUS que_events(P_EVENT*, PACKET*); - ISC_STATUS receive_after_start(P_DATA* data, PACKET* sendL, Firebird::CheckStatusWrapper* status_vector); + ISC_STATUS receive_after_start(P_DATA* data, PACKET* sendL, CheckStatusWrapper* status_vector); ISC_STATUS receive_msg(P_DATA*, PACKET*); ISC_STATUS seek_blob(P_SEEK*, PACKET*); ISC_STATUS send_msg(P_DATA*, PACKET*); ISC_STATUS send_response(PACKET*, OBJCT, ULONG, const ISC_STATUS*, bool); - ISC_STATUS send_response(PACKET* p, OBJCT obj, ULONG length, const Firebird::IStatus* status, bool defer_flag); - ISC_STATUS service_attach(const char*, Firebird::ClumpletWriter*, PACKET*); + ISC_STATUS send_response(PACKET* p, OBJCT obj, ULONG length, const IStatus* status, bool defer_flag); + ISC_STATUS service_attach(const char*, ClumpletWriter*, PACKET*); ISC_STATUS service_end(P_RLSE*, PACKET*); void service_start(P_INFO*, PACKET*); ISC_STATUS set_cursor(P_SQLCUR*, PACKET*); @@ -1732,17 +1732,17 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted void batch_bpb(P_BATCH_SETBPB*, PACKET*); void replicate(P_REPLICATE*, PACKET*); - Firebird::string getRemoteId() const; + string getRemoteId() const; void auxAcceptError(PACKET* packet); // Working with 'key/plugin' pairs and associated plugin specific data void addServerKeys(const CSTRING* str); - void addSpecificData(const Firebird::PathName& type, const Firebird::PathName& plugin, + void addSpecificData(const PathName& type, const PathName& plugin, unsigned length, const void* data); - const Firebird::UCharBuffer* findSpecificData(const Firebird::PathName& type, const Firebird::PathName& plugin); + const UCharBuffer* findSpecificData(const PathName& type, const PathName& plugin); bool tryNewKey(InternalCryptKey* cryptKey); - void checkResponse(Firebird::IStatus* warning, const PACKET* packet, bool checkKeys = false); + void checkResponse(IStatus* warning, const PACKET* packet, bool checkKeys = false); private: bool tryKeyType(const KnownServerKey& srvKey, InternalCryptKey* cryptKey); @@ -1805,7 +1805,7 @@ class RemotePortGuard private: WaitThread wThr; - Firebird::RefMutexGuard guard; + RefMutexGuard guard; }; @@ -1813,7 +1813,7 @@ class RemotePortGuard typedef void (*t_rmtque_fn)(rem_port*, rmtque*, USHORT); -struct rmtque : public Firebird::GlobalStorage +struct rmtque : public GlobalStorage { rmtque* rmtque_next; // Next entry in queue void* rmtque_parm; // What request has response in queue @@ -1857,10 +1857,13 @@ class PortsCleanup virtual void delay(); private: - typedef Firebird::SortedArray PortsArray; + typedef SortedArray PortsArray; PortsArray* m_ports; - Firebird::Mutex m_mutex; + Mutex m_mutex; bool closing; }; + +} // namespace Firebird::Remote + #endif // REMOTE_REMOTE_H diff --git a/src/remote/remote_def.h b/src/remote/remote_def.h index 9fedf4325c1..1ec78657f74 100644 --- a/src/remote/remote_def.h +++ b/src/remote/remote_def.h @@ -42,6 +42,10 @@ #include "../remote/protocol.h" +namespace Firebird::Remote +{ + + #if defined(__sun) # ifdef sparc constexpr P_ARCH ARCHITECTURE = arch_sun4; @@ -89,4 +93,7 @@ inline constexpr USHORT SRVR_high_priority = 64; // fork off server at high pri inline constexpr USHORT SRVR_thread_per_port = 128; // bind thread to a port inline constexpr USHORT SRVR_no_icon = 256; // tell the server not to show the icon + +} // namespace Firebird::Remote + #endif /* REMOTE_REMOTE_DEF_H */ diff --git a/src/remote/server/ReplServer.cpp b/src/remote/server/ReplServer.cpp index fd7d7a46b95..5747d6a2069 100644 --- a/src/remote/server/ReplServer.cpp +++ b/src/remote/server/ReplServer.cpp @@ -23,7 +23,7 @@ #include "firebird.h" #include "firebird/Message.h" #include "../common/common.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "ibase.h" #include "../jrd/license.h" #include "../jrd/ods.h" @@ -65,8 +65,11 @@ //#define NO_DATABASE //#define PRESERVE_LOG -using namespace Firebird; -using namespace Replication; +namespace Firebird::Remote +{ + +using namespace Jrd::Replication; + namespace { @@ -339,7 +342,7 @@ namespace class Target : public GlobalStorage { public: - explicit Target(const Replication::Config* config) + explicit Target(const Jrd::Replication::Config* config) : m_config(config), m_attachment(nullptr), m_replicator(nullptr), m_sequence(0), m_connected(false), @@ -352,7 +355,7 @@ namespace shutdown(); } - const Replication::Config* getConfig() const + const Jrd::Replication::Config* getConfig() const { return m_config; } @@ -503,7 +506,7 @@ namespace } private: - AutoPtr m_config; + AutoPtr m_config; IAttachment* m_attachment; IReplicator* m_replicator; FB_UINT64 m_sequence; @@ -1045,7 +1048,7 @@ namespace } -bool REPL_server(CheckStatusWrapper* status, const Replication::Config::ReplicaList& replicas, bool wait) +bool REPL_server(CheckStatusWrapper* status, const Jrd::Replication::Config::ReplicaList& replicas, bool wait) { try { @@ -1075,3 +1078,6 @@ bool REPL_server(CheckStatusWrapper* status, const Replication::Config::ReplicaL return true; } + + +} // namespace Firebird::Remote diff --git a/src/remote/server/ReplServer.h b/src/remote/server/ReplServer.h index e99e3288c96..21d80672022 100644 --- a/src/remote/server/ReplServer.h +++ b/src/remote/server/ReplServer.h @@ -23,6 +23,9 @@ #ifndef UTIL_REPL_SERVER_H #define UTIL_REPL_SERVER_H -bool REPL_server(Firebird::CheckStatusWrapper*, const Replication::Config::ReplicaList&, bool); +namespace Firebird::Remote +{ + bool REPL_server(CheckStatusWrapper*, const Jrd::Replication::Config::ReplicaList&, bool); +} // namespace Firebird::Remote #endif // UTIL_REPL_SERVER_H diff --git a/src/remote/server/os/posix/inet_server.cpp b/src/remote/server/os/posix/inet_server.cpp index cb51aa23e3a..2803ffdd378 100644 --- a/src/remote/server/os/posix/inet_server.cpp +++ b/src/remote/server/os/posix/inet_server.cpp @@ -110,6 +110,9 @@ #include #endif +namespace Firebird::Remote +{ + const char* TEMP_DIR = "/tmp"; @@ -125,9 +128,6 @@ static int INET_SERVER_start = 0; static void raiseLimit(int resource); #endif -using namespace Firebird; - - static void logSecurityDatabaseError(const char* path, ISC_STATUS* status) { // If I/O error happened then rather likely we just miss standard security DB @@ -163,9 +163,11 @@ bool check_fd(int fd) return fcntl(fd, F_GETFL) != -1 || errno != EBADF; } -extern "C" { -int CLIB_ROUTINE main( int argc, char** argv) +} // namespace Firebird::Remote + + +int CLIB_ROUTINE main(int argc, char** argv) { /************************************** * @@ -177,6 +179,9 @@ int CLIB_ROUTINE main( int argc, char** argv) * Run the server with apollo mailboxes. * **************************************/ + using namespace Firebird; + using namespace Firebird::Remote; + try { RemPortPtr port; @@ -431,8 +436,8 @@ int CLIB_ROUTINE main( int argc, char** argv) } } - Replication::Config::ReplicaList replicas; - Replication::Config::enumerate(replicas); + Jrd::Replication::Config::ReplicaList replicas; + Jrd::Replication::Config::enumerate(replicas); if (super || standaloneClassic) { @@ -604,7 +609,9 @@ int CLIB_ROUTINE main( int argc, char** argv) } } -} // extern "C" + +namespace Firebird::Remote +{ static void set_signal(int signal_number, void (*handler) (int)) @@ -688,3 +695,6 @@ static void raiseLimit(int resource) } } #endif // FB_RAISE_LIMITS + + +} // namespace Firebird::Remote diff --git a/src/remote/server/os/win32/cntl.cpp b/src/remote/server/os/win32/cntl.cpp index 71537ddcf8f..106ebe4b1d3 100644 --- a/src/remote/server/os/win32/cntl.cpp +++ b/src/remote/server/os/win32/cntl.cpp @@ -36,7 +36,9 @@ #include -using namespace Firebird; +namespace Firebird::Remote +{ + constexpr unsigned int SHUTDOWN_TIMEOUT = 10 * 1000; // 10 seconds @@ -236,3 +238,6 @@ static USHORT report_status(DWORD state, DWORD exit_code, DWORD checkpoint, DWOR return ret; } + + +} // namespace Firebird::Remote diff --git a/src/remote/server/os/win32/cntl_proto.h b/src/remote/server/os/win32/cntl_proto.h index f5245a57f7c..6635caa87ea 100644 --- a/src/remote/server/os/win32/cntl_proto.h +++ b/src/remote/server/os/win32/cntl_proto.h @@ -24,9 +24,12 @@ #ifndef REMOTE_CNTL_PROTO_H #define REMOTE_CNTL_PROTO_H -void CNTL_init(ThreadEntryPoint*, const TEXT*); -void WINAPI CNTL_main_thread(DWORD, char*[]); -void CNTL_shutdown_service(const TEXT*); +namespace Firebird::Remote +{ + void CNTL_init(ThreadEntryPoint*, const TEXT*); + void WINAPI CNTL_main_thread(DWORD, char*[]); + void CNTL_shutdown_service(const TEXT*); +} #endif // REMOTE_CNTL_PROTO_H diff --git a/src/remote/server/os/win32/property.cpp b/src/remote/server/os/win32/property.cpp index 4930975dc45..94061b1bb16 100644 --- a/src/remote/server/os/win32/property.cpp +++ b/src/remote/server/os/win32/property.cpp @@ -54,6 +54,7 @@ #include // snprintf() using namespace Firebird; +using namespace Firebird::Remote; static HINSTANCE hInstance = NULL; // Handle to the current app. instance diff --git a/src/remote/server/os/win32/srvr_w32.cpp b/src/remote/server/os/win32/srvr_w32.cpp index c1658460cba..868fc12a897 100644 --- a/src/remote/server/os/win32/srvr_w32.cpp +++ b/src/remote/server/os/win32/srvr_w32.cpp @@ -116,6 +116,9 @@ #include "../auth/SecurityDatabase/LegacyServer.h" #include "../auth/SecureRemotePassword/server/SrpServer.h" +namespace Firebird::Remote +{ + static THREAD_ENTRY_DECLARE inet_connect_wait_thread(THREAD_ENTRY_PARAM); static THREAD_ENTRY_DECLARE xnet_connect_wait_thread(THREAD_ENTRY_PARAM); @@ -132,8 +135,6 @@ static TEXT instance[MAXPATHLEN]; static USHORT server_flag = 0; static bool server_shutdown = false; -using namespace Firebird; - class ThreadCounter { public: @@ -168,6 +169,9 @@ AtomicCounter ThreadCounter::m_count; Semaphore ThreadCounter::m_semaphore; +} // namespace Firebird::Remote + + int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs, int nWndMode) { /************************************** @@ -181,6 +185,9 @@ int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs, * pipes and/or TCP/IP sockets. * **************************************/ + using namespace Firebird; + using namespace Firebird::Remote; + hInst = hThisInst; // We want server to crash without waiting for feedback from the user @@ -361,6 +368,10 @@ int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs, } +namespace Firebird::Remote +{ + + THREAD_ENTRY_DECLARE process_connection_thread(THREAD_ENTRY_PARAM arg) { /************************************** @@ -531,8 +542,8 @@ static THREAD_ENTRY_DECLARE start_connections_thread(THREAD_ENTRY_PARAM) } } - Replication::Config::ReplicaList replicas; - Replication::Config::enumerate(replicas); + Jrd::Replication::Config::ReplicaList replicas; + Jrd::Replication::Config::enumerate(replicas); if (replicas.hasData()) { @@ -741,3 +752,6 @@ static int wait_threads(const int, const int, void*) return FB_SUCCESS; } + + +} // namespace Firebird::Remote diff --git a/src/remote/server/os/win32/window.cpp b/src/remote/server/os/win32/window.cpp index 02c35de5177..80cd8065615 100644 --- a/src/remote/server/os/win32/window.cpp +++ b/src/remote/server/os/win32/window.cpp @@ -45,6 +45,8 @@ #include "../common/config/config.h" +using namespace Firebird::Remote; + static HWND hPSDlg = NULL; static HINSTANCE hInstance = NULL; diff --git a/src/remote/server/serve_proto.h b/src/remote/server/serve_proto.h index 00605fb554e..13f77226fc1 100644 --- a/src/remote/server/serve_proto.h +++ b/src/remote/server/serve_proto.h @@ -28,8 +28,11 @@ #define rem_port void #endif -void SRVR_main(rem_port*, USHORT); -void SRVR_multi_thread(rem_port*, USHORT); -void SRVR_enum_attachments(ULONG& att_cnt, ULONG& dbs_cnt, ULONG& svc_cnt); +namespace Firebird::Remote +{ + void SRVR_main(rem_port*, USHORT); + void SRVR_multi_thread(rem_port*, USHORT); + void SRVR_enum_attachments(ULONG& att_cnt, ULONG& dbs_cnt, ULONG& svc_cnt); +} // namespace Firebird::Remote #endif // REMOTE_SERVE_PROTO_H diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index c9143b39c63..faa53a13cd5 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -52,7 +52,7 @@ #include #endif #include "../common/isc_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "firebird/impl/inf_pub.h" #include "../common/classes/auto.h" #include "../common/classes/init.h" @@ -76,7 +76,8 @@ #include "../common/os/os_utils.h" #include "../common/security.h" -using namespace Firebird; +namespace Firebird::Remote +{ struct server_req_t : public GlobalStorage @@ -169,14 +170,14 @@ class NetworkCallback : public VersionedIfacesetErrors2(FB_NELEM(err), err); @@ -275,7 +276,7 @@ class CryptKeyCallback : public VersionedIfacecstr_length > 0; } + + +} // namespace Firebird::Remote diff --git a/src/utilities/analyse.cpp b/src/utilities/analyse.cpp index 3d9b120bbeb..ada00f35edf 100644 --- a/src/utilities/analyse.cpp +++ b/src/utilities/analyse.cpp @@ -55,7 +55,7 @@ static time_t times(struct tms*); #endif -using namespace Ods; +using namespace Firebird::Jrd::Ods; static void analyse(int, const SCHAR*, const pag*, int); static SLONG get_long(); @@ -110,7 +110,7 @@ void main( int argc, char **argv) } SLONG reads = 0, writes = 0; - trace = os_utils::fopen("trace.log", "r"); + trace = Firebird::os_utils::fopen("trace.log", "r"); page_size = 1024; SLONG sequence = 0; @@ -331,7 +331,7 @@ static void db_open( const char* file_name, USHORT file_length) * **************************************/ - if ((file = os_utils::open(file_name, 2)) == -1) + if ((file = Firebird::os_utils::open(file_name, 2)) == -1) db_error(errno); } @@ -354,7 +354,7 @@ static PAG db_read( SLONG page_number) if (!global_buffer) global_buffer = (pag*) malloc(page_size); - if (os_utils::lseek (file, offset, 0) == -1) + if (Firebird::os_utils::lseek (file, offset, 0) == -1) db_error(errno); if (read(file, global_buffer, page_size) == -1) diff --git a/src/utilities/fbsvcmgr/fbsvcmgr.cpp b/src/utilities/fbsvcmgr/fbsvcmgr.cpp index 00d17f99106..035d7b3be32 100644 --- a/src/utilities/fbsvcmgr/fbsvcmgr.cpp +++ b/src/utilities/fbsvcmgr/fbsvcmgr.cpp @@ -71,7 +71,7 @@ struct SvcSwitches namespace { constexpr int SVCMGR_FACILITY = FB_IMPL_MSG_FACILITY_FBSVCMGR; - using MsgFormat::SafeArg; + using Firebird::MsgFormat::SafeArg; } string getMessage(int n) @@ -149,13 +149,13 @@ bool putFileArgument(char**& av, ClumpletWriter& spb, unsigned int tag) case fb_utils::FETCH_PASS_OK: break; case fb_utils::FETCH_PASS_FILE_OPEN_ERROR: - (Arg::Gds(isc_fbsvcmgr_fp_open) << *av << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_open) << *av << Firebird::Arg::OsError()).raise(); break; case fb_utils::FETCH_PASS_FILE_READ_ERROR: - (Arg::Gds(isc_fbsvcmgr_fp_read) << *av << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_read) << *av << Firebird::Arg::OsError()).raise(); break; case fb_utils::FETCH_PASS_FILE_EMPTY: - (Arg::Gds(isc_fbsvcmgr_fp_empty) << *av).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_empty) << *av).raise(); break; } @@ -170,9 +170,9 @@ bool putFileFromArgument(char**& av, ClumpletWriter& spb, unsigned int tag) if (! *av) return false; - FILE* const file = os_utils::fopen(*av, "rb"); + FILE* const file = Firebird::os_utils::fopen(*av, "rb"); if (!file) { - (Arg::Gds(isc_fbsvcmgr_fp_open) << *av << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_open) << *av << Firebird::Arg::OsError()).raise(); } fseek(file, 0, SEEK_END); @@ -180,7 +180,7 @@ bool putFileFromArgument(char**& av, ClumpletWriter& spb, unsigned int tag) if (len == 0) { fclose(file); - (Arg::Gds(isc_fbsvcmgr_fp_empty) << *av).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_empty) << *av).raise(); } HalfStaticArray buff(*getDefaultMemoryPool(), len); @@ -190,7 +190,7 @@ bool putFileFromArgument(char**& av, ClumpletWriter& spb, unsigned int tag) if (fread(p, 1, len, file) != size_t(len)) { fclose(file); - (Arg::Gds(isc_fbsvcmgr_fp_read) << *av << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_fp_read) << *av << Firebird::Arg::OsError()).raise(); } fclose(file); @@ -218,7 +218,7 @@ bool putSpecTag(char**& av, ClumpletWriter& spb, unsigned int tag, } } - status_exception::raise(Arg::Gds(errorCode)); + status_exception::raise(Firebird::Arg::Gds(errorCode)); return false; // compiler warning silencer } @@ -294,7 +294,7 @@ bool putIntArgument(char**& av, ClumpletWriter& spb, unsigned int tag) SLONG n; if (sscanf(*av++, "%" SLONGFORMAT, &n) != 1) - (Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-2]).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-2]).raise(); spb.insertInt(tag, n); @@ -310,7 +310,7 @@ bool putBigIntArgument(char**& av, ClumpletWriter& spb, unsigned int tag) SINT64 n; if (sscanf(*av++, "%" SQUADFORMAT, &n) != 1) - (Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-2]).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-2]).raise(); spb.insertBigInt(tag, n); @@ -365,7 +365,7 @@ bool populateSpbFromSwitches(char**& av, ClumpletWriter& spb, } return true; } - (Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-1]).raise(); + (Firebird::Arg::Gds(isc_fbsvcmgr_bad_arg) << av[-1]).raise(); } } @@ -872,8 +872,8 @@ bool printInfo(const char* p, size_t pSize, UserPrint& up, ULONG& stdinRq) printInt(p, 17); break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_info_err) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_info_err) << + Firebird::Arg::Num(static_cast(p[-1]))); } } p++; @@ -908,8 +908,8 @@ bool printInfo(const char* p, size_t pSize, UserPrint& up, ULONG& stdinRq) printMessage(41); break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_limbo_state) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_limbo_state) << + Firebird::Arg::Num(static_cast(p[-1]))); } break; case isc_spb_tra_remote_site: @@ -931,8 +931,8 @@ bool printInfo(const char* p, size_t pSize, UserPrint& up, ULONG& stdinRq) printMessage(46); break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_info_limbo) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_info_limbo) << + Firebird::Arg::Num(static_cast(p[-1]))); } break; case isc_spb_multi_tra_id: @@ -954,8 +954,8 @@ bool printInfo(const char* p, size_t pSize, UserPrint& up, ULONG& stdinRq) printInt64(p, 37); break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_info_limbo) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_info_limbo) << + Firebird::Arg::Num(static_cast(p[-1]))); } } if (*p == isc_info_flag_end) @@ -1029,8 +1029,8 @@ bool printInfo(const char* p, size_t pSize, UserPrint& up, ULONG& stdinRq) break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_query_err) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_query_err) << + Firebird::Arg::Num(static_cast(p[-1]))); } } @@ -1224,7 +1224,7 @@ int main(int ac, char** av) return 0; } - os_utils::CtrlCHandler ctrlCHandler; + Firebird::os_utils::CtrlCHandler ctrlCHandler; fb_utils::FbShutdown appShutdown(fb_shutrsn_app_stopped); ISC_STATUS_ARRAY status; @@ -1265,7 +1265,7 @@ int main(int ac, char** av) if (*av) { - status_exception::raise(Arg::Gds(isc_fbsvcmgr_switch_unknown) << Arg::Str(*av)); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_switch_unknown) << Firebird::Arg::Str(*av)); } isc_svc_handle svc_handle = 0; diff --git a/src/utilities/fbtracemgr/traceMgrMain.cpp b/src/utilities/fbtracemgr/traceMgrMain.cpp index 48ff9893557..b443817bf78 100644 --- a/src/utilities/fbtracemgr/traceMgrMain.cpp +++ b/src/utilities/fbtracemgr/traceMgrMain.cpp @@ -47,7 +47,7 @@ namespace Firebird { -class TraceSvcUtil final : public TraceSvcIntf +class TraceSvcUtil final : public Jrd::TraceSvcIntf { public: TraceSvcUtil() noexcept {}; @@ -61,7 +61,7 @@ class TraceSvcUtil final : public TraceSvcIntf void setActive(ULONG id, bool active) override; void listSessions() override; - os_utils::CtrlCHandler ctrlCHandler; + Firebird::os_utils::CtrlCHandler ctrlCHandler; private: void runService(size_t spbSize, const UCHAR* spb); @@ -130,19 +130,19 @@ void TraceSvcUtil::startSession(TraceSession& session, bool /*interactive*/) try { const char* fileName = session.ses_config.c_str(); - file = os_utils::fopen(fileName, "rb"); + file = Firebird::os_utils::fopen(fileName, "rb"); if (!file) { - (Arg::Gds(isc_io_error) << Arg::Str("fopen") << Arg::Str(fileName) << - Arg::Gds(isc_io_open_err) << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_io_error) << Firebird::Arg::Str("fopen") << Firebird::Arg::Str(fileName) << + Firebird::Arg::Gds(isc_io_open_err) << Firebird::Arg::OsError()).raise(); } fseek(file, 0, SEEK_END); len = ftell(file); if (len == 0) { - (Arg::Gds(isc_io_error) << Arg::Str("fread") << Arg::Str(fileName) << - Arg::Gds(isc_io_read_err) << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_io_error) << Firebird::Arg::Str("fread") << Firebird::Arg::Str(fileName) << + Firebird::Arg::Gds(isc_io_read_err) << Firebird::Arg::OsError()).raise(); } fseek(file, 0, SEEK_SET); @@ -150,8 +150,8 @@ void TraceSvcUtil::startSession(TraceSession& session, bool /*interactive*/) if (fread(p, 1, len, file) != size_t(len)) { - (Arg::Gds(isc_io_error) << Arg::Str("fread") << Arg::Str(fileName) << - Arg::Gds(isc_io_read_err) << Arg::OsError()).raise(); + (Firebird::Arg::Gds(isc_io_error) << Firebird::Arg::Str("fread") << Firebird::Arg::Str(fileName) << + Firebird::Arg::Gds(isc_io_read_err) << Firebird::Arg::OsError()).raise(); } fclose(file); } @@ -285,8 +285,8 @@ void TraceSvcUtil::runService(size_t spbSize, const UCHAR* spb) break; default: - status_exception::raise(Arg::Gds(isc_fbsvcmgr_query_err) << - Arg::Num(static_cast(p[-1]))); + status_exception::raise(Firebird::Arg::Gds(isc_fbsvcmgr_query_err) << + Firebird::Arg::Num(static_cast(p[-1]))); } } } while (!(ctrlCHandler.getTerminated() || noData)); diff --git a/src/utilities/gsec/gsec.cpp b/src/utilities/gsec/gsec.cpp index 8e1b9c3353b..90c677f10fa 100644 --- a/src/utilities/gsec/gsec.cpp +++ b/src/utilities/gsec/gsec.cpp @@ -35,7 +35,7 @@ #include "../utilities/gsec/gsec.h" #include "../utilities/gsec/gsec_proto.h" #include "../jrd/license.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/security.h" #include "../common/classes/Switches.h" #include "../utilities/gsec/gsecswi.h" @@ -46,10 +46,6 @@ #include "../common/classes/MsgPrint.h" #include "../common/StatusHolder.h" -using MsgFormat::SafeArg; -using namespace Auth; - - #ifdef HAVE_UNISTD_H #include #endif @@ -58,6 +54,13 @@ using namespace Auth; #include #endif +namespace Firebird::Gsec +{ + +using namespace Auth; +using MsgFormat::SafeArg; + + constexpr int MAXSTUFF = 1000; // longest interactive command line static void util_output(bool error, const SCHAR*, ...); @@ -1768,3 +1771,6 @@ static void get_security_error(ISC_STATUS* status, int gsec_err) return; } } + + +} // namespace Firebird::Gsec diff --git a/src/utilities/gsec/gsec.h b/src/utilities/gsec/gsec.h index 8897f8392ec..4913be09f5f 100644 --- a/src/utilities/gsec/gsec.h +++ b/src/utilities/gsec/gsec.h @@ -26,13 +26,16 @@ #include "firebird/Interface.h" #include "../common/ThreadData.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "firebird/impl/msg_helper.h" -inline constexpr USHORT GSEC_MSG_FAC = FB_IMPL_MSG_FACILITY_GSEC; -inline constexpr int MSG_LENGTH = 128; +namespace Firebird::Gsec +{ + inline constexpr USHORT GSEC_MSG_FAC = FB_IMPL_MSG_FACILITY_GSEC; + inline constexpr int MSG_LENGTH = 128; +} // namespace Firebird::Gsec -namespace Auth +namespace Firebird::Auth { class UserData; @@ -53,13 +56,18 @@ inline constexpr unsigned int HELP_OPER = 102; inline constexpr unsigned int ADDMOD_OPER = 103; inline constexpr unsigned int OLD_DIS_OPER = 104; -} // namespace Auth +} // namespace Firebird::Auth namespace Firebird { class UtilSvc; } + +namespace Firebird::Gsec +{ + + class tsec : public Firebird::ThreadData { public: @@ -72,7 +80,7 @@ class tsec : public Firebird::ThreadData } Firebird::UtilSvc* utilSvc; - Auth::UserData* tsec_user_data; + Firebird::Auth::UserData* tsec_user_data; int tsec_exit_code; bool tsec_throw; bool tsec_interactive; @@ -200,5 +208,7 @@ inline constexpr USHORT GsecMsg102 = 102; // -adm(in) {yes|no} inline constexpr USHORT GsecMsg103 = 103; // invalid parameter for -ADMIN, only YES or NO is accepted inline constexpr USHORT GsecMsg104 = 104; // not enough privileges to complete operation -#endif // UTILITIES_GSEC_H +} // namespace Firebird::Gsec + +#endif // UTILITIES_GSEC_H diff --git a/src/utilities/gsec/gsec_proto.h b/src/utilities/gsec/gsec_proto.h index 64e5b14f56d..699811d9af2 100644 --- a/src/utilities/gsec/gsec_proto.h +++ b/src/utilities/gsec/gsec_proto.h @@ -4,6 +4,10 @@ #include "../common/ThreadData.h" #include "../common/UtilSvc.h" +namespace Firebird::Gsec +{ + + // Output reporting utilities void GSEC_print_status(const ISC_STATUS*); void GSEC_error_redirect(const ISC_STATUS*, USHORT); @@ -17,4 +21,7 @@ void GSEC_diag(USHORT); int gsec(Firebird::UtilSvc*); int GSEC_main(Firebird::UtilSvc*); + +} // namespace Firebird::Gsec + #endif // GSEC_PROTO_H diff --git a/src/utilities/gsec/gsecswi.h b/src/utilities/gsec/gsecswi.h index 3f94ee8be75..05b134562fd 100644 --- a/src/utilities/gsec/gsecswi.h +++ b/src/utilities/gsec/gsecswi.h @@ -24,7 +24,11 @@ #ifndef GSEC_GSECSWI_H #define GSEC_GSECSWI_H -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Gsec +{ + /* Switch handling constants. Note that the first IN_SW_DATA_ITEMS switch constants refer to data items. The remaining switch constants @@ -103,4 +107,8 @@ static inline constexpr struct Switches::in_sw_tab_t gsec_action_in_sw_table [] {IN_SW_GSEC_DIS_ADM, isc_action_svc_display_user_adm,"DISPLAY", 0, 0, 0, false, false, 0, 2, NULL}, // display user(s) with admin {IN_SW_GSEC_0, 0, NULL, 0, 0, 0, false, false, 0, 0, NULL} // End of List }; + + +} // namespace Firebird::Gsec + #endif // GSEC_GSECSWI_H diff --git a/src/utilities/gsec/main/gsecMain.cpp b/src/utilities/gsec/main/gsecMain.cpp index b661603cd65..56d1987737b 100644 --- a/src/utilities/gsec/main/gsecMain.cpp +++ b/src/utilities/gsec/main/gsecMain.cpp @@ -53,6 +53,8 @@ int CLIB_ROUTINE main(int argc, char* argv[]) * Invoke real gsec main function * **************************************/ + using namespace Firebird; + #ifdef HAVE_LOCALE_H // Pick up the system locale to allow SYSTEM<->UTF8 conversions setlocale(LC_CTYPE, ""); @@ -63,12 +65,12 @@ int CLIB_ROUTINE main(int argc, char* argv[]) try { - Firebird::AutoPtr uSvc(Firebird::UtilSvc::createStandalone(argc, argv)); - exitCode = gsec(uSvc); + AutoPtr uSvc(UtilSvc::createStandalone(argc, argv)); + exitCode = Gsec::gsec(uSvc); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { - Firebird::StaticStatusVector st; + StaticStatusVector st; ex.stuffException(st); isc_print_status(st.begin()); } diff --git a/src/utilities/gstat/dba.epp b/src/utilities/gstat/dba.epp index 6eae03c9f54..7ef3c7d6d60 100644 --- a/src/utilities/gstat/dba.epp +++ b/src/utilities/gstat/dba.epp @@ -50,7 +50,7 @@ #include "../common/isc_f_proto.h" #include "../common/utils_proto.h" #include "../common/classes/ClumpletWriter.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/ods_proto.h" #include "../common/classes/MsgPrint.h" #include "../common/classes/QualifiedMetaString.h" @@ -70,7 +70,7 @@ # endif #endif -using MsgFormat::SafeArg; +using Firebird::MsgFormat::SafeArg; #ifdef HAVE_UNISTD_H @@ -83,7 +83,7 @@ using MsgFormat::SafeArg; using namespace Firebird; using namespace Jrd; -using namespace Ods; +using namespace Firebird::Jrd::Ods; // For Netware the follow DB handle and isc_status is #defined to be a @@ -649,7 +649,7 @@ int gstat(Firebird::UtilSvc* uSvc) tddba->page_number = -1; const header_page* header = (const header_page*) db_read(HEADER_PAGE); - if (!Ods::isSupported(header)) + if (!Jrd::Ods::isSupported(header)) { const int oversion = (header->hdr_ods_version & ~ODS_FIREBIRD_FLAG); dba_error(3, SafeArg() << ODS_VERSION << oversion); @@ -668,8 +668,8 @@ int gstat(Firebird::UtilSvc* uSvc) fl_print_complete = true; tddba->page_size = header->hdr_page_size; - tddba->dp_per_pp = Ods::dataPagesPerPP(tddba->page_size); - tddba->max_records = Ods::maxRecsPerDP(tddba->page_size); + tddba->dp_per_pp = Jrd::Ods::dataPagesPerPP(tddba->page_size); + tddba->max_records = Jrd::Ods::maxRecsPerDP(tddba->page_size); { // scope char* buff = alloc(tddba->page_size * 3 + DIRECT_IO_BLOCK_SIZE); buff = FB_ALIGN(buff, DIRECT_IO_BLOCK_SIZE); @@ -1264,8 +1264,8 @@ static ULONG lastUsedPage(ULONG pageSize) { constexpr ULONG pipFirst = FIRST_PIP_PAGE; ULONG pipLast = pipFirst; - const ULONG pagesPerPIP = Ods::pagesPerPIP(pageSize); - const ULONG bytesBitPIP = Ods::bytesBitPIP(pageSize); + const ULONG pagesPerPIP = Jrd::Ods::pagesPerPIP(pageSize); + const ULONG bytesBitPIP = Jrd::Ods::bytesBitPIP(pageSize); page_inv_page* pip; while (true) @@ -1811,7 +1811,7 @@ static USHORT get_format_length(ISC_STATUS* status_vector, isc_db_handle databas buffer.resize(return_length); const USHORT count = buffer[0] | (buffer[1] << 8); - const Ods::Descriptor* const desc = (Ods::Descriptor*) &buffer[2] + count - 1; + const Jrd::Ods::Descriptor* const desc = (Jrd::Ods::Descriptor*) &buffer[2] + count - 1; return desc->dsc_offset + desc->dsc_length; } @@ -1973,7 +1973,7 @@ static const pag* db_read( ULONG page_number, bool ok_enc) // msg 4: Unexpected end of database file. } - if (tddba->global_buffer->pag_flags & Ods::crypted_page && !ok_enc) + if (tddba->global_buffer->pag_flags & Jrd::Ods::crypted_page && !ok_enc) { dba_error(55); } @@ -2047,7 +2047,7 @@ static dba_fil* db_open(const char* file_name, USHORT file_length) strcpy(file->fil_string, file_name); file->fil_length = file_length; - if ((file->fil_desc = os_utils::open(file_name, O_RDONLY)) == -1) + if ((file->fil_desc = Firebird::os_utils::open(file_name, O_RDONLY)) == -1) { tddba->uSvc->getStatusAccessor().setServiceStatus(GSTAT_MSG_FAC, 29, SafeArg() << file_name); // msg 29: Can't open database file %s @@ -2079,7 +2079,7 @@ static const pag* db_read( ULONG page_number, bool ok_enc) tddba->page_number = page_number; const FB_UINT64 offset = ((FB_UINT64) page_number) * ((FB_UINT64) tddba->page_size); - if (os_utils::lseek (tddba->file->fil_desc, offset, 0) == -1) + if (Firebird::os_utils::lseek (tddba->file->fil_desc, offset, 0) == -1) { tddba->uSvc->getStatusAccessor().setServiceStatus(GSTAT_MSG_FAC, 30, SafeArg()); // msg 30: Can't read a database page @@ -2109,7 +2109,7 @@ static const pag* db_read( ULONG page_number, bool ok_enc) length -= l; } - if (tddba->global_buffer->pag_flags & Ods::crypted_page && !ok_enc) + if (tddba->global_buffer->pag_flags & Jrd::Ods::crypted_page && !ok_enc) { dba_error(55); } diff --git a/src/utilities/gstat/dbaswi.h b/src/utilities/gstat/dbaswi.h index 9cdfde3d9b8..56a56e8cff5 100644 --- a/src/utilities/gstat/dbaswi.h +++ b/src/utilities/gstat/dbaswi.h @@ -25,7 +25,7 @@ #define DBA_DBASWI_H #include "../common/classes/Switches.h" -#include "../jrd/constants.h" +#include "../common/constants.h" // Switch handling constants. Note that the first IN_SW_DATA_ITEMS // switch constants refer to data items. The remaining switch constants @@ -53,7 +53,7 @@ inline constexpr int IN_SW_DBA_HELP = 16; // show help inline constexpr int IN_SW_DBA_ROLE = 17; // SQL role inline constexpr int IN_SW_DBA_SCHEMA = 18; // analyze specific schemas -inline constexpr static struct Switches::in_sw_tab_t dba_in_sw_table[] = +inline constexpr static struct Firebird::Switches::in_sw_tab_t dba_in_sw_table[] = { {IN_SW_DBA_DATAIDX, 0, "ALL", 0,0,0, false, false, 22, 1, NULL}, // msg 22: -a analyze data and index pages {IN_SW_DBA_DATA, isc_spb_sts_data_pages, "DATA", 0,0,0, false, true, 23, 1, NULL}, // msg 23: -d analyze data pages diff --git a/src/utilities/gstat/ppg.cpp b/src/utilities/gstat/ppg.cpp index 1ca5dc96f22..d0459c3e34d 100644 --- a/src/utilities/gstat/ppg.cpp +++ b/src/utilities/gstat/ppg.cpp @@ -38,7 +38,7 @@ #include "../utilities/gstat/ppg_proto.h" // gstat directly reads database files, therefore -using namespace Ods; +using namespace Firebird::Jrd::Ods; using Firebird::Guid; void PPG_print_header(const header_page* header, bool nocreation, Firebird::UtilSvc* uSvc) @@ -185,10 +185,10 @@ void PPG_print_header(const header_page* header, bool nocreation, Firebird::Util switch (nbakMode) { - case Ods::hdr_nbak_stalled: + case hdr_nbak_stalled: uSvc->printf(false, "backup lock"); break; - case Ods::hdr_nbak_merge: + case hdr_nbak_merge: uSvc->printf(false, "backup merge"); break; default: @@ -203,10 +203,10 @@ void PPG_print_header(const header_page* header, bool nocreation, Firebird::Util switch (replMode) { - case Ods::hdr_replica_read_only: + case hdr_replica_read_only: uSvc->printf(false, "read-only replica"); break; - case Ods::hdr_replica_read_write: + case hdr_replica_read_write: uSvc->printf(false, "read-write replica"); break; default: diff --git a/src/utilities/gstat/ppg_proto.h b/src/utilities/gstat/ppg_proto.h index 6faaee1c0a2..c8121dd85af 100644 --- a/src/utilities/gstat/ppg_proto.h +++ b/src/utilities/gstat/ppg_proto.h @@ -26,7 +26,7 @@ #include "../common/UtilSvc.h" -void PPG_print_header(const Ods::header_page*, bool, Firebird::UtilSvc*); +void PPG_print_header(const Firebird::Jrd::Ods::header_page*, bool, Firebird::UtilSvc*); int gstat(Firebird::UtilSvc*); #endif // UTILITIES_PPG_PROTO_H diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index fbd96db318f..0ab7b8d4798 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -56,6 +56,9 @@ int errno = -1; #include "../utilities/guard/util_proto.h" #include "../common/classes/fb_string.h" +using namespace Firebird; + + const USHORT FOREVER = 1; const USHORT ONETIME = 2; const USHORT IGNORE = 3; @@ -212,7 +215,7 @@ int CLIB_ROUTINE main( int argc, char **argv) if (pidfilename) { - FILE *pf = os_utils::fopen(pidfilename, "w"); + FILE *pf = Firebird::os_utils::fopen(pidfilename, "w"); if (pf) { fprintf(pf, "%d", child_pid); diff --git a/src/utilities/guard/util.cpp b/src/utilities/guard/util.cpp index a083220ad3d..f3c2d0d9c08 100644 --- a/src/utilities/guard/util.cpp +++ b/src/utilities/guard/util.cpp @@ -62,6 +62,8 @@ #include "../common/utils_proto.h" #include "../common/os/os_utils.h" +using namespace Firebird; + pid_t UTIL_start_process(const char* process, char** argv, const char* prog_name) { @@ -250,7 +252,7 @@ int UTIL_ex_lock(const TEXT* file) Firebird::PathName expanded_filename = fb_utils::getPrefix(Firebird::IConfigManager::DIR_GUARD, file); // file fd for the opened and locked file - int fd_file = os_utils::open(expanded_filename.c_str(), O_RDWR | O_CREAT, 0660); + int fd_file = Firebird::os_utils::open(expanded_filename.c_str(), O_RDWR | O_CREAT, 0660); if (fd_file == -1) { fprintf(stderr, "Could not open %s for write\n", expanded_filename.c_str()); diff --git a/src/utilities/ibmgr/ibmgr.h b/src/utilities/ibmgr/ibmgr.h index 2dd2ea52dc5..db74e96c278 100644 --- a/src/utilities/ibmgr/ibmgr.h +++ b/src/utilities/ibmgr/ibmgr.h @@ -27,7 +27,7 @@ #define OUTFILE stderr -#include "../jrd/constants.h" +#include "../common/constants.h" static const char* const FIREBIRD_USER_NAME = "firebird"; static const char* const INTERBASE_USER_NAME = "interbase"; diff --git a/src/utilities/nbackup/main/nbkMain.cpp b/src/utilities/nbackup/main/nbkMain.cpp index 4cb2dcc4d63..adec50fb24b 100644 --- a/src/utilities/nbackup/main/nbkMain.cpp +++ b/src/utilities/nbackup/main/nbkMain.cpp @@ -52,6 +52,8 @@ int CLIB_ROUTINE main(int argc, char* argv[]) * Invoke real nbackup main function * **************************************/ + using namespace Firebird; + #ifdef HAVE_LOCALE_H // Pick up the system locale to allow SYSTEM<->UTF8 conversions setlocale(LC_CTYPE, ""); @@ -60,10 +62,10 @@ int CLIB_ROUTINE main(int argc, char* argv[]) try { - Firebird::AutoPtr uSvc(Firebird::UtilSvc::createStandalone(argc, argv)); - nbackup(uSvc); + AutoPtr uSvc(UtilSvc::createStandalone(argc, argv)); + Nbackup::nbackup(uSvc); } - catch (const Firebird::Exception&) + catch (const Exception&) { // should be already printed, no need to print once more here return FINI_ERROR; diff --git a/src/utilities/nbackup/nbackup.cpp b/src/utilities/nbackup/nbackup.cpp index 55e05e8bba3..dd378b61e52 100644 --- a/src/utilities/nbackup/nbackup.cpp +++ b/src/utilities/nbackup/nbackup.cpp @@ -82,11 +82,14 @@ #define O_LARGEFILE 0 #endif -using namespace Firebird; +namespace Firebird::Nbackup +{ + +using MsgFormat::SafeArg; + namespace { - using MsgFormat::SafeArg; constexpr USHORT nbackup_msg_fac = FB_IMPL_MSG_FACILITY_NBACKUP; void printMsg(USHORT number, const SafeArg& arg, bool newLine = true) @@ -836,17 +839,17 @@ void NBackup::fixup_database(bool repl_seq, bool set_readonly) HalfStaticArray header_buffer; auto size = HDR_SIZE; - auto header = reinterpret_cast(header_buffer.getBuffer(size)); + auto header = reinterpret_cast(header_buffer.getBuffer(size)); if (read_file(dbase, header, size) != size) status_exception::raise(Arg::Gds(isc_nbackup_err_eofdb) << dbname.c_str()); const auto page_size = header->hdr_page_size; - if (header->hdr_backup_mode != Ods::hdr_nbak_stalled) + if (header->hdr_backup_mode != Jrd::Ods::hdr_nbak_stalled) { status_exception::raise(Arg::Gds(isc_nbackup_fixup_wrongstate) << dbname.c_str() << - Arg::Num(Ods::hdr_nbak_stalled)); + Arg::Num(Jrd::Ods::hdr_nbak_stalled)); } if (!repl_seq) @@ -855,7 +858,7 @@ void NBackup::fixup_database(bool repl_seq, bool set_readonly) Guid::generate().copyTo(header->hdr_guid); size = page_size; - header = reinterpret_cast(header_buffer.getBuffer(size)); + header = reinterpret_cast(header_buffer.getBuffer(size)); seek_file(dbase, 0); @@ -867,9 +870,9 @@ void NBackup::fixup_database(bool repl_seq, bool set_readonly) auto p = header->hdr_data; const auto* end = (UCHAR*) header + header->hdr_page_size; - while (p < end && *p != Ods::HDR_end) + while (p < end && *p != Jrd::Ods::HDR_end) { - if (*p == Ods::HDR_repl_seq) + if (*p == Jrd::Ods::HDR_repl_seq) { // Reset the sequence counter constexpr FB_UINT64 sequence = 0; @@ -884,10 +887,10 @@ void NBackup::fixup_database(bool repl_seq, bool set_readonly) // Update the backup mode and flags, write the header page back - header->hdr_backup_mode = Ods::hdr_nbak_normal; + header->hdr_backup_mode = Jrd::Ods::hdr_nbak_normal; if (set_readonly) - header->hdr_flags |= Ods::hdr_read_only; + header->hdr_flags |= Jrd::Ods::hdr_read_only; seek_file(dbase, 0); write_file(dbase, header, size); @@ -1343,13 +1346,13 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName& const ULONG headerSize = MAX(RAW_HEADER_SIZE, ioBlockSize); Array header_buffer; - Ods::header_page* header = reinterpret_cast + Jrd::Ods::header_page* header = reinterpret_cast (header_buffer.getAlignedBuffer(headerSize, ioBlockSize)); if (read_file(dbase, header, headerSize) != headerSize) status_exception::raise(Arg::Gds(isc_nbackup_err_eofhdrdb) << dbname.c_str() << Arg::Num(1)); - if (!Ods::isSupported(header)) + if (!Jrd::Ods::isSupported(header)) { const USHORT ods_version = header->hdr_ods_version & ~ODS_FIREBIRD_FLAG; status_exception::raise(Arg::Gds(isc_wrong_ods) << Arg::Str(database.c_str()) << @@ -1359,11 +1362,11 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName& Arg::Num(ODS_CURRENT)); } - if (header->hdr_backup_mode != Ods::hdr_nbak_stalled) + if (header->hdr_backup_mode != Jrd::Ods::hdr_nbak_stalled) status_exception::raise(Arg::Gds(isc_nbackup_db_notlock) << Arg::Num(header->hdr_flags)); Array page_buffer; - Ods::pag* page_buff = reinterpret_cast + Jrd::Ods::pag* page_buff = reinterpret_cast (page_buffer.getAlignedBuffer(header->hdr_page_size, ioBlockSize)); ULONG db_size = db_size_pages; @@ -1375,11 +1378,11 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName& page_reads++; std::optional backup_guid; - auto p = reinterpret_cast(page_buff)->hdr_data; + auto p = reinterpret_cast(page_buff)->hdr_data; const auto* end = reinterpret_cast(page_buff) + header->hdr_page_size; - while (p < end && *p != Ods::HDR_end) + while (p < end && *p != Jrd::Ods::HDR_end) { - if (*p == Ods::HDR_backup_guid) + if (*p == Jrd::Ods::HDR_backup_guid) { if (p[1] == Guid::SIZE) backup_guid = Guid(p + 2); @@ -1418,14 +1421,14 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName& ULONG curPage = 0; ULONG lastPage = FIRST_PIP_PAGE; - const ULONG pagesPerPIP = Ods::pagesPerPIP(header->hdr_page_size); + const ULONG pagesPerPIP = Jrd::Ods::pagesPerPIP(header->hdr_page_size); ULONG scnsSlot = 0; - const ULONG pagesPerSCN = Ods::pagesPerSCN(header->hdr_page_size); + const ULONG pagesPerSCN = Jrd::Ods::pagesPerSCN(header->hdr_page_size); Array scns_buffer; - Ods::scns_page* scns = NULL; - Ods::scns_page* scns_buf = reinterpret_cast + Jrd::Ods::scns_page* scns = NULL; + Jrd::Ods::scns_page* scns_buf = reinterpret_cast (scns_buffer.getAlignedBuffer(header->hdr_page_size, ioBlockSize)); while (true) @@ -1510,7 +1513,7 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName& // where stored number of pages allocated from this pointer page. if (page_buff->pag_type == pag_pages) { - Ods::page_inv_page* pip = (Ods::page_inv_page*) page_buff; + Jrd::Ods::page_inv_page* pip = (Jrd::Ods::page_inv_page*) page_buff; if (lastPage == FIRST_PIP_PAGE) lastPage = pip->pip_used - 1; else @@ -1778,7 +1781,7 @@ void NBackup::restore_database(const BackupFiles& files, bool repl_seq, bool inc if (bytesDone != bakheader.page_size) { status_exception::raise(Arg::Gds(isc_nbackup_err_eofbk) << bakname.c_str()); } - const SINT64 pageNum = reinterpret_cast(page_ptr)->pag_pageno; + const SINT64 pageNum = reinterpret_cast(page_ptr)->pag_pageno; seek_file(dbase, pageNum * bakheader.page_size); write_file(dbase, page_ptr, bakheader.page_size); checkCtrlC(uSvc); @@ -1805,7 +1808,7 @@ void NBackup::restore_database(const BackupFiles& files, bool repl_seq, bool inc open_database_write(true); // Read database header - Ods::header_page header; + Jrd::Ods::header_page header; if (read_file(dbase, &header, HDR_SIZE) != HDR_SIZE) status_exception::raise(Arg::Gds(isc_nbackup_err_eofhdr_restdb) << Arg::Num(1)); @@ -1817,11 +1820,11 @@ void NBackup::restore_database(const BackupFiles& files, bool repl_seq, bool inc status_exception::raise(Arg::Gds(isc_nbackup_err_eofhdr_restdb) << Arg::Num(2)); prev_guid.reset(); - auto p = reinterpret_cast(page_ptr)->hdr_data; + auto p = reinterpret_cast(page_ptr)->hdr_data; const auto end = page_ptr + header.hdr_page_size; - while (p < end && *p != Ods::HDR_end) + while (p < end && *p != Jrd::Ods::HDR_end) { - if (*p == Ods::HDR_backup_guid) + if (*p == Jrd::Ods::HDR_backup_guid) { if (p[1] == Guid::SIZE) prev_guid = Guid(p + 2); @@ -2218,3 +2221,6 @@ void nbackup(UtilSvc* uSvc) throw; } } + + +} // namespace Firebird::Nbackup diff --git a/src/utilities/nbackup/nbk_proto.h b/src/utilities/nbackup/nbk_proto.h index 7ba72eb1ab8..efff70dfe67 100644 --- a/src/utilities/nbackup/nbk_proto.h +++ b/src/utilities/nbackup/nbk_proto.h @@ -30,7 +30,10 @@ #include "../common/ThreadData.h" #include "../common/UtilSvc.h" -void nbackup(Firebird::UtilSvc*); -int NBACKUP_main(Firebird::UtilSvc*); +namespace Firebird::Nbackup +{ + void nbackup(UtilSvc*); + int NBACKUP_main(UtilSvc*); +} // namespace Firebird::Nbackup #endif // NBK_PROTO_H diff --git a/src/utilities/nbackup/nbkswi.h b/src/utilities/nbackup/nbkswi.h index 6eeec8da7d6..97518067605 100644 --- a/src/utilities/nbackup/nbkswi.h +++ b/src/utilities/nbackup/nbkswi.h @@ -27,7 +27,11 @@ #ifndef NBACKUP_NBKSWI_H #define NBACKUP_NBKSWI_H -#include "../jrd/constants.h" +#include "../common/constants.h" + +namespace Firebird::Nbackup +{ + // Switch handling constants @@ -89,4 +93,8 @@ static inline constexpr struct Switches::in_sw_tab_t nbackup_action_in_sw_table {IN_SW_NBK_HELP, 0, "?", 0, 0, 0, false, false, 0, 1, NULL, 0}, {IN_SW_NBK_0, 0, NULL, 0, 0, 0, false, false, 0, 0, NULL, 0} // End of List }; + + +} // namespace Firebird::Nbackup + #endif // NBACKUP_NBKSWI_H diff --git a/src/utilities/ntrace/PluginLogWriter.cpp b/src/utilities/ntrace/PluginLogWriter.cpp index 10889c7c6da..6ef6ee71683 100644 --- a/src/utilities/ntrace/PluginLogWriter.cpp +++ b/src/utilities/ntrace/PluginLogWriter.cpp @@ -40,7 +40,9 @@ #define S_IWRITE S_IWUSR #endif -using namespace Firebird; +namespace Firebird::Ntrace +{ + // seems to only be Solaris 9 that doesn't have strerror_r, // maybe we can remove this in the future @@ -327,3 +329,6 @@ void PluginLogWriter::onIdleTimer(TimerImpl*) ::close(m_fileHandle); m_fileHandle = -1; } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/PluginLogWriter.h b/src/utilities/ntrace/PluginLogWriter.h index 36294d20661..76784be0931 100644 --- a/src/utilities/ntrace/PluginLogWriter.h +++ b/src/utilities/ntrace/PluginLogWriter.h @@ -47,15 +47,18 @@ #include #include +namespace Firebird::Ntrace +{ + // Empty header. We need it to get shared mutex using SharedMemory -struct PluginLogWriterHeader : public Firebird::MemoryHeader +struct PluginLogWriterHeader : public MemoryHeader { }; class PluginLogWriter final : - public Firebird::RefCntIface >, - public Firebird::IpcObject + public RefCntIface>, + public IpcObject { public: PluginLogWriter(const char* fileName, size_t maxSize); @@ -63,7 +66,7 @@ class PluginLogWriter final : // TraceLogWriter implementation FB_SIZE_T write(const void* buf, FB_SIZE_T size) override; - FB_SIZE_T write_s(Firebird::CheckStatusWrapper* status, const void* buf, FB_SIZE_T size) override; + FB_SIZE_T write_s(CheckStatusWrapper* status, const void* buf, FB_SIZE_T size) override; private: static constexpr USHORT PLUGIN_LOG_VERSION = 1; @@ -75,7 +78,7 @@ class PluginLogWriter final : // evaluate new value or clear idle timer void setupIdleTimer(bool clear); - void onIdleTimer(Firebird::TimerImpl*); + void onIdleTimer(TimerImpl*); // Windows requires explicit syncronization when few processes appends to the // same file simultaneously, therefore we used our fastMutex for this @@ -84,9 +87,9 @@ class PluginLogWriter final : // Mutex on Posix is needed to rotate log file. void mutexBug(int osErrorCode, const char* text) override; - bool initialize(Firebird::SharedMemoryBase*, bool) override; + bool initialize(SharedMemoryBase*, bool) override; - USHORT getType() const override { return Firebird::SharedMemoryBase::SRAM_TRACE_AUDIT_MTX; }; + USHORT getType() const override { return SharedMemoryBase::SRAM_TRACE_AUDIT_MTX; }; USHORT getVersion() const override { return PLUGIN_LOG_VERSION; }; const char* getName() const override { return "AuditLogMutex"; }; @@ -112,14 +115,17 @@ class PluginLogWriter final : PluginLogWriter* m_log; }; - Firebird::PathName m_fileName; + PathName m_fileName; int m_fileHandle; size_t m_maxSize; - Firebird::AutoPtr > m_sharedMemory; + AutoPtr> m_sharedMemory; - typedef Firebird::TimerImpl IdleTimer; - Firebird::RefPtr m_idleTimer; - Firebird::Mutex m_idleMutex; + typedef TimerImpl IdleTimer; + RefPtr m_idleTimer; + Mutex m_idleMutex; }; + +} // namespace Firebird::Ntrace + #endif // PLUGINLOGWRITER_H diff --git a/src/utilities/ntrace/TraceConfiguration.cpp b/src/utilities/ntrace/TraceConfiguration.cpp index 04e5730fc63..4614c2020ba 100644 --- a/src/utilities/ntrace/TraceConfiguration.cpp +++ b/src/utilities/ntrace/TraceConfiguration.cpp @@ -31,7 +31,8 @@ #include "../../common/db_alias.h" #include "../../common/os/path_utils.h" -using namespace Firebird; +namespace Firebird::Ntrace +{ void TraceCfgReader::readTraceConfiguration(const char* text, @@ -45,7 +46,7 @@ void TraceCfgReader::readTraceConfiguration(const char* text, #define PATH_PARAMETER(NAME, VALUE) \ if (!found && el->name == #NAME) { \ - Firebird::PathName temp; \ + PathName temp; \ expandPattern(el, temp); \ PathUtils::fixupSeparators(temp.begin()); \ m_config.NAME = temp.c_str(); \ @@ -348,3 +349,6 @@ TraceCfgReader::SectionType TraceCfgReader::parseSectionKey(const ConfigFile::Pa return SectionType::DATABASE; } } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/TraceConfiguration.h b/src/utilities/ntrace/TraceConfiguration.h index b76ffb69162..296b5dfc02f 100644 --- a/src/utilities/ntrace/TraceConfiguration.h +++ b/src/utilities/ntrace/TraceConfiguration.h @@ -36,11 +36,14 @@ #include +namespace Firebird::Ntrace +{ + class TraceCfgReader { public: - static void readTraceConfiguration(const char* text, const Firebird::PathName& databaseName, TracePluginConfig& config); + static void readTraceConfiguration(const char* text, const PathName& databaseName, TracePluginConfig& config); private: struct MatchPos @@ -59,7 +62,7 @@ class TraceCfgReader }; private: - TraceCfgReader(const char* text, const Firebird::PathName& databaseName, TracePluginConfig& config) noexcept : + TraceCfgReader(const char* text, const PathName& databaseName, TracePluginConfig& config) noexcept : m_text(text), m_databaseName(databaseName), m_config(config) @@ -67,15 +70,18 @@ class TraceCfgReader void readConfig(); - void expandPattern(const ConfigFile::Parameter* el, Firebird::PathName& valueToExpand); + void expandPattern(const ConfigFile::Parameter* el, PathName& valueToExpand); bool parseBoolean(const ConfigFile::Parameter* el) const; ULONG parseUInteger(const ConfigFile::Parameter* el) const; SectionType parseSectionKey(const ConfigFile::Parameter* el) const; const char* const m_text; - const Firebird::PathName& m_databaseName; + const PathName& m_databaseName; MatchPos m_subpatterns[10]{}; TracePluginConfig& m_config; }; + +} // namespace Firebird::Ntrace + #endif // TRACE_CONFIGURATION diff --git a/src/utilities/ntrace/TracePluginConfig.h b/src/utilities/ntrace/TracePluginConfig.h index a91c05062e2..f07f27e5ae8 100644 --- a/src/utilities/ntrace/TracePluginConfig.h +++ b/src/utilities/ntrace/TracePluginConfig.h @@ -33,12 +33,16 @@ //enum LogFormat { lfText = 0, lfBinary = 1 }; +namespace Firebird::Ntrace +{ + + struct TracePluginConfig { #define DATABASE_PARAMS #define SERVICE_PARAMS -#define PATH_PARAMETER(NAME, VALUE) Firebird::PathName NAME; +#define PATH_PARAMETER(NAME, VALUE) PathName NAME; #define STR_PARAMETER(NAME, VALUE) ConfigFile::String NAME; #define BOOL_PARAMETER(NAME, VALUE) bool NAME; #define UINT_PARAMETER(NAME, VALUE) ULONG NAME; @@ -47,7 +51,7 @@ struct TracePluginConfig #undef STR_PARAMETER #undef BOOL_PARAMETER #undef UINT_PARAMETER - Firebird::PathName db_filename; + PathName db_filename; // Default constructor. Pass pool to all string parameters, initialize everything to defaults TracePluginConfig() : @@ -84,4 +88,7 @@ struct TracePluginConfig #undef SERVICE_PARAMS }; + +} // namespace Firebird::Ntrace + #endif diff --git a/src/utilities/ntrace/TracePluginImpl.cpp b/src/utilities/ntrace/TracePluginImpl.cpp index 5447402550d..50248c8d470 100644 --- a/src/utilities/ntrace/TracePluginImpl.cpp +++ b/src/utilities/ntrace/TracePluginImpl.cpp @@ -47,8 +47,9 @@ #include "../../common/SimpleStatusVector.h" #include "../../jrd/status.h" -using namespace Firebird; -using namespace Jrd; +namespace Firebird::Ntrace +{ + static const char* const DEFAULT_LOG_NAME = "default_trace.log"; @@ -61,9 +62,9 @@ static const char* const DEFAULT_LOG_NAME = "default_trace.log"; /// TracePluginImpl -const char* TracePluginImpl::marshal_exception(const Firebird::Exception& ex) +const char* TracePluginImpl::marshal_exception(const Exception& ex) { - Firebird::StaticStatusVector st; + StaticStatusVector st; ex.stuffException(st); const ISC_STATUS* status = st.begin(); @@ -259,7 +260,7 @@ void TracePluginImpl::logRecord(const char* action) { // We use atomic file appends for logging. Do not try to break logging // to multiple separate file operations - const Firebird::TimeStamp stamp(Firebird::TimeStamp::getCurrentTimeStamp()); + const TimeStamp stamp(TimeStamp::getCurrentTimeStamp()); struct tm times; stamp.decode(×); @@ -809,7 +810,7 @@ bool TracePluginImpl::filterStatus(const ISC_STATUS* status, GdsCodesArray& arr) } -void TracePluginImpl::str2Array(const Firebird::string& str, GdsCodesArray& arr) +void TracePluginImpl::str2Array(const string& str, GdsCodesArray& arr) { // input: string with comma-delimited list of gds codes values and\or gds codes names // output: sorted array of gds codes values @@ -1077,14 +1078,14 @@ void TracePluginImpl::appendParams(ITraceParams* params) case dtype_sql_date: { struct tm times; - Firebird::TimeStamp::decode_date(*(ISC_DATE*)parameters->dsc_address, ×); + TimeStamp::decode_date(*(ISC_DATE*)parameters->dsc_address, ×); paramvalue.printf("%04d-%02d-%02d", times.tm_year + 1900, times.tm_mon + 1, times.tm_mday); break; } case dtype_sql_time: { int hours, minutes, seconds, fractions; - Firebird::TimeStamp::decode_time(*(ISC_TIME*) parameters->dsc_address, + TimeStamp::decode_time(*(ISC_TIME*) parameters->dsc_address, &hours, &minutes, &seconds, &fractions); paramvalue.printf("%02d:%02d:%02d.%04d", hours, minutes, seconds, fractions); @@ -1092,7 +1093,7 @@ void TracePluginImpl::appendParams(ITraceParams* params) } case dtype_timestamp: { - Firebird::TimeStamp ts(*(ISC_TIMESTAMP*) parameters->dsc_address); + TimeStamp ts(*(ISC_TIMESTAMP*) parameters->dsc_address); struct tm times; ts.decode(×); @@ -2345,10 +2346,10 @@ void TracePluginImpl::log_event_service_start(ITraceServiceConnection* service, // Delete terminator symbols from service switches for (FB_SIZE_T i = 0; i < sw.length(); ++i) { - if (sw[i] == Firebird::SVC_TRMNTR) + if (sw[i] == SVC_TRMNTR) { sw.erase(i, 1); - if ((i < sw.length()) && (sw[i] != Firebird::SVC_TRMNTR)) + if ((i < sw.length()) && (sw[i] != SVC_TRMNTR)) --i; } } @@ -2537,7 +2538,7 @@ FB_BOOLEAN TracePluginImpl::trace_attach(ITraceDatabaseConnection* connection, log_event_attach(connection, create_db, att_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2551,7 +2552,7 @@ FB_BOOLEAN TracePluginImpl::trace_detach(ITraceDatabaseConnection* connection, F log_event_detach(connection, drop_db); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2568,7 +2569,7 @@ FB_BOOLEAN TracePluginImpl::trace_transaction_start(ITraceDatabaseConnection* co log_event_transaction_start(connection, transaction, tpb_length, tpb, tra_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2584,7 +2585,7 @@ FB_BOOLEAN TracePluginImpl::trace_transaction_end(ITraceDatabaseConnection* conn log_event_transaction_end(connection, transaction, commit, retain_context, tra_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2600,7 +2601,7 @@ FB_BOOLEAN TracePluginImpl::trace_set_context(ITraceDatabaseConnection* connecti log_event_set_context(connection, transaction, variable); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2616,7 +2617,7 @@ FB_BOOLEAN TracePluginImpl::trace_proc_compile(ITraceDatabaseConnection* connect log_event_proc_compile(connection, procedure, time_millis, proc_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2633,7 +2634,7 @@ FB_BOOLEAN TracePluginImpl::trace_proc_execute(ITraceDatabaseConnection* connect log_event_proc_execute(connection, transaction, procedure, started, proc_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2649,7 +2650,7 @@ FB_BOOLEAN TracePluginImpl::trace_func_compile(ITraceDatabaseConnection* connect log_event_func_compile(connection, function, time_millis, func_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2666,7 +2667,7 @@ FB_BOOLEAN TracePluginImpl::trace_func_execute(ITraceDatabaseConnection* connect log_event_func_execute(connection, transaction, function, started, func_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2682,7 +2683,7 @@ FB_BOOLEAN TracePluginImpl::trace_trigger_compile(ITraceDatabaseConnection* conn log_event_trigger_compile(connection, trigger, time_millis, trig_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2699,7 +2700,7 @@ FB_BOOLEAN TracePluginImpl::trace_trigger_execute(ITraceDatabaseConnection* conn log_event_trigger_execute(connection, transaction, trigger, started, trig_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2717,7 +2718,7 @@ FB_BOOLEAN TracePluginImpl::trace_dsql_prepare(ITraceDatabaseConnection* connect log_event_dsql_prepare(connection, transaction, statement, time_millis, req_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2732,7 +2733,7 @@ FB_BOOLEAN TracePluginImpl::trace_dsql_free(ITraceDatabaseConnection* connection log_event_dsql_free(connection, statement, option); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2748,7 +2749,7 @@ FB_BOOLEAN TracePluginImpl::trace_dsql_execute(ITraceDatabaseConnection* connect log_event_dsql_execute(connection, transaction, statement, started, 0, req_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2764,7 +2765,7 @@ FB_BOOLEAN TracePluginImpl::trace_dsql_restart(ITraceDatabaseConnection* connect ITracePlugin::RESULT_SUCCESS); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2782,7 +2783,7 @@ FB_BOOLEAN TracePluginImpl::trace_blr_compile(ITraceDatabaseConnection* connecti log_event_blr_compile(connection, transaction, statement, time_millis, req_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2797,7 +2798,7 @@ FB_BOOLEAN TracePluginImpl::trace_blr_execute(ITraceDatabaseConnection* connecti log_event_blr_execute(connection, transaction, statement, req_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2814,7 +2815,7 @@ FB_BOOLEAN TracePluginImpl::trace_dyn_execute(ITraceDatabaseConnection* connecti log_event_dyn_execute(connection, transaction, request, time_millis, req_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2830,7 +2831,7 @@ FB_BOOLEAN TracePluginImpl::trace_service_attach(ITraceServiceConnection* servic log_event_service_attach(service, att_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2845,7 +2846,7 @@ FB_BOOLEAN TracePluginImpl::trace_service_start(ITraceServiceConnection* service log_event_service_start(service, switches_length, switches, start_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2862,7 +2863,7 @@ FB_BOOLEAN TracePluginImpl::trace_service_query(ITraceServiceConnection* service recv_item_length, recv_items, query_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2878,7 +2879,7 @@ FB_BOOLEAN TracePluginImpl::trace_service_detach(ITraceServiceConnection* servic log_event_service_detach(service, detach_result); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2893,7 +2894,7 @@ FB_BOOLEAN TracePluginImpl::trace_event_error(ITraceConnection* connection, log_event_error(connection, status, function); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; @@ -2908,9 +2909,12 @@ FB_BOOLEAN TracePluginImpl::trace_event_sweep(ITraceDatabaseConnection* connecti log_event_sweep(connection, sweep, sweep_state); return true; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { marshal_exception(ex); return false; } } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/TracePluginImpl.h b/src/utilities/ntrace/TracePluginImpl.h index 4025af881ff..3b24c21f43d 100644 --- a/src/utilities/ntrace/TracePluginImpl.h +++ b/src/utilities/ntrace/TracePluginImpl.h @@ -41,18 +41,22 @@ // Bring in off_t #include +namespace Firebird::Ntrace +{ + + class TracePluginImpl final : - public Firebird::RefCntIface > + public RefCntIface> { public: // Serialize exception to TLS buffer to return it to user - static const char* marshal_exception(const Firebird::Exception& ex); + static const char* marshal_exception(const Exception& ex); // Data for tracked (active) connections struct ConnectionData { AttNumber id; - Firebird::string* description; + string* description; // Deallocate memory used by objects hanging off this structure void deallocate_references() @@ -67,13 +71,13 @@ class TracePluginImpl final : } }; - typedef Firebird::BePlusTree ConnectionsTree; + typedef BePlusTree ConnectionsTree; // Data for tracked (active) transactions struct TransactionData { TraNumber id; - Firebird::string* description; + string* description; // Deallocate memory used by objects hanging off this structure void deallocate_references() @@ -88,13 +92,13 @@ class TracePluginImpl final : } }; - typedef Firebird::BePlusTree TransactionsTree; + typedef BePlusTree TransactionsTree; // Data for tracked (active) statements struct StatementData { StmtNumber id; - Firebird::string* description; // NULL in this field indicates that tracing of this statement is not desired + string* description; // NULL in this field indicates that tracing of this statement is not desired static const StmtNumber& generate(const void* /*sender*/, const StatementData& item) { @@ -102,13 +106,13 @@ class TracePluginImpl final : } }; - typedef Firebird::BePlusTree StatementsTree; + typedef BePlusTree StatementsTree; typedef void* ServiceId; struct ServiceData { ServiceId id; - Firebird::string* description; + string* description; bool enabled; // Deallocate memory used by objects hanging off this structure @@ -124,7 +128,7 @@ class TracePluginImpl final : } }; - typedef Firebird::BePlusTree ServicesTree; + typedef BePlusTree ServicesTree; template struct RoutineHelper @@ -132,168 +136,168 @@ class TracePluginImpl final : C* const routine; }; - typedef Firebird::SortedArray RoutinesList; + typedef SortedArray RoutinesList; - TracePluginImpl(Firebird::IPluginBase* factory, const TracePluginConfig& configuration, Firebird::ITraceInitInfo* initInfo); + TracePluginImpl(IPluginBase* factory, const TracePluginConfig& configuration, ITraceInitInfo* initInfo); private: ~TracePluginImpl(); // Used to not allow to destroy plugin factory and unload dll\so if // instance of TracePluginImpl class exists - Firebird::RefPtr factory; + RefPtr factory; bool operational; // Set if plugin is fully initialized and is ready for logging // Keep this member field first to ensure its correctness // when destructor is called const int session_id; // trace session ID, set by Firebird - Firebird::string session_name; // trace session name, set by Firebird - Firebird::ITraceLogWriter* logWriter; + string session_name; // trace session name, set by Firebird + ITraceLogWriter* logWriter; TracePluginConfig config; // Immutable, thus thread-safe - Firebird::string record; + string record; // Data for currently active connections, transactions, statements - Firebird::RWLock connectionsLock; + RWLock connectionsLock; ConnectionsTree connections; - Firebird::RWLock transactionsLock; + RWLock transactionsLock; TransactionsTree transactions; - Firebird::RWLock statementsLock; + RWLock statementsLock; StatementsTree statements; - Firebird::RWLock servicesLock; + RWLock servicesLock; ServicesTree services; - Firebird::RWLock routinesLock; + RWLock routinesLock; RoutinesList routines; // Lock for log rotation - Firebird::RWLock renameLock; + RWLock renameLock; - Firebird::AutoPtr include_matcher, exclude_matcher; + AutoPtr include_matcher, exclude_matcher; // Filters for gds error codes - typedef Firebird::SortedArray GdsCodesArray; + typedef SortedArray GdsCodesArray; GdsCodesArray include_codes; GdsCodesArray exclude_codes; - void appendGlobalCounts(Firebird::IPerformanceStats* stats); - void appendTableCounts(Firebird::IPerformanceStats* stats); - void appendParams(Firebird::ITraceParams* params); + void appendGlobalCounts(IPerformanceStats* stats); + void appendTableCounts(IPerformanceStats* stats); + void appendParams(ITraceParams* params); void appendServiceQueryParams(size_t send_item_length, const ntrace_byte_t* send_items, size_t recv_item_length, const ntrace_byte_t* recv_items); - void formatStringArgument(Firebird::string& result, const UCHAR* str, size_t len); + void formatStringArgument(string& result, const UCHAR* str, size_t len); bool filterStatus(const ISC_STATUS* status, GdsCodesArray& arr); - void str2Array(const Firebird::string& str, GdsCodesArray& arr); + void str2Array(const string& str, GdsCodesArray& arr); // register various objects - void register_connection(Firebird::ITraceDatabaseConnection* connection); - void register_transaction(Firebird::ITraceTransaction* transaction); - void register_sql_statement(Firebird::ITraceSQLStatement* statement); - void register_blr_statement(Firebird::ITraceBLRStatement* statement); - void register_service(Firebird::ITraceServiceConnection* service); + void register_connection(ITraceDatabaseConnection* connection); + void register_transaction(ITraceTransaction* transaction); + void register_sql_statement(ITraceSQLStatement* statement); + void register_blr_statement(ITraceBLRStatement* statement); + void register_service(ITraceServiceConnection* service); - void register_procedure(Firebird::ITraceProcedure* procedure); - void register_function(Firebird::ITraceFunction* function); - void register_trigger(Firebird::ITraceTrigger* trigger); + void register_procedure(ITraceProcedure* procedure); + void register_function(ITraceFunction* function); + void register_trigger(ITraceTrigger* trigger); - bool checkServiceFilter(Firebird::ITraceServiceConnection* service, bool started); + bool checkServiceFilter(ITraceServiceConnection* service, bool started); bool checkRoutine(StmtNumber stmt_id); - template Firebird::string getPlan(C* routine); + template string getPlan(C* routine); // Write message to text log file void logRecord(const char* action); - void logRecordConn(const char* action, Firebird::ITraceDatabaseConnection* connection); - void logRecordTrans(const char* action, Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction); - void logRecordProc(const char* action, Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceProcedure* procedure); - void logRecordFunc(const char* action, Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceFunction* function); - void logRecordTrig(const char* action, Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceTrigger* trigger); - void logRecordStmt(const char* action, Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTransaction* transaction, Firebird::ITraceStatement* statement, + void logRecordConn(const char* action, ITraceDatabaseConnection* connection); + void logRecordTrans(const char* action, ITraceDatabaseConnection* connection, + ITraceTransaction* transaction); + void logRecordProc(const char* action, ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceProcedure* procedure); + void logRecordFunc(const char* action, ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceFunction* function); + void logRecordTrig(const char* action, ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceTrigger* trigger); + void logRecordStmt(const char* action, ITraceDatabaseConnection* connection, + ITraceTransaction* transaction, ITraceStatement* statement, bool isSQL); - void logRecordServ(const char* action, Firebird::ITraceServiceConnection* service); - void logRecordError(const char* action, Firebird::ITraceConnection* connection, Firebird::ITraceStatusVector* status); + void logRecordServ(const char* action, ITraceServiceConnection* service); + void logRecordError(const char* action, ITraceConnection* connection, ITraceStatusVector* status); /* Methods which do logging of events to file */ void log_init(); void log_finalize(); void log_event_attach( - Firebird::ITraceDatabaseConnection* connection, FB_BOOLEAN create_db, + ITraceDatabaseConnection* connection, FB_BOOLEAN create_db, unsigned att_result); void log_event_detach( - Firebird::ITraceDatabaseConnection* connection, FB_BOOLEAN drop_db); + ITraceDatabaseConnection* connection, FB_BOOLEAN drop_db); void log_event_transaction_start( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, size_t tpb_length, const ntrace_byte_t* tpb, unsigned tra_result); void log_event_transaction_end( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, FB_BOOLEAN commit, FB_BOOLEAN retain_context, unsigned tra_result); void log_event_set_context( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceContextVariable* variable); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceContextVariable* variable); void log_event_proc_compile( - Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceProcedure* procedure, ntrace_counter_t time_millis, unsigned proc_result); + ITraceDatabaseConnection* connection, + ITraceProcedure* procedure, ntrace_counter_t time_millis, unsigned proc_result); void log_event_proc_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceProcedure* procedure, bool started, unsigned proc_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceProcedure* procedure, bool started, unsigned proc_result); void log_event_func_compile( - Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceFunction* function, ntrace_counter_t time_millis, unsigned func_result); + ITraceDatabaseConnection* connection, + ITraceFunction* function, ntrace_counter_t time_millis, unsigned func_result); void log_event_func_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceFunction* function, bool started, unsigned func_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceFunction* function, bool started, unsigned func_result); void log_event_trigger_compile( - Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTrigger* trigger, ntrace_counter_t time_millis, unsigned trig_result); + ITraceDatabaseConnection* connection, + ITraceTrigger* trigger, ntrace_counter_t time_millis, unsigned trig_result); void log_event_trigger_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceTrigger* trigger, bool started, unsigned trig_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceTrigger* trigger, bool started, unsigned trig_result); void log_event_dsql_prepare( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, ntrace_counter_t time_millis, unsigned req_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, ntrace_counter_t time_millis, unsigned req_result); void log_event_dsql_free( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceSQLStatement* statement, unsigned short option); + ITraceDatabaseConnection* connection, ITraceSQLStatement* statement, unsigned short option); void log_event_dsql_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, bool started, unsigned number, unsigned req_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, bool started, unsigned number, unsigned req_result); void log_event_blr_compile( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceBLRStatement* statement, ntrace_counter_t time_millis, unsigned req_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceBLRStatement* statement, ntrace_counter_t time_millis, unsigned req_result); void log_event_blr_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceBLRStatement* statement, unsigned req_result); + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceBLRStatement* statement, unsigned req_result); void log_event_dyn_execute( - Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceDYNRequest* request, ntrace_counter_t time_millis, + ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceDYNRequest* request, ntrace_counter_t time_millis, unsigned req_result); - void log_event_service_attach(Firebird::ITraceServiceConnection* service, unsigned att_result); - void log_event_service_start(Firebird::ITraceServiceConnection* service, size_t switches_length, const char* switches, + void log_event_service_attach(ITraceServiceConnection* service, unsigned att_result); + void log_event_service_start(ITraceServiceConnection* service, size_t switches_length, const char* switches, unsigned start_result); - void log_event_service_query(Firebird::ITraceServiceConnection* service, size_t send_item_length, + void log_event_service_query(ITraceServiceConnection* service, size_t send_item_length, const ntrace_byte_t* send_items, size_t recv_item_length, const ntrace_byte_t* recv_items, unsigned query_result); - void log_event_service_detach(Firebird::ITraceServiceConnection* service, unsigned detach_result); + void log_event_service_detach(ITraceServiceConnection* service, unsigned detach_result); - void log_event_error(Firebird::ITraceConnection* connection, Firebird::ITraceStatusVector* status, const char* function); + void log_event_error(ITraceConnection* connection, ITraceStatusVector* status, const char* function); - void log_event_sweep(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceSweepInfo* sweep, + void log_event_sweep(ITraceDatabaseConnection* connection, ITraceSweepInfo* sweep, ntrace_process_state_t sweep_state); public: @@ -301,70 +305,72 @@ class TracePluginImpl final : const char* trace_get_error(); // Create/close attachment - FB_BOOLEAN trace_attach(Firebird::ITraceDatabaseConnection* connection, FB_BOOLEAN create_db, unsigned att_result); - FB_BOOLEAN trace_detach(Firebird::ITraceDatabaseConnection* connection, FB_BOOLEAN drop_db); + FB_BOOLEAN trace_attach(ITraceDatabaseConnection* connection, FB_BOOLEAN create_db, unsigned att_result); + FB_BOOLEAN trace_detach(ITraceDatabaseConnection* connection, FB_BOOLEAN drop_db); // Start/end transaction - FB_BOOLEAN trace_transaction_start(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + FB_BOOLEAN trace_transaction_start(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, unsigned tpb_length, const ntrace_byte_t* tpb, unsigned tra_result); - FB_BOOLEAN trace_transaction_end(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, + FB_BOOLEAN trace_transaction_end(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, FB_BOOLEAN commit, FB_BOOLEAN retain_context, unsigned tra_result); // Stored procedures, functions and triggers compilation and execution - FB_BOOLEAN trace_proc_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceProcedure* procedure, ISC_INT64 time_millis, unsigned proc_result); - FB_BOOLEAN trace_proc_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceProcedure* procedure, FB_BOOLEAN started, unsigned proc_result); - FB_BOOLEAN trace_func_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceFunction* function, ISC_INT64 time_millis, unsigned func_result); - FB_BOOLEAN trace_func_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceFunction* function, FB_BOOLEAN started, unsigned func_result); - FB_BOOLEAN trace_trigger_compile(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceTrigger* trigger, ISC_INT64 time_millis, unsigned trig_result); - FB_BOOLEAN trace_trigger_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceTrigger* trigger, FB_BOOLEAN started, unsigned trig_result); + FB_BOOLEAN trace_proc_compile(ITraceDatabaseConnection* connection, + ITraceProcedure* procedure, ISC_INT64 time_millis, unsigned proc_result); + FB_BOOLEAN trace_proc_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceProcedure* procedure, FB_BOOLEAN started, unsigned proc_result); + FB_BOOLEAN trace_func_compile(ITraceDatabaseConnection* connection, + ITraceFunction* function, ISC_INT64 time_millis, unsigned func_result); + FB_BOOLEAN trace_func_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceFunction* function, FB_BOOLEAN started, unsigned func_result); + FB_BOOLEAN trace_trigger_compile(ITraceDatabaseConnection* connection, + ITraceTrigger* trigger, ISC_INT64 time_millis, unsigned trig_result); + FB_BOOLEAN trace_trigger_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceTrigger* trigger, FB_BOOLEAN started, unsigned trig_result); // Assignment to context variables - FB_BOOLEAN trace_set_context(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceContextVariable* variable); + FB_BOOLEAN trace_set_context(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceContextVariable* variable); // DSQL statement lifecycle - FB_BOOLEAN trace_dsql_prepare(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, ISC_INT64 time_millis, unsigned req_result); - FB_BOOLEAN trace_dsql_free(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceSQLStatement* statement, + FB_BOOLEAN trace_dsql_prepare(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, ISC_INT64 time_millis, unsigned req_result); + FB_BOOLEAN trace_dsql_free(ITraceDatabaseConnection* connection, ITraceSQLStatement* statement, unsigned option); - FB_BOOLEAN trace_dsql_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, FB_BOOLEAN started, unsigned req_result); - FB_BOOLEAN trace_dsql_restart(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceSQLStatement* statement, unsigned number); + FB_BOOLEAN trace_dsql_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, FB_BOOLEAN started, unsigned req_result); + FB_BOOLEAN trace_dsql_restart(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceSQLStatement* statement, unsigned number); // BLR requests - FB_BOOLEAN trace_blr_compile(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceBLRStatement* statement, ISC_INT64 time_millis, unsigned req_result); - FB_BOOLEAN trace_blr_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceBLRStatement* statement, unsigned req_result); + FB_BOOLEAN trace_blr_compile(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceBLRStatement* statement, ISC_INT64 time_millis, unsigned req_result); + FB_BOOLEAN trace_blr_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceBLRStatement* statement, unsigned req_result); // DYN requests - FB_BOOLEAN trace_dyn_execute(Firebird::ITraceDatabaseConnection* connection, Firebird::ITraceTransaction* transaction, - Firebird::ITraceDYNRequest* request, ISC_INT64 time_millis, unsigned req_result); + FB_BOOLEAN trace_dyn_execute(ITraceDatabaseConnection* connection, ITraceTransaction* transaction, + ITraceDYNRequest* request, ISC_INT64 time_millis, unsigned req_result); // Using the services - FB_BOOLEAN trace_service_attach(Firebird::ITraceServiceConnection* service, unsigned att_result); - FB_BOOLEAN trace_service_start(Firebird::ITraceServiceConnection* service, unsigned switches_length, const char* switches, + FB_BOOLEAN trace_service_attach(ITraceServiceConnection* service, unsigned att_result); + FB_BOOLEAN trace_service_start(ITraceServiceConnection* service, unsigned switches_length, const char* switches, unsigned start_result); - FB_BOOLEAN trace_service_query(Firebird::ITraceServiceConnection* service, unsigned send_item_length, + FB_BOOLEAN trace_service_query(ITraceServiceConnection* service, unsigned send_item_length, const ntrace_byte_t* send_items, unsigned recv_item_length, const ntrace_byte_t* recv_items, unsigned query_result); - FB_BOOLEAN trace_service_detach(Firebird::ITraceServiceConnection* service, unsigned detach_result); + FB_BOOLEAN trace_service_detach(ITraceServiceConnection* service, unsigned detach_result); // Errors happened - virtual FB_BOOLEAN trace_event_error(Firebird::ITraceConnection* connection, Firebird::ITraceStatusVector* status, + virtual FB_BOOLEAN trace_event_error(ITraceConnection* connection, ITraceStatusVector* status, const char* function); // Sweep activity - virtual FB_BOOLEAN trace_event_sweep(Firebird::ITraceDatabaseConnection* connection, - Firebird::ITraceSweepInfo* sweep, ntrace_process_state_t sweep_state); + virtual FB_BOOLEAN trace_event_sweep(ITraceDatabaseConnection* connection, + ITraceSweepInfo* sweep, ntrace_process_state_t sweep_state); }; +} // namespace Firebird::Ntrace + #endif // TRACEPLUGINIMPL_H diff --git a/src/utilities/ntrace/os/FileObject.h b/src/utilities/ntrace/os/FileObject.h index fa64c65bb39..18a4f00ae9c 100644 --- a/src/utilities/ntrace/os/FileObject.h +++ b/src/utilities/ntrace/os/FileObject.h @@ -37,6 +37,10 @@ #define NEWLINE "\n" #endif +namespace Firebird::Ntrace +{ + + enum FileOpenFlags { fo_rdonly = 0x0000, // open for reading only @@ -66,10 +70,10 @@ enum SeekOrigin so_from_end }; -class FileObject : public Firebird::AutoStorage +class FileObject : public AutoStorage { public: - FileObject(const Firebird::PathName& afilename, int flags, int pflags = 0666) : + FileObject(const PathName& afilename, int flags, int pflags = 0666) : filename(getPool(), afilename), #ifdef WIN_NT file(INVALID_HANDLE_VALUE), @@ -81,8 +85,8 @@ class FileObject : public Firebird::AutoStorage open(flags, pflags); } - FileObject(Firebird::MemoryPool& pool, const Firebird::PathName& afilename, int flags, int pflags = 0666) : - Firebird::AutoStorage(pool), filename(getPool(), afilename), + FileObject(MemoryPool& pool, const PathName& afilename, int flags, int pflags = 0666) : + AutoStorage(pool), filename(getPool(), afilename), #ifdef WIN_NT file(INVALID_HANDLE_VALUE), append_mutex(INVALID_HANDLE_VALUE) @@ -104,11 +108,11 @@ class FileObject : public Firebird::AutoStorage //This method used when log file was renamed by another process void reopen(); - bool renameFile(const Firebird::PathName new_filename); + bool renameFile(const PathName new_filename); // Generic stuff. Let it be inline for the moment. // If there will be a more than a few such methods we need to use inheritance - bool readLine(Firebird::string& dest) + bool readLine(string& dest) { // This method is not very efficient, but is still much better than // reading characters one-by-one. Plus it can handle line breaks in @@ -156,10 +160,10 @@ class FileObject : public Firebird::AutoStorage return dest.length() || bytesRead; } - void writeLine(const Firebird::string& from) + void writeLine(const string& from) { // Line should be written in a single BlockWrite call to handle file append properly - Firebird::string temp = from.substr(0, from.max_length() - 2) + NEWLINE; + string temp = from.substr(0, from.max_length() - 2) + NEWLINE; blockWrite(temp.c_str(), temp.length()); } @@ -170,7 +174,7 @@ class FileObject : public Firebird::AutoStorage void open(int flags, int pflags); - Firebird::PathName filename; + PathName filename; #ifdef WIN_NT HANDLE file; HANDLE append_mutex; @@ -179,4 +183,7 @@ class FileObject : public Firebird::AutoStorage #endif }; + +} // namespace Firebird::Ntrace + #endif // OS_FILEOBJECT_H diff --git a/src/utilities/ntrace/os/platform.h b/src/utilities/ntrace/os/platform.h index 6afe7670db9..92d8c2b2943 100644 --- a/src/utilities/ntrace/os/platform.h +++ b/src/utilities/ntrace/os/platform.h @@ -28,10 +28,11 @@ #ifndef OS_PLATFORM_H #define OS_PLATFORM_H -const char* get_error_string(); - -void set_error_string(const char* str); - -SLONG get_process_id(); +namespace Firebird::Ntrace +{ + const char* get_error_string(); + void set_error_string(const char* str); + SLONG get_process_id(); +} // namespace Firebird::Ntrace #endif // OS_PLATFORM_H diff --git a/src/utilities/ntrace/os/posix/misc/FileObject.cpp b/src/utilities/ntrace/os/posix/misc/FileObject.cpp index eb7f1545e9f..3e05a45cfd6 100644 --- a/src/utilities/ntrace/os/posix/misc/FileObject.cpp +++ b/src/utilities/ntrace/os/posix/misc/FileObject.cpp @@ -35,8 +35,11 @@ #endif #include -using namespace Firebird; -Firebird::Mutex open_mutex; +namespace Firebird::Ntrace +{ + + +Mutex open_mutex; void FileObject::open(int flags, int pflags) { @@ -137,7 +140,7 @@ void FileObject::reopen() //fchmod(file, PMASK); } -bool FileObject::renameFile(const Firebird::PathName new_filename) +bool FileObject::renameFile(const PathName new_filename) { if (rename(filename.c_str(), new_filename.c_str())) { @@ -185,3 +188,6 @@ SINT64 FileObject::seek(SINT64 newOffset, SeekOrigin origin) return result; } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/os/posix/platform.cpp b/src/utilities/ntrace/os/posix/platform.cpp index 77029cf0fbd..0cabdd65ed2 100644 --- a/src/utilities/ntrace/os/posix/platform.cpp +++ b/src/utilities/ntrace/os/posix/platform.cpp @@ -34,6 +34,10 @@ #endif #include +namespace Firebird::Ntrace +{ + + #define TEST //#undef TEST @@ -47,7 +51,7 @@ class MallocClear } }; -Firebird::TlsValue error_value; +TlsValue error_value; const char* get_error_string() { @@ -106,3 +110,6 @@ SLONG get_process_id() { return getpid(); } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/os/win32/FileObject.cpp b/src/utilities/ntrace/os/win32/FileObject.cpp index 53fbfc0f0ff..26dc1770e28 100644 --- a/src/utilities/ntrace/os/win32/FileObject.cpp +++ b/src/utilities/ntrace/os/win32/FileObject.cpp @@ -28,8 +28,11 @@ #include "firebird.h" #include "../FileObject.h" -using namespace Firebird; -Firebird::Mutex open_mutex; +namespace Firebird::Ntrace +{ + + +Mutex open_mutex; void FileObject::open(int flags, int pflags) { @@ -224,7 +227,7 @@ void FileObject::writeHeader(const void* buffer, size_t bytesToWrite) ReleaseMutex(append_mutex); } -bool FileObject::renameFile(const Firebird::PathName new_filename) +bool FileObject::renameFile(const PathName new_filename) { if (append_mutex != INVALID_HANDLE_VALUE) { @@ -286,3 +289,6 @@ SINT64 FileObject::seek(SINT64 newOffset, SeekOrigin origin) return offset.QuadPart; } + + +} // namespace Firebird::Ntrace diff --git a/src/utilities/ntrace/os/win32/platform.cpp b/src/utilities/ntrace/os/win32/platform.cpp index 6fb1efc4ad6..bf54a5f20db 100644 --- a/src/utilities/ntrace/os/win32/platform.cpp +++ b/src/utilities/ntrace/os/win32/platform.cpp @@ -30,6 +30,9 @@ #include "../platform.h" #include "../common/classes/fb_tls.h" +namespace Firebird::Ntrace +{ + TLS_DECLARE(char*, error_string); const char* get_error_string() @@ -63,16 +66,20 @@ SLONG get_process_id() return GetCurrentProcessId(); } +} // namespace Firebird::Ntrace + BOOL WINAPI DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReserved*/) { + using namespace Firebird; + if (fdwReason == DLL_THREAD_DETACH) { - char* str = TLS_GET(error_string); + char* str = TLS_GET(Ntrace::error_string); if (str) { LocalFree(str); - TLS_SET(error_string, NULL); + TLS_SET(Ntrace::error_string, NULL); } } return TRUE; diff --git a/src/utilities/ntrace/traceplugin.cpp b/src/utilities/ntrace/traceplugin.cpp index f77cd9fe0bf..0d0e9492835 100644 --- a/src/utilities/ntrace/traceplugin.cpp +++ b/src/utilities/ntrace/traceplugin.cpp @@ -32,28 +32,32 @@ #include "TraceConfiguration.h" #include "TracePluginImpl.h" +namespace Firebird::Ntrace +{ + + class TraceFactoryImpl final : - public Firebird::StdPlugin > + public StdPlugin> { public: - explicit TraceFactoryImpl(Firebird::IPluginConfig*) + explicit TraceFactoryImpl(IPluginConfig*) { } // TraceFactory implementation ntrace_mask_t trace_needs(); - Firebird::ITracePlugin* trace_create(Firebird::CheckStatusWrapper* status, - Firebird::ITraceInitInfo* init_info); + ITracePlugin* trace_create(CheckStatusWrapper* status, + ITraceInitInfo* init_info); }; ntrace_mask_t TraceFactoryImpl::trace_needs() { - return (1 << Firebird::ITraceFactory::TRACE_EVENT_MAX) - 1; + return (1 << ITraceFactory::TRACE_EVENT_MAX) - 1; } -Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrapper* status, - Firebird::ITraceInitInfo* initInfo) +ITracePlugin* TraceFactoryImpl::trace_create(CheckStatusWrapper* status, + ITraceInitInfo* initInfo) { - Firebird::MasterInterfacePtr master; + MasterInterfacePtr master; const char* dbname = NULL; try { @@ -64,7 +68,7 @@ Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrap TracePluginConfig config; TraceCfgReader::readTraceConfiguration(initInfo->getConfigText(), dbname, config); - Firebird::ITraceDatabaseConnection* connection = initInfo->getConnection(); + ITraceDatabaseConnection* connection = initInfo->getConnection(); if (!config.enabled || (config.connection_id && connection && @@ -73,7 +77,7 @@ Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrap return NULL; // Plugin is not needed, no error happened. } - Firebird::AutoPtr + AutoPtr logWriter(initInfo->getLogWriter()); if (logWriter) @@ -82,14 +86,14 @@ Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrap return FB_NEW TracePluginImpl(this, config, initInfo); // Everything is ok, we created a plugin } - catch (Firebird::Exception& ex) + catch (Exception& ex) { // put error into trace log - Firebird::ITraceLogWriter* logWriter = initInfo->getLogWriter(); + ITraceLogWriter* logWriter = initInfo->getLogWriter(); if (logWriter) { const char* strEx = TracePluginImpl::marshal_exception(ex); - Firebird::string err; + string err; if (dbname && dbname[0]) err.printf("Error creating trace session for database \"%s\":\n%s\n", dbname, strEx); else @@ -106,17 +110,22 @@ Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrap } -static Firebird::SimpleFactory traceFactory; +static SimpleFactory traceFactory; -void registerTrace(Firebird::IPluginManager* iPlugin) +void registerTrace(IPluginManager* iPlugin) { - iPlugin->registerPluginFactory(Firebird::IPluginManager::TYPE_TRACE, "fbtrace", &traceFactory); - Firebird::getUnloadDetector()->registerMe(); + iPlugin->registerPluginFactory(IPluginManager::TYPE_TRACE, "fbtrace", &traceFactory); + getUnloadDetector()->registerMe(); } -extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) +} // namespace Firebird::Ntrace + + +using namespace Firebird; + +extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master) { - Firebird::CachedMasterInterface::set(master); - registerTrace(Firebird::PluginManagerInterfacePtr()); + CachedMasterInterface::set(master); + Ntrace::registerTrace(PluginManagerInterfacePtr()); } diff --git a/src/utilities/rebuild/rebui_proto.h b/src/utilities/rebuild/rebui_proto.h index ebd8bab8c36..08410e22f4b 100644 --- a/src/utilities/rebuild/rebui_proto.h +++ b/src/utilities/rebuild/rebui_proto.h @@ -24,7 +24,7 @@ #ifndef UTILITIES_REBUI_PROTO_H #define UTILITIES_REBUI_PROTO_H -namespace Ods { +namespace Firebird::Jrd::Ods { struct pag; } diff --git a/src/utilities/rebuild/rebuild.cpp b/src/utilities/rebuild/rebuild.cpp index 9dbbf55006d..90b68005804 100644 --- a/src/utilities/rebuild/rebuild.cpp +++ b/src/utilities/rebuild/rebuild.cpp @@ -225,7 +225,7 @@ int main( int argc, char *argv[]) gdbb->tdbb_database->dbb_pcontrol->pgc_pip = 1; if (ascii_out) - dbg_file = os_utils::fopen(ascii_out, "w"); + dbg_file = Firebird::os_utils::fopen(ascii_out, "w"); if (sw_print && rbdb && header) write_headers(dbg_file, rbdb, p_lower_bound, p_upper_bound); @@ -343,7 +343,7 @@ void RBDB_open( rbdb* rbdb) * Open a database file. * **************************************/ - if ((rbdb->rbdb_file.fil_file = os_utils::open(rbdb->rbdb_file.fil_name, O_RDWR, 0)) == -1) + if ((rbdb->rbdb_file.fil_file = Firebird::os_utils::open(rbdb->rbdb_file.fil_name, O_RDWR, 0)) == -1) { db_error(errno); } @@ -365,7 +365,7 @@ PAG RBDB_read(rbdb* rbdb, SLONG page_number) int file = rbdb->rbdb_file.fil_file; const FB_UINT64 offset = ((FB_UINT64) page_number) * ((FB_UINT64) rbdb->rbdb_page_size); - if (os_utils::lseek (file, offset, 0) == -1) + if (Firebird::os_utils::lseek (file, offset, 0) == -1) db_error(errno); SSHORT length = rbdb->rbdb_page_size; @@ -401,7 +401,7 @@ void RBDB_write( rbdb* rbdb, PAG page, SLONG page_number) int fd = rbdb->rbdb_file.fil_file; const FB_UINT64 offset = ((FB_UINT64) page_number) * ((FB_UINT64) page_size); - if (os_utils::lseek (fd, offset, 0) == -1) + if (Firebird::os_utils::lseek (fd, offset, 0) == -1) db_error(errno); if (write(fd, page, page_size) == -1) db_error(errno); diff --git a/src/utilities/rebuild/rstore.epp b/src/utilities/rebuild/rstore.epp index 5a8c3de5b89..a3509895902 100644 --- a/src/utilities/rebuild/rstore.epp +++ b/src/utilities/rebuild/rstore.epp @@ -33,7 +33,7 @@ DATABASE DB = STATIC FILENAME "rebuild.fdb"; static void store_headers(RBDB); -using namespace Ods; +using namespace Firebird::Jrd::Ods; void RSTORE( RBDB rbdb) diff --git a/src/yvalve/DistributedTransaction.cpp b/src/yvalve/DistributedTransaction.cpp index 976723df0e5..0800dc79265 100644 --- a/src/yvalve/DistributedTransaction.cpp +++ b/src/yvalve/DistributedTransaction.cpp @@ -37,8 +37,9 @@ #include "../common/isc_proto.h" #include "../jrd/acl.h" -using namespace Firebird; -using namespace Why; +namespace Firebird::Why +{ + namespace { @@ -515,9 +516,6 @@ DTransaction::~DTransaction() } // anonymous namespace -namespace Why { - - void DtcStart::addAttachment(CheckStatusWrapper* status, IAttachment* att) { this->addWithTpb(status, att, 0, NULL); @@ -639,4 +637,5 @@ DtcStart* Dtc::startBuilder(CheckStatusWrapper* status) return NULL; } -} // namespace Why + +} // namespace Firebird::Why diff --git a/src/yvalve/DistributedTransaction.h b/src/yvalve/DistributedTransaction.h index 95488005caf..8f741a32179 100644 --- a/src/yvalve/DistributedTransaction.h +++ b/src/yvalve/DistributedTransaction.h @@ -34,9 +34,11 @@ #include "../common/classes/array.h" #include "../common/StatusHolder.h" -namespace Why { +namespace Firebird::Why +{ + -class DtcStart : public Firebird::DisposeIface > +class DtcStart : public DisposeIface > { public: DtcStart() @@ -45,41 +47,42 @@ class DtcStart : public Firebird::DisposeIface components; + HalfStaticArray components; }; -class Dtc : public Firebird::AutoIface > +class Dtc : public AutoIface > { public: // IDtc implementation - YTransaction* join(Firebird::CheckStatusWrapper* status, - Firebird::ITransaction* one, Firebird::ITransaction* two); - DtcStart* startBuilder(Firebird::CheckStatusWrapper* status); + YTransaction* join(CheckStatusWrapper* status, + ITransaction* one, ITransaction* two); + DtcStart* startBuilder(CheckStatusWrapper* status); }; -} // namespace Why + +} // namespace Firebird::Why #endif // YVALVE_DISTRIBUTED_TRANSACTION_H diff --git a/src/yvalve/MasterImplementation.cpp b/src/yvalve/MasterImplementation.cpp index d8ec299dbc5..4f725a0e72e 100644 --- a/src/yvalve/MasterImplementation.cpp +++ b/src/yvalve/MasterImplementation.cpp @@ -48,17 +48,19 @@ #include "ibase.h" #include "../yvalve/utl_proto.h" -using namespace Firebird; - -namespace Why { +namespace Firebird::Why +{ // // getStatus() // -class UserStatus final : public Firebird::DisposeIface > +namespace { -}; + class UserStatus final : public DisposeIface> + { + }; +} IStatus* MasterImplementation::getStatus() { @@ -122,14 +124,11 @@ int MasterImplementation::serverMode(int mode) return currentMode; } -} // namespace Why // // timer // -namespace Why { - static bool abortShutdownFlag = false; void abortShutdown() @@ -259,7 +258,7 @@ THREAD_ENTRY_DECLARE TimerEntry::timeThread(THREAD_ENTRY_PARAM) while (stopTimerThread.value() == 0 #ifdef WIN_NT - && Firebird::dDllUnloadTID == 0 + && dDllUnloadTID == 0 #endif ) { @@ -306,7 +305,7 @@ THREAD_ENTRY_DECLARE TimerEntry::timeThread(THREAD_ENTRY_PARAM) timerCleanup->release(); #ifdef WIN_NT - if (Firebird::dDllUnloadTID) + if (dDllUnloadTID) { // fb_shutdown is called as result of FreeLibrary, not by application. // Sooner of all we are the last user of fbclient.dll, and code will be @@ -360,7 +359,7 @@ class TimerImplementation : timerWakeup->release(); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -379,7 +378,7 @@ class TimerImplementation : timerQueue->remove(curTimer); } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -409,43 +408,33 @@ bool timerThreadStopped() return stopTimerThread.value() != 0; } -} // namespace Why - // // Util (misc calls) // -namespace Why { - - extern UtilInterface utilInterface; // Implemented in utl.cpp - - IUtil* MasterImplementation::getUtilInterface() - { - return &utilInterface; - } +extern UtilInterface utilInterface; // Implemented in utl.cpp -} // namespace Why +IUtil* MasterImplementation::getUtilInterface() +{ + return &utilInterface; +} // // ConfigManager (config info access) // -namespace Firebird { - - extern IConfigManager* iConfigManager; +extern IConfigManager* iConfigManager; -} // namespace Firebird +IConfigManager* MasterImplementation::getConfigManager() +{ + return iConfigManager; +} -namespace Why { - IConfigManager* MasterImplementation::getConfigManager() - { - return Firebird::iConfigManager; - } -} // namespace Why +} // namespace Firebird::Why // diff --git a/src/yvalve/MasterImplementation.h b/src/yvalve/MasterImplementation.h index 08f3121cc93..14769cae584 100644 --- a/src/yvalve/MasterImplementation.h +++ b/src/yvalve/MasterImplementation.h @@ -40,29 +40,29 @@ namespace Firebird class Mutex; } -namespace Why +namespace Firebird::Why { class MasterImplementation : - public Firebird::AutoIface > + public AutoIface > { public: - static Firebird::Static dtc; + static Static dtc; public: // IMaster implementation - Firebird::IStatus* getStatus(); - Firebird::IProvider* getDispatcher(); - Firebird::IPluginManager* getPluginManager(); - Firebird::ITimerControl* getTimerControl(); - Firebird::IAttachment* registerAttachment(Firebird::IProvider* provider, - Firebird::IAttachment* attachment); - Firebird::ITransaction* registerTransaction(Firebird::IAttachment* attachment, - Firebird::ITransaction* transaction); + IStatus* getStatus(); + IProvider* getDispatcher(); + IPluginManager* getPluginManager(); + ITimerControl* getTimerControl(); + IAttachment* registerAttachment(IProvider* provider, + IAttachment* attachment); + ITransaction* registerTransaction(IAttachment* attachment, + ITransaction* transaction); Dtc* getDtc(); - Firebird::IMetadataBuilder* getMetadataBuilder(Firebird::CheckStatusWrapper* status, unsigned fieldCount); + IMetadataBuilder* getMetadataBuilder(CheckStatusWrapper* status, unsigned fieldCount); int serverMode(int mode); - Firebird::IUtil* getUtilInterface(); - Firebird::IConfigManager* getConfigManager(); + IUtil* getUtilInterface(); + IConfigManager* getConfigManager(); FB_BOOLEAN getProcessExiting(); }; @@ -71,9 +71,9 @@ namespace Why void shutdownTimers(); - Firebird::Mutex& pauseTimer(); + Mutex& pauseTimer(); bool timerThreadStopped(); -} // namespace Why +} // namespace Firebird::Why #endif // YVALVE_MASTER_IMPLEMENTATION_H diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp index cadaf792422..adcfe957b23 100644 --- a/src/yvalve/PluginManager.cpp +++ b/src/yvalve/PluginManager.cpp @@ -55,7 +55,9 @@ //#define DEBUG_PLUGINS -using namespace Firebird; +namespace Firebird::Why +{ + namespace { @@ -163,7 +165,7 @@ namespace { return confFile.hasData() ? newParam(confFile->findParameter(name)) : NULL; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -176,7 +178,7 @@ namespace { return confFile.hasData() ? newParam(confFile->findParameter(name, value)) : NULL; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -206,7 +208,7 @@ namespace return newParam(&p[n + pos]); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -240,7 +242,7 @@ namespace return rc; } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -304,7 +306,7 @@ namespace }; // Controls module, containing plugins. - class PluginModule : public Firebird::RefCounted, public GlobalStorage + class PluginModule : public RefCounted, public GlobalStorage { public: PluginModule(ModuleLoader::Module* pmodule, const PathName& pname); @@ -401,15 +403,15 @@ namespace if (cleanup) { // Pause timer thread for cleanup period - MutexLockGuard timerPause(Why::pauseTimer(), FB_FUNCTION); + MutexLockGuard timerPause(pauseTimer(), FB_FUNCTION); cleanup->doClean(); } } PathName name; - Firebird::AutoPtr module; - Firebird::IPluginModule* cleanup; + AutoPtr module; + IPluginModule* cleanup; ObjectsArray regPlugins; PluginModule* next; PluginModule** prev; @@ -609,7 +611,7 @@ namespace FbLocalStatus ls; IPluginBase* plugin = module->getPlugin(regPlugin).factory->createPlugin(&ls, par); - if (plugin && !(ls->getState() & Firebird::IStatus::STATE_ERRORS)) + if (plugin && !(ls->getState() & IStatus::STATE_ERRORS)) { plugin->setOwner(par); return plugin; @@ -716,7 +718,7 @@ namespace if (refCounter != 0) return 1; - if (Why::timerThreadStopped() && !processingDelayedDelete && delayedDelete) + if (timerThreadStopped() && !processingDelayedDelete && delayedDelete) { // delay delete addRef(); @@ -842,7 +844,7 @@ namespace namesList.alltrim(" \t"); next(status); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -943,7 +945,7 @@ namespace return; } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -1011,11 +1013,11 @@ namespace return p; next(status); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) break; } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -1039,8 +1041,6 @@ namespace } // anonymous namespace -namespace Firebird { - PluginManager::PluginManager() { MutexLockGuard g(plugins->mutex, FB_FUNCTION); @@ -1136,8 +1136,8 @@ void PluginManager::unregisterModule(IPluginModule* cleanup) // exit() is called by client of embedded server. Shutdown ourselves. #ifdef WIN_NT - if (!Firebird::dDllUnloadTID) - Firebird::dDllUnloadTID = GetCurrentThreadId(); + if (!dDllUnloadTID) + dDllUnloadTID = GetCurrentThreadId(); #endif fb_shutdown(10000, fb_shutrsn_exit_called); @@ -1195,7 +1195,7 @@ IConfig* PluginManager::getConfig(CheckStatusWrapper* status, const char* filena rc->addRef(); return rc; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } @@ -1252,7 +1252,6 @@ void PluginManager::deleteDelayed() ConfiguredPlugin::processDelayedDelete(); } -} // namespace Firebird namespace { @@ -1291,8 +1290,6 @@ InitInstance dataCache; } // anonymous namespace -namespace Firebird { - /****************************************************************************** * * Static instance of the root and install directories detector @@ -1348,7 +1345,7 @@ class ConfigManager : public AutoIface config; + RefPtr config; expandDatabaseName(dbName, dummy, &config); IFirebirdConf* firebirdConf = FB_NEW FirebirdConf(config); @@ -1381,4 +1378,5 @@ class ConfigManager : public AutoIface > { @@ -58,6 +60,7 @@ class PluginManager : public AutoIface -namespace Why +namespace Firebird::Why { @@ -75,21 +75,21 @@ template class HandleArray { public: - explicit HandleArray(Firebird::MemoryPool& pool) + explicit HandleArray(MemoryPool& pool) : array(pool) { } void add(T* obj) { - Firebird::MutexLockGuard guard(mtx, FB_FUNCTION); + MutexLockGuard guard(mtx, FB_FUNCTION); array.add(obj); } void remove(T* obj) { - Firebird::MutexLockGuard guard(mtx, FB_FUNCTION); + MutexLockGuard guard(mtx, FB_FUNCTION); FB_SIZE_T pos; if (array.find(obj, pos)) @@ -98,7 +98,7 @@ class HandleArray void destroy(unsigned dstrFlags) { - Firebird::MutexLockGuard guard(mtx, FB_FUNCTION); + MutexLockGuard guard(mtx, FB_FUNCTION); // Call destroy() only once even if handle is not removed from array // by this call for any reason @@ -120,12 +120,12 @@ class HandleArray } private: - Firebird::Mutex mtx; - Firebird::SortedArray array; + Mutex mtx; + SortedArray array; }; template -class YHelper : public Firebird::RefCntIface, public YObject +class YHelper : public RefCntIface, public YObject { public: typedef typename Intf::Declaration NextInterface; @@ -137,9 +137,9 @@ class YHelper : public Firebird::RefCntIface, public YObject explicit YHelper(NextInterface* aNext, const char* m = NULL) : #ifdef DEV_BUILD - Firebird::RefCntIface(m), + RefCntIface(m), #endif - next(Firebird::REF_NO_INCR, aNext) + next(REF_NO_INCR, aNext) { } int release() override @@ -171,7 +171,7 @@ class YHelper : public Firebird::RefCntIface, public YObject } } - Firebird::RefPtr next; + RefPtr next; }; template @@ -204,52 +204,52 @@ typedef AtomicYPtr AtomicAttPtr; typedef AtomicYPtr AtomicTraPtr; class YEvents final : - public YHelper > + public YHelper> { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_events_handle; - YEvents(YAttachment* aAttachment, Firebird::IEvents* aNext, Firebird::IEventCallback* aCallback); + YEvents(YAttachment* aAttachment, IEvents* aNext, IEventCallback* aCallback); void destroy(unsigned dstrFlags) override; FB_API_HANDLE& getHandle(); // IEvents implementation - void cancel(Firebird::CheckStatusWrapper* status) override; - void deprecatedCancel(Firebird::CheckStatusWrapper* status) override; + void cancel(CheckStatusWrapper* status) override; + void deprecatedCancel(CheckStatusWrapper* status) override; public: AtomicAttPtr attachment; - Firebird::RefPtr callback; + RefPtr callback; private: - Firebird::AtomicCounter destroyed; + AtomicCounter destroyed; }; class YRequest final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_req_handle; - YRequest(YAttachment* aAttachment, Firebird::IRequest* aNext); + YRequest(YAttachment* aAttachment, IRequest* aNext); void destroy(unsigned dstrFlags) override; isc_req_handle& getHandle(); // IRequest implementation - void receive(Firebird::CheckStatusWrapper* status, int level, unsigned int msgType, + void receive(CheckStatusWrapper* status, int level, unsigned int msgType, unsigned int length, void* message) override; - void send(Firebird::CheckStatusWrapper* status, int level, unsigned int msgType, + void send(CheckStatusWrapper* status, int level, unsigned int msgType, unsigned int length, const void* message) override; - void getInfo(Firebird::CheckStatusWrapper* status, int level, unsigned int itemsLength, + void getInfo(CheckStatusWrapper* status, int level, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - void start(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, int level) override; - void startAndSend(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, int level, + void start(CheckStatusWrapper* status, ITransaction* transaction, int level) override; + void startAndSend(CheckStatusWrapper* status, ITransaction* transaction, int level, unsigned int msgType, unsigned int length, const void* message) override; - void unwind(Firebird::CheckStatusWrapper* status, int level) override; - void free(Firebird::CheckStatusWrapper* status) override; - void deprecatedFree(Firebird::CheckStatusWrapper* status) override; + void unwind(CheckStatusWrapper* status, int level) override; + void free(CheckStatusWrapper* status) override; + void deprecatedFree(CheckStatusWrapper* status) override; public: AtomicAttPtr attachment; @@ -257,41 +257,41 @@ class YRequest final : }; class YTransaction final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_trans_handle; - YTransaction(YAttachment* aAttachment, Firebird::ITransaction* aNext); + YTransaction(YAttachment* aAttachment, ITransaction* aNext); void destroy(unsigned dstrFlags) override; isc_tr_handle& getHandle(); // ITransaction implementation - void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - void prepare(Firebird::CheckStatusWrapper* status, unsigned int msgLength, + void prepare(CheckStatusWrapper* status, unsigned int msgLength, const unsigned char* message) override; - void commit(Firebird::CheckStatusWrapper* status) override; - void commitRetaining(Firebird::CheckStatusWrapper* status) override; - void rollback(Firebird::CheckStatusWrapper* status) override; - void rollbackRetaining(Firebird::CheckStatusWrapper* status) override; - void disconnect(Firebird::CheckStatusWrapper* status) override; - Firebird::ITransaction* join(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction) override; - Firebird::ITransaction* validate(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* testAtt) override; - YTransaction* enterDtc(Firebird::CheckStatusWrapper* status) override; - void deprecatedCommit(Firebird::CheckStatusWrapper* status) override; - void deprecatedRollback(Firebird::CheckStatusWrapper* status) override; - void deprecatedDisconnect(Firebird::CheckStatusWrapper* status) override; - - void addCleanupHandler(Firebird::CheckStatusWrapper* status, CleanupCallback* callback); + void commit(CheckStatusWrapper* status) override; + void commitRetaining(CheckStatusWrapper* status) override; + void rollback(CheckStatusWrapper* status) override; + void rollbackRetaining(CheckStatusWrapper* status) override; + void disconnect(CheckStatusWrapper* status) override; + ITransaction* join(CheckStatusWrapper* status, ITransaction* transaction) override; + ITransaction* validate(CheckStatusWrapper* status, IAttachment* testAtt) override; + YTransaction* enterDtc(CheckStatusWrapper* status) override; + void deprecatedCommit(CheckStatusWrapper* status) override; + void deprecatedRollback(CheckStatusWrapper* status) override; + void deprecatedDisconnect(CheckStatusWrapper* status) override; + + void addCleanupHandler(CheckStatusWrapper* status, CleanupCallback* callback); void selfCheck(); public: AtomicAttPtr attachment; HandleArray childBlobs; HandleArray childCursors; - Firebird::Array cleanupHandlers; + Array cleanupHandlers; private: YTransaction(YTransaction* from) @@ -310,30 +310,30 @@ class YTransaction final : } }; -typedef Firebird::RefPtr NextTransaction; +typedef RefPtr NextTransaction; class YBlob final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_segstr_handle; - YBlob(YAttachment* aAttachment, YTransaction* aTransaction, Firebird::IBlob* aNext); + YBlob(YAttachment* aAttachment, YTransaction* aTransaction, IBlob* aNext); void destroy(unsigned dstrFlags) override; isc_blob_handle& getHandle(); // IBlob implementation - void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - int getSegment(Firebird::CheckStatusWrapper* status, unsigned int length, void* buffer, + int getSegment(CheckStatusWrapper* status, unsigned int length, void* buffer, unsigned int* segmentLength) override; - void putSegment(Firebird::CheckStatusWrapper* status, unsigned int length, const void* buffer) override; - void cancel(Firebird::CheckStatusWrapper* status) override; - void close(Firebird::CheckStatusWrapper* status) override; - int seek(Firebird::CheckStatusWrapper* status, int mode, int offset) override; - void deprecatedCancel(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; + void putSegment(CheckStatusWrapper* status, unsigned int length, const void* buffer) override; + void cancel(CheckStatusWrapper* status) override; + void close(CheckStatusWrapper* status) override; + int seek(CheckStatusWrapper* status, int mode, int offset) override; + void deprecatedCancel(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; public: AtomicAttPtr attachment; @@ -341,31 +341,31 @@ class YBlob final : }; class YResultSet final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_result_set; - YResultSet(YAttachment* anAttachment, YTransaction* aTransaction, Firebird::IResultSet* aNext); + YResultSet(YAttachment* anAttachment, YTransaction* aTransaction, IResultSet* aNext); YResultSet(YAttachment* anAttachment, YTransaction* aTransaction, YStatement* aStatement, - Firebird::IResultSet* aNext); + IResultSet* aNext); void destroy(unsigned dstrFlags) override; // IResultSet implementation - int fetchNext(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchPrior(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchFirst(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchLast(Firebird::CheckStatusWrapper* status, void* message) override; - int fetchAbsolute(Firebird::CheckStatusWrapper* status, int position, void* message) override; - int fetchRelative(Firebird::CheckStatusWrapper* status, int offset, void* message) override; - FB_BOOLEAN isEof(Firebird::CheckStatusWrapper* status) override; - FB_BOOLEAN isBof(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; - void setDelayedOutputFormat(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* format) override; - void getInfo(Firebird::CheckStatusWrapper* status, + int fetchNext(CheckStatusWrapper* status, void* message) override; + int fetchPrior(CheckStatusWrapper* status, void* message) override; + int fetchFirst(CheckStatusWrapper* status, void* message) override; + int fetchLast(CheckStatusWrapper* status, void* message) override; + int fetchAbsolute(CheckStatusWrapper* status, int position, void* message) override; + int fetchRelative(CheckStatusWrapper* status, int offset, void* message) override; + FB_BOOLEAN isEof(CheckStatusWrapper* status) override; + FB_BOOLEAN isBof(CheckStatusWrapper* status) override; + IMessageMetadata* getMetadata(CheckStatusWrapper* status) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; + void setDelayedOutputFormat(CheckStatusWrapper* status, IMessageMetadata* format) override; + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; @@ -376,30 +376,30 @@ class YResultSet final : }; class YBatch final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_result_set; // isc_bad_batch - YBatch(YAttachment* anAttachment, Firebird::IBatch* aNext); + YBatch(YAttachment* anAttachment, IBatch* aNext); void destroy(unsigned dstrFlags) override; // IBatch implementation - void add(Firebird::CheckStatusWrapper* status, unsigned count, const void* inBuffer) override; - void addBlob(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer, ISC_QUAD* blobId, + void add(CheckStatusWrapper* status, unsigned count, const void* inBuffer) override; + void addBlob(CheckStatusWrapper* status, unsigned length, const void* inBuffer, ISC_QUAD* blobId, unsigned parLength, const unsigned char* par) override; - void appendBlobData(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; - void addBlobStream(Firebird::CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; - unsigned getBlobAlignment(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override; - void registerBlob(Firebird::CheckStatusWrapper* status, const ISC_QUAD* existingBlob, ISC_QUAD* blobId) override; - Firebird::IBatchCompletionState* execute(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction) override; - void cancel(Firebird::CheckStatusWrapper* status) override; - void setDefaultBpb(Firebird::CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; - void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, + void appendBlobData(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; + void addBlobStream(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; + unsigned getBlobAlignment(CheckStatusWrapper* status) override; + IMessageMetadata* getMetadata(CheckStatusWrapper* status) override; + void registerBlob(CheckStatusWrapper* status, const ISC_QUAD* existingBlob, ISC_QUAD* blobId) override; + IBatchCompletionState* execute(CheckStatusWrapper* status, ITransaction* transaction) override; + void cancel(CheckStatusWrapper* status) override; + void setDefaultBpb(CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; public: @@ -408,19 +408,19 @@ class YBatch final : class YReplicator final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_repl_handle; - YReplicator(YAttachment* anAttachment, Firebird::IReplicator* aNext); + YReplicator(YAttachment* anAttachment, IReplicator* aNext); void destroy(unsigned dstrFlags) override; // IReplicator implementation - void process(Firebird::CheckStatusWrapper* status, unsigned length, const unsigned char* data) override; - void close(Firebird::CheckStatusWrapper* status) override; - void deprecatedClose(Firebird::CheckStatusWrapper* status) override; + void process(CheckStatusWrapper* status, unsigned length, const unsigned char* data) override; + void close(CheckStatusWrapper* status) override; + void deprecatedClose(CheckStatusWrapper* status) override; public: AtomicAttPtr attachment; @@ -434,58 +434,58 @@ class YMetadata : flag(false), input(in) { } - Firebird::IMessageMetadata* get(Firebird::IStatement* next, YStatement* statement); + IMessageMetadata* get(IStatement* next, YStatement* statement); private: - Firebird::RefPtr metadata; + RefPtr metadata; volatile bool flag; bool input; }; class YStatement final : - public YHelper > + public YHelper > { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_stmt_handle; - YStatement(YAttachment* aAttachment, Firebird::IStatement* aNext); + YStatement(YAttachment* aAttachment, IStatement* aNext); void destroy(unsigned dstrFlags) override; // IStatement implementation - void getInfo(Firebird::CheckStatusWrapper* status, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - unsigned getType(Firebird::CheckStatusWrapper* status) override; - const char* getPlan(Firebird::CheckStatusWrapper* status, FB_BOOLEAN detailed) override; - ISC_UINT64 getAffectedRecords(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getInputMetadata(Firebird::CheckStatusWrapper* status) override; - Firebird::IMessageMetadata* getOutputMetadata(Firebird::CheckStatusWrapper* status) override; - Firebird::ITransaction* execute(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, - Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, void* outBuffer) override; - Firebird::IResultSet* openCursor(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, - Firebird::IMessageMetadata* inMetadata, void* inBuffer, Firebird::IMessageMetadata* outMetadata, + unsigned getType(CheckStatusWrapper* status) override; + const char* getPlan(CheckStatusWrapper* status, FB_BOOLEAN detailed) override; + ISC_UINT64 getAffectedRecords(CheckStatusWrapper* status) override; + IMessageMetadata* getInputMetadata(CheckStatusWrapper* status) override; + IMessageMetadata* getOutputMetadata(CheckStatusWrapper* status) override; + ITransaction* execute(CheckStatusWrapper* status, ITransaction* transaction, + IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, void* outBuffer) override; + IResultSet* openCursor(CheckStatusWrapper* status, ITransaction* transaction, + IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata, unsigned int flags) override; - void setCursorName(Firebird::CheckStatusWrapper* status, const char* name) override; - void free(Firebird::CheckStatusWrapper* status) override; - void deprecatedFree(Firebird::CheckStatusWrapper* status) override; - unsigned getFlags(Firebird::CheckStatusWrapper* status) override; - - unsigned int getTimeout(Firebird::CheckStatusWrapper* status) override; - void setTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - YBatch* createBatch(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* inMetadata, + void setCursorName(CheckStatusWrapper* status, const char* name) override; + void free(CheckStatusWrapper* status) override; + void deprecatedFree(CheckStatusWrapper* status) override; + unsigned getFlags(CheckStatusWrapper* status) override; + + unsigned int getTimeout(CheckStatusWrapper* status) override; + void setTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + YBatch* createBatch(CheckStatusWrapper* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; - unsigned getMaxInlineBlobSize(Firebird::CheckStatusWrapper* status) override; - void setMaxInlineBlobSize(Firebird::CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxInlineBlobSize(CheckStatusWrapper* status) override; + void setMaxInlineBlobSize(CheckStatusWrapper* status, unsigned size) override; public: AtomicAttPtr attachment; - Firebird::Mutex statementMutex; + Mutex statementMutex; YResultSet* cursor; - Firebird::IMessageMetadata* getMetadata(bool in, Firebird::IStatement* next); + IMessageMetadata* getMetadata(bool in, IStatement* next); private: YMetadata input, output; @@ -504,18 +504,18 @@ class EnterCount } int enterCount; - Firebird::Mutex enterMutex; + Mutex enterMutex; }; class YAttachment final : - public YHelper >, + public YHelper >, public EnterCount { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_db_handle; - YAttachment(Firebird::IProvider* aProvider, Firebird::IAttachment* aNext, - const Firebird::PathName& aDbPath); + YAttachment(IProvider* aProvider, IAttachment* aNext, + const PathName& aDbPath); ~YAttachment(); void destroy(unsigned dstrFlags) override; @@ -524,81 +524,81 @@ class YAttachment final : void getOdsVersion(USHORT* majorVersion, USHORT* minorVersion); // IAttachment implementation - void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength, + void getInfo(CheckStatusWrapper* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) override; - YTransaction* startTransaction(Firebird::CheckStatusWrapper* status, unsigned int tpbLength, + YTransaction* startTransaction(CheckStatusWrapper* status, unsigned int tpbLength, const unsigned char* tpb) override; - YTransaction* reconnectTransaction(Firebird::CheckStatusWrapper* status, unsigned int length, + YTransaction* reconnectTransaction(CheckStatusWrapper* status, unsigned int length, const unsigned char* id) override; - YRequest* compileRequest(Firebird::CheckStatusWrapper* status, unsigned int blrLength, + YRequest* compileRequest(CheckStatusWrapper* status, unsigned int blrLength, const unsigned char* blr) override; - void transactRequest(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + void transactRequest(CheckStatusWrapper* status, ITransaction* transaction, unsigned int blrLength, const unsigned char* blr, unsigned int inMsgLength, const unsigned char* inMsg, unsigned int outMsgLength, unsigned char* outMsg) override; - YBlob* createBlob(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + YBlob* createBlob(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int bpbLength, const unsigned char* bpb) override; - YBlob* openBlob(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + YBlob* openBlob(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int bpbLength, const unsigned char* bpb) override; - int getSlice(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + int getSlice(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int sdlLength, const unsigned char* sdl, unsigned int paramLength, const unsigned char* param, int sliceLength, unsigned char* slice) override; - void putSlice(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, ISC_QUAD* id, + void putSlice(CheckStatusWrapper* status, ITransaction* transaction, ISC_QUAD* id, unsigned int sdlLength, const unsigned char* sdl, unsigned int paramLength, const unsigned char* param, int sliceLength, unsigned char* slice) override; - void executeDyn(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, unsigned int length, + void executeDyn(CheckStatusWrapper* status, ITransaction* transaction, unsigned int length, const unsigned char* dyn) override; - YStatement* prepare(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra, + YStatement* prepare(CheckStatusWrapper* status, ITransaction* tra, unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, unsigned int flags) override; - Firebird::ITransaction* execute(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + ITransaction* execute(CheckStatusWrapper* status, ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, - Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, void* outBuffer) override; - Firebird::IResultSet* openCursor(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, void* outBuffer) override; + IResultSet* openCursor(CheckStatusWrapper* status, ITransaction* transaction, unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, - Firebird::IMessageMetadata* inMetadata, void* inBuffer, Firebird::IMessageMetadata* outMetadata, + IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata, const char* cursorName, unsigned int cursorFlags) override; - YEvents* queEvents(Firebird::CheckStatusWrapper* status, Firebird::IEventCallback* callback, + YEvents* queEvents(CheckStatusWrapper* status, IEventCallback* callback, unsigned int length, const unsigned char* eventsData) override; - void cancelOperation(Firebird::CheckStatusWrapper* status, int option) override; - void ping(Firebird::CheckStatusWrapper* status) override; - void detach(Firebird::CheckStatusWrapper* status) override; - void dropDatabase(Firebird::CheckStatusWrapper* status) override; - void deprecatedDetach(Firebird::CheckStatusWrapper* status) override; - void deprecatedDropDatabase(Firebird::CheckStatusWrapper* status) override; - - void addCleanupHandler(Firebird::CheckStatusWrapper* status, CleanupCallback* callback); - YTransaction* getTransaction(Firebird::ITransaction* tra); - void getNextTransaction(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* tra, NextTransaction& next); - void execute(Firebird::CheckStatusWrapper* status, isc_tr_handle* traHandle, + void cancelOperation(CheckStatusWrapper* status, int option) override; + void ping(CheckStatusWrapper* status) override; + void detach(CheckStatusWrapper* status) override; + void dropDatabase(CheckStatusWrapper* status) override; + void deprecatedDetach(CheckStatusWrapper* status) override; + void deprecatedDropDatabase(CheckStatusWrapper* status) override; + + void addCleanupHandler(CheckStatusWrapper* status, CleanupCallback* callback); + YTransaction* getTransaction(ITransaction* tra); + void getNextTransaction(CheckStatusWrapper* status, ITransaction* tra, NextTransaction& next); + void execute(CheckStatusWrapper* status, isc_tr_handle* traHandle, unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, - Firebird::IMessageMetadata* inMetadata, void* inBuffer, - Firebird::IMessageMetadata* outMetadata, void* outBuffer); - - unsigned int getIdleTimeout(Firebird::CheckStatusWrapper* status) override; - void setIdleTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - unsigned int getStatementTimeout(Firebird::CheckStatusWrapper* status) override; - void setStatementTimeout(Firebird::CheckStatusWrapper* status, unsigned int timeOut) override; - YBatch* createBatch(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction, + IMessageMetadata* inMetadata, void* inBuffer, + IMessageMetadata* outMetadata, void* outBuffer); + + unsigned int getIdleTimeout(CheckStatusWrapper* status) override; + void setIdleTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + unsigned int getStatementTimeout(CheckStatusWrapper* status) override; + void setStatementTimeout(CheckStatusWrapper* status, unsigned int timeOut) override; + YBatch* createBatch(CheckStatusWrapper* status, ITransaction* transaction, unsigned stmtLength, const char* sqlStmt, unsigned dialect, - Firebird::IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; - YReplicator* createReplicator(Firebird::CheckStatusWrapper* status) override; + IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) override; + YReplicator* createReplicator(CheckStatusWrapper* status) override; - unsigned getMaxBlobCacheSize(Firebird::CheckStatusWrapper* status) override; - void setMaxBlobCacheSize(Firebird::CheckStatusWrapper* status, unsigned size) override; - unsigned getMaxInlineBlobSize(Firebird::CheckStatusWrapper* status) override; - void setMaxInlineBlobSize(Firebird::CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxBlobCacheSize(CheckStatusWrapper* status) override; + void setMaxBlobCacheSize(CheckStatusWrapper* status, unsigned size) override; + unsigned getMaxInlineBlobSize(CheckStatusWrapper* status) override; + void setMaxInlineBlobSize(CheckStatusWrapper* status, unsigned size) override; public: - Firebird::IProvider* provider; - Firebird::PathName dbPath; + IProvider* provider; + PathName dbPath; HandleArray childBlobs; HandleArray childEvents; HandleArray childRequests; HandleArray childStatements; HandleArray childIscStatements; HandleArray childTransactions; - Firebird::Array cleanupHandlers; - Firebird::StatusHolder savedStatus; // Do not use raise() method of this class in yValve. + Array cleanupHandlers; + StatusHolder savedStatus; // Do not use raise() method of this class in yValve. private: USHORT cachedOdsMajorVersion = 0; @@ -606,13 +606,13 @@ class YAttachment final : }; class YService final : - public YHelper >, + public YHelper >, public EnterCount { public: static constexpr ISC_STATUS ERROR_CODE = isc_bad_svc_handle; - YService(Firebird::IProvider* aProvider, Firebird::IService* aNext, bool utf8, Dispatcher* yProvider); + YService(IProvider* aProvider, IService* aNext, bool utf8, Dispatcher* yProvider); ~YService(); void shutdown(); @@ -620,32 +620,32 @@ class YService final : isc_svc_handle& getHandle() noexcept; // IService implementation - void detach(Firebird::CheckStatusWrapper* status) override; - void deprecatedDetach(Firebird::CheckStatusWrapper* status) override; - void query(Firebird::CheckStatusWrapper* status, + void detach(CheckStatusWrapper* status) override; + void deprecatedDetach(CheckStatusWrapper* status) override; + void query(CheckStatusWrapper* status, unsigned int sendLength, const unsigned char* sendItems, unsigned int receiveLength, const unsigned char* receiveItems, unsigned int bufferLength, unsigned char* buffer) override; - void start(Firebird::CheckStatusWrapper* status, + void start(CheckStatusWrapper* status, unsigned int spbLength, const unsigned char* spb) override; - void cancel(Firebird::CheckStatusWrapper* status) override; + void cancel(CheckStatusWrapper* status) override; public: - typedef Firebird::IService NextInterface; + typedef IService NextInterface; typedef YService YRef; private: - Firebird::IProvider* provider; + IProvider* provider; bool utf8Connection; // Client talks to us using UTF8, else - system default charset public: - Firebird::RefPtr alternativeHandle; - Firebird::ClumpletWriter attachSpb; - Firebird::RefPtr ownProvider; + RefPtr alternativeHandle; + ClumpletWriter attachSpb; + RefPtr ownProvider; }; class Dispatcher final : - public Firebird::StdPlugin > + public StdPlugin > { public: Dispatcher() noexcept @@ -653,47 +653,47 @@ class Dispatcher final : { } // IProvider implementation - YAttachment* attachDatabase(Firebird::CheckStatusWrapper* status, const char* filename, + YAttachment* attachDatabase(CheckStatusWrapper* status, const char* filename, unsigned int dpbLength, const unsigned char* dpb) override; - YAttachment* createDatabase(Firebird::CheckStatusWrapper* status, const char* filename, + YAttachment* createDatabase(CheckStatusWrapper* status, const char* filename, unsigned int dpbLength, const unsigned char* dpb) override; - YService* attachServiceManager(Firebird::CheckStatusWrapper* status, const char* serviceName, + YService* attachServiceManager(CheckStatusWrapper* status, const char* serviceName, unsigned int spbLength, const unsigned char* spb) override; - void shutdown(Firebird::CheckStatusWrapper* status, unsigned int timeout, const int reason) override; - void setDbCryptCallback(Firebird::CheckStatusWrapper* status, - Firebird::ICryptKeyCallback* cryptCallback) override; + void shutdown(CheckStatusWrapper* status, unsigned int timeout, const int reason) override; + void setDbCryptCallback(CheckStatusWrapper* status, + ICryptKeyCallback* cryptCallback) override; void destroy(unsigned) noexcept { } public: - Firebird::IService* internalServiceAttach(Firebird::CheckStatusWrapper* status, - const Firebird::PathName& svcName, Firebird::ClumpletReader& spb, - std::function start, - Firebird::IProvider** retProvider); + IService* internalServiceAttach(CheckStatusWrapper* status, + const PathName& svcName, ClumpletReader& spb, + std::function start, + IProvider** retProvider); private: - YAttachment* attachOrCreateDatabase(Firebird::CheckStatusWrapper* status, bool createFlag, + YAttachment* attachOrCreateDatabase(CheckStatusWrapper* status, bool createFlag, const char* filename, unsigned int dpbLength, const unsigned char* dpb); - Firebird::ICryptKeyCallback* cryptCallback; + ICryptKeyCallback* cryptCallback; }; class UtilInterface final : - public Firebird::AutoIface > + public AutoIface > { // IUtil implementation public: - void getFbVersion(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* att, - Firebird::IVersionCallback* callback) override; - void loadBlob(Firebird::CheckStatusWrapper* status, ISC_QUAD* blobId, Firebird::IAttachment* att, - Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt) override; - void dumpBlob(Firebird::CheckStatusWrapper* status, ISC_QUAD* blobId, Firebird::IAttachment* att, - Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt) override; - void getPerfCounters(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* att, + void getFbVersion(CheckStatusWrapper* status, IAttachment* att, + IVersionCallback* callback) override; + void loadBlob(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, + ITransaction* tra, const char* file, FB_BOOLEAN txt) override; + void dumpBlob(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, + ITransaction* tra, const char* file, FB_BOOLEAN txt) override; + void getPerfCounters(CheckStatusWrapper* status, IAttachment* att, const char* countersSet, ISC_INT64* counters) override; // in perf.cpp - YAttachment* executeCreateDatabase(Firebird::CheckStatusWrapper* status, + YAttachment* executeCreateDatabase(CheckStatusWrapper* status, unsigned stmtLength, const char* creatDBstatement, unsigned dialect, FB_BOOLEAN* stmtIsCreateDb = nullptr) override { @@ -701,7 +701,7 @@ class UtilInterface final : 0, nullptr, stmtIsCreateDb); } - YAttachment* executeCreateDatabase2(Firebird::CheckStatusWrapper* status, + YAttachment* executeCreateDatabase2(CheckStatusWrapper* status, unsigned stmtLength, const char* creatDBstatement, unsigned dialect, unsigned dpbLength, const unsigned char* dpb, FB_BOOLEAN* stmtIsCreateDb = nullptr) override; @@ -711,39 +711,40 @@ class UtilInterface final : unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions) override; ISC_DATE encodeDate(unsigned year, unsigned month, unsigned day) override; ISC_TIME encodeTime(unsigned hours, unsigned minutes, unsigned seconds, unsigned fractions) override; - unsigned formatStatus(char* buffer, unsigned bufferSize, Firebird::IStatus* status) override; + unsigned formatStatus(char* buffer, unsigned bufferSize, IStatus* status) override; unsigned getClientVersion() override; - Firebird::IXpbBuilder* getXpbBuilder(Firebird::CheckStatusWrapper* status, + IXpbBuilder* getXpbBuilder(CheckStatusWrapper* status, unsigned kind, const unsigned char* buf, unsigned len) override; - unsigned setOffsets(Firebird::CheckStatusWrapper* status, Firebird::IMessageMetadata* metadata, - Firebird::IOffsetsCallback* callback) override; - Firebird::IDecFloat16* getDecFloat16(Firebird::CheckStatusWrapper* status) override; - Firebird::IDecFloat34* getDecFloat34(Firebird::CheckStatusWrapper* status) override; - void decodeTimeTz(Firebird::CheckStatusWrapper* status, const ISC_TIME_TZ* timeTz, + unsigned setOffsets(CheckStatusWrapper* status, IMessageMetadata* metadata, + IOffsetsCallback* callback) override; + IDecFloat16* getDecFloat16(CheckStatusWrapper* status) override; + IDecFloat34* getDecFloat34(CheckStatusWrapper* status) override; + void decodeTimeTz(CheckStatusWrapper* status, const ISC_TIME_TZ* timeTz, unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) override; - void decodeTimeStampTz(Firebird::CheckStatusWrapper* status, const ISC_TIMESTAMP_TZ* timeStampTz, + void decodeTimeStampTz(CheckStatusWrapper* status, const ISC_TIMESTAMP_TZ* timeStampTz, unsigned* year, unsigned* month, unsigned* day, unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) override; - void encodeTimeTz(Firebird::CheckStatusWrapper* status, ISC_TIME_TZ* timeTz, + void encodeTimeTz(CheckStatusWrapper* status, ISC_TIME_TZ* timeTz, unsigned hours, unsigned minutes, unsigned seconds, unsigned fractions, const char* timeZone) override; - void encodeTimeStampTz(Firebird::CheckStatusWrapper* status, ISC_TIMESTAMP_TZ* timeStampTz, + void encodeTimeStampTz(CheckStatusWrapper* status, ISC_TIMESTAMP_TZ* timeStampTz, unsigned year, unsigned month, unsigned day, unsigned hours, unsigned minutes, unsigned seconds, unsigned fractions, const char* timeZone) override; - Firebird::IInt128* getInt128(Firebird::CheckStatusWrapper* status) override; - void decodeTimeTzEx(Firebird::CheckStatusWrapper* status, const ISC_TIME_TZ_EX* timeEx, + IInt128* getInt128(CheckStatusWrapper* status) override; + void decodeTimeTzEx(CheckStatusWrapper* status, const ISC_TIME_TZ_EX* timeEx, unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) override; - void decodeTimeStampTzEx(Firebird::CheckStatusWrapper* status, const ISC_TIMESTAMP_TZ_EX* timeStampEx, + void decodeTimeStampTzEx(CheckStatusWrapper* status, const ISC_TIMESTAMP_TZ_EX* timeStampEx, unsigned* year, unsigned* month, unsigned* day, unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) override; - void convert(Firebird::CheckStatusWrapper* status, + void convert(CheckStatusWrapper* status, unsigned sourceType, unsigned sourceScale, unsigned sourceLength, const void* source, unsigned targetType, unsigned targetScale, unsigned targetLength, void* target) override; }; -} // namespace Why + +} // namespace Firebird::Why #endif // YVALVE_Y_OBJECTS_H diff --git a/src/yvalve/alt.cpp b/src/yvalve/alt.cpp index 23e7abaa40d..a2696db2299 100644 --- a/src/yvalve/alt.cpp +++ b/src/yvalve/alt.cpp @@ -46,7 +46,9 @@ #include "../jrd/event.h" #include "../yvalve/alt_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" + +using namespace Firebird; static ISC_STATUS executeSecurityCommand(ISC_STATUS*, const USER_SEC_DATA*, Auth::UserData&); @@ -827,8 +829,8 @@ namespace { template void copyField(T1& f, T2 from, short flag) { - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); if (flag && from) { @@ -864,25 +866,25 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp **************************************/ Auth::UserData userInfo; userInfo.op = Auth::ADD_OPER; - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); if (input_user_data->user_name) { - Firebird::string work = input_user_data->user_name; + string work = input_user_data->user_name; if (work.length() > USERNAME_LENGTH) { return user_error(status, isc_usrname_too_long); } const auto l = work.find(' '); - if (l != Firebird::string::npos) { + if (l != string::npos) { work.resize(l); } userInfo.user.set(&statusWrapper, work.c_str()); - Firebird::check(&statusWrapper); + check(&statusWrapper); userInfo.user.setEntered(&statusWrapper, 1); - Firebird::check(&statusWrapper); + check(&statusWrapper); } else { return user_error(status, isc_usrname_required); @@ -891,9 +893,9 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp if (input_user_data->password) { userInfo.pass.set(&statusWrapper, input_user_data->password); - Firebird::check(&statusWrapper); + check(&statusWrapper); userInfo.pass.setEntered(&statusWrapper, 1); - Firebird::check(&statusWrapper); + check(&statusWrapper); } else { return user_error(status, isc_password_required); @@ -927,25 +929,25 @@ ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS* status, const USER_SEC_DATA* **************************************/ Auth::UserData userInfo; userInfo.op = Auth::DEL_OPER; - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); if (input_user_data->user_name) { - Firebird::string work = input_user_data->user_name; + string work = input_user_data->user_name; if (work.length() > USERNAME_LENGTH) { return user_error(status, isc_usrname_too_long); } const auto l = work.find(' '); - if (l != Firebird::string::npos) { + if (l != string::npos) { work.resize(l); } userInfo.user.set(&statusWrapper, work.c_str()); - Firebird::check(&statusWrapper); + check(&statusWrapper); userInfo.user.setEntered(&statusWrapper, 1); - Firebird::check(&statusWrapper); + check(&statusWrapper); } else { return user_error(status, isc_usrname_required); @@ -972,18 +974,18 @@ ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA* **************************************/ Auth::UserData userInfo; userInfo.op = Auth::MOD_OPER; - Firebird::LocalStatus s; - Firebird::CheckStatusWrapper statusWrapper(&s); + LocalStatus s; + CheckStatusWrapper statusWrapper(&s); if (input_user_data->user_name) { - Firebird::string work = input_user_data->user_name; + string work = input_user_data->user_name; if (work.length() > USERNAME_LENGTH) { return user_error(status, isc_usrname_too_long); } const auto l = work.find(' '); - if (l != Firebird::string::npos) { + if (l != string::npos) { work.resize(l); } @@ -1040,7 +1042,7 @@ static ISC_STATUS executeSecurityCommand(ISC_STATUS* status, if (handle) { callRemoteServiceManager(status, handle, userInfo, NULL); - makePermanentVector(status); + Why::makePermanentVector(status); ISC_STATUS_ARRAY user_status; detachRemoteServiceManager(user_status, handle); diff --git a/src/yvalve/alt_proto.h b/src/yvalve/alt_proto.h index 55179b7e8cb..f42fa163c84 100644 --- a/src/yvalve/alt_proto.h +++ b/src/yvalve/alt_proto.h @@ -201,4 +201,3 @@ void API_ROUTINE CVT_move(const dsc*, dsc*, FPTR_ERROR); } // extern "C" #endif //ALT_PROTO_H - diff --git a/src/yvalve/array.cpp b/src/yvalve/array.cpp index c90c195d244..b92e7dd5a59 100644 --- a/src/yvalve/array.cpp +++ b/src/yvalve/array.cpp @@ -41,7 +41,7 @@ #include "../yvalve/gds_proto.h" #include "../yvalve/YObjects.h" #include "../common/StatusArg.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../common/utils_proto.h" #include @@ -143,8 +143,12 @@ ISC_STATUS API_ROUTINE isc_array_get_slice(ISC_STATUS* status, } -void iscArrayLookupBoundsImpl(Why::YAttachment* attachment, - Why::YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc) +namespace Firebird::Why +{ + + +void iscArrayLookupBoundsImpl(YAttachment* attachment, + YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc) { LocalStatus status; CheckStatusWrapper statusWrapper(&status); @@ -223,8 +227,8 @@ void iscArrayLookupBoundsImpl(Why::YAttachment* attachment, } -void iscArrayLookupDescImpl(Why::YAttachment* attachment, - Why::YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc, +void iscArrayLookupDescImpl(YAttachment* attachment, + YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc, MetaString* globalField) { LocalStatus status; @@ -325,6 +329,9 @@ void iscArrayLookupDescImpl(Why::YAttachment* attachment, } +} // namespace Firebird::Why + + ISC_STATUS API_ROUTINE isc_array_put_slice(ISC_STATUS* status, FB_API_HANDLE* db_handle, FB_API_HANDLE* trans_handle, diff --git a/src/yvalve/array_proto.h b/src/yvalve/array_proto.h index 894645ebbf7..c2f387d4a12 100644 --- a/src/yvalve/array_proto.h +++ b/src/yvalve/array_proto.h @@ -26,10 +26,17 @@ #include "../common/classes/MetaString.h" -namespace Why { +namespace Firebird::Why +{ class YAttachment; class YTransaction; -} + + void iscArrayLookupBoundsImpl(YAttachment* attachment, YTransaction* transaction, + const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc); + + void iscArrayLookupDescImpl(YAttachment* attachment, YTransaction* transaction, + const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc, MetaString* globalField); +} // namespace Firebird::Why #ifdef __cplusplus extern "C" { @@ -56,10 +63,4 @@ ISC_STATUS API_ROUTINE isc_array_set_desc(ISC_STATUS*, const SCHAR*, const SCHAR } /* extern "C" */ #endif -void iscArrayLookupBoundsImpl(Why::YAttachment* attachment, Why::YTransaction* transaction, - const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc); - -void iscArrayLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* transaction, - const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc, Firebird::MetaString* globalField); - #endif // DSQL_ARRAY_PROTO_H diff --git a/src/yvalve/blob.cpp b/src/yvalve/blob.cpp index 3ab860ed61d..32d48db6a86 100644 --- a/src/yvalve/blob.cpp +++ b/src/yvalve/blob.cpp @@ -37,7 +37,7 @@ #include "../yvalve/YObjects.h" #include "../common/StatusArg.h" #include "../common/utils_proto.h" -#include "../jrd/constants.h" +#include "../common/constants.h" using namespace Firebird; @@ -120,10 +120,17 @@ ISC_STATUS API_ROUTINE isc_blob_gen_bpb(ISC_STATUS* status, } +namespace Firebird::Why +{ + + // Lookup the blob subtype, character set and segment size information from the metadata, // given a relation/procedure name and column/parameter name. // It will fill in the information in the BLOB_DESC. -void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* transaction, + + +void iscBlobLookupDescImpl(YAttachment* attachment, + YTransaction* transaction, const UCHAR* relationName, const UCHAR* fieldName, ISC_BLOB_DESC* desc, UCHAR* global) { LocalStatus status; @@ -302,6 +309,9 @@ void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* tran } +} // namespace Firebird::Why + + ISC_STATUS API_ROUTINE isc_blob_set_desc(ISC_STATUS* status, const UCHAR* relation_name, const UCHAR* field_name, diff --git a/src/yvalve/blob_proto.h b/src/yvalve/blob_proto.h index 0a5440ccd29..5dc20023a3f 100644 --- a/src/yvalve/blob_proto.h +++ b/src/yvalve/blob_proto.h @@ -26,25 +26,17 @@ #include "../common/classes/RefCounted.h" -namespace Why { +namespace Firebird::Why +{ class YAttachment; class YTransaction; -} - -ISC_STATUS API_ROUTINE isc_blob_gen_bpb(ISC_STATUS*, const ISC_BLOB_DESC*, - const ISC_BLOB_DESC*, USHORT, UCHAR*, USHORT*); -ISC_STATUS API_ROUTINE isc_blob_lookup_desc(ISC_STATUS*, void**, void**, - const UCHAR*, const UCHAR*, ISC_BLOB_DESC*, UCHAR*); -ISC_STATUS API_ROUTINE isc_blob_set_desc(ISC_STATUS*, const UCHAR*, const UCHAR*, - SSHORT, SSHORT, SSHORT, ISC_BLOB_DESC*); - -void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* transaction, - const UCHAR* relationName, const UCHAR* fieldName, ISC_BLOB_DESC* desc, UCHAR* global); -// Only declared in ibase.h: -//void API_ROUTINE isc_blob_default_desc(ISC_BLOB_DESC* desc, -// const UCHAR*, const UCHAR*); + void iscBlobLookupDescImpl(YAttachment* attachment, YTransaction* transaction, + const UCHAR* relationName, const UCHAR* fieldName, ISC_BLOB_DESC* desc, UCHAR* global); + // Only declared in ibase.h: + //void API_ROUTINE isc_blob_default_desc(ISC_BLOB_DESC* desc, + // const UCHAR*, const UCHAR*); +} #endif // DSQL_BLOB_PROTO_H - diff --git a/src/yvalve/config/os/config_root.h b/src/yvalve/config/os/config_root.h index a96aa364f7e..a779c6da8be 100644 --- a/src/yvalve/config/os/config_root.h +++ b/src/yvalve/config/os/config_root.h @@ -52,15 +52,16 @@ getConfigFilePath() member function. **/ -class ConfigRoot : public Firebird::PermanentStorage +namespace Firebird::Why { - // we deal with names of files here - typedef Firebird::PathName string; + +class ConfigRoot : public PermanentStorage +{ private: void GetRoot() { - const Firebird::PathName* clRoot = Firebird::Config::getCommandLineRootDirectory(); + const PathName* clRoot = Config::getCommandLineRootDirectory(); if (clRoot) { root_dir = *clRoot; @@ -103,7 +104,7 @@ class ConfigRoot : public Firebird::PermanentStorage } private: - string root_dir, install_dir; + PathName root_dir, install_dir; // If the path ends with a separator, remove it. void fixPath() @@ -116,7 +117,7 @@ class ConfigRoot : public Firebird::PermanentStorage bool getRootFromEnvironment(const char* envName) { - string envValue; + PathName envValue; if (!fb_utils::readenv(envName, envValue)) return false; @@ -133,4 +134,7 @@ class ConfigRoot : public Firebird::PermanentStorage void operator=(const ConfigRoot&); }; + +} // namespace Firebird::Why + #endif // CONFIG_ROOT_H diff --git a/src/yvalve/config/os/darwin/config_root.cpp b/src/yvalve/config/os/darwin/config_root.cpp index 011fc0e67ef..9b3f472012b 100644 --- a/src/yvalve/config/os/darwin/config_root.cpp +++ b/src/yvalve/config/os/darwin/config_root.cpp @@ -47,9 +47,11 @@ #include -typedef Firebird::PathName string; +namespace Firebird::Why +{ + -static string getFrameworkFromBundle() +static PathName getFrameworkFromBundle() { // Attempt to locate the Firebird.framework bundle CFBundleRef fbFramework = CFBundleGetBundleWithIdentifier(CFSTR(DARWIN_FRAMEWORK_ID)); @@ -67,7 +69,7 @@ static string getFrameworkFromBundle() if (CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN, kCFStringEncodingMacRoman)) { - string dir = file_buff; + PathName dir = file_buff; dir += PathUtils::dir_sep; return dir; } @@ -79,33 +81,33 @@ static string getFrameworkFromBundle() return ""; } -static string getExecutablePath() +static PathName getExecutablePath() { char file_buff[MAXPATHLEN]; uint32_t bufsize = sizeof(file_buff); _NSGetExecutablePath(file_buff, &bufsize); char canonic[PATH_MAX]; if (!realpath(file_buff, canonic)) - Firebird::system_call_failed::raise("realpath"); - string bin_dir = canonic; + system_call_failed::raise("realpath"); + PathName bin_dir = canonic; // get rid of the filename int index = bin_dir.rfind(PathUtils::dir_sep); bin_dir = bin_dir.substr(0, index); // go to parent directory index = bin_dir.rfind(PathUtils::dir_sep, bin_dir.length()); - string dir = (index ? bin_dir.substr(0,index) : bin_dir) + PathUtils::dir_sep; + PathName dir = (index ? bin_dir.substr(0,index) : bin_dir) + PathUtils::dir_sep; return dir; } -static string getDlInfoPath() +static PathName getDlInfoPath() { Dl_info dlInfo; static int test = 1; if (dladdr(&test, &dlInfo) != 0) // non-zero is success in dladdr { - string next, dummy; + PathName next, dummy; PathUtils::splitLastComponent(next, dummy, dlInfo.dli_fname); - string dir; + PathName dir; PathUtils::splitLastComponent(dir, dummy, next); return dir; } @@ -166,3 +168,6 @@ void ConfigRoot::osConfigInstallDir() // As a last resort get it from the default install directory install_dir = FB_PREFIX; } + + +} // namespace Firebird::Why diff --git a/src/yvalve/config/os/posix/config_root.cpp b/src/yvalve/config/os/posix/config_root.cpp index c0698975245..85559039d12 100644 --- a/src/yvalve/config/os/posix/config_root.cpp +++ b/src/yvalve/config/os/posix/config_root.cpp @@ -35,7 +35,9 @@ #include "../common/os/path_utils.h" #include "binreloc.h" -typedef Firebird::PathName string; +namespace Firebird::Why +{ + /****************************************************************************** * @@ -72,7 +74,7 @@ void ConfigRoot::osConfigInstallDir() #ifdef ANDROID install_dir = temp; #else - string dummy; + PathName dummy; PathUtils::splitLastComponent(install_dir, dummy, temp); #endif free(temp); @@ -82,5 +84,8 @@ void ConfigRoot::osConfigInstallDir() #endif // As a last resort get it from the default install directory - install_dir = string(FB_PREFIX); + install_dir = PathName(FB_PREFIX); } + + +} // namespace Firebird::Why diff --git a/src/yvalve/config/os/win32/config_root.cpp b/src/yvalve/config/os/win32/config_root.cpp index 3658ee3d89d..c740d188c08 100644 --- a/src/yvalve/config/os/win32/config_root.cpp +++ b/src/yvalve/config/os/win32/config_root.cpp @@ -30,7 +30,8 @@ #include "../../../../common/dllinst.h" #include "../../../../yvalve/config/os/config_root.h" -using Firebird::PathName; +namespace Firebird::Why +{ /****************************************************************************** @@ -41,14 +42,14 @@ namespace { bool getPathFromHInstance(PathName& root) { - const HINSTANCE hDllInst = Firebird::hDllInst; - if (!hDllInst) + const HINSTANCE hDllInstLocal = hDllInst; + if (!hDllInstLocal) { return false; } char* filename = root.getBuffer(MAX_PATH); - GetModuleFileName(hDllInst, filename, MAX_PATH); + GetModuleFileName(hDllInstLocal, filename, MAX_PATH); root.recalculate_length(); @@ -79,7 +80,7 @@ void ConfigRoot::osConfigInstallDir() PathUtils::splitLastComponent(bin_dir, file_name, module_path); // search for the configuration file in the bin directory - PathUtils::concatPath(file_name, bin_dir, Firebird::CONFIG_FILE); + PathUtils::concatPath(file_name, bin_dir, CONFIG_FILE); DWORD attributes = GetFileAttributes(file_name.c_str()); if (attributes == INVALID_FILE_ATTRIBUTES || attributes == FILE_ATTRIBUTE_DIRECTORY) { @@ -89,7 +90,7 @@ void ConfigRoot::osConfigInstallDir() if (parent_dir.hasData()) { - PathUtils::concatPath(file_name, parent_dir, Firebird::CONFIG_FILE); + PathUtils::concatPath(file_name, parent_dir, CONFIG_FILE); attributes = GetFileAttributes(file_name.c_str()); if (attributes != INVALID_FILE_ATTRIBUTES && attributes != FILE_ATTRIBUTE_DIRECTORY) { @@ -112,3 +113,6 @@ void ConfigRoot::osConfigInstallDir() PathUtils::ensureSeparator(install_dir); } + + +} // namespace Firebird::Why diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index 162fa9d8d65..0816a2c1e3f 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -49,7 +49,7 @@ #include "../common/os/path_utils.h" #include "../common/dsc.h" #include "../common/TimeZoneUtil.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/status.h" #include "../common/os/os_utils.h" #include "../common/os/mac_utils.h" @@ -116,6 +116,8 @@ #include #endif +using namespace Firebird; + static char fb_prefix_val[MAXPATHLEN]; static char fb_prefix_lock_val[MAXPATHLEN]; static char fb_prefix_msg_val[MAXPATHLEN]; @@ -189,10 +191,6 @@ constexpr SLONG GENERIC_SQLCODE = -999; #include "../common/classes/SafeArg.h" #include "../common/classes/MsgPrint.h" -using Firebird::TimeStamp; -using Firebird::TimeZoneUtil; -using Firebird::BlrReader; - // This structure is used to parse the firebird.msg file. struct gds_msg { @@ -216,7 +214,7 @@ struct gds_ctl FPTR_PRINT_CALLBACK ctl_routine; // Call back void* ctl_user_arg; // User argument SSHORT ctl_language; - Firebird::string ctl_string; + string ctl_string; }; #ifdef DEV_BUILD @@ -239,7 +237,7 @@ static void blr_print_name(gds_ctl*); static void blr_print_verb(gds_ctl*, SSHORT); static int blr_print_word(gds_ctl*); -static void sanitize(Firebird::string& locale); +static void sanitize(string& locale); // New functions that try to be safe. static SLONG safe_interpret(char* const s, const FB_SIZE_T bufsize, @@ -248,7 +246,7 @@ static void safe_strncpy(char* target, const char* source, size_t bs) noexcept; // Useful only in Windows. The hardcoded definition for the English-only version // is too crude. -static bool GetProgramFilesDir(Firebird::PathName& output); +static bool GetProgramFilesDir(PathName& output); // Generic cleanup handlers @@ -260,9 +258,9 @@ struct clean_t void* clean_arg; }; -static Firebird::GlobalPtr cleanup_handlers_mutex; +static GlobalPtr cleanup_handlers_mutex; static clean_t* cleanup_handlers = NULL; -static Firebird::GlobalPtr global_msg_mutex; +static GlobalPtr global_msg_mutex; static gds_msg* global_default_msg = NULL; VoidPtr API_ROUTINE gds__alloc_debug(SLONG size_request, const TEXT* filename, ULONG lineno) @@ -270,7 +268,7 @@ VoidPtr API_ROUTINE gds__alloc_debug(SLONG size_request, const TEXT* filename, U try { #ifdef DEBUG_GDS_ALLOC - Firebird::CustomSourceLocation location{ + CustomSourceLocation location{ .fileName = filename, .line = static_cast(lineno) }; @@ -279,7 +277,7 @@ VoidPtr API_ROUTINE gds__alloc_debug(SLONG size_request, const TEXT* filename, U return getDefaultMemoryPool()->allocate(size_request); #endif } - catch (const Firebird::Exception&) + catch (const Exception&) { return NULL; } @@ -571,7 +569,7 @@ void API_ROUTINE isc_decode_sql_time(const GDS_TIME* sql_time, void* times_arg) **************************************/ tm* const times = static_cast(times_arg); memset(times, 0, sizeof(*times)); - Firebird::TimeStamp::decode_time(*sql_time, ×->tm_hour, ×->tm_min, ×->tm_sec); + TimeStamp::decode_time(*sql_time, ×->tm_hour, ×->tm_min, ×->tm_sec); } @@ -591,7 +589,7 @@ void API_ROUTINE isc_decode_timestamp(const GDS_TIMESTAMP* date, void* times_arg * **************************************/ tm* const times = static_cast(times_arg); - Firebird::TimeStamp::decode_timestamp(*date, times); + TimeStamp::decode_timestamp(*date, times); } @@ -661,7 +659,7 @@ void API_ROUTINE isc_encode_sql_time(const void* times_arg, GDS_TIME* isc_time) * **************************************/ const tm* const times = static_cast(times_arg); - *isc_time = Firebird::TimeStamp::encode_time(times->tm_hour, times->tm_min, times->tm_sec); + *isc_time = TimeStamp::encode_time(times->tm_hour, times->tm_min, times->tm_sec); } @@ -681,7 +679,7 @@ void API_ROUTINE isc_encode_timestamp(const void* times_arg, GDS_TIMESTAMP* date * **************************************/ const tm* const times = static_cast(times_arg); - *date = Firebird::TimeStamp::encode_timestamp(times); + *date = TimeStamp::encode_timestamp(times); } @@ -781,9 +779,9 @@ void API_ROUTINE gds_alloc_report(ULONG flags, const char* filter_filename, int * **************************************/ // Skidder: Calls to this function must be replaced with MemoryPool::print_contents - Firebird::PathName report_name = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LOG, "fbsrvreport.txt"); + PathName report_name = fb_utils::getPrefix(IConfigManager::DIR_LOG, "fbsrvreport.txt"); // Our new facilities don't expose flags for reporting. - const bool used_only = !(flags & ALLOC_verbose); + const bool used_only = !(flags & Why::ALLOC_verbose); getDefaultMemoryPool()->print_contents(report_name.c_str(), used_only ? MemoryPool::PRINT_USED_ONLY : 0, filter_filename); } @@ -1110,7 +1108,7 @@ namespace { class LogFileHandles { public: - LogFileHandles(Firebird::MemoryPool&) + LogFileHandles(MemoryPool&) { mutex_handle = CreateMutex(ISC_get_security_desc(), FALSE, "firebird_trace_mutex"); } @@ -1148,7 +1146,7 @@ void LogFileHandles::trace_raw(const char* text, unsigned int length) { if (file_handle == INVALID_HANDLE_VALUE) { - Firebird::PathName name = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LOG, LOGFILE); + PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); // We do not care to close this file. // It will be closed automatically when our process terminates. @@ -1177,7 +1175,7 @@ void LogFileHandles::trace_raw(const char* text, unsigned int length) } } -Firebird::InitInstance logFileHandles; +InitInstance logFileHandles; HANDLE LogFileHandles::mutex_handle = INVALID_HANDLE_VALUE; HANDLE LogFileHandles::file_handle = INVALID_HANDLE_VALUE; @@ -1221,7 +1219,7 @@ void API_ROUTINE gds__trace_raw(const char* text, unsigned int length) LogGuard guard; logFileHandles().trace_raw(text, length); #else - Firebird::PathName name = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LOG, LOGFILE); + PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); int file = os_utils::open(name.c_str(), O_CREAT | O_APPEND | O_WRONLY, 0660); if (file == -1) return; @@ -1295,7 +1293,7 @@ void API_ROUTINE gds__trace(const TEXT* text) *p++ = ' '; *p = '\0'; - Firebird::string s(buffer); + string s(buffer); s += text; s += "\n"; @@ -1333,10 +1331,10 @@ void API_ROUTINE gds__log(const TEXT* text, ...) if (isSandboxed()) { - static Firebird::GlobalPtr logMutex; // protects big static + static GlobalPtr logMutex; // protects big static static char buffer[10240]; // buffer for messages - Firebird::MutexLockGuard(logMutex, FB_FUNCTION); + MutexLockGuard(logMutex, FB_FUNCTION); fb_utils::snprintf(buffer, sizeof(buffer), "\n\n%s\t%.25s\t", hostName, ctime(&now)); unsigned hdrlen = strlen(buffer); va_start(ptr, text); @@ -1350,7 +1348,7 @@ void API_ROUTINE gds__log(const TEXT* text, ...) #endif // DARWIN - Firebird::PathName name = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LOG, LOGFILE); + PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); #ifdef WIN_NT LogGuard guard; @@ -1419,7 +1417,7 @@ void gds__print_pool(MemoryPool* pool, const TEXT* text, ...) now = time((time_t *)0); #endif - Firebird::PathName name = fb_utils::getPrefix(Firebird::IConfigManager::DIR_LOG, LOGFILE); + PathName name = fb_utils::getPrefix(IConfigManager::DIR_LOG, LOGFILE); const int oldmask = umask(0111); #ifdef WIN_NT @@ -1463,7 +1461,7 @@ void API_ROUTINE gds__log_status(const TEXT* database, const ISC_STATUS* status_ { if (database) { - Firebird::string buffer; + string buffer; buffer.printf("Database: %s", database); iscLogStatus(buffer.c_str(), status_vector); } @@ -1472,7 +1470,7 @@ void API_ROUTINE gds__log_status(const TEXT* database, const ISC_STATUS* status_ iscLogStatus(NULL, status_vector); } } - catch (const Firebird::Exception&) + catch (const Exception&) {} // no-op } @@ -1492,7 +1490,7 @@ int API_ROUTINE gds__msg_close(void *handle) gds_msg* messageL = static_cast(handle); - Firebird::MutexLockGuard guard(global_msg_mutex, "gds__msg_close"); + MutexLockGuard guard(global_msg_mutex, "gds__msg_close"); if (!messageL) { @@ -1562,7 +1560,7 @@ SSHORT API_ROUTINE gds__msg_format(void* handle, } else { - Firebird::string s; + string s; s.printf("can't format message %d:%d -- ", facility, number); if (n == -1) s += "message text not found"; @@ -1620,13 +1618,13 @@ SSHORT API_ROUTINE gds__msg_lookup(void* handle, int status = -1; gds_msg* messageL = (gds_msg*) handle; - Firebird::MutexLockGuard guard(global_msg_mutex, "gds__msg_lookup"); + MutexLockGuard guard(global_msg_mutex, "gds__msg_lookup"); if (!messageL && !(messageL = global_default_msg)) { // Try environment variable setting first - Firebird::string p; + string p; if (!fb_utils::readenv("ISC_MSGS", p) || (status = gds__msg_open(reinterpret_cast(&messageL), p.c_str()))) { @@ -1643,11 +1641,11 @@ SSHORT API_ROUTINE gds__msg_lookup(void* handle, if (fb_utils::readenv("LC_MESSAGES", p)) { sanitize(p); - Firebird::string::size_type pos = p.find_last_of('/'); - if (pos == Firebird::string::npos) + string::size_type pos = p.find_last_of('/'); + if (pos == string::npos) pos = p.find_last_of('\\'); - if (pos != Firebird::string::npos) + if (pos != string::npos) p.erase(0, pos + 1); fb_utils::snprintf(translated_msg_file, @@ -1735,7 +1733,7 @@ SSHORT API_ROUTINE gds__msg_lookup(void* handle, return status; } - catch (const Firebird::Exception&) + catch (const Exception&) { // not much can be done here return -100; @@ -1850,7 +1848,7 @@ SLONG API_ROUTINE gds__get_prefix(SSHORT arg_type, const TEXT* passed_string) if (! passed_string) return -1; - Firebird::PathName prefix(passed_string); + PathName prefix(passed_string); prefix.erase(MAXPATHLEN); for (FB_SIZE_T n = 0; n < prefix.length(); ++n) { @@ -1864,23 +1862,23 @@ SLONG API_ROUTINE gds__get_prefix(SSHORT arg_type, const TEXT* passed_string) } } - if (arg_type == IB_PREFIX_TYPE) + if (arg_type == Why::IB_PREFIX_TYPE) { // it's very important to do it BEFORE GDS_init_prefix() - Firebird::Config::setRootDirectoryFromCommandLine(prefix); + Config::setRootDirectoryFromCommandLine(prefix); } GDS_init_prefix(); switch (arg_type) { - case IB_PREFIX_TYPE: + case Why::IB_PREFIX_TYPE: prefix.copyTo(fb_prefix_val, sizeof fb_prefix_val); break; - case IB_PREFIX_LOCK_TYPE: + case Why::IB_PREFIX_LOCK_TYPE: prefix.copyTo(fb_prefix_lock_val, sizeof fb_prefix_lock_val); break; - case IB_PREFIX_MSG_TYPE: + case Why::IB_PREFIX_MSG_TYPE: prefix.copyTo(fb_prefix_msg_val, sizeof fb_prefix_msg_val); break; default: @@ -2250,7 +2248,7 @@ int API_ROUTINE fb_print_blr(const UCHAR* blr, ULONG blr_length, blr_format(control, "blr_eoc"); blr_print_line(control, (SSHORT) offset); } - catch (const Firebird::Exception&) + catch (const Exception&) { return FB_FAILURE; } @@ -2336,7 +2334,7 @@ void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR routine, void* arg) gds_pid = getpid(); #endif - Firebird::InstanceControl::registerGdsCleanup(gds__cleanup); + InstanceControl::registerGdsCleanup(gds__cleanup); clean_t* clean = (clean_t*) gds__alloc((SLONG) sizeof(clean_t)); clean->clean_routine = routine; @@ -2347,7 +2345,7 @@ void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR routine, void* arg) gds_alloc_flag_unfreed((void *) clean); #endif - Firebird::MutexLockGuard guard(cleanup_handlers_mutex, "gds__register_cleanup"); + MutexLockGuard guard(cleanup_handlers_mutex, "gds__register_cleanup"); clean->clean_next = cleanup_handlers; cleanup_handlers = clean; } @@ -2627,7 +2625,7 @@ VoidPtr API_ROUTINE gds__temp_file(BOOLEAN stdio_flag, const TEXT* string, TEXT* // Fortunately, utilities never pass non-default values. fb_assert(!dir && !unlink_flag); - Firebird::PathName filename = Firebird::TempFile::create(string); + PathName filename = TempFile::create(string); if (expanded_string) { @@ -2642,7 +2640,7 @@ VoidPtr API_ROUTINE gds__temp_file(BOOLEAN stdio_flag, const TEXT* string, TEXT* return (void*) (IPTR) os_utils::open(filename.c_str(), O_RDWR | O_EXCL | O_TRUNC); } - catch (const Firebird::Exception&) + catch (const Exception&) { return (void*) (IPTR) (-1); } @@ -2661,7 +2659,7 @@ void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR routine, void *arg) * Unregister a cleanup handler. * **************************************/ - Firebird::MutexLockGuard guard(cleanup_handlers_mutex, "gds__unregister_cleanup"); + MutexLockGuard guard(cleanup_handlers_mutex, "gds__unregister_cleanup"); clean_t* clean; for (clean_t** clean_ptr = &cleanup_handlers; (clean = *clean_ptr); clean_ptr = &clean->clean_next) @@ -2696,7 +2694,7 @@ BOOLEAN API_ROUTINE gds__validate_lib_path(const TEXT* module, * else, if the module is not in the path return FALSE. * **************************************/ - Firebird::string ib_ext_lib_path; + string ib_ext_lib_path; if (!fb_utils::readenv(ib_env_var, ib_ext_lib_path)) { fb_utils::copy_terminate(resolved_module, module, length); @@ -2918,7 +2916,7 @@ static void blr_error(gds_ctl* control, const TEXT* string, ...) va_end(args); offset = 0; blr_print_line(control, (SSHORT) offset); - Firebird::LongJump::raise(); + LongJump::raise(); } @@ -3294,12 +3292,12 @@ static int blr_print_dtype(gds_ctl* control) case blr_dec64: string = "dec64"; - length = sizeof(Firebird::Decimal64); + length = sizeof(Decimal64); break; case blr_int128: string = "int128"; - length = sizeof(Firebird::Int128); + length = sizeof(Int128); break; case blr_domain_name: @@ -4500,9 +4498,9 @@ void gds__cleanup() gds__msg_close(NULL); - Firebird::MutexLockGuard guard(cleanup_handlers_mutex, "gds__cleanup"); + MutexLockGuard guard(cleanup_handlers_mutex, "gds__cleanup"); - Firebird::InstanceControl::registerGdsCleanup(0); + InstanceControl::registerGdsCleanup(0); clean_t* clean; while ( (clean = cleanup_handlers) ) @@ -4522,7 +4520,7 @@ void gds__cleanup() } -static void sanitize(Firebird::string& locale) +static void sanitize(string& locale) { /************************************** * @@ -4537,7 +4535,7 @@ static void sanitize(Firebird::string& locale) * **************************************/ - for (Firebird::string::pointer p = locale.begin(); *p; ++p) + for (string::pointer p = locale.begin(); *p; ++p) { if (*p == '.') *p = '_'; @@ -4574,7 +4572,7 @@ VoidPtr API_ROUTINE gds__alloc(SLONG size_request) { return getDefaultMemoryPool()->allocate(size_request); } - catch (const Firebird::Exception&) + catch (const Exception&) { return NULL; } @@ -4589,14 +4587,14 @@ class InitPrefix // CVC: I put this protection block because we can't raise exceptions // if exceptions are already raised due to the same reason: // config file not found. - Firebird::PathName prefix; + PathName prefix; try { - prefix = Firebird::Config::getRootDirectory(); + prefix = Config::getRootDirectory(); if (prefix.isEmpty() && !GetProgramFilesDir(prefix)) prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; } - catch (const Firebird::Exception&) + catch (const Exception&) { // CVC: Presumably here we failed because the config file can't be located. if (!GetProgramFilesDir(prefix)) @@ -4606,7 +4604,7 @@ class InitPrefix fb_prefix = fb_prefix_val; // Find appropriate temp directory - Firebird::PathName tempDir; + PathName tempDir; if (!fb_utils::readenv(FB_TMP_ENV, tempDir)) { #ifdef WIN_NT @@ -4633,7 +4631,7 @@ class InitPrefix // Find appropriate Firebird lock file prefix // Override conditional defines with the enviroment // variable FIREBIRD_LOCK if it is set. - Firebird::PathName lockPrefix; + PathName lockPrefix; if (!fb_utils::readenv(FB_LOCK_ENV, lockPrefix)) { #if !defined(WIN_NT) @@ -4657,7 +4655,7 @@ class InitPrefix fb_prefix_lock = fb_prefix_lock_val; // Find appropriate Firebird message file prefix. - Firebird::PathName msgPrefix; + PathName msgPrefix; if (!fb_utils::readenv(FB_MSG_ENV, msgPrefix)) { if (FB_MSGDIR[0] && PathUtils::isRelative(FB_MSGDIR)) @@ -4675,7 +4673,7 @@ class InitPrefix } }; -static Firebird::InitMutex initPrefix("InitPrefix"); +static InitMutex initPrefix("InitPrefix"); void GDS_init_prefix() { @@ -4700,7 +4698,7 @@ void GDS_init_prefix() // We try to see if the registry has the information for the Program Files // directory, that follows the boot partition and is localized. -static bool GetProgramFilesDir(Firebird::PathName& output) +static bool GetProgramFilesDir(PathName& output) { #ifdef WIN_NT const char* pdir = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion"; diff --git a/src/yvalve/gds_proto.h b/src/yvalve/gds_proto.h index 386db444232..5f36b63dd42 100644 --- a/src/yvalve/gds_proto.h +++ b/src/yvalve/gds_proto.h @@ -26,24 +26,27 @@ #define JRD_GDS_PROTO_H -inline constexpr SSHORT IB_PREFIX_TYPE = 0; -inline constexpr SSHORT IB_PREFIX_LOCK_TYPE = 1; -inline constexpr SSHORT IB_PREFIX_MSG_TYPE = 2; - -// flags for gds_alloc_report -inline constexpr ULONG ALLOC_dont_report = 1L << 0; /* Don't report this block */ -inline constexpr ULONG ALLOC_silent = 1L << 1; /* Don't report new leaks */ -inline constexpr ULONG ALLOC_verbose = 1L << 2; /* Report all leaks, even old */ -inline constexpr ULONG ALLOC_mark_current = 1L << 3; /* Mark all current leaks */ -inline constexpr ULONG ALLOC_check_each_call = 1L << 4; /* Check memory integrity on each alloc/free call */ -inline constexpr ULONG ALLOC_dont_check = 1L << 5; /* Stop checking integrity on each call */ - #ifdef __cplusplus namespace Firebird { class MemoryPool; } +namespace Firebird::Why +{ + inline constexpr SSHORT IB_PREFIX_TYPE = 0; + inline constexpr SSHORT IB_PREFIX_LOCK_TYPE = 1; + inline constexpr SSHORT IB_PREFIX_MSG_TYPE = 2; + + // flags for gds_alloc_report + inline constexpr ULONG ALLOC_dont_report = 1L << 0; /* Don't report this block */ + inline constexpr ULONG ALLOC_silent = 1L << 1; /* Don't report new leaks */ + inline constexpr ULONG ALLOC_verbose = 1L << 2; /* Report all leaks, even old */ + inline constexpr ULONG ALLOC_mark_current = 1L << 3; /* Mark all current leaks */ + inline constexpr ULONG ALLOC_check_each_call = 1L << 4; /* Check memory integrity on each alloc/free call */ + inline constexpr ULONG ALLOC_dont_check = 1L << 5; /* Stop checking integrity on each call */ +} + extern "C" { #endif diff --git a/src/yvalve/msg.h b/src/yvalve/msg.h index 08672a9db9e..8694100496c 100644 --- a/src/yvalve/msg.h +++ b/src/yvalve/msg.h @@ -26,50 +26,53 @@ #define JRD_MSG_H #define MSG_NUMBER(facility, code) ((SLONG) facility * 10000 + code) -inline constexpr USHORT MSG_BUCKET = 1024; -inline constexpr UCHAR MSG_MAJOR_VERSION = 1; // trick to silence the compiler when FB_MSG_MINOR_VERSION is 0 #define FB_MSG_MINOR_VERSION 1 -inline constexpr UCHAR MSG_MINOR_VERSION = FB_MSG_MINOR_VERSION; -// Message file header block - -struct isc_msghdr +namespace Firebird { - UCHAR msghdr_major_version; // Version number - UCHAR msghdr_minor_version; // Version number - USHORT msghdr_bucket_size; // Bucket size of B-tree - ULONG msghdr_top_tree; // Start address of first index bucket - ULONG msghdr_origin; // Origin for data records, unused. - USHORT msghdr_levels; // Levels in tree -}; + inline constexpr USHORT MSG_BUCKET = 1024; + inline constexpr UCHAR MSG_MAJOR_VERSION = 1; + inline constexpr UCHAR MSG_MINOR_VERSION = FB_MSG_MINOR_VERSION; -// Index node + // Message file header block -struct msgnod -{ - ULONG msgnod_code; // Message code - ULONG msgnod_seek; // Offset of next bucket or message -}; + struct isc_msghdr + { + UCHAR msghdr_major_version; // Version number + UCHAR msghdr_minor_version; // Version number + USHORT msghdr_bucket_size; // Bucket size of B-tree + ULONG msghdr_top_tree; // Start address of first index bucket + ULONG msghdr_origin; // Origin for data records, unused. + USHORT msghdr_levels; // Levels in tree + }; -// Leaf node + // Index node -struct msgrec -{ - ULONG msgrec_code; // Message code - USHORT msgrec_length; // Length of message text - USHORT msgrec_flags; // Misc flags - TEXT msgrec_text[1]; // Text of message + struct msgnod + { + ULONG msgnod_code; // Message code + ULONG msgnod_seek; // Offset of next bucket or message + }; + + // Leaf node - inline msgrec* next() const + struct msgrec { - IPTR next = (IPTR) this; - next += FB_ALIGN(offsetof(msgrec, msgrec_text[0]) + msgrec_length, sizeof (SLONG)); - return (msgrec*) next; - } -}; + ULONG msgrec_code; // Message code + USHORT msgrec_length; // Length of message text + USHORT msgrec_flags; // Misc flags + TEXT msgrec_text[1]; // Text of message -typedef msgrec* MSGREC; + inline msgrec* next() const + { + IPTR next = (IPTR) this; + next += FB_ALIGN(offsetof(msgrec, msgrec_text[0]) + msgrec_length, sizeof (SLONG)); + return (msgrec*) next; + } + }; -#endif // JRD_MSG_H + typedef msgrec* MSGREC; +} +#endif // JRD_MSG_H diff --git a/src/yvalve/perf.cpp b/src/yvalve/perf.cpp index 2276257215a..5aac38312bd 100644 --- a/src/yvalve/perf.cpp +++ b/src/yvalve/perf.cpp @@ -337,15 +337,20 @@ constexpr KnownCounters knownCounters[TOTAL_COUNTERS] = { } // anonymous namespace -void Why::UtilInterface::getPerfCounters(Firebird::CheckStatusWrapper* status, - Firebird::IAttachment* att, const char* countersSet, ISC_INT64* counters) + +namespace Firebird::Why +{ + + +void UtilInterface::getPerfCounters(CheckStatusWrapper* status, + IAttachment* att, const char* countersSet, ISC_INT64* counters) { try { // Parse countersSet unsigned cntLink[TOTAL_COUNTERS]; memset(cntLink, 0xFF, sizeof cntLink); - Firebird::string dupSet(countersSet); + string dupSet(countersSet); char* set = dupSet.begin(); char* save = NULL; constexpr const char* delim = " \t,;"; @@ -362,14 +367,14 @@ void Why::UtilInterface::getPerfCounters(Firebird::CheckStatusWrapper* status, for (char* nm = strtok_r(set, delim, &save); nm; nm = strtok_r(NULL, delim, &save)) { - Firebird::NoCaseString name(nm); + NoCaseString name(nm); for (unsigned i = 0; i < TOTAL_COUNTERS; ++i) { if (name == knownCounters[i].name) { if (cntLink[i] != ~0u) - (Firebird::Arg::Gds(isc_random) << "Duplicated name").raise(); //report name & position + (Arg::Gds(isc_random) << "Duplicated name").raise(); //report name & position cntLink[i] = n++; typeMask |= knownCounters[i].type; @@ -387,7 +392,7 @@ void Why::UtilInterface::getPerfCounters(Firebird::CheckStatusWrapper* status, goto found; } } - (Firebird::Arg::Gds(isc_random) << "Unknown name").raise(); //report name & position + (Arg::Gds(isc_random) << "Unknown name").raise(); //report name & position found: ; } @@ -440,7 +445,7 @@ found: ; { UCHAR buffer[BUFFER_LARGE]; att->getInfo(status, pinfo - info, info, sizeof(buffer), buffer); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; const UCHAR* p = buffer; @@ -479,7 +484,7 @@ found: ; } default: - (Firebird::Arg::Gds(isc_random) << "Unknown info code").raise(); //report char code + (Arg::Gds(isc_random) << "Unknown info code").raise(); //report char code } for (unsigned i = 0; i < TOTAL_COUNTERS; ++i) @@ -496,8 +501,11 @@ found: ; parsed: ; } } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { ex.stuffException(status); } } + + +} // namespace Firebird::Why diff --git a/src/yvalve/prepa_proto.h b/src/yvalve/prepa_proto.h index 32fbc7e7717..169d7f2b66d 100644 --- a/src/yvalve/prepa_proto.h +++ b/src/yvalve/prepa_proto.h @@ -27,11 +27,12 @@ #include "firebird/Interface.h" #include "../common/classes/fb_string.h" -namespace Why { +namespace Firebird::Why +{ class YAttachment; -} -bool PREPARSE_execute(Firebird::CheckStatusWrapper*, Why::YAttachment**, Firebird::string&, bool*, USHORT, - unsigned dpbLength, const unsigned char* dpb); + bool PREPARSE_execute(CheckStatusWrapper*, YAttachment**, string&, bool*, USHORT, + unsigned dpbLength, const unsigned char* dpb); +} #endif // DSQL_PREPA_PROTO_H diff --git a/src/yvalve/preparse.cpp b/src/yvalve/preparse.cpp index 5c2cf81feae..5d172120848 100644 --- a/src/yvalve/preparse.cpp +++ b/src/yvalve/preparse.cpp @@ -34,6 +34,10 @@ #include +namespace Firebird::Why +{ + + enum pp_vals { PP_CREATE = 0, PP_DATABASE, @@ -52,7 +56,7 @@ enum pp_vals { }; -static void generate_error(const Firebird::NoCaseString&, SSHORT, char = 0); +static void generate_error(const NoCaseString&, SSHORT, char = 0); struct pp_table { @@ -95,9 +99,6 @@ enum token_vals { static const char* quotes = "\"\'"; -using namespace Firebird; - - static NoCaseString getToken(unsigned& pos, const Tokens& toks, int symbol = SYMBOL) { if (pos >= toks.getCount()) @@ -155,7 +156,7 @@ static NoCaseString getToken(unsigned& pos, const Tokens& toks, int symbol = SYM @param dialect **/ -bool PREPARSE_execute(CheckStatusWrapper* status, Why::YAttachment** ptrAtt, +bool PREPARSE_execute(CheckStatusWrapper* status, YAttachment** ptrAtt, string& stmt, bool* stmt_eaten, USHORT dialect, unsigned dpbLength, const unsigned char* dpb) { // no use creating separate pool for a couple of strings @@ -320,7 +321,7 @@ bool PREPARSE_execute(CheckStatusWrapper* status, Why::YAttachment** ptrAtt, } // for } while (matched); - RefPtr dispatcher(FB_NEW Why::Dispatcher); + RefPtr dispatcher(FB_NEW Dispatcher); *ptrAtt = dispatcher->createDatabase(status, file_name.c_str(), dpbWriter.getBufferLength(), dpbWriter.getBuffer()); @@ -393,3 +394,6 @@ static void generate_error(const NoCaseString& token, SSHORT error, char result) Arg::StatusVector(temp_status).raise(); } + + +} // namespace Firebird::Why diff --git a/src/yvalve/user_dsql.cpp b/src/yvalve/user_dsql.cpp index 76a511b0481..10421d129e8 100644 --- a/src/yvalve/user_dsql.cpp +++ b/src/yvalve/user_dsql.cpp @@ -36,6 +36,7 @@ */ #include "firebird.h" +#include "ibase.h" #include "../dsql/chars.h" #include "firebird/impl/sqlda_pub.h" #include "../yvalve/gds_proto.h" @@ -51,10 +52,12 @@ #include #include +using namespace Firebird; + + // SQLDA dialects constexpr USHORT DIALECT_sqlda = 0; -using namespace Firebird; enum name_type { NAME_statement = 1, @@ -102,7 +105,7 @@ struct dsql_err_stblock static void cleanup(void*); static void cleanup_database(FB_API_HANDLE*, void*); -static ISC_STATUS error(const Firebird::Exception& ex); +static ISC_STATUS error(const Exception& ex); static ISC_STATUS error(); static void error_post(const Arg::StatusVector& v); static dsql_name* lookup_name(const SCHAR*, dsql_name*); @@ -122,7 +125,7 @@ static dsql_name* statement_names = NULL; static dsql_name* cursor_names = NULL; static dsql_dbb* databases = NULL; -Firebird::GlobalPtr global_sync; +GlobalPtr global_sync; static inline void set_global_private_status(ISC_STATUS* user_status, ISC_STATUS* local_status) noexcept { @@ -154,7 +157,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_close(ISC_STATUS* user_status, const SCHAR return isc_dsql_free_statement(user_status, &statement->stmt_handle, DSQL_close); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -184,12 +187,12 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_declare(ISC_STATUS* user_status, return s; } - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); statement->stmt_cursor = insert_name(cursor, &cursor_names, statement); return s; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -216,7 +219,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_describe(ISC_STATUS* user_status, return isc_dsql_describe(user_status, &statement->stmt_handle, dialect, sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -256,7 +259,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_describe_bind(ISC_STATUS* user_status, return isc_dsql_describe_bind(user_status, &statement->stmt_handle, dialect, sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -300,7 +303,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_execute2(ISC_STATUS* user_status, return isc_dsql_execute2(user_status, trans_handle, &statement->stmt_handle, dialect, in_sqlda, out_sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -376,7 +379,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_fetch(ISC_STATUS* user_status, return isc_dsql_fetch(user_status, &statement->stmt_handle, dialect, sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -429,7 +432,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_insert(ISC_STATUS* user_status, return isc_dsql_insert(user_status, &statement->stmt_handle, dialect, sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -511,7 +514,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_open2(ISC_STATUS* user_status, return isc_dsql_execute2(user_status, trans_handle, &statement->stmt_handle, dialect, in_sqlda, out_sqlda); } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -591,7 +594,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_prepare(ISC_STATUS* user_status, // If a new statement was allocated, add it to the symbol table and insert it // into the list of statements - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); if (!statement) { @@ -621,7 +624,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_prepare(ISC_STATUS* user_status, return s; } // try - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -657,7 +660,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_release(ISC_STATUS* user_status, const SCH // remove the statement from the symbol tables - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); if (statement->stmt_stmt) remove_name(statement->stmt_stmt, &statement_names); @@ -679,7 +682,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_release(ISC_STATUS* user_status, const SCH return s; } - catch (const Firebird::Exception& ex) + catch (const Exception& ex) { return error(ex); } @@ -975,7 +978,7 @@ static void cleanup(void*) UDSQL_error = NULL; { // scope - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); free_all_databases(databases); free_all_statements(statements); @@ -1000,7 +1003,7 @@ static void cleanup_database(FB_API_HANDLE* db_handle, void* /*dummy*/) // for each of the statements in this database, remove it // from the local list and from the hash table - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); dsql_stmt** stmt_ptr = &statements; dsql_stmt* p; @@ -1043,11 +1046,11 @@ static void cleanup_database(FB_API_HANDLE* db_handle, void* /*dummy*/) // a status vector, return a status code. Otherwise print the // error code(s) and abort. // -static ISC_STATUS error(const Firebird::Exception& ex) +static ISC_STATUS error(const Exception& ex) { - Firebird::StaticStatusVector v; + StaticStatusVector v; ex.stuffException(v); - makePermanentVector(v.begin()); + Why::makePermanentVector(v.begin()); if (UDSQL_error->dsql_user_status) { @@ -1092,7 +1095,7 @@ static void error_post(const Arg::StatusVector& v) v.copyTo(UDSQL_error->dsql_status); // Give up whatever we were doing and return to the user. - Firebird::status_exception::raise(UDSQL_error->dsql_status); + status_exception::raise(UDSQL_error->dsql_status); } @@ -1123,7 +1126,7 @@ static void init(FB_API_HANDLE* db_handle) dsql_dbb* dbb; { // scope - Firebird::ReadLockGuard guard(global_sync, FB_FUNCTION); + ReadLockGuard guard(global_sync, FB_FUNCTION); for (dbb = databases; dbb; dbb = dbb->dbb_next) { @@ -1142,7 +1145,7 @@ static void init(FB_API_HANDLE* db_handle) return; // Not a great error handler } - Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION); + WriteLockGuard guard(global_sync, FB_FUNCTION); dbb->dbb_next = databases; databases = dbb; @@ -1196,7 +1199,7 @@ static dsql_name* lookup_name(const TEXT* name, dsql_name* list) * **************************************/ - Firebird::ReadLockGuard guard(global_sync, FB_FUNCTION); + ReadLockGuard guard(global_sync, FB_FUNCTION); const USHORT l = name_length(name); for (; list; list = list->name_next) diff --git a/src/yvalve/utl.cpp b/src/yvalve/utl.cpp index db2d4161ae2..4ca12242002 100644 --- a/src/yvalve/utl.cpp +++ b/src/yvalve/utl.cpp @@ -57,7 +57,7 @@ #include "../yvalve/why_proto.h" #include "../yvalve/prepa_proto.h" #include "../yvalve/PluginManager.h" -#include "../jrd/constants.h" +#include "../common/constants.h" #include "../jrd/build_no.h" #include "../common/TimeZoneUtil.h" #include "../common/classes/ClumpletWriter.h" @@ -88,8 +88,9 @@ #include #endif +namespace Firebird::Why +{ -using namespace Firebird; IAttachment* handleToIAttachment(CheckStatusWrapper*, FB_API_HANDLE*); ITransaction* handleToITransaction(CheckStatusWrapper*, FB_API_HANDLE*); @@ -193,7 +194,7 @@ void load(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, ITrans // Open the blob. If it failed, what the hell -- just return failure IBlob* blob = att->createBlob(status, tra, blobId, 0, NULL); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; // Copy data from file to blob. Make up boundaries at end of line. @@ -215,7 +216,7 @@ void load(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, ITrans const SSHORT l = p - buffer; blob->putSegment(status, l, buffer); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { blob->close(&temp); return; @@ -247,7 +248,7 @@ void dump(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, ITrans // Open the blob. If it failed, what the hell -- just return failure IBlob* blob = att->openBlob(status, tra, blobId, 0, NULL); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; // Copy data from blob to scratch file @@ -259,8 +260,8 @@ void dump(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, ITrans unsigned l = 0; switch (blob->getSegment(status, sizeof(buffer), buffer, &l)) { - case Firebird::IStatus::RESULT_ERROR: - case Firebird::IStatus::RESULT_NO_DATA: + case IStatus::RESULT_ERROR: + case IStatus::RESULT_NO_DATA: cond = false; break; } @@ -319,7 +320,7 @@ FB_BOOLEAN edit(CheckStatusWrapper* status, ISC_QUAD* blob_id, IAttachment* att, // Would have saved me a lot of time, if I had seen this earlier :-( // FSG 15.Oct.2000 PathName tmpf = TempFile::create(status, buffer); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return FB_FALSE; FILE* file = os_utils::fopen(tmpf.c_str(), FOPEN_WRITE_TYPE_TEXT); @@ -363,8 +364,6 @@ FB_BOOLEAN edit(CheckStatusWrapper* status, ISC_QUAD* blob_id, IAttachment* att, } // anonymous namespace -namespace Why { - UtilInterface utilInterface; void UtilInterface::dumpBlob(CheckStatusWrapper* status, ISC_QUAD* blobId, @@ -453,7 +452,7 @@ void UtilInterface::getFbVersion(CheckStatusWrapper* status, IAttachment* att, do { att->getInfo(status, sizeof(info), info, buf_len, buf); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; ClumpletReader p(ClumpletReader::InfoResponse, buf, buf_len); @@ -548,14 +547,14 @@ void UtilInterface::getFbVersion(CheckStatusWrapper* status, IAttachment* att, s.printf("%s (%s), version \"%.*s\"", implementation_string, class_string, l, versions); callback->callback(status, s.c_str()); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; versions += l; } USHORT ods_version, ods_minor_version; UTL_get_ods_version(status, att, &ods_version, &ods_minor_version); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; s.printf("on disk structure version %d.%d", ods_version, ods_minor_version); @@ -568,7 +567,7 @@ void UtilInterface::getFbVersion(CheckStatusWrapper* status, IAttachment* att, } YAttachment* UtilInterface::executeCreateDatabase2( - Firebird::CheckStatusWrapper* status, unsigned stmtLength, const char* creatDBstatement, + CheckStatusWrapper* status, unsigned stmtLength, const char* creatDBstatement, unsigned dialect, unsigned dpbLength, const unsigned char* dpb, FB_BOOLEAN* stmtIsCreateDb) { try @@ -588,7 +587,7 @@ YAttachment* UtilInterface::executeCreateDatabase2( if (stmtIsCreateDb) *stmtIsCreateDb = FB_TRUE; - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return NULL; LocalStatus tempStatus; @@ -596,7 +595,7 @@ YAttachment* UtilInterface::executeCreateDatabase2( ITransaction* crdbTrans = att->startTransaction(status, 0, NULL); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { att->dropDatabase(&tempCheckStatusWrapper); return NULL; @@ -605,7 +604,7 @@ YAttachment* UtilInterface::executeCreateDatabase2( if (!stmtEaten) { att->execute(status, crdbTrans, statement.length(), statement.c_str(), dialect, NULL, NULL, NULL, NULL); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { crdbTrans->rollback(&tempCheckStatusWrapper); att->dropDatabase(&tempCheckStatusWrapper); @@ -614,7 +613,7 @@ YAttachment* UtilInterface::executeCreateDatabase2( } crdbTrans->commit(status); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) { crdbTrans->rollback(&tempCheckStatusWrapper); att->dropDatabase(&tempCheckStatusWrapper); @@ -698,7 +697,7 @@ void UtilInterface::decodeTimeTz(CheckStatusWrapper* status, const ISC_TIME_TZ* hours, minutes, seconds, fractions, timeZoneBufferLength, timeZoneBuffer); } -void UtilInterface::decodeTimeTzEx(Firebird::CheckStatusWrapper* status, const ISC_TIME_TZ_EX* timeEx, +void UtilInterface::decodeTimeTzEx(CheckStatusWrapper* status, const ISC_TIME_TZ_EX* timeEx, unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) { @@ -796,7 +795,7 @@ void UtilInterface::encodeTimeStampTz(CheckStatusWrapper* status, ISC_TIMESTAMP_ } } -void UtilInterface::convert(Firebird::CheckStatusWrapper* status, +void UtilInterface::convert(CheckStatusWrapper* status, unsigned sourceType, unsigned sourceScale, unsigned sourceLength, const void* source, unsigned targetType, unsigned targetScale, unsigned targetLength, void* target) { @@ -1444,8 +1443,6 @@ unsigned UtilInterface::setOffsets(CheckStatusWrapper* status, IMessageMetadata* return 0; } -} // namespace Why - #if (defined SOLARIS ) || (defined __cplusplus) extern "C" { @@ -2466,7 +2463,7 @@ int API_ROUTINE BLOB_display(ISC_QUAD* blob_id, ex.stuffException(&statusWrapper); } - if (statusWrapper.getState() & Firebird::IStatus::STATE_ERRORS) + if (statusWrapper.getState() & IStatus::STATE_ERRORS) { isc_print_status(statusWrapper.getErrors()); return FB_FAILURE; @@ -2527,15 +2524,15 @@ static int any_text_dump(ISC_QUAD* blob_id, LocalStatus ls; CheckStatusWrapper st(&ls); RefPtr att(REF_NO_INCR, handleToIAttachment(&st, &database)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; RefPtr tra(REF_NO_INCR, handleToITransaction(&st, &transaction)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; UtilInterfacePtr()->dumpBlob(&st, blob_id, att, tra, file_name, txt); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) { isc_print_status(st.getErrors()); return FB_FAILURE; @@ -2628,10 +2625,10 @@ int API_ROUTINE BLOB_edit(ISC_QUAD* blob_id, CheckStatusWrapper statusWrapper(&st); RefPtr att(REF_NO_INCR, handleToIAttachment(&statusWrapper, &database)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; RefPtr tra(REF_NO_INCR, handleToITransaction(&statusWrapper, &transaction)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; int rc = FB_SUCCESS; @@ -2645,7 +2642,7 @@ int API_ROUTINE BLOB_edit(ISC_QUAD* blob_id, ex.stuffException(&statusWrapper); } - if (statusWrapper.getState() & Firebird::IStatus::STATE_ERRORS) + if (statusWrapper.getState() & IStatus::STATE_ERRORS) isc_print_status(statusWrapper.getErrors()); return rc; @@ -2744,15 +2741,15 @@ static int any_text_load(ISC_QUAD* blob_id, LocalStatus ls; CheckStatusWrapper st(&ls); RefPtr att(REF_NO_INCR, handleToIAttachment(&st, &database)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; RefPtr tra(REF_NO_INCR, handleToITransaction(&st, &transaction)); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) return FB_FAILURE; UtilInterfacePtr()->loadBlob(&st, blob_id, att, tra, file_name, flag); - if (st.getState() & Firebird::IStatus::STATE_ERRORS) + if (st.getState() & IStatus::STATE_ERRORS) { isc_print_status(st.getErrors()); return FB_FAILURE; @@ -3012,7 +3009,7 @@ void UTL_get_ods_version(CheckStatusWrapper* status, IAttachment* att, att->getInfo(status, sizeof(ods_info), ods_info, sizeof(buffer), buffer); - if (status->getState() & Firebird::IStatus::STATE_ERRORS) + if (status->getState() & IStatus::STATE_ERRORS) return; for (ClumpletReader p(ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext()) @@ -3287,7 +3284,7 @@ void makeKey() int err = pthread_key_create(&key, ThreadCleanup::destructor); if (err) { - Firebird::system_call_failed::raise("pthread_key_create", err); + system_call_failed::raise("pthread_key_create", err); } keySet = true; } @@ -3297,13 +3294,13 @@ void ThreadCleanup::initThreadCleanup() int err = pthread_once(&keyOnce, makeKey); if (err) { - Firebird::system_call_failed::raise("pthread_once", err); + system_call_failed::raise("pthread_once", err); } err = pthread_setspecific(key, &key); if (err) { - Firebird::system_call_failed::raise("pthread_setspecific", err); + system_call_failed::raise("pthread_setspecific", err); } } @@ -3317,7 +3314,7 @@ void ThreadCleanup::finiThreadCleanup() class FiniThreadCleanup { public: - FiniThreadCleanup(Firebird::MemoryPool&) + FiniThreadCleanup(MemoryPool&) { } ~FiniThreadCleanup() @@ -3332,7 +3329,7 @@ class FiniThreadCleanup } }; -Firebird::GlobalPtr thrCleanup; // needed to call dtor +GlobalPtr thrCleanup; // needed to call dtor #endif // USE_POSIX_THREADS @@ -3374,7 +3371,7 @@ void ThreadCleanup::destructor(void*) void ThreadCleanup::add(FPTR_VOID_PTR cleanup, void* arg) { - Firebird::MutexLockGuard guard(cleanupMutex, FB_FUNCTION); + MutexLockGuard guard(cleanupMutex, FB_FUNCTION); initThreadCleanup(); @@ -3472,7 +3469,7 @@ class Strings ThreadCleanup::remove(cleanupAllStrings, NULL); } }; -Firebird::GlobalPtr cleanStrings; +GlobalPtr cleanStrings; const char* circularAlloc(const char* s, size_t len) { @@ -3547,12 +3544,12 @@ void makePermanentVector(ISC_STATUS* v) noexcept } #ifdef WIN_NT -namespace Why +// This is called from ibinitdll.cpp:DllMain() +void threadCleanup() { - // This is called from ibinitdll.cpp:DllMain() - void threadCleanup() - { - ThreadCleanup::destructor(NULL); - } + ThreadCleanup::destructor(NULL); } #endif + + +} // namespace Firebird::Why diff --git a/src/yvalve/utl_proto.h b/src/yvalve/utl_proto.h index 789e3711cda..829d5635e83 100644 --- a/src/yvalve/utl_proto.h +++ b/src/yvalve/utl_proto.h @@ -29,6 +29,11 @@ #include "fb_types.h" #include "../common/classes/ImplementHelper.h" +namespace Firebird +{ + class ClumpletWriter; +} + #ifdef __cplusplus extern "C" { #endif @@ -74,22 +79,17 @@ int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR*, void*, int, int, void*); } /* extern "C" */ #endif -// new utl -namespace Firebird +namespace Firebird::Why { - class ClumpletWriter; -} -void setLogin(Firebird::ClumpletWriter& dpb, bool spbFlag); + void setLogin(ClumpletWriter& dpb, bool spbFlag); -// Put status vector strings into strings circular buffer -void makePermanentVector(ISC_STATUS* v) noexcept; + // Put status vector strings into strings circular buffer + void makePermanentVector(ISC_STATUS* v) noexcept; -void UTL_get_ods_version(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* att, - USHORT* ods_version, USHORT* ods_minor_version); + void UTL_get_ods_version(CheckStatusWrapper* status, IAttachment* att, + USHORT* ods_version, USHORT* ods_minor_version); -namespace Why -{ void threadCleanup(); -} +} // namespace Firebird::Why #endif // JRD_UTL_PROTO_H diff --git a/src/yvalve/why.cpp b/src/yvalve/why.cpp index 20ca244ad8b..724ad67326a 100644 --- a/src/yvalve/why.cpp +++ b/src/yvalve/why.cpp @@ -34,6 +34,7 @@ #include "firebird/Interface.h" #include "memory_routines.h" +#include "ibase.h" #include "iberror.h" #include "../yvalve/YObjects.h" #include "firebird/impl/sqlda_pub.h" @@ -81,8 +82,10 @@ #include -using namespace Firebird; -using namespace Why; +namespace Firebird::Why +{ + class StatusVector; + extern UtilInterface utilInterface; [[noreturn]] static void badHandle(ISC_STATUS code); @@ -99,11 +102,6 @@ static ISC_STATUS openOrCreateBlob(ISC_STATUS* userStatus, isc_db_handle* dbHand //------------------------------------- -namespace Why { - class StatusVector; - extern UtilInterface utilInterface; -}; - namespace { static constexpr struct { @@ -136,8 +134,8 @@ friend class SQLDAMetadataLauncher; // Fool-proof requested by Alex // Private memory operators to be sure that this class is used in heap only with launcher - void* operator new (size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) { return pool.allocate(s ALLOC_PASS_ARGS); } - void operator delete (void* mem, Firebird::MemoryPool& ALLOC_PARAMS_DEF) { MemoryPool::globalFree(mem); } + void* operator new (size_t s, MemoryPool& pool ALLOC_PARAMS) { return pool.allocate(s ALLOC_PASS_ARGS); } + void operator delete (void* mem, MemoryPool& ALLOC_PARAMS_DEF) { MemoryPool::globalFree(mem); } void operator delete (void* mem) { MemoryPool::globalFree(mem); } public: @@ -874,8 +872,7 @@ class ShutdownInit //------------------------------------- -namespace Why -{ + // StatusVector: Provides correct status vector for operation and init() it. class StatusVector final : public AutoIface > { @@ -1372,7 +1369,6 @@ namespace Why } } -} // namespace Why struct TEB { @@ -1530,6 +1526,18 @@ static ISC_STATUS openOrCreateBlob(ISC_STATUS* userStatus, isc_db_handle* dbHand //------------------------------------- + +IAttachment* handleToIAttachment(CheckStatusWrapper* status, isc_db_handle* handle); +ITransaction* handleToITransaction(CheckStatusWrapper* status, isc_tr_handle* handle); + +} // namespace Firebird::Why + + + + +using namespace Firebird; +using namespace Firebird::Why; + static TLS_DECLARE(ICryptKeyCallback*, legacyCryptCallback); ISC_STATUS API_ROUTINE fb_database_crypt_callback(ISC_STATUS* userStatus, void* cb) @@ -1553,7 +1561,7 @@ ISC_STATUS API_ROUTINE fb_database_crypt_callback(ISC_STATUS* userStatus, void* //------------------------------------- -Firebird::IAttachment* handleToIAttachment(CheckStatusWrapper* status, isc_db_handle* handle) +IAttachment* Why::handleToIAttachment(CheckStatusWrapper* status, isc_db_handle* handle) { try { @@ -1570,7 +1578,7 @@ Firebird::IAttachment* handleToIAttachment(CheckStatusWrapper* status, isc_db_ha } -Firebird::ITransaction* handleToITransaction(CheckStatusWrapper* status, isc_tr_handle* handle) +ITransaction* Why::handleToITransaction(CheckStatusWrapper* status, isc_tr_handle* handle) { try { @@ -3943,7 +3951,6 @@ ISC_STATUS API_ROUTINE fb_get_statement_interface(ISC_STATUS* userStatus, void* //------------------------------------- -namespace Why { IAttachment* MasterImplementation::registerAttachment(IProvider* provider, IAttachment* attachment) { @@ -6655,7 +6662,7 @@ YService* Dispatcher::attachServiceManager(CheckStatusWrapper* status, const cha if (spbLength > 0 && !spb) status_exception::raise(Arg::Gds(isc_bad_spb_form) << - Arg::Gds(isc_null_spb)); + Arg::Gds(isc_null_spb)); PathName svcName(serviceName); svcName.trim(); @@ -6973,5 +6980,3 @@ void Dispatcher::setDbCryptCallback(CheckStatusWrapper* status, ICryptKeyCallbac status->init(); cryptCallback = callback; } - -} // namespace Why