-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Expressions can now contain artithmetic for binary operations (+, -, * and /). - Expressions now follow correct operator pecedence. - Added SQLSTATE 22012 "division by zero". - Adding grouping expression (parenthesis). - Added concatenation `||`. - Added logical operators for `AND`, `OR` and `NOT`. - Added unary operators `+` and `-`. - Changes not equal operator `!=` to `<>` to correct follow the SQL standard. - Renamed the lexer tokens to be same as the naming conventions in the SQL standard.
- Loading branch information
1 parent
9fb4514
commit baa523a
Showing
18 changed files
with
482 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
SELECT 1 + 2; | ||
-- COL1: 3 | ||
|
||
SELECT 1 - 2; | ||
-- COL1: -1 | ||
|
||
SELECT 2 * 3; | ||
-- COL1: 6 | ||
|
||
SELECT 6 / 2; | ||
-- COL1: 3 | ||
|
||
SELECT 1.2 + 2.4; | ||
-- COL1: 3.6 | ||
|
||
SELECT 1.7 - 0.5; | ||
-- COL1: 1.2 | ||
|
||
SELECT 2.2 * 3.3; | ||
-- COL1: 7.26 | ||
|
||
SELECT 6 / 2.5; | ||
-- COL1: 2.4 | ||
|
||
SELECT 0 / 2.5; | ||
-- COL1: 0 | ||
|
||
SELECT 2.5 / 0; | ||
-- error 22012: division by zero | ||
|
||
SELECT -123; | ||
-- COL1: -123 | ||
|
||
SELECT +1.23; | ||
-- COL1: 1.23 | ||
|
||
SELECT 1.5 + 2.4 * 7; | ||
-- COL1: 18.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
SELECT 1 = 2; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 = 1; | ||
-- COL1: TRUE | ||
|
||
SELECT 1 <> 2; | ||
-- COL1: TRUE | ||
|
||
SELECT 1 <> 1; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 > 2; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 > 1; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 >= 2; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 >= 1; | ||
-- COL1: TRUE | ||
|
||
SELECT 1 < 2; | ||
-- COL1: TRUE | ||
|
||
SELECT 1 < 1; | ||
-- COL1: FALSE | ||
|
||
SELECT 1 <= 2; | ||
-- COL1: TRUE | ||
|
||
SELECT 1 <= 1; | ||
-- COL1: TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT 'foo' || 'bar'; | ||
-- COL1: foobar | ||
|
||
SELECT 123 || 'bar'; | ||
-- error 42804: data type mismatch cannot INTEGER || CHARACTER VARYING: expected another type but got INTEGER and CHARACTER VARYING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
SELECT TRUE AND TRUE; | ||
-- COL1: TRUE | ||
|
||
SELECT TRUE AND FALSE; | ||
-- COL1: FALSE | ||
|
||
SELECT FALSE AND TRUE; | ||
-- COL1: FALSE | ||
|
||
SELECT FALSE AND FALSE; | ||
-- COL1: FALSE | ||
|
||
SELECT TRUE OR TRUE; | ||
-- COL1: TRUE | ||
|
||
SELECT TRUE OR FALSE; | ||
-- COL1: TRUE | ||
|
||
SELECT FALSE OR TRUE; | ||
-- COL1: TRUE | ||
|
||
SELECT FALSE OR FALSE; | ||
-- COL1: FALSE | ||
|
||
SELECT NOT TRUE; | ||
-- COL1: FALSE | ||
|
||
SELECT NOT FALSE; | ||
-- COL1: TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ Select 'hello'; | |
|
||
SELECT 123, 456; | ||
-- COL1: 123 COL2: 456 | ||
|
||
SELECT 2 + 3 * 5, (2 + 3) * 5; | ||
-- COL1: 17 COL2: 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.