Skip to content

Commit c6383cb

Browse files
committed
Before adding conversion to non-safe PTRs
1 parent dd86eba commit c6383cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1080
-770
lines changed

src/common/classes/sparse_bitmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define SPARSE_BITMAP_H
3232

3333
#include "../common/classes/alloc.h"
34+
#include "../common/classes/tree.h"
3435

3536
namespace Firebird {
3637

src/dsql/DsqlCompilerScratch.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,3 +1105,20 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
11051105

11061106
return NULL;
11071107
}
1108+
1109+
// hvlad: each member of recursive CTE can refer to CTE itself (only once) via
1110+
// CTE name or via alias. We need to substitute this aliases when processing CTE
1111+
// member to resolve field names. Therefore we store all aliases in order of
1112+
// occurrence and later use it in backward order (since our parser is right-to-left).
1113+
// Also we put CTE name after all such aliases to distinguish aliases for
1114+
// different CTE's.
1115+
// We also need to repeat this process if main select expression contains union with
1116+
// recursive CTE
1117+
1118+
void DsqlCompilerScratch::addCTEAlias(const string& alias)
1119+
{
1120+
thread_db* tdbb = JRD_get_thread_data();
1121+
fb_assert(currCteAlias == NULL);
1122+
cteAliases.add(FB_NEW_POOL(*tdbb->getDefaultPool()) string(*tdbb->getDefaultPool(), alias));
1123+
}
1124+

src/dsql/DsqlCompilerScratch.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,7 @@ class DsqlCompilerScratch : public BlrDebugWriter
211211
SelectExprNode* findCTE(const MetaName& name);
212212
void clearCTEs();
213213
void checkUnusedCTEs();
214-
215-
// hvlad: each member of recursive CTE can refer to CTE itself (only once) via
216-
// CTE name or via alias. We need to substitute this aliases when processing CTE
217-
// member to resolve field names. Therefore we store all aliases in order of
218-
// occurrence and later use it in backward order (since our parser is right-to-left).
219-
// Also we put CTE name after all such aliases to distinguish aliases for
220-
// different CTE's.
221-
// We also need to repeat this process if main select expression contains union with
222-
// recursive CTE
223-
void addCTEAlias(const Firebird::string& alias)
224-
{
225-
thread_db* tdbb = JRD_get_thread_data();
226-
fb_assert(currCteAlias == NULL);
227-
cteAliases.add(FB_NEW_POOL(*tdbb->getDefaultPool()) Firebird::string(*tdbb->getDefaultPool(), alias));
228-
}
214+
void addCTEAlias(const Firebird::string& alias);
229215

