Fix some derby datasource plugin sql problem.

This commit is contained in:
KomachiSion 2022-10-24 19:53:44 +08:00
parent b637b63bd8
commit 3cf00c7ccb
3 changed files with 24 additions and 22 deletions

View File

@ -20,6 +20,7 @@ server.servlet.contextPath=/nacos
### Include message field ### Include message field
server.error.include-message=ALWAYS server.error.include-message=ALWAYS
### Default web server port: ### Default web server port:
server.port=8848
#*************** Network Related Configurations ***************# #*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf: ### If prefer hostname over ip for Nacos server addresses in cluster.conf:

View File

@ -34,11 +34,11 @@ import java.util.Map;
public class ConfigInfoMapperByDerby implements ConfigInfoMapper { public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
private static final String DATA_ID = "data_id"; private static final String DATA_ID = "dataId";
private static final String GROUP = "group_id"; private static final String GROUP = "group";
private static final String APP_NAME = "app_name"; private static final String APP_NAME = "appName";
private static final String CONTENT = "content"; private static final String CONTENT = "content";
@ -89,7 +89,8 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
@Override @Override
public String findConfigInfoByDataIdAndAppFetchRows(int startRow, int pageSize) { public String findConfigInfoByDataIdAndAppFetchRows(int startRow, int pageSize) {
return "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE data_id = ? AND " return "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE data_id = ? AND "
+ "tenant_id = ? AND app_name = ?" + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"; + "tenant_id = ? AND app_name = ?" + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize
+ " ROWS ONLY";
} }
@Override @Override
@ -190,9 +191,8 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
} }
@Override @Override
public String findChangeConfigFetchRows( public String findChangeConfigFetchRows(Map<String, String> params, final Timestamp startTime,
Map<String, String> params, final Timestamp startTime, final Timestamp endTime, final Timestamp endTime, int startRow, int pageSize, long lastMaxId) {
int startRow, int pageSize, long lastMaxId) {
final String tenant = params.get(TENANT); final String tenant = params.get(TENANT);
final String dataId = params.get(DATA_ID); final String dataId = params.get(DATA_ID);
final String group = params.get(GROUP); final String group = params.get(GROUP);
@ -221,7 +221,7 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
if (endTime != null) { if (endTime != null) {
where += " AND gmt_modified <=? "; where += " AND gmt_modified <=? ";
} }
return sqlFetchRows + where + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"; return sqlFetchRows + where + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
} }
@Override @Override
@ -464,8 +464,8 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
@Override @Override
public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) { public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
return "SELECT id,data_id,group_id,content FROM config_info WHERE data_id=? " return "SELECT id,data_id,group_id,content FROM config_info WHERE data_id=? " + "AND tenant_id=?" + " OFFSET "
+ "AND tenant_id=?" + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"; + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
} }
@Override @Override
@ -518,8 +518,8 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
@Override @Override
public String findConfigInfoBaseByGroupFetchRows(int startRow, int pageSize) { public String findConfigInfoBaseByGroupFetchRows(int startRow, int pageSize) {
return "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? " return "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? " + "AND tenant_id=?" + " OFFSET "
+ "AND tenant_id=?" + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"; + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
} }
@Override @Override
@ -527,7 +527,7 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
final String appName = params.get("appName"); final String appName = params.get("appName");
final String content = params.get("content"); final String content = params.get("content");
final String dataId = params.get("dataId"); final String dataId = params.get("dataId");
final String group = params.get("groupId"); final String group = params.get(GROUP);
final String sqlCountRows = "SELECT count(*) FROM config_info"; final String sqlCountRows = "SELECT count(*) FROM config_info";
StringBuilder where = new StringBuilder(" WHERE "); StringBuilder where = new StringBuilder(" WHERE ");
where.append(" tenant_id LIKE ? "); where.append(" tenant_id LIKE ? ");
@ -629,7 +629,8 @@ public class ConfigInfoMapperByDerby implements ConfigInfoMapper {
@Override @Override
public String findConfigInfoByDataId2Group2Tenant() { public String findConfigInfoByDataId2Group2Tenant() {
return "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE id=?"; return "SELECT id,data_id,group_id,tenant_id,app_name,content,md5,type,encrypted_data_key FROM config_info "
+ "WHERE data_id=? AND group_id=? AND tenant_id=?";
} }
@Override @Override

View File

@ -53,7 +53,7 @@ public class HistoryConfigInfoMapperByDerby implements HistoryConfigInfoMapper {
@Override @Override
public String findConfigHistoryCountRows() { public String findConfigHistoryCountRows() {
return "SELECT count(*) FROM his_config_info WHERE gmt_modified < ?"; return "SELECT count(*) FROM his_config_info WHERE data_id = ? AND group_id = ? AND tenant_id = ?";
} }
@Override @Override