提交 e56155b3 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Move out identical code parts from if-else blocks in Parser.readJoin()

上级 2b25b90f
...@@ -1722,66 +1722,56 @@ public class Parser { ...@@ -1722,66 +1722,56 @@ public class Parser {
boolean joined = false; boolean joined = false;
TableFilter last = top; TableFilter last = top;
while (true) { while (true) {
TableFilter join;
if (readIf("RIGHT")) { if (readIf("RIGHT")) {
readIf("OUTER"); readIf("OUTER");
read("JOIN"); read("JOIN");
joined = true;
// the right hand side is the 'inner' table usually // the right hand side is the 'inner' table usually
TableFilter newTop = readTableFilter(fromOuter); join = readTableFilter(fromOuter);
newTop = readJoin(newTop, command, nested, true); join = readJoin(join, command, nested, true);
Expression on = null; Expression on = null;
if (readIf("ON")) { if (readIf("ON")) {
on = readExpression(); on = readExpression();
} }
top = getNested(top); top = getNested(top);
newTop.addJoin(top, true, false, on); join.addJoin(top, true, false, on);
top = newTop; top = join;
last = newTop;
} else if (readIf("LEFT")) { } else if (readIf("LEFT")) {
readIf("OUTER"); readIf("OUTER");
read("JOIN"); read("JOIN");
joined = true; join = readTableFilter(true);
TableFilter join = readTableFilter(true);
join = readJoin(join, command, true, true); join = readJoin(join, command, true, true);
Expression on = null; Expression on = null;
if (readIf("ON")) { if (readIf("ON")) {
on = readExpression(); on = readExpression();
} }
top.addJoin(join, true, false, on); top.addJoin(join, true, false, on);
last = join;
} else if (readIf("FULL")) { } else if (readIf("FULL")) {
throw getSyntaxError(); throw getSyntaxError();
} else if (readIf("INNER")) { } else if (readIf("INNER")) {
read("JOIN"); read("JOIN");
joined = true; join = readTableFilter(fromOuter);
TableFilter join = readTableFilter(fromOuter);
top = readJoin(top, command, false, false); top = readJoin(top, command, false, false);
Expression on = null; Expression on = null;
if (readIf("ON")) { if (readIf("ON")) {
on = readExpression(); on = readExpression();
} }
top.addJoin(join, false, false, on); top.addJoin(join, false, false, on);
last = join;
} else if (readIf("JOIN")) { } else if (readIf("JOIN")) {
joined = true; join = readTableFilter(fromOuter);
TableFilter join = readTableFilter(fromOuter);
top = readJoin(top, command, false, false); top = readJoin(top, command, false, false);
Expression on = null; Expression on = null;
if (readIf("ON")) { if (readIf("ON")) {
on = readExpression(); on = readExpression();
} }
top.addJoin(join, false, false, on); top.addJoin(join, false, false, on);
last = join;
} else if (readIf("CROSS")) { } else if (readIf("CROSS")) {
read("JOIN"); read("JOIN");
joined = true; join = readTableFilter(fromOuter);
TableFilter join = readTableFilter(fromOuter);
top.addJoin(join, false, false, null); top.addJoin(join, false, false, null);
last = join;
} else if (readIf("NATURAL")) { } else if (readIf("NATURAL")) {
read("JOIN"); read("JOIN");
joined = true; join = readTableFilter(fromOuter);
TableFilter join = readTableFilter(fromOuter);
Column[] tableCols = last.getTable().getColumns(); Column[] tableCols = last.getTable().getColumns();
Column[] joinCols = join.getTable().getColumns(); Column[] joinCols = join.getTable().getColumns();
String tableSchema = last.getTable().getSchema().getName(); String tableSchema = last.getTable().getSchema().getName();
...@@ -1811,10 +1801,11 @@ public class Parser { ...@@ -1811,10 +1801,11 @@ public class Parser {
} }
} }
top.addJoin(join, false, nested, on); top.addJoin(join, false, nested, on);
last = join;
} else { } else {
break; break;
} }
joined = true;
last = join;
} }
if (nested && joined) { if (nested && joined) {
top = getNested(top); top = getNested(top);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论