From ff9717ecd679a9111f9a378197ccfaeafb733236 Mon Sep 17 00:00:00 2001
From: wuchubuzai <2009longyu@163.com>
Date: Thu, 15 Dec 2022 10:38:29 +0800
Subject: [PATCH] =?UTF-8?q?[impr]=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=94=B9?=
=?UTF-8?q?=E4=B8=BAnacos2.2=E6=AD=A3=E5=BC=8F=E7=89=88=E7=9A=84postgresql?=
=?UTF-8?q?=E7=9A=84=E6=8F=92=E4=BB=B6=E9=80=82=E9=85=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../nacos-all-datasource-plugin-ext/pom.xml | 30 ------
...alect.java => DefaultDatabaseDialect.java} | 4 +-
.../impl/base/BaseConfigInfoAggrMapper.java | 9 +-
.../impl/base/BaseConfigInfoMapper.java | 92 -------------------
.../impl/base/BaseConfigInfoTagMapper.java | 7 +-
.../base/BaseConfigTagsRelationMapper.java | 46 +---------
.../manager/DatabaseDialectManager.java | 4 +-
....plugin.datasource.dialect.DatabaseDialect | 2 +-
nacos-datasource-plugin-ext/pom.xml | 1 -
pom.xml | 2 +-
10 files changed, 12 insertions(+), 185 deletions(-)
delete mode 100644 nacos-datasource-plugin-ext/nacos-all-datasource-plugin-ext/pom.xml
rename nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/{MysqlDatabaseDialect.java => DefaultDatabaseDialect.java} (89%)
diff --git a/nacos-datasource-plugin-ext/nacos-all-datasource-plugin-ext/pom.xml b/nacos-datasource-plugin-ext/nacos-all-datasource-plugin-ext/pom.xml
deleted file mode 100644
index d9f6875..0000000
--- a/nacos-datasource-plugin-ext/nacos-all-datasource-plugin-ext/pom.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- nacos-datasource-plugin-ext
- com.alibaba.nacos
- ${revision}
-
- 4.0.0
-
- nacos-all-datasource-plugin-ext
-
-
- 8
- 8
-
-
-
-
- com.alibaba.nacos
- nacos-postgresql-datasource-plugin-ext
- ${revision}
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/MysqlDatabaseDialect.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/DefaultDatabaseDialect.java
similarity index 89%
rename from nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/MysqlDatabaseDialect.java
rename to nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/DefaultDatabaseDialect.java
index 95d77d4..e711fd8 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/MysqlDatabaseDialect.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/dialect/DefaultDatabaseDialect.java
@@ -19,10 +19,10 @@
import com.alibaba.nacos.plugin.datasource.constants.DatabaseTypeConstant;
/**
- * mysql database dialect.
+ * defauLT database dialect.
* @author Long Yu
*/
-public class MysqlDatabaseDialect extends AbstractDatabaseDialect {
+public class DefaultDatabaseDialect extends AbstractDatabaseDialect {
@Override
public String getType() {
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoAggrMapper.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoAggrMapper.java
index 3a0e2d1..71163eb 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoAggrMapper.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoAggrMapper.java
@@ -39,14 +39,11 @@ public String getTableName() {
return TableConstant.CONFIG_INFO_AGGR;
}
- public String getLimitPageSqlWithMark(String sql) {
- return databaseDialect.getLimitPageSqlWithMark(sql);
- }
-
@Override
public String findConfigInfoAggrByPageFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithMark("SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
- + "group_id= ? AND tenant_id= ? ORDER BY datum_id ");
+ return databaseDialect.getLimitPageSqlWithOffset(
+ "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
+ + "group_id= ? AND tenant_id= ? ORDER BY datum_id ", startRow, pageSize);
}
}
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoMapper.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoMapper.java
index c645f1d..44f2a86 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoMapper.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoMapper.java
@@ -56,19 +56,6 @@ public String getLimitPageSqlWithMark(String sql) {
return databaseDialect.getLimitPageSqlWithMark(sql);
}
- @Override
- public String findConfigInfoByDataIdFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info "
- + "WHERE data_id = ? AND tenant_id = ? ",startRow, pageSize);
- }
-
-
- @Override
- public String findConfigInfoByDataIdAndAppFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info "
- + "WHERE data_id= ? AND tenant_id= ? AND app_name= ?",startRow, pageSize);
- }
-
@Override
public String findConfigInfoByAppFetchRows(int startRow, int pageSize) {
return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"
@@ -101,14 +88,6 @@ public String findAllConfigInfoBaseFetchRows(int startRow, int pageSize) {
+ " g, config_info t WHERE g.id = t.id ";
}
- @Override
- public String findAllConfigInfoForDumpAllFetchRows(int startRow, int pageSize) {
- String innerSql = getLimitPageSqlWithMark(" SELECT id FROM config_info ORDER BY id ");
- return " SELECT t.id,type,data_id,group_id,tenant_id,app_name,content,type,md5,gmt_modified "
- + " FROM ( " + innerSql + " )"
- + " g, config_info t WHERE g.id = t.id ";
- }
-
@Override
public String findAllConfigInfoFragment(int startRow, int pageSize) {
return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,type,encrypted_data_key "
@@ -156,27 +135,6 @@ public String listGroupKeyMd5ByPageFetchRows(int startRow, int pageSize) {
+ "( " + innerSql + " ) g, config_info t WHERE g.id = t.id";
}
- @Override
- public String findConfigInfoLikeFetchRows(Map params, int startRow, int pageSize) {
- final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE ";
- String where = " 1=1 ";
- if (!StringUtils.isEmpty(params.get(DATA_ID))) {
- where += " AND data_id LIKE ? ";
- }
- if (!StringUtils.isEmpty(params.get(GROUP))) {
- where += " AND group_id LIKE ? ";
- }
- where += " AND tenant_id LIKE ? ";
- if (!StringUtils.isEmpty(params.get(APP_NAME))) {
- where += " AND app_name = ? ";
- }
- if (!StringUtils.isBlank(params.get(CONTENT))) {
- where += " AND content LIKE ? ";
- }
-
- return getLimitPageSqlWithOffset(sqlFetchRows + where, startRow, pageSize);
- }
-
@Override
public String findConfigInfoBaseLikeFetchRows(Map params, int startRow, int pageSize) {
final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,content FROM config_info WHERE ";
@@ -193,17 +151,6 @@ public String findConfigInfoBaseLikeFetchRows(Map params, int st
return getLimitPageSqlWithOffset(sqlFetchRows + where, startRow, pageSize);
}
- @Override
- public String findConfigInfoByDataIdAndAdvanceFetchRows(Map params, int startRow, int pageSize) {
- final String appName = params.get(APP_NAME);
- StringBuilder sql = new StringBuilder(
- "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE data_id=? AND tenant_id=? ");
- if (StringUtils.isNotBlank(appName)) {
- sql.append(" AND app_name=? ");
- }
- return getLimitPageSqlWithOffset(sql.toString(), startRow, pageSize);
- }
-
@Override
public String findConfigInfo4PageFetchRows(Map params, int startRow, int pageSize) {
final String appName = params.get(APP_NAME);
@@ -224,34 +171,6 @@ public String findConfigInfo4PageFetchRows(Map params, int start
return getLimitPageSqlWithOffset(sql + where, startRow, pageSize);
}
- @Override
- public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,content FROM config_info WHERE data_id=? AND tenant_id=? ",startRow, pageSize);
- }
-
- @Override
- public String findConfigInfoByGroupFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE"
- + " group_id=? AND tenant_id=? ",startRow, pageSize);
- }
-
- @Override
- public String findConfigInfoByGroupAndAppFetchRows(int startRow, int pageSize) {
- return getLimitPageSqlWithOffset("SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE "
- + "group_id=? AND tenant_id=? AND app_name =? ",startRow, pageSize);
- }
-
- @Override
- public String findConfigInfoByAdvanceFetchRows(Map params, int startRow, int pageSize) {
- final String appName = params.get("appName");
- StringBuilder sql = new StringBuilder(
- "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE tenant_id LIKE ? ");
- if (StringUtils.isNotBlank(appName)) {
- sql.append(" AND app_name=? ");
- }
- return getLimitPageSqlWithOffset(sql.toString(),startRow, pageSize);
- }
-
@Override
public String findConfigInfoBaseByGroupFetchRows(int startRow, int pageSize) {
String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=? ";
@@ -290,17 +209,6 @@ public String findAllConfigInfoFetchRows(int startRow, int pageSize) {
+ " g, config_info t WHERE g.id = t.id ";
}
- @Override
- public String findConfigInfoByGroupAndAdvanceFetchRows(Map params, int startRow, int pageSize) {
- final String appName = params.get(APP_NAME);
- StringBuilder sql = new StringBuilder(
- "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE group_id=? AND tenant_id=? ");
- if (StringUtils.isNotBlank(appName)) {
- sql.append(" AND app_name=? ");
- }
- return getLimitPageSqlWithOffset(sql.toString(),startRow, pageSize);
- }
-
@Override
public String getTableName() {
return TableConstant.CONFIG_INFO;
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoTagMapper.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoTagMapper.java
index 1753f68..eaf0289 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoTagMapper.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigInfoTagMapper.java
@@ -34,10 +34,6 @@ public BaseConfigInfoTagMapper() {
databaseDialect = DatabaseDialectManager.getInstance().getDialect(getDataSource());
}
- public String getLimitPageSqlWithMark(String sql) {
- return databaseDialect.getLimitPageSqlWithMark(sql);
- }
-
@Override
public String getTableName() {
return TableConstant.CONFIG_INFO_TAG;
@@ -45,7 +41,8 @@ public String getTableName() {
@Override
public String findAllConfigInfoTagForDumpAllFetchRows(int startRow, int pageSize) {
- String innerSql = getLimitPageSqlWithMark("SELECT id FROM config_info_tag ORDER BY id ");
+ String innerSql = databaseDialect.getLimitPageSqlWithOffset("SELECT id FROM config_info_tag ORDER BY id ",
+ startRow, pageSize);
return " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "
+ " FROM ( " + innerSql + " ) "
+ "g, config_info_tag t WHERE g.id = t.id ";
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigTagsRelationMapper.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigTagsRelationMapper.java
index 76a3e33..3d4c658 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigTagsRelationMapper.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/impl/base/BaseConfigTagsRelationMapper.java
@@ -79,29 +79,6 @@ public String findConfigInfo4PageFetchRows(Map params, int tagSi
return getLimitPageSqlWithOffset(sql + where,startRow,pageSize);
}
- @Override
- public String findConfigInfoByGroupAndAdvanceFetchRows(final Map params, int tagSize, int startRow, int pageSize) {
- final String appName = params.get("appName");
- StringBuilder sql = new StringBuilder(
- "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a LEFT JOIN "
- + "config_tags_relation b ON a.id=b.id WHERE a.group_id=? AND a.tenant_id=? ");
-
- sql.append(" AND b.tag_name IN (");
- for (int i = 0; i < tagSize; i++) {
- if (i != 0) {
- sql.append(", ");
- }
- sql.append('?');
- }
- sql.append(") ");
-
- if (StringUtils.isNotBlank(appName)) {
- sql.append(" AND a.app_name=? ");
- }
-
- return getLimitPageSqlWithOffset(sql.toString(),startRow,pageSize);
- }
-
@Override
public String findConfigInfoLike4PageFetchRows(final Map params, int tagSize, int startRow, int pageSize) {
final String appName = params.get("appName");
@@ -134,28 +111,7 @@ public String findConfigInfoLike4PageFetchRows(final Map params,
where.append('?');
}
where.append(") ");
- return getLimitPageSqlWithOffset(sqlFetchRows + where,startRow,pageSize);
- }
-
- @Override
- public String findConfigInfoByAdvanceFetchRows(Map params, int tagSize, int startRow, int pageSize) {
- final String appName = params.get("appName");
- StringBuilder sql = new StringBuilder(
- "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a LEFT JOIN "
- + "config_tags_relation b ON a.id=b.id WHERE a.tenant_id=? ");
- sql.append(" AND b.tag_name IN (");
- for (int i = 0; i < tagSize; i++) {
- if (i != 0) {
- sql.append(", ");
- }
- sql.append('?');
- }
- sql.append(") ");
- if (StringUtils.isNotBlank(appName)) {
- sql.append(" AND a.app_name=? ");
- }
- return getLimitPageSqlWithOffset(sql.toString(),startRow,pageSize);
+ return getLimitPageSqlWithOffset(sqlFetchRows + where, startRow, pageSize);
}
-
}
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/manager/DatabaseDialectManager.java b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/manager/DatabaseDialectManager.java
index 9f94ea5..21a31bc 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/manager/DatabaseDialectManager.java
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/java/com/alibaba/nacos/plugin/datasource/manager/DatabaseDialectManager.java
@@ -18,7 +18,7 @@
import com.alibaba.nacos.common.spi.NacosServiceLoader;
import com.alibaba.nacos.plugin.datasource.dialect.DatabaseDialect;
-import com.alibaba.nacos.plugin.datasource.dialect.MysqlDatabaseDialect;
+import com.alibaba.nacos.plugin.datasource.dialect.DefaultDatabaseDialect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +56,7 @@ private DatabaseDialectManager() {
public DatabaseDialect getDialect(String databaseType) {
DatabaseDialect databaseDialect = SUPPORT_DIALECT_MAP.get(databaseType);
if (databaseDialect == null) {
- return new MysqlDatabaseDialect();
+ return new DefaultDatabaseDialect();
}
return databaseDialect;
}
diff --git a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.dialect.DatabaseDialect b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.dialect.DatabaseDialect
index b4bcbf2..92dc081 100644
--- a/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.dialect.DatabaseDialect
+++ b/nacos-datasource-plugin-ext/nacos-datasource-plugin-ext-base/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.dialect.DatabaseDialect
@@ -15,5 +15,5 @@
#
#
-com.alibaba.nacos.plugin.datasource.dialect.MysqlDatabaseDialect
+com.alibaba.nacos.plugin.datasource.dialect.DefaultDatabaseDialect
diff --git a/nacos-datasource-plugin-ext/pom.xml b/nacos-datasource-plugin-ext/pom.xml
index 4abb9c5..b5986c8 100644
--- a/nacos-datasource-plugin-ext/pom.xml
+++ b/nacos-datasource-plugin-ext/pom.xml
@@ -14,7 +14,6 @@
nacos-datasource-plugin-ext-base
- nacos-all-datasource-plugin-ext
nacos-postgresql-datasource-plugin-ext
diff --git a/pom.xml b/pom.xml
index ba1bb27..3e24f9d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
UTF-8
1.8
1.8
- 2.2.0-BETA
+ 2.2.0
1.1.0
3.2.4
4.12