Skip to content

Commit f4b14b1

Browse files
committed
Wipe out multi-file database support
1 parent 7b23935 commit f4b14b1

File tree

20 files changed

+312
-1347
lines changed

20 files changed

+312
-1347
lines changed

src/burp/restore.epp

Lines changed: 70 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4220,53 +4220,85 @@ bool get_files(BurpGlobals* tdgbl)
42204220
att_type attribute;
42214221
scan_attr_t scan_next_attr;
42224222

4223-
STORE (REQUEST_HANDLE tdgbl->handles_get_files_req_handle1)
4224-
X IN RDB$FILES
4225-
X.RDB$FILE_FLAGS = 0;
4223+
BASED_ON RDB$FILES.RDB$FILE_NAME filename = "";
4224+
SSHORT flags = 0, sequence = 0, number = 0;
4225+
SLONG start = 0, length = 0;
42264226

4227-
skip_init(&scan_next_attr);
4228-
while (skip_scan(&scan_next_attr), get_attribute(&attribute, tdgbl) != att_end)
4227+
skip_init(&scan_next_attr);
4228+
while (skip_scan(&scan_next_attr), get_attribute(&attribute, tdgbl) != att_end)
4229+
{
4230+
switch (attribute)
42294231
{
4230-
switch (attribute)
4231-
{
4232-
case att_file_filename:
4233-
GET_TEXT(X.RDB$FILE_NAME);
4234-
BURP_verbose (116, X.RDB$FILE_NAME);
4235-
// msg 116 restoring file %s
4236-
break;
4232+
case att_file_filename:
4233+
GET_TEXT(filename);
4234+
break;
42374235

4238-
case att_file_sequence:
4239-
X.RDB$FILE_SEQUENCE = (USHORT) get_int32(tdgbl);
4240-
break;
4236+
case att_file_sequence:
4237+
sequence = (SSHORT) get_int32(tdgbl);
4238+
break;
42414239

4242-
case att_file_start:
4243-
X.RDB$FILE_START = get_int32(tdgbl);
4244-
break;
4240+
case att_file_start:
4241+
start = get_int32(tdgbl);
4242+
break;
42454243

4246-
case att_file_length:
4247-
X.RDB$FILE_LENGTH = get_int32(tdgbl);
4248-
break;
4244+
case att_file_length:
4245+
length = get_int32(tdgbl);
4246+
break;
42494247

4250-
case att_file_flags:
4251-
X.RDB$FILE_FLAGS |= get_int32(tdgbl);
4252-
break;
4248+
case att_file_flags:
4249+
flags |= (SSHORT) get_int32(tdgbl);
4250+
break;
42534251

4254-
case att_shadow_number:
4255-
X.RDB$SHADOW_NUMBER = (USHORT) get_int32(tdgbl);
4256-
if (tdgbl->gbl_sw_kill && X.RDB$SHADOW_NUMBER)
4257-
X.RDB$FILE_FLAGS |= FILE_inactive;
4258-
break;
4252+
case att_shadow_number:
4253+
number = (SSHORT) get_int32(tdgbl);
4254+
if (tdgbl->gbl_sw_kill && number)
4255+
flags |= FILE_inactive;
4256+
break;
42594257

4260-
default:
4261-
bad_attribute(scan_next_attr, attribute, 85);
4262-
// msg 85 file
4263-
break;
4264-
}
4258+
default:
4259+
bad_attribute(scan_next_attr, attribute, 85);
4260+
// msg 85 file
4261+
break;
42654262
}
4266-
END_STORE;
4267-
ON_ERROR
4268-
general_on_error ();
4269-
END_ERROR;
4263+
}
4264+
4265+
const bool multiFileSupport = (tdgbl->runtimeODS <= DB_VERSION_DDL13_1);
4266+
4267+
if ((multiFileSupport || !sequence) && filename[0])
4268+
{
4269+
BURP_verbose (116, filename);
4270+
// msg 116 restoring file %s
4271+
4272+
STORE (REQUEST_HANDLE tdgbl->handles_get_files_req_handle1)
4273+
X IN RDB$FILES
4274+
4275+
strncpy(X.RDB$FILE_NAME, filename, sizeof(X.RDB$FILE_NAME));
4276+
X.RDB$FILE_FLAGS = flags;
4277+
X.RDB$SHADOW_NUMBER = number;
4278+
4279+
if (multiFileSupport)
4280+
{
4281+
X.RDB$FILE_SEQUENCE.NULL = FALSE;
4282+
X.RDB$FILE_SEQUENCE = sequence;
4283+
4284+
X.RDB$FILE_START.NULL = FALSE;
4285+
X.RDB$FILE_START = start;
4286+
4287+
X.RDB$FILE_LENGTH.NULL = FALSE;
4288+
X.RDB$FILE_LENGTH = length;
4289+
}
4290+
else
4291+
{
4292+
X.RDB$FILE_SEQUENCE.NULL = TRUE;
4293+
X.RDB$FILE_START.NULL = TRUE;
4294+
X.RDB$FILE_LENGTH.NULL = TRUE;
4295+
}
4296+
4297+
END_STORE;
4298+
ON_ERROR
4299+
general_on_error ();
4300+
END_ERROR;
4301+
}
42704302

