From 827865a9734a8a528d4c79ee0b51a7ecac4132ca Mon Sep 17 00:00:00 2001 From: Serge Rider Date: Mon, 30 Dec 2024 17:26:51 +0100 Subject: [PATCH] dbeaver/pro#3911 AI and SQL control commands (#3166) * dbeaver/pro#3911 AI and SQL control commands * dbeaver/pro#3911 AI and SQL control commands --------- Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> --- .../io/cloudbeaver/service/sql/WebSQLProcessor.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLProcessor.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLProcessor.java index 9c5290b879..d0f55ca283 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLProcessor.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLProcessor.java @@ -200,10 +200,15 @@ public WebSQLExecuteInfo processQuery( SQLScriptElement element = SQLScriptParser.extractActiveQuery(parserContext, 0, sql.length()); if (element instanceof SQLControlCommand command) { - dataContainer.getScriptContext().executeControlCommand(command); - WebSQLQueryResults stats = new WebSQLQueryResults(webSession, dataFormat); - executeInfo.setResults(new WebSQLQueryResults[]{stats}); - } else if (element instanceof SQLQuery sqlQuery) { + SQLControlResult controlResult = dataContainer.getScriptContext().executeControlCommand(monitor, command); + if (controlResult.getTransformed() != null) { + element = controlResult.getTransformed(); + } else { + WebSQLQueryResults stats = new WebSQLQueryResults(webSession, dataFormat); + executeInfo.setResults(new WebSQLQueryResults[]{stats}); + } + } + if (element instanceof SQLQuery sqlQuery) { DBExecUtils.tryExecuteRecover(monitor, connection.getDataSource(), param -> { try (DBCSession session = context.openSession(monitor, resolveQueryPurpose(dataFilter), "Execute SQL")) { AbstractExecutionSource source = new AbstractExecutionSource(