Skip to content

Commit f0740d2

Browse files
authored
Wipe out multi-file database support (#8047)
* Wipe out multi-file database support * Fix (fingers crossed) Windows build, some more cleanup and code simplification * Fix gstat build on Windows and also Android/MacOS builds
1 parent 1251401 commit f0740d2

File tree

22 files changed

+375
-1495
lines changed

22 files changed

+375
-1495
lines changed

src/burp/restore.epp

Lines changed: 70 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,53 +4204,85 @@ bool get_files(BurpGlobals* tdgbl)
42044204
att_type attribute;
42054205
scan_attr_t scan_next_attr;
42064206

4207-
STORE (REQUEST_HANDLE tdgbl->handles_get_files_req_handle1)
4208-
X IN RDB$FILES
4209-
X.RDB$FILE_FLAGS = 0;
4207+
BASED_ON RDB$FILES.RDB$FILE_NAME filename = "";
4208+
SSHORT flags = 0, sequence = 0, number = 0;
4209+
SLONG start = 0, length = 0;
42104210

4211-
skip_init(&scan_next_attr);
4212-
while (skip_scan(&scan_next_attr), get_attribute(&attribute, tdgbl) != att_end)
4211+
skip_init(&scan_next_attr);
4212+
while (skip_scan(&scan_next_attr), get_attribute(&attribute, tdgbl) != att_end)
4213+
{
4214+
switch (attribute)
42134215
{
4214-
switch (attribute)
4215-
{
4216-
case att_file_filename:
4217-
GET_TEXT(X.RDB$FILE_NAME);
4218-
BURP_verbose (116, X.RDB$FILE_NAME);
4219-
// msg 116 restoring file %s
4220-
break;
4216+
case att_file_filename:
4217+
GET_TEXT(filename);
4218+
break;
42214219

4222-
case att_file_sequence:
4223-
X.RDB$FILE_SEQUENCE = (USHORT) get_int32(tdgbl);
4224-
break;
4220+
case att_file_sequence:
4221+
sequence = (SSHORT) get_int32(tdgbl);
4222+
break;
42254223

4226-
case att_file_start:
4227-
X.RDB$FILE_START = get_int32(tdgbl);
4228-
break;
4224+
case att_file_start:
4225+
start = get_int32(tdgbl);
4226+
break;
42294227

4230-
case att_file_length:
4231-
X.RDB$FILE_LENGTH = get_int32(tdgbl);
4232-
break;
4228+
case att_file_length:
4229+
length = get_int32(tdgbl);
4230+
break;
42334231

4234-
case att_file_flags:
4235-
X.RDB$FILE_FLAGS |= get_int32(tdgbl);
4236-
break;
4232+
case att_file_flags:
4233+
flags |= (SSHORT) get_int32(tdgbl);
4234+
break;
42374235

4238-
case att_shadow_number:
4239-
X.RDB$SHADOW_NUMBER = (USHORT) get_int32(tdgbl);
4240-
if (tdgbl->gbl_sw_kill && X.RDB$SHADOW_NUMBER)
4241-
X.RDB$FILE_FLAGS |= FILE_inactive;
4242-
break;
4236+
case att_shadow_number:
4237+
number = (SSHORT) get_int32(tdgbl);
4238+
if (tdgbl->gbl_sw_kill && number)
4239+
flags |= FILE_inactive;
4240+
break;
42434241

4244-
default:
4245-
bad_attribute(scan_next_attr, attribute, 85);
4246-
// msg 85 file
4247-
break;
4248-
}
4242+
default:
4243+
bad_attribute(scan_next_attr, attribute, 85);
4244+
// msg 85 file
4245+
break;
42494246
}
4250-
END_STORE;
4251-
ON_ERROR
4252-
general_on_error ();
4253-
END_ERROR;
4247+
}
4248+
4249+
const bool multiFileSupport = (tdgbl->runtimeODS <= DB_VERSION_DDL13_1);
4250+
4251+
if ((multiFileSupport || !sequence) && filename[0])
4252+
{
4253+
BURP_verbose (116, filename);
4254+
// msg 116 restoring file %s
4255+
4256+
STORE (REQUEST_HANDLE tdgbl->handles_get_files_req_handle1)
4257+
X IN RDB$FILES
4258+
4259+
strncpy(X.RDB$FILE_NAME, filename, sizeof(X.RDB$FILE_NAME));
4260+
X.RDB$FILE_FLAGS = flags;
4261+
X.RDB$SHADOW_NUMBER = number;
4262+
4263+
if (multiFileSupport)
4264+
{
4265+
X.RDB$FILE_SEQUENCE.NULL = FALSE;
4266+
X.RDB$FILE_SEQUENCE = sequence;
4267+
4268+
X.RDB$FILE_START.NULL = FALSE;
4269+
X.RDB$FILE_START = start;
4270+
4271+
X.RDB$FILE_LENGTH.NULL = FALSE;
4272+
X.RDB$FILE_LENGTH = length;
4273+
}
4274+
else
4275+
{
4276+
X.RDB$FILE_SEQUENCE.NULL = TRUE;
4277+
X.RDB$FILE_START.NULL = TRUE;
4278+
X.RDB$FILE_LENGTH.NULL = TRUE;
4279+
}
4280+
4281+
END_STORE;
4282+
ON_ERROR
4283+
general_on_error ();
4284+
END_ERROR;
4285+
}
42544286

42554287
return true;
42564288
}