42714303
return true;
42724304
}

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)
@@ -10370,7 +10327,7 @@ string CreateShadowNode::internalPrint(NodePrinter& printer) const
1037010327
NODE_PRINT(printer, number);
1037110328
NODE_PRINT(printer, manual);
1037210329
NODE_PRINT(printer, conditional);
10373-
NODE_PRINT(printer, files);
10330+
NODE_PRINT(printer, fileName);
1037410331

1037510332
return "CreateShadowNode";
1037610333
}
@@ -10394,7 +10351,7 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat
1039410351
// run all statements under savepoint control
1039510352
AutoSavePoint savePoint(tdbb, transaction);
1039610353

10397-
// If a shadow set identified by the shadow number already exists return error.
10354+
// If a shadow set identified by the shadow number already exists return error
1039810355

1039910356
AutoCacheRequest request(tdbb, drq_l_shadow, DYN_REQUESTS);
1040010357

@@ -10407,25 +10364,34 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat
1040710364
}
1040810365
END_FOR
1040910366

10410-
SLONG start = 0;
10367+
PathName expandedName = fileName.ToPathName();
1041110368

10412-
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
10369+
if (!ISC_expand_filename(expandedName, false))
10370+
status_exception::raise(Arg::PrivateDyn(231)); // File name is invalid
10371+
10372+
if (tdbb->getDatabase()->dbb_filename == expandedName)
10373+
status_exception::raise(Arg::PrivateDyn(166));
10374+
10375+
request.reset(tdbb, drq_l_files, DYN_REQUESTS);
10376+
10377+
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
10378+
FIRST 1 X IN RDB$FILES
10379+
WITH X.RDB$FILE_NAME EQ expandedName.c_str()
1041310380
{
10414-
bool first = i == files.begin();
10415-
DbFileClause* file = *i;
10381+
status_exception::raise(Arg::PrivateDyn(166));
10382+
}
10383+
END_FOR
1041610384

10417-
if (!first && i[-1]->length == 0 && file->start == 0)
10418-
{
10419-
// Preceding file did not specify length, so %s must include starting page number
10420-
status_exception::raise(
10421-
Arg::Gds(isc_sqlerr) << Arg::Num(-607) <<
10422-
Arg::Gds(isc_dsql_command_err) <<
10423-
Arg::Gds(isc_dsql_file_length_err) << file->name);
10424-
}
10385+
request.reset(tdbb, drq_s_files, DYN_REQUESTS);
1042510386

10426-
defineFile(tdbb, transaction, number, manual && first, conditional && first,
10427-
start, file->name.c_str(), file->start, file->length);
10387+
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
10388+
X IN RDB$FILES
10389+
{
10390+
expandedName.copyTo(X.RDB$FILE_NAME, sizeof(X.RDB$FILE_NAME));
10391+
X.RDB$SHADOW_NUMBER = number;
10392+
X.RDB$FILE_FLAGS = (manual ? FILE_manual : 0) | (conditional ? FILE_conditional : 0);
1042810393
}
10394+
END_STORE
1042910395

1043010396
savePoint.release(); // everything is ok
1043110397
}
@@ -12637,13 +12603,11 @@ string AlterDatabaseNode::internalPrint(NodePrinter& printer) const
1263712603
DdlNode::internalPrint(printer);
1263812604

