Skip to content

Commit 5001b57

Browse files
committed
Merge branch '7.1'
# Conflicts: # Orm/Xtensive.Orm/Sql/Dml/Expressions/SqlExtract.cs # Version.props
2 parents b36f950 + a18a34a commit 5001b57

File tree

30 files changed

+387
-90
lines changed

30 files changed

+387
-90
lines changed

ChangeLog/7.1.5_Z_Final.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[main] Addressed certain cases of overlaping server-side error by new one when temporary tables are used in query
2+
[postgresql] Improved .Milliseconds translation for types which have this part
3+
[postgresql] Improved TimeSpan.TotalMilliseconds translation
4+
[sqlserver] Database schema objects which are "microsoft shipped", e.g. created for replication mechanisms, are excluded from extraction

Extensions/Xtensive.Orm.BulkOperations/Xtensive.Orm.BulkOperations.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
1818
</PropertyGroup>
1919
<ItemGroup Label="Nuget content">
20-
<Content Include="$(ProjectDir)NuGetContent\**">
20+
<Content Include="$(ProjectDir)NugetContent\**">
2121
<PackagePath>.</PackagePath>
2222
</Content>
2323
</ItemGroup>

Extensions/Xtensive.Orm.Localization/Xtensive.Orm.Localization.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
2121
</ItemGroup>
2222
<ItemGroup Label="Nuget content">
23-
<Content Include="$(ProjectDir)NuGetContent\**">
23+
<Content Include="$(ProjectDir)NugetContent\**">
2424
<PackagePath>.</PackagePath>
2525
</Content>
2626
</ItemGroup>

Extensions/Xtensive.Orm.Logging.NLog/Xtensive.Orm.Logging.NLog.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
2323
</ItemGroup>
2424
<ItemGroup Label="Nuget content">
25-
<Content Include="$(ProjectDir)NuGetContent\**">
25+
<Content Include="$(ProjectDir)NugetContent\**">
2626
<PackagePath>.</PackagePath>
2727
</Content>
2828
</ItemGroup>

Extensions/Xtensive.Orm.Logging.log4net/Xtensive.Orm.Logging.log4net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
2323
</ItemGroup>
2424
<ItemGroup Label="Nuget content">
25-
<Content Include="$(ProjectDir)NuGetContent\**">
25+
<Content Include="$(ProjectDir)NugetContent\**">
2626
<PackagePath>.</PackagePath>
2727
</Content>
2828
</ItemGroup>

Extensions/Xtensive.Orm.Reprocessing/Xtensive.Orm.Reprocessing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
2727
</ItemGroup>
2828
<ItemGroup Label="Nuget content">
29-
<Content Include="$(ProjectDir)NuGetContent\**">
29+
<Content Include="$(ProjectDir)NugetContent\**">
3030
<PackagePath>.</PackagePath>
3131
</Content>
3232
</ItemGroup>

Extensions/Xtensive.Orm.Security/Xtensive.Orm.Security.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
3131
</ItemGroup>
3232
<ItemGroup Label="Nuget content">
33-
<Content Include="$(ProjectDir)NuGetContent\**">
33+
<Content Include="$(ProjectDir)NugetContent\**">
3434
<PackagePath>.</PackagePath>
3535
</Content>
3636
</ItemGroup>

Extensions/Xtensive.Orm.Tracking/Xtensive.Orm.Tracking.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
2626
</ItemGroup>
2727
<ItemGroup Label="Nuget content">
28-
<Content Include="$(ProjectDir)NuGetContent\**">
28+
<Content Include="$(ProjectDir)NugetContent\**">
2929
<PackagePath>.</PackagePath>
3030
</Content>
3131
</ItemGroup>

Extensions/Xtensive.Orm.Web/Xtensive.Orm.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
1717
</PropertyGroup>
1818
<ItemGroup Label="Nuget content">
19-
<Content Include="$(ProjectDir)NuGetContent\**">
19+
<Content Include="$(ProjectDir)NugetContent\**">
2020
<PackagePath>.</PackagePath>
2121
</Content>
2222
</ItemGroup>

Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/DomainHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class DomainHandler : Providers.DomainHandler
2222
protected override ICompiler CreateCompiler(CompilerConfiguration configuration) =>
2323
new SqlCompiler(Handlers, configuration);
2424