src/dsql/DdlNodes.epp

Lines changed: 25 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ static void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode*
8080
dsql_fld* field, ValueSourceClause* clause, string& source, BlrDebugWriter::BlrData& value);
8181
static void deleteKeyConstraint(thread_db* tdbb, jrd_tra* transaction,
8282
const MetaName& relationName, const MetaName& constraintName, const MetaName& indexName);
83-
static void defineFile(thread_db* tdbb, jrd_tra* transaction, SLONG shadowNumber, bool manualShadow,
84-
bool conditionalShadow, SLONG& dbAlloc,
85-
const PathName& name, SLONG start, SLONG length);
8683
static bool fieldExists(thread_db* tdbb, jrd_tra* transaction, const MetaName& relationName,
8784
const MetaName& fieldName);
8885
static bool isItSqlRole(thread_db* tdbb, jrd_tra* transaction, const MetaName& inputName,
@@ -490,46 +487,6 @@ static void deleteKeyConstraint(thread_db* tdbb, jrd_tra* transaction,
490487
}
491488
}
492489

493-
// Define a database or shadow file.
494-
static void defineFile(thread_db* tdbb, jrd_tra* transaction, SLONG shadowNumber, bool manualShadow,
495-
bool conditionalShadow, SLONG& dbAlloc, const PathName& name, SLONG start, SLONG length)
496-
{
497-
PathName expandedName = name;
498-
499-
if (!ISC_expand_filename(expandedName, false))
500-
status_exception::raise(Arg::PrivateDyn(231)); // File name is invalid.
501-
502-
if (tdbb->getDatabase()->dbb_filename == expandedName)
503-
status_exception::raise(Arg::PrivateDyn(166));
504-
505-
AutoCacheRequest request(tdbb, drq_l_files, DYN_REQUESTS);
506-
507-
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
508-
FIRST 1 X IN RDB$FILES
509-
WITH X.RDB$FILE_NAME EQ expandedName.c_str()
510-
{
511-
status_exception::raise(Arg::PrivateDyn(166));
512-
}
513-
END_FOR
514-
515-
request.reset(tdbb, drq_s_files, DYN_REQUESTS);
516-
517-
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
518-
X IN RDB$FILES
519-
{
520-
expandedName.copyTo(X.RDB$FILE_NAME, sizeof(X.RDB$FILE_NAME));
521-
X.RDB$SHADOW_NUMBER = shadowNumber;
522-
X.RDB$FILE_FLAGS = (manualShadow ? FILE_manual : 0) |
523-
(conditionalShadow ? FILE_conditional : 0);
524-
525-
dbAlloc = MAX(dbAlloc, start);
526-
X.RDB$FILE_START = dbAlloc;
527-
X.RDB$FILE_LENGTH = length;
528-
dbAlloc += length;
529-
}
530-
END_STORE
531-
}
532-
533490
// Checks to see if the given field already exists in a relation.
534491
static bool fieldExists(thread_db* tdbb, jrd_tra* transaction, const MetaName& relationName,
535492
const MetaName& fieldName)
@@ -10462,7 +10419,7 @@ string CreateShadowNode::internalPrint(NodePrinter& printer) const
1046210419
NODE_PRINT(printer, number);
1046310420
NODE_PRINT(printer, manual);
1046410421
NODE_PRINT(printer, conditional);
10465-
NODE_PRINT(printer, files);
10422+
NODE_PRINT(printer, fileName);
1046610423

