private static final Block parseDo(ParserContext ctx) { parseKeyword(ctx, "DO"); String block = parseStringLiteral(ctx); return (Block) ctx.dsl.parser().parseQuery(block); }
ParsingConnection(Configuration configuration) { super(configuration.connectionProvider().acquire()); this.configuration = configuration; this.ctx = DSL.using(configuration); this.parser = ctx.parser(); }
@SuppressWarnings("deprecation") DiagnosticsConnection(Configuration configuration) { super(configuration.connectionProvider().acquire()); this.configuration = configuration; this.normalisingRenderer = configuration.derive( SettingsTools.clone(configuration.settings()) // Forcing all inline parameters to be indexed helps find opportunities to use bind variables .withParamType(FORCE_INDEXED) // Padding IN lists shows duplicates that arise from arbitrary-length dynamic IN lists .withInListPadding(true) .withInListPadBase(16) ).dsl().renderContext(); this.parser = configuration.dsl().parser(); this.listeners = DiagnosticsListeners.get(configuration); }
private static final Query parseExec(ParserContext ctx) { parseKeyword(ctx, "EXEC"); if (parseKeywordIf(ctx, "SP_RENAME")) { if (parseKeywordIf(ctx, "@OBJNAME")) parse(ctx, '='); Name oldName = ctx.dsl.parser().parseName(parseStringLiteral(ctx)); parse(ctx, ','); if (parseKeywordIf(ctx, "@NEWNAME")) parse(ctx, '='); Name newName = ctx.dsl.parser().parseName(parseStringLiteral(ctx)); String objectType = "TABLE"; if (parseIf(ctx, ',')) { if (parseKeywordIf(ctx, "@OBJTYPE")) parse(ctx, '='); if (!parseKeywordIf(ctx, "NULL")) objectType = parseStringLiteral(ctx); } if ("TABLE".equalsIgnoreCase(objectType)) return ctx.dsl.alterTable(oldName).renameTo(newName.unqualifiedName()); else if ("INDEX".equalsIgnoreCase(objectType)) return ctx.dsl.alterIndex(oldName).renameTo(newName.unqualifiedName()); else if ("COLUMN".equalsIgnoreCase(objectType)) return ctx.dsl.alterTable(oldName.qualifier()).renameColumn(oldName.unqualifiedName()).to(newName.unqualifiedName()); else throw ctx.exception("Unsupported object type: " + objectType); } else { throw ctx.unsupportedClause(); } }
private static final Field<?> parseNextvalCurrvalIf(ParserContext ctx, SequenceMethod method) { if (parseFunctionNameIf(ctx, method.name())) { parse(ctx, '('); Name name = parseNameIf(ctx); Sequence s = name != null ? sequence(name) : sequence(ctx.dsl.parser().parseName(parseStringLiteral(ctx))); parse(ctx, ')'); if (method == SequenceMethod.NEXTVAL) return s.nextval(); else if (method == SequenceMethod.CURRVAL) return s.currval(); else throw ctx.exception("Only NEXTVAL and CURRVAL methods supported"); } return null; }