From 00d715e7a5925eb03b587983de44cc7c0102fbdc Mon Sep 17 00:00:00 2001 From: lukaseder Date: Thu, 3 Jan 2019 16:09:32 +0100 Subject: [PATCH] git commit -m --- .../resources/org/jooq/web/grammar-3.12.txt | 18 ++- .../main/java/org/jooq/impl/ParserImpl.java | 114 +++++++++++++++++- 2 files changed, 128 insertions(+), 4 deletions(-) diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.12.txt b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.12.txt index e01ce30338..99a0c2b94b 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.12.txt +++ b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.12.txt @@ -45,14 +45,30 @@ dmlStatement = proceduralStatement = query +| declareStatement +| assignmentStatement | nullStatement ; blockStatement = - [ 'EXECUTE BLOCK AS' ] 'BEGIN' proceduralStatement ';' { proceduralStatement ';' } 'END' + [ 'EXECUTE BLOCK AS' | 'DECLARE' ( declarationStatement ';' )+ ] + 'BEGIN' ( proceduralStatement ';' )+ 'END' | 'DO' stringLiteral ; +declarationStatement = + identifier [ 'CONSTANT' ] dataType [ ( '=' | ':=' | 'DEFAULT' ) field ] +; + +declareStatement = + 'DECLARE' identifier dataType [ '=' field ] +; + +assignmentStatement = + 'SET' identifier '=' field +| identifier ':=' field +; + nullStatement = 'NULL' ; diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index c2272e30e4..dc5381acab 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -94,6 +94,7 @@ import static org.jooq.impl.DSL.day; import static org.jooq.impl.DSL.dayOfWeek; import static org.jooq.impl.DSL.dayOfYear; import static org.jooq.impl.DSL.decade; +import static org.jooq.impl.DSL.declare; import static org.jooq.impl.DSL.defaultValue; import static org.jooq.impl.DSL.deg; import static org.jooq.impl.DSL.denseRank; @@ -253,6 +254,7 @@ import static org.jooq.impl.DSL.unique; import static org.jooq.impl.DSL.unnest; import static org.jooq.impl.DSL.user; import static org.jooq.impl.DSL.values; +import static org.jooq.impl.DSL.var; import static org.jooq.impl.DSL.varPop; import static org.jooq.impl.DSL.varSamp; import static org.jooq.impl.DSL.week; @@ -336,6 +338,7 @@ import org.jooq.DDLQuery; import org.jooq.DSLContext; import org.jooq.DataType; import org.jooq.DatePart; +// ... import org.jooq.Delete; import org.jooq.DeleteLimitStep; import org.jooq.DeleteOrderByStep; @@ -723,7 +726,9 @@ final class ParserImpl implements Parser { case 'd': case 'D': - if (!parseResultQuery && (peekKeyword(ctx, "DELETE") || peekKeyword(ctx, "DEL"))) + if (!parseResultQuery && peekKeyword(ctx, "DECLARE") && ctx.requireProEdition()) + return parseBlock(ctx); + else if (!parseResultQuery && (peekKeyword(ctx, "DELETE") || peekKeyword(ctx, "DEL"))) return parseDelete(ctx, null); else if (!parseResultQuery && peekKeyword(ctx, "DROP")) return parseDrop(ctx); @@ -2179,10 +2184,18 @@ final class ParserImpl implements Parser { } private static final Block parseBlock(ParserContext ctx) { - parseKeywordIf(ctx, "EXECUTE BLOCK AS"); + List statements = new ArrayList(); + + if (parseKeywordIf(ctx, "DECLARE") && ctx.requireProEdition()) + + + + ; + else + parseKeywordIf(ctx, "EXECUTE BLOCK AS"); + parseKeyword(ctx, "BEGIN"); - List statements = new ArrayList(); for (;;) { Statement statement = parseStatement(ctx); statements.add(statement); @@ -2198,6 +2211,20 @@ final class ParserImpl implements Parser { return ctx.dsl.begin(statements); } + + + + + + + + + + + + + + private static final Block parseDo(ParserContext ctx) { parseKeyword(ctx, "DO"); String block = parseStringLiteral(ctx); @@ -2206,14 +2233,40 @@ final class ParserImpl implements Parser { private static final Statement parseStatement(ParserContext ctx) { switch (ctx.character()) { + case 'd': + case 'D': + if (peekKeyword(ctx, "DECLARE") && ctx.requireProEdition()) + + + + ; + + break; + case 'n': case 'N': if (peekKeyword(ctx, "NULL")) return parseNullStatement(ctx); break; + + case 's': + case 'S': + if (peekKeyword(ctx, "SET") && ctx.requireProEdition()) + + + + ; + + break; } + + + + + + return parseQuery(ctx, false, false); } @@ -2226,6 +2279,61 @@ final class ParserImpl implements Parser { return new NullStatement(); } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // ----------------------------------------------------------------------------------------------------------------- // Statement clause parsing // -----------------------------------------------------------------------------------------------------------------