@@ -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)
@@ -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}
0 commit comments