[#6475] Added support for DB2
This commit is contained in:
parent
f805586ff2
commit
ef6b165178
@ -79,7 +79,7 @@ declarationStatement =
|
||||
;
|
||||
|
||||
declareStatement =
|
||||
'DECLARE' identifier dataType [ '=' field ]
|
||||
'DECLARE' identifier dataType [ ( '=' | 'DEFAULT' ) field ]
|
||||
;
|
||||
|
||||
assignmentStatement =
|
||||
@ -91,7 +91,7 @@ ifStatement =
|
||||
'IF' condition
|
||||
(
|
||||
'THEN' proceduralStatements
|
||||
[ 'ELSIF' condition 'THEN' proceduralStatements ]
|
||||
[ ( 'ELSIF' | 'ELSEIF' ) condition 'THEN' proceduralStatements ]
|
||||
[ 'ELSE' proceduralStatements ]
|
||||
'END IF'
|
||||
) | (
|
||||
@ -110,7 +110,7 @@ forStatement =
|
||||
;
|
||||
|
||||
whileStatement =
|
||||
'WHILE' condition loopStatement
|
||||
'WHILE' condition ( loopStatement | 'DO' proceduralStatements 'END WHILE' )
|
||||
;
|
||||
|
||||
gotoStatement =
|
||||
@ -118,11 +118,11 @@ gotoStatement =
|
||||
;
|
||||
|
||||
continueStatement =
|
||||
'CONTINUE' [ identifier ] [ 'WHEN' condition ]
|
||||
( 'CONTINUE' | 'ITERATE' ) [ identifier ] [ 'WHEN' condition ]
|
||||
;
|
||||
|
||||
exitStatement =
|
||||
'EXIT' [ identifier ] [ 'WHEN' condition ]
|
||||
( 'EXIT' | 'LEAVE' ) [ identifier ] [ 'WHEN' condition ]
|
||||
;
|
||||
|
||||
nullStatement = 'NULL'
|
||||
|
||||
@ -88,6 +88,7 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ import static org.jooq.impl.Keywords.K_EXECUTE_STATEMENT;
|
||||
import static org.jooq.impl.Keywords.K_NOT;
|
||||
import static org.jooq.impl.Tools.decrement;
|
||||
import static org.jooq.impl.Tools.increment;
|
||||
import static org.jooq.impl.Tools.toplevel;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_FORCE_STATIC_STATEMENT;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_BLOCK_NESTING;
|
||||
|
||||
@ -93,6 +94,8 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final Collection<? extends Statement> statements;
|
||||
private final boolean alwaysWrapInBeginEnd;
|
||||
|
||||
@ -161,16 +164,6 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default: {
|
||||
increment(ctx.data(), DATA_BLOCK_NESTING);
|
||||
accept0(ctx);
|
||||
@ -188,11 +181,11 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
;
|
||||
|
||||
accept1(ctx, new ArrayList<Statement>(statements), wrapInBeginEnd);
|
||||
acceptDeclarations(ctx, new ArrayList<Statement>(statements), wrapInBeginEnd);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static final void accept1(Context<?> ctx, List<Statement> statements, boolean wrapInBeginEnd) {
|
||||
private static final void acceptDeclarations(Context<?> ctx, List<Statement> statements, boolean wrapInBeginEnd) {
|
||||
|
||||
|
||||
|
||||
@ -234,15 +227,41 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
accept2(ctx, statements, wrapInBeginEnd);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
acceptNonDeclarations(ctx, statements, wrapInBeginEnd);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final void semicolonAfterStatement(Context<?> ctx, Statement s) {
|
||||
if (!(s instanceof Block))
|
||||
if (s instanceof Block)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
ctx.sql(';');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql(';');
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +274,7 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
private static final void accept2(Context<?> ctx, List<Statement> statements, boolean wrapInBeginEnd) {
|
||||
private static final void acceptNonDeclarations(Context<?> ctx, List<Statement> statements, boolean wrapInBeginEnd) {
|
||||
if (wrapInBeginEnd) {
|
||||
ctx.visit(K_BEGIN);
|
||||
|
||||
@ -297,6 +316,7 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
|
||||
if (s instanceof NullStatement && !SUPPORTS_NULL_STATEMENT.contains(ctx.family()))
|
||||
continue statementLoop;
|
||||
|
||||
@ -321,14 +341,18 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
}
|
||||
}
|
||||
|
||||
if (wrapInBeginEnd) {
|
||||
ctx.formatIndentEnd()
|
||||
.formatSeparator()
|
||||
.visit(K_END);
|
||||
if (wrapInBeginEnd)
|
||||
end(ctx);
|
||||
}
|
||||
|
||||
switch (ctx.family()) {
|
||||
case FIREBIRD:
|
||||
break;
|
||||
private static final void end(Context<?> ctx) {
|
||||
ctx.formatIndentEnd()
|
||||
.formatSeparator()
|
||||
.visit(K_END);
|
||||
|
||||
switch (ctx.family()) {
|
||||
case FIREBIRD:
|
||||
break;
|
||||
|
||||
|
||||
|
||||
@ -336,9 +360,13 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.sql(';');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.sql(';');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,19 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -101,6 +101,15 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
private static final Pattern NEWLINE = Pattern.compile("[\\n\\r]");
|
||||
private static final Set<String> SQLITE_KEYWORDS;
|
||||
|
||||
private final StringBuilder sql;
|
||||
final StringBuilder sql;
|
||||
private final QueryPartList<Param<?>> bindValues;
|
||||
private int params;
|
||||
private int alias;
|
||||
|
||||
@ -37,6 +37,19 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,6 +37,14 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -118,6 +118,7 @@ final class Keywords {
|
||||
static final Keyword K_DROP_TABLE = keyword("drop table");
|
||||
static final Keyword K_DROP_VIEW = keyword("drop view");
|
||||
static final Keyword K_ELSE = keyword("else");
|
||||
static final Keyword K_ELSEIF = keyword("elseif");
|
||||
static final Keyword K_ELSIF = keyword("elsif");
|
||||
static final Keyword K_END = keyword("end");
|
||||
static final Keyword K_END_CATCH = keyword("end catch");
|
||||
@ -174,10 +175,12 @@ final class Keywords {
|
||||
static final Keyword K_IS = keyword("is");
|
||||
static final Keyword K_IS_NOT_NULL = keyword("is not null");
|
||||
static final Keyword K_IS_NULL = keyword("is null");
|
||||
static final Keyword K_ITERATE = keyword("iterate");
|
||||
static final Keyword K_KEEP = keyword("keep");
|
||||
static final Keyword K_KEY = keyword("key");
|
||||
static final Keyword K_LAST = keyword("last");
|
||||
static final Keyword K_LATERAL = keyword("lateral");
|
||||
static final Keyword K_LEAVE = keyword("leave");
|
||||
static final Keyword K_LEFT_OUTER_JOIN_LATERAL = keyword("left outer join lateral");
|
||||
static final Keyword K_LIKE = keyword("like");
|
||||
static final Keyword K_LIKE_REGEX = keyword("like_regex");
|
||||
|
||||
@ -81,6 +81,7 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -157,6 +157,18 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2382,13 +2382,23 @@ final class ParserImpl implements Parser {
|
||||
|
||||
|
||||
|
||||
;
|
||||
else if (peekKeyword(ctx, "ITERATE") && ctx.requireProEdition())
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'L':
|
||||
if (peekKeyword(ctx, "LOOP") && ctx.requireProEdition())
|
||||
if (peekKeyword(ctx, "LEAVE") && ctx.requireProEdition())
|
||||
|
||||
|
||||
|
||||
;
|
||||
else if (peekKeyword(ctx, "LOOP") && ctx.requireProEdition())
|
||||
|
||||
|
||||
|
||||
@ -2618,6 +2628,13 @@ final class ParserImpl implements Parser {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user