mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
perf(build): replace quarkus-jdbc extensions with plain JDBC drivers (#3465)
* perf(build): replace quarkus-jdbc extensions with plain JDBC drivers The RDS Data API and Redshift Data API open connections with DriverManager. They never used Agroal, Narayana or the datasource layer that quarkus-jdbc-mysql and quarkus-jdbc-postgresql pull in. Depend on mysql-connector-j and postgresql directly and hand-supply the native image config the extensions provided. * perf(build): cut unused JDBC driver paths from the native image Substitute driver code that cannot be reached against the databases Floci provisions, mirroring what quarkus-jdbc-mysql did for JMX and going a step further for authentication and multi-host URLs. * perf(build): keep the MySQL cleanup thread disabled in JVM mode quarkus-jdbc-mysql set com.mysql.cj.disableAbandonedConnectionCleanup at startup in JVM mode as well as at native build time. The first commit carried only the native build argument and a surefire copy, so quarkus:dev and the JVM Docker image started Connector/J's abandoned connection cleanup thread on the first MySQL Data API call. In dev mode that thread is recreated with every restart and pins the old classloader. * fix(rdsdata): reject PostgreSQL result types the Data API does not support Aurora PostgreSQL answers a result set that holds a point, interval, money, box, circle, line, lseg, path or polygon column with UnsupportedResultException and the message "The result contains the unsupported data type POINT." Floci returned the driver's toString of the value instead. Check the column type names before reading the rows and raise the same error. json and jsonb stay supported, and a column cast to text still reads as a string, which is the workaround AWS documents. * perf(build): drop the PGobject reflection entries pgjdbc builds point, interval, money and the geometric types through reflection only when a result set holds such a column. The Data API now rejects those columns before reading a row, and json and jsonb values are plain PGobject instances the driver creates directly, so none of the ten entries can be reached. * chore(rdsdata): name the tolerated ClassNotFoundException in OpenTelemetryUnavailable * perf(build): keep PGInterval registered for the Redshift Data API Redshift tables can hold INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND columns and the Redshift Data API returns them as strings. Floci serves that path from a PostgreSQL container through pgjdbc, which builds an interval value by reflection, so the entry stays. The Redshift Data compat test now reads two interval columns on the native image. * perf(build): keep the geometric reflection entries for the Redshift Data API Redshift refuses point, box, circle, lseg, path and polygon as column types but evaluates them in a select, and its Data API returns the values as strings, checked on a real ra3.large cluster. Floci serves that path through pgjdbc, which builds those values by reflection, so the six entries stay. line stays out because Redshift rejects it, and money never reaches PGmoney because pgjdbc reads it as a double. The Redshift Data compat test selects those expressions and expects the strings Redshift returned. JdbcDriverNativeSupportTest resolves every registered class name. * fix(redshiftdata): fail statements that produce line, json or jsonb like Redshift Redshift has none of these types. A select that names one fails with "ERROR: type "line" not yet implemented" or "ERROR: type "json" does not exist", checked on a real cluster. The PostgreSQL container behind Floci's Redshift evaluates them, so the Data API now checks the result column types and fails the statement with the same text.
This commit is contained in:
1 parent
589b1aba9c
commit
569f9f55e4
16 files changed
+522
-9
No files matched your search
+88
@@ -83,6 +83,94 @@ class RedshiftDataOperationsTest {
|
||||
assertThat(result.records().get(0).get(1).stringValue()).isEqualTo("a");
|
||||
}
|
||||
|
||||
/**
|
||||
* Redshift stores INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND columns and the
|
||||
* Data API returns them as strings, checked against a real cluster on 2026-09-13. pgjdbc
|
||||
* builds the value through reflection, so this also checks that the native image keeps
|
||||
* that metadata.
|
||||
*/
|
||||
@Test
|
||||
@DisplayName("interval columns read back as strings")
|
||||
void intervalColumnsReadBackAsStrings() throws Exception {
|
||||
run("CREATE TABLE compat_intervals (y2m interval year to month, d2s interval day to second)");
|
||||
run("INSERT INTO compat_intervals VALUES (interval '1-2' year to month, interval '2 1:0:0' day to second)");
|
||||
|
||||
String selectId = run("SELECT y2m, d2s FROM compat_intervals");
|
||||
GetStatementResultResponse result = data.getStatementResult(GetStatementResultRequest.builder()
|
||||
.id(selectId)
|
||||
.build());
|
||||
|
||||
assertThat(result.totalNumRows()).isEqualTo(1L);
|
||||
assertThat(result.records().get(0).get(0).stringValue()).isEqualTo("1 years 2 mons");
|
||||
// Redshift prints "2 days 1 hours 0 mins 0.0 secs", Floci drops the zero fields.
|
||||
assertThat(result.records().get(0).get(1).stringValue()).isNotEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redshift rejects these as column types but evaluates them in a select, and the Data
|
||||
* API returns them as strings. Values checked against a real ra3.large cluster on
|
||||
* 2026-09-13. pgjdbc builds them through reflection, so this also checks that the
|
||||
* native image keeps that metadata.
|
||||
*/
|
||||
@Test
|
||||
@DisplayName("geometric expressions read back as strings")
|
||||
void geometricExpressionsReadBackAsStrings() throws Exception {
|
||||
String selectId = run("SELECT point(1, 2), box '((0,0),(1,1))', circle '<(0,0),1>', lseg '[(0,0),(1,1)]', "
|
||||
+ "path '[(0,0),(1,1)]', polygon '((0,0),(1,1),(1,0))', '12.34'::money");
|
||||
GetStatementResultResponse result = data.getStatementResult(GetStatementResultRequest.builder()
|
||||
.id(selectId)
|
||||
.build());
|
||||
|
||||
assertThat(result.totalNumRows()).isEqualTo(1L);
|
||||
assertThat(result.columnMetadata()).extracting("typeName")
|
||||
.containsExactly("point", "box", "circle", "lseg", "path", "polygon", "money");
|
||||
assertThat(result.records().get(0).get(0).stringValue()).isEqualTo("(1.0,2.0)");
|
||||
assertThat(result.records().get(0).get(1).stringValue()).isEqualTo("(1.0,1.0),(0.0,0.0)");
|
||||
assertThat(result.records().get(0).get(2).stringValue()).isEqualTo("<(0.0,0.0),1.0>");
|
||||
assertThat(result.records().get(0).get(3).stringValue()).isEqualTo("[(0.0,0.0),(1.0,1.0)]");
|
||||
// Redshift prints path as the server text [(0,0),(1,1)], Floci still prints the driver form.
|
||||
assertThat(result.records().get(0).get(4).stringValue()).isNotEmpty();
|
||||
assertThat(result.records().get(0).get(5).stringValue()).isEqualTo("((0.0,0.0),(1.0,1.0),(1.0,0.0))");
|
||||
assertThat(result.records().get(0).get(6).doubleValue()).isEqualTo(12.34);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error text checked against a real cluster on 2026-09-13.
|
||||
*/
|
||||
@Test
|
||||
@DisplayName("PostgreSQL types Redshift lacks fail the statement with the Redshift error")
|
||||
void typesRedshiftLacksFailTheStatement() throws Exception {
|
||||
assertThat(failure("SELECT line '{1,2,3}'")).isEqualTo("ERROR: type \"line\" not yet implemented");
|
||||
assertThat(failure("SELECT '{\"a\":1}'::json")).isEqualTo("ERROR: type \"json\" does not exist");
|
||||
assertThat(failure("SELECT '{\"a\":1}'::jsonb")).isEqualTo("ERROR: type \"jsonb\" does not exist");
|
||||
}
|
||||
|
||||
private String failure(String sql) throws Exception {
|
||||
String id = submit(sql);
|
||||
Instant deadline = Instant.now().plus(Duration.ofSeconds(30));
|
||||
while (Instant.now().isBefore(deadline)) {
|
||||
DescribeStatementResponse describe = describe(id);
|
||||
if (describe.status() == StatusString.FAILED) {
|
||||
return describe.error();
|
||||
}
|
||||
if (describe.status() == StatusString.FINISHED) {
|
||||
throw new IllegalStateException("Statement " + id + " finished but was expected to fail");
|
||||
}
|
||||
Thread.sleep(250);
|
||||
}
|
||||
throw new IllegalStateException("Statement " + id + " did not finish in time");
|
||||
}
|
||||
|
||||
private String submit(String sql) {
|
||||
return data.executeStatement(ExecuteStatementRequest.builder()
|
||||
.clusterIdentifier(clusterId)
|
||||
.dbUser(USERNAME)
|
||||
.database(DATABASE)
|
||||
.sql(sql)
|
||||
.build())
|
||||
.id();
|
||||
}
|
||||
|
||||
private String run(String sql) throws Exception {
|
||||
String id = data.executeStatement(ExecuteStatementRequest.builder()
|
||||
.clusterIdentifier(clusterId)
|
||||
|
||||
Reference in new issue
Block a user