@Override public void executeStart(ExecuteContext ctx) { ctx.data("org.jooq.meta.AbstractDatabase.watch", new StopWatch()); }
private final <U> void fetchOutParameter(ExecuteContext ctx, Parameter<U> parameter) throws SQLException { { DefaultBindingGetStatementContext<U> out = new DefaultBindingGetStatementContext<U>( ctx.configuration(), ctx.data(), (CallableStatement) ctx.statement(), resultIndexes.get(parameter) ); parameter.getBinding().get(out); outValues.put(parameter, out.value()); } }
CursorImpl(ExecuteContext ctx, ExecuteListener listener, Field<?>[] fields, int[] internIndexes, boolean keepStatement, boolean keepResultSet, Class<? extends R> type, int maxRows) { super(ctx.configuration(), new Fields<R>(fields)); this.ctx = ctx; this.listener = (listener != null ? listener : ExecuteListeners.get(ctx)); this.cursorFields = fields; this.factory = recordFactory(type, fields); this.keepStatement = keepStatement; this.keepResultSet = keepResultSet; this.rs = new CursorResultSet(); this.rsContext = new DefaultBindingGetResultSetContext<Object>(ctx.configuration(), ctx.data(), rs, 0); this.maxRows = maxRows; this.lockRowsForUpdate = TRUE.equals(ctx.data(DATA_LOCK_ROWS_FOR_UPDATE)); if (internIndexes != null) { this.intern = new boolean[fields.length]; for (int i : internIndexes) intern[i] = true; } else this.intern = null; }
private final void registerOutParameters(ExecuteContext ctx) throws SQLException { Configuration c = ctx.configuration(); Map<Object, Object> data = ctx.data(); CallableStatement statement = (CallableStatement) ctx.statement(); // Register all out / inout parameters according to their position // Note that some RDBMS do not support binding by name very well for (Parameter<?> parameter : getParameters()) if (resultParameter(parameter)) registerOutParameter(c, data, statement, parameter); }
@Override public void executeEnd(ExecuteContext ctx) { int s = getLogSlowQueriesAfterSeconds(); if (s <= 0) return; StopWatch watch = (StopWatch) ctx.data("org.jooq.meta.AbstractDatabase.watch"); if (watch.split() > TimeUnit.SECONDS.toNanos(s)) { watch.splitWarn("Slow SQL"); log.warn( "Slow SQL", "jOOQ Meta executed a slow query (slower than " + s + " seconds, configured by configuration/generator/database/logSlowQueriesAfterSeconds)" + "\n\n" + "Please report this bug here: https://github.com/jOOQ/jOOQ/issues/new\n\n```sql\n" + formatted(ctx.query()) + "```\n", new SQLPerformanceWarning()); } }
ctx.data(DATA_LOCK_ROWS_FOR_UPDATE, true); ctx.statement(ctx.connection().prepareStatement(ctx.sql(), TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE));
private final String getSQL0(ExecuteContext ctx) { if (executePreparedStatements(configuration().settings())) { try { RenderContext render = new DefaultRenderContext(configuration); render.data(DATA_COUNT_BIND_VALUES, true); return render.render(this); } catch (DefaultRenderContext.ForceInlineSignal e) { ctx.data(DATA_FORCE_STATIC_STATEMENT, true); return getSQL(INLINED); } } else { return getSQL(INLINED); } }
ctx.data(DATA_LOCK_ROWS_FOR_UPDATE, true); ctx.statement(ctx.connection().prepareStatement(ctx.sql(), TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE));
private final Rendered getSQL0(ExecuteContext ctx) { Rendered result; // [#3542] [#4977] Some dialects do not support bind values in DDL statements // [#6474] [#6929] Can this be communicated in a leaner way? if (ctx.type() == DDL) { ctx.data(DATA_FORCE_STATIC_STATEMENT, true); DefaultRenderContext render = new DefaultRenderContext(configuration); result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.peekSkipUpdateCounts()); } else if (executePreparedStatements(configuration().settings())) { try { DefaultRenderContext render = new DefaultRenderContext(configuration); render.data(DATA_COUNT_BIND_VALUES, true); result = new Rendered(render.visit(this).render(), render.bindValues(), render.peekSkipUpdateCounts()); } catch (DefaultRenderContext.ForceInlineSignal e) { ctx.data(DATA_FORCE_STATIC_STATEMENT, true); DefaultRenderContext render = new DefaultRenderContext(configuration); result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.peekSkipUpdateCounts()); } } else { DefaultRenderContext render = new DefaultRenderContext(configuration); result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.peekSkipUpdateCounts()); } return result; }
!Boolean.TRUE.equals(ctx.data(DATA_FORCE_STATIC_STATEMENT))) {