38
38
import java .util .List ;
39
39
40
40
import net .sf .jsqlparser .statement .SetStatement ;
41
+ import net .sf .jsqlparser .statement .Statement ;
41
42
import net .sf .jsqlparser .statement .StatementVisitor ;
42
43
import net .sf .jsqlparser .statement .Statements ;
43
44
import net .sf .jsqlparser .statement .alter .Alter ;
@@ -58,9 +59,8 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
58
59
private static final String NOT_SUPPORTED_YET = "Not supported yet." ;
59
60
private List <String > tables ;
60
61
/**
61
- * There are special names, that are not table names but are parsed as
62
- * tables. These names are collected here and are not included in the tables
63
- * - names anymore.
62
+ * There are special names, that are not table names but are parsed as tables. These names are
63
+ * collected here and are not included in the tables - names anymore.
64
64
*/
65
65
private List <String > otherItemNames ;
66
66
@@ -70,45 +70,9 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
70
70
* @param delete
71
71
* @return
72
72
*/
73
- public List <String > getTableList (Delete delete ) {
73
+ public List <String > getTableList (Statement statement ) {
74
74
init ();
75
- delete .accept (this );
76
- return tables ;
77
- }
78
-
79
- /**
80
- * Main entry for this Tool class. A list of found tables is returned.
81
- *
82
- * @param insert
83
- * @return
84
- */
85
- public List <String > getTableList (Insert insert ) {
86
- init ();
87
- insert .accept (this );
88
- return tables ;
89
- }
90
-
91
- /**
92
- * Main entry for this Tool class. A list of found tables is returned.
93
- *
94
- * @param replace
95
- * @return
96
- */
97
- public List <String > getTableList (Replace replace ) {
98
- init ();
99
- replace .accept (this );
100
- return tables ;
101
- }
102
-
103
- /**
104
- * Main entry for this Tool class. A list of found tables is returned.
105
- *
106
- * @param select
107
- * @return
108
- */
109
- public List <String > getTableList (Select select ) {
110
- init ();
111
- select .accept (this );
75
+ statement .accept (this );
112
76
return tables ;
113
77
}
114
78
@@ -128,17 +92,6 @@ public void visit(Select select) {
128
92
* @param update
129
93
* @return
130
94
*/
131
- public List <String > getTableList (Update update ) {
132
- init ();
133
- update .accept (this );
134
- return tables ;
135
- }
136
-
137
- public List <String > getTableList (CreateTable create ) {
138
- init ();
139
- create .accept (this );
140
- return tables ;
141
- }
142
95
143
96
public List <String > getTableList (Expression expr ) {
144
97
init ();
@@ -246,7 +199,11 @@ public void visit(GreaterThanEquals greaterThanEquals) {
246
199
247
200
@ Override
248
201
public void visit (InExpression inExpression ) {
249
- inExpression .getLeftExpression ().accept (this );
202
+ if (inExpression .getLeftExpression () != null ) {
203
+ inExpression .getLeftExpression ().accept (this );
204
+ } else if (inExpression .getLeftItemsList () != null ) {
205
+ inExpression .getLeftItemsList ().accept (this );
206
+ }
250
207
inExpression .getRightItemsList ().accept (this );
251
208
}
252
209
@@ -639,7 +596,12 @@ public void visit(HexValue hexValue) {
639
596
640
597
@ Override
641
598
public void visit (Merge merge ) {
642
- throw new UnsupportedOperationException (NOT_SUPPORTED_YET );
599
+ tables .add (merge .getTable ().getName ());
600
+ if (merge .getUsingTable () != null ) {
601
+ merge .getUsingTable ().accept (this );
602
+ } else if (merge .getUsingSelect () != null ) {
603
+ merge .getUsingSelect ().accept ((FromItemVisitor ) this );
604
+ }
643
605
}
644
606
645
607
@ Override
@@ -661,6 +623,6 @@ public void visit(TimeKeyExpression timeKeyExpression) {
661
623
662
624
@ Override
663
625
public void visit (DateTimeLiteralExpression literal ) {
664
-
626
+
665
627
}
666
628
}
0 commit comments