230216
const Firebird::string* getNextCTEAlias()
231217
{

src/jrd/Attachment.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "../jrd/tpc_proto.h"
4343

4444
#include "../jrd/extds/ExtDS.h"
45+
#include "../jrd/met.h"
4546

4647
#include "../jrd/replication/Applier.h"
4748
#include "../jrd/replication/Manager.h"
@@ -265,7 +266,6 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, JProvider* provider
265266
att_utility(UTIL_NONE),
266267
att_dec_status(DecimalStatus::DEFAULT),
267268
att_pools(*pool),
268-
att_mdc(*pool),
269269
att_idle_timeout(0),
270270
att_stmt_timeout(0),
271271
att_batches(*pool),
@@ -462,7 +462,7 @@ void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
462462
{
463463
// Run ON DISCONNECT trigger before reset
464464
if (!(att_flags & ATT_no_db_triggers))
465-
att_mdc.runDBTriggers(tdbb, TRIGGER_DISCONNECT);
465+
att_database->dbb_mdc->runDBTriggers(tdbb, TRIGGER_DISCONNECT);
466466

467467
// shutdown attachment on any error after this point
468468
shutAtt = true;
@@ -500,11 +500,11 @@ void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
500500
SCL_release_all(att_security_classes);
501501

502502
// reset GTT's
503-
att_mdc.releaseGTTs(tdbb);
503+
att_database->dbb_mdc->releaseGTTs(tdbb);
504504

505505
// Run ON CONNECT trigger after reset
506506
if (!(att_flags & ATT_no_db_triggers))
507-
att_mdc.runDBTriggers(tdbb, TRIGGER_CONNECT);
507+
att_database->dbb_mdc->runDBTriggers(tdbb, TRIGGER_CONNECT);
508508

509509
if (oldTran)
510510
{
@@ -623,7 +623,7 @@ void Jrd::Attachment::initLocks(thread_db* tdbb)
623623

624624
void Jrd::Attachment::releaseLocks(thread_db* tdbb)
625625
{
626-
att_mdc.releaseLocks(tdbb);
626+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! to database att_mdc.releaseLocks(tdbb);
627627

628628
// Release the DSQL cache locks
629629

@@ -877,13 +877,13 @@ void Attachment::checkReplSetLock(thread_db* tdbb)
877877
}
878878
}
879879

880-
// Move to database level ????????
880+
// Move to database level ???????? !!!!!!!!!!!!!!!!!!!!!!!!!!!!
881881

882882
void Attachment::invalidateReplSet(thread_db* tdbb, bool broadcast)
883883
{
884884
att_flags |= ATT_repl_reset;
885885

886-
att_mdc.invalidateReplSet(tdbb);
886+
att_database->dbb_mdc->invalidateReplSet(tdbb);
887887

888888
if (broadcast)
889889
{

src/jrd/Attachment.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include "../jrd/EngineInterface.h"
4949
#include "../jrd/sbm.h"
5050
#include "../jrd/HazardPtr.h"
51-
#include "../jrd/met.h"
5251

5352
#include <atomic>
5453

@@ -582,8 +581,6 @@ class Attachment : public pool_alloc<type_att>
582581
MemoryPool* createPool();
583582
void deletePool(MemoryPool* pool);
584583

585-
MetadataCache att_mdc;
586-
587584
/// former Database members - end
588585

589586
bool locksmith(thread_db* tdbb, SystemPrivilege sp) const;

src/jrd/Database.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "../jrd/CryptoManager.h"
4141
#include "../jrd/os/pio_proto.h"
4242
#include "../common/os/os_utils.h"
43-
//#include "../dsql/Parser.h"
43+
#include "../jrd/met.h"
4444

4545
// Thread data block
4646
#include "../common/ThreadData.h"
@@ -569,6 +569,42 @@ namespace Jrd
569569
return m_replMgr;
570570
}
571571

572+
Database::Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared)
573+
: dbb_permanent(p),
574+
dbb_page_manager(this, *p),
575+
dbb_file_id(*p),
576+
dbb_modules(*p),
577+
dbb_extManager(nullptr),
578+
dbb_flags(shared ? DBB_shared : 0),
579+
dbb_filename(*p),
580+
dbb_database_name(*p),
581+
#ifdef HAVE_ID_BY_NAME
582+
dbb_id(*p),
583+
#endif
584+
dbb_owner(*p),
585+
dbb_pools(*p, 4),
586+
dbb_sort_buffers(*p),
587+
dbb_gc_fini(*p, garbage_collector, THREAD_medium),
588+
dbb_stats(*p),
589+
dbb_lock_owner_id(getLockOwnerId()),
590+
dbb_tip_cache(NULL),
591+
dbb_creation_date(Firebird::TimeZoneUtil::getCurrentGmtTimeStamp()),
592+
dbb_external_file_directory_list(NULL),
593+
dbb_init_fini(FB_NEW_POOL(*getDefaultMemoryPool()) ExistenceRefMutex()),
594+
dbb_linger_seconds(0),
595+
dbb_linger_end(0),
596+
dbb_plugin_config(pConf),
597+
dbb_repl_sequence(0),
598+
dbb_replica_mode(REPLICA_NONE),
599+
dbb_compatibility_index(~0U),
600+
dbb_dic(*p),
601+
dbb_mdc(FB_NEW_POOL(*p) MetadataCache(*p)),
602+
dbb_delayed_delete(*p, *p)
603+
{
604+
dbb_pools.add(p);
605+
}
606+
607+
572608
GlobalPtr<Database::GlobalObjectHolder::DbIdHash>
573609
Database::GlobalObjectHolder::g_hashTable;
574610
GlobalPtr<Mutex> Database::GlobalObjectHolder::g_mutex;

src/jrd/Database.h

Lines changed: 4 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "../common/gdsassert.h"
3636
#include "../common/dsc.h"
3737
#include "../jrd/btn.h"
38+
#include "../jrd/vec.h"
3839
#include "../jrd/jrd_proto.h"
3940
#include "../jrd/val.h"
4041
#include "../jrd/irq.h"
@@ -90,6 +91,7 @@ class MonitoringData;
9091
class GarbageCollector;
9192
class CryptoManager;
9293
class KeywordsMap;
94+
class MetadataCache;
9395

9496
// allocator for keywords table
9597
class KeywordsMapAllocator
@@ -99,118 +101,6 @@ class KeywordsMapAllocator
99101
static void destroy(KeywordsMap* inst);
100102
};
101103

102-
// general purpose vector
103-
template <class T, BlockType TYPE = type_vec>
104-
class vec_base : protected pool_alloc<TYPE>
105-
{
106-
public:
107-
typedef typename Firebird::Array<T>::iterator iterator;
108-
typedef typename Firebird::Array<T>::const_iterator const_iterator;
109-
110-
/*
111-
static vec_base* newVector(MemoryPool& p, int len)
112-
{
113-
return FB_NEW_POOL(p) vec_base<T, TYPE>(p, len);
114-
}
115-
116-
static vec_base* newVector(MemoryPool& p, const vec_base& base)
117-
{
118-
return FB_NEW_POOL(p) vec_base<T, TYPE>(p, base);
119-
}
120-
*/
121-
122-
FB_SIZE_T count() const { return v.getCount(); }
123-
T& operator[](FB_SIZE_T index) { return v[index]; }
124-
const T& operator[](FB_SIZE_T index) const { return v[index]; }
125-
126-
iterator begin() { return v.begin(); }
127-
iterator end() { return v.end(); }
128-
129-
const_iterator begin() const { return v.begin(); }
130-
const_iterator end() const { return v.end(); }
131-
132-
void clear() { v.clear(); }
133-
134-
T* memPtr() { return &v[0]; }
135-
136-
void resize(FB_SIZE_T n, T val = T()) { v.resize(n, val); }
137-
138-
void operator delete(void* mem) { MemoryPool::globalFree(mem); }
139-
140-
protected:
141-
vec_base(MemoryPool& p, int len)
142-
: v(p, len)
143-
{
144-
v.resize(len);
145-
}
146-
147-
vec_base(MemoryPool& p, const vec_base& base)
148-
: v(p)
149-
{
150-
v = base.v;
151-
}
152-
153-
private:
154-
Firebird::Array<T> v;
155-
};
156-
157-
template <typename T>
158-
class vec : public vec_base<T, type_vec>
159-
{
160-
public:
161-
static vec* newVector(MemoryPool& p, int len)
162-
{
163-
return FB_NEW_POOL(p) vec<T>(p, len);
164-
}
165-
166-
static vec* newVector(MemoryPool& p, const vec& base)
167-
{
168-
return FB_NEW_POOL(p) vec<T>(p, base);
169-
}
170-
171-
static vec* newVector(MemoryPool& p, vec* base, int len)
172-
{
173-
if (!base)
174-
base = FB_NEW_POOL(p) vec<T>(p, len);
175-
else if (len > (int) base->count())
176-
base->resize(len);
177-
return base;
178-
}
179-
180-
private:
181-
vec(MemoryPool& p, int len) : vec_base<T, type_vec>(p, len) {}
182-
vec(MemoryPool& p, const vec& base) : vec_base<T, type_vec>(p, base) {}
183-
};
184-
185-
class vcl : public vec_base<ULONG, type_vcl>
186-
{
187-
public:
188-
static vcl* newVector(MemoryPool& p, int len)
189-
{
190-
return FB_NEW_POOL(p) vcl(p, len);
191-
}
192-
193-
static vcl* newVector(MemoryPool& p, const vcl& base)
194-
{
195-
return FB_NEW_POOL(p) vcl(p, base);
196-
}
197-
198-
static vcl* newVector(MemoryPool& p, vcl* base, int len)
199-
{
200-
if (!base)
201-
base = FB_NEW_POOL(p) vcl(p, len);
202-
else if (len > (int) base->count())
203-
base->resize(len);
204-
return base;
205-
}
206-
207-
private:
208-
vcl(MemoryPool& p, int len) : vec_base<ULONG, type_vcl>(p, len) {}
209-
vcl(MemoryPool& p, const vcl& base) : vec_base<ULONG, type_vcl>(p, base) {}
210-
};
211-
212-
typedef vec<TraNumber> TransactionsVector;
213-
214104

215105
//
216106
// bit values for dbb_flags
@@ -546,7 +436,7 @@ class Database : public pool_alloc<type_dbb>
546436
Dictionary dbb_dic; // metanames dictionary
547437
Firebird::InitInstance<KeywordsMap, KeywordsMapAllocator, Firebird::TraditionalDelete> dbb_keywords_map;
548438

549-
MetadataCache dbb_mdc;
439+
MetadataCache* dbb_mdc;
550440
HazardDelayedDelete dbb_delayed_delete;
551441
Firebird::Mutex dbb_dd_mutex;
552442

@@ -588,41 +478,7 @@ class Database : public pool_alloc<type_dbb>
588478
}
589479

