jiangxt2 commented on code in PR #11731:
URL: https://github.com/apache/gravitino/pull/11731#discussion_r3496807088
##########
catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java:
##########
@@ -228,28 +234,153 @@ private static void validateDistribution(Distribution
distribution, JdbcColumn[]
}
}
+ /**
+ * Validates that the Doris server version supports AUTO_INCREMENT columns.
AUTO_INCREMENT was
+ * introduced in Doris 2.1.0. On older versions, the SQL parser does not
recognize the
+ * AUTO_INCREMENT keyword and returns a syntax error.
+ */
+ private void validateAutoIncrementVersion(JdbcColumn[] columns) {
+ boolean hasAutoIncrement =
Arrays.stream(columns).anyMatch(Column::autoIncrement);
+ if (!hasAutoIncrement) {
+ return;
+ }
+ Preconditions.checkState(dataSource != null, "dataSource is required for
version validation");
+ String version = null;
+ try (Connection connection = dataSource.getConnection();
+ Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT VERSION()")) {
Review Comment:
Thanks for catching this! I've pushed a fix.
**Why `SELECT VERSION()` returns `5.7.99`**: This is actually a Doris design
choice, not a Gravitino bug. Doris hardcodes `5.7.99` as the MySQL protocol
version (see `GlobalVariable.java` and `MysqlHandshakePacket.java`) to:
1. Maintain MySQL JDBC driver compatibility (protocol v10)
2. Prevent vulnerability scanners from falsely reporting MySQL CVEs (patch
99 exceeds the real MySQL 5.7 range of 5.7.0–5.7.44, so scanners can't match it
to known vulnerabilities)
The consequence is that `SELECT VERSION()` is fundamentally unreliable for
Doris version detection — it always returns `5.7.99` regardless of the actual
Doris version.
**Fix**: Replaced `SELECT VERSION()` with `SHOW FRONTENDS`, which returns
the actual Doris version in the `Version` column (e.g.
`doris-3.0.6.2-rc01-910c4249c5`). Extracted using regex `(\d+\.\d+\.\d+\.?\d*)`
to handle both 3-part (`1.2.2`) and 4-part (`3.0.6.2`) formats.
Also addressed the BITMAP backward compatibility concern: omit the `USING`
clause entirely, letting each Doris version apply its own default (1.2.x →
BITMAP, 3.0+/4.0+ → INVERTED).
Verified on all three local Doris clusters (1.2.2, 3.0.6.2, 4.0.6):
```
Unit tests: ✅
CatalogDorisIT (1.2.x): ✅
CatalogDoris3xIT (3.0.6.2): ✅
CatalogDoris4xIT (4.0.6): ✅
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]