Skip to content

Commit 0d613d8

Browse files
Merge pull request #21 from actiontech/odc/fix-865
fix(odc): enable PG-family queryTableOrViewData for GaussDB / openGauss
2 parents ac6cf3d + adddc42 commit 0d613d8

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

server/odc-migrate/src/main/resources/migrate/common/R_2_0_0__initialize_version_diff_config.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,15 @@ insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min
275275
'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`;
276276
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`;
277277
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`;
278-
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`;
278+
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`;
279+
280+
-- GaussDB / openGauss column data types (PostgreSQL-compatible)
281+
-- Required so VersionDiffConfigService.getDatatypeList() returns a non-empty list for GAUSSDB sessions.
282+
-- Without this row, session.dataTypes is empty and the column editor's data type dropdown shows no options.
283+
insert into `odc_version_diff_config`(`config_key`,`db_mode`,`config_value`,`min_version`,`gmt_create`) values(
284+
'column_data_type',
285+
'GAUSSDB',
286+
'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',
287+
'1.0',
288+
CURRENT_TIMESTAMP
289+
) ON DUPLICATE KEY UPDATE `config_key`=`config_key`;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ public SqlExecuteResult queryTableOrViewData(@NotNull String sessionId,
184184
asyncExecuteReq.setContinueExecutionOnError(true);
185185
asyncExecuteReq.setFullLinkTraceEnabled(false);
186186
return executeQueryTableOrViewData(sessionId, connectionSession, asyncExecuteReq);
187+
} else if (dialectType.isPgFamily()) {
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();
187199
} else {
188200
throw new IllegalArgumentException("Unsupported dialect type, " + dialectType);
189201
}

0 commit comments

Comments
 (0)