Skip to content

Commit 2d8c902

Browse files
committed
Corrections and simplifications.
1 parent cff7722 commit 2d8c902

File tree

10 files changed

+103
-83
lines changed

10 files changed

+103
-83
lines changed

src/dsql/DdlNodes.epp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ static void checkSpTrigDependency(thread_db* tdbb, jrd_tra* transaction,
279279

280280
// msg 206: Column %s from table %s is referenced in %s.
281281
status_exception::raise(
282-
Arg::PrivateDyn(206) << fieldName << relationName.toQuotedString() << depName.toQuotedString());
282+
Arg::PrivateDyn(206) <<
283+
fieldName.toQuotedString() <<
284+
relationName.toQuotedString() <<
285+
depName.toQuotedString());
283286
}
284287
END_FOR
285288
}
@@ -311,7 +314,10 @@ static void checkViewDependency(thread_db* tdbb, jrd_tra* transaction,
311314

312315
// msg 206: Column %s from table %s is referenced in %s.
313316
status_exception::raise(
314-
Arg::PrivateDyn(206) << fieldName << relationName.toQuotedString() << viewName.toQuotedString());
317+
Arg::PrivateDyn(206) <<
318+
fieldName.toQuotedString() <<
319+
relationName.toQuotedString() <<
320+
viewName.toQuotedString());
315321
}
316322
END_FOR
317323
}
@@ -695,7 +701,10 @@ static void modifyLocalFieldPosition(thread_db* tdbb, jrd_tra* transaction,
695701
if (!found)
696702
{
697703
// msg 176: "column %s does not exist in table/view %s"
698-
status_exception::raise(Arg::PrivateDyn(176) << fieldName << relationName.toQuotedString());
704+
status_exception::raise(
705+
Arg::PrivateDyn(176) <<
706+
fieldName.toQuotedString() <<
707+
relationName.toQuotedString());
699708
}
700709

701710
// Find the position of the last field in the relation.
@@ -2318,7 +2327,7 @@ void CreateAlterFunctionNode::storeArgument(thread_db* tdbb, DsqlCompilerScratch
23182327
status_exception::raise(
23192328
Arg::Gds(isc_dyn_defvaldecl_package_func) <<
23202329
name.getSchemaAndPackage().toQuotedString() <<
2321-
name.object);
2330+
name.object.toQuotedString());
23222331
}
23232332

23242333
ARG.RDB$DEFAULT_VALUE.NULL = FALSE;
@@ -3254,7 +3263,7 @@ void CreateAlterProcedureNode::storeParameter(thread_db* tdbb, DsqlCompilerScrat
32543263
status_exception::raise(
32553264
Arg::Gds(isc_dyn_defvaldecl_package_proc) <<
32563265
name.getSchemaAndPackage().toQuotedString() <<
3257-
name.object);
3266+
name.object.toQuotedString());
32583267
}
32593268

32603269
attachment->storeMetaDataBlob(tdbb, transaction, &PRM.RDB$DEFAULT_SOURCE,
@@ -6508,7 +6517,7 @@ bool RelationNode::deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
65086517
// msg 52: "field %s from relation %s is referenced in view %s"
65096518
status_exception::raise(
65106519
Arg::PrivateDyn(52) <<
6511-
fieldName <<
6520+
fieldName.toQuotedString() <<
65126521
relationName.toQuotedString() <<
65136522
QualifiedName(Y.RDB$RELATION_NAME, Y.RDB$SCHEMA_NAME).toQuotedString());
65146523
}
@@ -6544,7 +6553,10 @@ bool RelationNode::deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
65446553
{
65456554
// msg 187: "field %s from relation %s is referenced in index %s"
65466555
status_exception::raise(
6547-
Arg::PrivateDyn(187) << fieldName << relationName.toQuotedString() << IDX.RDB$INDEX_NAME);
6556+
Arg::PrivateDyn(187) <<
6557+
fieldName.toQuotedString() <<
6558+
relationName.toQuotedString() <<
6559+
MetaName(IDX.RDB$INDEX_NAME).toQuotedString());
65486560
}
65496561
}
65506562
END_FOR
@@ -6575,8 +6587,9 @@ bool RelationNode::deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
65756587
// msg 187: "field %s from relation %s is referenced in index %s"
65766588
status_exception::raise(
65776589
Arg::PrivateDyn(187) <<
6578-
fieldName << relationName.toQuotedString() <<
6579-
fb_utils::exact_name_limit(IDX.RDB$INDEX_NAME, sizeof(IDX.RDB$INDEX_NAME)));
6590+
fieldName.toQuotedString() <<
6591+
relationName.toQuotedString() <<
6592+
MetaName(IDX.RDB$INDEX_NAME).toQuotedString());
65806593
}
65816594
END_FOR
65826595

