mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 18:03:03 +01:00
Usage of C++11 strongly typed enum.
This commit is contained in:
parent
f864a6d68a
commit
09c2dc164b
@ -20,3 +20,4 @@ Only ones mentioned in this document could be used, but as necessities appears,
|
||||
- [function object binders](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1455.htm)
|
||||
- [function template mem_fn](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1432.htm)
|
||||
- [rvalue references](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html)
|
||||
- [strongly-typed enum](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf)
|
||||
|
@ -7447,13 +7447,13 @@ WindowClause::FrameExtent* WindowClause::FrameExtent::dsqlPass(DsqlCompilerScrat
|
||||
{
|
||||
if (frame1 && frame2)
|
||||
{
|
||||
if (frame1->bound == Frame::BOUND_CURRENT_ROW && frame2->bound == Frame::BOUND_PRECEDING)
|
||||
if (frame1->bound == Frame::Bound::CURRENT_ROW && frame2->bound == Frame::Bound::PRECEDING)
|
||||
{
|
||||
status_exception::raise(
|
||||
Arg::Gds(isc_dsql_window_incompat_frames) << "CURRENT ROW" << "PRECEDING");
|
||||
}
|
||||
|
||||
if (frame1->bound == Frame::BOUND_FOLLOWING && frame2->bound != Frame::BOUND_FOLLOWING)
|
||||
if (frame1->bound == Frame::Bound::FOLLOWING && frame2->bound != Frame::Bound::FOLLOWING)
|
||||
{
|
||||
status_exception::raise(
|
||||
Arg::Gds(isc_dsql_window_incompat_frames) <<
|
||||
@ -7536,7 +7536,7 @@ WindowClause* WindowClause::dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
||||
doDsqlPass(dsqlScratch, window->extent),
|
||||
window->exclusion);
|
||||
|
||||
if (node->order && node->extent && node->extent->unit == FrameExtent::UNIT_RANGE &&
|
||||
if (node->order && node->extent && node->extent->unit == FrameExtent::Unit::RANGE &&
|
||||
(node->extent->frame1->value || (node->extent->frame2 && node->extent->frame2->value)))
|
||||
{
|
||||
if (node->order->items.getCount() > 1)
|
||||
@ -7816,7 +7816,7 @@ ValueExprNode* OverNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
||||
AggNode::CAP_RESPECTS_WINDOW_FRAME)
|
||||
{
|
||||
node->window->extent = WindowClause::FrameExtent::createDefault(getPool());
|
||||
node->window->exclusion = WindowClause::EXCLUDE_NO_OTHERS;
|
||||
node->window->exclusion = WindowClause::Exclusion::NO_OTHERS;
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -982,12 +982,12 @@ public:
|
||||
class Frame : public TypedNode<ListExprNode, ExprNode::TYPE_WINDOW_CLAUSE_FRAME>
|
||||
{
|
||||
public:
|
||||
enum Bound
|
||||
enum class Bound : UCHAR
|
||||
{
|
||||
// Warning: used in BLR
|
||||
BOUND_PRECEDING = 0,
|
||||
BOUND_FOLLOWING,
|
||||
BOUND_CURRENT_ROW
|
||||
PRECEDING = 0,
|
||||
FOLLOWING,
|
||||
CURRENT_ROW
|
||||
};
|
||||
|
||||
public:
|
||||
@ -1002,7 +1002,7 @@ public:
|
||||
public:
|
||||
virtual Firebird::string internalPrint(NodePrinter& printer) const
|
||||
{
|
||||
NODE_PRINT(printer, bound);
|
||||
NODE_PRINT_ENUM(printer, bound);
|
||||
NODE_PRINT(printer, value);
|
||||
|
||||
return "WindowClause::Frame";
|
||||
@ -1054,11 +1054,11 @@ public:
|
||||
class FrameExtent : public TypedNode<ListExprNode, ExprNode::TYPE_WINDOW_CLAUSE_FRAME_EXTENT>
|
||||
{
|
||||
public:
|
||||
enum Unit
|
||||
enum class Unit : UCHAR
|
||||
{
|
||||
// Warning: used in BLR
|
||||
UNIT_RANGE = 0,
|
||||
UNIT_ROWS
|
||||
RANGE = 0,
|
||||
ROWS
|
||||
//// TODO: SQL-2013: GROUPS
|
||||
};
|
||||
|
||||
@ -1075,16 +1075,16 @@ public:
|
||||
|
||||
static FrameExtent* createDefault(MemoryPool& p)
|
||||
{
|
||||
FrameExtent* frameExtent = FB_NEW_POOL(p) WindowClause::FrameExtent(p, UNIT_RANGE);
|
||||
frameExtent->frame1 = FB_NEW_POOL(p) WindowClause::Frame(p, Frame::BOUND_PRECEDING);
|
||||
frameExtent->frame2 = FB_NEW_POOL(p) WindowClause::Frame(p, Frame::BOUND_CURRENT_ROW);
|
||||
FrameExtent* frameExtent = FB_NEW_POOL(p) WindowClause::FrameExtent(p, Unit::RANGE);
|
||||
frameExtent->frame1 = FB_NEW_POOL(p) WindowClause::Frame(p, Frame::Bound::PRECEDING);
|
||||
frameExtent->frame2 = FB_NEW_POOL(p) WindowClause::Frame(p, Frame::Bound::CURRENT_ROW);
|
||||
return frameExtent;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual Firebird::string internalPrint(NodePrinter& printer) const
|
||||
{
|
||||
NODE_PRINT(printer, unit);
|
||||
NODE_PRINT_ENUM(printer, unit);
|
||||
NODE_PRINT(printer, frame1);
|
||||
NODE_PRINT(printer, frame2);
|
||||
|
||||
@ -1121,13 +1121,13 @@ public:
|
||||
NestConst<Frame> frame2;
|
||||
};
|
||||
|
||||
enum Exclusion
|
||||
enum Exclusion : UCHAR
|
||||
{
|
||||
// Warning: used in BLR
|
||||
EXCLUDE_NO_OTHERS = 0,
|
||||
EXCLUDE_CURRENT_ROW,
|
||||
EXCLUDE_GROUP,
|
||||
EXCLUDE_TIES
|
||||
NO_OTHERS = 0,
|
||||
CURRENT_ROW,
|
||||
GROUP,
|
||||
TIES
|
||||
};
|
||||
|
||||
public:
|
||||
@ -1136,7 +1136,7 @@ public:
|
||||
ValueListNode* aPartition = NULL,
|
||||
ValueListNode* aOrder = NULL,
|
||||
FrameExtent* aFrameExtent = NULL,
|
||||
Exclusion aExclusion = EXCLUDE_NO_OTHERS)
|
||||
Exclusion aExclusion = Exclusion::NO_OTHERS)
|
||||
: DsqlNode(p),
|
||||
name(aName),
|
||||
partition(aPartition),
|
||||
@ -1155,6 +1155,7 @@ public:
|
||||
NODE_PRINT(printer, partition);
|
||||
NODE_PRINT(printer, order);
|
||||
NODE_PRINT(printer, extent);
|
||||
NODE_PRINT_ENUM(printer, exclusion);
|
||||
|
||||
return "WindowClause";
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "../dsql/Nodes.h"
|
||||
|
||||
#define NODE_PRINT(var, property) var.print(STRINGIZE(property), property)
|
||||
#define NODE_PRINT_ENUM(var, property) var.print(STRINGIZE(property), (int) property)
|
||||
|
||||
namespace Jrd {
|
||||
|
||||
|
@ -7146,11 +7146,11 @@ window_frame_extent
|
||||
: /* nothing */
|
||||
{ $$ = NULL; }
|
||||
| RANGE
|
||||
{ $$ = newNode<WindowClause::FrameExtent>(WindowClause::FrameExtent::UNIT_RANGE); }
|
||||
{ $$ = newNode<WindowClause::FrameExtent>(WindowClause::FrameExtent::Unit::RANGE); }
|
||||
window_frame($2)
|
||||
{ $$ = $2; }
|
||||
| ROWS
|
||||
{ $$ = newNode<WindowClause::FrameExtent>(WindowClause::FrameExtent::UNIT_ROWS); }
|
||||
{ $$ = newNode<WindowClause::FrameExtent>(WindowClause::FrameExtent::Unit::ROWS); }
|
||||
window_frame($2)
|
||||
{ $$ = $2; }
|
||||
;
|
||||
@ -7161,7 +7161,7 @@ window_frame($frameExtent)
|
||||
{
|
||||
$frameExtent->frame1 = $1;
|
||||
$frameExtent->frame2 =
|
||||
newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_CURRENT_ROW);
|
||||
newNode<WindowClause::Frame>(WindowClause::Frame::Bound::CURRENT_ROW);
|
||||
}
|
||||
| BETWEEN window_frame_between_bound1 AND window_frame_between_bound2
|
||||
{
|
||||
@ -7173,44 +7173,44 @@ window_frame($frameExtent)
|
||||
%type <windowClauseFrame> window_frame_start
|
||||
window_frame_start
|
||||
: UNBOUNDED PRECEDING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_PRECEDING); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::PRECEDING); }
|
||||
| CURRENT ROW
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_CURRENT_ROW); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::CURRENT_ROW); }
|
||||
| value PRECEDING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_PRECEDING, $1); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::PRECEDING, $1); }
|
||||
;
|
||||
|
||||
%type <windowClauseFrame> window_frame_between_bound1
|
||||
window_frame_between_bound1
|
||||
: UNBOUNDED PRECEDING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_PRECEDING); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::PRECEDING); }
|
||||
| CURRENT ROW
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_CURRENT_ROW); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::CURRENT_ROW); }
|
||||
| value PRECEDING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_PRECEDING, $1); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::PRECEDING, $1); }
|
||||
| value FOLLOWING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_FOLLOWING, $1); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::FOLLOWING, $1); }
|
||||
;
|
||||
|
||||
%type <windowClauseFrame> window_frame_between_bound2
|
||||
window_frame_between_bound2
|
||||
: UNBOUNDED FOLLOWING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_FOLLOWING); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::FOLLOWING); }
|
||||
| CURRENT ROW
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_CURRENT_ROW); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::CURRENT_ROW); }
|
||||
| value PRECEDING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_PRECEDING, $1); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::PRECEDING, $1); }
|
||||
| value FOLLOWING
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::BOUND_FOLLOWING, $1); }
|
||||
{ $$ = newNode<WindowClause::Frame>(WindowClause::Frame::Bound::FOLLOWING, $1); }
|
||||
;
|
||||
|
||||
%type <windowClauseExclusion> window_frame_exclusion_opt
|
||||
window_frame_exclusion_opt
|
||||
: /* nothing */ { $$ = WindowClause::EXCLUDE_NO_OTHERS; }
|
||||
| EXCLUDE NO OTHERS { $$ = WindowClause::EXCLUDE_NO_OTHERS; }
|
||||
| EXCLUDE CURRENT ROW { $$ = WindowClause::EXCLUDE_CURRENT_ROW; }
|
||||
| EXCLUDE GROUP { $$ = WindowClause::EXCLUDE_GROUP; }
|
||||
| EXCLUDE TIES { $$ = WindowClause::EXCLUDE_TIES; }
|
||||
: /* nothing */ { $$ = WindowClause::Exclusion::NO_OTHERS; }
|
||||
| EXCLUDE NO OTHERS { $$ = WindowClause::Exclusion::NO_OTHERS; }
|
||||
| EXCLUDE CURRENT ROW { $$ = WindowClause::Exclusion::CURRENT_ROW; }
|
||||
| EXCLUDE GROUP { $$ = WindowClause::Exclusion::GROUP; }
|
||||
| EXCLUDE TIES { $$ = WindowClause::Exclusion::TIES; }
|
||||
;
|
||||
|
||||
%type <valueExprNode> delimiter_opt
|
||||
|
@ -2955,7 +2955,7 @@ WindowMap* dsql_ctx::getWindowMap(DsqlCompilerScratch* dsqlScratch, WindowClause
|
||||
MemoryPool& pool = *tdbb->getDefaultPool();
|
||||
|
||||
bool isNullWindow = windowNode == NULL;
|
||||
WindowClause nullWindow(pool, NULL, NULL, NULL, NULL, WindowClause::EXCLUDE_NO_OTHERS);
|
||||
WindowClause nullWindow(pool, NULL, NULL, NULL, NULL, WindowClause::Exclusion::NO_OTHERS);
|
||||
|
||||
if (isNullWindow)
|
||||
windowNode = &nullWindow;
|
||||
@ -2977,7 +2977,7 @@ WindowMap* dsql_ctx::getWindowMap(DsqlCompilerScratch* dsqlScratch, WindowClause
|
||||
if (isNullWindow)
|
||||
{
|
||||
windowNode = FB_NEW_POOL(pool) WindowClause(pool, NULL, NULL, NULL, NULL,
|
||||
WindowClause::EXCLUDE_NO_OTHERS);
|
||||
WindowClause::Exclusion::NO_OTHERS);
|
||||
}
|
||||
|
||||
windowMap = FB_NEW_POOL(*tdbb->getDefaultPool()) WindowMap(windowNode);
|
||||
|
@ -1331,7 +1331,7 @@ void AggregateSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
{
|
||||
bool v3 = !((*i)->window &&
|
||||
((*i)->window->extent ||
|
||||
(*i)->window->exclusion != WindowClause::EXCLUDE_NO_OTHERS));
|
||||
(*i)->window->exclusion != WindowClause::Exclusion::NO_OTHERS));
|
||||
|
||||
ValueListNode* partition = (*i)->window ? (*i)->window->partition : NULL;
|
||||
ValueListNode* partitionRemapped = (*i)->partitionRemapped;
|
||||
@ -1399,7 +1399,7 @@ void AggregateSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
}
|
||||
}
|
||||
|
||||
if ((*i)->window->exclusion != WindowClause::EXCLUDE_NO_OTHERS)
|
||||
if ((*i)->window->exclusion != WindowClause::Exclusion::NO_OTHERS)
|
||||
{
|
||||
dsqlScratch->appendUChar(blr_window_win_exclusion);
|
||||
dsqlScratch->appendUChar((UCHAR) (*i)->window->exclusion);
|
||||
@ -2122,8 +2122,8 @@ void WindowSourceNode::parseWindow(thread_db* tdbb, CompilerScratch* csb)
|
||||
|
||||
switch (window.frameExtent->unit)
|
||||
{
|
||||
case WindowClause::FrameExtent::UNIT_RANGE:
|
||||
case WindowClause::FrameExtent::UNIT_ROWS:
|
||||
case WindowClause::FrameExtent::Unit::RANGE:
|
||||
case WindowClause::FrameExtent::Unit::ROWS:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2142,10 +2142,10 @@ void WindowSourceNode::parseWindow(thread_db* tdbb, CompilerScratch* csb)
|
||||
|
||||
switch (window.exclusion)
|
||||
{
|
||||
case WindowClause::EXCLUDE_NO_OTHERS:
|
||||
case WindowClause::EXCLUDE_CURRENT_ROW:
|
||||
case WindowClause::EXCLUDE_GROUP:
|
||||
case WindowClause::EXCLUDE_TIES:
|
||||
case WindowClause::Exclusion::NO_OTHERS:
|
||||
case WindowClause::Exclusion::CURRENT_ROW:
|
||||
case WindowClause::Exclusion::GROUP:
|
||||
case WindowClause::Exclusion::TIES:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2175,9 +2175,9 @@ void WindowSourceNode::parseWindow(thread_db* tdbb, CompilerScratch* csb)
|
||||
|
||||
switch (frame->bound)
|
||||
{
|
||||
case WindowClause::Frame::BOUND_PRECEDING:
|
||||
case WindowClause::Frame::BOUND_FOLLOWING:
|
||||
case WindowClause::Frame::BOUND_CURRENT_ROW:
|
||||
case WindowClause::Frame::Bound::PRECEDING:
|
||||
case WindowClause::Frame::Bound::FOLLOWING:
|
||||
case WindowClause::Frame::Bound::CURRENT_ROW:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -556,7 +556,7 @@ public:
|
||||
{
|
||||
explicit Window(MemoryPool&)
|
||||
: stream(INVALID_STREAM),
|
||||
exclusion(WindowClause::EXCLUDE_NO_OTHERS)
|
||||
exclusion(WindowClause::Exclusion::NO_OTHERS)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -263,10 +263,10 @@ WindowedStream::WindowedStream(thread_db* tdbb, CompilerScratch* csb,
|
||||
|
||||
// between !{<n> following || unbounded preceding} and unbounded following
|
||||
if (window->frameExtent &&
|
||||
window->frameExtent->frame2->bound == WindowClause::Frame::BOUND_FOLLOWING &&
|
||||
window->frameExtent->frame2->bound == WindowClause::Frame::Bound::FOLLOWING &&
|
||||
!window->frameExtent->frame2->value &&
|
||||
!(window->frameExtent->frame1->bound == WindowClause::Frame::BOUND_FOLLOWING ||
|
||||
(window->frameExtent->frame1->bound == WindowClause::Frame::BOUND_PRECEDING &&
|
||||
!(window->frameExtent->frame1->bound == WindowClause::Frame::Bound::FOLLOWING ||
|
||||
(window->frameExtent->frame1->bound == WindowClause::Frame::Bound::PRECEDING &&
|
||||
!window->frameExtent->frame1->value)))
|
||||
{
|
||||
if (window->order)
|
||||
@ -290,10 +290,10 @@ WindowedStream::WindowedStream(thread_db* tdbb, CompilerScratch* csb,
|
||||
window->frameExtent->frame1 = window->frameExtent->frame2;
|
||||
window->frameExtent->frame2 = temp;
|
||||
|
||||
window->frameExtent->frame1->bound = WindowClause::Frame::BOUND_PRECEDING;
|
||||
window->frameExtent->frame1->bound = WindowClause::Frame::Bound::PRECEDING;
|
||||
|
||||
if (window->frameExtent->frame2->bound == WindowClause::Frame::BOUND_PRECEDING)
|
||||
window->frameExtent->frame2->bound = WindowClause::Frame::BOUND_FOLLOWING;
|
||||
if (window->frameExtent->frame2->bound == WindowClause::Frame::Bound::PRECEDING)
|
||||
window->frameExtent->frame2->bound = WindowClause::Frame::Bound::FOLLOWING;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -474,9 +474,9 @@ WindowedStream::WindowStream::WindowStream(thread_db* tdbb, CompilerScratch* csb
|
||||
WindowClause::Frame* frame = i == 0 ?
|
||||
m_frameExtent->frame1 : m_frameExtent->frame2;
|
||||
|
||||
if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE && frame->value)
|
||||
if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE && frame->value)
|
||||
{
|
||||
int direction = frame->bound == WindowClause::Frame::BOUND_FOLLOWING ? 1 : -1;
|
||||
int direction = frame->bound == WindowClause::Frame::Bound::FOLLOWING ? 1 : -1;
|
||||
|
||||
if (m_order->descending[0])
|
||||
direction *= -1;
|
||||
@ -613,31 +613,31 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
|
||||
if (!m_order)
|
||||
impure->windowBlock.startPosition = impure->partitionBlock.startPosition;
|
||||
// {range | rows} between unbounded preceding and ...
|
||||
else if (m_frameExtent->frame1->bound == WindowClause::Frame::BOUND_PRECEDING &&
|
||||
else if (m_frameExtent->frame1->bound == WindowClause::Frame::Bound::PRECEDING &&
|
||||
!m_frameExtent->frame1->value)
|
||||
{
|
||||
impure->windowBlock.startPosition = impure->partitionBlock.startPosition;
|
||||
}
|
||||
// rows between current row and ...
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_ROWS &&
|
||||
m_frameExtent->frame1->bound == WindowClause::Frame::BOUND_CURRENT_ROW)
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::ROWS &&
|
||||
m_frameExtent->frame1->bound == WindowClause::Frame::Bound::CURRENT_ROW)
|
||||
{
|
||||
impure->windowBlock.startPosition = position;
|
||||
}
|
||||
// rows between <n> {preceding | following} and ...
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_ROWS &&
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::ROWS &&
|
||||
m_frameExtent->frame1->value)
|
||||
{
|
||||
impure->windowBlock.startPosition = position + impure->startOffset.vlux_count;
|
||||
}
|
||||
// range between current row and ...
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE &&
|
||||
m_frameExtent->frame1->bound == WindowClause::Frame::BOUND_CURRENT_ROW)
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE &&
|
||||
m_frameExtent->frame1->bound == WindowClause::Frame::Bound::CURRENT_ROW)
|
||||
{
|
||||
impure->windowBlock.startPosition = position;
|
||||
}
|
||||
// range between <n> {preceding | following} and ...
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE &&
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE &&
|
||||
m_frameExtent->frame1->value)
|
||||
{
|
||||
impure->windowBlock.startPosition = locateFrameRange(tdbb, request, impure,
|
||||
@ -657,26 +657,26 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
|
||||
if (!m_order)
|
||||
impure->windowBlock.endPosition = impure->partitionBlock.endPosition;
|
||||
// {range | rows} between ... and unbounded following
|
||||
else if (m_frameExtent->frame2->bound == WindowClause::Frame::BOUND_FOLLOWING &&
|
||||
else if (m_frameExtent->frame2->bound == WindowClause::Frame::Bound::FOLLOWING &&
|
||||
!m_frameExtent->frame2->value)
|
||||
{
|
||||
impure->windowBlock.endPosition = impure->partitionBlock.endPosition;
|
||||
}
|
||||
// rows between ... and current row
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_ROWS &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::BOUND_CURRENT_ROW)
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::ROWS &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::Bound::CURRENT_ROW)
|
||||
{
|
||||
impure->windowBlock.endPosition = position;
|
||||
}
|
||||
// rows between ... and <n> {preceding | following}
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_ROWS &&
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::ROWS &&
|
||||
m_frameExtent->frame2->value)
|
||||
{
|
||||
impure->windowBlock.endPosition = position + impure->endOffset.vlux_count;
|
||||
}
|
||||
// range between ... and current row
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::BOUND_CURRENT_ROW)
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::Bound::CURRENT_ROW)
|
||||
{
|
||||
SINT64 rangePos = position;
|
||||
cacheValues(tdbb, request, &m_order->expressions, impure->orderValues,
|
||||
@ -702,7 +702,7 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
|
||||
fb_assert(false);
|
||||
}
|
||||
// range between ... and <n> {preceding | following}
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE &&
|
||||
else if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE &&
|
||||
m_frameExtent->frame2->value)
|
||||
{
|
||||
impure->windowBlock.endPosition = locateFrameRange(tdbb, request, impure,
|
||||
@ -716,11 +716,11 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
|
||||
|
||||
if (!m_order)
|
||||
impure->rangePending = MAX(0, impure->windowBlock.endPosition - position);
|
||||
else if (m_order && m_frameExtent->unit == WindowClause::FrameExtent::UNIT_RANGE)
|
||||
else if (m_order && m_frameExtent->unit == WindowClause::FrameExtent::Unit::RANGE)
|
||||
{
|
||||
if (m_frameExtent->frame1->bound == WindowClause::Frame::BOUND_PRECEDING &&
|
||||
if (m_frameExtent->frame1->bound == WindowClause::Frame::Bound::PRECEDING &&
|
||||
!m_frameExtent->frame1->value &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::BOUND_FOLLOWING &&
|
||||
m_frameExtent->frame2->bound == WindowClause::Frame::Bound::FOLLOWING &&
|
||||
!m_frameExtent->frame2->value)
|
||||
{
|
||||
impure->rangePending = MAX(0, impure->windowBlock.endPosition - position);
|
||||
@ -913,7 +913,7 @@ const void WindowedStream::WindowStream::getFrameValue(thread_db* tdbb, jrd_req*
|
||||
error = true;
|
||||
else
|
||||
{
|
||||
if (m_frameExtent->unit == WindowClause::FrameExtent::UNIT_ROWS)
|
||||
if (m_frameExtent->unit == WindowClause::FrameExtent::Unit::ROWS)
|
||||
{
|
||||
// Purposedly used 32-bit here. So long distance will complicate things for no gain.
|
||||
impureValue->vlux_count = MOV_get_long(desc, 0);
|
||||
@ -921,7 +921,7 @@ const void WindowedStream::WindowStream::getFrameValue(thread_db* tdbb, jrd_req*
|
||||
if (impureValue->vlux_count < 0)
|
||||
error = true;
|
||||
|
||||
if (frame->bound == WindowClause::Frame::BOUND_PRECEDING)
|
||||
if (frame->bound == WindowClause::Frame::Bound::PRECEDING)
|
||||
impureValue->vlux_count = -impureValue->vlux_count;
|
||||
}
|
||||
else if (MOV_compare(desc, &zeroDsc) < 0)
|
||||
@ -951,7 +951,7 @@ SINT64 WindowedStream::WindowStream::locateFrameRange(thread_db* tdbb, jrd_req*
|
||||
|
||||
if (offsetDesc)
|
||||
{
|
||||
int direction = (frame->bound == WindowClause::Frame::BOUND_FOLLOWING ? 1 : -1);
|
||||
int direction = (frame->bound == WindowClause::Frame::Bound::FOLLOWING ? 1 : -1);
|
||||
|
||||
if (m_order->descending[0])
|
||||
direction *= -1;
|
||||
@ -985,7 +985,7 @@ SINT64 WindowedStream::WindowStream::locateFrameRange(thread_db* tdbb, jrd_req*
|
||||
--rangePos;
|
||||
}
|
||||
}
|
||||
else if (frame->bound == WindowClause::Frame::BOUND_FOLLOWING)
|
||||
else if (frame->bound == WindowClause::Frame::Bound::FOLLOWING)
|
||||
{
|
||||
const int bound = frame == m_frameExtent->frame1 ? 0 : 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user