提交 eab3251b authored 作者: plus33's avatar plus33

Added more Oracle compatibility: VARCHAR with type BYTE is accepted now

too. The type treaded same as CHAR.
上级 d40ab416
...@@ -3486,6 +3486,20 @@ public class Parser { ...@@ -3486,6 +3486,20 @@ public class Parser {
addExpected(token); addExpected(token);
return false; return false;
} }
/*
* Reads passed token in list, in order and returns true on first match.
* If none of the token matches returns false
*/
private boolean readIfOr(String ... tokens) {
for(String token: tokens) {
if (readIf(token)) {
return true;
}
}
return false;
}
/* /*
* Reads every token in list, in order - returns true if all are found. * Reads every token in list, in order - returns true if all are found.
* If any are not found, returns false - AND resets parsing back to state when called. * If any are not found, returns false - AND resets parsing back to state when called.
...@@ -4466,7 +4480,7 @@ public class Parser { ...@@ -4466,7 +4480,7 @@ public class Parser {
} }
original += "(" + p; original += "(" + p;
// Oracle syntax // Oracle syntax
readIf("CHAR"); readIfOr("CHAR", "BYTE");
if (dataType.supportsScale) { if (dataType.supportsScale) {
if (readIf(",")) { if (readIf(",")) {
scale = readInt(); scale = readInt();
......
...@@ -40,6 +40,7 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -40,6 +40,7 @@ public class TestCompatibilityOracle extends TestBase {
testPoundSymbolInColumnName(); testPoundSymbolInColumnName();
testToDate(); testToDate();
testForbidEmptyInClause(); testForbidEmptyInClause();
testSpecialTypes();
} }
private void testNotNullSyntax() throws SQLException { private void testNotNullSyntax() throws SQLException {
...@@ -86,12 +87,28 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -86,12 +87,28 @@ public class TestCompatibilityOracle extends TestBase {
conn.close(); conn.close();
} }
private void testSpecialTypes() throws SQLException {
// Test VARCHAR, VARCHAR2 with CHAR and BYTE
deleteDb("oracle");
Connection conn = getConnection("oracle;MODE=Oracle");
Statement stat = conn.createStatement();
stat.execute("create table T (ID NUMBER)");
stat.execute("alter table T add A_1 VARCHAR(1)");
stat.execute("alter table T add A_2 VARCHAR2(1)");
stat.execute("alter table T add B_1 VARCHAR(1 byte)"); // with BYTE
stat.execute("alter table T add B_2 VARCHAR2(1 byte)");
stat.execute("alter table T add C_1 VARCHAR(1 char)"); // with CHAR
stat.execute("alter table T add C_2 VARCHAR2(1 char)");
stat.execute("alter table T add B_255 VARCHAR(255 byte)");
stat.execute("alter table T add C_255 VARCHAR(255 char)");
stat.execute("drop table T");
conn.close();
}
private void testTreatEmptyStringsAsNull() throws SQLException { private void testTreatEmptyStringsAsNull() throws SQLException {
deleteDb("oracle"); deleteDb("oracle");
Connection conn = getConnection("oracle;MODE=Oracle"); Connection conn = getConnection("oracle;MODE=Oracle");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE A (ID NUMBER, X VARCHAR2(1))"); stat.execute("CREATE TABLE A (ID NUMBER, X VARCHAR2(1))");
stat.execute("INSERT INTO A VALUES (1, 'a')"); stat.execute("INSERT INTO A VALUES (1, 'a')");
stat.execute("INSERT INTO A VALUES (2, '')"); stat.execute("INSERT INTO A VALUES (2, '')");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论