1046710424
return "CreateShadowNode";
1046810425
}
@@ -10486,7 +10443,7 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat
1048610443
// run all statements under savepoint control
1048710444
AutoSavePoint savePoint(tdbb, transaction);
1048810445

10489-
// If a shadow set identified by the shadow number already exists return error.
10446+
// If a shadow set identified by the shadow number already exists return error
1049010447

1049110448
AutoCacheRequest request(tdbb, drq_l_shadow, DYN_REQUESTS);
1049210449

@@ -10502,25 +10459,34 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat
1050210459
}
1050310460
END_FOR
1050410461

10505-
SLONG start = 0;
10462+
PathName expandedName = fileName.ToPathName();
1050610463

10507-
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
10464+
if (!ISC_expand_filename(expandedName, false))
10465+
status_exception::raise(Arg::PrivateDyn(231)); // File name is invalid
10466+
10467+
if (tdbb->getDatabase()->dbb_filename == expandedName)
10468+
status_exception::raise(Arg::PrivateDyn(166));
10469+
10470+
request.reset(tdbb, drq_l_files, DYN_REQUESTS);
10471+
10472+
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
10473+
FIRST 1 X IN RDB$FILES
10474+
WITH X.RDB$FILE_NAME EQ expandedName.c_str()
1050810475
{
10509-
bool first = i == files.begin();
10510-
DbFileClause* file = *i;
10476+
status_exception::raise(Arg::PrivateDyn(166));
10477+
}
10478+
END_FOR
1051110479

10512-
if (!first && i[-1]->length == 0 && file->start == 0)
10513-
{
10514-
// Preceding file did not specify length, so %s must include starting page number
10515-
status_exception::raise(
10516-
Arg::Gds(isc_sqlerr) << Arg::Num(-607) <<
10517-
Arg::Gds(isc_dsql_command_err) <<
10518-
Arg::Gds(isc_dsql_file_length_err) << file->name);
10519-
}
10480+
request.reset(tdbb, drq_s_files, DYN_REQUESTS);
1052010481

10521-
defineFile(tdbb, transaction, number, manual && first, conditional && first,
10522-
start, file->name.c_str(), file->start, file->length);
10482+
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
10483+
X IN RDB$FILES
10484+
{
10485+
expandedName.copyTo(X.RDB$FILE_NAME, sizeof(X.RDB$FILE_NAME));
10486+
X.RDB$SHADOW_NUMBER = number;
10487+
X.RDB$FILE_FLAGS = (manual ? FILE_manual : 0) | (conditional ? FILE_conditional : 0);
1052310488
}
10489+
END_STORE
1052410490

1052510491
savePoint.release(); // everything is ok
1052610492
}
@@ -12742,13 +12708,11 @@ string AlterDatabaseNode::internalPrint(NodePrinter& printer) const
1274212708
DdlNode::internalPrint(printer);
1274312709

1274412710
NODE_PRINT(printer, create);
12745-
NODE_PRINT(printer, createLength);
1274612711
NODE_PRINT(printer, linger);
1274712712
NODE_PRINT(printer, clauses);
1274812713
NODE_PRINT(printer, differenceFile);
1274912714
NODE_PRINT(printer, setDefaultCharSet);
1275012715
NODE_PRINT(printer, setDefaultCollation);
12751-
NODE_PRINT(printer, files);
1275212716
NODE_PRINT(printer, cryptPlugin);
1275312717
NODE_PRINT(printer, keyName);
1275412718

@@ -12924,18 +12888,6 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
1292412888
}
1292512889
}
1292612890

12927-
SLONG dbAlloc = PageSpace::maxAlloc(tdbb->getDatabase());
12928-
SLONG start = create ? createLength + 1 : 0;
12929-
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
12930-
{
12931-
DbFileClause* file = *i;
12932-
12933-
start = MAX(start, file->start);
12934-
defineFile(tdbb, transaction, 0, false, false, dbAlloc,
12935-
file->name.c_str(), start, file->length);
12936-
start += file->length;
12937-
}
12938-
1293912891
if (differenceFile.hasData())
1294012892
defineDifference(tdbb, transaction, differenceFile.c_str());
1294112893

