Skip to content

Commit 56a7c4c

Browse files
committed
No SharedStorageSchema in SqlCompilerConfiguration
1 parent 8dad7d1 commit 56a7c4c

File tree

9 files changed

+66
-94
lines changed

9 files changed

+66
-94
lines changed

Orm/Xtensive.Orm.Tests.Sql/MakeNamesUnreadableTest.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ private void TestQueryNamesUnreadable(ISqlCompileUnit query, Schema defaultSchem
364364
var queryText = string.Empty;
365365

366366
if (IsMultidatabaseSupported) {
367-
var compilerConfiguration = new SqlCompilerConfiguration() { DatabaseQualifiedObjects = true, SharedStorageSchema = true };
367+
var compilerConfiguration = new SqlCompilerConfiguration() { DatabaseQualifiedObjects = true };
368368

369369
_ = Assert.Throws<InvalidOperationException>(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText());
370370

@@ -383,36 +383,33 @@ private void TestQueryNamesUnreadable(ISqlCompileUnit query, Schema defaultSchem
383383
Assert.That(queryText.Contains(DummySchemaName), Is.True);
384384
}
385385
if (IsMultischemaSupported) {
386-
var compilerConfiguration = new SqlCompilerConfiguration() { SharedStorageSchema = true };
387-
388-
_ = Assert.Throws<InvalidOperationException>(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText());
386+
_ = Assert.Throws<InvalidOperationException>(() => queryText = Driver.Compile(query).GetCommandText());
389387

390388
var postCompilerConfiguration = new SqlPostCompilerConfiguration(emptyMap, emptyMap);
391-
Assert.DoesNotThrow(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText(postCompilerConfiguration));
389+
Assert.DoesNotThrow(() => queryText = Driver.Compile(query).GetCommandText(postCompilerConfiguration));
392390
Assert.That(queryText.Contains(defaultSchema.GetDbNameInternal()), Is.True);
393391
Assert.That(queryText.Contains(defaultSchema.Catalog.GetDbNameInternal()), Is.False);
394392

395393
postCompilerConfiguration = new SqlPostCompilerConfiguration(GetDatabaseMap(defaultSchema.Catalog), GetSchemaMap(defaultSchema));
396394

397-
Assert.DoesNotThrow(() => queryText = Driver.Compile(query,compilerConfiguration).GetCommandText(postCompilerConfiguration));
395+
Assert.DoesNotThrow(() => queryText = Driver.Compile(query).GetCommandText(postCompilerConfiguration));
398396
Assert.That(queryText.Contains(defaultSchema.GetDbNameInternal()), Is.False);
399397
Assert.That(queryText.Contains(defaultSchema.Catalog.GetDbNameInternal()), Is.False);
400398
Assert.That(queryText.Contains(DummyDatabaseName), Is.False);
401399
Assert.That(queryText.Contains(DummySchemaName), Is.True);
402400
}
403401
else {
404-
var compilerConfiguration = new SqlCompilerConfiguration() { SharedStorageSchema = true };
405-
Assert.DoesNotThrow(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText());
402+
Assert.DoesNotThrow(() => queryText = Driver.Compile(query).GetCommandText());
406403

407404
var postCompilerConfiguration = new SqlPostCompilerConfiguration(emptyMap, emptyMap);
408405

409-
Assert.DoesNotThrow(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText(postCompilerConfiguration));
406+
Assert.DoesNotThrow(() => queryText = Driver.Compile(query).GetCommandText(postCompilerConfiguration));
410407
Assert.That(queryText.Contains(defaultSchema.GetDbNameInternal()), Is.False);
411408
Assert.That(queryText.Contains(defaultSchema.Catalog.GetDbNameInternal()), Is.False);
412409

413410
postCompilerConfiguration = new SqlPostCompilerConfiguration(GetDatabaseMap(defaultSchema.Catalog), GetSchemaMap(defaultSchema));
414411

415-
Assert.DoesNotThrow(() => queryText = Driver.Compile(query, compilerConfiguration).GetCommandText());
412+
Assert.DoesNotThrow(() => queryText = Driver.Compile(query).GetCommandText());
416413
Assert.That(queryText.Contains(defaultSchema.GetDbNameInternal()), Is.False);
417414
Assert.That(queryText.Contains(defaultSchema.Catalog.GetDbNameInternal()), Is.False);
418415
Assert.That(queryText.Contains(DummyDatabaseName), Is.False);

Orm/Xtensive.Orm/Orm/Providers/StorageDriver.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement)
8484
var options = new SqlCompilerConfiguration {
8585
DatabaseQualifiedObjects = configuration.IsMultidatabase,
8686
CommentLocation = configuration.TagsLocation.ToCommentLocation(),
87-
SharedStorageSchema = false,
8887
};
8988
return underlyingDriver.Compile(statement, options);
9089
}
@@ -94,7 +93,6 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement, NodeConfiguration
9493
#pragma warning restore IDE0060 // Remove unused parameter
9594
{
9695
var options = new SqlCompilerConfiguration {
97-
SharedStorageSchema = configuration.ShareStorageSchemaOverNodes,
9896
DatabaseQualifiedObjects = configuration.IsMultidatabase,
9997
CommentLocation = configuration.TagsLocation.ToCommentLocation()
10098
};

Orm/Xtensive.Orm/Sql/Compiler/SqlCompilerConfiguration.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,16 @@ public sealed class SqlCompilerConfiguration
3535
/// </summary>
3636
public SqlCommentLocation CommentLocation { get; set; } = SqlCommentLocation.Nowhere;
3737

38-
/// <summary>
39-
/// Indicated whether storage schema was shared over several storage nodes.
40-
/// </summary>
41-
public bool SharedStorageSchema { get; init; } = false;
42-
4338
/// <summary>
4439
/// Gets database mapping.
4540
/// </summary>
46-
[Obsolete("No longer in use")]
41+
[Obsolete("No longer in use. Moved to SqlPostCompilerConfiguration.")]
4742
public IReadOnlyDictionary<string, string> SchemaMapping { get; private set; }
4843

4944
/// <summary>
5045
/// Gets database mapping.
5146
/// </summary>
52-
[Obsolete("No longer in use")]
47+
[Obsolete("No longer in use. Moved to SqlPostCompilerConfiguration.")]
5348
public IReadOnlyDictionary<string, string> DatabaseMapping { get; private set; }
5449

5550
/// <summary>

Orm/Xtensive.Orm/Sql/Compiler/SqlCompilerContext.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public class SqlCompilerContext
3030
public SqlNode[] GetTraversalPath() =>
3131
traversalPath ??= traversalStack.ToArray();
3232

33-
public bool SharedStorageSchema { get; }
34-
3533
public bool HasOptions(SqlCompilerNamingOptions requiredOptions)
3634
{
3735
return (NamingOptions & requiredOptions)==requiredOptions;
@@ -146,8 +144,6 @@ internal SqlCompilerContext(SqlCompilerConfiguration configuration)
146144
if (configuration.DatabaseQualifiedObjects)
147145
NamingOptions |= SqlCompilerNamingOptions.DatabaseQualifiedObjects;
148146

149-
SharedStorageSchema = configuration.SharedStorageSchema;
150-
151147
TableNameProvider = new SqlTableNameProvider(this);
152148
ParameterNameProvider = new SqlParameterNameProvider(configuration);
153149
Output = new ContainerNode();

Orm/Xtensive.Orm/Sql/Compiler/SqlTranslator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,8 @@ public virtual void Translate(SqlCompilerContext context, SchemaNode node)
19551955
var dbQualified = node.Schema.Catalog != null
19561956
&& context.HasOptions(SqlCompilerNamingOptions.DatabaseQualifiedObjects);
19571957

1958-
if (context.SharedStorageSchema) {
1958+
1959+
if (node.Schema.IsNamesReadingDenied) {
19591960
// if schema is shared we use placeholders to translate
19601961
// schema node in PostCompiler
19611962
output.AppendSchemaNodePlaceholder(node, EscapeSetup, dbQualified);

Orm/Xtensive.Orm/Sql/Model/Catalog.cs

Lines changed: 43 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ namespace Xtensive.Sql.Model
1414
[Serializable]
1515
public class Catalog : Node
1616
{
17-
private bool isNamesReadingDenied = false;
18-
1917
private Schema defaultSchema;
2018
private PairedNodeCollection<Catalog, Schema> schemas;
2119
private PairedNodeCollection<Catalog, PartitionFunction> partitionFunctions;
@@ -25,12 +23,12 @@ public class Catalog : Node
2523
public override string Name
2624
{
2725
get {
28-
if (!isNamesReadingDenied)
26+
if (!IsNamesReadingDenied)
2927
return base.Name;
3028
throw new InvalidOperationException(Strings.ExNameValueReadingOrSettingIsDenied);
3129
}
3230
set {
33-
if (!isNamesReadingDenied)
31+
if (!IsNamesReadingDenied)
3432
base.Name = value;
3533
else
3634
throw new InvalidOperationException(Strings.ExNameValueReadingOrSettingIsDenied);
@@ -41,50 +39,18 @@ public override string Name
4139
public override string DbName
4240
{
4341
get {
44-
if (!isNamesReadingDenied)
42+
if (!IsNamesReadingDenied)
4543
return base.DbName;
4644
throw new InvalidOperationException(Strings.ExDbNameValueReadingOrSettingIsDenied);
4745
}
4846
set {
49-
if (!isNamesReadingDenied)
47+
if (!IsNamesReadingDenied)
5048
base.DbName = value;
5149
else
5250
throw new InvalidOperationException(Strings.ExDbNameValueReadingOrSettingIsDenied);
5351
}
5452
}
5553

56-
/// <summary>
57-
/// Creates a schema.
58-
/// </summary>
59-
/// <param name="name">The name.</param>
60-
/// <returns></returns>
61-
public Schema CreateSchema(string name)
62-
{
63-
return new Schema(this, name);
64-
}
65-
66-
/// <summary>
67-
/// Creates the partition function.
68-
/// </summary>
69-
/// <param name="name">The name.</param>
70-
/// <param name="dataType">Type of the input parameter.</param>
71-
/// <param name="boundaryValues">The boundary values.</param>
72-
public PartitionFunction CreatePartitionFunction(string name, SqlValueType dataType, params string[] boundaryValues)
73-
{
74-
return new PartitionFunction(this, name, dataType, boundaryValues);
75-
}
76-
77-
/// <summary>
78-
/// Creates the partition schema.
79-
/// </summary>
80-
/// <param name="name">The name.</param>
81-
/// <param name="partitionFunction">The partition function.</param>
82-
/// <param name="filegroups">The filegroups.</param>
83-
public PartitionSchema CreatePartitionSchema(string name, PartitionFunction partitionFunction, params string[] filegroups)
84-
{
85-
return new PartitionSchema(this, name, partitionFunction, filegroups);
86-
}
87-
8854
/// <summary>
8955
/// Default <see cref="Schema"/> of this instance.
9056
/// </summary>
@@ -113,10 +79,7 @@ public Schema DefaultSchema
11379
/// Gets the schemas.
11480
/// </summary>
11581
/// <value>The schemas.</value>
116-
public PairedNodeCollection<Catalog, Schema> Schemas
117-
{
118-
get { return schemas; }
119-
}
82+
public PairedNodeCollection<Catalog, Schema> Schemas => schemas;
12083

12184
/// <summary>
12285
/// Gets the partition functions.
@@ -140,13 +103,41 @@ public PairedNodeCollection<Catalog, PartitionSchema> PartitionSchemas
140103
{
141104
get
142105
{
143-
if (partitionSchemas==null)
106+
if (partitionSchemas == null)
144107
partitionSchemas =
145108
new PairedNodeCollection<Catalog, PartitionSchema>(this, "PartitionSchemas");
146109
return partitionSchemas;
147110
}
148111
}
149112

113+
internal bool IsNamesReadingDenied { get; private set; }
114+
115+
/// <summary>
116+
/// Creates a schema.
117+
/// </summary>
118+
/// <param name="name">The name.</param>
119+
/// <returns></returns>
120+
public Schema CreateSchema(string name) => new(this, name);
121+
122+
/// <summary>
123+
/// Creates the partition function.
124+
/// </summary>
125+
/// <param name="name">The name.</param>
126+
/// <param name="dataType">Type of the input parameter.</param>
127+
/// <param name="boundaryValues">The boundary values.</param>
128+
public PartitionFunction CreatePartitionFunction(string name, SqlValueType dataType, params string[] boundaryValues) =>
129+
new(this, name, dataType, boundaryValues);
130+
131+
/// <summary>
132+
/// Creates the partition schema.
133+
/// </summary>
134+
/// <param name="name">The name.</param>
135+
/// <param name="partitionFunction">The partition function.</param>
136+
/// <param name="filegroups">The filegroups.</param>
137+
public PartitionSchema CreatePartitionSchema(string name, PartitionFunction partitionFunction, params string[] filegroups) =>
138+
new(this, name, partitionFunction, filegroups);
139+
140+
150141
#region ILockable Members
151142

152143
/// <summary>
@@ -163,37 +154,32 @@ public override void Lock(bool recursive)
163154

164155
internal void MakeNamesUnreadable()
165156
{
166-
isNamesReadingDenied = true;
167-
this.Schemas.ForEach(s => s.MakeNamesUnreadable());
168-
this.PartitionFunctions.ForEach(pf => pf.MakeNamesUnreadable());
169-
this.PartitionSchemas.ForEach(ps => ps.MakeNamesUnreadable());
157+
IsNamesReadingDenied = true;
158+
Schemas.ForEach(s => s.MakeNamesUnreadable());
159+
PartitionFunctions.ForEach(pf => pf.MakeNamesUnreadable());
160+
PartitionSchemas.ForEach(ps => ps.MakeNamesUnreadable());
170161
}
171162

172163
internal string GetActualName(IReadOnlyDictionary<string, string> catalogNameMap)
173164
{
174-
if (!isNamesReadingDenied)
165+
if (!IsNamesReadingDenied)
175166
return Name;
176167
if (catalogNameMap==null)
177168
throw new ArgumentNullException("catalogNameMap");
178169

179170
var name = GetNameInternal();
180-
string actualName;
181-
if (catalogNameMap.TryGetValue(name, out actualName))
182-
return actualName;
183-
return name;
171+
return catalogNameMap.TryGetValue(name, out var actualName) ? actualName : name;
184172
}
185173

186174
internal string GetActualDbName(IReadOnlyDictionary<string, string> catalogNameMap)
187175
{
188-
if (!isNamesReadingDenied)
176+
if (!IsNamesReadingDenied)
189177
return DbName;
190178
if (catalogNameMap==null)
191179
throw new ArgumentNullException("Unable to calculate real name for catalog");
180+
192181
var name = GetDbNameInternal();
193-
string actualName;
194-
if (catalogNameMap.TryGetValue(name, out actualName))
195-
return actualName;
196-
return name;
182+
return catalogNameMap.TryGetValue(name, out var actualName) ? actualName : name;
197183
}
198184

199185
// Constructors
@@ -212,6 +198,5 @@ public Catalog(string name, bool caseSensitiveNames = false)
212198
? new PairedNodeCollection<Catalog, Schema>(this, "Schemas", 1, StringComparer.Ordinal)
213199
: new PairedNodeCollection<Catalog, Schema>(this, "Schemas", 1, StringComparer.OrdinalIgnoreCase);
214200
}
215-
216201
}
217202
}

Orm/Xtensive.Orm/Sql/Model/CatalogNode.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ namespace Xtensive.Sql.Model
1515
public abstract class CatalogNode : Node, IPairedNode<Catalog>
1616
{
1717
private Catalog catalog;
18-
private bool isNamesReadingDenied = false;
1918

2019
/// <inheritdoc />
2120
public override string Name
2221
{
2322
get {
24-
if (!isNamesReadingDenied)
23+
if (!IsNamesReadingDenied)
2524
return base.Name;
2625
throw new InvalidOperationException(Strings.ExNameValueReadingOrSettingIsDenied);
2726
}
2827
set {
29-
if (!isNamesReadingDenied)
28+
if (!IsNamesReadingDenied)
3029
base.Name = value;
3130
else
3231
throw new InvalidOperationException(Strings.ExNameValueReadingOrSettingIsDenied);
@@ -37,12 +36,12 @@ public override string Name
3736
public override string DbName
3837
{
3938
get {
40-
if (!isNamesReadingDenied)
39+
if (!IsNamesReadingDenied)
4140
return base.DbName;
4241
throw new InvalidOperationException(Strings.ExDbNameValueReadingOrSettingIsDenied);
4342
}
4443
set {
45-
if (!isNamesReadingDenied)
44+
if (!IsNamesReadingDenied)
4645
base.DbName = value;
4746
else
4847
throw new InvalidOperationException(Strings.ExDbNameValueReadingOrSettingIsDenied);
@@ -63,6 +62,8 @@ public Catalog Catalog
6362
}
6463
}
6564

65+
internal bool IsNamesReadingDenied { get; private set; }
66+
6667
/// <summary>
6768
/// Changes the catalog.
6869
/// </summary>
@@ -86,12 +87,12 @@ void IPairedNode<Catalog>.UpdatePairedProperty(string property, Catalog value)
8687

8788
internal void MakeNamesUnreadable()
8889
{
89-
isNamesReadingDenied = true;
90+
IsNamesReadingDenied = true;
9091
}
9192

9293
internal string GetActualName(IReadOnlyDictionary<string, string> nodeNameMap)
9394
{
94-
if (!isNamesReadingDenied)
95+
if (!IsNamesReadingDenied)
9596
return Name;
9697
if (nodeNameMap==null)
9798
throw new ArgumentNullException("nodeNameMap");
@@ -105,14 +106,13 @@ internal string GetActualName(IReadOnlyDictionary<string, string> nodeNameMap)
105106

106107
internal string GetActualDbName(IReadOnlyDictionary<string, string> nodeNameMap)
107108
{
108-
if (!isNamesReadingDenied)
109+
if (!IsNamesReadingDenied)
109110
return DbName;
110111
if (nodeNameMap==null)
111112
throw new ArgumentNullException("nodeNameMap");
112113

113114
var name = GetDbNameInternal();
114-
string actualName;
115-
if (nodeNameMap.TryGetValue(name, out actualName))
115+
if (nodeNameMap.TryGetValue(name, out var actualName))
116116
return actualName;
117117
return name;
118118
}

Orm/Xtensive.Orm/Strings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)