1263912605
NODE_PRINT(printer, create);
12640-
NODE_PRINT(printer, createLength);
1264112606
NODE_PRINT(printer, linger);
1264212607
NODE_PRINT(printer, clauses);
1264312608
NODE_PRINT(printer, differenceFile);
1264412609
NODE_PRINT(printer, setDefaultCharSet);
1264512610
NODE_PRINT(printer, setDefaultCollation);
12646-
NODE_PRINT(printer, files);
1264712611
NODE_PRINT(printer, cryptPlugin);
1264812612
NODE_PRINT(printer, keyName);
1264912613

@@ -12819,18 +12783,6 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
1281912783
}
1282012784
}
1282112785

12822-
SLONG dbAlloc = PageSpace::maxAlloc(tdbb->getDatabase());
12823-
SLONG start = create ? createLength + 1 : 0;
12824-
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
12825-
{
12826-
DbFileClause* file = *i;
12827-
12828-
start = MAX(start, file->start);
12829-
defineFile(tdbb, transaction, 0, false, false, dbAlloc,
12830-
file->name.c_str(), start, file->length);
12831-
start += file->length;
12832-
}
12833-
1283412786
if (differenceFile.hasData())
1283512787
defineDifference(tdbb, transaction, differenceFile.c_str());
1283612788

@@ -12959,7 +12911,6 @@ void AlterDatabaseNode::changeBackupMode(thread_db* tdbb, jrd_tra* transaction,
1295912911
X IN RDB$FILES
1296012912
{
1296112913
X.RDB$FILE_FLAGS = FILE_difference | FILE_backing_up;
12962-
X.RDB$FILE_START = 0;
1296312914
}
1296412915
END_STORE
1296512916

@@ -13011,7 +12962,6 @@ void AlterDatabaseNode::defineDifference(thread_db* tdbb, jrd_tra* transaction,
1301112962

1301212963
strcpy(FIL.RDB$FILE_NAME, file.c_str());
1301312964
FIL.RDB$FILE_FLAGS = FILE_difference;
13014-
FIL.RDB$FILE_START = 0;
1301512965
}
1301612966
END_STORE
1301712967
}

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:
@@ -1960,12 +1926,13 @@ class DropFilterNode : public DdlNode
19601926
class CreateShadowNode : public DdlNode
19611927
{
19621928
public:
1963-
CreateShadowNode(MemoryPool& p, const SSHORT aNumber)
1929+
CreateShadowNode(MemoryPool& p, SSHORT aNumber, bool aManual, bool aConditional,
1930+
const Firebird::string& aFileName)
19641931
: DdlNode(p),
19651932
number(aNumber),
1966-
manual(false),
1967-
conditional(false),
1968-
files(p)
1933+
manual(aManual),
1934+
conditional(aConditional),
1935+
fileName(p, aFileName)
19691936
{
19701937
}
19711938

@@ -1989,7 +1956,7 @@ class CreateShadowNode : public DdlNode
19891956
SSHORT number;
19901957
bool manual;
19911958
bool conditional;
1992-
Firebird::Array<NestConst<DbFileClause> > files;
1959+
Firebird::string fileName;
19931960
};
19941961

19951962

@@ -2413,14 +2380,9 @@ class AlterDatabaseNode : public DdlNode
24132380
public:
24142381
AlterDatabaseNode(MemoryPool& p)
24152382
: DdlNode(p),
2416-
create(false),
2417-
createLength(0),
2418-
linger(-1),
2419-
clauses(0),
24202383
differenceFile(p),
24212384
setDefaultCharSet(p),
24222385
setDefaultCollation(p),
2423-
files(p),
24242386
cryptPlugin(p),
24252387
keyName(p),
24262388
pubTables(p)
@@ -2456,13 +2418,12 @@ class AlterDatabaseNode : public DdlNode
24562418
void checkClauses(thread_db* tdbb);
24572419

24582420
public:
2459-
bool create; // Is the node created with a CREATE DATABASE command?
2460-
SLONG createLength, linger;
2461-
unsigned clauses;
2421+
bool create = false; // Is the node created with a CREATE DATABASE command?
2422+
SLONG linger = -1;
2423+
unsigned clauses = 0;
24622424
Firebird::string differenceFile;
24632425
MetaName setDefaultCharSet;
24642426
MetaName setDefaultCollation;
2465-
Firebird::Array<NestConst<DbFileClause> > files;
24662427
MetaName cryptPlugin;
24672428
MetaName keyName;
24682429
Firebird::TriState ssDefiner;

0 commit comments

Comments
 (0)