@@ -13064,7 +13016,6 @@ void AlterDatabaseNode::changeBackupMode(thread_db* tdbb, jrd_tra* transaction,
1306413016
X IN RDB$FILES
1306513017
{
1306613018
X.RDB$FILE_FLAGS = FILE_difference | FILE_backing_up;
13067-
X.RDB$FILE_START = 0;
1306813019
}
1306913020
END_STORE
1307013021

@@ -13116,7 +13067,6 @@ void AlterDatabaseNode::defineDifference(thread_db* tdbb, jrd_tra* transaction,
1311613067

1311713068
strcpy(FIL.RDB$FILE_NAME, file.c_str());
1311813069
FIL.RDB$FILE_FLAGS = FILE_difference;
13119-
FIL.RDB$FILE_START = 0;
1312013070
}
1312113071
END_STORE
1312213072
}

src/dsql/DdlNodes.h

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -101,40 +101,6 @@ class ValueSourceClause : public Printable
101101
};
102102

103103

104-
class DbFileClause : public Printable
105-
{
106-
public:
107-
DbFileClause(MemoryPool& p, const DbFileClause& o)
108-
: name(p, o.name),
109-
start(o.start),
110-
length(o.length)
111-
{
112-
}
113-
114-
explicit DbFileClause(MemoryPool& p, const Firebird::string& aName)
115-
: name(p, aName),
116-
start(0),
117-
length(0)
118-
{
119-
}
120-
121-
public:
122-
virtual Firebird::string internalPrint(NodePrinter& printer) const
123-
{
124-
NODE_PRINT(printer, name);
125-
NODE_PRINT(printer, start);
126-
NODE_PRINT(printer, length);
127-
128-
return "DbFileClause";
129-
}
130-
131-
public:
132-
Firebird::string name; // File name
133-
SLONG start; // Starting page
134-
SLONG length; // File length in pages
135-
};
136-
137-
138104
class ExternalClause : public Printable
139105
{
140106
public:
@@ -1967,12 +1933,13 @@ class DropFilterNode : public DdlNode
19671933
class CreateShadowNode : public DdlNode
19681934
{
19691935
public:
1970-
CreateShadowNode(MemoryPool& p, const SSHORT aNumber)
1936+
CreateShadowNode(MemoryPool& p, SSHORT aNumber, bool aManual, bool aConditional,
1937+
const Firebird::string& aFileName)
19711938
: DdlNode(p),
19721939
number(aNumber),
1973-
manual(false),
1974-
conditional(false),
1975-
files(p)
1940+
manual(aManual),
1941+
conditional(aConditional),
1942+
fileName(p, aFileName)
19761943
{
19771944
}
19781945

@@ -1996,7 +1963,7 @@ class CreateShadowNode : public DdlNode
19961963
SSHORT number;
19971964
bool manual;
19981965
bool conditional;
1999-
Firebird::Array<NestConst<DbFileClause> > files;
1966+
Firebird::string fileName;
20001967
bool createIfNotExistsOnly = false;
20011968
};
20021969

@@ -2425,14 +2392,9 @@ class AlterDatabaseNode : public DdlNode
24252392
public:
24262393
AlterDatabaseNode(MemoryPool& p)
24272394
: DdlNode(p),
2428-
create(false),
2429-
createLength(0),
2430-
linger(-1),
2431-
clauses(0),
24322395
differenceFile(p),
24332396
setDefaultCharSet(p),
24342397
setDefaultCollation(p),
2435-
files(p),
24362398
cryptPlugin(p),
24372399
keyName(p),
24382400
pubTables(p)
@@ -2468,13 +2430,12 @@ class AlterDatabaseNode : public DdlNode
24682430
void checkClauses(thread_db* tdbb);
24692431

24702432
public:
2471-
bool create; // Is the node created with a CREATE DATABASE command?
2472-
SLONG createLength, linger;
2473-
unsigned clauses;
2433+
bool create = false; // Is the node created with a CREATE DATABASE command?
2434+
SLONG linger = -1;
2435+
unsigned clauses = 0;
24742436
Firebird::string differenceFile;
24752437
MetaName setDefaultCharSet;
24762438
MetaName setDefaultCollation;
2477-
Firebird::Array<NestConst<DbFileClause> > files;
24782439
MetaName cryptPlugin;
24792440
MetaName keyName;
24802441
Firebird::TriState ssDefiner;

0 commit comments

Comments
 (0)