8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 05:23:03 +01:00

Various cleanup to make engine compile and work after mentioned earlier changes.

Mainly:
1) MemoryPool* => MemoryPool& in arrays' constructors
2) use Firebird::string to keep strings data
This commit is contained in:
alexpeshkoff 2004-03-14 13:40:14 +00:00
parent 9603b40b4d
commit 67f1740fea
36 changed files with 178 additions and 167 deletions

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: locks.h,v 1.11 2004-03-07 07:58:25 robocop Exp $
* $Id: locks.h,v 1.12 2004-03-14 13:40:09 alexpeshkoff Exp $
*
*/
@ -179,6 +179,6 @@ public:
#endif /* MULTI_THREAD */
}
} //namespace Firebird
#endif // CLASSES_LOCKS_H

View File

@ -174,7 +174,8 @@ public:
}
};
typedef Firebird::SortedArray<const char*, const char*,
typedef Firebird::SortedArray<const char*,
Firebird::EmptyStorage<const char*>, const char*,
Firebird::DefaultKeyValue<const char*>,
CStrCmp>
StrArray;
@ -1254,7 +1255,7 @@ dsql_nod* PASS1_statement(dsql_req* request, dsql_nod* input, bool proc_flag)
node->nod_arg[e_exe_blk_body] = input->nod_arg[e_exe_blk_body];
{
StrArray names( getDefaultMemoryPool(),
StrArray names( *getDefaultMemoryPool(),
node->nod_arg[e_exe_blk_inputs] ?
node->nod_arg[e_exe_blk_inputs]->nod_count : 0 +
node->nod_arg[e_exe_blk_outputs] ?

View File

@ -22,10 +22,10 @@ namespace Firebird
{
public:
vector(int len) : std::vector<T, Firebird::allocator<T> >(len) {}
vector(int len, MemoryPool &p, SSHORT type = 0)
vector(int len, MemoryPool& p, SSHORT type = 0)
: std::vector<T, Firebird::allocator<T> >(len, T(),
Firebird::allocator<T>(p, type)) {}
vector(MemoryPool &p, SSHORT type = 0)
vector(MemoryPool& p, SSHORT type = 0)
: std::vector<T, Firebird::allocator<T> >(
Firebird::allocator<T>(p, type) ) {}
};

View File

@ -1542,7 +1542,7 @@ void BTR_selectivity(thread_db* tdbb, jrd_rel* relation, USHORT id, SelectivityL
const USHORT segments = root->irt_rpt[id].irt_keys;
SSHORT count, stuff_count, pos, i;
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(tdbb->tdbb_default);
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(*tdbb->tdbb_default);
duplicatesList.grow(segments);
memset(duplicatesList.begin(), 0, segments * sizeof(ULONG));
@ -2311,7 +2311,7 @@ static CONTENTS delete_node(thread_db* tdbb, WIN *window, UCHAR *pointer)
// remove jump nodes pointing to the deleted node or node
// next to the deleted one.
jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default)
jumpNodeList(tdbb->tdbb_default);
jumpNodeList(*tdbb->tdbb_default);
IndexJumpInfo jumpInfo;
pointer = BTreeNode::getPointerFirstNode(page, &jumpInfo);
@ -2562,7 +2562,7 @@ static SLONG fast_load(thread_db* tdbb,
typedef Firebird::vector<jumpNodeList*> jumpNodeListContainer;
jumpNodeListContainer* jumpNodes = FB_NEW(*tdbb->tdbb_default)
jumpNodeListContainer(*tdbb->tdbb_default);
jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default));
jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default));
keyList* jumpKeys = FB_NEW(*tdbb->tdbb_default) keyList(*tdbb->tdbb_default);
jumpKeys->push_back(FB_NEW(*tdbb->tdbb_default) dynKey);
@ -2652,7 +2652,7 @@ static SLONG fast_load(thread_db* tdbb,
ULONG duplicates = 0;
const USHORT segments = idx->idx_count;
SSHORT segment, stuff_count, pos, i;
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(tdbb->tdbb_default);
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(*tdbb->tdbb_default);
duplicatesList.grow(segments);
memset(duplicatesList.begin(), 0, segments * sizeof(ULONG));
@ -2979,7 +2979,7 @@ static SLONG fast_load(thread_db* tdbb,
// Initialize jumpNodes variables for new level
jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default)
jumpNodeList(tdbb->tdbb_default));
jumpNodeList(*tdbb->tdbb_default));
jumpKeys->push_back(FB_NEW(*tdbb->tdbb_default) dynKey);
(*jumpKeys)[level]->keyLength = 0;
(*jumpKeys)[level]->keyData =
@ -4392,7 +4392,7 @@ static CONTENTS garbage_collect(thread_db* tdbb, WIN * window, SLONG parent_numb
newBucket->btr_length += l;
// Generate new jump nodes.
jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default);
jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default);
USHORT jumpersNewSize = 0;
// Update jump information on scratch page, so generate_jump_nodes
// can deal with it.
@ -4971,7 +4971,7 @@ static SLONG insert_node(thread_db* tdbb,
USHORT newPrefixTotalBySplit = 0;
USHORT splitJumpNodeIndex = 0;
IndexJumpInfo jumpInfo;
jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default);
jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default);
USHORT ensureEndInsert = 0;
if (endOfPage) {

View File

@ -1686,7 +1686,7 @@ void CCH_init(thread_db* tdbb, ULONG number)
if (count != (SLONG) bcb_->bcb_count) {
gds__log
("Database: %s\n\tAllocated %ld page buffers of %ld requested",
tdbb->tdbb_attachment->att_filename->str_data, bcb_->bcb_count, count);
tdbb->tdbb_attachment->att_filename.c_str(), bcb_->bcb_count, count);
}
if (dbb->dbb_lock->lck_logical != LCK_EX) {
@ -3243,8 +3243,7 @@ static void THREAD_ROUTINE cache_writer(Database* dbb)
tdbb->tdbb_default = dbb->dbb_bufferpool;
tdbb->tdbb_status_vector = status_vector;
tdbb->tdbb_quantum = QUANTUM;
tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_bufferpool) att;
tdbb->tdbb_attachment->att_database = dbb;
tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_bufferpool) att(dbb);
tdbb->tdbb_attachment->att_filename = dbb->dbb_filename;
/* This try block is specifically to protect the LCK_init call: if

View File

@ -1843,7 +1843,7 @@ jrd_req* CMP_make_request(thread_db* tdbb, Csb* csb)
MsgInvariantArray* msg_invariants;
if (!msg->nod_arg[e_msg_invariants]) {
msg_invariants = FB_NEW(*tdbb->tdbb_default)
MsgInvariantArray(tdbb->tdbb_default);
MsgInvariantArray(*tdbb->tdbb_default);
msg->nod_arg[e_msg_invariants] =
reinterpret_cast<jrd_nod*>(msg_invariants);
}
@ -1866,7 +1866,7 @@ jrd_req* CMP_make_request(thread_db* tdbb, Csb* csb)
if (!(*var_invariants)) {
*var_invariants = FB_NEW(*tdbb->tdbb_default)
VarInvariantArray(tdbb->tdbb_default);
VarInvariantArray(*tdbb->tdbb_default);
}
int pos;
if (!(*var_invariants)->find((*link_ptr)->nod_impure, pos))
@ -3174,7 +3174,7 @@ static jrd_nod* pass1(thread_db* tdbb,
{
(*i_node)->nod_variables =
FB_NEW(*tdbb->tdbb_default)
Firebird::Array<jrd_nod*>(tdbb->tdbb_default);
Firebird::Array<jrd_nod*>(*tdbb->tdbb_default);
}
(*i_node)->nod_variables->add(node);
}

View File

@ -49,7 +49,7 @@
*
*/
/*
$Id: common.h,v 1.108 2004-03-12 07:00:46 skidder Exp $
$Id: common.h,v 1.109 2004-03-14 13:39:44 alexpeshkoff Exp $
*/
#ifndef JRD_COMMON_H
@ -1088,16 +1088,6 @@ inline int fb_stricmp(const char* a, const char* b)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
inline char* fb_getcwd(char* output_buf, size_t len)
{
#if defined(WIN_NT)
return _getcwd(output_buf, len);
#elif defined(HAVE_GETCWD)
return getcwd(output_buf, len);
#else
return getwd(output_buf);
#endif
}
#endif /* JRD_COMMON_H */

