forked from JSQLParser/JSqlParser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeature.java
More file actions
843 lines (777 loc) · 16.5 KB
/
Feature.java
File metadata and controls
843 lines (777 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2020 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.parser.feature;
import net.sf.jsqlparser.expression.Function;
import net.sf.jsqlparser.expression.JdbcNamedParameter;
import net.sf.jsqlparser.expression.JdbcParameter;
import net.sf.jsqlparser.expression.OracleHierarchicalExpression;
import net.sf.jsqlparser.expression.OracleHint;
import net.sf.jsqlparser.expression.operators.relational.SupportsOldOracleJoinSyntax;
import net.sf.jsqlparser.statement.Block;
import net.sf.jsqlparser.statement.Commit;
import net.sf.jsqlparser.statement.CreateFunctionalStatement;
import net.sf.jsqlparser.statement.DeclareStatement;
import net.sf.jsqlparser.statement.DescribeStatement;
import net.sf.jsqlparser.statement.ExplainStatement;
import net.sf.jsqlparser.statement.ResetStatement;
import net.sf.jsqlparser.statement.SetStatement;
import net.sf.jsqlparser.statement.ShowColumnsStatement;
import net.sf.jsqlparser.statement.ShowStatement;
import net.sf.jsqlparser.statement.UseStatement;
import net.sf.jsqlparser.statement.alter.Alter;
import net.sf.jsqlparser.statement.alter.sequence.AlterSequence;
import net.sf.jsqlparser.statement.analyze.Analyze;
import net.sf.jsqlparser.statement.comment.Comment;
import net.sf.jsqlparser.statement.create.function.CreateFunction;
import net.sf.jsqlparser.statement.create.index.CreateIndex;
import net.sf.jsqlparser.statement.create.procedure.CreateProcedure;
import net.sf.jsqlparser.statement.create.schema.CreateSchema;
import net.sf.jsqlparser.statement.create.sequence.CreateSequence;
import net.sf.jsqlparser.statement.create.synonym.CreateSynonym;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import net.sf.jsqlparser.statement.create.view.AlterView;
import net.sf.jsqlparser.statement.create.view.CreateView;
import net.sf.jsqlparser.statement.delete.Delete;
import net.sf.jsqlparser.statement.drop.Drop;
import net.sf.jsqlparser.statement.execute.Execute;
import net.sf.jsqlparser.statement.grant.Grant;
import net.sf.jsqlparser.statement.merge.Merge;
import net.sf.jsqlparser.statement.refresh.RefreshMaterializedViewStatement;
import net.sf.jsqlparser.statement.select.Fetch;
import net.sf.jsqlparser.statement.select.First;
import net.sf.jsqlparser.statement.select.KSQLWindow;
import net.sf.jsqlparser.statement.select.Limit;
import net.sf.jsqlparser.statement.select.Offset;
import net.sf.jsqlparser.statement.select.OptimizeFor;
import net.sf.jsqlparser.statement.select.Pivot;
import net.sf.jsqlparser.statement.select.PivotXml;
import net.sf.jsqlparser.statement.select.Skip;
import net.sf.jsqlparser.statement.select.TableFunction;
import net.sf.jsqlparser.statement.select.Top;
import net.sf.jsqlparser.statement.select.UnPivot;
import net.sf.jsqlparser.statement.show.*;
import net.sf.jsqlparser.statement.truncate.Truncate;
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.upsert.Upsert;
public enum Feature {
// SQL KEYWORD FEATURES
/**
* "SELECT"
*/
select,
/**
* "GROUP BY"
*/
selectGroupBy,
/**
* "GROUPING SETS"
*/
selectGroupByGroupingSets,
/**
* "HAVING"
*/
selectHaving,
/**
* "INTO table(, table)*"
*/
selectInto,
/**
* @see Limit
*/
limit,
/**
* "LIMIT NULL"
*
* @see Limit#isLimitNull()
*/
limitNull,
/**
* "LIMIT ALL"
*
* @see Limit#isLimitAll()
*/
limitAll,
/**
* "LIMIT offset, limit"
*
* @see Limit#getOffset()
*/
limitOffset,
/**
* "OFFSET offset"
*
* @see Offset
*/
offset,
/**
* "OFFSET offset param" where param is ROW | ROWS
*
* @see Offset#getOffsetParam()
*/
offsetParam,
/**
* @see Fetch
*/
fetch,
/**
* "FETCH FIRST row_count (ROW | ROWS) ONLY"
*
* @see Fetch#isFetchParamFirst()
*/
fetchFirst,
/**
* "FETCH NEXT row_count (ROW | ROWS) ONLY" if not {@link #fetchFirst}
*
* @see Fetch#isFetchParamFirst()
*/
fetchNext,
/**
* "JOIN"
*/
join,
/**
* join tables by ", OUTER" placing the join specification in WHERE-clause
*/
joinOuterSimple,
/**
* join tables by "," placing the join specification in WHERE-clause
*/
joinSimple,
/**
* "RIGHT" join
*/
joinRight,
/**
* "NATURAL" join
*/
joinNatural,
/**
* "FULL" join
*/
joinFull,
/**
* "LEFT" join
*/
joinLeft,
/**
* "CROSS" join
*/
joinCross,
/**
* "OUTER" join
*/
joinOuter,
/**
* "SEMI" join
*/
joinSemi,
/**
* "INNER" join
*/
joinInner,
/**
* "STRAIGHT_JOIN" join
*/
joinStraight,
/**
* "APPLY" join
*/
joinApply,
joinWindow, joinUsingColumns,
/**
* "SKIP variable" | "SKIP ?" | "SKIP rowCount"
*
* @see Skip
*/
skip,
/**
* "FIRST" \?|[0-9]+|variable or "LIMIT" \?|[0-9]+|variable
*
* @see First
*/
first,
/**
* "TOP" ? "PERCENT"
*
* @see Top
*/
top,
/**
* "OPTIMIZE FOR rowCount ROWS"
*
* @see OptimizeFor
*/
optimizeFor,
/**
* "UNIQUE" keyword
*/
selectUnique,
/**
* "DISTINCT" keyword
*/
distinct,
/**
* "DISTINCT ON (col1, ...)"
*/
distinctOn,
/**
* "ORDER BY"
*/
orderBy,
/**
* "ORDER BY expression [ NULLS { FIRST | LAST } ]"
*/
orderByNullOrdering,
/**
* "FOR UPDATE"
*/
selectForUpdate,
/**
* "FOR SHARE"
*/
selectForShare,
/**
* "FOR KEY SHARE"
*/
selectForKeyShare,
/**
* "NO KEY UPDATE"
*/
selectForNoKeyUpdate,
/**
* "FOR UPDATE OF table"
*/
selectForUpdateOfTable,
/**
* "FOR UPDATE WAIT timeout"
*/
selectForUpdateWait,
/**
* "FOR UPDATE NOWAIT"
*/
selectForUpdateNoWait,
/**
* "FOR UPDATE SKIP LOCKED"
*/
selectForUpdateSkipLocked,
/**
* SQL "INSERT" statement is allowed
*/
insert,
/**
* "INSERT .. SELECT"
*/
insertFromSelect,
/**
* "LOW_PRIORITY | DELAYED | HIGH_PRIORITY | IGNORE"
*/
insertModifierPriority,
/**
* "IGNORE"
*/
insertModifierIgnore,
/**
* "INSERT .. SET"
*/
insertUseSet,
/**
* "ON DUPLICATE KEY UPDATE"
*/
insertUseDuplicateKeyUpdate,
/**
* "RETURNING *"
*/
insertReturningAll,
/**
* "RETURNING expr(, expr)*"
*
* @see net.sf.jsqlparser.expression.operators.relational.ExpressionList
*/
insertReturningExpressionList,
/**
* "VALUES"
*/
insertValues,
/**
* @see net.sf.jsqlparser.statement.select.Values
*/
values,
/**
* SQL "TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]“
*/
tableStatement,
/**
* SQL "UPDATE" statement is allowed
*
* @see Update
*/
update,
/**
* "UPDATE table1 SET ... FROM table2
*/
updateFrom,
/**
* "UPDATE table1, table2 ..."
*/
updateJoins,
/**
* UPDATE table SET (col, ...) = (SELECT col, ... )"
*/
updateUseSelect, updateOrderBy, updateLimit,
/**
* "RETURNING expr(, expr)*"
*
* @see net.sf.jsqlparser.statement.select.SelectItem
*/
updateReturning,
/**
* SQL "DELETE" statement is allowed
*
* @see Delete
*/
delete,
/**
* "DELETE FROM table1, table1 ..."
*/
deleteJoin,
/**
* "DELETE table1, table1 FROM table ..."
*/
deleteTables,
/**
* "LIMIT row_count"
*/
deleteLimit,
/**
* "ORDER BY ..."
*/
deleteOrderBy,
/**
* "RETURNING expr(, expr)*"
*
* @see net.sf.jsqlparser.statement.select.SelectItem
*/
deleteReturningExpressionList,
/**
* SQL "UPSERT" statement is allowed
*
* @see Upsert
* @see <a href=
* "https://wiki.postgresql.org/wiki/UPSERT">https://wiki.postgresql.org/wiki/UPSERT</a>
*/
upsert,
/**
* SQL "MERGE" statement is allowed
*
* @see Merge
*/
merge,
/**
* SQL "ALTER" statement is allowed
*
* @see Alter
*/
alterTable,
/**
* SQL "ALTER SEQUENCE" statement is allowed
*
* @see AlterSequence
*/
alterSequence,
/**
* SQL "ALTER VIEW" statement is allowed
*
* @see AlterView
*/
alterView,
/**
* SQL "REFRESH MATERIALIZED VIEW" statement is allowed
*
* @see RefreshMaterializedViewStatement
*/
refreshMaterializedView, refreshMaterializedWithDataView, refreshMaterializedWithNoDataView,
/**
* SQL "REPLACE VIEW" statement is allowed
*
* @see AlterView
*/
alterViewReplace,
/**
* SQL "ALTER INDEX" statement is allowed
*/
alterIndex,
/**
* SQL "ANALYZE" statement is allowed
*
* @see Analyze
*/
analyze,
/**
* SQL "TRUNCATE" statement is allowed
*
* @see Truncate
*/
truncate,
/**
* SQL "CALL|EXEC|EXECUTE" stored procedure is allowed
*
* @see Execute
*/
execute, executeExec, executeCall, executeExecute,
/**
* SQL "EXECUTE" statement is allowed
*/
executeStatement,
/**
* SQL "EXECUTE IMMEDIATE" statement is allowed
*/
executeStatementImmediate,
executeUsing,
/**
* SQL "REPLACE" statement is allowed
*/
@Deprecated
replace,
/**
* SQL "DROP" statement is allowed
*
* @see Drop
*/
drop, dropTable, dropIndex, dropView, dropSchema, dropSequence, dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists,
/**
* SQL "CREATE SCHEMA" statement is allowed
*
* @see CreateSchema
*/
createSchema,
/**
* SQL "CREATE VIEW" statement is allowed
*
* @see CreateView
*/
createView,
/**
* "CREATE FORCE VIEW"
*/
createViewForce,
/**
* "CREATE TEMPORARAY VIEW"
*/
createViewTemporary,
/**
* "CREATE OR REPLACE VIEW"
*/
createOrReplaceView,
/**
* SQL "CREATE MATERIALIZED VIEW" statement is allowed
*/
createViewMaterialized,
/**
* SQL "CREATE VIEW(x comment 'x', y comment 'y') comment 'view'" statement is allowed
*/
createViewWithComment,
/**
* SQL "CREATE TABLE" statement is allowed
*
* @see CreateTable
*/
createTable,
/**
* "CREATE GLOBAL UNLOGGED"
*/
createTableUnlogged,
/**
* i.e. "CREATE GLOBAL TEMPORARY TABLE", "CREATE SHARDED TABLE"
*/
createTableCreateOptionStrings,
/**
* i.e. "ENGINE = InnoDB AUTO_INCREMENT = 8761 DEFAULT CHARSET = utf8"
*/
createTableTableOptionStrings,
/**
* "CREATE TABLE IF NOT EXISTS table"
*/
createTableIfNotExists,
/**
* " ROW MOVEMENT"
*/
createTableRowMovement,
/**
* "CREATE TABLE (colspec) SELECT ...
*/
createTableFromSelect,
/**
* SQL "CREATE INDEX" statement is allowed
*
* @see CreateIndex
*/
createIndex,
/**
* SQL "CREATE SEQUENCE" statement is allowed
*
* @see CreateSequence
*/
createSequence,
/**
* SQL "CREATE SYNONYM" statement is allowed
*
* @see CreateSynonym
*/
createSynonym,
/**
* SQL "CREATE TRIGGER" statement is allowed
*/
createTrigger,
/**
* SQL "COMMIT" statement is allowed
*
* @see Commit
*/
commit,
/**
* SQL "COMMENT ON" statement is allowed
*
* @see Comment
*/
comment,
/**
* "COMMENT ON table"
*/
commentOnTable,
/**
* "COMMENT ON column"
*/
commentOnColumn,
/**
* "COMMENT ON view"
*/
commentOnView,
/**
* SQL "DESCRIBE" statement is allowed
*
* @see DescribeStatement
*/
describe,
/**
* SQL "DESC" statement is allowed
*
* @see DescribeStatement
*/
desc,
/**
* SQL "EXPLAIN" statement is allowed
*
* @see ExplainStatement
*/
explain,
/**
* @see ShowStatement
*/
show,
/**
* @see ShowTablesStatement
*/
showTables,
/**
* @see ShowColumnsStatement
*/
showColumns,
/**
* @see ShowIndexStatement
*/
showIndex,
/**
* @see UseStatement
*/
use,
/**
* @see Grant
*/
grant,
/**
* @see Function
*/
function,
/**
* @see CreateFunction
*/
createFunction,
/**
* @see CreateProcedure
*/
createProcedure,
/**
* @see CreateFunctionalStatement
*/
functionalStatement,
/**
* SQL block starting with "BEGIN" and ends with "END" statement is allowed
*
* @see Block
*/
block,
/**
* @see DeclareStatement
*/
declare,
/**
* @see SetStatement
*/
set,
/**
* @see ResetStatement
*/
reset,
/**
* @see Pivot
*/
pivot,
/**
* @see UnPivot
*/
unpivot,
/**
* @see PivotXml
*/
pivotXml,
setOperation, setOperationUnion, setOperationIntersect, setOperationExcept, setOperationMinus,
/**
* "WITH name query"
*/
withItem, withItemRecursive,
lateralSubSelect,
/**
* @see net.sf.jsqlparser.statement.select.Values
*/
valuesList,
/**
* @see TableFunction
*/
tableFunction,
// JDBC
/**
* @see JdbcParameter
*/
jdbcParameter,
/**
* @see JdbcNamedParameter
*/
jdbcNamedParameter,
// EXPRESSIONS
/**
* "LIKE"
*/
exprLike,
/**
* "SIMILAR TO"
*/
exprSimilarTo,
// VENDOR SPECIFIC SYNTAX FEATURES
/**
* @see KSQLWindow
*/
kSqlWindow,
// ORACLE
/**
* allows old oracle join syntax (+)
*
* @see SupportsOldOracleJoinSyntax
*/
oracleOldJoinSyntax,
/**
* allows oracle prior position
*
* @see SupportsOldOracleJoinSyntax
*/
oraclePriorPosition,
/**
* @see OracleHint
*/
oracleHint,
/**
* oracle SQL "CONNECT BY"
*
* @see OracleHierarchicalExpression
*/
oracleHierarchicalExpression, oracleOrderBySiblings,
// MYSQL
mySqlHintStraightJoin, mysqlSqlCacheFlag, mysqlCalcFoundRows,
// SQLSERVER
/**
* "FOR XML PATH(...)"
*/
selectForXmlPath,
/**
* allows square brackets for names, disabled by default
*/
allowSquareBracketQuotation(false),
/**
* allow parsing of RDBMS specific syntax by switching off SQL Standard Compliant Syntax
*/
allowPostgresSpecificSyntax(false),
// PERFORMANCE
/**
* allows complex expression parameters or named parameters for functions will be switched off,
* when deep nesting of functions is detected
*/
allowComplexParsing(true),
/**
* allows passing through Unsupported Statements as a plain List of Tokens needs to be switched
* off, when VALIDATING statements or parsing blocks
*/
allowUnsupportedStatements(false),
timeOut(8000),
/**
* allows Backslash '\' as Escape Character
*/
allowBackslashEscapeCharacter(false),
/**
* allows sub selects without parentheses, e.g. `select * from dual where 1 = select 1`
*/
allowUnparenthesizedSubSelects(false),
/**
* maximum nesting depth for trying complex parsing, can bet set to -1 to ignore
*/
allowedNestingDepth(10),
dialect(null),
/**
* "IMPORT"
*/
imprt,
/**
* "EXPORT"
*/
export,
;
private final Object value;
private final boolean configurable;
/**
* a feature which can't configured within the parser
*/
Feature() {
this.value = null;
this.configurable = false;
}
/**
* a feature which can be configured by {@link FeatureConfiguration}
*
* @param value The Value Object of the Parameter.
*/
Feature(Object value) {
this.value = value;
this.configurable = true;
}
public Object getDefaultValue() {
return value;
}
public boolean isConfigurable() {
return configurable;
}
}