590480
private:
591-
Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared)
592-
: dbb_permanent(p),
593-
dbb_page_manager(this, *p),
594-
dbb_file_id(*p),
595-
dbb_modules(*p),
596-
dbb_extManager(nullptr),
597-
dbb_flags(shared ? DBB_shared : 0),
598-
dbb_filename(*p),
599-
dbb_database_name(*p),
600-
#ifdef HAVE_ID_BY_NAME
601-
dbb_id(*p),
602-
#endif
603-
dbb_owner(*p),
604-
dbb_pools(*p, 4),
605-
dbb_sort_buffers(*p),
606-
dbb_gc_fini(*p, garbage_collector, THREAD_medium),
607-
dbb_stats(*p),
608-
dbb_lock_owner_id(getLockOwnerId()),
609-
dbb_tip_cache(NULL),
610-
dbb_creation_date(Firebird::TimeZoneUtil::getCurrentGmtTimeStamp()),
611-
dbb_external_file_directory_list(NULL),
612-
dbb_init_fini(FB_NEW_POOL(*getDefaultMemoryPool()) ExistenceRefMutex()),
613-
dbb_linger_seconds(0),
614-
dbb_linger_end(0),
615-
dbb_plugin_config(pConf),
616-
dbb_repl_sequence(0),
617-
dbb_replica_mode(REPLICA_NONE),
618-
dbb_compatibility_index(~0U),
619-
dbb_dic(*p),
620-
dbb_mdc(*p),
621-
dbb_delayed_delete(*p, *p)
622-
{
623-
dbb_pools.add(p);
624-
}
625-
481+
Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared);
626482
~Database();
627483

628484
public:

src/jrd/ExtEngineManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "../jrd/Function.h"
4747
#include "../jrd/TimeZone.h"
4848
#include "../jrd/SystemPackages.h"
49+
#include "../jrd/met.h"
4950
#include "../common/isc_proto.h"
5051
#include "../common/classes/auto.h"
5152
#include "../common/classes/fb_string.h"

0 commit comments

Comments
 (0)