@@ -6633,7 +6646,10 @@ bool RelationNode::deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
66336646
if (!found && !silent)
66346647
{
66356648
// msg 176: "column %s does not exist in table/view %s"
6636-
status_exception::raise(Arg::PrivateDyn(176) << fieldName << relationName.toQuotedString());
6649+
status_exception::raise(
6650+
Arg::PrivateDyn(176) <<
6651+
fieldName.toQuotedString() <<
6652+
relationName.toQuotedString());
66376653
}
66386654

66396655
return found;
@@ -12481,12 +12497,12 @@ void GrantRevokeNode::grantRevoke(thread_db* tdbb, jrd_tra* transaction, const G
1248112497
if (isGrant)
1248212498
{
1248312499
// msg 195: keyword NONE could not be used as SQL role name.
12484-
status_exception::raise(Arg::PrivateDyn(195) << objName.object.c_str());
12500+
status_exception::raise(Arg::PrivateDyn(195) << objName.object.toQuotedString());
1248512501
}
1248612502
else
1248712503
{
1248812504
///CVC: Make this a warning in the future.
12489-
///DYN_error_punt(false, 195, objName.c_str());
12505+
///DYN_error_punt(false, 195, objName.toQuotedString());
1249012506
}
1249112507
}
1249212508

@@ -12787,7 +12803,7 @@ void GrantRevokeNode::checkGrantorCanGrantRelation(thread_db* tdbb, jrd_tra* tra
1278712803
{
1278812804
// column .. does not exist in table/view ..
1278912805
status_exception::raise(Arg::PrivateDyn(176) <<
12790-
fieldName <<
12806+
fieldName.toQuotedString() <<
1279112807
relationName.toQuotedString());
1279212808
}
1279312809
}
@@ -12871,7 +12887,7 @@ void GrantRevokeNode::checkGrantorCanGrantRelation(thread_db* tdbb, jrd_tra* tra
1287112887
{
1287212888
// no grant option for privilege .. on column .. of [base] table/view ..
1287312889
status_exception::raise(Arg::PrivateDyn(topLevel ? 167 : 168) <<
12874-
privilegeName(*privilege) << fieldName.c_str() << relationName.toQuotedString());
12890+
privilegeName(*privilege) << fieldName.toQuotedString() << relationName.toQuotedString());
1287512891
}
1287612892

1287712893
if (goFld == -1)
@@ -12880,14 +12896,14 @@ void GrantRevokeNode::checkGrantorCanGrantRelation(thread_db* tdbb, jrd_tra* tra
1288012896
{
1288112897
// no grant option for privilege .. on [base] table/view .. (for column ..)
1288212898
status_exception::raise(Arg::PrivateDyn(topLevel ? 169 : 170) <<
12883-
privilegeName(*privilege) << relationName.toQuotedString() << fieldName.c_str());
12899+
privilegeName(*privilege) << relationName.toQuotedString() << fieldName.toQuotedString());
1288412900
}
1288512901

1288612902
if (goRel == -1)
1288712903
{
1288812904
// no .. privilege with grant option on [base] table/view .. (for column ..)
1288912905
status_exception::raise(Arg::PrivateDyn(topLevel ? 171 : 172) <<
12890-
privilegeName(*privilege) << relationName.toQuotedString() << fieldName.c_str());
12906+
privilegeName(*privilege) << relationName.toQuotedString() << fieldName.toQuotedString());
1289112907
}
1289212908
}
1289312909
}
@@ -13189,8 +13205,7 @@ void GrantRevokeNode::setFieldClassName(thread_db* tdbb, jrd_tra* transaction,
1318913205
AutoCacheRequest request2(tdbb, drq_s_u_class, DYN_REQUESTS);
1319013206
FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE transaction)
1319113207
RFR1 IN RDB$RELATION_FIELDS
13192-
WITH RFR1.RDB$SCHEMA_NAME = RFR.RDB$SCHEMA_NAME AND
13193-
RFR1.RDB$SECURITY_CLASS = RFR.RDB$SECURITY_CLASS
13208+
WITH RFR1.RDB$SECURITY_CLASS = RFR.RDB$SECURITY_CLASS
1319413209
{
1319513210
unique = false;
1319613211
}

