forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement binary format support for SQL clear cursor
- support binary_format parameter on _sql/close - make cursor close response consistent with the query protocol (ie. in ODBC/JDBC/CLI return CBOR response for cursor close - as for query)
- Loading branch information
1 parent
85359f3
commit d6486ab
Showing
12 changed files
with
160 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 84230 | ||
summary: Implement binary format support for SQL clear cursor | ||
area: SQL | ||
type: bug | ||
issues: | ||
- 53359 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...node/src/test/java/org/elasticsearch/xpack/sql/qa/jdbc/single_node/JdbcCloseCursorIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.sql.qa.jdbc.single_node; | ||
|
||
import org.elasticsearch.xpack.sql.qa.jdbc.CloseCursorTestCase; | ||
|
||
public class JdbcCloseCursorIT extends CloseCursorTestCase {} |
60 changes: 60 additions & 0 deletions
60
...in/sql/qa/jdbc/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/CloseCursorTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.sql.qa.jdbc; | ||
|
||
import org.elasticsearch.core.CheckedConsumer; | ||
import org.junit.Before; | ||
|
||
import java.io.IOException; | ||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
public abstract class CloseCursorTestCase extends JdbcIntegrationTestCase { | ||
|
||
@Before | ||
public void initIndex() throws IOException { | ||
index("library", "1", builder -> { builder.field("name", "foo"); }); | ||
index("library", "2", builder -> { builder.field("name", "bar"); }); | ||
index("library", "3", builder -> { builder.field("name", "baz"); }); | ||
} | ||
|
||
public void testCloseCursor() throws SQLException { | ||
doWithQuery("SELECT name FROM library", results -> { | ||
assertTrue(results.next()); | ||
results.close(); // force sending a cursor close since more pages are available | ||
assertTrue(results.isClosed()); | ||
}); | ||
} | ||
|
||
public void testCloseConsumedCursor() throws SQLException { | ||
doWithQuery("SELECT name FROM library", results -> { | ||
for (int i = 0; i < 3; i++) { | ||
assertTrue(results.next()); | ||
} | ||
assertFalse(results.next()); | ||
results.close(); | ||
assertTrue(results.isClosed()); | ||
}); | ||
} | ||
|
||
public void testCloseNoCursor() throws SQLException { | ||
doWithQuery("SELECT name FROM library WHERE name = 'zzz'", results -> { | ||
results.close(); | ||
assertTrue(results.isClosed()); | ||
}); | ||
} | ||
|
||
private void doWithQuery(String query, CheckedConsumer<ResultSet, SQLException> consumer) throws SQLException { | ||
try (Connection connection = createConnection(connectionProperties()); Statement statement = connection.createStatement()) { | ||
statement.setFetchSize(1); | ||
ResultSet results = statement.executeQuery(query); | ||
consumer.accept(results); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters