Skip to content

Commit 1e61c65

Browse files
authored
Merge branch 'master' into upstream/Optimize_FunctionCall
2 parents 52cab85 + 0fb2dd9 commit 1e61c65

File tree

77 files changed

+14896
-7905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+14896
-7905
lines changed

ChangeLog/6.0.10_Z_Final.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[main] Fixed certain cases of NRE happened on Domain build due to views in extracted schema
2+
[main] Fixed NotSupportedException appeared on x86 architecture when DateTimeOffset is used in entites

ChangeLog/7.1.0-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[main] CollectionExtensions.ReverseList() method is removed
2020
[main] ThreadSafeCached type is removed
2121
[main] Triplet<T> and Triplet<TFirst,TSecond,TThird> are removed
22+
[main] SqlTranslator/SqlCompiler APIs were significantly changed in order to improve memory usage and perfromance
2223
[main] Introduced IQueryable<T>.Tag() extensions allowing to add tags to result SQL statement
2324
[main] Introduced Session.Tag() method for being able to tag queries within returned TagScope
2425
[main] Domain.TagsEnabled is introduced as faster alternative to DomainConfiguration.TagLocation!=TagLocation.Nowhere check

Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Compiler.cs

Lines changed: 63 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void Visit(SqlSelect node)
3030
using (context.EnterScope(node)) {
3131
var comment = node.Comment;
3232
VisitCommentIfBefore(comment);
33-
context.Output.AppendText(translator.Translate(context, node, SelectSection.Entry));
33+
AppendTranslatedEntry(node);
3434
VisitCommentIfWithin(comment);
3535
VisitSelectLimitOffset(node);
3636
VisitSelectColumns(node);
@@ -39,40 +39,42 @@ public override void Visit(SqlSelect node)
3939
VisitSelectGroupBy(node);
4040
VisitSelectOrderBy(node);
4141
VisitSelectLock(node);
42-
context.Output.AppendText(translator.Translate(context, node, SelectSection.Exit));
42+
AppendTranslatedExit(node);
4343
VisitCommentIfAfter(comment);
4444
}
4545
}
4646

4747
/// <inheritdoc/>
48-
public override void VisitSelectFrom(SqlSelect node)
48+
protected override void VisitSelectFrom(SqlSelect node)
4949
{
50-
if (node.From!=null)
50+
if (node.From != null) {
5151
base.VisitSelectFrom(node);
52-
else
53-
context.Output.AppendText("FROM RDB$DATABASE");
52+
}
53+
else {
54+
_ = context.Output.Append(" FROM RDB$DATABASE");
55+
}
5456
}
5557

5658
/// <inheritdoc/>
5759
public override void Visit(SqlQueryExpression node)
5860
{
5961
using (context.EnterScope(node)) {
60-
bool needOpeningParenthesis = false;
61-
bool needClosingParenthesis = false;
62-
context.Output.AppendText(translator.Translate(context, node, QueryExpressionSection.Entry));
63-
if (needOpeningParenthesis)
64-
context.Output.AppendText("(");
62+
//bool needOpeningParenthesis = false;
63+
//bool needClosingParenthesis = false;
64+
AppendTranslated(node, QueryExpressionSection.Entry);
65+
//if (needOpeningParenthesis)
66+
// context.Output.Append("(");
6567
node.Left.AcceptVisitor(this);
66-
if (needClosingParenthesis)
67-
context.Output.AppendText(")");
68-
context.Output.AppendText(translator.Translate(node.NodeType));
69-
context.Output.AppendText(translator.Translate(context, node, QueryExpressionSection.All));
70-
if (needOpeningParenthesis)
71-
context.Output.AppendText("(");
68+
//if (needClosingParenthesis)
69+
// context.Output.Append(")");
70+
AppendTranslated(node.NodeType);
71+
AppendTranslated(node, QueryExpressionSection.All);
72+
//if (needOpeningParenthesis)
73+
// context.Output.Append("(");
7274
node.Right.AcceptVisitor(this);
73-
if (needClosingParenthesis)
74-
context.Output.AppendText(")");
75-
context.Output.AppendText(translator.Translate(context, node, QueryExpressionSection.Exit));
75+
//if (needClosingParenthesis)
76+
// context.Output.Append(")");
77+
AppendTranslated(node, QueryExpressionSection.Exit);
7678
}
7779
}
7880

