Skip to content

fix(odc): enable PG-family queryTableOrViewData for GaussDB / openGauss#21

Merged
LordofAvernus merged 2 commits into
dev/4.3.4from
odc/fix-865
May 29, 2026
Merged

fix(odc): enable PG-family queryTableOrViewData for GaussDB / openGauss#21
LordofAvernus merged 2 commits into
dev/4.3.4from
odc/fix-865

Conversation

@actiontech-bot
Copy link
Copy Markdown
Member

Summary

This PR routes the GaussDB / openGauss / PostgreSQL dialects (PG family) through the queryTableOrViewData path with the correct identifier quoting style and seeds the GAUSSDB column data-type catalog.

  • Add an isPgFamily() branch in ConnectConsoleService.queryTableOrViewData() that uses OracleSqlBuilder. OracleSqlBuilder.identifier() wraps identifiers with double quotes ("schema"."table"), matching PostgreSQL syntax. The previously-active MySQLSqlBuilder produced back-tick identifiers and triggered SQLState=42601 syntax error at or near "\"` on openGauss / GaussDB.
  • Seed a new column_data_type row for GAUSSDB in the Flyway R_2_0_0__initialize_version_diff_config.sql (uses ON DUPLICATE KEY UPDATE, idempotent B-class seed). Without this row VersionDiffConfigService.getDatatypeList() returns an empty list for GAUSSDB sessions and the column-editor data-type dropdown is blank.

Upstream context: this is part of the cross-repo effort to make the ODC SQL Workbench support GaussDB / openGauss. The DMS side (whitelist + convertDBType mapping + static fallback fix) is being merged in actiontech/dms#631 and the SQLE driver-type contract test in actiontech/sqle#3318.

Test plan

  • go vet-equivalent for Java: mvn -pl server/odc-service -am compile -DskipTests -> BUILD SUCCESS
  • mvn -pl server/odc-service test-compile -DskipTests -> BUILD SUCCESS
  • bash skills/odc/script/odc.sh build-backend -> BUILD SUCCESS, fat-jar contains both MySQLSqlBuilder and OracleSqlBuilder references in ConnectConsoleService.class
  • Sanity check: db-browser DmSqlBuilderTest 24/24 PASS (identifier quoting path)
  • Manual sanity: builders generate SELECT t.* FROM "schema"."table" t LIMIT 1000 for PG-family vs SELECT t.* FROM \schema`.`table` t LIMIT 1000` for MySQL
  • Deploy + port self-check (DMS 10000 / SQLE 10001 / ODC 8989 / DMS-to-ODC /odc_query/api/v1/info?notLogin=true) all responded

Fixes https://github.com/actiontech/dms-ee/issues/865

…ryTableOrViewData

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: actiontech/dms-ee#865
…eOrViewData

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 actiontech/dms-ee#865
@LordofAvernus LordofAvernus merged commit 0d613d8 into dev/4.3.4 May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants