Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/sphinxexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,11 @@ DECLARE_UNARY_FLT ( Expr_Exp_c, float(exp(EVALFIRST)) )

DECLARE_UNARY_INT ( Expr_NotInt_c, (float)(INTFIRST?0:1), INTFIRST?0:1, INTFIRST?0:1 )
DECLARE_UNARY_INT ( Expr_NotInt64_c, (float)(INT64FIRST?0:1), INT64FIRST?0:1, INT64FIRST?0:1 )
DECLARE_UNARY_INT ( Expr_Sint_c, (float)(INTFIRST), INTFIRST, INTFIRST )
DECLARE_UNARY_TRAITS ( Expr_Sint_c )
float Eval ( const CSphMatch & tMatch ) const final { return (float)Int64Eval ( tMatch ); }
int IntEval ( const CSphMatch & tMatch ) const final { return (int)Int64Eval ( tMatch ); }
int64_t Int64Eval ( const CSphMatch & tMatch ) const final { return INT64FIRST; }
};
Comment on lines +3290 to +3294

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too complex and redundand.
Original line can be just replaced to

DECLARE_UNARY_INT ( Expr_Sint_c,		INT64FIRST,			INT64FIRST,		INT64FIRST )

(that is - simple change INTFIRST to INT64FIRST triple.


DECLARE_UNARY_TRAITS ( Expr_Ln_c )
float Eval ( const CSphMatch & tMatch ) const final
Expand Down Expand Up @@ -9554,11 +9558,16 @@ int ExprParser_t::AddNodeOp ( int iOp, int iLeft, int iRight )
}
break;

case '+': case '-': case '*': case ',':
case '+': case '*': case ',':
tNode.m_eArgType = GetWidestRet ( iLeft, iRight );
tNode.m_eRetType = tNode.m_eArgType;
break;

case '-':
tNode.m_eArgType = GetWidestRet ( iLeft, iRight );
tNode.m_eRetType = ( tNode.m_eArgType==SPH_ATTR_INTEGER ) ? SPH_ATTR_BIGINT : tNode.m_eArgType;
break;

case '%':
tNode.m_eArgType = GetWidestRet ( iLeft, iRight );
tNode.m_eRetType = tNode.m_eArgType;
Expand Down
2 changes: 1 addition & 1 deletion test/test_125/model.bin

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/test_125/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,18 @@ INSERT INTO name_table VALUES
SELECT IN(aa-(aa-15), 15) FROM test WHERE id=10;

<!-- various function and operators for test coverage -->
SELECT 1-2 FROM test WHERE id=10;
SELECT 1-id FROM test WHERE id=10;
SELECT SINT(1-2) FROM test WHERE id=10;

<!-- exact repro shape and more signed subtraction edge cases -->
SELECT *, 1-2 AS diff FROM test WHERE id=10;
SELECT *, aa-4 AS diff FROM test ORDER BY id ASC;
SELECT *, 1-aa AS diff FROM test ORDER BY id ASC;
SELECT *, aa-(aa+1) AS diff FROM test ORDER BY id ASC;
SELECT *, (1-2)+aa AS diff FROM test ORDER BY id ASC;
SELECT *, (1-2)-(3-4) AS diff FROM test WHERE id=10;
Comment on lines +303 to +308

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to add:

	SELECT *, 1-2+2000000000+1000000001 AS diff FROM test WHERE id=10;
	SELECT *, aa-4+2000000000+1000000001 AS diff FROM test ORDER BY id ASC;
	SELECT *, 1-aa+2000000000+1000000001 AS diff FROM test ORDER BY id ASC;
	SELECT *, aa-(aa+1)+2000000000+1000000001 AS diff FROM test ORDER BY id ASC;
	SELECT *, (1-2)+aa+2000000000+1000000001 AS diff FROM test ORDER BY id ASC;
	SELECT *, (1-2)-(3-4)+2000000000+1000000001 AS diff FROM test WHERE id=10;

after this block. Comparing to current master, it also reveals prominent difference in result

SELECT *, BIGINT(1)-BIGINT(2) AS diff FROM test WHERE id=10;
SELECT FIBONACCI(5) FROM test WHERE id=10;
SELECT INTERVAL(1, -1,3,5.0) FROM test WHERE id=10;
SELECT INTERVAL(id, id-1, id+2) FROM test WHERE id=10;
Expand Down
Loading