1 /*
2  * Copyright 2015-2018 HuntLabs.cn
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 module hunt.sql.dialect.mysql.ast.statement.MySqlFlushStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLName;
20 import hunt.sql.ast.statement.SQLExprTableSource;
21 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
22 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
23 
24 import hunt.sql.ast.SQLObject;
25 
26 import hunt.collection;
27 
28 /**
29  * Created by wenshao on 16/08/2017.
30  */
31 public class MySqlFlushStatement : MySqlStatementImpl {
32 
33     alias accept0 = MySqlStatementImpl.accept0;
34     
35     private bool noWriteToBinlog = false;
36     private bool local = false;
37 
38     private  List!(SQLExprTableSource) tables;
39 
40     private bool withReadLock = false;
41     private bool forExport;
42 
43     private bool binaryLogs;
44     private bool desKeyFile;
45     private bool engineLogs;
46     private bool errorLogs;
47     private bool generalLogs;
48     private bool hots;
49     private bool logs;
50     private bool privileges;
51     private bool optimizerCosts;
52     private bool queryCache;
53     private bool relayLogs;
54     private SQLExpr relayLogsForChannel;
55     private bool slowLogs;
56     private bool status;
57     private bool userResources;
58     private bool tableOption;
59 
60     this()
61     {
62         tables = new ArrayList!(SQLExprTableSource)();
63     }
64 
65     public bool isNoWriteToBinlog() {
66         return noWriteToBinlog;
67     }
68 
69     public void setNoWriteToBinlog(bool noWriteToBinlog) {
70         this.noWriteToBinlog = noWriteToBinlog;
71     }
72 
73     public bool isLocal() {
74         return local;
75     }
76 
77     public void setLocal(bool local) {
78         this.local = local;
79     }
80 
81     public List!(SQLExprTableSource) getTables() {
82         return tables;
83     }
84 
85     public bool isWithReadLock() {
86         return withReadLock;
87     }
88 
89     public void setWithReadLock(bool withReadLock) {
90         this.withReadLock = withReadLock;
91     }
92 
93     public bool isForExport() {
94         return forExport;
95     }
96 
97     public void setForExport(bool forExport) {
98         this.forExport = forExport;
99     }
100 
101     public bool isBinaryLogs() {
102         return binaryLogs;
103     }
104 
105     public void setBinaryLogs(bool binaryLogs) {
106         this.binaryLogs = binaryLogs;
107     }
108 
109     public bool isDesKeyFile() {
110         return desKeyFile;
111     }
112 
113     public void setDesKeyFile(bool desKeyFile) {
114         this.desKeyFile = desKeyFile;
115     }
116 
117     public bool isEngineLogs() {
118         return engineLogs;
119     }
120 
121     public void setEngineLogs(bool engineLogs) {
122         this.engineLogs = engineLogs;
123     }
124 
125     public bool isGeneralLogs() {
126         return generalLogs;
127     }
128 
129     public void setGeneralLogs(bool generalLogs) {
130         this.generalLogs = generalLogs;
131     }
132 
133     public bool isHots() {
134         return hots;
135     }
136 
137     public void setHots(bool hots) {
138         this.hots = hots;
139     }
140 
141     public bool isLogs() {
142         return logs;
143     }
144 
145     public void setLogs(bool logs) {
146         this.logs = logs;
147     }
148 
149     public bool isPrivileges() {
150         return privileges;
151     }
152 
153     public void setPrivileges(bool privileges) {
154         this.privileges = privileges;
155     }
156 
157     public bool isOptimizerCosts() {
158         return optimizerCosts;
159     }
160 
161     public void setOptimizerCosts(bool optimizerCosts) {
162         this.optimizerCosts = optimizerCosts;
163     }
164 
165     public bool isQueryCache() {
166         return queryCache;
167     }
168 
169     public void setQueryCache(bool queryCache) {
170         this.queryCache = queryCache;
171     }
172 
173     public bool isRelayLogs() {
174         return relayLogs;
175     }
176 
177     public void setRelayLogs(bool relayLogs) {
178         this.relayLogs = relayLogs;
179     }
180 
181     public SQLExpr getRelayLogsForChannel() {
182         return relayLogsForChannel;
183     }
184 
185     public void setRelayLogsForChannel(SQLExpr relayLogsForChannel) {
186         this.relayLogsForChannel = relayLogsForChannel;
187     }
188 
189     public bool isSlowLogs() {
190         return slowLogs;
191     }
192 
193     public void setSlowLogs(bool showLogs) {
194         this.slowLogs = showLogs;
195     }
196 
197     public bool isStatus() {
198         return status;
199     }
200 
201     public void setStatus(bool status) {
202         this.status = status;
203     }
204 
205     public bool isUserResources() {
206         return userResources;
207     }
208 
209     public void setUserResources(bool userResources) {
210         this.userResources = userResources;
211     }
212 
213     public bool isErrorLogs() {
214         return errorLogs;
215     }
216 
217     public void setErrorLogs(bool errorLogs) {
218         this.errorLogs = errorLogs;
219     }
220 
221     public bool isTableOption() {
222         return tableOption;
223     }
224 
225     public void setTableOption(bool tableOption) {
226         this.tableOption = tableOption;
227     }
228 
229     override public void accept0(MySqlASTVisitor visitor) {
230         if (visitor.visit(this)) {
231             acceptChild!SQLExprTableSource(visitor, tables);
232             acceptChild(visitor, relayLogsForChannel);
233         }
234         visitor.endVisit(this);
235     }
236 
237     public void addTable(SQLName name) {
238         if (name is null) {
239             return;
240         }
241         this.addTable(new SQLExprTableSource(name));
242     }
243 
244     public void addTable(SQLExprTableSource table) {
245         if (table is null) {
246             return;
247         }
248         table.setParent(this);
249         this.tables.add(table);
250     }
251 }