View File

@ -27,16 +27,15 @@
#include "../common/config/config.h"
#include "../common/config/config_file.h"
#include "../jrd/os/path_utils.h"
#include "../jrd/gds_proto.h"
typedef Firebird::PathName string;
const char* ALIAS_FILE = "aliases.conf";
bool ResolveDatabaseAlias(const char* alias, char* database)
bool ResolveDatabaseAlias(const string& alias, string& database)
{
TEXT alias_filename[MAXPATHLEN];
gds__prefix(alias_filename, const_cast<char*>(ALIAS_FILE));
string alias_filename;
Firebird::Prefix(alias_filename, ALIAS_FILE);
ConfigFile aliasConfig(false);
aliasConfig.setConfigFile(alias_filename);
@ -45,17 +44,17 @@ bool ResolveDatabaseAlias(const char* alias, char* database)
string corrected_alias = alias;
std::replace(corrected_alias.begin(), corrected_alias.end(), incorrect_dir_sep, correct_dir_sep);
string value = aliasConfig.getString(corrected_alias);
database = aliasConfig.getString(corrected_alias);
if (!value.empty())
if (!database.empty())
{
std::replace(value.begin(), value.end(), incorrect_dir_sep, correct_dir_sep);
if (PathUtils::isRelative(value)) {
std::replace(database.begin(), database.end(), incorrect_dir_sep, correct_dir_sep);
if (PathUtils::isRelative(database)) {
gds__log("Value %s configured for alias %s "
"is not a fully qualified path name, ignored", value.c_str(), alias);
"is not a fully qualified path name, ignored",
database.c_str(), alias.c_str());
return false;
}
strcpy(database, value.c_str());
return true;
}

View File

@ -22,5 +22,5 @@
#ifndef DB_ALIAS_H
#define DB_ALIAS_H
bool ResolveDatabaseAlias(const char* alias, char* database);
bool ResolveDatabaseAlias(const Firebird::PathName& alias, Firebird::PathName& database);
#endif

View File

@ -49,6 +49,7 @@
*/
#include "firebird.h"
#include "fb_string.h"
#include "../jrd/ib_stdio.h"
#include <string.h>
#include "../jrd/common.h"
@ -743,7 +744,7 @@ static bool add_file(thread_db* tdbb, SSHORT phase, Deferred_work* work,
USHORT section, shadow_number;
SLONG start, max;
BLK handle, handle2;
TEXT temp[MAXPATHLEN];
Firebird::PathName temp;
SET_TDBB(tdbb);
Database* dbb = tdbb->tdbb_database;
@ -792,9 +793,9 @@ static bool add_file(thread_db* tdbb, SSHORT phase, Deferred_work* work,
** for shadows in add_shadow ()) */
if (work->dfw_type != dfw_add_shadow)
{
ISC_expand_filename(X.RDB$FILE_NAME, 0, temp);
ISC_expand_filename(X.RDB$FILE_NAME, temp);
MODIFY X USING
strcpy(X.RDB$FILE_NAME, temp);
strcpy(X.RDB$FILE_NAME, temp.c_str());
END_MODIFY;
}
@ -879,7 +880,7 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work,
USHORT sequence, add_sequence;
bool finished;
ULONG min_page;
TEXT expanded_fname[1024];
Firebird::PathName expanded_fname;
SET_TDBB(tdbb);
Database* dbb = tdbb->tdbb_database;
@ -910,9 +911,9 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work,
FOR(REQUEST_HANDLE handle)
F IN RDB$FILES
WITH F.RDB$FILE_NAME EQ work->dfw_name
ISC_expand_filename(F.RDB$FILE_NAME, 0, expanded_fname);
ISC_expand_filename(F.RDB$FILE_NAME, expanded_fname);
MODIFY F USING
strcpy(F.RDB$FILE_NAME, expanded_fname);
strcpy(F.RDB$FILE_NAME, expanded_fname.c_str());
END_MODIFY;
for (shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next)
@ -982,7 +983,7 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work,
X IN RDB$FILES CROSS
Y IN RDB$FILES
OVER RDB$SHADOW_NUMBER
WITH X.RDB$FILE_NAME EQ expanded_fname
WITH X.RDB$FILE_NAME EQ expanded_fname.c_str()
SORTED BY Y.RDB$FILE_START
/* for the first file, create a brand new shadow; for secondary
files that have a starting page specified, add a file */
@ -1592,7 +1593,7 @@ static bool create_index( thread_db* tdbb,
}
if (IDX.RDB$INDEX_ID && IDX.RDB$STATISTICS < 0.0)
{
SelectivityList selectivity(tdbb->tdbb_default);
SelectivityList selectivity(*tdbb->tdbb_default);
const USHORT id = IDX.RDB$INDEX_ID - 1;
IDX_statistics(tdbb, relation, id, selectivity);
DFW_update_index(work->dfw_name, id, selectivity);
@ -1776,7 +1777,7 @@ static bool create_index( thread_db* tdbb,
}
fb_assert(work->dfw_id == dbb->dbb_max_idx);
SelectivityList selectivity(tdbb->tdbb_default);
SelectivityList selectivity(*tdbb->tdbb_default);
IDX_create_index(tdbb, relation, &idx, work->dfw_name,
&work->dfw_id, transaction, selectivity);
fb_assert(work->dfw_id == idx.idx_id);

View File

@ -215,10 +215,9 @@ MDLS* DLS_get_access(void)
static bool is_initialized = false;
if (!is_initialized) {
is_initialized = true;
TempDirectoryList dir_list;
Firebird::TempDirectoryList dir_list;
for (size_t i = 0; i < dir_list.Count(); i++) {
TempDirectoryList::Item item = dir_list[i];
DLS_add_dir(item.size, item.dir.c_str());
DLS_add_dir(dir_list[i].second, dir_list[i].first.c_str());
}
}

View File

@ -38,6 +38,7 @@
*/
#include "firebird.h"
#include "fb_string.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -797,7 +798,6 @@ void DYN_define_file(GBL gbl,
BLK request;
SLONG temp;
USHORT man_auto;
TEXT temp_f1[MAXPATHLEN], temp_f[MAXPATHLEN];
SSHORT id;
thread_db* tdbb = GET_THREAD_DATA;
@ -811,14 +811,16 @@ void DYN_define_file(GBL gbl,
request = CMP_find_request(tdbb, id = drq_l_files, DYN_REQUESTS);
TEXT temp_f1[MAXPATHLEN];
GET_STRING(ptr, temp_f1);
ISC_expand_filename(temp_f1, 0, temp_f);
if (!strcmp((char*)dbb->dbb_filename->str_data, temp_f)) {
Firebird::PathName temp_f;
ISC_expand_filename(temp_f1, temp_f);
if (dbb->dbb_filename == temp_f) {
DYN_error_punt(false, 166, NULL, NULL, NULL, NULL, NULL);
}
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FIRST 1 X IN RDB$FILES WITH X.RDB$FILE_NAME EQ temp_f
FIRST 1 X IN RDB$FILES WITH X.RDB$FILE_NAME EQ temp_f.c_str()
DYN_error_punt(false, 166, NULL, NULL, NULL, NULL, NULL);
END_FOR;
@ -826,7 +828,7 @@ void DYN_define_file(GBL gbl,
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
X IN RDB$FILES
strcpy(X.RDB$FILE_NAME, temp_f);
strcpy(X.RDB$FILE_NAME, temp_f.c_str());
X.RDB$SHADOW_NUMBER = (SSHORT)shadow_number;
X.RDB$FILE_FLAGS = 0;
X.RDB$FILE_FLAGS.NULL = FALSE;
@ -2515,7 +2517,6 @@ void DYN_define_log_file(
UCHAR verb;
BLK request;
SSHORT id;
STR db_filename;
thread_db* tdbb = GET_THREAD_DATA;
Database* dbb = tdbb->tdbb_database;
@ -2553,12 +2554,11 @@ void DYN_define_log_file(
X.RDB$FILE_P_OFFSET.NULL = TRUE;
if (default_log) {
db_filename = dbb->dbb_filename;
if (db_filename->str_length >= sizeof(X.RDB$FILE_NAME))
if (dbb->dbb_filename.length() >= sizeof(X.RDB$FILE_NAME))
DYN_error_punt(false, 159, NULL, NULL, NULL, NULL, NULL);
memcpy(X.RDB$FILE_NAME, db_filename->str_data,
(int) db_filename->str_length);
X.RDB$FILE_NAME[db_filename->str_length] = '\0';
memcpy(X.RDB$FILE_NAME, dbb->dbb_filename.c_str(),
dbb->dbb_filename.length());
X.RDB$FILE_NAME[dbb->dbb_filename.length()] = '\0';
X.RDB$FILE_FLAGS.NULL = FALSE;
X.RDB$FILE_FLAGS = LOG_default | LOG_serial;
}

View File

@ -281,15 +281,8 @@ void ERR_log(int facility, int number, const TEXT* message)
sprintf(errmsg + strlen(errmsg), " (%d)", number);
const UCHAR* dbname = 0;
if (tdbb && tdbb->tdbb_attachment)
{
dbname = ((tdbb->tdbb_attachment->att_filename) ?
tdbb->tdbb_attachment->att_filename->str_data : NULL);
}
gds__log("Database: %s\n\t%s",
(dbname) ? reinterpret_cast<const SCHAR*>(dbname) : "",
gds__log("Database: %s\n\t%s", (tdbb && tdbb->tdbb_attachment) ?
tdbb->tdbb_attachment->att_filename.c_str() : "",
errmsg, 0);
}
#endif
@ -496,9 +489,8 @@ void ERR_punt(void)
if (dbb && (dbb->dbb_flags & DBB_bugcheck))
{
const UCHAR* dbname = ((tdbb->tdbb_attachment->att_filename) ?
tdbb->tdbb_attachment->att_filename->str_data : NULL);
gds__log_status(reinterpret_cast<const char*>(dbname),
gds__log_status(tdbb->tdbb_attachment->att_filename ?
tdbb->tdbb_attachment->att_filename.c_str() : NULL,
tdbb->tdbb_status_vector);
}

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: evl_string.h,v 1.7 2004-02-20 06:42:59 robocop Exp $
* $Id: evl_string.h,v 1.8 2004-03-14 13:39:45 alexpeshkoff Exp $
*
*/
@ -112,11 +112,11 @@ static void preKmp(const CharType *x, int m, SSHORT kmpNext[]) {
class StaticAllocator {
public:
StaticAllocator(MemoryPool* _pool) : chunksToFree(_pool), pool(_pool), allocated(0) {};
StaticAllocator(MemoryPool& _pool) : chunksToFree(_pool), pool(_pool), allocated(0) {};
~StaticAllocator() {
for (int i=0; i < chunksToFree.getCount(); i++)
pool->deallocate(chunksToFree[i]);
pool.deallocate(chunksToFree[i]);
}
void* alloc(SSHORT count) {
@ -127,14 +127,14 @@ public:
return result;
}
else {
result = pool->allocate(count);
result = pool.allocate(count);
chunksToFree.add(result);
return result;
}
}
private:
Array<void*> chunksToFree;
MemoryPool* pool;
MemoryPool& pool;
char allocBuffer[STATIC_PATTERN_BUFFER];
int allocated;
};
@ -142,7 +142,7 @@ private:
template <typename CharType>
class ContainsEvaluator : private StaticAllocator {
public:
ContainsEvaluator(MemoryPool* _pool, const CharType* _pattern_str, SSHORT _pattern_len) :
ContainsEvaluator(MemoryPool& _pool, const CharType* _pattern_str, SSHORT _pattern_len) :
StaticAllocator(_pool), pattern_len(_pattern_len)
{
CharType* temp = reinterpret_cast<CharType*>(alloc(_pattern_len*sizeof(CharType)));
@ -207,7 +207,7 @@ enum MatchType {
template <typename CharType>
class LikeEvaluator : private StaticAllocator {
public:
LikeEvaluator(MemoryPool* _pool, const CharType* _pattern_str,
LikeEvaluator(MemoryPool& _pool, const CharType* _pattern_str,
SSHORT pattern_len, CharType escape_char, CharType sql_match_any,
CharType sql_match_one);
@ -258,7 +258,7 @@ private:
template <typename CharType>
LikeEvaluator<CharType>::LikeEvaluator(
MemoryPool* _pool, const CharType* _pattern_str, SSHORT pattern_len,
MemoryPool& _pool, const CharType* _pattern_str, SSHORT pattern_len,
CharType escape_char, CharType sql_match_any, CharType sql_match_one)
: StaticAllocator(_pool), patternItems(_pool), branches(_pool), match_type(MATCH_NONE)
{

View File

@ -1074,7 +1074,7 @@ inline void PreModifyEraseTriggers(thread_db* tdbb,
if (! tdbb->tdbb_transaction->tra_rpblist) {
tdbb->tdbb_transaction->tra_rpblist =
FB_NEW(*tdbb->tdbb_transaction->tra_pool)
traRpbList(tdbb->tdbb_transaction->tra_pool);
traRpbList(*tdbb->tdbb_transaction->tra_pool);
}
const int rpblevel = tdbb->tdbb_transaction->
tra_rpblist->PushRpb(rpb);

View File

@ -585,10 +585,10 @@ public:
csb_msg_number(0),
csb_impure(0),
csb_g_flags(0),*/
csb_fors(&p),
csb_invariants(&p),
csb_current_nodes(&p),
csb_rpt(&p, len)
csb_fors(p),
csb_invariants(p),
csb_current_nodes(p),
csb_rpt(p, len)
{}
static Csb* newCsb(MemoryPool& p, size_t len)

View File

@ -43,6 +43,7 @@
#define WHY_NO_API
#include "../jrd/why_proto.h"
#include "../common/classes/auto.h"
#include "../jrd/execute_statement.h"
WHY_DBB GetWhyAttachment(ISC_STATUS* status,
@ -91,7 +92,7 @@ void ExecuteStatement::Open(thread_db* tdbb, jrd_nod* sql, SSHORT nVars, bool Si
fb_assert(tdbb->tdbb_transaction->tra_pool);
// We allocated char[N]; therefore, make sure we deallocate char's and with delete[]
AutoPtrFromString<vary> v = reinterpret_cast<vary*> (
Firebird::AutoPtrFromString<vary> v = reinterpret_cast<vary*> (
FB_NEW(*tdbb->tdbb_transaction->tra_pool) char[BUFFER_LARGE + sizeof(vary)]);
v->vary_length = BUFFER_LARGE;
UCHAR* p = 0;

View File

@ -33,7 +33,6 @@
#include "../jrd/exe.h"
#include "../jrd/y_ref.h"
#include "../jrd/ibase.h"
#include "../common/classes/auto.h"
#define MAX_CALLBACKS 50

View File

@ -57,26 +57,35 @@
#include "../common/config/config.h"
#include "../common/config/dir_list.h"
#include "../jrd/os/path_utils.h"
#include "../common/classes/init.h"
namespace {
IB_FILE *ext_fopen(const char *filename, const char *mode);
IB_FILE *ext_fopen(const char *filename, const char *mode);
class ExternalFileDirectoryList : public DirectoryList {
const Firebird::PathName GetConfigString(void) const {
return Firebird::PathName(Config::getExternalFileAccess());
class ExternalFileDirectoryList : public Firebird::DirectoryList
{
private:
const Firebird::PathName getConfigString(void) const {
return Firebird::PathName(Config::getExternalFileAccess());
}
public:
ExternalFileDirectoryList(MemoryPool& p) : DirectoryList(p)
{
initialize();
}
};
Firebird::InitInstance<ExternalFileDirectoryList> iExternalFileDirectoryList;
IB_FILE *ext_fopen(const char *filename, const char *mode) {
if (!iExternalFileDirectoryList().isPathInList(filename))
ERR_post(isc_conf_access_denied,
isc_arg_string, "external file",
isc_arg_string, ERR_cstring(filename),
isc_arg_end);
return ib_fopen(filename, mode);
}
} iExternalFileDirectoryList;
IB_FILE *ext_fopen(const char *filename, const char *mode) {
if (!iExternalFileDirectoryList.IsPathInList(filename))
ERR_post(isc_conf_access_denied,
isc_arg_string, "external file",
isc_arg_string, ERR_cstring(filename),
isc_arg_end);
return ib_fopen(filename, mode);
}
};
#ifdef WIN_NT
#define FOPEN_TYPE "a+b"
@ -160,7 +169,7 @@ EXT EXT_file(jrd_rel* relation, const TEXT* file_name, bid* description)
Firebird::PathName Path, Name;
PathUtils::splitLastComponent(Path, Name, file_name);
if (Path.length() == 0) { // path component not present in file_name
iExternalFileDirectoryList.ExpandFileName(Path, Name, 4);
iExternalFileDirectoryList().expandFileName(Path, Name, 4);
file_name = Path.c_str();
}

View File

@ -43,13 +43,14 @@
*
*/
/*
$Id: flu.cpp,v 1.45 2004-02-20 06:43:00 robocop Exp $
$Id: flu.cpp,v 1.46 2004-03-14 13:39:45 alexpeshkoff Exp $
*/
#include "firebird.h"
#include "../common/config/config.h"
#include "../common/config/dir_list.h"
#include "../jrd/os/path_utils.h"
#include "../common/classes/init.h"
#include "../jrd/common.h"
#include "../jrd/flu.h"
@ -831,6 +832,22 @@ static int condition_handler(int *sig, int *mech, int *enbl)
}
#endif
namespace {
class UdfDirectoryList : public Firebird::DirectoryList
{
private:
const Firebird::PathName getConfigString(void) const {
return Firebird::PathName(Config::getUdfAccess());
}
public:
UdfDirectoryList(MemoryPool& p) : DirectoryList(p)
{
initialize();
}
};
Firebird::InitInstance<UdfDirectoryList> iUdfDirectoryList;
}
static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError)
{
/**************************************
@ -847,12 +864,7 @@ static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError
#ifndef REQUIRED_MODULE_ACCESS
return NULL;
#else
static class UdfDirectoryList : public DirectoryList {
const Firebird::PathName GetConfigString(void) const {
return Firebird::PathName(Config::getUdfAccess());
}
} iUdfDirectoryList;
Firebird::PathName path, relative;
Firebird::PathName absolute_module = module_name;
@ -860,12 +872,12 @@ static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError
PathUtils::splitLastComponent(path, relative, absolute_module);
if (path.length() == 0 && PathUtils::isRelative(absolute_module)) {
relative = absolute_module;
iUdfDirectoryList.ExpandFileName(absolute_module, relative, REQUIRED_MODULE_ACCESS);
iUdfDirectoryList().expandFileName(absolute_module, relative, REQUIRED_MODULE_ACCESS);
}
// The module name, including directory path,
// must satisfy UdfAccess entry in config file.
if (!iUdfDirectoryList.IsPathInList(absolute_module)) {
if (!iUdfDirectoryList().isPathInList(absolute_module)) {
if (ShowAccessError) {
ERR_post(isc_conf_access_denied,
isc_arg_string, "UDF library",

View File

@ -1615,8 +1615,6 @@ void API_ROUTINE gds__prefix(TEXT* resultString, const TEXT* file)
*
* Functional description
* Find appropriate file prefix.
* Override conditional defines with
* the enviroment variable FIREBIRD if it is set.
*
**************************************/
resultString[0] = 0;

View File

@ -458,10 +458,10 @@ int INF_database_info(const SCHAR* items,
case isc_info_db_id:
{
const str* str_fn = tdbb->tdbb_attachment->att_filename;
const Firebird::PathName& str_fn = tdbb->tdbb_attachment->att_filename;
STUFF(p, 2);
*p++ = l = str_fn->str_length;
for (q = reinterpret_cast<const SCHAR*>(str_fn->str_data); *q;)
*p++ = l = str_fn.length();
for (q = str_fn.c_str(); *q;)
*p++ = *q++;
ISC_get_host(site, sizeof(site));
*p++ = l = strlen(site);

View File

@ -959,7 +959,7 @@ static void add_index_set(Database* dbb,
}
idx.idx_count = index->ini_idx_segment_count;
idx.idx_flags = index->ini_idx_flags;
SelectivityList selectivity(tdbb->tdbb_default);
SelectivityList selectivity(*tdbb->tdbb_default);
IDX_create_index(tdbb, relation, &idx, string, NULL, NULL,
selectivity);
X.RDB$INDEX_ID = idx.idx_id + 1;

View File

@ -40,6 +40,9 @@
#endif /* __cplusplus */
#ifdef __cplusplus
#include "fb_string.h"
extern "C" {
#endif
@ -168,7 +171,7 @@ void JRD_wlck_unlock(struct mutx_t *);
#ifdef SUPERSERVER
void JRD_print_all_counters(const TEXT*);
USHORT JRD_getdir(TEXT*, USHORT);
bool JRD_getdir(Firebird::PathName&);
#endif
#ifdef DEBUG_PROCS
@ -179,5 +182,19 @@ void JRD_print_procedure_info(thread_db*, const char*);
} /* extern "C" */
#endif
inline bool fb_getcwd(Firebird::PathName& pn)
{
char buffer[MAXPATHLEN];
#if defined(WIN_NT)
_getcwd(buffer, MAXPATHLEN);
#elif defined(HAVE_GETCWD)
getcwd(buffer, MAXPATHLEN);
#else
getwd(buffer);
#endif
pn = buffer;
return bool(buffer);
}
#endif /* JRD_JRD_PROTO_H */

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: nbak.cpp,v 1.25 2004-03-13 01:57:52 skidder Exp $
* $Id: nbak.cpp,v 1.26 2004-03-14 13:39:46 alexpeshkoff Exp $
*
*/
@ -504,7 +504,7 @@ int BackupManager::backup_database_ast(void *ast_object) throw()
/********************************** CORE LOGIC ********************************/
void BackupManager::generate_filename() throw() {
strncpy(diff_name, (char*)database->dbb_filename->str_data, sizeof(diff_name));
strncpy(diff_name, (char*)database->dbb_filename.c_str(), sizeof(diff_name));
strncat(diff_name, ".delta", sizeof(diff_name)-strlen(diff_name)-1);
}

View File

@ -2024,7 +2024,7 @@ static USHORT distribute_equalities(LLS * org_stack, Csb* csb, USHORT base_count
* operation '$'.
*
**************************************/
Firebird::HalfStaticArray<LLS, OPT_STATIC_ITEMS> classes(GET_THREAD_DATA->tdbb_default);
Firebird::HalfStaticArray<LLS, OPT_STATIC_ITEMS> classes(*GET_THREAD_DATA->tdbb_default);
LLS *eq_class, stack;
DEV_BLKCHK(*org_stack, type_lls);
@ -2901,7 +2901,7 @@ static void find_best(thread_db* tdbb,
// Save the various flag bits from the optimizer block to reset its
// state after each test.
Firebird::HalfStaticArray<UCHAR, OPT_STATIC_ITEMS>
stream_flags(tdbb->tdbb_default), conjunct_flags(tdbb->tdbb_default);
stream_flags(*tdbb->tdbb_default), conjunct_flags(*tdbb->tdbb_default);
stream_flags.grow(csb->csb_n_stream);
conjunct_flags.grow(opt->opt_base_conjuncts);
int i;
@ -4287,10 +4287,10 @@ static Rsb* gen_retrieval(thread_db* tdbb,
could be calculated via the index; currently we won't detect that case
*/
Firebird::HalfStaticArray<IDX*, OPT_STATIC_ITEMS> idx_walk_vector(tdbb->tdbb_default);
Firebird::HalfStaticArray<IDX*, OPT_STATIC_ITEMS> idx_walk_vector(*tdbb->tdbb_default);
idx_walk_vector.grow(csb_tail->csb_indices);
IDX** idx_walk = idx_walk_vector.begin();
Firebird::HalfStaticArray<UINT64, OPT_STATIC_ITEMS> idx_priority_level_vector(tdbb->tdbb_default);
Firebird::HalfStaticArray<UINT64, OPT_STATIC_ITEMS> idx_priority_level_vector(*tdbb->tdbb_default);
idx_priority_level_vector.grow(csb_tail->csb_indices);
UINT64* idx_priority_level = idx_priority_level_vector.begin();
@ -4382,10 +4382,10 @@ static Rsb* gen_retrieval(thread_db* tdbb,
// when necessary build the index
Firebird::HalfStaticArray<SSHORT, OPT_STATIC_ITEMS>
conjunct_position_vector(tdbb->tdbb_default);
conjunct_position_vector(*tdbb->tdbb_default);
Firebird::HalfStaticArray<Opt::opt_conjunct*, OPT_STATIC_ITEMS>
matching_nodes_vector(tdbb->tdbb_default);
matching_nodes_vector(*tdbb->tdbb_default);
for (i = 0; i < idx_walk_count; i++)
{
@ -4983,7 +4983,7 @@ static bool gen_sort_merge(thread_db* tdbb, OPT opt, LLS * org_rivers)
river1->riv_number = cnt++;
}
Firebird::HalfStaticArray<jrd_nod*, OPT_STATIC_ITEMS> scratch(tdbb->tdbb_default);
Firebird::HalfStaticArray<jrd_nod*, OPT_STATIC_ITEMS> scratch(*tdbb->tdbb_default);
scratch.grow(opt->opt_base_conjuncts * cnt);
jrd_nod** classes = scratch.begin();
@ -5042,7 +5042,7 @@ static bool gen_sort_merge(thread_db* tdbb, OPT opt, LLS * org_rivers)
to indicate that nothing could be done. */
USHORT river_cnt = 0, stream_cnt = 0;
Firebird::HalfStaticArray<jrd_nod**, OPT_STATIC_ITEMS> selected_classes(tdbb->tdbb_default, cnt);
Firebird::HalfStaticArray<jrd_nod**, OPT_STATIC_ITEMS> selected_classes(*tdbb->tdbb_default, cnt);
for (eq_class = classes; eq_class < last_class; eq_class += cnt) {
i = river_count(cnt, eq_class);
if (i > river_cnt) {
@ -5611,11 +5611,11 @@ static jrd_nod* make_inversion(thread_db* tdbb, OPT opt, jrd_nod* boolean, USHOR
// TMN: Shouldn't this be allocated from the tdbb->tdbb_default pool?
Firebird::HalfStaticArray<IDX*, OPT_STATIC_ITEMS>
idx_walk_vector(tdbb->tdbb_default);
idx_walk_vector(*tdbb->tdbb_default);
idx_walk_vector.grow(csb_tail->csb_indices);
IDX** idx_walk = idx_walk_vector.begin();
Firebird::HalfStaticArray<UINT64, OPT_STATIC_ITEMS>
idx_priority_level_vector(tdbb->tdbb_default);
idx_priority_level_vector(*tdbb->tdbb_default);
idx_priority_level_vector.grow(csb_tail->csb_indices);
UINT64* idx_priority_level = idx_priority_level_vector.begin();
@ -6738,7 +6738,7 @@ static void sort_indices_by_selectivity(csb_repeat* csb_tail)
IDX* selected_idx = NULL;
USHORT i, j;
Firebird::Array<IDX> idx_sort(GET_THREAD_DATA->tdbb_default, csb_tail->csb_indices);
Firebird::Array<IDX> idx_sort(*GET_THREAD_DATA->tdbb_default, csb_tail->csb_indices);
float selectivity;
bool same_selectivity = false;
@ -6808,7 +6808,7 @@ static SSHORT sort_indices_by_priority(csb_repeat * csb_tail,
* Sort indices based on the priority level.
*
***************************************************/
Firebird::HalfStaticArray<IDX*, OPT_STATIC_ITEMS> idx_csb(GET_THREAD_DATA->tdbb_default);
Firebird::HalfStaticArray<IDX*, OPT_STATIC_ITEMS> idx_csb(*GET_THREAD_DATA->tdbb_default);
idx_csb.grow(csb_tail->csb_indices);
memcpy(idx_csb.begin(), idx_walk, csb_tail->csb_indices * sizeof(IDX*));

View File

@ -395,7 +395,7 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
nt_error("ReadFile", file, isc_io_read_err, 0);
}
(*dbb->dbb_decrypt) (reinterpret_cast<char*>(dbb->dbb_encrypt_key->str_data),
(*dbb->dbb_decrypt) (dbb->dbb_encrypt_key.c_str(),
spare_buffer, length, address);
}
else
@ -608,7 +608,7 @@ bool PIO_read(jrd_file* file, Buffer_desc* bdb, PAG page, ISC_STATUS* status_vec
return nt_error("ReadFile", file, isc_io_read_err, status_vector);
}
(*dbb->dbb_decrypt) (reinterpret_cast<char*>(dbb->dbb_encrypt_key->str_data),
(*dbb->dbb_decrypt) (dbb->dbb_encrypt_key.c_str(),
spare_buffer, size, page);
}
else
@ -821,7 +821,7 @@ bool PIO_write(jrd_file* file, Buffer_desc* bdb, PAG page, ISC_STATUS* status_ve
if (dbb->dbb_encrypt_key) {
SLONG spare_buffer[MAX_PAGE_SIZE / sizeof(SLONG)];
(*dbb->dbb_encrypt) (reinterpret_cast<char*>(dbb->dbb_encrypt_key->str_data),
(*dbb->dbb_encrypt) (dbb->dbb_encrypt_key.c_str(),
page, size, spare_buffer);
if (!WriteFile(desc, spare_buffer, size, &actual_length, overlapped_ptr)

View File

@ -135,7 +135,7 @@ typedef srpb *SRPB;
class jrd_req : public pool_alloc_rpt<rpb, type_req>
{
public:
jrd_req(JrdMemoryPool* pool) : req_fors(pool), req_invariants(pool) { };
jrd_req(JrdMemoryPool* pool) : req_fors(*pool), req_invariants(*pool) { };
ATT req_attachment; // database attachment
USHORT req_count; // number of streams
USHORT req_incarnation; // incarnation number

View File

@ -20,7 +20,7 @@
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* $Id: rse.cpp,v 1.59 2004-03-11 05:03:58 robocop Exp $
* $Id: rse.cpp,v 1.60 2004-03-14 13:39:46 alexpeshkoff Exp $
*
* 2001.07.28: John Bellardo: Implemented rse_skip and made rse_first work with
* seekable streams.
@ -3311,7 +3311,7 @@ static void pop_rpbs(jrd_req* request, Rsb* rsb)
*
**************************************/
// temporary sparse bitmap of the used streams
Firebird::HalfStaticArray<UCHAR, OPT_STATIC_ITEMS> streams(request->req_pool);
Firebird::HalfStaticArray<UCHAR, OPT_STATIC_ITEMS> streams(*request->req_pool);
switch (rsb->rsb_type) {
case rsb_indexed:
@ -3424,7 +3424,7 @@ static void push_rpbs(thread_db* tdbb, jrd_req* request, Rsb* rsb)
SET_TDBB(tdbb);
// temporary sparse bitmap of the used streams
Firebird::HalfStaticArray<UCHAR, OPT_STATIC_ITEMS> streams(request->req_pool);
Firebird::HalfStaticArray<UCHAR, OPT_STATIC_ITEMS> streams(*request->req_pool);
switch (rsb->rsb_type) {
case rsb_indexed:

View File

@ -339,7 +339,7 @@ public:
};
Firebird::HalfStaticArray<opt_conjunct, OPT_STATIC_ITEMS> opt_conjuncts;
Firebird::HalfStaticArray<opt_stream, OPT_STATIC_ITEMS> opt_streams;
Opt(JrdMemoryPool* pool) : opt_conjuncts(pool), opt_streams(pool) {}
Opt(JrdMemoryPool* pool) : opt_conjuncts(*pool), opt_streams(*pool) {}
};
typedef Opt* OPT;

View File

@ -390,7 +390,7 @@ static bool bad_mode(bool ignore) {
*status++ = isc_bad_shutdown_mode;
*status++ = isc_arg_string;
*status++ = (ISC_STATUS) (IPTR)
ERR_cstring(reinterpret_cast<const TEXT*>(tdbb->tdbb_database->dbb_filename->str_data));
ERR_cstring(reinterpret_cast<const TEXT*>(tdbb->tdbb_database->dbb_filename.c_str()));
*status++ = isc_arg_end;
}
return ignore;

View File

@ -1397,8 +1397,8 @@ jrd_tra* TRA_start(thread_db* tdbb, int tpb_length, const SCHAR* tpb)
if (dbb->dbb_ast_flags & DBB_shut_tran) {
ERR_post(isc_shutinprog, isc_arg_cstring,
tdbb->tdbb_attachment->att_filename->str_length,
tdbb->tdbb_attachment->att_filename->str_data,
tdbb->tdbb_attachment->att_filename.length(),
tdbb->tdbb_attachment->att_filename.c_str(),
0);
}
@ -2643,8 +2643,7 @@ static BOOLEAN start_sweeper(thread_db* tdbb, Database* dbb)
LCK_release(tdbb, &temp_lock);
/* allocate space for the string and a null at the end */
const char* pszFilename =
reinterpret_cast<const char*>(tdbb->tdbb_attachment->att_filename->str_data);
const char* pszFilename = tdbb->tdbb_attachment->att_filename.c_str();
char* database = (char*)gds__alloc(strlen(pszFilename) + 1);

View File

@ -769,7 +769,7 @@ static RTN corrupt(thread_db* tdbb, VDR control, USHORT err_code, jrd_rel* relat
const TEXT* string = msg_table[err_code];
sprintf(s, "Database: %s\n\t",
tdbb->tdbb_attachment->att_filename->str_data);
tdbb->tdbb_attachment->att_filename.c_str());
TEXT* p;
for (p = s; *p; p++)

View File

@ -3574,8 +3574,7 @@ static void THREAD_ROUTINE garbage_collector(Database* dbb)
/* Pseudo attachment needed for lock owner identification. */
tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_permanent) att();
tdbb->tdbb_attachment->att_database = dbb;
tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_permanent) att(dbb);
tdbb->tdbb_attachment->att_filename = dbb->dbb_filename;
tdbb->tdbb_attachment->att_flags = ATT_garbage_collector;

View File

@ -36,6 +36,7 @@
#include <string.h>
#include "../remote/remote.h"
#include "../jrd/gdsassert.h"
#include "../jrd/jrd_proto.h"
#include <stdarg.h>
#ifndef NO_NFS
@ -4617,25 +4618,19 @@ static void add_working_directory(UCHAR* dpb_or_spb,
* settings that the server should know about.
*
************************************************/
char cwd[MAXPATHLEN];
Firebird::PathName cwd;
if (node_name && !strcmp(node_name, "localhost"))
{
fb_getcwd(cwd, sizeof(cwd));
fb_getcwd(cwd);
}
else
{
/** Remote database. Pass Null **/
cwd[0] = 0;
}
const USHORT len = strlen(cwd);
if (*length == 0) {
dpb_or_spb[(*length)++] = isc_dpb_version1;
}
dpb_or_spb[(*length)++] = isc_dpb_working_directory;
dpb_or_spb[(*length)++] = len;
memcpy(&(dpb_or_spb[(*length)]), cwd, len);
*length += len;
dpb_or_spb[(*length)++] = cwd.length();
memcpy(&(dpb_or_spb[(*length)]), cwd.c_str(), cwd.length());
*length += cwd.length();
}

View File

@ -30,6 +30,7 @@
#include "firebird.h"
#include "fb_string.h"
#include "../jrd/common.h"
#include "../jrd/ib_stdio.h"
#include "../common/classes/alloc.h"
@ -496,9 +497,9 @@ int CLIB_ROUTINE main(int argc, char** argv)
/* Open database and go to work */
TEXT temp_buf[MAXPATHLEN];
if (ResolveDatabaseAlias(name, temp_buf)) {
name = temp_buf;
Firebird::PathName temp_buf = name;
if (ResolveDatabaseAlias(temp_buf, temp_buf)) {
name = temp_buf.c_str();
}
dba_fil* current = db_open(name, strlen(name));