src/dsql/DdlNodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,11 +2739,11 @@ class CreateAlterSchemaNode : public DdlNode
27392739

27402740
public:
27412741
MetaName name;
2742+
std::optional<QualifiedName> setDefaultCharSet; // use empty QualifiedName with DROP DEFAULT CHARACTER SET
2743+
std::optional<SqlSecurity> setDefaultSqlSecurity;
27422744
bool create = true;
27432745
bool alter = false;
27442746
bool createIfNotExistsOnly = false;
2745-
std::optional<QualifiedName> setDefaultCharSet; // use empty QualifiedName with DROP DEFAULT CHARACTER SET
2746-
std::optional<SqlSecurity> setDefaultSqlSecurity;
27472747
};
27482748

27492749

src/dsql/DsqlCompilerScratch.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,10 @@ void DsqlCompilerScratch::qualifyExistingName(QualifiedName& name, std::initiali
8888
{
8989
cachedDdlSchemaSearchPath = FB_NEW_POOL(getPool()) ObjectsArray<MetaString>(getPool(), {ddlSchema});
9090

91-
for (const auto& searchSchema : *attachment->att_schema_search_path)
91+
if (const auto& searchPath = *attachment->att_schema_search_path;
92+
std::find(searchPath.begin(), searchPath.end(), SYSTEM_SCHEMA) != searchPath.end())
9293
{
93-
if (searchSchema == SYSTEM_SCHEMA)
94-
{
95-
cachedDdlSchemaSearchPath->push(searchSchema);
96-
break;
97-
}
94+
cachedDdlSchemaSearchPath->push(SYSTEM_SCHEMA);
9895
}
9996
}
10097

@@ -795,7 +792,7 @@ void DsqlCompilerScratch::addCTEs(WithClause* withClause)
795792

796793
// Add CTE name into CTE aliases stack. It allows later to search for
797794
// aliases of given CTE.
798-
addCTEAlias((*cte)->alias.c_str());
795+
addCTEAlias((*cte)->alias);
799796
}
800797
else
801798
ctes.add(*cte);

src/dsql/ExprNodes.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,7 +6135,7 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs
61356135
if ((id = PAR_find_proc_field(procedure, name)) == -1)
61366136
{
61376137
PAR_error(csb, Arg::Gds(isc_fldnotdef2) <<
6138-
Arg::Str(name) << Arg::Str(procedure->getName().toQuotedString()));
6138+
name.toQuotedString() << procedure->getName().toQuotedString());
61396139
}
61406140
}
61416141
else
@@ -6166,13 +6166,15 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs
61666166

61676167
if (tdbb->getAttachment()->isGbak())
61686168
{
6169-
PAR_warning(Arg::Warning(isc_fldnotdef) << Arg::Str(name) <<
6170-
relation->rel_name.toQuotedString());
6169+
PAR_warning(Arg::Warning(isc_fldnotdef) <<
6170+
name.toQuotedString() <<
6171+
relation->rel_name.toQuotedString());
61716172
}
61726173
else if (!(relation->rel_flags & REL_deleted))
61736174
{
6174-
PAR_error(csb, Arg::Gds(isc_fldnotdef) << Arg::Str(name) <<
6175-
relation->rel_name.toQuotedString());
6175+
PAR_error(csb, Arg::Gds(isc_fldnotdef) <<
6176+
name.toQuotedString() <<
6177+
relation->rel_name.toQuotedString());
61766178
}
61776179
else
61786180
PAR_error(csb, Arg::Gds(isc_ctxnotdef));
@@ -6943,8 +6945,9 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
69436945
}
69446946

69456947
// Msg 364 "cannot access column %s in view %s"
6946-
ERR_post(Arg::Gds(isc_no_field_access) << Arg::Str(field->fld_name) <<
6947-
relation->rel_name.toQuotedString());
6948+
ERR_post(Arg::Gds(isc_no_field_access) <<
6949+
field->fld_name.toQuotedString() <<
6950+
relation->rel_name.toQuotedString());
69486951
}
69496952

69506953
// The previous test below is an apparent temporary fix
@@ -12477,7 +12480,7 @@ DmlNode* SysFuncCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat
1247712480
if (!node->function)
1247812481
{
1247912482
csb->csb_blr_reader.seekBackward(count);
12480-
PAR_error(csb, Arg::Gds(isc_funnotdef) << Arg::Str(name));
12483+
PAR_error(csb, Arg::Gds(isc_funnotdef) << name.toQuotedString());
1248112484
}
1248212485

