提交 138b31ca authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Parse ANY and SOME in special way only in PostgreSQL mode

上级 8304d409
......@@ -2152,7 +2152,7 @@ ID<>2
"
"Other Grammar","Condition Right Hand Side","
compare { { { ALL | ANY | SOME } ( select ) } | operand }
compare { { ALL ( select ) } | operand }
| IS [ NOT ] NULL
| IS [ NOT ] [ DISTINCT FROM ] operand
| BETWEEN operand AND operand
......
......@@ -959,6 +959,7 @@ or the SQL statement <code>SET MODE PostgreSQL</code>.
</li><li>Fixed-width strings are padded with spaces.
</li><li>MONEY data type is treated like NUMERIC(19, 2) data type.
</li><li>Datetime value functions return the same value within a transaction.
</li><li>ANY and SOME after comparison operators are parsed as array comparison operators
</li></ul>
<h3>Ignite Compatibility Mode</h3>
......
......@@ -2857,7 +2857,7 @@ public class Parser {
r = new ConditionInSelect(database, r, query, true,
compareType);
read(CLOSE_PAREN);
} else if (readIf("ANY") || readIf("SOME")) {
} else if (database.getMode().anyAndSomeAreComparisons && (readIf("ANY") || readIf("SOME"))) {
read(OPEN_PAREN);
if (currentTokenType == PARAMETER && compareType == 0) {
Parameter p = readParameter();
......
......@@ -209,6 +209,12 @@ public class Mode {
*/
public boolean dateTimeValueWithinTransaction;
/**
* If {@code true}, ANY and SOME after comparison operators are parsed as
* array comparison operators.
*/
public boolean anyAndSomeAreComparisons;
/**
* An optional Set of hidden/disallowed column types.
* Certain DBMSs don't support all column types provided by H2, such as
......@@ -354,6 +360,7 @@ public class Mode {
dt.name = "MONEY";
mode.typeByNameMap.put("MONEY", dt);
mode.dateTimeValueWithinTransaction = true;
mode.anyAndSomeAreComparisons = true;
add(mode);
mode = new Mode(ModeEnum.Ignite);
......
......@@ -1642,6 +1642,7 @@ public class TestPreparedStatement extends TestDb {
anyParameterCheck(ps, 300, new int[] {30});
anyParameterCheck(ps, -5, new int[0]);
// Test expression = ANY(?)
conn.createStatement().execute("SET MODE PostgreSQL");
ps = conn.prepareStatement("SELECT ID FROM TEST WHERE VALUE = ANY(?)");
assertThrows(ErrorCode.PARAMETER_NOT_SET_1, ps).executeQuery();
anyParameterCheck(ps, values, expected);
......
......@@ -6513,6 +6513,9 @@ SELECT * FROM CUSTOMER WHERE NAME NOT IN(SELECT NAME FROM CUSTOMER);
> -- ----
> rows: 0
SET MODE PostgreSQL;
> ok
SELECT * FROM CUSTOMER WHERE NAME = ANY(SELECT NAME FROM CUSTOMER);
> ID NAME
> -- -------
......@@ -6545,6 +6548,9 @@ SELECT * FROM CUSTOMER WHERE NAME < ANY(SELECT NAME FROM CUSTOMER);
> 2 Meier
> rows: 2
SET MODE Regular;
> ok
DROP TABLE INVOICE;
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论