@@ -106,17 +108,19 @@ public override void Visit(SqlExtract node)
106108
Visit(SqlDml.Add(node, SqlDml.Literal(1)));
107109
case_SqlDateTimePart_DayOfYear = false;
108110
}
109-
else
111+
else {
110112
base.Visit(node);
113+
}
111114
return;
112115
case SqlDateTimePart.Second:
113116
if (!case_SqlDateTimePart_Second) {
114117
case_SqlDateTimePart_Second = true;
115118
Visit(SqlDml.Truncate(node));
116119
case_SqlDateTimePart_Second = false;
117120
}
118-
else
121+
else {
119122
base.Visit(node);
123+
}
120124
return;
121125
}
122126
base.Visit(node);
@@ -125,7 +129,7 @@ public override void Visit(SqlExtract node)
125129
/// <inheritdoc/>
126130
public override void Visit(SqlUnary node)
127131
{
128-
if (node.NodeType==SqlNodeType.BitNot) {
132+
if (node.NodeType == SqlNodeType.BitNot) {
129133
Visit(BitNot(node.Operand));
130134
return;
131135
}
@@ -146,7 +150,7 @@ public override void Visit(SqlBinary node)
146150
DateTimeSubtractDateTime(node.Left, node.Right).AcceptVisitor(this);
147151
return;
148152
case SqlNodeType.Modulo:
149-
Visit(SqlDml.FunctionCall(translator.Translate(SqlNodeType.Modulo), node.Left, node.Right));
153+
Visit(SqlDml.FunctionCall(translator.TranslateToString(SqlNodeType.Modulo), node.Left, node.Right));
150154
return;
151155
case SqlNodeType.BitAnd:
152156
BitAnd(node.Left, node.Right).AcceptVisitor(this);
@@ -200,25 +204,24 @@ public override void Visit(SqlFunctionCall node)
200204
base.Visit(node);
201205
}
202206

203-
public override void Visit(SqlRenameTable node)
204-
{
205-
throw new NotSupportedException();
206-
}
207+
/// <inheritdoc/>
208+
public override void Visit(SqlRenameTable node) => throw new NotSupportedException();
207209

210+
/// <inheritdoc/>
208211
public override void Visit(SqlAlterSequence node)
209212
{
210-
context.Output.AppendText(translator.Translate(context, node, NodeSection.Entry));
211-
context.Output.AppendText(translator.Translate(context, node, NodeSection.Exit));
213+
translator.Translate(context, node, NodeSection.Entry);
214+
translator.Translate(context, node, NodeSection.Exit);
212215
}
213216

214217
#region Static helpers
215218

216219
protected static SqlExpression DateTimeSubtractDateTime(SqlExpression date1, SqlExpression date2)
217220
{
218-
return CastToLong(DateDiffDay(date2, date1)) * NanosecondsPerDay
221+
return (CastToLong(DateDiffDay(date2, date1)) * NanosecondsPerDay)
219222
+
220-
CastToLong(DateDiffMillisecond(DateAddDay(date2, DateDiffDay(date2, date1)), date1)) *
221-
NanosecondsPerMillisecond;
223+
(CastToLong(DateDiffMillisecond(DateAddDay(date2, DateDiffDay(date2, date1)), date1)) *
224+
NanosecondsPerMillisecond);
222225
}
223226

224227
protected static SqlExpression DateTimeAddInterval(SqlExpression date, SqlExpression interval)
@@ -228,75 +231,46 @@ protected static SqlExpression DateTimeAddInterval(SqlExpression date, SqlExpres
228231
(interval / NanosecondsPerMillisecond) % (MillisecondsPerDay));
229232
}
230233

231-
protected static SqlCast CastToLong(SqlExpression arg)
232-
{
233-
return SqlDml.Cast(arg, SqlType.Int64);
234-
}
234+
protected static SqlCast CastToLong(SqlExpression arg) => SqlDml.Cast(arg, SqlType.Int64);
235235

236-
protected static SqlUserFunctionCall DateDiffDay(SqlExpression date1, SqlExpression date2)
237-
{
238-
return SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("DAY"), date1, date2);
239-
}
236+
protected static SqlUserFunctionCall DateDiffDay(SqlExpression date1, SqlExpression date2) =>
237+
SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("DAY"), date1, date2);
240238

