From ea725c55680baa7b9e6a48046db9b01702143fed Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Fri, 29 May 2026 03:24:58 +0000 Subject: [PATCH 1/2] fix(odc): register GAUSSDB column data types and enable PG-family queryTableOrViewData Two P0 GaussDB / openGauss issues fixed in a single commit because they are discovered together when opening a table in the Workbench: 1. Bug 4a: column editor "type" dropdown is empty. VersionDiffConfigService.getDatatypeList() returns the rows in odc_version_diff_config keyed by db_mode='GAUSSDB' / config_key= 'column_data_type'. R_2_0_0__initialize_version_diff_config.sql had rows for OB_MYSQL / MYSQL / ORACLE / SQL_SERVER but none for GAUSSDB, so the session's dataTypes list was empty and the column type dropdown rendered no options. Append the GAUSSDB row with the PostgreSQL-compatible type catalog (smallint / integer / decimal / varchar / timestamp / json / ...). R_ prefix is a Flyway repeatable migration; restarting ODC re-applies it. 2. Bug 5: "data" tab fails with 400 "Unsupported dialect type, GAUSSDB". ConnectConsoleService.queryTableOrViewData() picks a SqlBuilder by DialectType but had no branch for GAUSSDB, falling through to the final "Unsupported dialect type" throw. Add an isPgFamily() branch (after isMongoDB()) that reuses MySQLSqlBuilder. The generated "SELECT t.* FROM schema.table t LIMIT n" is valid PostgreSQL syntax, so the same builder works for both GAUSSDB and POSTGRESQL. Refs: https://github.com/actiontech/dms-ee/issues/865 --- .../R_2_0_0__initialize_version_diff_config.sql | 13 ++++++++++++- .../odc/service/session/ConnectConsoleService.java | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/odc-migrate/src/main/resources/migrate/common/R_2_0_0__initialize_version_diff_config.sql b/server/odc-migrate/src/main/resources/migrate/common/R_2_0_0__initialize_version_diff_config.sql index 04c7dbb484..7c4caaf92d 100644 --- a/server/odc-migrate/src/main/resources/migrate/common/R_2_0_0__initialize_version_diff_config.sql +++ b/server/odc-migrate/src/main/resources/migrate/common/R_2_0_0__initialize_version_diff_config.sql @@ -275,4 +275,15 @@ insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min 'bit:NUMERIC, tinyint:NUMERIC, smallint:NUMERIC, int:NUMERIC, bigint:NUMERIC, decimal:NUMERIC, numeric:NUMERIC, float:NUMERIC, real:NUMERIC, money:NUMERIC, smallmoney:NUMERIC, char:TEXT, varchar:TEXT, nchar:TEXT, nvarchar:TEXT, text:OBJECT, ntext:OBJECT, binary:TEXT, varbinary:TEXT, image:OBJECT, date:DATE, time:TIME, datetime:DATETIME, datetime2:DATETIME, smalldatetime:DATETIME, datetimeoffset:TIMESTAMP, timestamp:OBJECT, uniqueidentifier:OBJECT, xml:OBJECT, sql_variant:OBJECT, hierarchyid:OBJECT, geography:OBJECT, geometry:OBJECT', '0', CURRENT_TIMESTAMP) ON DUPLICATE KEY update `config_key`=`config_key`; insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values('support_view','SQL_SERVER','true','0',CURRENT_TIMESTAMP) ON DUPLICATE KEY update `config_key`=`config_key`; insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values('support_procedure','SQL_SERVER','true','0',CURRENT_TIMESTAMP) ON DUPLICATE KEY update `config_key`=`config_key`; -insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values('support_function','SQL_SERVER','true','0',CURRENT_TIMESTAMP) ON DUPLICATE KEY update `config_key`=`config_key`; \ No newline at end of file +insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values('support_function','SQL_SERVER','true','0',CURRENT_TIMESTAMP) ON DUPLICATE KEY update `config_key`=`config_key`; + +-- GaussDB / openGauss column data types (PostgreSQL-compatible) +-- Required so VersionDiffConfigService.getDatatypeList() returns a non-empty list for GAUSSDB sessions. +-- Without this row, session.dataTypes is empty and the column editor's data type dropdown shows no options. +insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values( + 'column_data_type', + 'GAUSSDB', + 'smallint:NUMERIC, integer:NUMERIC, int:NUMERIC, bigint:NUMERIC, decimal:NUMERIC, numeric:NUMERIC, real:NUMERIC, float:NUMERIC, serial:NUMERIC, bigserial:NUMERIC, char:TEXT, varchar:TEXT, text:OBJECT, bytea:OBJECT, boolean:NUMERIC, date:DATE, time:TIME, timestamp:TIMESTAMP, timestamptz:TIMESTAMP, interval:TEXT, json:OBJECT, jsonb:OBJECT, uuid:OBJECT', + '1.0', + CURRENT_TIMESTAMP +) ON DUPLICATE KEY UPDATE `config_key`=`config_key`; \ No newline at end of file diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java index 725259ceea..1684732300 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java @@ -184,6 +184,11 @@ public SqlExecuteResult queryTableOrViewData(@NotNull String sessionId, asyncExecuteReq.setContinueExecutionOnError(true); asyncExecuteReq.setFullLinkTraceEnabled(false); return executeQueryTableOrViewData(sessionId, connectionSession, asyncExecuteReq); + } else if (dialectType.isPgFamily()) { + // GaussDB / openGauss use PostgreSQL wire protocol. MySQLSqlBuilder generates + // "SELECT t.* FROM schema.table t LIMIT n" which is valid PostgreSQL syntax, + // so it is reused here for PG-family dialects. This also covers POSTGRESQL. + sqlBuilder = new MySQLSqlBuilder(); } else { throw new IllegalArgumentException("Unsupported dialect type, " + dialectType); } From adddc42f401fa73a34d3ccc6d7ec81fb9b7486b9 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Fri, 29 May 2026 05:40:59 +0000 Subject: [PATCH 2/2] fix(odc): use double-quote identifier quoting for PG-family queryTableOrViewData Previously the PG-family branch in ConnectConsoleService.queryTableOrViewData reused MySQLSqlBuilder, which wraps identifiers with back-ticks (`schema`.`table`). openGauss / GaussDB / PostgreSQL reject back-ticks and return SQLState=42601 syntax error at or near "`" when a user clicks the table 'Data' tab. Switch the PG-family branch to OracleSqlBuilder, whose identifier() wraps with ASCII double quotes ("schema"."table"), which is the canonical PostgreSQL identifier-quoting style. Only identifier() / schemaPrefixIfNotBlank() are used in this code path; OracleSqlBuilder's other Oracle-specific behaviors (value quoting, default values, LIKE ESCAPE) are not invoked here, so the reuse is safe. Fixes https://github.com/actiontech/dms-ee/issues/865 --- .../service/session/ConnectConsoleService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java index 1684732300..d740fc8df4 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java @@ -185,10 +185,17 @@ public SqlExecuteResult queryTableOrViewData(@NotNull String sessionId, asyncExecuteReq.setFullLinkTraceEnabled(false); return executeQueryTableOrViewData(sessionId, connectionSession, asyncExecuteReq); } else if (dialectType.isPgFamily()) { - // GaussDB / openGauss use PostgreSQL wire protocol. MySQLSqlBuilder generates - // "SELECT t.* FROM schema.table t LIMIT n" which is valid PostgreSQL syntax, - // so it is reused here for PG-family dialects. This also covers POSTGRESQL. - sqlBuilder = new MySQLSqlBuilder(); + // GaussDB / openGauss / PostgreSQL use PostgreSQL wire protocol, where identifiers + // are quoted with double quotes (e.g. "schema"."table"), NOT MySQL back-ticks. + // Reusing MySQLSqlBuilder here previously produced + // SELECT t.* FROM `schema`.`table` t LIMIT 1000 + // which triggered SQLState=42601 syntax error at or near "`" against openGauss. + // OracleSqlBuilder.identifier() wraps identifiers with '"' (see + // StringUtils.ORACLE_IDENTIFIER_WRAP_CHAR), which is exactly what PG expects. + // Only identifier() / schemaPrefixIfNotBlank() are exercised below, so the rest of + // OracleSqlBuilder's Oracle-specific behavior (value quoting, default values, + // LIKE ESCAPE) is never invoked here and is therefore safe to reuse. + sqlBuilder = new OracleSqlBuilder(); } else { throw new IllegalArgumentException("Unsupported dialect type, " + dialectType); }