From e342e7f37dd7ade84945ec59633e2bec46d3671e Mon Sep 17 00:00:00 2001 From: User Date: Fri, 22 Aug 2025 10:47:00 +0800 Subject: [PATCH] Improve Apache Doris and StarRocks detection logic - Use VERSION() = '5.7.99' as primary Doris fingerprint (more reliable than BITMAP functions) - Add @@VERSION_COMMENT checks for both Doris and StarRocks - Add StarRocks fork detection to avoid misidentification - Remove unreliable BITMAP_UNION_COUNT() as sole detection method This addresses the issue where BITMAP_UNION_COUNT() alone could misidentify StarRocks or other bitmap-compatible systems as Doris. The new multi-step detection logic provides more accurate database identification. --- lib/core/enums.py | 1 + lib/core/settings.py | 2 +- plugins/dbms/mysql/fingerprint.py | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/core/enums.py b/lib/core/enums.py index 6e5f65c1e..40131d149 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -109,6 +109,7 @@ class FORK(object): OPENGAUSS = "OpenGauss" DM8 = "DM8" DORIS = "Doris" + STARROCKS = "StarRocks" class CUSTOM_LOGGING(object): PAYLOAD = 9 diff --git a/lib/core/settings.py b/lib/core/settings.py index 1367e4d44..7f04d3320 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -295,7 +295,7 @@ VIRTUOSO_SYSTEM_DBS = ("",) # Note: () + () MSSQL_ALIASES = ("microsoft sql server", "mssqlserver", "mssql", "ms") -MYSQL_ALIASES = ("mysql", "my") + ("mariadb", "maria", "memsql", "tidb", "percona", "drizzle", "doris") +MYSQL_ALIASES = ("mysql", "my") + ("mariadb", "maria", "memsql", "tidb", "percona", "drizzle", "doris", "starrocks") PGSQL_ALIASES = ("postgresql", "postgres", "pgsql", "psql", "pg") + ("cockroach", "cockroachdb", "amazon redshift", "redshift", "greenplum", "yellowbrick", "enterprisedb", "yugabyte", "yugabytedb", "opengauss") ORACLE_ALIASES = ("oracle", "orcl", "ora", "or") SQLITE_ALIASES = ("sqlite", "sqlite3") diff --git a/plugins/dbms/mysql/fingerprint.py b/plugins/dbms/mysql/fingerprint.py index b61a47666..8647bd266 100644 --- a/plugins/dbms/mysql/fingerprint.py +++ b/plugins/dbms/mysql/fingerprint.py @@ -105,8 +105,12 @@ class Fingerprint(GenericFingerprint): fork = FORK.PERCONA elif inject.checkBooleanExpression("AURORA_VERSION() LIKE '%'"): # Reference: https://aws.amazon.com/premiumsupport/knowledge-center/aurora-version-number/ fork = FORK.AURORA - elif inject.checkBooleanExpression("BITMAP_UNION_COUNT(NULL) IS NULL"): # Reference: Apache Doris specific BITMAP functions + elif inject.checkBooleanExpression("VERSION() LIKE '5.7.99'"): # Reference: Apache Doris returns fixed version 5.7.99 for MySQL compatibility fork = FORK.DORIS + elif inject.checkBooleanExpression("@@VERSION_COMMENT LIKE '%Doris%'"): # Reference: Apache Doris version comment contains 'Doris' + fork = FORK.DORIS + elif inject.checkBooleanExpression("@@VERSION_COMMENT LIKE '%StarRocks%'"): # Reference: StarRocks version comment contains 'StarRocks' + fork = FORK.STARROCKS else: fork = ""