25+
/// <inheritdoc/>
2526
protected override IPreCompiler CreatePreCompiler(CompilerConfiguration configuration)
2627
{
2728
var decimalAggregateCorrector = new AggregateOverDecimalColumnCorrector(Handlers.Domain.Model);

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Compiler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override void Visit(SqlFunctionCall node)
116116
((node.Arguments[0] / SqlDml.Literal(nanosecondsPerSecond)) * OneSecondInterval).AcceptVisitor(this);
117117
return;
118118
case SqlFunctionType.IntervalToMilliseconds:
119-
SqlHelper.IntervalToMilliseconds(node.Arguments[0]).AcceptVisitor(this);
119+
VisitIntervalToMilliseconds(node);
120120
return;
121121
case SqlFunctionType.IntervalToNanoseconds:
122122
SqlHelper.IntervalToNanoseconds(node.Arguments[0]).AcceptVisitor(this);
@@ -284,6 +284,11 @@ public override void Visit(SqlCustomFunctionCall node)
284284
base.Visit(node);
285285
}
286286

287+
protected virtual void VisitIntervalToMilliseconds(SqlFunctionCall node)
288+
{
289+
SqlHelper.IntervalToMilliseconds(node.Arguments[0]).AcceptVisitor(this);
290+
}
291+
287292
private static SqlExpression DateTimeToStringIso(SqlExpression dateTime, in string isoFormat) =>
288293
SqlDml.FunctionCall("TO_CHAR", dateTime, isoFormat);
289294

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Translator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,11 @@ public override void Translate(SqlCompilerContext context, SqlExtract node, Extr
404404
}
405405
switch (section) {
406406
case ExtractSection.Entry:
407-
_ = context.Output.AppendOpeningPunctuation(isSecond ? "(trunc(extract(" : "(extract(");
407+
_ = context.Output.AppendOpeningPunctuation(isSecond || isMillisecond ? "(trunc(extract(" : "(extract(");
408408
break;
409409
case ExtractSection.Exit:
410410
_ = context.Output.Append(isMillisecond
411-
? ")::int8 % 1000)"
411+
? "))::int8 % 1000)"
412412
: isSecond ? ")))" : ")::int8)"
413413
);
414414
break;

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v9_0/Compiler.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
// Created by: Denis Krjuchkov
55
// Created: 2012.06.06
66

7+
using Xtensive.Sql.Dml;
8+
79
namespace Xtensive.Sql.Drivers.PostgreSql.v9_0
810
{
911
internal class Compiler : v8_4.Compiler
1012
{
13+
14+
protected override void VisitIntervalToMilliseconds(SqlFunctionCall node)
15+
{
16+
AppendSpaceIfNecessary();
17+
_ = context.Output.Append("(TRUNC(EXTRACT(EPOCH FROM (");
18+
node.Arguments[0].AcceptVisitor(this);
19+
_ = context.Output.Append("))::double precision * 1000))");
20+
}
21+
1122
// Constructors
1223

1324
public Compiler(SqlDriver driver)

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public ExtractionContext(Catalog catalog, IReadOnlyCollection<string> targetSche
7272
}
7373

7474
protected const string SysTablesFilterPlaceholder = "{SYSTABLE_FILTER}";
75+
protected const string SysObjectFilterPlaceholder = "{SYSOBJECT_FILTER}";
7576
protected const string CatalogPlaceholder = "{CATALOG}";
7677
protected const string SchemaFilterPlaceholder = "{SCHEMA_FILTER}";
7778

@@ -125,6 +126,7 @@ protected virtual void RegisterReplacements(ExtractionContext context)
125126
{
126127
context.RegisterReplacement(SchemaFilterPlaceholder, MakeSchemaFilter(context));
127128
context.RegisterReplacement(SysTablesFilterPlaceholder, "1 > 0");
129+
context.RegisterReplacement(SysObjectFilterPlaceholder, "is_ms_shipped = 0");
128130
}
129131

130132
private ExtractionContext CreateContext(string catalogName, string[] schemaNames)
@@ -303,14 +305,15 @@ private string BuildExtractTablesAndViewsQuery(ExtractionContext context)
303305
name,
304306
0 type
305307
FROM {CATALOG}.sys.tables
306-
WHERE {SYSTABLE_FILTER}
308+
WHERE {SYSTABLE_FILTER} AND {SYSOBJECT_FILTER}
307309
UNION
308310
SELECT
309311
schema_id,
310312
object_id,
311313
name,
312314
1 type
313315
FROM {CATALOG}.sys.views
316+
WHERE {SYSOBJECT_FILTER}
314317
) AS t
315318
WHERE t.schema_id {SCHEMA_FILTER}
316319
ORDER BY t.schema_id, t.object_id";
@@ -411,13 +414,14 @@ INNER JOIN (
411414
object_id,
412415
0 as type
413416
FROM {CATALOG}.sys.tables
414-
WHERE {SYSTABLE_FILTER}
417+
WHERE {SYSTABLE_FILTER} AND {SYSOBJECT_FILTER}
415418
UNION
416419
SELECT
417420
schema_id,
418421
object_id,
419422
1 AS type
420423
FROM {CATALOG}.sys.views
424+
WHERE {SYSOBJECT_FILTER}
421425
) AS t ON c.object_id = t.object_id
422426
LEFT OUTER JOIN {CATALOG}.sys.default_constraints AS dc
423427
ON c.object_id = dc.parent_object_id
@@ -501,6 +505,7 @@ WHERE seed_value IS NOT NULL
501505
AND increment_value IS NOT NULL
502506
AND {SYSTABLE_FILTER}
503507
AND t.schema_id {SCHEMA_FILTER}
508+
AND t.{SYSOBJECT_FILTER}
504509
ORDER BY
505510
t.schema_id,
506511
ic.object_id";
@@ -560,13 +565,14 @@ INNER JOIN (
560565
object_id,
561566
0 AS type
562567
FROM {CATALOG}.sys.tables
563-
WHERE {SYSTABLE_FILTER}
568+
WHERE {SYSTABLE_FILTER} AND {SYSOBJECT_FILTER}
564569
UNION
565570
SELECT
566571
schema_id,
567572
object_id,
568573
1 AS type
569574
FROM {CATALOG}.sys.views
575+
WHERE {SYSOBJECT_FILTER}
570576
) AS t
571577
ON i.object_id = t.object_id
572578
INNER JOIN {CATALOG}.sys.index_columns ic
@@ -839,7 +845,7 @@ INNER JOIN {CATALOG}.sys.indexes AS i
839845
ON fic.object_id = i.object_id
840846
AND fi.unique_index_id = i.index_id
841847
WHERE {SYSTABLE_FILTER}
842-
AND t.schema_id {SCHEMA_FILTER}
848+
AND t.schema_id {SCHEMA_FILTER} AND t.{SYSOBJECT_FILTER}
843849
ORDER BY
844850
t.schema_id,
845851
fic.object_id,

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v10/Extractor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ INNER JOIN (
3636
object_id,
3737
0 AS type
3838
FROM {CATALOG}.sys.tables
39-
WHERE {SYSTABLE_FILTER}
39+
WHERE {SYSTABLE_FILTER} AND {SYSOBJECT_FILTER}
4040
UNION
4141
SELECT
4242
schema_id,
4343
object_id,
4444
1 AS type
4545
FROM {CATALOG}.sys.views
46+
WHERE {SYSOBJECT_FILTER}
4647
) AS t
4748
ON i.object_id = t.object_id
4849
INNER JOIN {CATALOG}.sys.index_columns ic

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v11/Extractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private string BuildExtractSequencesQuery(ExtractionContext context)
6868
is_cycling,
6969
current_value
7070
FROM {CATALOG}.sys.sequences
71-
WHERE schema_id {SCHEMA_FILTER}
71+
WHERE schema_id {SCHEMA_FILTER} AND {SYSOBJECT_FILTER}
7272
ORDER BY
7373
schema_id,
7474
object_id";

Orm/Xtensive.Orm.Tests.Framework/Orm.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
<domain name="pgsql160"
7676
connectionUrl="postgresql://dotest:dotest@localhost:54160/dotest" />
7777

78+
<domain name="pgsql170"
79+
connectionUrl="postgresql://dotest:dotest@localhost:54170/dotest" />
80+
7881
<domain name="oracle10"
7982
connectionUrl="oracle://dotest:dotest@localhost:5510/ora10" />
8083

@@ -173,6 +176,9 @@
173176
<domain name="pgsql160cs" provider="postgresql"
174177
connectionString="HOST=localhost;PORT=54160;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest" />
175178

179+
<domain name="pgsql170cs" provider="postgresql"
180+
connectionString="HOST=localhost;PORT=54170;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest" />
181+
176182
<domain name="oracle10cs" provider="oracle"
177183
connectionString="DATA SOURCE=&quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=5510))(CONNECT_DATA=(SERVICE_NAME=ora10)))&quot;;USER ID=dotest;PASSWORD=dotest" />
178184

Orm/Xtensive.Orm.Tests.Framework/StorageProviderVersion.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ public static class StorageProviderVersion
3131
public static Version PostgreSql90 = new Version(9, 0);
3232
public static Version PostgreSql91 = new Version(9, 1);
3333
public static Version PostgreSql92 = new Version(9, 2);
34+
public static Version PostgreSql96 = new Version(9, 6);
3435
public static Version PostgreSql100 = new Version(10, 0);
3536
public static Version PostgreSql110 = new Version(11, 0);
3637
public static Version PostgreSql120 = new Version(12, 0);
38+
public static Version PostgreSql130 = new Version(13, 0);
39+
public static Version PostgreSql140 = new Version(14, 0);
40+
public static Version PostgreSql150 = new Version(15, 0);
41+
public static Version PostgreSql160 = new Version(16, 0);
42+
public static Version PostgreSql170 = new Version(17, 0);
3743

3844
public static Version MySql55 = new Version(5, 5);
3945
public static Version MySql56 = new Version(5, 6);

Orm/Xtensive.Orm.Tests.Framework/StorageTestHelper.cs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
using System;
88
using System.Collections.Generic;
9+
using System.Data.Common;
910
using System.Linq;
11+
using System.Threading;
1012
using Xtensive.Orm.Providers;
1113
using Xtensive.Sql;
1214
using Xtensive.Sql.Model;
@@ -17,15 +19,13 @@ public static class StorageTestHelper
1719
{
1820
public static bool IsFetched(Session session, Key key)
1921
{
20-
EntityState dummy;
21-
return session.EntityStateCache.TryGetItem(key, false, out dummy);
22+
return session.EntityStateCache.TryGetItem(key, false, out var _);
2223
}
2324

24-
public static object GetNativeTransaction()
25+
public static object GetNativeTransaction(Session session)
2526
{
26-
var handler = Session.Demand().Handler;
27-
var sqlHandler = handler as SqlSessionHandler;
28-
if (sqlHandler!=null)
27+
var handler = session.Handler;
28+
if (handler is SqlSessionHandler sqlHandler)
2929
return sqlHandler.Connection.ActiveTransaction;
3030
throw new NotSupportedException();
3131
}
@@ -66,6 +66,39 @@ public static void DemandSchemas(ConnectionInfo connectionInfo, params string[]
6666
}
6767
}
6868

69+
/// <summary>
70+
/// Waits for full-text indexes of MS SQL to be populated.
71+
/// Every now and then it gets state of them from database or waits timeout to be reached.
72+
/// </summary>
73+
/// <param name="domain"></param>
74+
public static void WaitFullTextIndexesPopulated(Domain domain, TimeSpan timeout)
75+
{
76+
if (StorageProviderInfo.Instance.Provider == StorageProvider.SqlServer) {
77+
var driver = TestSqlDriver.Create(domain.Configuration.ConnectionInfo);
78+
using (var connection = driver.CreateConnection()) {
79+
80+
var date = DateTime.UtcNow.Add(timeout);
81+
while (!CheckFtIndexesPopulated(connection) && DateTime.UtcNow < date) {
82+
Thread.Sleep(TimeSpan.FromSeconds(2));
83+
}
84+
}
85+
}
86+
87+
static bool CheckFtIndexesPopulated(SqlConnection connection)
88+
{
89+
connection.Open();
90+
try {
91+
using (var command = connection.CreateCommand()) {
92+
command.CommandText = $"SELECT COUNT(*) FROM sys.fulltext_indexes WHERE has_crawl_completed = 0";
93+
return ((int) command.ExecuteScalar()) == 0;
94+
}
95+
}
96+
finally {
97+
connection.Close();
98+
}
99+
}
100+
}
101+
69102
private static void CreateUsers(SqlConnection connection, IEnumerable<string> schemasToCreate)
70103
{
71104
var translator = connection.Driver.Translator;
@@ -86,14 +119,14 @@ private static void CreateSchemas(SqlConnection connection, Catalog catalog, IEn
86119

87120
private static void ExecuteQuery(SqlConnection connection, ISqlCompileUnit query)
88121
{
89-
using (var command = connection.CreateCommand(query))
90-
command.ExecuteNonQuery();
122+
using var command = connection.CreateCommand(query);
123+
_ = command.ExecuteNonQuery();
91124
}
92125

93126
private static void ExecuteQuery(SqlConnection connection, string query)
94127
{
95-
using (var command = connection.CreateCommand(query))
96-
command.ExecuteNonQuery();
128+
using var command = connection.CreateCommand(query);
129+
_ = command.ExecuteNonQuery();
97130
}
98131
}
99132
}

0 commit comments

Comments
 (0)