提交 f3383fbc authored 作者: Thomas Mueller's avatar Thomas Mueller

Support a comma before closing a list, as in: create table test(id int,)

上级 50d0f816
...@@ -734,8 +734,7 @@ public class Parser { ...@@ -734,8 +734,7 @@ public class Parser {
do { do {
String columnName = readColumnIdentifier(); String columnName = readColumnIdentifier();
columns.add(columnName); columns.add(columnName);
} while (readIf(",")); } while (readIfMore());
read(")");
String[] cols = new String[columns.size()]; String[] cols = new String[columns.size()];
columns.toArray(cols); columns.toArray(cols);
return cols; return cols;
...@@ -751,14 +750,21 @@ public class Parser { ...@@ -751,14 +750,21 @@ public class Parser {
throw Message.getSQLException(ErrorCode.DUPLICATE_COLUMN_NAME_1, column.getSQL()); throw Message.getSQLException(ErrorCode.DUPLICATE_COLUMN_NAME_1, column.getSQL());
} }
columns.add(column); columns.add(column);
} while (readIf(",")); } while (readIfMore());
read(")");
} }
Column[] cols = new Column[columns.size()]; Column[] cols = new Column[columns.size()];
columns.toArray(cols); columns.toArray(cols);
return cols; return cols;
} }
private boolean readIfMore() throws SQLException {
if (readIf(",")) {
return !readIf(")");
}
read(")");
return false;
}
private Prepared parseHelp() throws SQLException { private Prepared parseHelp() throws SQLException {
StringBuffer buff = new StringBuffer("SELECT * FROM INFORMATION_SCHEMA.HELP"); StringBuffer buff = new StringBuffer("SELECT * FROM INFORMATION_SCHEMA.HELP");
int i = 0; int i = 0;
...@@ -803,8 +809,7 @@ public class Parser { ...@@ -803,8 +809,7 @@ public class Parser {
} else { } else {
values.add(readExpression()); values.add(readExpression());
} }
} while (readIf(",")); } while (readIfMore());
read(")");
} }
Expression[] expr = new Expression[values.size()]; Expression[] expr = new Expression[values.size()];
values.toArray(expr); values.toArray(expr);
...@@ -841,8 +846,7 @@ public class Parser { ...@@ -841,8 +846,7 @@ public class Parser {
} else { } else {
values.add(readExpression()); values.add(readExpression());
} }
} while (readIf(",")); } while (readIfMore());
read(")");
} }
Expression[] expr = new Expression[values.size()]; Expression[] expr = new Expression[values.size()];
values.toArray(expr); values.toArray(expr);
...@@ -4531,8 +4535,7 @@ public class Parser { ...@@ -4531,8 +4535,7 @@ public class Parser {
command.addConstraintCommand(ref); command.addConstraintCommand(ref);
} }
} }
} while (readIf(",")); } while (readIfMore());
read(")");
} }
if (readIf("AS")) { if (readIf("AS")) {
command.setQuery(parseSelect()); command.setQuery(parseSelect());
......
create view test_view(id,) as select * from dual;
drop view test_view;
create table test(id int,);
insert into test(id,) values(1,);
merge into test(id,) key(id,) values(1,);
drop table test;
SET MODE DB2; SET MODE DB2;
SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 99 ROWS; SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 99 ROWS;
> 100; > 100;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论