提交 1762e152 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Extract Parser.parseValuesForInsert()

上级 d5a35fe2
...@@ -956,6 +956,20 @@ public class Parser { ...@@ -956,6 +956,20 @@ public class Parser {
return false; return false;
} }
private Expression[] parseValuesForInsert() {
ArrayList<Expression> values = Utils.newSmallArrayList();
if (!readIf(")")) {
do {
if (readIf("DEFAULT")) {
values.add(null);
} else {
values.add(readExpression());
}
} while (readIfMore(false));
}
return values.toArray(new Expression[0]);
}
private Prepared parseHelp() { private Prepared parseHelp() {
StringBuilder buff = new StringBuilder( StringBuilder buff = new StringBuilder(
"SELECT * FROM INFORMATION_SCHEMA.HELP"); "SELECT * FROM INFORMATION_SCHEMA.HELP");
...@@ -1105,18 +1119,8 @@ public class Parser { ...@@ -1105,18 +1119,8 @@ public class Parser {
} }
if (readIf("VALUES")) { if (readIf("VALUES")) {
do { do {
ArrayList<Expression> values = Utils.newSmallArrayList();
read("("); read("(");
if (!readIf(")")) { command.addRow(parseValuesForInsert());
do {
if (readIf("DEFAULT")) {
values.add(null);
} else {
values.add(readExpression());
}
} while (readIfMore(false));
}
command.addRow(values.toArray(new Expression[0]));
} while (readIf(",")); } while (readIf(","));
} else { } else {
command.setQuery(parseSelect()); command.setQuery(parseSelect());
...@@ -1334,17 +1338,7 @@ public class Parser { ...@@ -1334,17 +1338,7 @@ public class Parser {
} else if (readIf("VALUES")) { } else if (readIf("VALUES")) {
read("("); read("(");
do { do {
ArrayList<Expression> values = Utils.newSmallArrayList(); command.addRow(parseValuesForInsert());
if (!readIf(")")) {
do {
if (readIf("DEFAULT")) {
values.add(null);
} else {
values.add(readExpression());
}
} while (readIfMore(false));
}
command.addRow(values.toArray(new Expression[0]));
// the following condition will allow (..),; and (..); // the following condition will allow (..),; and (..);
} while (readIf(",") && readIf("(")); } while (readIf(",") && readIf("("));
} else if (readIf("SET")) { } else if (readIf("SET")) {
...@@ -1392,18 +1386,8 @@ public class Parser { ...@@ -1392,18 +1386,8 @@ public class Parser {
} }
if (readIf("VALUES")) { if (readIf("VALUES")) {
do { do {
ArrayList<Expression> values = Utils.newSmallArrayList();
read("("); read("(");
if (!readIf(")")) { command.addRow(parseValuesForInsert());
do {
if (readIf("DEFAULT")) {
values.add(null);
} else {
values.add(readExpression());
}
} while (readIfMore(false));
}
command.addRow(values.toArray(new Expression[0]));
} while (readIf(",")); } while (readIf(","));
} else { } else {
command.setQuery(parseSelect()); command.setQuery(parseSelect());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论