Skip to content

Commit adddc42

Browse files
committed
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 actiontech/dms-ee#865
1 parent ea725c5 commit adddc42

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

server/odc-service/src/main/java/com/oceanbase/odc/service/session/ConnectConsoleService.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,17 @@ public SqlExecuteResult queryTableOrViewData(@NotNull String sessionId,
185185
asyncExecuteReq.setFullLinkTraceEnabled(false);
186186
return executeQueryTableOrViewData(sessionId, connectionSession, asyncExecuteReq);
187187
} else if (dialectType.isPgFamily()) {
188-
// GaussDB / openGauss use PostgreSQL wire protocol. MySQLSqlBuilder generates
189-
// "SELECT t.* FROM schema.table t LIMIT n" which is valid PostgreSQL syntax,
190-
// so it is reused here for PG-family dialects. This also covers POSTGRESQL.
191-
sqlBuilder = new MySQLSqlBuilder();
188+
// GaussDB / openGauss / PostgreSQL use PostgreSQL wire protocol, where identifiers
189+
// are quoted with double quotes (e.g. "schema"."table"), NOT MySQL back-ticks.
190+
// Reusing MySQLSqlBuilder here previously produced
191+
// SELECT t.* FROM `schema`.`table` t LIMIT 1000
192+
// which triggered SQLState=42601 syntax error at or near "`" against openGauss.
193+
// OracleSqlBuilder.identifier() wraps identifiers with '"' (see
194+
// StringUtils.ORACLE_IDENTIFIER_WRAP_CHAR), which is exactly what PG expects.
195+
// Only identifier() / schemaPrefixIfNotBlank() are exercised below, so the rest of
196+
// OracleSqlBuilder's Oracle-specific behavior (value quoting, default values,
197+
// LIKE ESCAPE) is never invoked here and is therefore safe to reuse.
198+
sqlBuilder = new OracleSqlBuilder();
192199
} else {
193200
throw new IllegalArgumentException("Unsupported dialect type, " + dialectType);
194201
}

0 commit comments

Comments
 (0)