diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedStoragePersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedStoragePersistServiceImpl.java index 8295357a5e2..50f17f599c1 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedStoragePersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedStoragePersistServiceImpl.java @@ -940,8 +940,8 @@ public ConfigInfo findConfigInfo(long id) { public ConfigInfoWrapper findConfigInfo(final String dataId, final String group, final String tenant) { final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant; ConfigInfoMapper configInfoMapper = (ConfigInfoMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO).get(); - final String sql = configInfoMapper.select(Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content"), - Collections.singletonList("id")); + final String sql = configInfoMapper.select(Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "type", "encrypted_data_key"), + Arrays.asList("data_id", "group_id", "tenant_id")); final Object[] args = new Object[] {dataId, group, tenantTmp}; return databaseOperate.queryOne(sql, args, CONFIG_INFO_WRAPPER_ROW_MAPPER); @@ -1273,7 +1273,7 @@ public int aggrConfigInfoCount(String dataId, String group, String tenant, List< } final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant; ConfigInfoAggrMapper configInfoAggrMapper = (ConfigInfoAggrMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO_AGGR).get(); - String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds, isIn); + String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds.size(), isIn); List objectList = com.alibaba.nacos.common.utils.CollectionUtils.list(dataId, group, tenantTmp); objectList.addAll(datumIds); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalStoragePersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalStoragePersistServiceImpl.java index c059acc6770..169b54b28b8 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalStoragePersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalStoragePersistServiceImpl.java @@ -1278,7 +1278,7 @@ public int aggrConfigInfoCount(String dataId, String group, String tenant, List< } final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant; ConfigInfoAggrMapper configInfoAggrMapper = (ConfigInfoAggrMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO_AGGR).get(); - String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds, isIn); + String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds.size(), isIn); List objectList = com.alibaba.nacos.common.utils.CollectionUtils.list(dataId, group, tenantTmp); objectList.addAll(datumIds); Integer result = jt.queryForObject(sql, Integer.class, objectList.toArray()); diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoAggrMapperByDerby.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoAggrMapperByDerby.java index e8483f762cf..09c9bef8d7e 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoAggrMapperByDerby.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoAggrMapperByDerby.java @@ -38,12 +38,12 @@ public String batchRemoveAggr(List datumList) { datumString.append('\'').append(datum).append("',"); } datumString.deleteCharAt(datumString.length() - 1); - return "DELETE FROM config_info_aggr WHERE data_id=? AND group_id=? AND tenant_id=? AND datum_id IN (" + return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN (" + datumString.toString() + ")"; } @Override - public String aggrConfigInfoCount(List datumIds, boolean isIn) { + public String aggrConfigInfoCount(int size, boolean isIn) { StringBuilder sql = new StringBuilder( " SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id"); if (isIn) { @@ -51,7 +51,7 @@ public String aggrConfigInfoCount(List datumIds, boolean isIn) { } else { sql.append(" NOT IN ("); } - for (int i = 0, size = datumIds.size(); i < size; i++) { + for (int i = 0; i < size; i++) { if (i > 0) { sql.append(", "); } @@ -69,8 +69,8 @@ public String aggrConfigInfoCount() { @Override public String findConfigInfoAggr() { - return "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 "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"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerby.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerby.java index ac3e9aea926..1bf49235a5a 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerby.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerby.java @@ -31,8 +31,8 @@ public class ConfigInfoBetaMapperByDerby extends AbstractMapper implements Confi @Override public String updateConfigInfo4BetaCas() { - return "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=? " - + "WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')"; + return "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerby.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerby.java index 8a8a99ac305..dc4b6b130e8 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerby.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerby.java @@ -31,8 +31,8 @@ public class ConfigInfoTagMapperByDerby extends AbstractMapper implements Config @Override public String updateConfigInfo4TagCas() { - return "UPDATE config_info_tag SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=? " - + "WHERE data_id=? AND group_id=? AND tenant_id=? AND tag_id=? AND (md5=? OR md5 IS NULL OR md5='')"; + return "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoAggrMapperByMySql.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoAggrMapperByMySql.java index 0f6d7c0b666..af30fb7dcd7 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoAggrMapperByMySql.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoAggrMapperByMySql.java @@ -37,12 +37,13 @@ public String batchRemoveAggr(List datumList) { for (String datum : datumList) { datumString.append('\'').append(datum).append("',"); } + datumString.deleteCharAt(datumString.length() - 1); return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN (" + datumString.toString() + ")"; } @Override - public String aggrConfigInfoCount(List datumIds, boolean isIn) { + public String aggrConfigInfoCount(int size, boolean isIn) { StringBuilder sql = new StringBuilder( " SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id"); if (isIn) { @@ -50,7 +51,7 @@ public String aggrConfigInfoCount(List datumIds, boolean isIn) { } else { sql.append(" NOT IN ("); } - for (int i = 0, size = datumIds.size(); i < size; i++) { + for (int i = 0; i < size; i++) { if (i > 0) { sql.append(", "); } @@ -69,7 +70,7 @@ public String aggrConfigInfoCount() { @Override public String findConfigInfoAggr() { return "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"; + + "config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY datum_id"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySql.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySql.java index 26dea9943d2..182a5ae5d44 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySql.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySql.java @@ -31,8 +31,8 @@ public class ConfigInfoBetaMapperByMySql extends AbstractMapper implements Confi @Override public String updateConfigInfo4BetaCas() { - return "UPDATE config_info_beta SET content= ?, md5= ?, beta_ips= ?, src_ip= ?,src_user= ?,gmt_modified= ?,app_name= ? " - + " WHERE data_id= ? AND group_id= ? AND tenant_id= ? AND (md5= ? or md5 is null or md5='')"; + return "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? or md5 is null or md5 = '')"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySql.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySql.java index 0b42d772e3c..6337284e33b 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySql.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySql.java @@ -31,8 +31,8 @@ public class ConfigInfoTagMapperByMySql extends AbstractMapper implements Config @Override public String updateConfigInfo4TagCas() { - return "UPDATE config_info_tag SET content= ?, md5 = ?, src_ip= ?,src_user= ?,gmt_modified= ?,app_name= ? WHERE " - + "data_id= ? AND group_id= ? AND tenant_id= ? AND tag_id= ? AND (md5= ? or md5 is null or md5='')"; + return "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')"; } @Override diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/AbstractMapper.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/AbstractMapper.java index 89007255768..7cf525113c5 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/AbstractMapper.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/AbstractMapper.java @@ -119,9 +119,9 @@ public String update(List columns, List where) { public String delete(List params) { StringBuilder sql = new StringBuilder(); String method = "DELETE "; - sql.append(method).append(" FROM ").append(getTableName()).append(" "); + sql.append(method).append(" FROM ").append(getTableName()).append(" ").append("WHERE "); for (int i = 0; i < params.size(); i++) { - sql.append(params.get(i)).append(" "); + sql.append(params.get(i)).append(" ").append("=").append(" ? "); if (i != params.size() - 1) { sql.append("AND "); } diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoAggrMapper.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoAggrMapper.java index b557d04c710..a6847702efe 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoAggrMapper.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoAggrMapper.java @@ -41,11 +41,11 @@ public interface ConfigInfoAggrMapper extends Mapper { * The default sql: * SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? * - * @param datumIds datum id list - * @param isIn search condition + * @param size datum id list size + * @param isIn search condition * @return The sql of getting count of aggregation config info. */ - String aggrConfigInfoCount(List datumIds, boolean isIn); + String aggrConfigInfoCount(int size, boolean isIn); /** * Get count of aggregation config info.