@@ -80,9 +80,6 @@ static void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode*
8080 dsql_fld* field, ValueSourceClause* clause, string& source, BlrDebugWriter::BlrData& value);
8181static 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);
8683static bool fieldExists(thread_db* tdbb, jrd_tra* transaction, const MetaName& relationName,
8784 const MetaName& fieldName);
8885static 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.
534491static 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}
0 commit comments