1248312486
node->args = PAR_args(tdbb, csb);
@@ -13646,12 +13649,13 @@ dsc* UdfCallNode::execute(thread_db* tdbb, Request* request) const
1364613649
{
1364713650
status_exception::raise(
1364813651
Arg::Gds(isc_func_pack_not_implemented) <<
13649-
Arg::Str(function->getName().object) << function->getName().getSchemaAndPackage().toQuotedString());
13652+
function->getName().object.toQuotedString() <<
13653+
function->getName().getSchemaAndPackage().toQuotedString());
1365013654
}
1365113655
else if (!function->isDefined())
1365213656
{
1365313657
status_exception::raise(
13654-
Arg::Gds(isc_funnotdef) << Arg::Str(function->getName().toQuotedString()) <<
13658+
Arg::Gds(isc_funnotdef) << function->getName().toQuotedString() <<
1365513659
Arg::Gds(isc_modnotfound));
1365613660
}
1365713661

@@ -13843,7 +13847,7 @@ ValueExprNode* UdfCallNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
1384313847
{
1384413848
status_exception::raise(
1384513849
Arg::Gds(isc_private_function) <<
13846-
function->udf_name.object <<
13850+
function->udf_name.object.toQuotedString() <<
1384713851
function->udf_name.getSchemaAndPackage().toQuotedString());
1384813852
}
1384913853

src/dsql/PackageNodes.epp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ DdlNode* CreateAlterPackageNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
254254
status_exception::raise(
255255
Arg::Gds(isc_no_meta_update) <<
256256
Arg::Gds(isc_dyn_duplicate_package_item) <<
257-
Arg::Str("FUNCTION") << fun->name.object);
257+
Arg::Str("FUNCTION") << fun->name.object.toQuotedString());
258258
}
259259

260260
functionNames.add(fun->name.object);
@@ -275,7 +275,7 @@ DdlNode* CreateAlterPackageNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
275275
status_exception::raise(
276276
Arg::Gds(isc_no_meta_update) <<
277277
Arg::Gds(isc_dyn_duplicate_package_item) <<
278-
Arg::Str("PROCEDURE") << proc->name.object);
278+
Arg::Str("PROCEDURE") << proc->name.object.toQuotedString());
279279
}
280280

281281
procedureNames.add(proc->name.object);
@@ -714,7 +714,7 @@ DdlNode* CreatePackageBodyNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
714714
status_exception::raise(
715715
Arg::Gds(isc_no_meta_update) <<
716716
Arg::Gds(isc_dyn_duplicate_package_item) <<
717-
Arg::Str("FUNCTION") << fun->name.object);
717+
Arg::Str("FUNCTION") << fun->name.object.toQuotedString());
718718
}
719719

720720
functionNames[i].add(fun->name.object);
@@ -739,7 +739,7 @@ DdlNode* CreatePackageBodyNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
739739
status_exception::raise(
740740
Arg::Gds(isc_no_meta_update) <<
741741
Arg::Gds(isc_dyn_duplicate_package_item) <<
742-
Arg::Str("PROCEDURE") << proc->name.object);
742+
Arg::Str("PROCEDURE") << proc->name.object.toQuotedString());
743743
}
744744

745745
procedureNames[i].add(proc->name.object);

src/dsql/PackageNodes.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ class DropPackageNode : public DdlNode
124124
public:
125125
DropPackageNode(MemoryPool& pool, const QualifiedName& aName)
126126
: DdlNode(pool),
127-
name(pool, aName),
128-
silent(false)
127+
name(pool, aName)
129128
{
130129
}
131130

@@ -155,7 +154,7 @@ class DropPackageNode : public DdlNode
155154

156155
public:
157156
QualifiedName name;
158-
bool silent;
157+
bool silent = false;
159158
bool recreate = false;
160159
};
161160

@@ -206,8 +205,7 @@ class DropPackageBodyNode : public DdlNode
206205
public:
207206
DropPackageBodyNode(MemoryPool& pool, const QualifiedName& aName)
208207
: DdlNode(pool),
209-
name(pool, aName),
210-
silent(false)
208+
name(pool, aName)
211209
{
212210
}
213211

@@ -233,7 +231,7 @@ class DropPackageBodyNode : public DdlNode
233231

234232
public:
235233
QualifiedName name;
236-
bool silent; // Unused. Just to please RecreateNode template.
234+
bool silent = false; // Unused. Just to please RecreateNode template.
237235
bool recreate = false;
238236
};
239237

0 commit comments

Comments
 (0)