241-
protected static SqlUserFunctionCall DateDiffMillisecond(SqlExpression date1, SqlExpression date2)
242-
{
243-
return SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("MILLISECOND"), date1, date2);
244-
}
239+
protected static SqlUserFunctionCall DateDiffMillisecond(SqlExpression date1, SqlExpression date2) =>
240+
SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("MILLISECOND"), date1, date2);
245241

246-
protected static SqlUserFunctionCall DateAddYear(SqlExpression date, SqlExpression years)
247-
{
248-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("YEAR"), years, date);
249-
}
242+
protected static SqlUserFunctionCall DateAddYear(SqlExpression date, SqlExpression years) =>
243+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("YEAR"), years, date);
250244

251-
protected static SqlUserFunctionCall DateAddMonth(SqlExpression date, SqlExpression months)
252-
{
253-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("MONTH"), months, date);
254-
}
245+
protected static SqlUserFunctionCall DateAddMonth(SqlExpression date, SqlExpression months) =>
246+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("MONTH"), months, date);
255247

256-
protected static SqlUserFunctionCall DateAddDay(SqlExpression date, SqlExpression days)
257-
{
258-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("DAY"), days, date);
259-
}
248+
protected static SqlUserFunctionCall DateAddDay(SqlExpression date, SqlExpression days) =>
249+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("DAY"), days, date);
260250

261-
protected static SqlUserFunctionCall DateAddHour(SqlExpression date, SqlExpression hours)
262-
{
263-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("HOUR"), hours, date);
264-
}
251+
protected static SqlUserFunctionCall DateAddHour(SqlExpression date, SqlExpression hours) =>
252+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("HOUR"), hours, date);
265253

266-
protected static SqlUserFunctionCall DateAddMinute(SqlExpression date, SqlExpression minutes)
267-
{
268-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("MINUTE"), minutes, date);
269-
}
254+
protected static SqlUserFunctionCall DateAddMinute(SqlExpression date, SqlExpression minutes) =>
255+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("MINUTE"), minutes, date);
270256

271-
protected static SqlUserFunctionCall DateAddSecond(SqlExpression date, SqlExpression seconds)
272-
{
273-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("SECOND"), seconds, date);
274-
}
257+
protected static SqlUserFunctionCall DateAddSecond(SqlExpression date, SqlExpression seconds) =>
258+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("SECOND"), seconds, date);
275259

276-
protected static SqlUserFunctionCall DateAddMillisecond(SqlExpression date, SqlExpression milliseconds)
277-
{
278-
return SqlDml.FunctionCall("DATEADD", SqlDml.Native("MILLISECOND"), milliseconds, date);
279-
}
260+
protected static SqlUserFunctionCall DateAddMillisecond(SqlExpression date, SqlExpression milliseconds) =>
261+
SqlDml.FunctionCall("DATEADD", SqlDml.Native("MILLISECOND"), milliseconds, date);
280262

281-
protected static SqlUserFunctionCall BitAnd(SqlExpression left, SqlExpression right)
282-
{
283-
return SqlDml.FunctionCall("BIN_AND", left, right);
284-
}
263+
protected static SqlUserFunctionCall BitAnd(SqlExpression left, SqlExpression right) =>
264+
SqlDml.FunctionCall("BIN_AND", left, right);
285265

286-
protected static SqlUserFunctionCall BitOr(SqlExpression left, SqlExpression right)
287-
{
288-
return SqlDml.FunctionCall("BIN_OR", left, right);
289-
}
266+
protected static SqlUserFunctionCall BitOr(SqlExpression left, SqlExpression right) =>
267+
SqlDml.FunctionCall("BIN_OR", left, right);
290268

291-
protected static SqlUserFunctionCall BitXor(SqlExpression left, SqlExpression right)
292-
{
293-
return SqlDml.FunctionCall("BIN_XOR", left, right);
294-
}
269+
protected static SqlUserFunctionCall BitXor(SqlExpression left, SqlExpression right) =>
270+
SqlDml.FunctionCall("BIN_XOR", left, right);
295271

296-
protected static SqlUserFunctionCall BitNot(SqlExpression operand)
297-
{
298-
return SqlDml.FunctionCall("BIN_NOT", operand);
299-
}
272+
protected static SqlUserFunctionCall BitNot(SqlExpression operand) =>
273+
SqlDml.FunctionCall("BIN_NOT", operand);
300274

301275
protected static SqlConcat DateTimeToStringIso(SqlExpression dateTime)
302276
{

0 commit comments

Comments
 (0)